var IndexFront=1;
var MaxIndexFront=5;
var TimeOn=0;
   jQuery(function() {
      //Eveto hover de las pestanias
   	function btn_over(obj,e){
          jQuery('.fotito').css('opacity','1');
          jQuery('.middle-right').css('z-index','7');
          jQuery('#botones').css('width','260px');
          jQuery(obj).hoverFlow(e.type, { width: 260 }, 'fast');
          jQuery(obj).removeClass("des").addClass("act");
          jQuery('.item',jQuery(obj)).hoverFlow(e.type, { width: 250 }, 'fast');
          jQuery('.item .logo',jQuery(obj)).hoverFlow(e.type, { width: 250 }, 'fast');
          jQuery('.item .texto',jQuery(obj)).hoverFlow(e.type, { width: 250 }, 'fast');
			 var idbtab = parseInt(jQuery(obj).parent().attr('id').split('-')[1]);
			 jQuery('#itab-'+IndexFront).removeClass("act").addClass("des");
			 jQuery('#itab-'+idbtab).removeClass("des").addClass("act");
			 jQuery('#t'+idbtab).removeClass("des").addClass("act");
			 IndexFront = idbtab;
			for(i=1; i<=MaxIndexFront; i++){
				if(IndexFront != i){
					jQuery('#btab-'+i+' .act').trigger('mouseleave');
			 		jQuery('#t'+i).removeClass("act").addClass("des");
				}
			}
      }
      function btn_out(obj,e){
          jQuery('.fotito').css('opacity','1');
          jQuery(obj).hoverFlow(e.type, { width: 160 }, 'fast');
          jQuery(obj).removeClass("act").addClass("des");
          jQuery('.item',jQuery(obj)).hoverFlow(e.type, { width: 150 }, 'fast');
          jQuery('.item .logo',jQuery(obj)).hoverFlow(e.type, { width: 150 }, 'fast');
          jQuery('.item .texto',jQuery(obj)).hoverFlow(e.type, { width: 150 }, 'fast');
			var idbtab = parseInt(jQuery(obj).parent().attr('id').split('-')[1]);
      }
      jQuery('.btn').hover(function(e) {
			btn_over(jQuery(this),e);
		}, function(e) {
			btn_out(jQuery(this),e);
      });
	function getCookie(c_name){
		var i,x,y,ARRcookies=document.cookie.split(";");
		for (i=0;i<ARRcookies.length;i++){
			x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
			y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
			x=x.replace(/^\s+|\s+$/g,"");
			if (x==c_name){
				return unescape(y);
			}
  		}
	}
	function movingTabs(){
		setInterval(function(){
			if(IndexFront < 5){
				IndexFront++;
			}else{
				IndexFront = 1;
			}
			for(i=1; i<=MaxIndexFront; i++){
				if(IndexFront != i){
					jQuery('#btab-'+i+' .act').trigger('mouseleave');
					jQuery('#itab-'+i).removeClass("act").addClass("des");
				}
			}
			jQuery('#btab-'+IndexFront+' .btn').trigger('mouseenter');
			if(IndexFront == 5) IndexFront=0;
		},7000);
	}
/*Este es el script que le da vida a todo el menu*/
	if(getCookie('SnFirst')){
		setTimeout(function(){
			jQuery('.inside .middle-middle .loading .icon_loading').hide('fast',
				function() {
					movingTabs();	
			});
		},3000);
	}else{
		document.cookie='SnFirst=1';
		setTimeout(function(){
			jQuery('.inside .middle-middle .loading .icon_loading').hide('fast',
				function() {
					movingTabs();	
			});
		},15000);
		
	}
		jQuery('#btab-1 .btn').removeClass("des").addClass("act");
		jQuery('#btab-1 .btn .item').css({'width':'260'});
   });


