// JavaScript Document
$(document).ready(function(){
						   
	ver_calendario();
	
	$("#detalle_caja02").click(function(){
		var scr01 = $("#SlideShow").attr("src");
		//alert(scr01);
		$("#grande").attr("href",scr01); 
	
	});	 
	
	
	$("#imagess a").click(function(){
		var title = ""+ $(this).attr("title");
		//alert(title);
		var len = title.length;
		var text = title.substr(0,33);
		//var newtitle = text + title.substr(39,len);
		//alert(newtitle);
		var newtitle = title;
		//alert(newtitle);
		$("#imgp").hide();
		$("#imgp").attr("src",title).fadeIn('slow'); 
		$("#imgp").attr("alt",title); 
		$("#grande").attr("href",newtitle); 
	
	});	
	
	
	
	$('#menus li').each(function(index){ 
		$(this).click(function(){			                
			$("#subcat"+index).toggle("fast"); 			   
		}); 	  
	});	
	
	
	$(".item_img_destino img ").click(function(){
		$("#des").hide();									   
		$("#des").attr("src",''+$(this).attr('alt')).fadeIn("slow");
	});
});
// JavaScript Document
var request = false;

if (window.XMLHttpRequest) {
	request = new XMLHttpRequest();
}

function sumarDescarga(field, resul) {
	var su = Math.random()
		if (window.ActiveXObject) {
    		try {
            	request = new ActiveXObject("Msxml2.XMLHTTP");
       		 } catch(e) {
            	try {
                	request = new ActiveXObject("Microsoft.XMLHTTP");
            	} catch(e) {
                	request = false;
            	}
        	}    
		}
		 

    	if (request) {
    	    request.onreadystatechange = function (){
	
				var result = document.getElementById(resul);
			
				if (request.readyState == 4) {
					if (request.status == 200) {
						result.innerHTML = request.responseText;
					}
				} else {
					result.innerHTML = " Descarga...";
				}
			}
    	    request.open("GET", "suma_descarga.php?su="+ su +"&id=" + encodeURIComponent(field));
    	    request.send(null);
    	}	
}

function validar(){
	
	if(document.frm.nombre.value==""){
		alert("CUIDADO: Por favor introduzca su nombre");
		document.frm.nombre.focus();
		return false;
	}else if(document.frm.apellido.value==""){
		alert("CUIDADO:Por favor introduzca su apellido");
		document.frm.apellido.focus();
		return false;
	}else if(document.frm.telefono.value==""){
		alert("CUIDADO: Por favor escriba al menos un telefono");
		document.frm.telefono.focus();
		return false;
	}else if(document.frm.email.value==""){
		alert("CUIDADO: Por favor escriba su e-mail");
		document.frm.email.focus();
		return false;
	}else if(document.frm.mensaje.value==""){
		alert("CUIDADO: Por favor escriba el mensaje");
		document.frm.mensaje.focus();
		return false;
	}else{
		return true;	
	}
}


function validar_acceso(){
	if(document.f1.email.value==""){
		alert("ERROR: Ingrese su email ");
		document.f1.email.focus();
		return false;
	}else if(checkemail(document.f1.email.value)== false){
		document.f1.email.value="";
		document.f1.email.focus();
		return false;
	}else if(document.f1.password.value==""){
		alert("ERROR: Ingrese password ");
		document.f1.password.focus();
		return false;
	}/*else{
		document.f1.action = "cuenta.php?cuenta=acceso";
		document.f1.submit();
	}*/
	return true;
}

function validar_sendcontrasenia(opcion){
	if(document.cuenta.email.value==""){
		alert(" ERROR: Por favor ingrese su email ");
		document.cuenta.email.focus();
		return false
	}else if(checkemail(document.cuenta.email.value)== false){
		document.cuenta.email.value="";
		document.cuenta.email.focus();
		return false;
	}else{
		document.cuenta.action='cuenta.php?cuenta='+opcion;
		document.cuenta.submit();
	}
	return true;
}


function validar_delete(){
	if(!confirm("Esta Seguro que desea Eliminar el Registro")){
		return false;	
	}else{
		return true;	
	}	
}


