
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Esta funcion calcula la fecha actual en el siguiente formato: Saturday 27 May 2004
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function fechaDia(){
	var month_names = new Array(12)
	month_names[0] =  "January"
	month_names[1] = "February"
	month_names[2] = "March"
	month_names[3] = "April"
	month_names[4] = "May"
	month_names[5] = "June"
	month_names[6] = "July" 
	month_names[7] = "August"
	month_names[8] = "September"
	month_names[9] = "October"
	month_names[10] = "November"
	month_names[11] = "December"

	var day_names = new Array(7)
	day_names[0] = "Sunday"
	day_names[1] = "Monday"
	day_names[2] = "Tuesday" 
	day_names[3] = "Wednesday"
	day_names[4] = "Thursday"
	day_names[5] = "Friday"
	day_names[6] = "Saturday"

	// Recopilar el día, mes y año actuales	
	var fechaActual = new Date();
      var diaActual = fechaActual.getDate();            
      var mesActual = fechaActual.getMonth()+1;
      var anoActual = fechaActual.getFullYear();

	// Construir un objeto Date y usar los datos anteriores para cambiar la fecha
	var user_date = new Date()
	user_date.setFullYear(anoActual)
	user_date.setMonth(mesActual - 1)
	user_date.setDate(diaActual) 

	// Convertir los números en sus nombres correspondientes
	var day_name = day_names[user_date.getDay()]
	var month_name = month_names[user_date.getMonth()]

	// Mostrar el mensaje
	//alert("La fecha introducida fue el " + diaActual + " de " + month_name + " de " + anoActual + "\n" + "El día de la semana es: " + day_name)

	//pe: Wenesday 28 February 2004
	document.forms["formularioFecha"].elements["fechaDiaSemana"].value = day_name +" "+diaActual+" "+month_name+" "+anoActual
}//fin fechaDia
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  function navegadorImagenesProperty(imagen)
  {
    var PopWidth=450;
    var PopHeight=430;
    var PopLeft = (window.screen.width-PopWidth)/2;
    var PopTop = (window.screen.height-PopHeight)/2;

    window.open('../navegadorImagenesProperty.htm?'+imagen,'','toolbar=no,status=no,menubar=no,location=no,directories=no,resizable=no,scrollbars=no,width='+PopWidth+',height='+PopHeight+',top='+PopTop+',left='+PopLeft);   
  }//fin navegador
//---------------------------------------------------------------------------------------------------------------------      
  function navegadorImagenesND(imagen)
  {
    var PopWidth=420;
    var PopHeight=400;
    var PopLeft = (window.screen.width-PopWidth)/2;
    var PopTop = (window.screen.height-PopHeight)/2;

    window.open('../navegadorImagenesND.htm?'+imagen,'','toolbar=no,status=no,menubar=no,location=no,directories=no,resizable=no,scrollbars=no,width='+PopWidth+',height='+PopHeight+',top='+PopTop+',left='+PopLeft);   
  }//fin navegador
//---------------------------------------------------------------------------------------------------------------------      
  function navegadorImagenesModelo(imagen,idModelo)
  {
    var PopWidth=420;
    var PopHeight=400;
    var PopLeft = (window.screen.width-PopWidth)/2;
    var PopTop = (window.screen.height-PopHeight)/2;

    window.open('../navegadorImagenesModelo.htm?'+imagen+'&'+idModelo,'','toolbar=no,status=no,menubar=no,location=no,directories=no,resizable=no,scrollbars=no,width='+PopWidth+',height='+PopHeight+',top='+PopTop+',left='+PopLeft);   
  }//fin navegador
