//window.onerror=null
msgWindow=""
n_ventanas=0
compat = false;
mouse_x=0;
mouse_y=0;
//    var is_nav     = (parseInt(navigator.appVersion) >= 4) &&((agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1)
//		       && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1)
//		       && (agt.indexOf('webtv') == -1));
//var sw_arranque=(is_nav4up ? true : false)
var muestra_clickizq=false
if( parseInt( navigator.appVersion ) >= 3 ) { compat = true; }

//alert("Cargo Fotos");
  if (document.images) {

//    var linea_hor_f2= new Image; linea_hor_f2.src= "linea_hor_f2.gif";
//    var linea_hor_f3= new Image; linea_hor_f2.src= "linea_hor_f3.gif";
//    var linea_hor= new Image; linea_hor.src= "linea_hor.gif";
//    var boceto_web= new Image; boceto_web.src = "boceto_web.gif";
//    var logovfani= new Image; logovfani.src = "logovfani.gif";
//    var globosw= new Image; globosw.src = "globos.gif";
//    var globosw_f2= new Image; globosw_f2.src = "globos_f2.gif";

//    var ultimo_0   = new Image; ultimo_0.src	  = "imgprg/ultimo_0.gif";
//    var ultimo_1 = new Image; ultimo_1.src	= "imgprg/ultimo_1.gif";
//    var anterior_0   = new Image; anterior_0.src    = "imgprg/anterior_0.gif";
//    var anterior_1   = new Image; anterior_1.src    = "imgprg/anterior_1.gif";
//    var siguiente_0	= new Image; siguiente_0.src	= "imgprg/siguiente_0.gif";
//    var siguiente_1	= new Image; siguiente_1.src	= "imgprg/siguiente_1.gif";
//    var primero_0   = new Image; primero_0.src    = "imgprg/primero_0.gif";
//    var primero_1   = new Image; primero_1.src    = "imgprg/primero_1.gif";
  // alert(menuico_r1_c1_f1.src)
  }
if( parseInt( navigator.appVersion ) >= 3 ) { compat = true; }

var count = 0;
var hand = 0;
nav = (document.layers) ? true : false;
ie  = (document.all) ? true : false;
//if (nav)
////  skin = document.topdeck;
//  var skin = document.globos;
//if (ie)
//  var skin = globos.style;
//if (eval("(nav) ? document.layers['globos']:document.all['globos']")!=null){
//   var skin = (nav) ?  document.layers['globos']:document.globos.style;
//}
document.onmousemove = sustain;
if (nav) document.captureEvents(Event.MOUSEMOVE);
//*****************************************************

compat = false;

if( parseInt( navigator.appVersion ) >= 3 ) { compat = true; }

if (document.images) {
//    var linea_hor_f2= new Image; linea_hor_f2.src= "linea_hor_f2.gif";
//    var linea_hor_f3= new Image; linea_hor_f2.src= "linea_hor_f3.gif";
//    var linea_hor= new Image; linea_hor.src= "linea_hor.gif";
//    var boceto_web= new Image; boceto_web.src = "boceto_web.gif";
//    var logovfani= new Image; logovfani.src = "logovfani.gif";

    var ultimo_0   = new Image; ultimo_0.src	= "imgprg/ultimo_0.gif";
    var ultimo_1 = new Image; ultimo_1.src    = "imgprg/ultimo_1.gif";
    var anterior_0   = new Image; anterior_0.src    = "imgprg/anterior_0.gif";
    var anterior_1   = new Image; anterior_1.src    = "imgprg/anterior_1.gif";
    var siguiente_0   = new Image; siguiente_0.src    = "imgprg/siguiente_0.gif";
    var siguiente_1   = new Image; siguiente_1.src    = "imgprg/siguiente_1.gif";
    var primero_0   = new Image; primero_0.src	  = "imgprg/primero_0.gif";
    var primero_1   = new Image; primero_1.src	  = "imgprg/primero_1.gif";

}

//function cambia(x, y)
//{
 //  if( compat ) { document.images[x].src=eval(y+'.src'); }
