
function LanzarValor(form)
{	form.submit();
}

function fieldfocus(campo)
{var campo;
if(campo=='Cadena')
	{f=document.formBusqueda.Cadena;
	f.focus();
	f.value=language.your_search;
	f.select();}
else if(campo=='q')
	{f=document.googleForm.q;
	f.focus();
	f.value=language.your_search;
	f.select();}
else if(campo=='Titulo')
	{f=document.anuncioForm.Titulo;
	f.focus();
	f.select();}
else if(campo=='Categoria')
	{f=document.anuncioForm.Categoria;
	f.focus();}
else if(campo=='email')
	{
	f=document.HotBoletin.email;
	f.focus();
	f.value='Tu direccion de correo';
	f.select();}
}

function ValidarBusqueda()
	{f=document.formBusqueda;
	//alert(f.Cadena.value);
		if(f.Cadena.value==language.your_search || f.Cadena.value=='')
			{alert(language.specific_search);
			f.Cadena.focus();
			return false;}
	
	}


function CAtoque(){
	/*
	f=document.useraltaForm;
	//trabajo por defecto, ocultar boletin xx
	f.frmProfesion.options[23].selected=true;
	f.frmCategoria310.checked=false;
	f.frmNumCategorias.value--;
	f.frmCategoria310.style.display='none';
	f.frmCategoria310.nextSibling.nextSibling.style.display='none';
	*/
}


//Borrar contenido de todos los campos
function VaciarCampos(Formu)
{  	var F=Formu;
	var longi=F.elements.length;
	for (i=0;i<(longi-2);i++)
		{
		campo=F.elements[i];
		campo.value='';
		}
}

function ValUsu()
	{//alert(navigator.appName);
		var formu=document.Acceso;
		//alert(formu);
		var Usuario=formu.UsuarioMenu;
		var Password=formu.PasswordMenu;
		var al="";
		var al2="";
		if (Usuario.value=='' || Password.value=='' )
			{
			al=language.checks_fields;
			if (Usuario.value=='') al+="\n " + language.username;
			if (Password.value=='') al+="\n " + language.password;
			
			alert(al);
			return false;
			}
		
		else{return true;}
	}

//Validar formulario de Anuncio
function Validar_Anuncio(Cat)
	{
	var error;
    error='false';
	var f=document.anuncioForm;
	
	//validar Titulo
    if (f.Titulo.value.length==0)
    	{
       alert(language.title_valid);
       f.Titulo.focus();
       return false;}

    //validar Descripcion
    Descrip = f.Descripcion.value;
    if (f.Descripcion.value==''){
       alert(language.description_chars);
       f.Descripcion.focus();
       return false;
    }else{
       if (f.Descripcion.value.length<10 || f.Descripcion.value.length>2000){
          alert(language.description_chars);
          f.Descripcion.focus();
          return false;}
    }
	
	//validar Categoria
    if(Cat==1)
		{if (f.Categoria.value=='' ){
	       alert(language.select_category);
	       f.Categoria.focus();
	       return false;}
	}
		if (f.Categoria.selectedIndex==0 && f.Categoria2.selectedIndex==0){
	       alert(language.select_category);
	       f.Categoria.focus();
	       return false;}
    //validar Loc
    
    
    if (f.Localidad.selectedIndex==0 ){
       alert(language.select_location);
       f.Localidad.focus();
       return false;}
	
	
       f.submit;
	}

//Validar longitud textarea descripcion

contenido_textarea = "";

function valida_longitud(num_caracteres_permitidos){
   	
	var f=document.anuncioForm;
	var Descrip = f.Descripcion.value;
   	num_caracteres = Descrip.length;

   if (num_caracteres <= num_caracteres_permitidos)
   		{
		contenido_textarea = Descrip;
		}
	else{
		var DescripOld=Descrip.substr(0,num_caracteres_permitidos);
		//alert(DescripOld);
		
		f.Descripcion.value=DescripOld;
		
		//f.Descripcion.selectionEnd = f.Descripcion.value.length;
		f.Descripcion.selectionEnd.focus();
		
		}
   
   if (num_caracteres >= num_caracteres_permitidos){
    	f.caracteres.style.color="#ff0000";
   }else{
      f.caracteres.style.color="#000000";
   }
cuenta();
   
   //f.caracteres.value=Descrip.length;
}
function cuenta(){
var f=document.anuncioForm;
Descrip = f.Descripcion.value;
f.caracteres.value=Descrip.length;
} 
	
//Validar formulario de Contacto
function Validar_Mail()
	{
	var error;
    error='false';
	var f=document.FormuContacto;
	
	//validar Nombre
    if (f.Sug_User_Nombre.value.length==0)
    	{
       alert(language.valid_name);
       f.Sug_User_Nombre.focus();
       return false;}
       
     //validar Email
    if (f.Sug_User_Email.value.length==0)
    	{
       alert(language.valid_email);
       f.Sug_User_Email.focus();
       return false;}
	
       var mail = f.Sug_User_Email.value;
		var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (filter.test(mail))
		{}
      else{alert(language.valid_email);
		f.Sug_User_Email.focus();
		return false;} 
       
	//validar Pregunta
    if (f.Pregunta.selectedIndex==0){
       alert(language.select_question);
       f.Pregunta.focus();
       return false;}
    
    //validar Comentario
   // Descrip = f.Descripcion.value;
    if (f.Sug_Comentario.value==''){
       alert(language.empty_comment);
       f.Sug_Comentario.focus();
       return false;
    }else{
       if (f.Sug_Comentario.value.length<=0 || f.Sug_Comentario.value.length>1000){
          alert(language.description_chars);
          f.Sug_Comentario.focus();
          return false;}
    }
       f.submit;
	}		

