

// This is the wait function .......... begin
 $.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
// This is the wait function .......... end


function animate_nav_position_reset (selector_target)
{
    $(selector_target).wait(100)
    .animate({backgroundPosition:"(0px 0px)"}, {duration:100})
    .animate({backgroundPosition:"(0px -210px)", textHeight:"20px"}, {duration:100})
    .animate({backgroundPosition:"(0px -225px)"}, {duration:100})
}

function animate_position_1 (selector_target)
{
    $(selector_target).stop()
    .animate({backgroundPosition:"(0px 0px)"}, {duration:150})
    .animate({backgroundPosition:"(0px -210px)", textHeight:"30px"}, {duration:250})
    .animate({backgroundPosition:"(0px -210px)"}, {duration:150})
}



function animate_position_3 (selector_target)
{
			$(selector_target).stop()
			.animate({backgroundPosition:"(0px 0px)"}, {duration:150})
			.animate({backgroundPosition:"(0px -210px)"}, {duration:250})
			.animate({backgroundPosition:"(0px -210px)"}, {duration:150})
}



function cascade (selector_target,time)
{
		time = 50;
		
			$(selector_target).each(function(i){
			time = (time + 80);
			$(this).wait(time)
			.animate({backgroundPosition:"(0px 0px)"}, {duration:150})
			.animate({backgroundPosition:"(0px -210px)"}, {duration:250})
			.animate({backgroundPosition:"(0px -225px)"}, {duration:150});
			});
			
			

}



function cascade_top (selector_target,time)
{
 		time = 50;
 		$(selector_target).wait(50);
 		
 			$(selector_target).each(function(i){
 			time = (time + 80);
 			time_2 = (time + 50);
 			$(this)
 			.wait(time_2).slideDown(50)
 			.wait(time_2).slideUp(50)
 			});
 			
			

}


function fullscreen(section)
{
window.open('#','kyscorp','toolbar=no,navigationbar=no;menu=0,menubar=0,status=0,copyhistory=0,resizable=0,location=0,width='+screen.width+',height='+screen.height+',top=0,left=0');
}

function load_nav_jquery (section)
{
$(function(){

	$('#a a')
		.css( {backgroundPosition: "0px -225px"} )
		.mouseover(function(){
            animate_position_1(this);
			$(section).animate({backgroundPosition:"(0px -60px)"}, {duration:1000});
        })

		.mouseout(function(){
			animate_nav_position_reset(this);
			$(section).animate({backgroundPosition:"(0px -60px)"}, {duration:1000});

		})
		

 		.mouseup(function(){
             animate_position_3(this);
			$(section).animate({backgroundPosition:"(0px -60px)"}, {duration:1000});
 		})
 		
        cascade_top('.top_effect');
       	cascade('.nav');
       	
       	$(section).animate({backgroundPosition:"(0px -370px)"}, {duration:1000});
 
 		$('#nav_bar').css({marginTop: "-30px"}).animate({marginTop: "0px"},1000);
 		$('#white_stripe').css({width: "0px"}).animate({width: "1000px"},1000);
				
});

}