//}
//function MM_reloadPage(init) {  //reloads the window if Nav4 resized
//  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
//    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
//  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
//}
//MM_reloadPage(true);
// -->
//************************************
//********************************************************************
function confirma(texto_confirma,url_voy,form_submit){
 if (confirm("¿ " +texto_confirma+" ?")){
  // alert(form_submit.action);
    form_submit.action=url_voy;
    form_submit.submit();
   }else{
     alert("Cancela "+texto_confirma)
   }
   // alert(1111)

}
//********************************************************************
function stylo(sty_trae){

  cook_sty=getCookie("sty")
 //alert(sty_trae+"/"+cook_sty)
 //document.write(show_props(history.elements))
 //alert("<B>history is</B> " + history)
  if (sty_trae!=cook_sty){
   // alert(history.previous.url)
   setCookie("sty",sty_trae)
  // history.next()
  //return false;
    //window.location.reload()
    // setCookie("kkk",sty_trae)
   //  alert("aqui " +getCookie("sty"))
    // document.write(show_props(document.location))
    redirecciona="http://"+ document.location.host + document.location.pathname+"?sty="+getCookie("sty")
  // redirecciona=document.location.href
//     redirecciona=redirecciona.replace("sty="+getCookie("sty"),"")
    // redirecciona=redirecciona.replace("?","?sty="+getCookie("sty"))
    // +"&sty="+getCookie("sty")
  //  alert(document.location + " # " +redirecciona);
    if (document.location!=redirecciona) {
      document.location.href=redirecciona
//	location.replace(null)
     //  document.location.reload()
     // history.back()
    }
    //document.location.href
  }
}
function actualiza_pcn(nom_campo,f){
// alert(nom_campo)
 eval("f.ncampo.value='"+nom_campo+"'")
 if (confirm('¿ Actualizar Valores de '+nom_campo +' ?')){
   f.submit()
 }
}
function actualizapc1(obj,nom_campo){
  alert(nom_campo)
  // for (var i in f){
  //		      result = f[i]
  //	document.write(i)
  //	document.write(" - ")
  //   document.write(result)
  //   document.write("<br>")
  // }
  var result=""
  for (var i in obj) {
   //  if (){
	result +=  "." + i + " = " + obj[i] + "<br>\n"
   //  }

  }
  document.write(result)
 //document.write(show_props(f))
}
function alias_camp(campo){
if (campo.indexOf("nomcli")!= -1){
  return "Nombre y Apellidos,"
}else if (campo.indexOf("cif")!= -1){
  return "C.I.F. / N.I.F.,"
}else if (campo.indexOf("CICALL")!= -1){
  return "Cl/Pz/Avd,"
}else if (campo.indexOf("CIDIRC")!= -1){
  return "Direccion,"
}else if (campo.indexOf("CIPOSC")!= -1){
  return "Código Postal,"
}else if (campo.indexOf("CIMUNC")!= -1){
  return "Localidad/Municipio/Ciudad,"
}else if (campo.indexOf("tlf")!= -1){
  return "Teléfono,"
}else if (campo.indexOf("clicod")!= -1){
  return "Código de Cliente,"

}else{
  return campo
}

}
function verifica_form(f,arr_cvalida){
 // alert(show_props(arr_cvalida))
//document.write(show_props(f,"f"))
 nom_form="document."+f.name
 //alert(nom_form)
     var result =true
     result_txt="Por favor introduzca "
	  for (var i in arr_cvalida){
		//    result +=  i + " = " + arr_cvalida[i] + "<br>\n"
	       //  alert("f."+arr_cvalida[i])
		 algo=eval(nom_form+"."+arr_cvalida[i]+".value")
	      //   alert(algo)
		 if (algo=="") {
		    result_txt=result_txt + alias_camp(arr_cvalida[i]) + " ";
		    result = false ;
		 }
	      // alert(show_props(f.(arr_cvalida[i])))

		  // resu obj[i]
	  }
    if (!result) {
      alert(result_txt)
      return false
    }else{
     f.submit()
    }
 //alert(result)
 //f.submit()
}
function pop(orientation,msg) {
if (pon_globos!=true){
  return
}
 //content=msg
 content=  '  <table border="0" cellpadding="0" cellspacing="0" width="1" height="1"> '
+'  <tr>  '
+'    <td rowspan="2" colspan="2" >	'
+'	 <img src="shim.gif" width="1" height="1" border="0"> '
+'    </td>	  '
+'    <td align="left"> 	'
+'	<div align="left"><img src="shim.gif" width="1" height="18" border="0"></div>	'
+'    </td>	  '
+'    <td width="1">  '
+'	<div align="left" width="1"><img src="globos/globo_pico.gif" align="left" width="27" height="18" border="0"></div>	'
+'    </td>	  '
+'    <td>'
+'	<div align="left"><img	src="shim.gif" width="1" height="18" border="0"></div>	'
+'    </td>	  '
+'    <td rowspan="2" colspan="2">	'
+'	 <img src="shim.gif" width="1" height="1" border="0"> '
+'    </td>	  '
+'  </tr> '
+'  <tr>  '
+'    <td bgcolor="#000000" width="1">	'
+'	<div align="left"><img src="shim.gif" width="1" height="1" border="0"></div>'
+'    </td>	  '
+'    <td bgcolor="#000000" width="1">	'
+'	<div align="left"><img src="globos/globo_blancen.gif" align="left" width="27" height="1" border="0"></div>	'
+'    </td>	  '
+'    <td bgcolor="#000000" width="100%">   '
+'	<div align="left"><img src="shim.gif" width="1" height="1" border="0"></div>'
+'    </td>	  '
+'  </tr> '
+'  <tr>  '
+'    <td colspan="2" valign="top" height="7" width="11"><img src="globos/globo_supiz.gif" width="11" height="7" border="0"></td>   '
+'    <td colspan="3" bgcolor="#FFFFFF" height="1"><img src="shim.gif" width="1" height="1" border="0"></td>  '
+'    <td colspan="2" valign="top" height="7"><img  src="globos/globo_supder.gif" width="11" height="7" border="0"></td>'
+'  </tr> '
+'  <tr>  '
+'    <td width="1" bgcolor="#000000"><img src="shim.gif" width="1" height="1" border="0"></td>   '
+'    <td bgcolor="#FFFFFF" width="11"><img src="shim.gif" width="1" height="1" border="0"></td>  '
+'    <td colspan="3" bgcolor="#FFFFFF" height="2" nowrap><center><font size="-2" face="Geneva, Arial, Helvetica, san-serif" size=-1>'
+ msg
+'</font></center></td>     '
+'    <td bgcolor="#FFFFFF"><img src="shim.gif" width="11" height="1" border="0"></td>	'
+'    <td width="1" bgcolor="#000000"><img src="shim.gif" width="1" height="1" border="0"></td>   '
+'  </tr> '
+'  <tr>  '
+'    <td width="11" height="8" rowspan="2" colspan="2" valign="bottom"><img src="globos/globo_infizq.gif" width="11" height="8" border="0"></td>     '
+'    <td colspan="3" bgcolor="#FFFFFF" height="100%"><img src="shim.gif" width="1" height="7" border="0"></td> 	'
+'    <td rowspan="2" colspan="2" valign="bottom"><img src="globos/globo_infder.gif" width="11" height="8" border="0"></td>	'
+'  </tr> '
+'  <tr>  '
+'    <td height="1" bgcolor="#000000" width="1"><img src="shim.gif" width="1" height="1" border="0"></td>'
+'    <td height="1" bgcolor="#000000" width="1"><img src="shim.gif" width="1" height="1" border="0"></td>'
+'    <td height="1" bgcolor="#000000" width="1"><img src="shim.gif" width="1" height="1" border="0"></td>'
+'  </tr> '
+'</table>'
  if (nav) {
    var canvas = document.globos.document;
    canvas.write(content);
    canvas.close();
   // skin.visibility = "show";
   //	show_capa('globos',true)
  }
  else if (ie) {
    document.all("globos").innerHTML = content;

  //  skin.visibility = "visible";
  }
    show_capa('globos',true)
    hand = orientation;
}