//Validar formulario de USUARIO **************************************************************
function Submit_Usuario()
 {
 
 formulario=document.useraltaForm;
  hayError = false;
	
	if(hayError == false && esBlanco(formulario.Nombre)) {
    alert(language.empty_name);
    formulario.Nombre.focus();
    return false;
  }
	
  if(hayError == false && esBlanco(formulario.Email)) {
    alert(language.empty_email);
    formulario.Email.focus();
    return false;
  }
/*  if (hayError==false && (formulario.pais.value=='')) { 
    alert(language.select_country);
    formulario.pais.focus();
    return false;
  }
  if (hayError==false)
   {
     if (CompruebaCp(formulario)== true)
      {
        formulario.cp.focus();
        return false;
      }
     else
        hayError=false;
   }
   */
  var validaEmail= esEmailValido(formulario.Email.value);
  if(hayError == false && validaEmail!=0 ) {
    if (validaEmail==1) {
        alert(language.valid_email);
        formulario.Email.focus();
        return false;
    } 
    if (validaEmail==2) {
         alert(language.email_spaces);
         formulario.Email.focus();    
        return false;
      }   
  }
  
  
  
   if(hayError == false && formulario.Password.value.length<6) {
      alert(language.password_length);
      formulario.Password.focus();
     return false;
  }
  
  if(hayError == false && esMenorLongitud(formulario.Email, 60) == false) {
      alert(language.email_long);
      formulario.Email.focus();
     return false;
  }
  /*
  if (hayError==false && (formulario.sexo.value == '' )) {
     	alert (language.select_sex);
        return false;
     }
   if ( hayError == false && formulario.fec_ncto.value == ''  ) {
        alert (language.select_age);
        formulario.fec_ncto.focus();
        return false;
    }
  if ( hayError == false && formulario.ocupacion.value == ''  ) {
        alert (language.select_ocupation);
        formulario.ocupacion.focus();
        return false;
    }
  if ( hayError == false && formulario.sector.value == ''  ) {
        alert (language.select_sector);
        formulario.sector.focus();
        return false;
    }
  
   var numform=0;
	numform=formulario.length;
	//alert(numform);
	
	for (var z=0;z<numform;z++)  
		{
  		if(formulario[z].type=='checkbox' && (formulario[z].name=='listas[]'))
  			{//alert(formulario[z].checked);
  			if (formulario[z].checked==true) {var ListaStatus='ok';break;}
  			else{ListaStatus='kao';}
  			  }
    	}
	if(ListaStatus=='kao')
  		{alert(language.select_interest);
	     return false;}
	    
  if(formulario.Condiciones.checked==false)
  	{alert(language.select_conditions);
  	return false;}
  */	
  	
  if(hayError == false) {
    //formulario.submit();
    return true;
   }
 }
 function esBlanco(campo) {
 
 if(campo.value == "")
   return true;
  else
   for (var i=0;i<campo.value.length;i++)
    if (campo.value.charAt(i)!=" ") return false;

  return true;
 }

//CHEQUEO DE LONGITUD
 function esMenorLongitud(campo, longitud) {
  valor = campo.value;

  if(valor.length > longitud) {
   return false;
  }
  return true;
 }
  //CHEQUEO DE EMAIL
  function esEmailValido(email) // Devuelve los valores:0(correcto),1(incorrecto),2(con espacios)
  {
    if (email.indexOf(" ")!=-1) // Comprobamos que email no contenga espacios,tampoco en los laterales
       return 2;
    if (email.indexOf("@")==-1) // Comprobamos que exista al menos un carÃ¡cter @
    {
       return 1;
    }
    else
    {
      var posarroba=email.indexOf("@");
      var nombre=email.substring(0, posarroba);
      var dominio=email.substring(posarroba+1);

      // Comprobamos que nombre  tenga al menos un carÃ¡cter
      if (nombre.length==0)
         return 1;

      // Comprobamos que nombre no sea un solo punto
      if (nombre==".")
         return 1;

      // Comprobamos que dominio tenga al menos un carÃ¡cter
      if (dominio.length==0)
         return 1;

      // Comprobamos que dominio tenga al menos existe un punto
      if (dominio.indexOf(".")==-1)
         return 1;

      // Comprobamos que la ni la primera ni la Ãºltima posiciÃ³n del dominio sea el punto
      len_dom=dominio.length - 1;
      if ((dominio.charAt(0)==".")||(dominio.charAt(len_dom)=="."))
         return 1;

      // Comprobamos que tanto nombre como dominio sÃ³lo cotengan carÃ¡cteres vÃ¡lidos
      if (CharInCorrectos(nombre)) return 1;
      if (CharInCorrectos(dominio)) return 1;
    }
    return 0;
   }

   function CharInCorrectos(cadena)
   {
     validos="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";

     // Comprobamos que cadena no tenga algÃºn carÃ¡cter no contemplado
     // en el string validos y que no existan dos puntos contiguos
     for (i=0;i<cadena.length;i++)
     {
       if (validos.indexOf(cadena.charAt(i))==-1) return true;
       if (cadena.charAt(i)==".")
         if ((i!=cadena.length-1) && (cadena.charAt(i+1)=="."))
           return true;
     }
     return false; // No se ha encontrado ninguna irregularidad
   }
  function CompruebaCp(formulario)
  {
        var pais     = formulario.pais.value;
        var cp       = formulario.cp.value;
        var longitud = formulario.cp.value.length;
        if (cp=='' && pais=='ESP') 
          {
            alert(language.select_cp);
            hayError="true";
            return true;
          }
        if (longitud != 5 && pais=='ESP')
          {
             alert(language.select_cp_error);
             hayError="true";
             return true;
          }
        if (longitud==5 && pais=='ESP')
          {
           var pos0=parseInt(cp.charAt(0));
           var pos1=parseInt(cp.charAt(1));
           if (  (( pos0==5)&& (pos1 > 2)) || ( pos0 > 5 )    )
            {
               alert(language.select_cp_error);
               hayError="true";
               return true;
            }
           validos="0123456789";   
           for (contador=0;contador<longitud;contador++)
            {
       		if (validos.indexOf(cp.charAt(contador))==-1) 
       		  {
               		alert(language.select_cp_error);
               		hayError="true";
               		return true;       		     
       		  }    		
            } 
 	     }
       hayError="false";
 	     return false;

   }   
// *********************************************************************************************	
   

//Eliminar foto
function eliminarDato(string,texto)
{
  var eliminar = confirm(language.confirm_remove + " ?");
 if ( eliminar ) 
   {
   	document.location.href=string;
   }
}

//Solo introducir numeros en un campo
function acceptNum(event){
    event=event?event:window.event;
    var kc=0;
    if(event.which){
        kc=event.which;
    }else if(event.keyCode){
        kc=event.keyCode;        
    }else if(event.charCode){
        kc=event.charCode;        
    }
    if((kc>=48 && kc<=57) || kc==13 || kc==8 || kc==46 || kc==37 || kc==39){
        return true;
    }
    return false;
}