//---------------------------------------------------------------------------------------------------------------------      
//esta funcion pone las areas correspondientes al 'mainArea' seleccionada
function computeAreas(formulario) {  
  if (document.forms[formulario].elements["mainArea"].value == "Costa Brava North"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Rosas","Rosas");
		    document.forms[formulario].elements["area"].options[2]= new Option ("Palafrugell","Palafrugell");
		    document.forms[formulario].elements["area"].options[3]= new Option ("Sant Feliu de Guixols","Sant Feliu de Guixols");
                document.forms[formulario].elements["area"].options[4]= new Option ("Tordera","Tordera");                
                document.forms[formulario].elements["area"].options[5]= new Option ("Mataro","Mataro");                
                document.forms[formulario].elements["area"].options[6]= new Option ("Barcelona","Barcelona");                
  } //fin Costa Brava North
  else if (document.forms[formulario].elements["mainArea"].value == "Costa Brava South"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Casteldefells","Casteldefells");
		    document.forms[formulario].elements["area"].options[2]= new Option ("Vilanova","Vilanova");
  } //fin Costa Brava South
  else if (document.forms[formulario].elements["mainArea"].value == "Costa Blanca North"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Gandia","Gandia");
		    document.forms[formulario].elements["area"].options[2]= new Option ("Denia","Denia");
                document.forms[formulario].elements["area"].options[3]= new Option ("Calpe","Calpe");
		    document.forms[formulario].elements["area"].options[4]= new Option ("Benidorm","Benidorm");
                document.forms[formulario].elements["area"].options[5]= new Option ("Villa Joiosa","Villa Joiosa");
  } //fin Costa Blanca North
  else if (document.forms[formulario].elements["mainArea"].value == "Costa Blanca South"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Santa Pola","Santa Pola");
		    document.forms[formulario].elements["area"].options[2]= new Option ("Vega Baja","Vega Baja");
                document.forms[formulario].elements["area"].options[3]= new Option ("Torrevieja","Torrevieja");
		    document.forms[formulario].elements["area"].options[4]= new Option ("Orihuela Costa","Orihuela Costa");
                document.forms[formulario].elements["area"].options[5]= new Option ("Mar Menor","Mar Menor");
  } //fin Costa Blanca South
  else if (document.forms[formulario].elements["mainArea"].value == "Alicante"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Alcoi","Alcoi");
		    document.forms[formulario].elements["area"].options[2]= new Option ("Elda","Elda");
                document.forms[formulario].elements["area"].options[3]= new Option ("Jijona","Jijona");
  } //Alicante
  else if (document.forms[formulario].elements["mainArea"].value == "Costa Calida"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Mazarron","Mazarron");
		    document.forms[formulario].elements["area"].options[2]= new Option ("Aguilas","Aguilas");
  } //CostaCalida
  else if (document.forms[formulario].elements["mainArea"].value == "Murcia"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Sucina","Sucina");
		    document.forms[formulario].elements["area"].options[2]= new Option ("Valle de Ricote","Valle de Ricote");
		    document.forms[formulario].elements["area"].options[3]= new Option ("Mula","Mula");
		    document.forms[formulario].elements["area"].options[4]= new Option ("Calaspara","Calaspara");
		    document.forms[formulario].elements["area"].options[5]= new Option ("Sierra Espuña","Sierra Espuña");
		    document.forms[formulario].elements["area"].options[6]= new Option ("Totana","Totana");
		    document.forms[formulario].elements["area"].options[7]= new Option ("Bullas","Bullas");
		    document.forms[formulario].elements["area"].options[8]= new Option ("Caravaca","Caravaca");
  } //Murcia
  else if (document.forms[formulario].elements["mainArea"].value == "Costa Almeria North"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Vera","Vera");
		    document.forms[formulario].elements["area"].options[2]= new Option ("Mojacar","Mojacar");
		    document.forms[formulario].elements["area"].options[3]= new Option ("Carboneras","Carboneras");
  } //Costa Almeria North
  else if (document.forms[formulario].elements["mainArea"].value == "Costa Almeria South"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Almeria","Almeria");
		    document.forms[formulario].elements["area"].options[2]= new Option ("Roquetas","Roquetas");
		    document.forms[formulario].elements["area"].options[3]= new Option ("El Ejido","El Ejido");
		    document.forms[formulario].elements["area"].options[4]= new Option ("Adra","Adra");		         
  } //Costa Almeria South
  else if (document.forms[formulario].elements["mainArea"].value == "Almeria"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Velez Rubio","Velez Rubio");
		    document.forms[formulario].elements["area"].options[2]= new Option ("Huercal","Huercal");
   		    document.forms[formulario].elements["area"].options[3]= new Option ("Overa","Overa");
  } //Almeria
   else if (document.forms[formulario].elements["mainArea"].value == "Granada North"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Huescar","Huescar");
  } //Granada North
  else if (document.forms[formulario].elements["mainArea"].value == "Costa del Sol East"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Nerja","Nerja");
                document.forms[formulario].elements["area"].options[2]= new Option ("Malaga","Malaga");
                document.forms[formulario].elements["area"].options[3]= new Option ("Torremolinos","Torremolinos");
                document.forms[formulario].elements["area"].options[4]= new Option ("Fuengirola","Fuengirola");                
  } //Costa del Sol East
  else if (document.forms[formulario].elements["mainArea"].value == "Costa del Sol West"){
                //hay que tener en cuenta el retardo en los borrados: por eso se borra varias veces
                document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
		    document.forms[formulario].elements["area"].options[5]= null
		    document.forms[formulario].elements["area"].options[6]= null
		    document.forms[formulario].elements["area"].options[7]= null
                document.forms[formulario].elements["area"].options[8]= null
 		    document.forms[formulario].elements["area"].options[1]= null
		    document.forms[formulario].elements["area"].options[2]= null
 		    document.forms[formulario].elements["area"].options[3]= null
                document.forms[formulario].elements["area"].options[4]= null
 		    document.forms[formulario].elements["area"].options[1]= null
                document.forms[formulario].elements["area"].options[2]= null
                document.forms[formulario].elements["area"].options[1]= null

                document.forms[formulario].elements["area"].options[1]= new Option ("Mijas","Mijas");
                document.forms[formulario].elements["area"].options[2]= new Option ("Marbella","Marbella");
                document.forms[formulario].elements["area"].options[3]= new Option ("Estepona","Estepona");
  } //Costa del Sol West

}//fin computeAreas
//---------------------------------------------------------------------------------------------------------------------

