//modificada por Rolando Avalos Avalos para Zews S.A
var ventana;
var cont=0;

/***************************************************************************************************/
 function PopUp(img,enca,idf){
	  foto1= new Image();
	  foto1.src=(img);
	  Control(img,enca,idf);
  }

function Control(img,enca,idf){
	if((foto1.width!=0)&&(foto1.height!=0)){
	  verFoto(img,enca,idf);
	}
	else{
		funcion="Control('"+img+"','"+enca+"','"+idf+"')";
		intervalo=setTimeout(funcion,01);
	}
}
/***************************************************************************************************/function verFoto(img,enca,idf){
  ancho=foto1.width;
  alto=foto1.height;
  
  if(cont==1){
            cont=0;
            ventana.close();
            ventana=null;
    } 
  ventana = window.open("ver_foto.php?id="+idf+"&foto="+img+"&an="+ancho+"&al="+alto+"&tit="+enca,"Imagen","width="+ancho+",height="+alto+",left=190,top=110,scrollbars=no,menubars=no,statusbar=NO,status=NO,resizable=NO,location=NO");
  cont++;
  }
/***************************************************************************************************/
function cerrar()
{
	window.close();
}

function adjust_popup()
{
	var w, h, fixedW, fixedH, diffW, diffH;
	if (document.all) {
			fixedW = document.body.clientWidth;
			fixedH = document.body.clientHeight;
			window.resizeTo(fixedW, fixedH);
			diffW = fixedW - document.body.clientWidth;
			diffH = fixedH - document.body.clientHeight;
	} else {
			fixedW = window.innerWidth;
			fixedH = window.innerHeight;
			window.resizeTo(fixedW, fixedH);
			diffW = fixedW - window.innerWidth;
			diffH = fixedH - window.innerHeight;
	}
	w = fixedW + diffW;
	h = fixedH + diffH;
	if (h >= screen.availHeight) w += 16;
	if (w >= screen.availWidth)  h += 16;
	w = Math.min(w,screen.availWidth);
	h = Math.min(h,screen.availHeight);
	window.resizeTo(w,h);
	window.moveTo((screen.availWidth-w)/2, (screen.availHeight-h)/2);
}

function redimensionar(ancho,alto){
    ventana.resizeTo(ancho+12,alto+28);
    ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2);
  } 

// NOTE: Backspace = 8 / Enter = 13 / '0' = 48 | '9' = 57 / 46='.' / 44=',' / 45='-' / 32=''
var nav4 = window.Event ? true : false;  

function NumTelef(evt){ 
    var key = nav4 ? evt.which : evt.keyCode;
    //alert(key);
	return (key <= 13 || (key >= 48 && key <= 57)||key==45);
	
}
function SoloNum(evt){ 
    var key = nav4 ? evt.which : evt.keyCode;
    return (key <= 13 || (key >= 48 && key <= 57));
}

/***************************************************************************************************/
function checkLen(Input,countInput,limit){

		if(Input.value.length <=limit){
			countInput.value =Input.value.length + ' de ' + limit + ' caracteres';
		}else{
			Input.value = Input.value.substring(0, limit);
		}
	}	
/**************************************************************************************************/
/*quita los blancos al inicio */
function quitaBlancos(Input){	
  while(''+Input.value.charAt(0)==' ')
  {Input.value=Input.value.substring(1,Input.value.length);}
}
/**************************************************************************************************/

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];
   }
}
/**************************************************************************************************/
function externalLinks() {
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
/**************************************************************************************************/
//PARA EL EFECTO DE LAS IMAGENES

var baseopacity=50

function slowhigh(which2){
	imgobj=which2
	browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
	instantset(baseopacity)
	highlighting=setInterval("gradualfade(imgobj)",200)
}

function slowlow(which2){
	cleartimer()
	instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
	imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
		imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
	if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
	cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
		cur2.filters.alpha.opacity+=10
	else if (window.highlighting)
		clearInterval(highlighting)
}

/**************************************************************************************************/