//Agregar a favoritos
function AgregarFavoritos(Titulo,URL) {
	
	/* CondiciÃ³n para el navegador Firefox */
	if (navigator.appName=="Netscape") {
	/* Agrega la pÃ¡gina a favoritos y asigna un tÃ­tulo al enlace */
		window.sidebar.addPanel(Titulo,URL,""); 
	}
	
	/* CondiciÃ³n para el navegador IE */
	if (navigator.appName=="Microsoft Internet Explorer"){
	/* Agrega la pÃ¡gina a favoritos y asigna un tÃ­tulo al enlace */
		window.external.AddFavorite(URL,Titulo);
	}

}
function Carga()
{
document.getElementById('CargaImg').style.visibility="hidden";
//document.getElementById('DelImg').src="DelImg.php?IdSesion=ODcuMjIwLjEzNC4xMjc=";
}

function ventanaSecundaria (URL,Nombre){
   window.open(URL,Nombre,"width=120,height=300,scrollbars=NO");
} 

// Funcion para crear campos de foto **********************************************
//var numero = 1; //Esta es una variable de control para mantener nombres
            //diferentes de cada campo creado dinamicamente.
evento = function (evt) { //esta funcion nos devuelve el tipo de evento disparado
   return (!evt) ? event : evt;
};

// esta funcion crea dinamicamente los nuevos campos file
addCampo = function () { 

	 
//Creamos un nuevo div para que contenga el nuevo campo
   nDiv = document.createElement('div');
//con esto se establece la clase de la div
   nDiv.className = 'archivo';
//este es el id de la div, aqui la utilidad de la variable numero
//nos permite darle un id unico
   nDiv.id = 'file' + (++numero);
   Text=document.createTextNode(language.photo +(numero)); 
   nDiv.appendChild(Text);
//creamos el input para el formulario:
   nCampo = document.createElement('input');
//le damos un nombre, es importante que lo nombren como vector, pues todos los campos
//compartiran el nombre en un arreglo, asi es mas facil procesar posteriormente con php
   nCampo.name = 'Foto['+(numero)+']';
//Establecemos el tipo de campo
   nCampo.type = 'file';

	//Ahora creamos un link para poder eliminar un campo que ya no deseemos
	   a = document.createElement('a');
	//El link debe tener el mismo nombre de la div padre, para efectos de localizarla y eliminarla
	   a.name = nDiv.id;
	//Este link no debe ir a ningun lado
	   a.href = '#photo';
	//Establecemos que dispare esta funcion en click
	   a.onclick = elimCamp;
	//Con esto ponemos el texto del link
	   a.innerHTML =language.remove;

//Bien es el momento de integrar lo que hemos creado al documento,
//primero usamos la funciÃ³n appendChild para adicionar el campo file nuevo
   nDiv.appendChild(nCampo);
//Adicionamos el Link
   nDiv.appendChild(a);
//Ahora si recuerdan, en el html hay una div cuyo id es 'adjuntos', bien
//con esta funciÃ³n obtenemos una referencia a ella para usar de nuevo appendChild
//y adicionar la div que hemos creado, la cual contiene el campo file con su link de eliminaciÃ³n:
   container = document.getElementById('adjuntos');
   container.appendChild(nDiv);
};
//con esta funciÃ³n eliminamos el campo cuyo link de eliminaciÃ³n sea presionado
elimCamp = function (evt){
   //alert(numero);
	evt = evento(evt);
   nCampo = rObj(evt);
   div = document.getElementById('file'+(numero));
   //alert(div);
   div.parentNode.removeChild(div);
   
   //var numero=numero-1;
   numero--;
};
//con esta funciÃ³n recuperamos una instancia del objeto que disparo el evento
rObj = function (evt) 
	{ 
	   return evt.srcElement ?  evt.srcElement : evt.target;
	};
// ********************************************************************************************

//Capa top poner anuncios***************************************************************************************
function ml(id)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	if(d.layers)el.style=el;
  if (!el.currentStyle || el.currentStyle.position == 'fixed') return false;
  el.sP=function(x,y){ if(y + 'px' != this.style.top) this.style.top=y + 'px';};
	// el.x = startX;
	if (verticalpos=="fromtop") {
    el.y = startY;
  }
	else {
  	el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
	  el.y -= startY;
	}
	el.style.position = 'absolute';
	el.style.right = startY + 'px';
	return el;
}

function stayTopLeft()
{
	if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : document.documentElement.scrollTop;
		ftlObj.y = (pY + startY); // /8;
	}
	else{
		var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		ftlObj.y = (pY - startY - ftlObj.y); // /8;
	}

  ftlObj.sP(ftlObj.x, ftlObj.y);

	setTimeout("stayTopLeft()", 150);
}

// AJAX	 *********************************************************************************
// Funcion para actualizar las categorias **********************************************
function nuevoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false;
	try
	{
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			// Creacion del objet AJAX para IE
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E)
		{
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
		}
	}
	return xmlhttp; 
}

// Declaro los selects que componen el documento HTML. Su atributo ID debe figurar aqui.
var listadoSelects=new Array();
listadoSelects[0]="Categoria";
listadoSelects[1]="Categoria2";

function buscarEnArray(array, dato)
{
	// Retorna el indice de la posicion donde se encuentra el elemento en el array o null si no se encuentra
	var x=0;
	while(array[x])
	{
		if(array[x]==dato) return x;
		x++;
	}
	return null;
}