function kill() {

  if (count >= 1 )
    var always=true;
  if (always == true) {
    hand = 0;
      show_capa('globos',false)
   }
  else
    count++;
}

function pon_globo(texto,pon){
  if (pon){
   pop(2,texto)
  }else{
     kill()
  }

}

function pon_globo1(texto,pon){
if (pon_globos==true){
  if (eval("(is_nav4up) ? document.layers['globos']:document.all['globos']")!=null){
	var x = mouse_x
     //(is_nav4up)? e.pageX : event.x+document.body.scrollLeft
	var y =  mouse_y
     //(is_nav4up)? e.pageY : event.y+document.body.scrollTop
     //   alert(x+"/"+y)
//   algo=((is_nav4up) ? document.layers['globos'] : document.all['globos'].style);
//	algo=((is_nav4up) ? document.layers['globos'].myform.textoglobo: document.all['globos'].myform.textoglobo);
      algo=((is_nav4up) ? document.layers['globos'].document.links: document.all['globos'].document.links[1]);
   //	 alert(show_props(algo,"formcapa"))
   algo.value=texto
   if (!is_nav4up){
     algo.innerHTML=texto
    // alert(show_props(algo,'capa1'))
     //alert(algo.innertext)
   }else{
  // algo.text=texto
   //  document.layers['globos'].myform.globotxt.value=texto
    document.layers['globos'].document.myform.textoglobo.value=texto.replace("<BR>", " ")
     //: document.all['globos'].myform.textoglobo);
  //   alert(algo.value)
   //alert(show_props(algo,'capa1'))
   }
   move_div('globos',x-50,y+15)
   //color_capa('globos','blue')
   show_capa('globos',pon)

   //document.write(A)
   //alert("KKKKKKKKKKKKKKKKKK")
  }else{
   alert('No definida capa de globos')
  }
 }
}
function init_mouse_cal() {
 alert('init')
	document.onmousedown = mouseDown
	document.onmousemove = sustain
	document.onmouseup = mouseUp
	if (is_nav4up ) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP )
}
function replace(theString, oldChars, newChars)
{
   while (theString.indexOf(oldChars) > -1)
   {
       charPosition = theString.indexOf(oldChars);
       theString = "" + (theString.substring(0, charPosition) + newChars + theString.substring((charPosition + oldChars.length), theString.length));
   }
}

function peque_pag(href,ancho,alto){

//alert(href)

if (ancho==null)ancho=400;
if (alto==null)alto=300;
//alert (ancho+"/"+alto)
//alert(ancho);
//msgWindow=window.open(href,"peque","toolbar=no,scrollbars=auto,width="+ancho+",height="+alto)
msgWindow=window.open(href,"peque","toolbar=no,scrollbars=yes,width="+ancho+",height="+alto)
//msgWindow.document.close()

}

