function MM_preloadImages() { //v3.0
  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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function nuevoAjax()
{ 
	var xmlhttp=false; 
	try 
	{ 
		// No IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 
	return xmlhttp; 
}



function TraerConvenios(id,ruta){
	if(id != "0"){
		document.getElementById('s_es').style.display='inline';
        divResultado = document.getElementById('s_es');
		datos=ruta+'php_ajax/consultasAjax.php?id_ciudad=' + id + '&id_tipo=convenios';
		ajax=nuevoAjax();
		ajax.open("GET", datos);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				document.getElementById('s_es').innerHTML = ajax.responseText
			}
		}
		ajax.send(null)
	}
	
}

function TraerEspecialidades(id,ruta){
	
	if(id != "0"){
		//document.getElementById('especialidades').style.display='inline';
        divResultado = document.getElementById('especialidades');
		datos=ruta+'php_ajax/consultasAjax.php?id_ciudad=' + id + '&id_tipo=especialidades';
		
		ajax=nuevoAjax();
		ajax.open("GET", datos);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				//alert(ajax.responseText)
				document.getElementById('especialidades').innerHTML = ajax.responseText
				
			}
		}
		ajax.send(null)
	}
	
	
}

function cambiarvalue(valueselect){
	document.getElementById('textespecialidades').value=valueselect;
	
}

function TraerCiudades(id,ruta){
	if(id != "0"){
		document.getElementById('s_es').style.display='inline';
        divResultado = document.getElementById('s_es');
		datos=ruta+'php_ajax/consultasAjax.php?id_pais=' + id + '&id_tipo=ciudades';
		ajax=nuevoAjax();
		ajax.open("GET", datos);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				divResultado.innerHTML = ajax.responseText
			}
		}
		ajax.send(null)
	}
	
}


function TraerCiudadesTitular(id,ruta,div,id2){
	if(id != "0"){
	    divResultado = document.getElementById(div);
		datos=ruta+'php_ajax/consultasAjax.php?id_pais=' + id + '&id_tipo=ciudades_tit&di=' + div+'&di_2='+id2;
		ajax=nuevoAjax();
		ajax.open("GET", datos);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				divResultado.innerHTML = ajax.responseText
			}
		}
		ajax.send(null)
	}
	
}



function validar_buscar_descuentos(){
	pal=document.getElementById('categoria').value;
	
	if (pal != 0){
		document.form2.submit();
	}else{
		alert("Debes escoger una categoria")
		return false ;
	}
}


function mostrarhome(id,cantidad){
	nombre = "foto"+id;
	for(x=0;x<=cantidad;x++){
		document.getElementById("foto"+x).style.display = "none";
	}
	document.getElementById(nombre).style.display = "";
	
}



function ClickBanner(id,ruta){
	datos=ruta+'php_ajax/consultasAjax.php?id_banner=' + id + '&id_tipo=banners';
	ajax=nuevoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			return true;
		}
	}
	ajax.send(null)
	
}

function TraerCiudadTipo(ruta,pais,id){
	datos=ruta+'php_ajax/consultasAjax.php?id_pais='+pais+'&id_ciudad=' + id + '&id_tipo=Solictud';
	ajax=nuevoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//alert(ajax.responseText)
			document.getElementById("TipoSolicitud").innerHTML = ajax.responseText
			
		}
	}
	ajax.send(null)
	
}

function mostrarfile(id){
	var file=document.getElementById("DivFile");
	if(id==35){
		file.style.display='';
		
	}else{
		file.style.display='none';
	}
}

function validar_archivo_contacto(pais){
	
	if(pais==2){
		var file=document.getElementById("DivFile");
		var archivo = document.getElementById("archivo").value;
		if(file.style.display==''){
		
			if (archivo!=''){
				
			msj = comprueba_extension(document.getElementById("archivo").value)
				if(msj !=1){
					alert(msj)
				}
			}else{
				document.form.submit();
			}
		}else{
			document.form.submit();
		}
	}else{
		document.form.submit();
	}
}

function comprueba_extension(archivo) { 
   extensiones_permitidas = new Array(".zip", ".doc",".docx", ".pdf"); 
   mierror = ""; 
   
   //recupero la extensión de este nombre de archivo 
   extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 
   //compruebo si la extensión está entre las permitidas 
   permitida = false; 
   for (var i = 0; i < extensiones_permitidas.length; i++) { 
     if (extensiones_permitidas[i] == extension) { 
       permitida = true; 
       break; 
     } 
   } 
   if (!permitida) { 
        mierror = "Comprueba la extensión de los archivos a subir. \nSólo se pueden subir archivos con extensiones: " + extensiones_permitidas.join(); 
		return mierror; 
   }else{ 
      //submito! 
      return 1; 
   } 
   
} 


