//// swap imágenes

function preloadImages() { //v3.0
	var d=document; 
	if(d.images){ 
		if(!d.p) d.p=new Array();
		var i,j=d.p.length,a=preloadImages.arguments; 
		for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ 
			d.p[j]=new Image; 
			d.p[j++].src=a[i];
		}
	}
}

function swapImgRestore() { //v3.0
	var i,x,a=document.sr; 
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function 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=findObj(n,d.layers[i].document);
	if (!x && d.getElementById) x=d.getElementById(n); 
	return x;
}

function swapImage() { //v3.0
	var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=findObj(a[i]))!=null){
		document.sr[j++]=x; 
		if (!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

///// Desplegable con ciudades
// usa la función findObj anterior

function showHideLayers() { 
	var i,v,obj,args=showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3) 
	if ((obj=findObj(args[i]))!=null) { 
		v=args[i+2];
		if (obj.style) { 
			obj=obj.style; 
			v=(v=='si')?'visible':(v=='no')?'hidden':v; 
		}
		obj.visibility=v; 
	}
}

//// Desplegable ciudades abajo mapita home

var opened=false,sw=false;
function tgl(n,c){
	n = parseInt(n)==0 ? 1 : n
	c = parseInt(c)==0 ? 1 : c
	var div=document.getElementById("despliega_"+n)
	var tbl=document.getElementById("tabla_"+n)
	if (typeof(opened)=="object" && div!=opened){
		opened.style.visibility="hidden"
		opened.opened=false
	}
	opened=false
	if (div.opened){
		div.style.visibility="hidden"
		div.opened=false
		sw=false
	}
	else {
		if (!div.fixed){
			var h=(c*26); h = h>(26*5) ? 150 : h ;
			h=h-Math.abs(1-c)*1.5;
			var w=parseInt(tbl.offsetWidth)+20; w= w<150 ? 150 : w ;
			div.style.height=h+"px";
			div.style.width=w+"px";
			div.fixed=true;
		}
		if (navigator.userAgent.indexOf("MSIE")!=-1)
		{
			div.style.top="-5px";
		}
		div.style.visibility="visible"
		div.opened=true
		opened=div
		sw=true
	}
}

function clMenu(e){
	var elt;
	if (typeof(event)!="object"){
		elt=e.target
	}
	else {
		elt=event.srcElement
	}
	if (elt.id.indexOf("toggler")==-1){
		if (typeof(opened)=="object"){
			opened.style.visibility="hidden"
			opened.opened=false
		}
	}
	return true;
}

// fade imágenes
// (C) 2000 www.CodeLifter.com

if (!Pic) {
	var Pic = new Array()
}
var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]
}

function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[j].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}

///// Abre ventana con html dentro

var Ventana
function carolina(url,ancho,alto,resi,scroll) {
	if (Ventana!= null && !Ventana.closed) {
		VentanaVieja=Ventana;
		VentanaVieja.name="VentanaVieja";
		Ventana.close();
	 }
	Ventana=window.open(url,"VentanaNueva","toolbar=no,location=no, status=no,menubar=no,left=0,top=0,resizable="+resi+",scrollbars="+scroll+",width="+ancho+",height="+alto);
	Ventana.focus();
}

///// Ventanita fotos anula botón derecho del mouse
// usa también closeWin() declarada antes.
var MuestraVentana

function cerrarMarcos(){
	if (MuestraVentana != null && !MuestraVentana.closed) {
		CuadroViejo = MuestraVentana;
		CuadroViejo.name = "CuadroViejo";
		CuadroViejo.close();
	 }
}

function marcos(imagen,ancho,alto,titulo) 
{
  cerrarMarcos();
  var left = (screen.width - ancho) / 2;
  var top = (screen.height - alto) / 2;
	MuestraVentana=window.open("","CuadroNuevo","toolbar=no,location=no, status=no,menubar=no,left="+left+",top="+top+",resizable=no,scrollbars=no,width="+ancho+",height="+alto);
	MuestraVentana.document.write("<html><head><title>"+titulo+"</title>");
	MuestraVentana.document.write("<script language=\"JavaScript\">");
	MuestraVentana.document.write("var mensaje=\"Derechos reservados por los autores. Prohibida su reproducción.\";");
	MuestraVentana.document.write("function nosepuede(A){if (document.all){if (event.button == 2) {alert(mensaje);	return false;	}}");
	MuestraVentana.document.write("if(document.layers){if(A.which == 3){alert(mensaje);return false;}	}}");
	MuestraVentana.document.write("if(document.layers){document.captureEvents(Event.MOUSEDOWN);}document.onmousedown=nosepuede;");
	MuestraVentana.document.write("</script>");
	MuestraVentana.document.write("</head><body>");
	MuestraVentana.document.write('<div style="position:absolute;width:'+ancho+'px;height:'+alto+'px;left:0px;top:0px">');
	MuestraVentana.document.write("<img src="+imagen+" alt=\""+titulo+"\"></div></body></html>");
	MuestraVentana.document.close();
	if (MuestraVentana.opener == null)	{
		MuestraVentana.opener = carolina;
	}
		MuestraVentana.opener.name = "VentanaOriginal";
        MuestraVentana.focus();
}

///// Abre ventana fija con imagen dentro (tapices,mapas)

var ImprimeVentana
function leandro(imagen,titulo) 
{
	if (ImprimeVentana != null && !ImprimeVentana.closed) {
		VentanaVieja = ImprimeVentana;
		VentanaVieja.name = "VentanaVieja";
		VentanaVieja.close();
	 }
	ImprimeVentana=window.open("","VentanaNueva","toolbar=no,location=no, status=no,menubar=no,left=0,top=0,resizable=yes,scrollbars=yes,width=550,height=400");
	ImprimeVentana.document.write("<html><head><title>"+titulo+"</title>");
	ImprimeVentana.document.write("</head><body>");
	ImprimeVentana.document.write('<div style="position:absolute;width:550px;height:400px;left:0px;top:0px">');
	ImprimeVentana.document.write("<img src="+imagen+"></div></body></html>");
	ImprimeVentana.document.close();
	if (ImprimeVentana.opener == null)	{
		ImprimeVentana.opener = leandro;
	}
		ImprimeVentana.opener.name = "VentanaOriginal";
        ImprimeVentana.focus();
}
function closeWin()
	{
		this.close();
		ImprimeVentana = null;
	}

///// Abre formulario para email en listados

var ImprimeVentana
function email(idcliente,extension) {
	if (!extension){
		extension="";
	}
	if (ImprimeVentana != null && !ImprimeVentana.closed) {
		VentanaVieja = ImprimeVentana;
		VentanaVieja.name = "VentanaVieja";
		VentanaVieja.close();
	 }
	ImprimeVentana=window.open("/email"+extension+".php?idcliente="+idcliente,"VentanaNueva","toolbar=no,location=no, status=no,menubar=no,left=150,top=100,resizable=no,scrollbars=no,width=350,height=300");
	if (ImprimeVentana.opener == null)	{
		ImprimeVentana.opener = email;
	}
		ImprimeVentana.opener.name = "VentanaOriginal";
        ImprimeVentana.focus();
}
function closeWin()	{
	this.close();
	ImprimeVentana = null;
}