function sustain(e) {

//if (eval("(nav) ? document.layers['globos']:document.all['globos']")!=null){
//   var skin = (nav) ?  document.layers['globos']:document.all['globos'].style;
//}else{
  return
//}
var x = (is_nav4up )? e.pageX : event.x+document.body.scrollLeft
var y = (is_nav4up )? e.pageY : event.y+document.body.scrollTop
//  var x = (nav) ? e.pageX : event.x;
//  var y = (nav) ? e.pageY : event.y;
//  alert(hand)
  switch(hand) {
  case 0 :
   kill();
    break;
  case 1 :
    skin.left = x+10,  skin.top = y+10;
    window.status = "Demostración del panel de control";
    break;
  case 2 :
    skin.left = x-60,  skin.top = y+20;
    break;
  case 3 :
    skin.left = x-135, skin.top = y+10;
    window.status = "Right Popup";
    break;
  default:
    skin.left = x+10,  skin.top = y+10;
    break;
  }
//	    status = "x1---:"+	 x+" y1:"+y


}
function mouseDown(e) {
    que_boton=((is_nav4up)?e.which:event.button)
    if (que_boton!=1 && !muestra_clickizq) {
     alert("© SECOT")
      if (es_calen!=null){
  //	  alert("Es Calendario")
      }
      if (is_nav4up){
	    return false
      }else{
	return void(0)
	 //event.button=1
      }
    }
	if ((is_nav4up	&& e.which!=1) || (!is_nav4up && event.button!=1)) return true
	var x = (is_nav4up )? e.pageX : event.x+document.body.scrollLeft
	var y = (is_nav4up )? e.pageY : event.y+document.body.scrollTop
  //	 status = "pico x:"+x+" y:"+y
	mouse_x= x;
	mouse_y= y;
	return true
}


function mouseMove(e) {
	var x = (is_nav4up )? e.pageX : event.x+document.body.scrollLeft
	var y = (is_nav4up )? e.pageY : event.y+document.body.scrollTop
	status = "x:"+x+" y:"+y
	mouse_x= x;
	mouse_y= y;
	return true
}

function mouseUp(e) {
	var x = (is_nav4up )? e.pageX : event.x+document.body.scrollLeft
	var y = (is_nav4up )? e.pageY : event.y+document.body.scrollTop
	mouse_x= x;
	mouse_y= y;
	return true
}
function usuar(){
//alert(this.parent.frames.quien.usuario_ht);
    if (eval("this.parent.frames.quien")==null){
	usr_ht=""
    }else{
	usr_ht='|'+this.parent.frames.quien.usuario_ht;
    }
return usr_ht
}

function lleva_funphp(fun,para){
  alert(fun+"('"+para+"')|ZmVy")
      window.open(fun+"('"+para+"')","_self")  ;
  // window.open("afe_bd.php3?|consultadb('estadisticas')|ZmVy","_self")  ;
//http://fer-movil/afe/newweb/afe_bd.php3?|consultadb('estadisticas')|ZmVy
//http://fer-movil/afe/newweb/afephp.php3?|pon_idkey_est('537|BILBAO031|BILBAO031')|ZmVy
}
function at(fullS,cadena_busca){
	// alert("esto es at : "+fullS+"/"+cadena_busca)
    for (var i=0; i<fullS.length; i++) {
      //alert(i+"("+fullS.substring(i,1)+")")
      cade_corta=fullS.substring(i,i+1)
	 //   alert(i+"("+cade_corta+"/"+fullS.substring(i,i+1))
      if ( cade_corta==cadena_busca) {

	return fullS.substring(0,i)
       // fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
      }
    }
   return ""
}
function replaceString(oldS,newS,fullS) {
  // Replaces oldS with newS in the string fullS
  //alert("----->"+fullS);
  for (var i=0; i<fullS.length; i++) {
   // alert(fullS.substring(i,i+oldS.length))
    if (fullS.substring(i,i+oldS.length) == oldS) {
      fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
    }
   }
//   alert(fullS)
   return fullS
}

function cambia(w,x, y,z,a,b,r,s){
//alert(x)
//alert(eval(x+'.src'));
//alert(w +" / " + x +" / " + y+" / " +z);
//alert(r +" / " + s );
//alert(r == null );
//alert(eval(w+'.src')+"/"+document.images[z].src)
   if( compat ) { document.images[w].src=eval(x+'.src');
		if (!(y == null)) {document.images[y].src=eval(z+'.src');}
		if (!(a == null)) {document.images[a].src=eval(b+'.src'); }
		if (!(r == null)) {document.images[r].src=eval(s+'.src')} }
}
 //*************************