function cargaContenido(idSelectOrigen,CargarParametros)
{	// Obtengo la posicion que ocupa el select que debe ser cargado en el array declarado mas arriba
	//alert(idSelectOrigen);
	var posicionSelectDestino=buscarEnArray(listadoSelects, idSelectOrigen)+1;
	//alert(posicionSelectDestino);
	// Obtengo el select que el usuario modifico
	var selectOrigen=document.getElementById(idSelectOrigen);
	//alert(selectOrigen.name);
	// Obtengo la opcion que el usuario selecciono
	var opcionSeleccionada=selectOrigen.options[selectOrigen.selectedIndex].value;
	// Si el usuario eligio la opcion "Elige", no voy al servidor y pongo los selects siguientes en estado "Selecciona opcion..."
	//alert(opcionSeleccionada);
	if(opcionSeleccionada==0)
	{ 
		var x=posicionSelectDestino, selectActual=null;
		// Busco todos los selects siguientes al que inicio el evento onChange y les cambio el estado y deshabilito
		while(listadoSelects[x])
		{
			selectActual=document.getElementById(listadoSelects[x]);
			selectActual.length=0;
			
			var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Selecciona Opci&oacute;n...";
			selectActual.appendChild(nuevaOpcion);	selectActual.disabled=true;
			x++;
		}
	}
	// Compruebo que el select modificado no sea el ultimo de la cadena
	else if(idSelectOrigen!=listadoSelects[listadoSelects.length-1])
	{ 
		// Obtengo el elemento del select que debo cargar
		var idSelectDestino=listadoSelects[posicionSelectDestino];
		//alert(idSelectDestino);
		var selectDestino=document.getElementById(idSelectDestino);
		// Creo el nuevo objeto AJAX y envio al servidor el ID del select a cargar y la opcion seleccionada del select origen
		var ajax=nuevoAjax();
		ajax.open("GET", "/ajax/select_dependientes_proceso.php?select="+idSelectDestino+"&opcion="+opcionSeleccionada+"&CargarParametros="+CargarParametros, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==1)
			{
				// Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
				selectDestino.length=0;
				var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML=language.loading +"...";
				selectDestino.appendChild(nuevaOpcion); selectDestino.disabled=true;	
			}
			if (ajax.readyState==4)
			{	//alert(CargarParametros);
				//alert(selectDestino.parentNode.innerHTML);
				selectDestino.parentNode.innerHTML=ajax.responseText;
				//alert(ajax.responseText);
				//alert(opcionSeleccionada);
				if(CargarParametros==1){Cargar_Parametros(opcionSeleccionada,'Anuncio');}
				else if(CargarParametros==2){Cargar_Parametros(opcionSeleccionada,'Noti');}
			} 
		};
		ajax.send(null);
	}
}
function cargaContenidoModerar(idSelectOrigen,IdSelectDestino)
{	// Obtengo la posicion que ocupa el select que debe ser cargado en el array declarado mas arriba
	//alert(idSelectOrigen);
	var posicionSelectDestino=buscarEnArray(listadoSelects, idSelectOrigen)+1;
	// Obtengo el select que el usuario modifico
	var selectOrigen=document.getElementById(idSelectOrigen);
	// Obtengo la opcion que el usuario selecciono
	var opcionSeleccionada=selectOrigen.options[selectOrigen.selectedIndex].value;
	// Si el usuario eligio la opcion "Elige", no voy al servidor y pongo los selects siguientes en estado "Selecciona opcion..."
	//alert(opcionSeleccionada);
	/*if(opcionSeleccionada==0)
	{ 
		var x=posicionSelectDestino, selectActual=null;
		// Busco todos los selects siguientes al que inicio el evento onChange y les cambio el estado y deshabilito
		while(listadoSelects[x])
		{
			selectActual=document.getElementById(listadoSelects[x]);
			selectActual.length=0;
			
			var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Selecciona Opci&oacute;n...";
			selectActual.appendChild(nuevaOpcion);	selectActual.disabled=true;
			x++;
		}
	}
	// Compruebo que el select modificado no sea el ultimo de la cadena
	else if(idSelectOrigen!=listadoSelects[listadoSelects.length-1])
	{ */
		// Obtengo el elemento del select que debo cargar
		//var idSelectDestino=listadoSelects[posicionSelectDestino];
		var selectDestino=document.getElementById(IdSelectDestino);
		// Creo el nuevo objeto AJAX y envio al servidor el ID del select a cargar y la opcion seleccionada del select origen
		var ajax=nuevoAjax();
		ajax.open("GET", "/admin/ajax/select_dependientes_admin.php?select="+IdSelectDestino+"&opcion="+opcionSeleccionada, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==1)
			{
				// Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
				selectDestino.length=0;
				var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML=language.loading+"...";
				selectDestino.appendChild(nuevaOpcion); selectDestino.disabled=true;	
			}
			if (ajax.readyState==4)
			{	//alert(CargarParametros);
				//alert(selectDestino.parentNode.innerHTML);
				selectDestino.parentNode.innerHTML=ajax.responseText;
				//alert(ajax.responseText);
				//alert(opcionSeleccionada);
				/*if(CargarParametros==1){Cargar_Parametros(opcionSeleccionada,'Anuncio');}
				else if(CargarParametros==2){Cargar_Parametros(opcionSeleccionada,'Noti');}*/
			} 
		};
		ajax.send(null);
	//}
}

//Actualizar la capa de parametros en funcion del Id de Categoria
//Tipo-> Anuncio : carga los parametros correspondientes a la categoria del anuncio
//Tipo-> Noti : carga los parametros correspondientes a la categoria de la notificacion
function Cargar_Parametros(opcionSeleccionada,Tipo)
{// Creo el nuevo objeto AJAX y envio al servidor el ID del select a cargar y la opcion seleccionada del select origen
		if(opcionSeleccionada!='')
		{
			//alert(opcionSeleccionada);
			var Destino=document.getElementById('CapaParametros');
			var ajax=nuevoAjax();
			if(Tipo=='Anuncio')
				{ajax.open("GET", "/ajax/select_parametros.php?opcion="+opcionSeleccionada, true);}
			else if(Tipo=='AnuncioGoogle')
				{ajax.open("GET", "/ajax/select_parametros.php?opcion="+opcionSeleccionada, true);}
			else if(Tipo=='Noti')
				{ajax.open("GET", "/ajax/select_noti_parametros.php?opcion="+opcionSeleccionada, true);}
			ajax.onreadystatechange=function() 
			{ 
				if (ajax.readyState==1)
					{// Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
					Destino.innerHTML=language.loading + "...";
					}
				if (ajax.readyState==4)
					{Destino.innerHTML=ajax.responseText;} 
			};
			ajax.send(null);
		}
}

