//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));
}

/************PARA OCULTAR ENSEÑAO UN DIV **********************/
function Def() {
  for(var i=0; i<arguments.length; ++i){
	  if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
function Show(e) {
  if(!(e=document.getElementById(e))) return;
  if(e.style && Def(e.style.visibility)) e.style.visibility='visible';
}
function Hide(e) {
  if(!(e=document.getElementById(e))) return;
  if(e.style && Def(e.style.visibility)) e.style.visibility='hidden';
}
function habilitar(cbo,txt){
  with (document.forms['reservacion'])  
   {
	if (cbo.options[cbo.selectedIndex].value!='0'){
			Show('ampliacion');
			txt.disabled = false;
		}else{
			Hide('ampliacion');
			txt.disabled = true;
			}
   }
};

/***************************************************************************************************/
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 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)
}
/*=========================================*/
function verificar_checks(){
	var n=0;
	len=document.reservacion.elements.length;
	for (i=0;i<len;i++){
		if (document.reservacion.elements[i].type=='checkbox' && document.reservacion.elements[i].checked==true){
			n++;
		};
	};
	if (n ==0)
	{//si hay uno o mas
			alert("No es posible enviar reservación.Selecciona al menos un paquete del formulario.");
		return false;
	}
	
	return true;
};

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