function cambia_fotocapa(foto_src,foto_trae,capa,tipo_graf)
{
//  foto_ant=foto_sw;
//alert(foto_src+"/"+foto_trae+"/"+capa+"/"+tipo_graf);
//alert(capa.substring( 1,2));
// Mira si es menu para guardar la imagen activa
if (capa.substring(0,2)=="mn"){
afoto_sw[capa.substring(2)]=foto_trae.substring(0,foto_trae.length-3)
//  alert(afoto_sw[capa.substring(2)])
}
//alert(eval("document."+foto_trae+".src"))
  if (tipo_graf==null){
     tipo_graf=".gif"
  }
//
     algo=(is_nav4up ? "document."+capa+".document." : "document.")+foto_src
  //alert(algo)
     obj=eval(algo);
 //alert(show_props(algo, "obj"))
    obj.src=foto_trae+tipo_graf;
}

function move_div(capa,x,y,ancho)
{
//alert(capa)
d=(is_nav4up) ? document.layers[capa] : document.all[capa].style;
//alert(show_props(d,'capa'))
//algo=(show_props(d,'capa'))
//document.write(algo)
//alert(d)
 d.left=x;
 d.top=y;
 if ((is_ie4) && ancho!=null) {
 // alert(ancho)
//    alert("************* "+ancho)
   d.pixelWidth=ancho;
 }
}

function show_props(obj, obj_name) {
//alert(obj_name)
	  var result = obj_name+"\n\n"
	  for (var i in obj)
		    result += obj_name + "." + i + " = " + obj[i] + "<br>\n"
		  //  alert(obj[i]=="[object]")
		    if (obj[i]=="[object]"){

//			result +="<br>-----------------------<br>"+show_props(obj[i],obj_name)+"<br>-----------------------<br>";
		    }

	  return result
}
function color_capa(capa,color){
//ver1=((!ver)?"hidden":((is_nav4up)?"show":"visible"));
//alert(capa+"/"+color);
     if (is_nav4up) {
	//document[capa].visibility = ver1;
    //alert(capa+"/"+color);
	document[capa].bgColor = color;
//alert( show_props(document[capa],"capA"));
     } else {
//	  alert(capa+"/"+color);
    color=(color==null)?"":color;
//alert( show_props(document.all[capa].style,"capA"));
	document.all[capa].style.backgroundColor = color;
     }
}
function show_capa(capa,ver){
ver1=((!ver)?"hidden":((is_nav4up)?"show":"visible"));
//alert(capa+"/"+ver1);

     if (is_nav4up) {	 
	document.layers[capa].visibility = ver1;
// document[capa].bgColor = "#FFFFFF";
//   alert( show_props(document[capa],"capA"));
//    alert(document[capa].visibility);
     } else {
	document.all[capa].style.visibility =  ver1;
     }
}
function foto_abierta()
{
//alert(eval(msgWindow.closed))
//var a=eval(msgWindow.closed)
//alert("->"+a+"<-")
//alert(a==null)
//if (eval(msgWindow.closed)==false){msgWindow.close()};
	if (eval(msgWindow.closed)==null){
	}
	else
	{
	if (eval(msgWindow.closed)==false){msgWindow.close()};
	}
}

