function sacar_publicidad() {

	var div=document.getElementById("conash3D0");
	if (div) {
		div.style.display="none";	
		div.style.visibility="hidden";
		var arr=document.getElementsByTagName("iframe");	
		for (var i=0; i < arr.length; i++)
		{
			if (arr[i].name!="estadisticas" && arr[i].name!="google_ads_frame")
				arr[i].style.display="none";
		}
	}

	document.body.style.display="block";
}

var destino; //div donde mostrare el resultado ajax


function ajax_load(url, pars, donde)
{
	destino=donde;
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'post', 
			parameters: pars, 
			onComplete: showResponse
		});
		
}

function showResponse(originalRequest)
{
	document.getElementById(destino).innerHTML = originalRequest.responseText;	
}


//dato un formulario, retorna una cadena con todos los elementos de la sigueibnte forma: elemento1=valor&elemento2=valor2&...
function obtener_parametros_formulario(formu)
{
	var params="";
	for (var i=0; i < formu.elements.length; i++) 
	{
		if (formu.elements[i].type == "select-one")
			params+="&" + formu.elements[i].id + "=" + formu.elements[i].options[formu.elements[i].selectedIndex].text;
		else
			params+="&" + formu.elements[i].id + "=" + escape (formu.elements[i].value);
	}					
	return params;
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("El email ingresado no es valido.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("El email ingresado no es valido.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("El email ingresado no es valido.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("El email ingresado no es valido.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("El email ingresado no es valido.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("El email ingresado no es valido.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("El email ingresado no es valido.")
		    return false
		 }

 		 return true					
	}

function validar_formulario(formu) 
{	
	var emailID=formu.email;
	var ciudad_pais=formu.ciudad_pais;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("El email ingresado no es valido.")
		emailID.focus();
		return false;
	}
	
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus();
		return false;
	}
	
	if ((ciudad_pais.value==null)||(ciudad_pais.value=="")){
		alert ("Por favor ingrese su pais y ciudad");
		return false;
	}
	formu.Buscar.disabled=true;
	return true;
}

function handleKey(e) 
{
  // get the event
  e = (!e) ? window.event : e;
  // get the code of the character that has been pressed        
  code = (e.charCode) ? e.charCode :
         ((e.keyCode) ? e.keyCode :
         ((e.which) ? e.which : 0));
  // handle the keydown event       
  if (e.type == "keydown") 
  {
    // if enter (code 13) is pressed
    if(code == 13)
    {
      // send the current message  
      $('btn_ok').click();
    }
  }
}

function subir_bajar(id_sel,operacion)
{
	var sel=document.getElementById(id_sel);
	
	switch (operacion) {
		case "subir":
			if (sel.selectedIndex>=1) 
			{
				var aux_value=sel.options[sel.selectedIndex].value;
				var aux_text=sel.options[sel.selectedIndex].text;
				
				sel.options[sel.selectedIndex].value=sel.options[sel.selectedIndex-1].value;
				sel.options[sel.selectedIndex].text=sel.options[sel.selectedIndex-1].text;
				
				sel.options[sel.selectedIndex-1].value=aux_value;
				sel.options[sel.selectedIndex-1].text=aux_text;
				
				sel.selectedIndex=sel.selectedIndex-1;
			}
			break;
		
		case "bajar":
			if (sel.selectedIndex < sel.options.length-1) 
			{
				var aux_value=sel.options[sel.selectedIndex].value;
				var aux_text=sel.options[sel.selectedIndex].text;
				
				sel.options[sel.selectedIndex].value=sel.options[sel.selectedIndex+1].value;
				sel.options[sel.selectedIndex].text=sel.options[sel.selectedIndex+1].text;
				
				sel.options[sel.selectedIndex+1].value=aux_value;
				sel.options[sel.selectedIndex+1].text=aux_text;
				
				sel.selectedIndex=sel.selectedIndex+1;
			}
			break;
	}	
	
}

//retorna todos los valores de un select
function leer_orden(id_sel)
{
	var sel=$(id_sel);
	var orderby="";
	
	for (i=0; i < sel.options.length; i++)
	{
		if (orderby != "")
			orderby+=",";
		orderby += " " + sel.options[i].value + " ASC " ;
	}
	
	return orderby;
}