//===============================================================================================
//PAISES DE TITUTAR
//===============================================================================================

function paises_mundo(ruta,name,titular){
	
	EliminaOpciones(document.getElementById(name));
	opc = new Option('Escoger','0');
	eval(document.getElementById(name).options[0]=opc)
	
	
	//elimino las opciones del select de departamentos
	EliminaOpciones(document.getElementById('datos_tit_1'));
	// agrego un nuevo option con el valor 0
	opc = new Option('Escoger','0');
	eval(document.getElementById('datos_tit_1').options[0]=opc)
	
	
	//elimino las opciones del select de ciudades
	EliminaOpciones(document.getElementById('datos_tit_2'));
			
	// agrego un nuevo option con el valor 0
	opc = new Option('Escoger','0');
	eval(document.getElementById('datos_tit_2').options[0]=opc)
	
	
	
	//elimino las opciones del select de ciudades
	EliminaOpciones(document.getElementById('datos_tit_12'));
			
	// agrego un nuevo option con el valor 0
	opc = new Option('Escoger','0');
	eval(document.getElementById('datos_tit_12').options[0]=opc)
	
	
	//elimino las opciones del select de ciudades
	EliminaOpciones(document.getElementById('datos_tit_13'));
			
	// agrego un nuevo option con el valor 0
	opc = new Option('Escoger','0');
	eval(document.getElementById('datos_tit_13').options[0]=opc)
	
	//elimino las opciones del select de ciudades
	EliminaOpciones(document.getElementById('datos_tit_14'));
			
	// agrego un nuevo option con el valor 0
	opc = new Option('Escoger','0');
	eval(document.getElementById('datos_tit_14').options[0]=opc)
	
	
	
	
/*	Escondo esto por peticion del cliente

	//elimino las opciones del select de ciudades
	EliminaOpciones(document.getElementById('datos_tit_16'));
			
	// agrego un nuevo option con el valor 0
	opc = new Option('Escoger','0');
	eval(document.getElementById('datos_tit_16').options[0]=opc)
	
	
	//elimino las opciones del select de ciudades
	EliminaOpciones(document.getElementById('datos_tit_17'));
			
	// agrego un nuevo option con el valor 0
	opc = new Option('Escoger','0');
	eval(document.getElementById('datos_tit_17').options[0]=opc)
	
	//elimino las opciones del select de ciudades
	EliminaOpciones(document.getElementById('datos_tit_18'));
			
	// agrego un nuevo option con el valor 0
	opc = new Option('Escoger','0');
	eval(document.getElementById('datos_tit_18').options[0]=opc)

*/
	
	
	
	if(titular==1){
		$('#'+name).change(function(){
			DepartamentCol(ruta,'datos_tit_1',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_1').change(function(){
			CiudadesCol(ruta,'datos_tit_2',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_12').change(function(){
			DepartamentCol(ruta,'datos_tit_13',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_13').change(function(){
			CiudadesCol(ruta,'datos_tit_14',this.options[this.selectedIndex].value);
		});
		
		/* Escondo por peticion del cliente
		$('#datos_tit_16').change(function(){
			DepartamentCol(ruta,'datos_tit_17',this.options[this.selectedIndex].value);
		});
		$('#datos_tit_17').change(function(){
			CiudadesCol(ruta,'datos_tit_18',this.options[this.selectedIndex].value);
		});*/
		
	}else{
		
		$('#'+name).change(function(){
			DepartamentWord(ruta,'datos_tit_1',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_1').change(function(){
			CiuadesWord(ruta,'datos_tit_2',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_12').change(function(){
			DepartamentWord(ruta,'datos_tit_13',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_13').change(function(){
			CiuadesWord(ruta,'datos_tit_14',this.options[this.selectedIndex].value);
		});
		
		/* Escondo Por peticion del cliente
		$('#datos_tit_16').change(function(){
			DepartamentWord(ruta,'datos_tit_17',this.options[this.selectedIndex].value);
		});
		$('#datos_tit_17').change(function(){
			CiuadesWord(ruta,'datos_tit_18',this.options[this.selectedIndex].value);
		});*/
	}
	
	
	//alert('id: '+name)
	datos=ruta+'php_ajax/consultasAjax.php?id_tipo=paises&titular='+titular;
	
	ajax=nuevoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			
			
			
			val=ajax.responseText.split('--')
			
			obj=document.getElementById(name);
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('-')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}
			
			obj=document.getElementById('datos_tit_12');
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('-')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}
			
	/*	Escondo por peticion del cliente
			obj=document.getElementById('datos_tit_16');
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('-')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}
			*/
			
			//$('#'+name).attr({"onchange":'DepartamentCol("'+ruta+'","'+name+'",this.options[this.selectedIndex].value);'});
			
			
			
		}
	}
	ajax.send(null)
}

function DepartamentWord(ruta,id,pais){
	//alert('mi code '+pais)
	
	
	datos=ruta+'php_ajax/consultasAjax.php?id_tipo=estados_word&pais='+pais;
	
	ajax=nuevoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//alert(ajax.responseText)
			obj=document.getElementById(id);
			
			val=ajax.responseText.split('---')
			
			try{
				for(i=0;i<50000;i++){
					obj.options[0]=null;
				}
			}
			catch(e){}			
			
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('|')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}			
		}
	}
	ajax.send(null)
	
	
	
}