function validar_direccion(){
	var doc= eval('document.direccion');
	if(doc.nombre.value==""){
		alert("ERROR: Por favor ingrese el nombre");
		doc.nombre.focus();
		return false;
	} else if(doc.apellidos.value==""){
		alert("ERROR: Por favor ingrese el apellido");
		doc.apellidos.focus();
		return false;
	} else if(doc.departamento.value==""){
		alert("ERROR: Por favor seleccione el departamento");
		doc.departamento.focus();
		return false;
	} else if(doc.direccion.value==""){
		alert("ERROR: Por favor ingrese el distrito");
		doc.direccion.focus();
		return false;
	} 
	return true;
}

function validar_mis_datos(opcion){
	if(document.cuenta.nombre.value==""){
		alert(" ERROR: Por favor ingrese su nombre ");
		document.cuenta.nombre.focus();
		return false
	}else if(document.cuenta.apellidos.value==""){
		alert(" ERROR: Por favor ingrese su apellido ");
		document.cuenta.apellidos.focus();
		return false
	}else if(document.cuenta.email.value==""){
		alert(" ERROR: Por favor ingrese su email ");
		document.cuenta.email.focus();
		return false
	}else if(checkemail(document.cuenta.email.value)== false){
		document.cuenta.email.focus();
		return false;
	}else if(document.cuenta.telefono.value==""){
		alert(" ERROR: Por favor ingrese su telefono ");
		document.cuenta.telefono.focus();
		return false
	}else{
		document.cuenta.action='cuenta.php?cuenta='+opcion;
		document.cuenta.submit();
	}	
}

function validar_mi_contrasenia(opcion){
	if(document.cuenta.password_actual.value==""){
		alert(" ERROR: Por favor ingrese su password actual ");
		document.cuenta.password_actual.focus();
		return false
	}else if(document.cuenta.nuevo_password.value==""){
		alert(" ERROR: Por favor ingrese su nuevo password ");
		document.cuenta.nuevo_password.focus();
		return false
	}else if(document.cuenta.confirmar_password.value==""){
		alert(" ERROR: Por favor confirme su password ");
		document.cuenta.confirmar_password.focus();
		return false
	}else if(document.cuenta.confirmar_password.value!=document.cuenta.nuevo_password.value){
		alert(" ERROR: la confirmación de su password no es válido");
		document.cuenta.confirmar_password.focus();
		return false
	}else{
		document.cuenta.action='cuenta.php?cuenta='+opcion;
		document.cuenta.submit();
	}	
}

function validar_contacto(){
	
	if (document.contacto.nombre.value==""){
		alert("Por favor ingrese su nombre");
		document.contacto.nombre.focus();
		return false;
	} else if (document.contacto.apellidos.value==""){
		alert("Por favor ingrese sus apellidos ");
		document.contacto.apellidos.focus();
		return false;
	} else if (checkemail(document.contacto.email.value)== false){
		document.contacto.email.value="";
		document.contacto.email.focus();
		return false;
	} else if (document.contacto.mensaje.value==""){
		alert("Por favor ingrese sus mensaje ");
		document.contacto.mensaje.focus();
		return false;
	}
	return true;
	
}


function validar_1registroboletin(){
	
	if (checkemail(document.frm_emailregistro.email.value)== false){
		return false;
	} else if(document.frm_emailregistro.nombre.value==""){
		alert(" ERROR: Por favor ingrese su nombre ");
		document.frm_emailregistro.nombre.focus();
		return false;
	} else if(document.frm_emailregistro.apellidos.value==""){
		alert(" ERROR: Por favor ingrese sus apellidos ");
		document.frm_emailregistro.apellidos.focus();
		return false;
	}

	return true;	
}

function validar_2registroboletin(){
	alert("hola");
	
	/*if (checkemail(document.altaregistro.email.value)== false){
		return false;
	} else */ if (document.altaregistro.nombre.value==""){
		alert(" ERROR: Por favor ingrese su nombre ");
		document.altaregistro.nombre.focus();
		return false;
	} else if(document.altaregistro.apellidos.value==""){
		alert(" ERROR: Por favor ingrese sus apellidos ");
		document.altaregistro.apellidos.focus();
		return false;
	}
	return true;
}



function validar_solicitud(opcion){
	if(document.cuenta.asunto.value==""){
		alert(" ERROR: Por favor ingrese el asunto ");
		document.cuenta.asunto.focus();
		return false
	}else if(document.cuenta.mensaje.value!=document.cuenta.nuevo_password.value){
		alert(" ERROR: Por favor ingrese el mensaje de la solicitud");
		document.cuenta.mensaje.focus();
		return false
	}else{
		document.cuenta.action='cuenta.php?cuenta='+opcion;
		document.cuenta.submit();
	}	
}
function validpsw(e) { 
	tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8 || tecla==46 || tecla==13) return true; //Tecla de retroceso (para poder borrar) 
    patron = /\w/; // Acepta números y letras 
    te = String.fromCharCode(tecla); 
    verifica= patron.test(te);
	if(verifica==false){
		alert("El caracter que esta tratando de ingresar no se permite");		
		return false;
	}else{
		return true
	}	
}