//Tipo->Productos: carga informacion del producto que se quiere comprar
function Cargar_Productos(opcionSeleccionada,Tipo,Usuario,Anuncio)
{// Creo el nuevo objeto AJAX y envio al servidor el ID del select a cargar y la opcion seleccionada del select origen
		//alert(opcionSeleccionada);
		var Destino=document.getElementById('CapaParametros');
		var ajax=nuevoAjax();
		//
		if(Tipo=='Productos')
			{ajax.open("GET", "/ajax/select_productos.php?opcion="+opcionSeleccionada+"&Usuario="+Usuario+"&Anuncio="+Anuncio+"&Tipo="+Tipo, true);}
		//Para la pagina de detalle de informacion de producto
		else if(Tipo=='InfoProductos')
			{ajax.open("GET", "/ajax/select_productosinfo.php?opcion="+opcionSeleccionada+"&Usuario="+Usuario+"&Tipo="+Tipo, true);}
		//Para la informacion de la derecha en anuncionew.php
		else if(Tipo=='InfoAdProductos')
			{var Destino=document.getElementById('CapaProdInfo');
			ajax.open("GET", "/ajax/select_productosinfo.php?opcion="+opcionSeleccionada+"&Usuario="+Usuario+"&Tipo="+Tipo, true);}
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==1)
				{// Mientras carga elimino la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
				Destino.innerHTML=language.loading+"...";
				}
			if (ajax.readyState==4)
				{Destino.innerHTML=ajax.responseText;} 
		};
		ajax.send(null);
}


//Actualizar periodicidad de envio de boletin para un usuario
function Cambiar_Periodo(User_Id,Periodo)
{
	var actualizar = confirm(language.update_time);
	if (actualizar) 
	  {var Destino=document.getElementById('Periodo');
		
		// Creo el nuevo objeto AJAX 
		var ajax=nuevoAjax();
		ajax.open("GET", "ajax/notificacion_periodo_update.php?User_Id="+User_Id+"&Periodo="+Periodo, true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==1)
				{
				Destino.innerHTML=language.loading+"...";
				}
			if (ajax.readyState==4)
				{
			   	Destino.innerHTML=ajax.responseText;
				//alert(opcionSeleccionada);
				//Cargar_Parametros(opcionSeleccionada);
				} 
		};
		ajax.send(null);
	 }
}

var MailOpen=false;
function MostrarCapa(capa)
{//alert(capa);
if($(capa).css('display')=='none')
	{
	/*
		layer=capa.substring(1);
		 $(capa).animate({height: 'inherit'
		 }, "slow", function(){ $(capa).fadeTo("slow", 1);});
		 //$(capa).css("display","block").animate({"height":$(capa).attr("_h")},this.defaultTimer);
		 MailOpen=true;
		*/
		
		$(capa).css('display',  'block');
	 }
else
	 {
	 /*
		layer=capa.substring(1);
		 $(capa).animate({height: 10
		 }, "slow", function(){ $(capa).hide();});
		MailOpen=false;
		*/
		
		$(capa).css('display',  'none');
	}

}

function MailFriend(Ad_Id,Modo,Friend_Nombre,Friend_Email,Friend_Coment,Mi_Nombre,Mi_Email)
{

$.get("/ajax/Manage_MailFriend.php",
{"Ad_Id":Ad_Id,"Modo":Modo,"Friend_Nombre":Friend_Nombre,"Friend_Email":Friend_Email,"Friend_Coment":Friend_Coment,"Mi_Nombre":Mi_Nombre,"Mi_Email":Mi_Email},
		   function(data)
			   {$("#MailSend").html(data);
			  	//alert("Data Loaded: " + data);
				});
}

function MailAnunciante(Ad_Id,Modo,Interesado_Nombre,Interesado_Email,Interesado_Movil,Interesado_Comentario, Captcha_security)
{

var top_url= top.location.href?top.location.href:top.location;
top_url=escape(top_url).replace('+', '%2B').replace('%20', '+').replace('*', '%2A').replace('/', '%2F').replace('@', '%40');
$.get("/ajax/Manage_MailAnunciante.php",
{"Ad_Id":Ad_Id,"Modo":Modo,"Interesado_Nombre":Interesado_Nombre,"Interesado_Email":Interesado_Email,"Interesado_Movil":Interesado_Movil,"Interesado_Comentario":Interesado_Comentario,"securityCode":Captcha_security, "urltop":top_url},
		   function(data)
			   {$("#AnuncianteSend").html(data);
			  	//alert("Data Loaded: " + data);
				});

}
function SendFriend(form)
{alert(form);}

var previewImage={
	over:function(el, src){
		var w=100;
		src=addslashes(src);
		//var image=new Image(w);
		//image.src=src+'?resize='+w;
		//$(image).css({height:w});
		var d=$(el).offset();
		el.elem=$('<div></div>').css({
			position:'absolute', 
			left:d.left-(w+30), 
			top:d.top-20,
			border:'1px solid Black',
			padding:'5px',
			background:'White',
			MozBorderRadius:'5px',
			width:w
		}).appendTo('body').append('<img alt="" title="" src="'+(src+'?resize='+w)+'" width="'+w+'"/>').append('<div style="background:transparent url(/Images/imgOverlayPoints.gif) no-repeat 0% -90px; width:22px; height:25px; position:absolute; top:5px; right:-22px;"></div>');
	},
	out:function(el){
		if(el.elem){
			$(el.elem).remove();
			el.elem=null;
		}
	}
};


// ********************************************************************************************