function DepartamentCol(ruta,id,pais){
	//alert('mi code '+pais)
	
	
	datos=ruta+'php_ajax/consultasAjax.php?id_tipo=estados_col&pais='+pais;
	
	ajax=nuevoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//alert(ajax.responseText)
			obj=document.getElementById(id);
			
			val=ajax.responseText.split('---')
			
			try{
				for(i=0;i<50000;i++){
					obj.options[0]=null;
				}
			}
			catch(e){}			
			
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('|')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}			
		}
	}
	ajax.send(null)
	
	
	
}




function CiuadesWord(ruta,id,depart){
	//alert('mi code '+pais)
	
	
	datos=ruta+'php_ajax/consultasAjax.php?id_tipo=ciudades_word&depar='+depart;
	
	ajax=nuevoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//alert(ajax.responseText)
			obj=document.getElementById(id);
			
			val=ajax.responseText.split('---')
			
			try{
				for(i=0;i<50000;i++){
					obj.options[0]=null;
				}
			}
			catch(e){}			
			
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('|')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}			
		}
	}
	ajax.send(null)
	
	
	
}

function CiudadesCol(ruta,id,depart){
	//alert('mi ciudad col '+depart)
	
	
	datos=ruta+'php_ajax/consultasAjax.php?id_tipo=ciudades_col&depar='+depart;
	
	ajax=nuevoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//alert(ajax.responseText)
			obj=document.getElementById(id);
			
			val=ajax.responseText.split('---')
			
			try{
				for(i=0;i<50000;i++){
					obj.options[0]=null;
				}
			}
			catch(e){}			
			
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('|')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}			
		}
	}
	ajax.send(null)
	
	
	
}

//eliminacion de opcione del select
function EliminaOpciones(ObjetoSelect){
	j=ObjetoSelect.length-1
	while(j>=0){
		ObjetoSelect.remove(j)
		j--
	}
}//fin de elimina opciones




/*-----------------FUNCIONES PARA LA TIENDA DE URUGUAY--------------------*/
function CiudadesURU(ruta,id,depart){
	//alert('mi ciudad col '+depart)
	
	
	datos=ruta+'php_ajax/consultasAjax.php?id_tipo=ciudades_uru&depar='+depart;
	
	ajax=nuevoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//alert(ajax.responseText)
			obj=document.getElementById(id);
			
			val=ajax.responseText.split('---')
			
			try{
				for(i=0;i<50000;i++){
					obj.options[0]=null;
				}
			}
			catch(e){}			
			
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('|')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}			
		}
	}
	ajax.send(null)
	
	
	
}


function DepartamentURU(ruta,id,pais){
	//alert('mi code '+pais)
	
	
	datos=ruta+'php_ajax/consultasAjax.php?id_tipo=estados_uru&pais='+pais;
	
	ajax=nuevoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			//alert(ajax.responseText)
			obj=document.getElementById(id);
			
			val=ajax.responseText.split('---')
			
			try{
				for(i=0;i<50000;i++){
					obj.options[0]=null;
				}
			}
			catch(e){}			
			
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('|')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}			
		}
	}
	ajax.send(null)
	
	
	
}