function validacaracter(e) { 
	tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8 || tecla==46 || tecla==13 || tecla==32) return true; //Tecla de retroceso (para poder borrar) 
    patron = /\w/; // Acepta números y letras 
    te = String.fromCharCode(tecla);
    verifica= patron.test(te);
	if(verifica==false){
		alert("El caracter que esta tratando de ingresar no se permite");		
		return false;
	}else{
		return true
	}	
}

function actualiza_producto(){
	document.cesta.action="cesta.php?car=update";
	document.cesta.submit();	
}

function validnum(e) { 
	tecla = (document.all) ? e.keyCode : e.which; 
	//alert(tecla)
    if (tecla==8 || tecla==46) return true; //Tecla de retroceso (para poder borrar) 
    // dejar la línea de patron que se necesite y borrar el resto 
    //patron =/[A-Za-z]/; // Solo acepta letras 
    patron = /\d/; // Solo acepta números
    //patron = /\w/; // Acepta números y letras 
    //patron = /\D/; // No acepta números 
    //patron = /[\d.-]/; numeros el punto y el signo -
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
	// uso  onKeyPress="return validnum(event)"
}

function buscar(url,texto){
	document.f2.action=url+'&q='+ texto.value;
	document.f2.submit();
}

function procesa_admin(){
	if(document.f1.usuario.value==""){
		alert("ERROR: Por favor ingrese Usuario");
		document.f1.usuario.focus();
		return false
	}else if(document.f1.password.value==""){
		alert("ERROR: Por favor ingrese Password");
		document.f1.password.focus();
		return false;
	}
	document.f1.action="admin/validacion.php";
	document.f1.submit();
	
	} 	
	
var testresults
	function checkemail(value){
		var str = value
		var filter=/^.+@.+\..{2,3}$/

		if (filter.test(str))
			testresults=true
		else{
			alert("Por favor ingrese un e-mail valido...");
			testresults=false
		}
		return (testresults)
	}	
	
function clave(value){
			var str = value
			var filter=/^.+@.+\..{2,3}$/

			if (filter.test(str))
				testresults=true
			else{
				alert(" Do not accept specials caracters ")
				testresults=false
			}
			return (testresults)
		}

function pedido(action){
	if (action=="finalizado"){	
		if (document.getElementById('nombre').value==""){
			alert(" ERROR: Por favor ingrese el nombre ");
			document.getElementById('nombre').focus();
			return false;
		}
		if (document.getElementById('apellidos').value==""){
			alert(" ERROR: Por favor ingrese los apellidos ");
			document.getElementById('apellidos').focus();
			return false;
		}
		if (document.getElementById('telefono').value==""){
			alert(" ERROR: Por favor ingrese el telefono ");
			document.getElementById('telefono').focus();
			return false;
		}
		
		if (document.getElementById('provincia').value==""){
			alert(" ERROR: Por favor ingrese la provincia ");
			document.getElementById('provincia').focus();
			return false;
		}
		
		if (document.getElementById('direccion').value==""){
			alert(" ERROR: Por favor ingrese la direccion ");
			document.getElementById('direccion').focus();
			return false;
		}
		
		if (document.getElementById('distrito').value==""){
			alert(" ERROR: Por favor ingrese el distrito ");
			document.getElementById('direccion').focus();
			return false;
		}
		
		
	}
	return true;
/*
	if (action=="finalizado"){	
			if (document.getElementById('nombre').value==""){
				alert(" ERROR: Por favor ingrese el nombre ");
				document.getElementById('nombre').focus();
				return false;
			}
			
			if (document.getElementById('apellidos').value==""){
				alert(" ERROR: Por favor ingrese los apellidos ");
				document.getElementById('apellidos').focus();
				return false;
			}

			if ((document.getElementById('email').indexOf ('@', 0) == -1)||(document.getElementById('email').length < 9)||(document.getElementById('email').indexOf ('.', 0) == -1)){ 
				alert(" ERROR: Por favor ingrese un email válido ");
				document.getElementById('apellidos').focus();
				return false;
			}
			
			if (document.getElementById('telefono').value==""){
				alert(" ERROR: Por favor ingrese el telefono ");
				document.getElementById('telefono').focus();
				return false;
			}
			
			if (document.getElementById('provincia').value==""){
				alert(" ERROR: Por favor ingrese la provincia ");
				document.getElementById('provincia').focus();
				return false;
			}
			
			if (document.getElementById('direccion').value==""){
				alert(" ERROR: Por favor ingrese la direccion ");
				document.getElementById('direccion').focus();
				return false;
			}
			
			if (document.getElementById('distrito').value==""){
				alert(" ERROR: Por favor ingrese el distrito ");
				document.getElementById('direccion').focus();
				return false;
			}
			
	}
	return true;
*/	
//return true;
}

