/* Funciones para flash */
function insertar_flash(nombre, w, h, variables, bgcolor)
{
    
       document.write(" <object style='z-index:0' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + w + "' height='" + h + "' id='" + nombre + "' align='middle' VIEWASTEXT>");
       document.write(" <param name='allowScriptAccess' value='sameDomain' />");
       document.write("<param name='movie' value='flash/" + nombre + ".swf" + variables + "' />");
       document.write("<param name='quality' value='high' />");
       document.write("<embed src='flash/" + nombre + ".swf" + variables + "' quality='high' bgcolor='" + bgcolor + "' width='" + w + "' height='" + h + "' name='" + nombre + "' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
       document.write("</object>");
}
function flash_transparente(cual, width, height, variables)
{
       document.write("<object style='z-index:0' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + width + "' height='" + height + "' id='" + cual + "' align='middle' VIEWASTEXT>");
       document.write("<param name='allowScriptAccess' value='sameDomain' />");
       document.write("<param name='movie' value='../flash/" + cual + ".swf" + variables + "' />");
       document.write("<param name='quality' value='high' />");
       document.write("<param name='wmode' value='transparent'>");
       document.write("<embed wmode='transparent'  src='../flash/" + cual + ".swf" + variables + "' quality='high' width='" + width + "' height='" + height + "' name='" + cual + "' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
       document.write("</object>");
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


/* Obtener QueryString */
function querySt(ji) {
hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}

/* Pre cargar imagenes */
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function precargar()
{
	MM_preloadImages('../fotos/1.png','../fotos/2.png','../fotos/3.png','../fotos/4.png','../fotos/5.png','../fotos/6.png',
					 '../fotos/7.png','../fotos/8.png','../fotos/9.png','../fotos/10.png','../fotos/11.png','../fotos/12.png',
					 '../fotos/13.png','../fotos/14.png','../fotos/15.png','../fotos/16.png','../fotos/17.png','../fotos/18.png',
					 '../fotos/19.png','../fotos/20.png','../fotos/21.png','../fotos/22.png','../fotos/23.png','../fotos/24.png',
					 '../fotos/b1.png','../fotos/b2.png','../fotos/b3.png','../fotos/b4.png','../fotos/b5.png','../fotos/b6.png',
					 '../fotos/b7.png','../fotos/g1.png','../fotos/g2.png','../fotos/g3.png','../fotos/g4.png','../fotos/g5.png',
					 '../fotos/g6.png','../fotos/m1.png','../fotos/m2.png','../fotos/m3.png','../fotos/m4.png','../fotos/m5.png',
					 '../fotos/m6.png','../fotos/m9.png','../fotos/m12.png','../fotos/m15.png','../fotos/m18.png','../fotos/m21.png',
					 '../fotos/m7.png','../fotos/m10.png','../fotos/m13.png','../fotos/m16.png','../fotos/m19.png','../fotos/m22.png',
					 '../fotos/m8.png','../fotos/m11.png','../fotos/m14.png','../fotos/m17.png','../fotos/m20.png','../fotos/m23.png',
					 '../fotos/m24.png','../fotos/m26.png','../fotos/m28.png','../fotos/m30.png','../fotos/m32.png','../fotos/.png',
					 '../fotos/m25.png','../fotos/m27.png','../fotos/m29.png','../fotos/m31.png','../fotos/s1.png','../fotos/s2.png',
					 '../fotos/s3.png','../fotos/s7.png','../fotos/s11.png','../fotos/s15.png','../fotos/s19.png','../fotos/a_25.png',
					 '../fotos/s4.png','../fotos/s8.png','../fotos/s12.png','../fotos/s16.png','../fotos/s20.png','../fotos/a_26.png',
					 '../fotos/s5.png','../fotos/s9.png','../fotos/s13.png','../fotos/s17.png','../fotos/s21.png','../fotos/a_27.png',
					 '../fotos/s6.png','../fotos/s10.png','../fotos/s14.png','../fotos/18.png','../fotos/s22.png','../fotos/a_28.png',
					 '../fotos/a_29.png','../fotos/a_47.png','../fotos/a_49.png','../fotos/a_51.png',
					 '../fotos/a_61.png','../fotos/a_74.png',
					 '../fotos/a_31.png','../fotos/a_48.png','../fotos/a_50.png','../fotos/a_6.png'
					 );
}

function mostrar_menu(cual)
{
	menuAnimado(cual,"OPEN");
}
function esconder_menu(cual)
{
	menuAnimado(cual,"CLOSE");
}
var currM1;
function menu1(tipo, cual)
{
	if (cual != currM1)
	{
	document.getElementById('m1_' + cual).className='m1-td1' + tipo;
	}
}
function setMenu1(cual)
{
	if (document.getElementById('m1_' + cual))
	{
		document.getElementById('m1_' + cual).className='m1-td1_on';
		document.getElementById('m1_a' + cual).className='link-menu1_on';
		currM1 = cual;
	}
}
var currM2;
function menu2(tipo, cual)
{
	if (cual != currM2)
	{
	document.getElementById('m2_' + cual).className='m2-td1' + tipo;
	}
}
function setMenu2(cual)
{
	if (document.getElementById('m2_' + cual))
	{
		document.getElementById('m2_' + cual).className='m2-td1_on';
		document.getElementById('m2_a' + cual).className='link-menu2_on';
		currM2 = cual;
	}
}
function menu3(tipo, cual)
{
	document.getElementById('m2_' + cual).className='m2-td2' + tipo;
}
/* GALERIA DE IMAGENES */
var currGal = 0;
function fotoSiguiente()
{
	var cant = document.getElementById("cantidad").value;
	if ((currGal+1) < cant)
	{
	document.getElementById("img_"+currGal).style.display = "none";
	document.getElementById("tit_"+ currGal).style.display = "none";
	document.getElementById("tit2_"+ currGal).style.display = "none";
	currGal++;
	
	if ((currGal+1) == cant)
		document.getElementById("sig").style.visibility="hidden";
	document.getElementById("ant").style.visibility="visible";
	document.getElementById("img_"+ currGal).style.display = "";
	document.getElementById("tit_"+ currGal).style.display = "";
	document.getElementById("tit2_"+ currGal).style.display = "";
	}
}
function fotoAnterior()
{
	document.getElementById("img_"+currGal).style.display = "none";
	document.getElementById("tit_"+ currGal).style.display = "none";
	document.getElementById("tit2_"+ currGal).style.display = "none";
	currGal--;
	var cant = document.getElementById("cantidad").value;
	if (currGal == 0)
		document.getElementById("ant").style.visibility="hidden";
	document.getElementById("sig").style.visibility="visible";
	document.getElementById("img_"+ currGal).style.display = "";
	document.getElementById("tit_"+ currGal).style.display = "";
	document.getElementById("tit2_"+ currGal).style.display = "";
}

/* DETALLE PRODUCTOS */
function detalleProd(cual,tipo)
{
	cual = cual.substring(4);
	document.getElementById("link_" + cual).className = "link-gris" + tipo;
}
var currProd = 0;
function pantallaSiguiente()
{
	var cant = document.getElementById("cantidad").value;
	if ((currProd+1) < cant)
	{
		prenderApagar(currProd,"none");
		currProd++;
		prenderApagar(currProd,"");
		prenderBotones();
	}
}
function pantallaAnterior()
{
	var cant = document.getElementById("cantidad").value;
	prenderApagar(currProd,"none");
	currProd--;
	prenderApagar(currProd,"");
	prenderBotones();
}

function setCurrpantalla(cual)
{
	currProd=cual;
	prenderBotones();
}
function botonesSiguiente()
{
	document.getElementById("ant").style.visibility="visible";
	document.getElementById("sig").style.visibility="visible";
	document.getElementById("ant2").style.visibility="visible";
	document.getElementById("sig2").style.visibility="visible";	
}
function prenderApagar(currProd,tipo)
{
	var cant = document.getElementById("cantidad").value;
	document.getElementById("tbl_"+currProd).style.display = tipo;
	if (document.getElementById("tit_"+ currProd))
		document.getElementById("tit_"+ currProd).style.display = tipo;
	if (document.getElementById("titulo")) 
		document.getElementById("titulo").innerHTML= "HOJA " + (currProd+1) + " DE " + cant;
}
function irMedidas()
{
	var cant = parseInt(document.getElementById("cantidad").value) - 1;
	var inicio = parseInt(document.getElementById("inicioMedidas").value);
	prenderApagar(currProd,"none");
	currProd= inicio;
	prenderApagar(currProd,'');
	prenderBotones();
}

function prenderBotones()
{
	var cant = document.getElementById("cantidad").value;
	if (document.getElementById("btn_fotos"))
	{
		var fotos = parseInt(document.getElementById("masfotos").value);
		var medidas = parseInt(document.getElementById("inicioMedidas").value);
		document.getElementById("btn_fotos").src = "../img/es/boton1_off.png";
		document.getElementById("btn_medidas").src = "../img/es/boton2_off.png";
		if (currProd >= fotos && currProd < medidas)
			document.getElementById("btn_fotos").src = "../img/es/boton1.png";
		if (currProd >= medidas)
			document.getElementById("btn_medidas").src = "../img/es/boton2.png";
	}
	if (document.getElementById("sig"))
	{
		document.getElementById("sig").style.visibility="visible";
		document.getElementById("sig2").style.visibility="visible";
		document.getElementById("ant").style.visibility="visible";
		document.getElementById("ant2").style.visibility="visible";	
		currProd = parseInt(currProd);
		if ((currProd+1) == cant)
		{
			document.getElementById("sig").style.visibility="hidden";
			document.getElementById("sig2").style.visibility="hidden";
		}		
		if (currProd == 0)
		{
			document.getElementById("ant").style.visibility="hidden";
			document.getElementById("ant2").style.visibility="hidden";
		}
	}
	
}
function irFotos()
{
	var cant = parseInt(document.getElementById("cantidad").value) - 1;
	var inicio = parseInt(document.getElementById("masfotos").value);
	prenderApagar(currProd,"none");
	currProd= inicio;
	prenderApagar(currProd,"");
	prenderBotones();
}

function botonCambiar(cual, tipo)
{
	var fotos = parseInt(document.getElementById("masfotos").value);
		var medidas = parseInt(document.getElementById("inicioMedidas").value);
	if (cual =="1")
	{
		if (currProd < fotos || currProd >= medidas)
			document.getElementById("btn_fotos").src = "../img/es/boton" + cual + tipo +".png";
	}
	else 
	{
		if (currProd < medidas)
			document.getElementById("btn_medidas").src = "../img/es/boton" + cual + tipo +".png";
	}
}