//esta funcion añade la pagina actual a 'Favoritos'
function addFavourites(){
  window.external.AddFavorite(window.location.href,'www.villasolera.com -> purchase/sale/rent of properties');
}

//------------------------------------------------------------------------------------
function isEmailAddress(theElement)
{
var s = theElement.value;
//var filter=/^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)*(.[a-zA-Z]{2,3})$/
// Para permitir direcciones del tipo prueba@prueba.es.eses
  var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;  
if (s.length == 0){ return true;}
if (filter.test(s)){
	return true;
}else{
	alert("You must introduce a valid e-mail address.");
	return false;
}
}
//------------------------------------------------------------------------------------
// Esta función comprueba que el dígito decimal es un '.' y no una ','
function validaDecimalPunto(theElement)
{
var s = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}
 //miramos que en los campos con decimales no haya ninguna coma ',' -> tiene que haber punto
 for (i=0; i<s.length; i++)
   if (s.charAt(i)==","){
		window.alert("The field "+name+" contains character ','. Must be '.'");
		return false;
 }
 return true;
}
//------------------------------------------------------------------------------------
// Esta función comprueba el campo es un dígito
function isDigit(theElement)
{
 var value = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}

if (value==""){value="0";}
 var i;
 for (i=0; i<value.length; i++)
   if ( (value.charAt(i)<"0") || (value.charAt(i)>"9") ){
		window.alert("The number is not an integer.");
		return false;
   }
 return true;
}
//------------------------------------------------------------------------------------
// Esta función comprueba el campo es un dígito
function validaNumero(theElement)
{
 var value = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}