function cambiar_direccion(opcion, from){	
	location.replace("pedido.php?pedido="+opcion+'&from='+from);	
	
}	

function validar_clientes(tipoForm, nombreForm){

	if (document.getElementById('nombre').value=="") {
		alert(" ERROR: Por favor ingrese el nombre ");
		document.getElementById('nombre').focus();
		document.getElementById('nombre').select();		
		return false;
	} else if(document.getElementById('apellidos').value==""){
		alert(" ERROR: Por favor ingrese el apellido ");
		document.getElementById('apellidos').select();				
		document.getElementById('apellidos').focus();
		return false;	
	} else if ((nombreForm.email.value.indexOf ('@', 0) == -1)||(nombreForm.email.value.length < 9)||(nombreForm.email.value.indexOf ('.', 0) == -1)||(nombreForm.email.value == "")){ 
		alert(" ERROR: Por favor ingrese el email ");
				nombreForm.email.focus();
				nombreForm.email.select();
				return (false);
	} else if(document.getElementById('telefono').value==""){
		alert(" ERROR: Por favor ingrese el teléfono ");
		document.getElementById('telefono').select();				
		document.getElementById('telefono').focus();
		return false;	
	}

	if (tipoForm=="new"){
		if(document.getElementById('nuevo_password').value==""){
			alert(" ERROR: Por favor ingrese el Password ");
			document.getElementById('nuevo_password').focus();
			return false	
		} else if(document.getElementById('nuevo_password').value!=document.getElementById('password_confirma').value){
			alert(" ERROR: El password tiene que ser identico al campo confirmar password ");
			document.getElementById('nuevo_password').value=="";
			document.getElementById('password_confirma').value=="";
			document.getElementById('nuevo_password').focus();
			return false	
		}

		if(document.getElementById('dir_nombre').value==""){
			alert(" ERROR: Por favor ingrese el nombre del destinatario ");
			document.getElementById('dir_nombre').focus();
			return false;
		}

		if(document.getElementById('dir_apellidos').value==""){
			alert(" ERROR: Por favor ingrese los apellidos del destinatario ");
			document.getElementById('dir_apellidos').focus();
			return false;
		}	
		
		if(document.getElementById('dir_departamento').value==""){
			alert(" ERROR: Por favor ingrese el departamento (ciudad) del destinatario");
			document.getElementById('dir_departamento').focus();
			return false;
		}	

		if(document.getElementById('dir_direccion').value==""){
			alert(" ERROR: Por favor ingrese la direccion del destinatario destinatario");
			document.getElementById('dir_direccion').focus();
			return false;
		}
		if(document.getElementById('default').checked==false){
			alert(" ERROR: El check de direccion predetrerminada tiene que estar marcado");
			document.getElementById('default').focus();
			return false;
		}
		
	}
	
	return true;
}

function validar_confirmarenvio(nombreForm){
	
	if (document.getElementById('envdir_departamento').value==""){
		alert(" ERROR: Por favor ingrese el departamento");
		return false;	
	} else if(document.getElementById('envdir_direccion').value==""){
		alert(" ERROR: Por favor ingrese la direccion");
		document.getElementById('envdir_direccion').focus();
		return false;	
	} else if(document.getElementById('env_comprobantepago').value==""){
		alert(" ERROR: Por favor ingrese el comprobante de pago");
		document.getElementById('env_comprobantepago').focus();
		return false;	
	} 
	
	return true;
}