function MM_preloadImages() { //v3.0
//alert("Aqui");
  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 arranca2(){
a=this.location.href
var_litestoy=""
//alert(show_props(a))

//  alert(a.substring(0,a.length-1))
// alert(a)
  if (!todo_bien){
  //alert('Voy');
    if (a.substring(a.length-1)=="#"){
      a=a.substring(0,a.length-1)
      // alert(show_props(this.location))

    }
   this.location.href=a
  }
  sw_arranque=false
  //alert('Vuelvo')
 // this.location=this.location+"#"
}
function carga_foto_ventana(foto,comentario,ancho_trae,alto_trae,directorio)
{
//alert("aqui");
foto_abierta()
//alert(document.images.length)
//alert(comentario==null)
n_ventanas=document.images.length+1;
imagen_nueva=new Image;
//alert(foto)
imagen_nueva.src=foto;
if (directorio==null){
  directorio="";
}else{
  directorio=directorio+"/";
}

imagen_nueva.src=directorio+foto;
//alert("Voy a Preload Aqui");
MM_preloadImages(imagen_nueva.src);
MM_preloadImages(imagen_nueva.src);
//alert(foto+'; nombre=' + document.images[document.images.length].name+
//alert(foto+'; nombre=' + document.images[n_ventanas].name+
//	'; height=' + ancho+
//    '; width=' + alto +
//	'; hspace=' + imagen_nueva.hspace +
//	'; vspace=' + imagen_nueva.vspace);
// analiza_foto()


document.images[n_ventanas]=imagen_nueva.src;
document.images[n_ventanas]=imagen_nueva.src;
//alert(document.images[n_ventanas])
if (ancho_trae==null){
ancho=imagen_nueva.height;
alto=imagen_nueva.width;
//alert(ancho+" <--- SIN Paremetros ---> "+alto)
}
else{
ancho=ancho_trae;
alto=alto_trae;
//alert(ancho+" <--- CON Paremetros ---> "+alto)
}

n_ventanas++;
//if (alto==0){
if (false){
	//alert(imagen_nueva.hspace)
	//carga_foto_ventana(foto,comentario)
}
else{
  if (alto<=(196+40)){
    alto=290;
  }
	if (!(comentario == null)) {
		ancho=ancho+10
	}else{
	      ancho=ancho-40
	}
	msgWindow=window.open('','window'+n_ventanas,'resizable=1,width='+(alto+35)+',height='+(ancho+120));
//	msgWindow=window.open('','descripcion1');
	msgWindow.document.write('<TITLE>&copy;'+""+' Vernatura</title>',"\n");
	msgWindow.document.write('<BODY TEXT="#000000" BGCOLOR="#EAFFB3" LINK="#000000" VLINK="#808080" ALINK="#990000">',"\n");
	msgWindow.document.write('<table border=0><tr><td colspan=2 align=center valign=top  WIDTH='+alto+ '><img src="'+imagen_nueva.src+'" HEIGHT='+ancho+' WIDTH='+alto+ ' border=0></td></tr>',"\n");
	msgWindow.document.write('<tr><td><IMG SRC="logopq.gif" BORDER=0  ALIGN=LEFT></td>');
	if (!(comentario == null)) {
	  msgWindow.document.write('<td><CENTER><FONT FACE="Verdana,Arial,Helvetica"><FONT SIZE=-1><b>'+comentario+'</FONT></FONT></CENTER>',"\n");
	}
	msgWindow.document.write('<FORM NAME="form2"><INPUT TYPE="button" VALUE="Cerrar Foto" onClick=self.close()></td></tr></table></FORM>');
//alert("KKKK")

// PRINT MsgWindow.document.write('</FORM><FORM NAME="form3"><INPUT TYPE="button" VALUE="Imprimir Foto" onClick=document.images[n_ventanas].print()> </FORM>',"\n");
	msgWindow.document.write('</BODY>',"\n");
	msgWindow.focus()
}
}
/* ------------------- */
/* Funciones generales */
/* ------------------- */

function Trim(cad)
{
  var aux="";
  var i,lg = cad.length;
  for (;lg>0 && cad.charAt(lg-1)<=' ';lg--);
  for (i=0;i<lg && cad.charAt(i)<=' ';i++);
  for (;i<lg;i++) aux = aux + cad.charAt(i);
  return aux;
}


function IsAlpha(car)
{
  car = car.toUpperCase();
  esp = " -áéíóúäëïöüÄËÏÖÜÁÉÍÓÚñÑ";
  return  (car>='A' && car<='Z') || esp.indexOf(car)!=-1;
}


// ARGUMENTOS FUNCION Abrir_Ventana
// theURL: Dirección
// winName: Nombre que queremos darle a la ventana
// Features:
	// scrollbars: Si tiene barras de desplazamiento
	// resizable: Si puede cambiarse tamaño
	// width y height: Dan tamaño a la ventana
	// top y left: Posiciona la ventana

function Abrir_Ventana(theURL, winName, features)
{
  window.open(theURL, winName, features);
}


/* --------------------------------- */
/* Funciones de validacion de fechas */
/* --------------------------------- */

// Función que comprueba que el formato de fecha es correcto

function comprobarFecha(dia, mes, anio)
{
  var caracter;
  var cadena = dia + "/" + mes + "/20" + anio;
  var caracteresValidos = "/0123456789";

  if(cadena.length!=10 || cadena.charAt(2)!="/" || cadena.charAt(5)!="/")
  {
    return false;
  }
  for(var i=0;i<cadena.length;i++)
  {
    caracter = cadena.charAt(i);
    if(caracteresValidos.indexOf(caracter)<0)
    {
      return false;
    }
  }
  dia = parseInt(cadena.substr(0,2),10);
  mes = parseInt(cadena.substr(3,2),10);
  anio = parseInt(cadena.substr(6,4),10);
  if(anio<=0)
  {
    return false;
  }
  switch(mes)
  {
    case 1:case 3:case 5:case 7:case 8:case 10:case 12:
    {
      if(dia<=0 || dia>31) return false;
      break;
    }
    case 4:case 6:case 9:case 11:
    {
      if(dia<=0 || dia>30) return false;
      break;
    }
    case 2:
    {
      if(anio%4)
      {
	if(dia<=0 || dia>28) return false;
      }
      else if(dia<=0 || dia>29) return false;
      break;
    }
    default:
    {
      return false;
    }
  }
  return true;
}


// Función que comprueba que la fecha de regreso sea mayor o igual que la de salida

function CompruebaRangos(di, mi, ai, df, mf, af)
{
//alert ("Comprueba :" +di+"/"+mi+"/"+ai+" # "+df+"/"+mf+"/"+af)

  if (ai<100)
  {
    ai = "20" + ai;
  }
  if (af<100)
  {
    af = "20" + af;
  }
  di = parseInt(di,10);
  mi = parseInt(mi,10);
  ai = parseInt(ai,10);
  df = parseInt(df,10);
  mf = parseInt(mf,10);
  af = parseInt(af,10);
//alert ("Comprueba :" +di+"/"+mi+"/"+ai+" # "+df+"/"+mf+"/"+af)
  if (af<ai)
  {
    return false;
  }
  if (af>ai) return true;
  if (mf<mi) return false;
  if (mf>mi) return true;
  if (df<di) return false;

  return true;
}


// Función que comprueba que una fecha sea posterior a la fecha actual

function CompruebaRango(df, mf, af, navegador)
{
  if (af<100)
  {
    af="20" + af;
  }

  df = parseInt(df,10);
  mf = parseInt(mf,10);
  af = parseInt(af,10);

  fa = new Date();
  da = fa.getDate();
  ma = fa.getMonth()+1;

  if (navegador=="ie")
  {
    aa = fa.getYear();
  }
  else
  {
    aa = 1900+fa.getYear();
  }

  if (af<aa) return false;
  if (af>aa) return true;
  if (mf<ma) return false;
  if (mf>ma) return true;
  if (df<da) return false;
  return true;
}


// Función que comprueba que la hora de regreso sea posterior a la hora de salida

function CompruebaHoras(di, mi, ai, df, mf, af, hs, hr)
{
  if((af==ai) && (mf==mi) && (df==di))
  {
    if (hr<=hs)
    {
      return false;
    }
  }
  return true;
}


// Función que comprueba que una hora sea posterior a la hora actual

function CompruebaHora(di, mi, ai, hs, navegador)
{
  mi = parseInt(mi,10);
  di = parseInt(di,10);
  hs = parseInt(hs,10);
  if (ai<100)
  {
    ai = "20" + ai;
  }
  ai = parseInt(ai,10);
  fa = new Date();

  if (navegador=="ie")
  {
    aa = fa.getYear();
  }
  else
  {
    aa = 1900+fa.getYear();
  }

  ma = fa.getMonth()+1;
  da = fa.getDate();
  ha = fa.getHours();

  if((aa==ai) && (ma==mi) && (da==di))
  {
    if (hs<=ha)
    {
      return false;
    }
  }
  return true;
}


/* --------------- */
/* Otras funciones */
/* --------------- */

// Función que comprueba que el número de vuelo sea correcto

function redimensionar() {
	//Redimensionar en NS causa problemas
	//window.onResize = redimensionar
	if (anchoVentana != window.innerWidth || altoVentana != window.innerHeight)
	document.location.href = document.location.href
}

function longitudMes(mes,agno) {
	if(mes==3||mes==5||mes==8||mes==10) return 30;
	else if (mes==1 && bisiesto(agno)) return 29;
	else if (mes==1) return 28;
	else return 31;
}

function introducir_fecha()
{
	mesmarcado=mesmarcado+1;
	agnomarcado_aux=agnomarcado.toString()
	if(diamarcado<10)
	{
		 dia = "0" + diamarcado;
	}
	else
	{
		dia = diamarcado;
	}
	if(mesmarcado<10)
	{
		mes = "0" + mesmarcado;
	}
	else
	{
		mes = mesmarcado;
	}
	if(window.opener.document.formulario.origen_destino.value=='origen')
	{
		window.opener.document.formulario.D_Day.value = dia
		window.opener.document.formulario.D_Month.value = mes
		window.opener.document.formulario.D_Anio.value = agnomarcado_aux.substring(2,4)
		aux=dia + "/" + mes + "/" + agnomarcado_aux.substring(2,4)
		window.opener.document.formulario.D_Fecha_usr.value = aux
	}
	else
	{
		window.opener.document.formulario.R_Day.value = dia
		window.opener.document.formulario.R_Month.value = mes
		window.opener.document.formulario.R_Anio.value = agnomarcado_aux.substring(2,4)
		aux=dia + "/" + mes + "/" + agnomarcado_aux.substring(2,4)
		window.opener.document.formulario.R_Fecha_usr.value = aux
	}
	window.close()
}

function bisiesto(agno) {
	if (((agno%4==0) && (agno%100!=0)) || (agno%400==0)) return true;
	else return false;
}

function escribir(texto,bloque) {
	//alert(bloque)
	if (ns4)
		{
		aux = eval(bloque)
		aux.open()
		aux.write(texto)
		aux.close()
		}
	else
		document.all[bloque].innerHTML=texto
}

function borrar() {
	for(i=1;i<43;i++) {
		if (ns4) casilla="document.Calendario.document.CalendarioCelda"+i+".document"
		else casilla="CalendarioCelda"+i
		contenido=''
		escribir(contenido,casilla)
	}

}


   function cargar_calendario_origen()
  {
    alert()
	document.myform.origen_destino.value='origen'
	window.open('calendario.html','Vernatura','scrollbars=no,resizable=no,width=210,height=210,top=200,left=400')
  }

  function cargar_calendario_destino()
  {
	document.myform.origen_destino.value='destino'
	window.open('calendario.jsp','Vernatura','scrollbars=no,resizable=no,width=210,height=210,top=200,left=400')
  }

    function cargar_calendario(nom_campo,aplicacion)
  {
	 document.myform.origen_destino.value=nom_campo
	 document.myform.aplicacion.value=aplicacion
       //  alert(aplicacion)
	window.open('calendario.html','Vernatura','scrollbars=no,resizable=no,width=210,height=210,top=200,left=400')
  }
//*************************************************************
function identifica() {
//   alert('Esto es Identifica JS :'+document.identif.usrsecot.value);
//  if (document.identif.usrsecot.value==null || document.identif.usrsecot.value==""){
  if (document.identif.usrsecot.value=="" || document.identif.passsecot.value==""){
//or document.identif.passsecot.value==null
	alert("Para Identificarse, Por favor Introduzca Nombre de Usuario y Contraseña");
	return;
   }
   //alert('Esto es Identifica JS :'+document.identif.usrsecot.value);
   document.identif.submit()
}
//**************************************************************
function poneColor( pag, color )

{
alert("Esto es Pone_COlor")
	if (color==1)
	{
		pag.document.fgColor="Black";
		pag.document.bgColor="White";
	}
	if (color==2)
	{
		pag.document.fgColor="Blue";
		pag.document.bgColor="Yellow";
	}
	if (color==3)
	{
		pag.document.fgColor="Yellow";
		pag.document.bgColor="Black";
	}
	if (color==4)
	{
		pag.document.fgColor="#800080";
		pag.document.bgColor="#FFEEEE";
	}
}
function set1Cookie(nom_cookie,valor_cookie) {
  expireDate = new Date;
 // document.write(show_props(Date))
//expireDate.setMonth(expireDate.getMonth()+6);

       // document.cookie = nom_cookie+"="+valor_cookie+";expires=" + expireDate.toGMTString();
	document.cookie = nom_cookie+"="+valor_cookie+";";
}

function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) +
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