if (value==""){value="0";}
if (isNaN(value)){
		window.alert("The field " + name + " is not correct number(decimal is .)");
		return false;
   }
 return true;
}
//------------------------------------------------------------------------------------
// Esta función comprueba si el campo contiene el valor "Select"
function isSelect(theElement)
{
 var value = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}
  
 if (name == undefined){
    name = theElement.name;
 }
 if (value == "Select"){
		window.alert("You must introduce a " + name + "");
		return true; }
 return false;
}
//------------------------------------------------------------------------------------
// Esta función comprueba si el campo es un porcentaje valido
function porcentajeValido(theElement)
{
 var value = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
} 
 if ((value!="")&&((!((value > 0) && (value <101))) || (isNaN(value)))){
		window.alert("You must introduce a pecentage of " + name + " valid.");
		return false; }
 return true;
}
//------------------------------------------------------------------------------------
// Esta función comprueba si el campo esta vacio
function estaVacio(theElement)
{
 var value = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.title;
	if ( (name=="") || (name=="undefined") ){
	     name = theElement.name;
	}
}
 if (value == ""){
		window.alert("You must introduce a " + name + "");
		return true; }
 return false;
}
//------------------------------------------------------------------------------------
// Esta función comprueba si dos password son iguales
function passwordIguales(theElement1,theElement2)
{
 var value1 = theElement1.value;
 var value2 = theElement2.value; 
 if (value1 != value2){
		window.alert("Error: The keys password don't coincide!!");
		return false; }
 return true;
}
//------------------------------------------------------------------------------------
// Esta función comprueba si el elemento es un color valido
function esColor(theElement1)
{
 var value1 = theElement1.value;
 if ((value1.length != 7)||(value1.charAt(0) != "#") ){
	window.alert("Yom must introduce a correct dark color (first character must be '#').");
	return false; }
 return true;
}
//------------------------------------------------------------------------------------
// Esta función comprueba si el elemento es un color valido
function esHoraValida(theElement1)
{
 	hora=theElement1.value
 	if ((isNaN(hora.charAt(0))) || (isNaN(hora.charAt(1))) || (isNaN(hora.charAt(3))) || (isNaN(hora.charAt(4)))){
 		alert("Introduce HH:MM");return}		
	if (hora.length!=5) {alert("Introduce HH:MM");return}
	a=hora.charAt(0)
	b=hora.charAt(1)
	c=hora.charAt(3)
	if (a>=2 && b>3) {alert("Hour evil");return}
	if (c>5) {alert("Minutes evil");return}
	return true;
}	
//------------------------------------------------------------------------------------
// Esta función valida una fecha
function isDateValid(theElement1,theElement2,theElement3)
{
 var valueDay = theElement1.value;
 var valueMonth = theElement2.value;
 var valueYear = theElement3.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement1.label;
} else {
	var name = theElement1.title;
	if ( (name=="") || (name=="undefined") ){
	     name = theElement1.name;
	}
}
// if(( valueDay=="" ) && ( valueMonth=="" ) && ( valueYear=="" )){
// 	 window.alert("You must introduce a "+ name);
//	 return false;        
// }
//else
//{       
  if((valueDay.length != "2") || (valueMonth.length != "2") ||(valueYear.length != "4") )
     {
		window.alert("You must introduce a correct " +name);
		return false;
     } 
  
  if ((valueDay<"01") || (valueDay>"31") ||
      (valueMonth<"01") ||
      (valueMonth>"12"))      
      {
		window.alert("You must introduce a correct "+name);
		return false;
      } 
      
// }//fin fecha validez de precios

 return true;
}
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
// Esta función valida una fecha
function isDate(dia,mes,ano)
{
     
  if((dia.length != "2") || (mes.length != "2") ||(ano.length != "4") )
     {
		return false;
     } 
  
  if ((dia<"01") || (dia>"31") ||
      (mes<"01") ||
      (mes>"12"))      
      {
		return false;
      } 

 return true;
}
//------------------------------------------------------------------------------------
// Esta función valida una fecha
function formateaDateADos(value)
{
  if (value.length == 1){ return value = "0"+value;}
  else{ return value;}

}

//------------------------------------------------------------------------------------

/*esta funcion abre una ventana nueva con el formulario de soporte*/
function fventanasoporte()
{
		window.open("../formularioSoporte.jsp", null, "width=800,height=600,toolbar=no,directories=no,location=no,status=no,scrollbars=yes,resizable=yes,menubar=no");
}
//------------------------------------------------------------------------------------