function validar_comentario(nombreForm){

	if (document.getElementById('cmt_nombre').value=="") {
		alert(" ERROR: Por favor ingrese el nombre.");
		document.getElementById('cmt_nombre').focus();
		document.getElementById('cmt_nombre').select();		
		return false;
	} else if ((nombreForm.cmt_email.value.indexOf ('@', 0) == -1)||(nombreForm.cmt_email.value.length < 9)||(nombreForm.cmt_email.value.indexOf ('.', 0) == -1)||(nombreForm.cmt_email.value == "")){ 
		alert(" ERROR: Por favor ingrese el email ");
				nombreForm.cmt_email.focus();
				nombreForm.cmt_email.select();
				return (false);
	} else if(document.getElementById('cmt_departamento').value==""){
		alert(" ERROR: Por favor ingrese el departamento");
		return false;	
	} else if(document.getElementById('cmt_comentario').value==""){
		alert(" ERROR: Por favor ingrese el comentario");
		document.getElementById('cmt_comentario').select();				
		document.getElementById('cmt_comentario').focus();
		return false;	
	}	
	return true;
}

function cancelar_cuenta(){
	document.cuenta.action="cuenta.php";
	document.cuenta.submit();	
}

function ventanaSecundaria (URL){ 
   window.open(URL,"ventana1","width=600,height=500,scrollbars=NO") 
} 

function emailvalido(email){
	if ((document.getElementById("'"+email+"'").indexOf ('@', 0) == -1)||(document.getElementById("'"+email+"'").length < 9)||(document.getElementById(email).indexOf ('.', 0) == -1)) { 
		alert("Ingrese un email válido");
		document.getElementById("'"+email+"'").focus();
		document.getElementById("'"+email+"'").select();
		return (false);
	}
	return false;
}

function ajax_distritos(iddir,iddis,iddep,prefijo){
	//var d = Math.random();
	//var iddep = $("#cli_departamento").val();
	$("#"+prefijo+"divDistrito").load('sql_distritos.php?iddir='+iddir+'&iddep='+iddep+'&iddis='+iddis+'&prefijo='+prefijo);		
	
}

function ajax_imagehome(id){
	$("#img_home").load('sql_imagehome.php?id='+id);		
}

/* tabs content box*/
function init(){
	var stretchers = document.getElementsByClassName('box');
	var toggles = document.getElementsByClassName('tab');
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: false, height: true, duration:600}
	);
	//hash functions
	var found = false;
	toggles.each(function(h3, i){
		var div = Element.find(h3, 'nextSibling');
			if (window.location.href.indexOf(h3.title) > 0) {
				myAccordion.showThisHideOpen(div);
				found = true;
			}
		});
		if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}

function goPage(currentpage){
	location.href=currentpage;	
}

function ejecutarCarro(theForm){
	theForm.submit();
}

function estado_paginador(k){

	$("#p"+k).css({background: "#9A9969",color: "#fff"});
}

function validar_form(){
	if(document.f5.nombre.value==""){
		alert("ERROR : Ingrese el nombre ");
		document.f5.nombre.focus();
		return false;
	}else if(document.f5.apellidos.value==""){
		alert("ERROR : Ingrese el apellido ");
		document.f5.apellidos.focus();
		return false;
	}else if(document.f5.email.value==""){
		alert("ERROR : Ingrese el email ");
		document.f5.email.focus();
		return false;
	}else if(document.f5.mensaje.value==""){
		alert("ERROR : Ingrese el mensaje ");
		document.f5.mensaje.focus();
		return false;
	}else{
		document.f5.action="enviar.php";
		document.f5.submit();
	}
}

function ver_calendario(){
	$("#calender").load('calendario.php?pmes=0');
	
	$("#atras").click(function(){
		var t = $("#atras").attr("title");
		$("#calender").load("calendario.php?pmes=1&opt="+t+"");					   
	});
	
	$("#siguiente").click(function(){
		var t = $("#siguiente").attr("title");
		$("#calender").load("calendario.php?pmes=1&opt="+t+"");					   
	});	
}

function emailCheck (emailStr) {
	if(emailStr.length>=1){
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
			return 0;
		}
		var user=matchArray[1]
		var domain=matchArray[2]
		
		if (user.match(userPat)==null) {
			return 0;
		}
	
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			for (var i=1;i<=4;i++) {
				if(IPArray[i]>255){
					return 0;
				}
			}
			return 1;
		}
	
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			return 0;
		}
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
			domArr[domArr.length-1].length>3) {
		   return 0;
		}
	
		if (len<2) {
		   return 0;
		}
		
	}else{
		return 1;
	}

}