// *********************** GOOGLE ADSENSE *******************************************
/*
       * Esta funciÃ³n es obligatoria: procesa el google_ads objeto JavaScript,
       * que contiene anuncios de AFS relevantes para la consulta de bÃºsqueda del usuario. El nombre de
       *esta funciÃ³n <i>debe</i> ser <strong>google_afs_request_done</strong>. Si no se nombra correctamente
       * esta funciÃ³n, su pÃ¡gina no mostrarÃ¡ anuncios de AFS.
       */

       function google_afs_request_done(google_ads,Tipo)
 {
          /*
           * Verify that there are actually ads to display.
           */
          var google_num_ads = google_ads.length;
          if (google_num_ads <= 0)
          {
              return;
          }

          var wideAds = "";   // texto html de bloque de anuncios anchos
          var TopwideAds = "";   // texto html de bloque de anuncios anchos arriba 
          var BottomwideAds = "";   // texto html de bloque de anuncios anchos abajo
          var narrowAds = "";   // texto html de bloque de anuncios estrechos

          for(i = 0; i < google_num_ads; i++)
          {
              
          
          	if (google_ads[i].type=="text/narrow")
              {
                  // mostrar un anuncio estrecho
                  narrowAds+='<a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
                          google_ads[i].url + '\';return true;" ' +
                          'onmouseout="javascript:window.status=\'\';return true;" ' +
                          'href="' + google_ads[i].url + '">' +

                          '<span class="ad_line1">' + google_ads[i].line1 + '</span></a><br/>' +

                          '<span class="ad_text">' + google_ads[i].line2 + '</span><br/>' +

                          '<span class="ad_text">' + google_ads[i].line3 + '</span><br/>' +

                          '<a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
                          google_ads[i].url + '\';return true;" ' +
                          'onmouseout="javascript:window.status=\'\';return true;" ' +
                          'href="' + google_ads[i].url + '">' +

                          '<span class="ad_url">' + google_ads[i].visible_url + '</span><br/><br/></a>';
              }
          
          
          
          	else
              {
                  // render a wide ad
				if(i<=2) TopwideAds+='<li class="google_adsense_entry">'+ 
									 '<a style="text-decoration:none;" onmouseover="javascript:window.status=\'' +
			                          google_ads[i].url + '\';return true;" ' +
			                          'onmouseout="javascript:window.status=\'\';return true;" ' +
			                          'href="' + google_ads[i].url + '">' +
									  '<span class="ad_line1">' + google_ads[i].line1 + '</span></a>' + Adsense_Wrap +
			                          
			                          '<span class="ad_text">' + google_ads[i].line2 + '</span>&nbsp;' + Adsense_Wrap2 + 
			                          
			                          '<a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
			                          google_ads[i].url + '\';return true;" ' +
			                          'onmouseout="javascript:window.status=\'\';return true;" ' +
			                          'href="' + google_ads[i].url + '">' +
			                          '<span class="ad_url">' + google_ads[i].visible_url + '</span><br/></a></li>';
			                          
    			else BottomwideAds+= '<li class="google_adsense_entry"><a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
			                          google_ads[i].url + '\';return true;" ' +
			                          'onmouseout="javascript:window.status=\'\';return true;" ' +
			                          'href="' + google_ads[i].url + '">' +
			
			                          '<span class="ad_line1">' + google_ads[i].line1 + '</span></a>' + Adsense_Wrap +
			                          
			                          '<span class="ad_text">' + google_ads[i].line2 + '</span>&nbsp;' + Adsense_Wrap2 +
			                          
			                          '<a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
			                          google_ads[i].url + '\';return true;" ' +
			                          'onmouseout="javascript:window.status=\'\';return true;" ' +
			                          'href="' + google_ads[i].url + '">' +
			                          
			                          '<span class="ad_url">' + google_ads[i].visible_url + '</span><br/></a></li>';
                  
                 
              }

           }   

          if (narrowAds != "")
          {
              narrowAds = '<a style="text-decoration:none" ' +
                          'href="http://services.google.com/feedback/online_hws_feedback">' +
                          '<span class="ad_header">Anuncios Google</span><br/></a>' + narrowAds;
          }
          

          if (TopwideAds != "")
          {
             TopwideAds = '<a style="text-decoration:none" ' +
                        'href="http://services.google.com/feedback/online_hws_feedback">' +
                        '<span class="ad_header">Anuncios Google</span><br/></a>' + TopwideAds;
          }
          
          if (BottomwideAds != "")
          {
             BottomwideAds = '<a style="text-decoration:none" ' +
                        'href="http://services.google.com/feedback/online_hws_feedback">' +
                        '<span class="ad_header">Anuncios Google</span><br/></a>' + BottomwideAds;
          }

          // Escriba texto HTML para anuncios anchos y estrechos para los elementos <div> adecuados
          
          document.getElementById("narrow_ad_unit").innerHTML = narrowAds;
          document.getElementById("wide_ad_unit_Top").innerHTML = TopwideAds;
          document.getElementById("wide_ad_unit_Bottom").innerHTML = BottomwideAds;
          
          
          
          
      }

       
      function google_afs_request_negrita(google_ads,Tipo)
      {
        	var kw = kw_google_afs_query+' ';
    		var Ergebnis = kw.match(/([^ ]*) /g);
          /*
           * Verify that there are actually ads to display.
           */
          var google_num_ads = google_ads.length;
          if (google_num_ads <= 0)
          {
              return;
          }

          var wideAds = "";   // texto html de bloque de anuncios anchos
          var TopwideAds = "";   // texto html de bloque de anuncios anchos arriba 
          var BottomwideAds = "";   // texto html de bloque de anuncios anchos abajo
          var narrowAds = "";   // texto html de bloque de anuncios estrechos

          for(i = 0; i < google_num_ads; i++)
          {
              
           if (google_ads[i].line1 && google_ads[i].line2 && Ergebnis){
                for (var j = 0; j < Ergebnis.length; ++j) {
                    Ergebnis[j] = Ergebnis[j].replace(' ','');
                    if(!Ergebnis[j])continue;
                    myregexp = new RegExp(Ergebnis[j],'ig');
                    google_ads[i].line1 =google_ads[i].line1.replace(myregexp,'<strong>'+Ergebnis[j][0].toUpperCase()+Ergebnis[j].substring(1, Ergebnis[j].length)+'</strong>');
                    myregexp = new RegExp(Ergebnis[j],'ig');
                    google_ads[i].line2 =google_ads[i].line2.replace(myregexp,'<strong>'+Ergebnis[j][0].toUpperCase()+Ergebnis[j].substring(1, Ergebnis[j].length)+'</strong>');
                    if(google_ads[i].line3){
	                    myregexp = new RegExp(Ergebnis[j],'ig');
	                    google_ads[i].line3 =google_ads[i].line3.replace(myregexp,'<strong>'+Ergebnis[j][0].toUpperCase()+Ergebnis[j].substring(1, Ergebnis[j].length)+'</strong>');
                    }
                }
			}
          	if (google_ads[i].type=="text/narrow")
              {
                  // mostrar un anuncio estrecho
                  narrowAds+='<a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
                          google_ads[i].url + '\';return true;" ' +
                          'onmouseout="javascript:window.status=\'\';return true;" ' +
                          'href="' + google_ads[i].url + '">' +

                          '<span class="ad_line1">' + google_ads[i].line1 + '</span></a><br/>' +

                          '<span class="ad_text">' + google_ads[i].line2 + '</span><br/>' +

                          '<span class="ad_text">' + google_ads[i].line3 + '</span><br/>' +

                          '<a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
                          google_ads[i].url + '\';return true;" ' +
                          'onmouseout="javascript:window.status=\'\';return true;" ' +
                          'href="' + google_ads[i].url + '">' +

                          '<span class="ad_url">' + google_ads[i].visible_url + '</span><br/><br/></a>';
              }
          
          
          
          	else
              {
                  // render a wide ad
				if(i<=1) TopwideAds+='<li class="google_adsense_entry">'+ 
									 '<a style="text-decoration:none;" onmouseover="javascript:window.status=\'' +
			                          google_ads[i].url + '\';return true;" ' +
			                          'onmouseout="javascript:window.status=\'\';return true;" ' +
			                          'href="' + google_ads[i].url + '">' +
									  '<span class="ad_line1">' + google_ads[i].line1 + '</span></a>' + Adsense_Wrap +
			                          
			                          '<span class="ad_text">' + google_ads[i].line2 + '</span>' + Adsense_Wrap +
			                          
			                          '<a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
			                          google_ads[i].url + '\';return true;" ' +
			                          'onmouseout="javascript:window.status=\'\';return true;" ' +
			                          'href="' + google_ads[i].url + '">' +
			                          '<span class="ad_url">' + google_ads[i].visible_url + '</span><br/></a></li>';
			                          
    			else BottomwideAds+= '<li class="google_adsense_entry"><a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
			                          google_ads[i].url + '\';return true;" ' +
			                          'onmouseout="javascript:window.status=\'\';return true;" ' +
			                          'href="' + google_ads[i].url + '">' +
			
			                          '<span class="ad_line1">' + google_ads[i].line1 + '</span></a>' + Adsense_Wrap +
			                          
			                          '<span class="ad_text">' + google_ads[i].line2 + '</span>' + Adsense_Wrap +
			                          
			                          '<a style="text-decoration:none" onmouseover="javascript:window.status=\'' +
			                          google_ads[i].url + '\';return true;" ' +
			                          'onmouseout="javascript:window.status=\'\';return true;" ' +
			                          'href="' + google_ads[i].url + '">' +
			                          
			                          '<span class="ad_url">' + google_ads[i].visible_url + '</span><br/></a></li>';
                  
                 
              }

           }   

          if (narrowAds != "")
          {
              narrowAds = '<a style="text-decoration:none" ' +
                          'href="http://services.google.com/feedback/online_hws_feedback">' +
                          '<span class="ad_header">Anuncios Google</span><br/><br/></a>' + narrowAds;
          }
          

          if (TopwideAds != "")
          {
             TopwideAds = '<a style="text-decoration:none" ' +
                        'href="http://services.google.com/feedback/online_hws_feedback">' +
                        '<span class="ad_header">Anuncios Google</span><br/><br/></a>' + TopwideAds;
          }
          
          if (BottomwideAds != "")
          {
             BottomwideAds = '<a style="text-decoration:none" ' +
                        'href="http://services.google.com/feedback/online_hws_feedback">' +
                        '<span class="ad_header">Anuncios Google</span><br/><br/></a>' + BottomwideAds;
          }

          // Escriba texto HTML para anuncios anchos y estrechos para los elementos <div> adecuados
          
          document.getElementById("narrow_ad_unit").innerHTML = narrowAds;
          document.getElementById("wide_ad_unit_Top").innerHTML = TopwideAds;
          document.getElementById("wide_ad_unit_Bottom").innerHTML = BottomwideAds;
          
      }
      
    
    function google_ad_request_done(google_ads) {
		/*
		* Esta función es obligatoria y se utiliza para mostrar
		* los anuncios obtenidos como respuesta a la solicitud de
		* JavaScript. Deberá modificar los comandos
		* document.write a fin de que el código HTML que escriban se ajuste
		* a la disposición del anuncio.
		*/
		var s = '';
		var i;
		
		/*
		* Verifique que hay anuncios para publicar.
		*/
	//	alert(google_ads.length);
		if (google_ads.length == 0) {
		return;
		}
		
		/*
		* Si se ofrece como resultado un anuncio gráfico o de Flash, muestre ese anuncio.
		* De lo contrario, cree una cadena que contenga todos los anuncios y,
		* a continuación, utilice un comando document.write() para imprimir la cadena.
		*/
		
		if (google_ads[0].type == "flash") {
		
		   s += '<a href=\"' +
		google_info.feedback_url + '\" style="color:000000">Anuncios Google</a><br>' +
		'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
		' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' +
		google_ad.image_width + '" HEIGHT="' +
		google_ad.image_height + '"> <PARAM NAME="movie" VALUE="' +
		google_ad.image_url + '">' +
		'<PARAM NAME="quality" VALUE="high">' +
		'<PARAM NAME="AllowScriptAccess" VALUE="never">' +
		'<EMBED src="' +
		google_ad.image_url + '" WIDTH="' +
		google_ad.image_width + '" HEIGHT="' +
		google_ad.image_height +
		'" TYPE="application/x-shockwave-flash"' +
		' AllowScriptAccess="never" ' +
		' PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
		
		} else if (google_ads[0].type == "image") {
		
		   s += '<a href=\"' +
		google_info.feedback_url + '\" style="color:000000">Anuncios Google</a><br> <a href="' +
		google_ads[0].url + '" target="_top" title="vaya a ' +
		google_ads[0].visible_url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' +
		google_ads[0].visible_url + '\';return true"><img border="0" src="' +
		google_ads[0].image_url + '"width="' +
		google_ads[0].image_width + '"height="' +
		google_ads[0].image_height + '"></a>';
		
		} else if (google_ads[0].type == "html") {
		
		s += google_ads[0].snippet;
		
		} else {
		
		if (google_ads.length == 1) {
		/*
		* Los sitios asociados deberán ajustar el tamaño del texto
		* de modo que los anuncios ocupen la mayor parte del espacio publicitario.
		*/
		   s += '<a href=\"' +
		google_info.feedback_url + '\" style="color:000000">Anuncios Google</a><br> <a style="text-decoration:none" href="' +
		google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' +
		google_ads[0].visible_url + '\';return true"> <span style="text-decoration:underline;font-size:20pt"> <b>' +
		google_ads[0].line1 + '</b><br></span></a> <span style="color:#000000;font-size:16pt">' +
		google_ads[0].line2 + '&nbsp;' +
		google_ads[0].line3 + '<br></span> <span><a style="color:#008000;font-size:14pt;text-decoration:none" href="' +
		google_ads[0].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' +
		google_ads[0].visible_url + '\';return true">' +
		google_ads[0].visible_url + '</span></a><br>';
		
		} else if (google_ads.length > 1) {
		
		   s += '<a href=\"' + google_info.feedback_url + '\" style="color:000000">Ads by Google</a><br>'
		
		  /*
		  * En el caso de los anuncios de texto, añada cada uno de ellos a la cadena.
		  */
		
		for(i = 0; i < google_ads.length; ++i) {
		
		s += '<br><a style="text-decoration:none" href="' +
		google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' +
		google_ads[i].visible_url + '\';return true"> <span style="text-decoration:underline"> <b>' +
		google_ads[i].line1 + '</b><br></span></a> <span style="color:#000000">' +
		google_ads[i].line2 + '<br>' +
		google_ads[i].line3 + '<br></span> <span><a style="color:#008000;text-decoration:none" href="' +
		google_ads[i].url + '" onmouseout="window.status=\'\'" onmouseover="window.status=\'vaya a ' +
		google_ads[i].visible_url + '\';return true">' +
		google_ads[i].visible_url + '</span></a><br>';
		}
		}
		    }
		
		    document.write(s);
		    return;
		  }	    
      
      
	function PesquisaFirefox(){
		var enderecoDoIcone='http://www.'+siteName+'/search_sidebar/file.gif';
	   var dir = enderecoDoIcone.split('/'); 
	   var imgFile = dir.pop(); 
	   var path = dir.join('/') + '/';
	   var splitedImgFile = imgFile.split('.'); 
	   splitedImgFile.pop(); 
	   var srcFile = splitedImgFile.join('.') + '.src';
	   try { 
	   	window.sidebar.addSearchEngine(path + srcFile, path + 'file.ico', siteName, '{traduce}'+siteName+'{/traduce}');
	   }
	   catch(ex) { 
	   	window.alert('{traduce}'+siteName+'{/traduce} http://www.mozilla-europe.org/es/products/firefox/'); 
		}
	}
	function PesquisaIE(){						
	try { 
		window.external.AddSearchProvider('http://www.'+siteName+'/search_sidebar/file.xml');
	}
   catch(ex) { window.alert('{traduce}'+siteName+'{/traduce}'); }}
