	
                
//DROPDOWN             
function init_dropdown(){
                //Does element exist?
                if (!$('ul.dropdown').length){
                                return;
                }
                
                $('ul.dropdown li.dropdown_trigger').hover(function(){
                                $(this).find('ul').fadeIn(1);
                },
                function(){
                                $(this).find('ul').hide();
                });
}
	


//ROLLOVER
function init_rollover(){
                //add classes and id's where image rollovers are required
                // Preload all rollovers
                $("#nav img,.home_block_left img, .roll img").each(function() {
                        // Set the original src
                        rollsrc = $(this).attr("src");
                        rollON = rollsrc.replace(/.gif$/ig,"_over.gif");
                        $("<img>").attr("src", rollON);
                });
                
                // Navigation rollovers
                $("#nav a,  .roll a").mouseover(function(){
                        imgsrc = $(this).children("img").attr("src");
                        matches = (imgsrc.match(/_over/) || imgsrc.match(/_on/));
                        
                        // don't do the rollover if state is already ON
                        if (!matches) {
                        imgsrcON = imgsrc.replace(/.gif$/ig,"_over.gif"); // strip off extension
                        $(this).children("img").attr("src", imgsrcON);
                        }
                        
                });
                $("#nav a, .home_block_left a,.roll a").mouseout(function(){
                        $(this).children("img").attr("src", imgsrc);
                });
      
                
}

function init_rotator(){
//Does element exist?
if(!$('#rotator').length){
                return;
}

var speed = 2000;

var pause = false;

function rotate(element){
                if(pause){
                                return;
                }
var $next_li = $(element).next('li').length ?
                $(element).next('li'):
                $('#rotator li:first');

var $next_a = $('#rotator_controls a.current').parent('li').next('li').length?
                $('#rotator_controls a.current').parent('li').next('li').find('a'):
                $('#rotator_controls a:first');



//Animate
$('#rotator_controls a.current').removeClass('current');
$next_a.addClass('current');

function doIt(){
                rotate($next_li);
}

$(element).fadeOut(speed);

$($next_li).fadeIn(speed, function(){
                setTimeout(doIt,speed);
});
}


$('#rotator_controls a').click(function(){
                
                $('#rotator_play_pause').html('PLAY');
                
                $($(this).attr('href')).show().siblings('li').hide();
                
                $(this).addClass('current').parent('li').siblings('li').find('a').removeClass('current');;
                
                pause = true;
                
                this.blur();
                return false;
});

$('rotator_play_pause').click(function(){
                if ($(this).html() ==='PAUSE'){
                                pause = true;
                                
                                $(this).html('PLAY');
                }else{
                                pause = false;
                                
                                rotate('#rotator li:visible:first');
                                $(this).html('PAUSE');
                }
                this.blur();
                return false;

});

$('#rotator li:first').siblings('li').hide();

$(window).load(function(){
                rotate($('#rotator li:visible:first'));
});


}


function init_kgsanimation(){
                $('#photo_1,#photo_2,#photo_3,#arrow_1,#arrow_2,#arrow_3').hide(); 
                $('#photo_1').fadeIn(2000).animate({opacity:0,width:137,height:112,left:80,top:10},800,function(){
                $('#photo_2').fadeIn(2000).animate({opacity:0,width:137,height:112,left:265,top:90},800,function(){
                $('#photo_3').fadeIn(2000).animate({opacity:0,width:137,height:112,left:0,top:160},800,function(){
                $('#photo_1').animate({opacity:1},100,function(){
                $('#arrow_1').fadeIn(100,function(){
                $('#photo_2').animate({opacity:1},100,function(){
                $('#arrow_2').fadeIn(100,function(){
                $('#photo_3').animate({opacity:1},100,function(){                                
                $('#arrow_3').fadeIn(100,function(){
                   setInterval(swell_effect,20);             
                });
                });                
                });
                });               
                });
                });
                });
                });
                });
                 
}







function init_kgsanimation2(){
                //first fade process
                $('#photo_1,#photo_2,#photo_3,#arrow_1,#arrow_2,#arrow_3').hide(); 
                $('#photo_1').css('left','60px').fadeIn(2000).animate({opacity:0,width:137,height:112,left:120,top:10},800);
                $('#photo_2').css('left','60px').delay(2500).fadeIn(2000).animate({opacity:0,width:137,height:112,left:270,top:90},800);
                $('#photo_3').css('left','60px').delay(5000).fadeIn(2000).animate({opacity:0,width:137,height:112,left:45,top:160},800,function(){
                                
                $('#photo_1').animate({opacity:1},200);
                $('#arrow_1').delay(200).fadeIn(200);
                $('#photo_2').delay(250).animate({opacity:1},200);
                $('#arrow_2').delay(300).fadeIn(200);
                $('#photo_3').delay(350).animate({opacity:1},200);                             
                $('#arrow_3').delay(400).fadeIn(200);
                });
}


function swell_effect(){
                var i = 0;
                //if(notnull){
                   $('#rotator_wrapper img:eq(0)').animate({width:190,height:150},{duration: 400,easing: 'easeInOutCirc'});
                   $('#rotator_wrapper img:eq(0)').animate({width:170,height:130},{duration: 400,easing: 'easeInOutCirc'});
                }


$(document).ready(function() {
//CODE START	

init_rollover();
init_dropdown();
//init_rotator();

init_kgsanimation2();

//CODE END
});