function validaForm(ruta){

var propControl = new Array();
debecontar=0;
contar=0;
validar=0;
validarmail=0;
vacios=0;
	for(var i=0; i<ruta.elements.length; i++){
		controlAct=ruta.elements[i];
		if(ruta.elements[i].title.indexOf("*")!=-1){//si existe * entonces valida datos del control actual
			propControl = ruta.elements[i].title.split("*");
			//alert(propControl[1]);
			if(propControl[1].indexOf("r")!= -1){//si es diferente de -1 entonces es un control requerido
				if(controlAct.value=="" || controlAct.value=="0"){
					alert("El campo \""+propControl[0]+"\" es obligatorio");
					controlAct.focus();
					return false;
					break;
				}
			}
			if(propControl[1].indexOf("m")!= -1){//si es diferente de -1 entonces se debe validar el email
				if(emailCheck(controlAct.value)==0){
					alert("El email no es valido");
					controlAct.focus();
					return false;
					break;
				}
			}
			if(propControl[1].indexOf("c")!= -1){
				debecontar=1;
				contar=contar+1;
				if(controlAct.value==""){
					vacios=vacios+1;
					if(contar==1){
						kontrol=controlAct;
						nombreKontrol=propControl[0];
					}
				}				
			}			
			if(propControl[1].indexOf("f")!= -1){
				if(checkDecimals(controlAct)==0){
					alert("Le champ "+propControl[0]+" ne doit pas contenir de caractères alphanumériques");
					controlAct.focus();
					controlAct.select();
					return false;
					break;
				}else{
					num=roundOff(controlAct.value, 2);
					//alert(num);
				}				
			}
			if(propControl[1].indexOf("p1")!= -1){//hay un "campo password"
				password1=controlAct.value;
			}
			if(propControl[1].indexOf("p2")!= -1){//hay un campo "repetir password"
				password2=controlAct.value;
				validar=1;
				ctrlRep=controlAct;
			}
			if(propControl[1].indexOf("m1")!= -1){//hay un "campo email"
				email1=controlAct.value;
			}
			if(propControl[1].indexOf("m2")!= -1){//hay un campo "repetir email"
				email2=controlAct.value;
				validarmail=1;
				ctrlRep=controlAct;
			}
			if(propControl[1].indexOf("chk")!= -1){//si es diferente de -1 indica que se debe hacer check
				if(controlAct.checked==false){
					alert("El campo \""+propControl[0]+"\" es obligatorio");
					controlAct.focus();
					return false;
					break;
				}
			}
		}
	}
	if(validarmail==1){
		if(email1!=email2){
			alert('Tienes que repetir el email correctamente');
			ctrlRep.focus();
			ctrlRep.select();
			return false;
		}
	}
	if(validar==1){
		if(password1!=password2){
			alert('Tienes que repetir el password correctamente');
			ctrlRep.focus();
			ctrlRep.select();
			return false;
		}
	}
	if(debecontar==1){
		if(contar==vacios){
			alert('Los campos "'+nombreKontrol+'" no estan permitidos ');
			kontrol.focus();
			return false;
		}
	}
}

function ver_hoteles(valor){
	if(valor>0){
		var texto = document.frm_hoteles.cbodistrito.options[document.frm_hoteles.cbodistrito.selectedIndex].text;
		//alert(texto);
		document.frm_hoteles.action='hoteles.php?id='+valor+'&n='+texto;	
		document.frm_hoteles.submit();
	}else{
		alert("Escoja una provincia");
		return false;
	}
}

function ver_distrito(valor){
	if(valor>0){
		document.frm_distrito.action='destinos.php?listd='+valor;	
		document.frm_distrito.submit();
	}else{
		alert("Escoja una provincia");
		return false;
	}
}

function ver_hoteles(valor){
	if(valor>0){
		document.frm_distrito.action='hoteles.php?list='+valor;	
		document.frm_distrito.submit();
	}else{
		alert("Escoja una provincia");
		return false;
	}
}


function boletin(){
	if(document.getElementById("txt_boletin").value==""){
		alert(" ERROR: Por favor ingrese su email ");
		document.getElementById("txt_boletin").focus();
		return false
	}else if(checkemail(document.getElementById("txt_boletin").value)== false){
		document.getElementById("txt_boletin").focus();
		return false;
	}else{
		valemail = document.getElementById("txt_boletin").value;
		window.open('popup_boletin.php?email='+valemail , "Boletin" ,"width=450,height=290 , scrollbars=1");
	}
}