function getCookie(name){
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    begin = dc.indexOf(cname);
    if (begin != -1) {
      begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
	return unescape(dc.substring(begin, end));
    }
  }
  return null;
}
function getexpirydate( nodays){
var UTCstring;
Today = new Date();
nomilli=Date.parse(Today);
Today.setTime(nomilli+nodays*24*60*60*1000);
UTCstring = Today.toUTCString();
return UTCstring;
}

function pon_color(color){
 var cookie_color = "color" + "=" + escape(color) + ";" ;
 // alert(color);
//+"; expires="+escape(90000);
//alert(cookie_color);
var now = new Date() ;
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
mi_time=now.getTime();
//Wdy, DD-Mon-YY HH:MM:SS GMT
//dia_exp=
//alert();
var d = new Date (mi_time + 24*60*60*1000)
//alert(d.format('day, month dd, yyyy hh:mm:ss timezone'));
var fecha_exp=getexpirydate(1)
//alert(fecha_exp);
//document.cookie += "expires=" + cookieDate(time + 24*60*60*1000)


//cookie_color = "color" +"=" + escape(color);
//  document.cookie=cookie_color;
//  document.cookie += ";expires=" + String(d);
cookie_color=cookie_color+ "expires=" + fecha_exp ;

//alert(cookie_color)
document.cookie =  cookie_color;

document.location.reload();
}

