

function closePest(id){
	$("#"+id).animate({left: "254px"}, 500,"swing");
}
var pestanyas_lock=false
function unlock(){
	pestanyas_lock=false
	var pos=$("#det_maquina").get(0).style.left
}

//ABRIR Y CERRAR DEL LATERAL DE OFERTAS
	function openOferta(){
		if($("#lateral").get(0).style.display!="block"){
			$("#lateral").get(0).style.display="block"
			$("#lateral .container").get(0).style.marginTop="530px"
			$("#lateral .container").animate({marginTop: "0px"}, 800);
			setTimeout("showcerrar()",650)
		}
		else{
			if($("#lateral .container").get(0).style.marginTop=="0px"){
				$("#lateral .container").get(0).style.marginTop="0px"
				$("#lateral .close").fadeOut(0)
				$("#ver_mas_ofertas").fadeOut(300)
				$("#lateral .container").animate({marginTop: "530px"}, 800 ,hideLateral);
			}
		}
	}
	
	function hideLateral(){
		$("#lateral").get(0).style.display="none"
	}
	function showcerrar(){
		$("#lateral .close").fadeIn(300)
		$("#ver_mas_ofertas").fadeIn(300)
	}


function hideGal(id){
	
	$("#gal"+id).animate({height: "0px"}, 500,"swing")
	$("#mas"+id).get(0).style.display="block";
	$("#menos"+id).get(0).style.display="none";
	if(text_opened===id)text_opened=null;
 
}

function showGal(id){
	if(text_opened!=id){
		$("#gal"+id).animate({height: "150px"}, 500,"swing")
		$("#mas"+id).get(0).style.display="none";
		$("#menos"+id).get(0).style.display="block";
		if(text_opened!=null)hideGal(text_opened);
		text_opened=id;
	}
	else hideGal(id)
}

var text_opened=null
function hideText(id){
	var height=21;
	if($("#text"+id+" .resumen").get().length>0) height+=$("#text"+id+" .resumen").get(0).offsetHeight+3
	$("#text"+id).animate({height: height+"px"}, 500,"swing")
	$("#mas"+id).get(0).style.display="block";
	$("#menos"+id).get(0).style.display="none";
	if(text_opened===id)text_opened=null;
}

function showText(id,hide){
	if(text_opened!=id){
		var height=$("#text"+id+" .brilla").get(0).offsetHeight+21+20
		if($("#text"+id+" .resumen").get().length>0) height+=$("#text"+id+" .resumen").get(0).offsetHeight
		$("#text"+id).animate({height: height+"px"}, 500,"swing")
		$("#mas"+id).get(0).style.display="none";
		$("#menos"+id).get(0).style.display="block";
		if(text_opened!=null && hide=="S")hideText(text_opened);
		text_opened=id;
	}else{
		hideText(id)	
	}
	
	
	
}


//Pasa a la serie de miniaturas que se le dice
//La variable slide indica el ancho de la galería

var gals=new Array()


function setGal(gal,next,prev,object){
	gals[gal]=new Object();
	
	gals[gal].actual=0
	gals[gal].contenedor=$("#"+gal+" .fotos")
	gals[gal].next=$("#"+gal+" ."+next)
	gals[gal].prev=$("#"+gal+" ."+prev)
	gals[gal].slides=object.slides
	gals[gal].width=object.width
	gals[gal].next.get(0).gal=gals[gal]
	gals[gal].prev.get(0).gal=gals[gal]
	
	$("#"+gal+" .fotos").get(0).style.width=(gals[gal].slides+1)*gals[gal].width+"px"
	
	gals[gal].next.get(0).onclick=function(){
		slideTo(this.gal,this.gal.actual+1)
	}
	gals[gal].prev.get(0).onclick=function(){
		slideTo(this.gal,this.gal.actual-1)
	}
	
	updateArrows(gals[gal])
}

function slideTo(gal,num){
	if(gal.slides>num>-1){
		gal.contenedor.animate({marginLeft: "-"+(gal.width*num)+"px"}, 500,"swing")
		gal.actual=num
		updateArrows(gal)
	}
	
}

//Hace aparecer o desaparecer las flechas
function updateArrows(gal){
	btnNext=gal.next.get(0).style.display
	btnPrev=gal.prev.get(0).style.display
	if(gal.actual==0){if(btnPrev!="none")gal.prev.fadeOut(0)}
	else {if(btnPrev!="block")gal.prev.fadeIn(1000)}
	if(gal.actual==gal.slides){if(btnNext!="none") gal.next.fadeOut(0)}
	else {if(btnNext!="block")gal.next.fadeIn(1000)}
}






var actual_container=null

function curveContainer(){
	//$("#"+actual_container).get(0).style.backgroundColor="#222222";
	//$("#"+actual_container).get(0).style.backgroundImage="none";
	//document.getElementById(actual_container).className="curved";
	
}

function showContainer(container,temps){
	actual_container=container
	$("#"+container).fadeIn(temps,curveContainer);
}

//EQUIVALENT ARRAY_SEARCH
function getIdx(vector,k){
	for(i=0;i<vector.length;i++){
		if(vector[i]==k) return i
	}
	return false;
}


function fadein(capa)
{
	$(capa).fadeIn(100);
}


function fadeout(capa)
{
	$(capa).fadeOut(100);
}


function pngFIX(){
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
					 var img = document.images[i]
					 var imgName = img.src.toUpperCase()
					 if (img.className=="pngfix" )
					 {
									var imgID = (img.id) ? "id='" + img.id + "' " : ""
									var imgClass = (img.className) ? "class='" + img.className + "' " : ""
									var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
									var imgStyle = "display:inline-block;" + img.style.cssText 
									if (img.align == "left") imgStyle = "float:left;" + imgStyle
									if (img.align == "right") imgStyle = "float:right;" + imgStyle
									if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
									var strNewHTML = "<span " + imgID + imgClass + imgTitle
									+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
									+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
									+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
									img.outerHTML = strNewHTML
									i = i-1
					 }
	   }
	}
}



//DETECCIÓN DE IE6
nav_detection=navigator.userAgent.search(/MSIE 6/)
if(nav_detection>0)var IE6=true
else var IE6=false

//DETECCIÓN DE IE7
nav_detection=navigator.userAgent.search(/MSIE 7/)
if(nav_detection>0)var IE7=true
else var IE7=false