/*funciones necesarias para la logica de pestañas en los formularios*/
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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//--------------------------------------------------------------------------
/* Con esta función se pide confirmación para eliminar una imagen. En caso afirmativo, llama al servlet correspondiente
Parametros: esFoto = true/false
			tipoImagen = proyecto/proyectoLogo/property/account
			id = identificador del usuario
			nombre = nombre de la imagen.
 */
function delImagen(esFoto,tipoImagen,user,name,numero){	      
	if (confirm("Are yo sure to delete this image ?")==true){
             this.window.location = "../servlet/AccionDeleteImagen.ctrl?esFoto="+esFoto+"&tipoImagen="+tipoImagen+"&id="+user+"&nombre="+name+"&numero="+numero;
      }
}
//--------------------------------------------------------------------------
/* Con esta función se pide confirmación para eliminar una entidad o una organización*/
function delEntOrg(name,objeto,pantalla){
var mensaje1="";
var mensaje2="";

if (objeto=="Entidad"){
	mensaje1 = "If you delete enterprise "+ name +" all organization and persons will be deleted!";
	mensaje2 = "Are yo sure to delete the enterprise " + name + " ?."; 
} else if (objeto=="Organizacion"){
	var pos2 = name.indexOf("---");          
	var nombre_solo = name.substring(pos2 + 3);	
	mensaje1 = "If you delete organization "+ nombre_solo +" all persons will be deleted!";
	mensaje2 = "Are yo sure to delete organization " + nombre_solo + " ?.";

}	
      window.alert(mensaje1);
	if (confirm(mensaje2)==true){
             this.window.location = "../servlet/AccionDeleteEntOrg.ctrl?accountActual="+name+"&pantalla="+pantalla;
      }
}
//--------------------------------------------------------------------------
/* Funcion necesaria para la ayuda contextual en los botones de la aplicacion*/
function MM_setTextOfTextfield(objName,x,newText) { //v3.0
  var obj = MM_findObj(objName); if (obj) obj.value = newText;
}
//--------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/*
	Hace el submit, desactiva el boton de submit
	y reaigna la funcion JavaScript de envio a una funcion dummy
	para evitar el reenvio en caso de que el navegador no soporte
	la deshabilitacion del boton submit
*/
function Submit_seguro( formulario) {
	for (i=1; i < formulario.elements.length; i++) {
		//deshabilita el boton de submit
		if (formulario.elements[i].type == 'submit') {
			formulario.elements[i].disabled = true
		}
	}
	//envia el formulario
	formulario.submit()
	
	//reasinga la funcion de envio a una funcion dummy
	Submit_seguro = Submit_off
	return false
}

/*
	Esta funcion no hace nada
	Sirve para evitar el reenvio del formulario
*/
function Submit_off( formulario ) {
    return false
}
//-------------------------------------------------------------------------------

