	
$(document).ready(function() {
   
	
	var galleryInd = 2
	var currGalleryInd = 1
	var theInt = null;
	var galleryMode = 'stop'
	var outObj = null;
	var inObj = null;
	var maxGalleryItemsNumber = 9
	
	maxGalleryItemsNumber = $(".gallery_numbers a").length+1
	
	
	
	
	
	$(".gallery_promotions_component").hover(function(){}, function(){
	    if(galleryMode == 'stop') theInt = setInterval(runGalleryInterval,6000);
	});
	$(".gallery_numbers a").click( function() {
	    	galleryMode = 'stop'
	    	clearInterval(theInt);
	    
        	var galleryInd = $(this).attr('gallery_href');
        
        
        	$('.gallery_numbers a[gallery_href="'+currGalleryInd+'"]').removeClass("on")

        	$('div.gallery_item[gallery_rel="'+currGalleryInd+'"]').css("display","none");
        
        	$('div.gallery_item[gallery_rel="'+galleryInd+'"]').css("display","block");
	        $('.gallery_numbers a[gallery_href="'+galleryInd+'"]').addClass("on"); 
	        currGalleryInd = galleryInd ;
	        $('div.gallery_item[gallery_rel="'+galleryInd+'"]').fadeIn("slow")

        	return false;
	});
	
	
	
	function runGalleryInterval()
	{
	    galleryMode = 'run'
	    
        galleryInd = parseInt(currGalleryInd)+1;
        if(galleryInd == maxGalleryItemsNumber) galleryInd = 1;
	    outObj = $('div.gallery_item[gallery_rel="'+currGalleryInd+'"]')
	    
	    $('div.gallery_item[gallery_rel="'+currGalleryInd+'"]').fadeOut("slow",function(){
	        $('.gallery_numbers a[gallery_href="'+currGalleryInd+'"]').removeClass("on")
	        $(this).css("display","none");
	        $('div.gallery_item[gallery_rel="'+galleryInd+'"]').css("display","block");
	        $('.gallery_numbers a[gallery_href="'+galleryInd+'"]').addClass("on"); 
	        currGalleryInd = galleryInd ;
	        inObj = $('div.gallery_item[gallery_rel="'+galleryInd+'"]')
	        $('div.gallery_item[gallery_rel="'+galleryInd+'"]').fadeIn("slow")
	    })
	    
	    
	    
	}
	
	function runGallery(){
	    clearInterval(theInt);
	    
	    theInt = setInterval(runGalleryInterval,6000)
	}
	
	runGallery();
    
})