function addslashes(str) {
	//str=str.replace(/\\/g,'\\\\');
	//str=str.replace(/\'/g,'\\\'');
	//str=str.replace(/\"/g,'\\"');
	//str=str.replace(/\0/g,'\\0');
	return str;
}    				







function _httprequest(url, method, vars, end){
	end=end?end:function(){};
	var xmlHttp = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4){
			if (xmlHttp.status == 200){ 
				end(xmlHttp.responseText);
	    	}
		}
	};
	if(method=='POST'){
		xmlHttp.open("POST", url, true);
        xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlHttp.send(vars);		
	}else{
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
	}
}
var ajax={
	get:function(url,end){
		_httprequest(url, 'GET', null, end);
	},
	post:function(url, vars, end){
		_httprequest(url, 'POST', vars, end);		
	},
	getScript:function(url, end){
		var _script=document.createElement('SCRIPT');
		_script.src=url;
		_script.onload=_script.onreadystatechange=function(){
			if(end){
				end();
			}
			if(_script && _script.parentNode){
				_script.parentNode.removeChild(_script);
			}
		};
		var head=document.getElementsByTagName('head')[0];
		head.appendChild(_script);
	}
};
var suggestqueries=function(a){
	if(typeof a[1]=='object'){
		if(a[1].length>0){
			var xd=document.getElementById('resultados');
			xd.innerHTML='';
			for(var i=0; i<a[1].length; i++){
				var dv=document.createElement('DIV');
				dv.className='dv';
				dv.setAttribute('class','dv');
				var dv1=document.createElement('DIV');
				dv1.className='dv1';
				dv1.setAttribute('class','dv1');
				dv1.innerHTML=a[1][i][0];
				dv.appendChild(dv1);
				dv.val=a[1][i][0];
				dv.xd=xd;
				dv.pos=i;
				dv.onclick=function(){
					document.getElementById('Cadena').value=this.val;
					document.getElementById('Cadena').focus();
					this.xd.style['display']='none';
				};
				dv.onmouseover=function(){
					this.className='dv over';
					xd.selected=this.pos;
				};
				dv.onmouseout=function(){
					this.className='dv';
				};
				if(i==0){
					dv.className='dv over';
					dv.setAttribute('class','dv over');
				}
				xd.appendChild(dv);
			}
			xd.style['display']='block';
		}
	}	
};


