/* ---------------------------------------------------- */
/*		Navigation Dropdowns
/* ---------------------------------------------------- */

$(function() {

    $('#nav ul').css('width', 'auto');
    $('#header').after('<div class="subnav-background"></div>');

    $('#nav li').hover(function() {
        $(this).children('ul').hide().stop(true, true).slideDown(200);
    }, function() {
        $(this).children('ul').stop(true, true).fadeOut(0, function() {
            $('.subnav-background').slideUp(200);
            //$('#header').removeClass('active');
        });
    });

    $('#nav li').hover(function() {
        if( $(this).children('ul').length > 0 ) {
            var containerWidth = $('.container').width(),
            subWidth = $(this).children('ul').width(),
            pos = $(this).position(),
            left = containerWidth - subWidth - ( pos.left + ( $(this).width() / 2 )),
            margin = ( $(this).children('ul').children('li').size() - 1 ) * 30;
				
            $(this).children('ul').css('right', left+margin);
            $(this).addClass('hover');
            $('.subnav-background').stop(true, true).slideDown(200);
            //$('#header').addClass('active');
        }
    }, function() {
        $(this).removeClass('hover');
		
    });
});

/* end Navigation Dropdowns */

/* ---------------------------------------------------- */
/*		Input Placeholders
/* ---------------------------------------------------- */

$(function() {
    $('[placeholder]').focus(function() {
        var input = $(this);
        if (input.val() == input.attr('placeholder')) {
            input.val('');
            input.removeClass('placeholder');
        }
    }).blur(function() {
        var input = $(this);
        if (input.val() == '' || input.val() == input.attr('placeholder')) {
            input.addClass('placeholder');
            input.val(input.attr('placeholder'));
        }
    }).blur().parents('form').submit(function() {
        $(this).find('[placeholder]').each(function() {
            var input = $(this);
            if (input.val() == input.attr('placeholder')) {
                input.val('');
            }
        })
    });
})

/* end Input Placeholders */

/* ---------------------------------------------------- */
/*		Homepage Project Grid
/* ---------------------------------------------------- */

$(function(){
    $('#projects-slider').gridnav({
        rows	: 2,
                    type	: {
                        mode		: 'rows', 		// use def | fade | seqfade | updown | sequpdown | showhide | disperse | rows
                        speed		: 500,			// for fade, seqfade, updown, sequpdown, showhide, disperse, rows
                        easing		: 'jswing',		// for fade, seqfade, updown, sequpdown, showhide, disperse, rows	
                        factor		: 50,			// for seqfade, sequpdown, rows
                        reverse		: false,		// for sequpdown
                        timeout		: 6000
                    }
    });
});

/* end Homepage Project Grid */

function displayloading(){
    $(document.body).prepend("<div id='loading'></div>");
}
        
function hideloading(){
    $("#loading").remove();
}

$(".imgmanager").live("click",function(){
    var imgwin = window.open ("images.php", "imagewindow","location=1,status=1,scrollbars=1, width=990,height=700,resizable=0");
    var elementid = $(this).data("element");
    imgwin.windowElement = document.getElementById(elementid);
     return false;
});

$(".delete").live("click",function(){
	return confirm("Are you sure you want to Delete it?");
});
/* end Content Tabs */
