//var DOMINIO = 'http://localhost/directodepromotor/';
//var DOMINIO = 'http://localhost/28-05-2008/directodepromotor/';
var DOMINIO = 'http://www.directodepromotor.com/';
//var DOMINIO = '';

function make_blank1(){
   document.getElementById("login").username.value ="";
}

function make_blank1b(){
   if(document.getElementById("login").username.value ==""){
       document.getElementById("login").username.value ="usuario";
   }
}

function make_blank2(){
	if(document.getElementById("login")){
		
		document.getElementById("login").passwd.value ="";
		var uno = "<input class='caja1' type='text' onclick='make_blank2();' onblur='make_blank2b();' name='passwd' value='contraseña' />";
		var dos = "<input class='caja1' type='password' onclick='make_blank2();' onblur='make_blank2b();' name='passwd' value='' />";
		document.getElementById("pp").innerHTML=dos;
		document.getElementById("login").passwd.focus();
		if(document.getElementById("passwd")){
			document.getElementById("passwd").focus();
			//document.forms[0].elements["passwd"].focus();
		}
	}
}

function make_blank2b(){
   if(document.getElementById("login").passwd.value ==""){
       document.getElementById("login").passwd.value ="contraseña";
			 var uno = "<input class='caja1' type='text' onclick='make_blank2();' onblur='make_blank2b();' name='passwd' value='contraseña' />";
			 var dos = "<input class='caja1' type='password' onclick='make_blank2();' onblur='make_blank2b();' name='passwd' value='' />";
			 document.getElementById("pp").innerHTML=uno;
  }
}

function Desconectarse(id_usuario){
    if(confirm("¿Desea desconectarse?")) {
        document.location.href= DOMINIO + 'desconectarse/id_usuario/'+ id_usuario +'/';
    }
}

function AgregarFavoritos(browser){
	
   if(browser == "Firefox" || browser == "Safari"){
	    alert('Para agregarnos a tus marcadores presiona Ctrl+D.');
	}
	if(browser == "Opera"){
	    alert('Para agregarnos a tus marcadores presiona Ctrl+T.');
	}
	if(browser == "Internet Explorer"){
	    var url="http://www.directodepromotor.com/"; 
      	var titulo="Directo de Promotor";
      	window.external.AddFavorite(url,titulo);
      	
	}	 
}

function validarCampo(){
   if(document.getElementById("buscadores").palabra.value == ""){
	    alert('Desbes escribir alguna palabra.');
			document.getElementById("buscadores").palabra.focus();
			return;
	 }else{document.getElementById("buscadores").submit();}
}

function validarCampo2(){
   if(document.getElementById("buscadores").localidad.value == ""){
	    alert('Debes elegir alguna localidad.');
			document.getElementById("buscadores").localidad.focus();
			return;
	 }else{document.getElementById("buscadores").submit();}
}

function validarCampo3(){
   if(document.getElementById("buscadores").localidad.value == ""){
	    alert('Debes elegir alguna localidad.');
			document.getElementById("buscadores").localidad.focus();
			return;
	 }else{
	    if(document.getElementById("sus_searchs").checked == true){
			   var band = true;
				 if(document.getElementById("buscadores").miemail.value == ""){
				    band = false;
						alert('Debes ingresar tu dirección de e-mail.');
						document.getElementById("buscadores").miemail.focus();
						return;
				 }else{
				    var s = document.getElementById("buscadores").miemail.value;
						var filter=/^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
						if(filter.test(s)){
						   document.getElementById("buscadores").submit();
							 return;
						}
						else{
							 band = false;	 
						   alert("Ingrese una dirección de correo válida");
							 document.getElementById("buscadores").miemail.focus();
							 return;
						}	 
				 }
				 if(band){document.getElementById("buscadores").submit();}
			}else{document.getElementById("buscadores").submit();}
	 }
}

function ShowPopUp(page,ancho,alto){
   window.open(page,"ventana1","width="+ ancho +", height="+ alto +", scrollbars=no, menubar=no, location=no, resizable=no, top=100, left=100")
}