// Esta función comprueba si el campo es una imagen"
function esImagen(theElement)
{

var value = theElement.value;
var bname = navigator.appName;
var pos = value.lastIndexOf(".");
var extension = value.substring(pos+1);

if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}
  
 if (name == undefined){
    name = theElement.name;
 }
  if ((extension != "bmp")&&(extension != "jpg")&&(extension != "gif")&&(extension != "png")&&(extension != "jpeg")){
		window.alert("The file '"+name+"' has to be jpg/jpeg/bmp/gif/png!!!");
		return false; }
 return true;
}
//---------------------
	function utf8_encode ( theElement ) {  
        // Encodes an ISO-8859-1 string to UTF-8    
        //   
        // version: 81316  
        // discuss at: http://phpjs.org/functions/utf8_encode  
        // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)  
        // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)  
        // +   improved by: sowberry  
        // +    tweaked by: Jack  
      // +   bugfixed by: Onno Marsman  
      // +   improved by: Yves Sucaet  
      // +   bugfixed by: Onno Marsman  
      // *     example 1: utf8_encode('Tom van Mikes');  
      // *     returns 1: 'Tom van Mikes' 
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}
      
      string = theElement.value; 
      string = (string+'').replace(/\r\n/g, "\n").replace(/\r/g, "\n");  
      
   
      var utftext = "";  
      var start, end;  
      var stringl = 0;  
     
       start = end = 0;  
       stringl = string.length;  
       for (var n = 0; n < stringl; n++) {  
           var c1 = string.charCodeAt(n);  
           var enc = null;  
           if (c1 < 128) {  
				//alert('ok = '+string[n]);
               end++;  
           } else {  
		       if (
		       (string[n]=='ñ')||(string[n]=='Ñ')||(string[n]=='á')||(string[n]=='é')||(string[n]=='í')||(string[n]=='ó')||(string[n]=='ú')||
		       (string[n]=='Á')||(string[n]=='É')||(string[n]=='Í')||(string[n]=='Ó')||(string[n]=='Ú')
		       ){
			   //alert('ok = '+string[n]);
			   }else {
			   window.alert("The field "+name+" contains no permitted character "+string[n]);
			   return false;
			   }

           }  
       }  
     
    
       return true;  
   } 
//------------------------------------------------------------------------------------
// Esta función comprueba que el campo no contiene una comilla
function validaCadena(theElement)
{
var s = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}

if (!utf8_encode(theElement)) return false;
//s.replace('"','\"');
//s.replace('\'','\"');
//miramos que en el campo no haya ningun carácter especial
 for (i=0; i<s.length; i++){
   if ((s.charAt(i)=="'")||(s.charAt(i)=="\"")){
		window.alert("The field "+name+" contains no permitted characters ' ,\"");
		return false;
 }}
 return true;
}

//------------------------------------------------------------------------------------
// +[1<n<5 dígitos]espacio[n dígitos entre 6 y 12]

function validaTelefono(theElement)
{

var value = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}

if (value==""){return true;}
if (value.charAt(0)!="+") {
	window.alert("The field "+name+" contains an invalid format. The correct is +34 123456789");
	return false;

}


// se define una expresion regular con la cual se evaluará el formato del telefono
var filter =/^[0-9]{2,4}-? ?[0-9]{6,12}$/;

// verificamos que el telefono cumpla con el formato requerido a partir del +
if (!filter.test(value.substring(1))){
	window.alert("The field "+name+" contains an invalid format. The correct is +34 123456789");
	return false;
}
return true;

}
//------------------------------------------------------------------------------------
// Esta función comprueba el campo es un dígito
/*
function validaTelefono(theElement)
{

var value = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}

if (value==""){return true;}
var erroneo = "false";
if (value.length<5) {erroneo = "true";}
// Lo primero debe ser un + y el cuarto un espacio
if ((value.charAt(0)!="+")||(value.charAt(3)!=" ")) {erroneo = "true";}
// Primer y segundo dígito deben ser números
if ( (value.charAt(1)<"0") || (value.charAt(1)>"9") ){erroneo = "true";}
if ( (value.charAt(2)<"0") || (value.charAt(2)>"9") ){erroneo = "true";}
// El resto a partir del espacio, todos dígitos
 for (i=4; i<value.length; i++){
 if ( (value.charAt(i)<"0") || (value.charAt(i)>"9") ){erroneo = "true";break;}
 }


if (erroneo=="true"){
	window.alert("The field "+name+" contains an invalid format. The correct is +34 123456789");
	return false;
}

return true;
}
*/
//***************************************************************
// Elimina espacios a la izquierda
      function ltrim( s )
      {
        var lpatt = new RegExp( "^ *(.*)$" );
        var parse = s.match( lpatt );
        if (null==parse)
          return "";
        else
          return parse[1];
      }
//***************************************************************
// Elimina espacios a la derecha
      function rtrim( s )
      {
        var rpatt = new RegExp( "^(.*[^ ]) *$" );
        var parse = s.match( rpatt );
        if (null==parse)
          return "";
	else
          return parse[1];
      }
      