var url_search='http://suggestqueries.google.com/complete/search?hl='+language.lang+'&nolabels=t&jsonp=suggestqueries&q=';
function suggest(event, key){
	var xd=document.getElementById('resultados');
	if(key && key.length>2){
		if(event.keyCode>=37 && event.keyCode<=40){			
			var childs=xd.childNodes;
			if(event.keyCode==38){
				if(childs.length>1){
					childs[xd.selected].className='dv';
					if(xd.selected==0){
						xd.selected=childs.length;
					}
					xd.selected--;
					childs[xd.selected].className='dv over';
					document.getElementById('Cadena').value=xd.childNodes[xd.selected].val;
				}
			}else if(event.keyCode==40){
				if(childs.length>1){
					if(xd.selected==childs.length){
						xd.selected=-1;
					}
					xd.selected++;
					childs[(xd.selected?xd.selected-1:childs.length-1)].className='dv';
					childs[xd.selected].className='dv over';
					document.getElementById('Cadena').value=xd.childNodes[xd.selected].val;
				}
			}
		}else{
			xd.innerHTML='';
			xd.selected=0;
			ajax.getScript(url_search+key);
		}
	}else{
		xd.innerHTML='';
		xd.selected=0;
	}
}

function MM_openBrWindow(theURL,winName,features){
			window.open(theURL,winName,features);
		}
		