function paises_mundo_uruguay(ruta,name,titular){
	
	EliminaOpciones(document.getElementById(name));
	opc = new Option('Escoger','0');
	eval(document.getElementById(name).options[0]=opc)
	
	
	//elimino las opciones del select de departamentos
	EliminaOpciones(document.getElementById('datos_tit_1'));
	// agrego un nuevo option con el valor 0
	opc = new Option('Escoger','0');
	eval(document.getElementById('datos_tit_1').options[0]=opc)
	
	
	//elimino las opciones del select de ciudades
	EliminaOpciones(document.getElementById('datos_tit_2'));
			
	// agrego un nuevo option con el valor 0
	opc = new Option('Escoger','0');
	eval(document.getElementById('datos_tit_2').options[0]=opc)
	
	
	
	//elimino las opciones del select de ciudades
	//EliminaOpciones(document.getElementById('datos_tit_12'));
			
	// agrego un nuevo option con el valor 0
	//opc = new Option('Escoger','0');
	//eval(document.getElementById('datos_tit_12').options[0]=opc)
	
	
	//elimino las opciones del select de ciudades
	//EliminaOpciones(document.getElementById('datos_tit_13'));
			
	// agrego un nuevo option con el valor 0
	//opc = new Option('Escoger','0');
	//eval(document.getElementById('datos_tit_13').options[0]=opc)
	
	//elimino las opciones del select de ciudades
	//EliminaOpciones(document.getElementById('datos_tit_14'));
			
	// agrego un nuevo option con el valor 0
	//opc = new Option('Escoger','0');
	//eval(document.getElementById('datos_tit_14').options[0]=opc)
	
	
	
	
	//elimino las opciones del select de ciudades
	//EliminaOpciones(document.getElementById('datos_tit_16'));
			
	// agrego un nuevo option con el valor 0
	//opc = new Option('Escoger','0');
	//eval(document.getElementById('datos_tit_16').options[0]=opc)
	
	
	//elimino las opciones del select de ciudades
	//EliminaOpciones(document.getElementById('datos_tit_17'));
			
	// agrego un nuevo option con el valor 0
	//opc = new Option('Escoger','0');
	//eval(document.getElementById('datos_tit_17').options[0]=opc)
	
	//elimino las opciones del select de ciudades
	//EliminaOpciones(document.getElementById('datos_tit_18'));
			
	// agrego un nuevo option con el valor 0
	//opc = new Option('Escoger','0');
	//eval(document.getElementById('datos_tit_18').options[0]=opc)
	
	
	
	if(titular==1){
		$('#'+name).change(function(){
			DepartamentURU(ruta,'datos_tit_1',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_1').change(function(){
			CiudadesURU(ruta,'datos_tit_2',this.options[this.selectedIndex].value);
		});
		
		/*$('#datos_tit_12').change(function(){
			DepartamentCol(ruta,'datos_tit_13',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_13').change(function(){
			CiudadesCol(ruta,'datos_tit_14',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_16').change(function(){
			DepartamentCol(ruta,'datos_tit_17',this.options[this.selectedIndex].value);
		});
		$('#datos_tit_17').change(function(){
			CiudadesCol(ruta,'datos_tit_18',this.options[this.selectedIndex].value);
		});*/
		
	}else{
		
		$('#'+name).change(function(){
			DepartamentWord(ruta,'datos_tit_1',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_1').change(function(){
			CiuadesWord(ruta,'datos_tit_2',this.options[this.selectedIndex].value);
		});
		
		/*$('#datos_tit_12').change(function(){
			DepartamentWord(ruta,'datos_tit_13',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_13').change(function(){
			CiuadesWord(ruta,'datos_tit_14',this.options[this.selectedIndex].value);
		});
		
		$('#datos_tit_16').change(function(){
			DepartamentWord(ruta,'datos_tit_17',this.options[this.selectedIndex].value);
		});
		$('#datos_tit_17').change(function(){
			CiuadesWord(ruta,'datos_tit_18',this.options[this.selectedIndex].value);
		});*/
	}
	
	
	//alert('id: '+name)
	datos=ruta+'php_ajax/consultasAjax.php?id_tipo=paisesURU&titular='+titular;
	
	ajax=nuevoAjax();
	ajax.open("GET", datos);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			
			
			
			val=ajax.responseText.split('--')
			
			obj=document.getElementById(name);
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('-')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}
			
			/*obj=document.getElementById('datos_tit_12');
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('-')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}
			
			obj=document.getElementById('datos_tit_16');
			for(x=0;x<(val.length-1);x++){
				
				option=val[x].split('-')
				
				valor=option[0];
				txt=option[1];
				
				opc = new Option(txt,valor);
				
				eval(obj.options[x]=opc)
				
				
			}*/
			
			
			//$('#'+name).attr({"onchange":'DepartamentCol("'+ruta+'","'+name+'",this.options[this.selectedIndex].value);'});
			
			
			
		}
	}
	ajax.send(null)
}