// ****************************************************************
function trim (s){
        var lpatt = new RegExp( "^ *(.*)$" );
        var parse = s.match( lpatt );
        if (null==parse) return "";
        else s = parse[1];

        var rpatt = new RegExp( "^(.*[^ ]) *$" );
        var parse = s.match( rpatt );
        if (null==parse)  return "";
		else return parse[1];          
          
          
} 
//---------------------------------------------------------- 
// Valida que la fecha venga con formato dd/mm/yyyy
 function validaFormatoFecha(theElement){
  var valor = theElement.value;
  
  if (valor.length != 10) {
		alert('Date format invalid. Please enter the date in the format dd / mm / yyyy.');  
    	return false;
  		  
  }
  if ((valor.charAt(2)!= "/")||(valor.charAt(5)!= "/")) {
		alert('Date format invalid. Please enter the date in the format dd / mm / yyyy.');  
    	return false;
  
  } 
  
  var valueDay = valor.substring(0,2);
  var valueMonth = valor.substring(3,5);
  var valueYear = valor.substring(6,10);
  if((valueDay.length != "2") || (valueMonth.length != "2") ||(valueYear.length != "4") )
     {
		alert('Date format invalid');  
    	return false;
     } 
  
  if ((valueDay<"01") || (valueDay>"31") ||
      (valueMonth<"01") ||
      (valueMonth>"12"))      
      {
		alert('Date format invalid');  
    	return false;
      } 

  
  return true;
}  
//****************************************************************************************
//*********** DETECCION NAVEGADOR Y DATOS DEL CLIENTE **********
//****************************************************************************************
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function SistemaOperativo() { 
if (navigator.userAgent.indexOf('IRIX') != -1) {var SO = "Irix" } 
else if ((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('98') != -1)) {var SO= "Windows 98"} 
else if ((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('95') != -1)) {var SO= "Windows 95"} 
else if (navigator.appVersion.indexOf("16") !=-1) {var SO= "Windows 3.1"} 
else if (navigator.userAgent.indexOf("NT 5.1") !=-1) {var SO= "Windows XP"} 
else if (navigator.userAgent.indexOf("NT 5.2") !=-1) {var SO= "Windows Server 2003"} 
else if (navigator.userAgent.indexOf("NT 5") !=-1) {var SO= "Windows 2000"} 
else if (navigator.userAgent.indexOf("NT 6") !=-1) {var SO= "Windows Vista"} 
else if (navigator.appVersion.indexOf("NT") !=-1) {var SO= "Windows NT"} 
else if (navigator.appVersion.indexOf("SunOS") !=-1) {var SO= "SunOS"} 
else if (navigator.appVersion.indexOf("Linux") !=-1) {var SO= "Linux"} 
else if (navigator.userAgent.indexOf('Mac') != -1) {var SO= "Macintosh"} 
else if (navigator.appName=="WebTV Internet Terminal") {var SO="WebTV"} 
else if (navigator.appVersion.indexOf("HP") !=-1) {var SO="HP-UX"} 
else {var SO= "No identificado"} 
return SO;} 
var SO= SistemaOperativo();

var java;
if (navigator.javaEnabled()) java="Si"; else java="No";

//****************************************************************************************
//*********** FIN DETECCION NAVEGADOR Y DATOS DEL CLIENTE **********
//****************************************************************************************