function goPage(Direccion)
{
    // alert(document.location.href)
    // alert(document.frmlista.numPagina.value)
    document.frmlista.pagina.value = Direccion;
    //	   alert(document.frmlista.pagina.value)
    document.frmlista.action = document.location.href;
    document.frmlista.submit();

    // document._frmConsulta._hidDireccion.value = strDireccion;
 //   alert(Direccion)
 //	  alert(show_props(document.location))
 //   alert(document.location.pathname)
   // document.location.href = document.location.pathname;
  //document._frmConsulta.submit();
}
//**************************************************
function busca_catalogo(cod,desc){
//d=document.adofrom
//alert(d.codarticulo.value + "/"+ d.descripcion.value);
//'d_cod=d.codarticulo.value;
//'d_des=d.descripcion.value;
//document.write(show_props(this))
d_cod=cod
d_des=desc
//alert(d_cod+ "/"+ d_des);
//'var lleva_arg = ((d.codarticulo.value=="")?"":"&cod="+d.codarticulo.value);
//'var lleva_arg = lleva_arg + ((d.descripcion.value=="")?"":"&desc="+d.descripcion.value);

var lleva_arg = ((cod=="")?"":"&cod="+cod);
var lleva_arg = lleva_arg + ((desc=="")?"":"&desc="+desc);
//alert(lleva_arg);
 if (lleva_arg==""){
  alert("Introduzca Algún dato Cod. Articulo o Cualquier Nombre, Ej: Tuberia, Tornillo..")
 }else{
   lnk_ves="http://"+host_trae+"id=catalogo"+lleva_arg
 // alert(lnk_ves);
  //void(0);
   document.location.href=lnk_ves
  return false
   //ocument.reload
  }
 //if ((d.codarticulo.value!=null) and (d.codarticulo.value!="")){
  //lleva_arg=lleva_arg+"&codart="+d_cod;
// }

}
