// JavaScript Document



$(document).ready(function() {

$('a.title1').click(function(){

// get the ID of the image to fade in
var targetID = $(this).attr("id").replace("title1_", "movtitle1_");


// if there are any active images in the container
if ($('#imageContainer1 img.active').length > 0){

// fade them out (and remove the flag)
$('#imageContainer1 img.active').fadeOut(100, function(){

// when the fade out is done, fade in the new image and flag it
$('#'+targetID).fadeIn('normal').addClass('active');

}).removeClass('active');

//	if there aren't any active images
}else{

$('#'+targetID).fadeIn('normal').addClass('active'); 


}

});

});


$(document).ready(function() {

$('a.title2').click(function(){

// get the ID of the image to fade in
var targetID = $(this).attr("id").replace("title2_", "movtitle2_");


// if there are any active images in the container
if ($('#imageContainer2 img.active').length > 0){

// fade them out (and remove the flag)
$('#imageContainer2 img.active').fadeOut(100, function(){

// when the fade out is done, fade in the new image and flag it
$('#'+targetID).fadeIn('normal').addClass('active');

}).removeClass('active');

//	if there aren't any active images
}else{

$('#'+targetID).fadeIn('normal').addClass('active');

}

});

});


$(document).ready(function() {

$('a.title3').click(function(){

// get the ID of the image to fade in
var targetID = $(this).attr("id").replace("title3_", "movtitle3_");


// if there are any active images in the container
if ($('#imageContainer3 img.active').length > 0){

// fade them out (and remove the flag)
$('#imageContainer3 img.active').fadeOut(100, function(){

// when the fade out is done, fade in the new image and flag it
$('#'+targetID).fadeIn('normal').addClass('active');

}).removeClass('active');

//	if there aren't any active images
}else{

$('#'+targetID).fadeIn('normal').addClass('active');

}

});

});






//JS TO ROTATE DIV"S  - SPEED
	$(document).ready(function(){
		$("#rotator > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 6000, true);
	});



//#########################################
//#########################################
//
//        SMALL IMAGE ROTATER #1
//
//#########################################
//#########################################
	var currentImage;
    var currentIndex = -1;
    var interval;
    function showImage(index){
        if(index < $('#bigPic img').length){
        	var indexImage = $('#bigPic img')[index]
            if(currentImage){   
            	if(currentImage != indexImage ){
                    $(currentImage).css('z-index',2);
                    clearTimeout(myTimer);
                    $(currentImage).fadeOut('slow', function() {
					    myTimer = setTimeout("showNext()", 4000);
					    $(this).css({'display':'none','z-index':1})
					});
                }
            }
            
            
            $(indexImage).css({'display':'block', 'opacity':1});
            currentImage = indexImage;
            currentIndex = index;
            $('#thumbs li').removeClass('active');
            $($('#thumbs li')[index]).addClass('active');
            
             

             if(currentIndex == 3 || currentIndex == 6 || currentIndex == 4  || currentIndex == 7 ){
             $('#site1').removeClass('siteOff');
             $('#site1').addClass('siteOn');
             }else{
             $('#site1').removeClass('siteOn');
             $('#site1').addClass('siteOff');
             }
            
             if(currentIndex == 0 || currentIndex == 1 || currentIndex == 2 || currentIndex == 8){
             $('#site2').removeClass('siteOff');
             $('#site2').addClass('siteOn');
             }else{
             $('#site2').removeClass('siteOn');
             $('#site2').addClass('siteOff');
             }
             
             if(currentIndex == 5){
             $('#site3').removeClass('siteOff');
             $('#site3').addClass('siteOn');
             }else{
             $('#site3').removeClass('siteOn');
             $('#site3').addClass('siteOff');
             }
             
        }
        

         
        
    }
    
    function showNext(){
        var len = $('#bigPic img').length;
        var next = currentIndex < (len-1) ? currentIndex + 1 : 0;
        showImage(next);
    }
    
    var myTimer;
    
    $(document).ready(function() {
	    myTimer = setTimeout("showNext()", 4000);
		showNext(); //loads first image
        $('#thumbs li').bind('click',function(e){
        	var count = $(this).attr('rel');
        	showImage(parseInt(count)-1);
        });
        
	});
    
 	   


//#########################################
//#########################################
//
//        SMALL IMAGE ROTATER #2
//
//#########################################
//#########################################
	var currentImage2;
    var currentIndex2 = -1;
    var interval;
    function showImage2(index){
        if(index < $('#bigPic2 img').length){
        	var indexImage2 = $('#bigPic2 img')[index]
            if(currentImage2){   
            	if(currentImage2 != indexImage2 ){
                    $(currentImage2).css('z-index',2);
                    clearTimeout(myTimer);
                    $(currentImage2).fadeOut('slow', function() {
					    myTimer = setTimeout("showNext2()", 900);
					    $(this).css({'display':'none','z-index':1})
					});
                }
            }
            $(indexImage2).css({'display':'block', 'opacity':1});
            currentImage2 = indexImage2;
            currentIndex2 = index;
            $('#thumbs2 li').removeClass('active');
            $($('#thumbs2 li')[index]).addClass('active');
        }
    }
    
    function showNext2(){
        var len = $('#bigPic2 img').length;
        var next = currentIndex2 < (len-1) ? currentIndex2 + 1 : 0;
        showImage2(next);
    }
    
    var myTimer;
    
    $(document).ready(function() {
	    myTimer = setTimeout("showNext2()", 900);
		showNext2(); //loads first image
        $('#thumbs2 li').bind('click',function(e){
        	var count = $(this).attr('rel');
        	showImage2(parseInt(count)-1);
        });
	});
  
  
  
  //#########################################
//#########################################
//
//        SMALL IMAGE ROTATER #3
//
//#########################################
//#########################################
	var currentImage3;
    var currentIndex3 = -1;
    var interval;
    function showImage3(index){
        if(index < $('#bigPic3 img').length){
        	var indexImage3 = $('#bigPic3 img')[index]
            if(currentImage3){   
            	if(currentImage3 != indexImage3 ){
                    $(currentImage3).css('z-index',2);
                    clearTimeout(myTimer);
                    $(currentImage3).fadeOut('slow', function() {
					    myTimer = setTimeout("showNext3()", 900);
					    $(this).css({'display':'none','z-index':1})
					});
                }
            }
            $(indexImage3).css({'display':'block', 'opacity':1});
            currentImage3 = indexImage3;
            currentIndex3 = index;
            $('#thumbs3 li').removeClass('active');
            $($('#thumbs3 li')[index]).addClass('active');
        }
    }
    
    function showNext3(){
        var len = $('#bigPic3 img').length;
        var next = currentIndex3 < (len-1) ? currentIndex3 + 1 : 0;
        showImage3(next);
    }
    
    var myTimer;
    
    $(document).ready(function() {
	    myTimer = setTimeout("showNext3()", 900);
		showNext3(); //loads first image
        $('#thumbs3 li').bind('click',function(e){
        	var count = $(this).attr('rel');
        	showImage3(parseInt(count)-1);
        });
	}); 
