/******************* CAROUSEL HORIZONTAL CENTRAL*****************************/

var activo_central = new Array(false,false,false);
var down_central = new Array(false,false,false);

var activo_central = false;
var down_central = false;

function final_central(opcion){
	if (down_central[opcion]){
		activo_central[opcion]=true;
		down_central[opcion]=false;
		if ($.browser.msie){		
			//$(this).animate({marginTop:158}, "fast", "linear", function(){final_central(opcion)});
			$(this).animate({marginTop:111}, "fast", "linear", function(){final_central(opcion)});
		}else{
			//$(this).animate({marginTop:157}, "fast", "linear", function(){final_central(opcion)});
			$(this).animate({marginTop:110}, "fast", "linear", function(){final_central(opcion)});
		}
	}else{			
		if (activo_central[opcion]){
			activo_central[opcion]=false;					
		}else{
			activo_central[opcion]=true;
		}
	}
}

function mycarousel_central_initCallback(carousel) {
	
	if ($.browser.msie){
		
		$('.cortina-central').bind('mouseover', function() {	
			var s = new String($(this).attr('id'));
			var indice = s.split('-');
			indice=indice[1];			
			if (!activo_central[indice]){
				activo_central[indice]=true;
				//$(this).animate({marginTop:145}, "fast", "linear", function(){final_central(indice)});
				$(this).animate({marginTop:100}, "fast", "linear", function(){final_central(indice)});
			}		
			
			return false;
		});		
		
		$('.cortina-central').bind('mouseleave', function() {	
			var s = new String($(this).attr('id'));
			var indice = s.split('-');
			indice=indice[1];			
			if (!activo_central[indice]){
				activo_central[indice]=true;				
				//$(this).animate({marginTop:158}, "fast", "linear", function(){final_central(indice)});
				$(this).animate({marginTop:111}, "fast", "linear", function(){final_central(indice)});
			}else{
				down_central[indice]=true;
			}			
			return false;
		});		
		

		
	}else{		
		
		$('.cortina-central').bind('mouseover', function() {
			var s = new String($(this).attr('id'));
			var indice = s.split('-');
			indice=indice[1];			
			if (!activo_central[indice]){
				activo_central[indice]=true;
				//$(this).animate({marginTop:143}, "fast", "linear", function(){final_central(indice)});
				$(this).animate({marginTop:98}, "fast", "linear", function(){final_central(indice)});
			}			
			return false;
		});				
		$('.cortina-central').bind('mouseleave', function() {	
			var s = new String($(this).attr('id'));
			var indice = s.split('-');
			indice=indice[1];				
			if (!activo_central[indice]){
				activo_central[indice]=true;
				//$(this).animate({marginTop:157}, "fast", "linear", function(){final_central(indice)});
				$(this).animate({marginTop:110}, "fast", "linear", function(){final_central(indice)});
			}else{
				down_central[indice]=true;
			}			
			return false;
		});					
	}

    jQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('.jcarousel-scroll select').bind('change', function() {
        //carousel.options.scroll = 2*jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
    	// 2 * el numero de fichas de scroll
        carousel.options.scroll = 2*1; 
        return false;
    });

    jQuery('#mycarousel-central-next').bind('click', function() {
    	if (carousel.options.size!=carousel.last){
    		carousel.next();
    	}
        return false;
    });

    jQuery('#mycarousel-central-prev').bind('click', function() {
        carousel.prev();
        return false;
    });    
    
};

function carousel_emisoracr(){
	
	jQuery("#mycarousel-central").jcarousel({
        scroll: 6,
        visible: 6,
        initCallback: mycarousel_central_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
	
    if (($.browser.msie)&&($.browser.version=='6.0')){
    	setTimeout("$('.cortina-central').css('width','281px')", 800);
    	setTimeout("$('.cortina-central').css('marginLeft','-293px')", 100);    	
	}  	
    	
}