function Borrar(id,tipo,subtipo) {
    switch(tipo){
		   case "tipologias":
			 				 					 if(confirm("¿Realmente desea eliminar esta tipología?")) {
        								    document.location.href= DOMINIO + 'index.php?secc=eliminar-objetos&idobjeto='+ id +'&tipo='+ tipo +'&subtipo='+ subtipo +'';
    										 }
							 					 break;
			case "tipologias2":
			 				 					 if(confirm("¿Realmente desea eliminar esta tipología?")) {
        								    document.location.href= DOMINIO + 'index.php?secc=eliminar-objetos&idobjeto='+ id +'&tipo='+ tipo +'&subtipo='+ subtipo +'';
    										 }
							 					 break;									 
			case "promociones":
					 							 if(confirm("¿Realmente desea eliminar esta promoción?")) {
        								    	document.location.href= DOMINIO + 'index.php?secc=eliminar-objetos&idobjeto='+ id +'&tipo='+ tipo +'&subtipo='+ subtipo +'';
    										 }
							 					 break;
			
			case "promocioness":
	 						if(confirm("¿Realmente desea eliminar esta promoción?")) {
						    	document.location.href= DOMINIO + 'index.php?secc=eliminar-objetos&idobjeto='+ id +'&tipo='+ tipo +'&subtipo='+ subtipo +'';
							}
			 				break;
			 				
			case "banners":
 							if(confirm("¿Realmente desea eliminar este banner ?")) {
 							 	
					    		document.location.href= DOMINIO + 'index.php?secc=eliminar-objetos&idobjeto='+ id +'&tipo='+ tipo +'&subtipo='+ subtipo +'';
						 	}
		 					break;
		 	case "tipologiass":
			 				if(confirm("¿Realmente desea eliminar esta tipología?")) {
			 					//alert(DOMINIO + 'index.php?secc=eliminar-objetos&idobjeto='+ id +'&tipo='+ tipo +'&subtipo='+ subtipo +'');
					    		document.location.href= DOMINIO + 'index.php?secc=eliminar-objetos&idobjeto='+ id +'&tipo='+ tipo +'&subtipo='+ subtipo +'';
						 	}
		 					break;
		 					
			case "localidades":
			 				if(confirm("¿Realmente desea eliminar esta localidad?")) {
			 					//alert(DOMINIO + 'index.php?secc=eliminar-objetos&idobjeto='+ id +'&tipo='+ tipo +'&subtipo='+ subtipo +'');
			 					document.location.href= DOMINIO + 'index.php?secc=eliminar-objetos&idobjeto='+ id +'&tipo='+ tipo +'';
					    		//document.location.href= DOMINIO + '?secc=backprincipal&subsecc=ver-localidades';
						 	}
		 					break;
							 					 
							 					 				
		 					
		} //fin switch tipo
}

function Borrar_obj(id,tipo,subtipo) {
    if(confirm("¿Realmente desea eliminar este archivo?")) {
       document.location.href= DOMINIO + 'index.php?secc=eliminar-objetos&idobjeto='+ id +'&tipo='+ tipo +'&subtipo='+ subtipo +'';
    }
}

function Borrar_obj2(id,tipo,subtipo) {
    if(confirm("¿Realmente desea eliminar este archivo?")) {
       document.location.href= DOMINIO + '?secc=backprincipal&subsecc=editar-tipologias&idtipologia='+id+'&idpromo='+subtipo+'';
    }
}

function BuscarXPais(idpais,cat) {
    var nombrepais='';
		if(idpais == 1){nombrepais='espana';}
		if(idpais == 2){nombrepais='brasil';}
		if(idpais == 3){nombrepais='marruecos';}
		if(idpais == 4){nombrepais='portugal';}
		document.location.href= DOMINIO + 'buscador/resultados/'+ cat +'/'+ nombrepais +'/'+ idpais +'/';
}

function InfoProvincias(provincia,num){
   	if(document.getElementById('dynamic')){
		document.getElementById('dynamic').style.visibility = "visible";
		ContentInfo=''+ provincia +'<br/>'+ num +' promociones';
		document.getElementById('dynamic').innerHTML = ContentInfo;
   	}
}

function InfoProvincias2(provincia,num){
	if(document.getElementById('dynamic2')){
		document.getElementById('dynamic2').style.visibility = "visible";
		ContentInfo=''+ provincia +'<br/>'+ num +' promociones';
		document.getElementById('dynamic2').innerHTML = ContentInfo;
	}
}

function DeleteInfo(){
	if(document.getElementById('dynamic')){
   		document.getElementById('dynamic').style.visibility = "hidden";
	}
}

function DeleteInfo2(){
	if(document.getElementById('dynamic2')){
		document.getElementById('dynamic2').style.visibility = "hidden";
	}
}

function Habilitar(){
      if(document.getElementById('sus_searchs').checked == true){
			      document.getElementById('visi1').style.visibility = "visible";
				    document.getElementById('visi2').style.visibility = "visible";
			}else{
			      document.getElementById('visi1').style.visibility = "hidden";
				    document.getElementById('visi2').style.visibility = "hidden";
			}	 
}