//************************************************
// Las fechas deben llegar en formato yyyy-MM-dd
// 0 --> no es posterior
// 1 --> es posterior
function fechaEsPosterior(fecha1,fecha2){

	if (fecha1==fecha2) {  
		return true;
	} else {
// Validación de la fecha de fin. No puede ser posterior a la de inicio. La transforma a entero manteniendo 0's
		var anyo = fecha1.substring(0,4);
		var mes = fecha1.substring(5,7);
		if (mes.length==1) mes = "0"+mes;
		var dia = fecha1.substring(8,10);
		if (dia.length==1) dia = "0"+dia;
		var fechaInicio =  anyo + mes + dia;

		
		
		var anyo = fecha2.substring(0,4);
		var mes = fecha2.substring(5,7);
		if (mes.length==1) mes = "0"+mes;
		var dia = fecha2.substring(8,10);

		if (dia.length==1) dia = "0"+dia;
		var fechaFin =  anyo + mes + dia;
		
		if (parseInt(fechaFin)<parseInt(fechaInicio)){
			return false;
		}
	}
	return true;
}
//**************************** VALIDACION DE LA CUENTA CORRIENTE. LAS DOS FUNCIONES DE DEBAJO SON NECESARIAS ***************************
function numerico(valor){
  cad = valor.toString();
  for (var i=0; i<cad.length; i++) {
    var caracter = cad.charAt(i);
	if (caracter<"0" || caracter>"9")
	  return false;
  }
  return true;
}
function obtenerDigito(valor){
  valores = new Array(1, 2, 4, 8, 5, 10, 9, 7, 3, 6);
  control = 0;
  for (i=0; i<=9; i++)
    control += parseInt(valor.charAt(i)) * valores[i];
  control = 11 - (control % 11);
  if (control == 11) control = 0;
  else if (control == 10) control = 1;
  return control;
}

function esValidaCCC(banco,sucursal,dc,cuenta){

	// Validación del número de cuenta	
	  if (banco == ""  || sucursal == "" ||  dc == "" || cuenta == ""){
  		alert("Please enter your CCC information");
	    return false;
    }
  else {
    if (banco.length != 4 || sucursal.length != 4 || dc.length != 2 || cuenta.length != 10){
		alert("Please correctly enter your CCC information. There are no complete.");
        return false;
      }
    else {
      if (!numerico(banco) || !numerico(sucursal) || !numerico(dc) || !numerico(cuenta)){
		alert("Please correctly enter your account information. Not numerical data");
		return false;
        }
      else {
        if (!(obtenerDigito("00" + banco + sucursal) == parseInt(dc.charAt(0))) || !(obtenerDigito(cuenta) == parseInt(dc.charAt(1)))){
	     alert("The check digits do not correspond to other CCC numbers");
	     return false;
          }
      }
    }
  }
  return true;  
}
//------------------------------------------------------------------------------------
// Esta función comprueba el campo es un dígito
function noEsImporte(theElement)
{
 var value = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}

if (value==""){value="0";}
 var i;
 for (i=0; i<value.length; i++)
   if ((( (value.charAt(i)<"0") || (value.charAt(i)>"9") )) && (value.charAt(i)!=".") && (value.charAt(i)!=",") ){
		window.alert("The field " + name + " is not an ammount valid.");
		return false;
   }
 return true;
}
//-------------------
//------------------------------------------------------------------------------------
//
function validaCaracteresEspeciales(theElement)
{
var s = theElement.value;
var bname = navigator.appName;
if (bname == "Microsoft Internet Explorer"){
	var name = theElement.label;
} else {
	var name = theElement.name;
}

 for (i=0; i<s.length; i++){
   if ((s.charAt(i)=="&")||(s.charAt(i)=="(")||(s.charAt(i)==")")){
		window.alert("The field "+name+" contains the illegal character &, ) or (");
		return false;
 }}
 return true;
}
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
// Función que ejecuta una búsqueda google y la muestra en el div
function ejecutaBusquedaGoogle(nombreDiv,valor)
{

    /*
    *  How to do a search that returns the max number of results per page.
    */
    
    google.load('search', '1');
    
    function OnLoad() {
    
      // create a search control
      var searchControl = new google.search.SearchControl();
    
      // Set the Search Control to get the most number of results
      searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
    
      // Create 2 searchers and add them to the control
      searchControl.addSearcher(new google.search.WebSearch());
      searchControl.addSearcher(new google.search.BlogSearch());
    
      // Set the options to draw the control in tabbed mode
      var drawOptions = new google.search.DrawOptions();
      drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
    
      // Draw the control onto the page
      searchControl.draw(document.getElementById(nombreDiv), drawOptions);
    
      // Search!
      searchControl.execute(valor);
    }
    google.setOnLoadCallback(OnLoad);
}

    
