// JavaScript Document

function showHide(name,nombre, number){

  if(name=="Panama"){
	document.getElementById(nombre+1).style.display='none';
  }
  else
    document.getElementById(nombre+1).style.display='block';
	
}

function showIA(name,nombre, number,elemento){

  if(name=="checkbox"){
	document.getElementById(nombre+number).style.display='block';
	//window.alert("entra "+name);
	document.getElementById(elemento).value = "";
  }
  else{
    document.getElementById(nombre+number).style.display='none';
	document.getElementById(elemento).value = "checkbox";
  }
	
}

function showVisited(name,nombre, number){
  if(name=="Yes"){
	document.getElementById(nombre+3).style.display='block';
//	window.alert("entra "+name);
	//document.getElementById('visited').value = "";
  }
  else if(name=="No"){
    document.getElementById(nombre+3).style.display='none';
	//document.getElementById('ia').value = "true";
  }
	
}

function showServices(name,nombre){

 if(name=="Select your service"){
	document.getElementById(nombre+6).style.display='none';
	document.getElementById(nombre+7).style.display='none';
  }
  //alert(name);
  if(name=="Buy, Rent, Relocate / Compra, Renta, Relocalizacion"){
	document.getElementById(nombre+6).style.display='block';
	document.getElementById(nombre+7).style.display='none';
  }
 /*if(name=="2"){
	document.getElementById(nombre+6).style.display='none';
	document.getElementById(nombre+7).style.display='none';
  }*/
 if(name=="Sell, Rent a Property / Venta, Alquilar una Propiedad"){
	  document.getElementById(nombre+6).style.display='none';
	document.getElementById(nombre+7).style.display='block';
  }	
}

function llamarShowAbout(valor){
		var name = "nada";
		if(valor=="Internet Advertising"){
				name="ele2";
		}else if(valor=="Printed Advertising"){
			name="ele4";
		}else if(valor=="Other"){
				name="ele8";
		}
			showAbout(name);
}
//Función usada para desplegar las opciones de How did you found out about us
function showAbout(name){

  if(name=="ele2"){
	document.getElementById(name).style.display='block';
	document.getElementById("ele4").style.display='none';
	document.getElementById("ele8").style.display='none';
  }
  else if(name=="ele4"){
	document.getElementById(name).style.display='block';
	document.getElementById("ele2").style.display='none';
	document.getElementById("ele8").style.display='none';
  }
  else if(name=="ele8"){
	document.getElementById(name).style.display='block';
	document.getElementById("ele4").style.display='none';
	document.getElementById("ele2").style.display='none';
  }
  else if(name=="nada"){
	document.getElementById("ele8").style.display='none';
	document.getElementById("ele4").style.display='none';
	document.getElementById("ele2").style.display='none';
  }
	
}


//Valida el formulario de miembros
function validarContactUs(fname, lname, email,thome,toffice,tcel,Country,visited,visitdate,about,aboutia,aboutpa,other,service,comments,Submit){
	var todo=true;//se mantiene true si todos los campos estan correctos
	var msg="";

 if(!validateNotEmpty(fname)){
    msg=msg+"Fill your name\n";
    todo=false;
 }

 if(!validateNotEmpty(lname)){
    msg=msg+"Fill your last name\n";
    todo=false;
 }
  if(!validateEmail(email)){
    msg=msg+"Fill your e-mail\n";
    todo=false;
 }
  if(!validateNotEmpty(thome)&&!validateNotEmpty(toffice)&&!validateNotEmpty(tcel)){
    msg=msg+"You must fill a phone type\n";
    todo=false;
 }
 if(Country=="Select your country"){
	msg=msg+"Select your country\n";
    todo=false;
 }
 
 if(!validateNotEmpty(state)){
    msg=msg+"Fill your state\n";
    todo=false;
 }
 
 if(Country!="Panama"){
	if(visited[0].checked==false && visited[1].checked==false){
		msg=msg+"Choose yes or no if Have you visited Panama?\n";
		todo=false;
	}
   if(!validateNotEmpty(visitdate)){
    msg=msg+"Fill your Next planned visit\n";
    todo=false;
  }
 }
 /* window.alert("0: "+about[0].value+"checked: "+about[0].checked);
  window.alert("1:"+about[1].value+"checked: "+about[1].checked);
  window.alert("2:"+about[2].value+"checked: "+about[2].checked);
  window.alert("3:"+about[3].value+"checked: "+about[3].checked);
  window.alert("4:"+about[4].value+"checked: "+about[4].checked);
  window.alert("5:"+about[5].value+"checked: "+about[5].checked);*/
  if(about[0].checked==false &&about[1].checked==false &&about[2].checked==false &&about[3].checked==false
	 &&about[4].checked==false &&about[5].checked==false){
	  msg=msg+"Choose a option of How did you found out About Us\n";
	  todo=false;
  }
  if(about[2].checked==true){
	  if(aboutia[0].checked==false&&aboutia[1].checked==false&&aboutia[2].checked==false&&aboutia[3].checked==false
		 &&aboutia[4].checked==false&&aboutia[5].checked==false&&aboutia[6].checked==false){
		   msg=msg+"Choose a option of Internet Advertising\n";
	       todo=false;
	  }
  }
   if(about[4].checked==true){
	  if(aboutpa[0].checked==false&&aboutpa[1].checked==false&&aboutpa[2].checked==false&&aboutpa[3].checked==false
		 &&aboutpa[4].checked==false&&aboutpa[5].checked==false&&aboutpa[6].checked==false&&aboutpa[7].checked==false){
		   msg=msg+"Choose a option of Printed Advertising\n";
	       todo=false;
	  }
  }
  if(about[5].checked==true){
	  if(!validateNotEmpty(other)){
		   msg=msg+"Fill the other text field in How did you found out About Us\n";
           todo=false;
	  }
  }
 /* window.alert("service:"+service);
  window.alert("Country:"+Country);*/
  if(service=="Select your service"){
	msg=msg+"Select your service\n";
	todo=false;
  }
  
  if(service=="Buy / Rent, Relocating, Living Advice"){
	   if(!validateNotEmpty(location)){
		   msg=msg+"Fill the location\n";
           todo=false;
	   }
	   if(!validateNotEmpty(lotsize)){
		   msg=msg+"Fill the lot size\n";
           todo=false;
	   }
	   if(!validateNotEmpty(ecsize)){
		   msg=msg+"Fill the Enclosed Construction Size\n";
           todo=false;
	   }
	   if(!validateNotEmpty(gdescription)){
		   msg=msg+"Fill the General Description\n";
           todo=false;
	   }
	   if(!validateNotEmpty(budget)){
		   msg=msg+"Fill the Budget\n";
           todo=false;
	   }
	 
  }
  
  if(service=="Sell or Rent a Property"){
	  if(!validateNotEmpty(slocation)){
		   msg=msg+"Fill the location\n";
           todo=false;
	   }
	   if(!validateNotEmpty(slotsize)){
		   msg=msg+"Fill the lot size\n";
           todo=false;
	   }
	   if(!validateNotEmpty(secsize)){
		   msg=msg+"Fill the Enclosed Construction Size\n";
           todo=false;
	   }
	   if(!validateNotEmpty(sgdescription)){
		   msg=msg+"Fill the General Description\n";
           todo=false;
	   }
	   if(!validateNotEmpty(sellprice)&&!validateNotEmpty(rentprice)){
		   msg=msg+"Fill the sell or rent price\n";
           todo=false;
	   }
  }
 /* 
  if((validateNotEmpty(comments))&&(comments.length > 250)){
	 msg = msg + "The comments can't have more of 250 characters"; 
	 todo=false;
  }
 */
 if(todo==false)
   alert(msg);
  else{
   //alert("Please, do not to press the submit button again!");
   Submit.disabled=true;
   pleaseWait();
  }
   
 return todo;
//return false;
}

function showNewOption(valor,name){
	//alert(valor);
	if(valor=="Rent"){
		document.getElementById("nuevosrv1").style.display='block';
		document.getElementById("nuevosrv2").style.display='none';
	}else if(valor=="Purchase"){
		document.getElementById("nuevosrv2").style.display='block';
		document.getElementById("nuevosrv1").style.display='none';
	}else{
		document.getElementById("nuevosrv2").style.display='none';
		document.getElementById("nuevosrv1").style.display='none';
	}
}

//Valida el formulario de miembros
function validarContactUs_contact(fname, lname, email,thome,toffice,tcel,Country,visited,visitdate,about,aboutia,aboutpa,other,service,comments,Submit,idioma){
	frm = document.form1;
	var todo=true;//se mantiene true si todos los campos estan correctos
	var msg="";

 if(!validateNotEmpty(frm.sector.value)){
	if(idioma=='en')
	    msg=msg+"Select your region\n";
	else	
		msg=msg+"Seleccione su region\n";	
    todo=false;
 }
 if(!validateNotEmpty(fname)){
	if(idioma=='en') 
	    msg=msg+"Fill your name\n";
	else
		msg=msg+"Su nombre es requerido\n";
    todo=false;
 }

 if(!validateNotEmpty(lname)){
	if(idioma=='en')	 
	    msg=msg+"Fill your last name\n";
	else
		msg=msg+"Su apellido es requerido\n";
    todo=false;
 }
  if(!validateEmail(email)){
	if(idioma=='en')  
	    msg=msg+"Fill your e-mail\n";
	else
		msg=msg+"Su e-mail es requerido\n";
    todo=false;
 }
  if(!validateNotEmpty(thome)){//&&!validateNotEmpty(toffice)&&!validateNotEmpty(tcel)
  	if(idioma=='en')
	    msg=msg+"You must fill a phone\n";
	else
		msg=msg+"Debe llenar su teléfono\n";
    todo=false;
 }
 if(Country=="Select your country"){
	if(idioma=='en') 	
		msg=msg+"Select your country\n";
	else
		msg=msg+"Seleccione su país\n";
    todo=false;
 }
 
 /*if(!validateNotEmpty(state) && !validateNotEmpty(state)){
    msg=msg+"Fill your state\n";
    todo=false;
 }*/
 
 if(Country!="Panama"){
	if(visited[0].checked==false && visited[1].checked==false){
		if(idioma=='en')	
			msg=msg+"Choose yes or no if Have you visited Panama?\n";
		else	
			msg=msg+"Escoga Sí o No, Si ha visitado antes Panama?\n";
		todo=false;
	}
   /*if(!validateNotEmpty(visitdate)){
    msg=msg+"Fill your Next planned visit\n";
    todo=false;
  }*/
 }
 /* window.alert("0: "+about[0].value+"checked: "+about[0].checked);
  window.alert("1:"+about[1].value+"checked: "+about[1].checked);
  window.alert("2:"+about[2].value+"checked: "+about[2].checked);
  window.alert("3:"+about[3].value+"checked: "+about[3].checked);
  window.alert("4:"+about[4].value+"checked: "+about[4].checked);
  window.alert("5:"+about[5].value+"checked: "+about[5].checked);*/
  if(about.value==""){
	  if(idioma=='en')
		  msg=msg+"Choose a option of How did you found out About Us\n";
	  else
	  	  msg=msg+"Escoga una opción de Como se enteró de CENTURY21 Semusa Realty\n";
	  todo=false;
  }
  if(about.value=="Internet Advertising"){
	  	
	  if(!validateNotEmpty(aboutia.value)){
		   if(idioma=='en')	
			   msg=msg+"Choose a option of Internet Advertising\n";
		   else
			   msg=msg+"Seleccione una opción de Publicidad en Internet\n";
	       todo=false;
	  }
  }
   if(about.value=="Printed Advertising"){
	  if(!validateNotEmpty(aboutpa.value)){
		   if(idioma=='en')	
		   		msg=msg+"Choose a option of Printed Advertising\n";
		   else
			   	msg=msg+"Seleccione una opción de Publicidad Imprenta\n";
		   
	       todo=false;
	  }
  }
  if(about.value=="Other"){
	  if(!validateNotEmpty(other)){
		   if(idioma=='en')		
		   		msg=msg+"Fill the other text field in How did you found out About Us\n";
		   else
			   	msg=msg+"Por favor describa Como se entero de nosotros\?n";
           todo=false;
	  }
  }
 /* window.alert("service:"+service);
  window.alert("Country:"+Country);*/
  if(service=="Select your service"){
	if(idioma=='en')	  
		msg=msg+"Select your service\n";
	else
		msg=msg+"Seleccione su servicio\n";
	todo=false;
  }
  
  if(service=="Buy, Rent, Relocate / Compra, Renta, Relocalizacion"){
	   if(!validateNotEmpty(frm.months.value)){
		   if(idioma=='en')
			   msg=msg+"Select  the Time Frame of Purchase / Rent\n";
		   else
		   	   msg=msg+"Selecione el Periodo de compra / Alquiler\n";
           todo=false;
	   }
	   if(!validateNotEmpty(frm.typep.value)){
		   if(idioma=='en')	
		   		msg=msg+"Select the Type of Property\n";
		   else
		   	msg=msg+"Seleccione el Tipo de Propiedad\n";
           todo=false;
	   }



	   /*if(!validateNotEmpty(frm.location.value)){
		   msg=msg+"Fill the location\n";
           todo=false;
	   }
	   if(!validateNotEmpty(frm.lotsize.value)){
		   msg=msg+"Fill the lot size\n";
           todo=false;
	   }
	   if(!validateNotEmpty(frm.ecsize.value)){
		   msg=msg+"Fill the Enclosed Construction Size\n";
           todo=false;
	   }
	   if(!validateNotEmpty(frm.gdescription.value)){
		   msg=msg+"Fill the General Description\n";
           todo=false;
	   }
	   if(!validateNotEmpty(frm.rentopur.value)){
		   	msg=msg+"Select the option Rent or Purchase \n";
			todo=false;
	   }else{
		   if(frm.rentopur.value=="Rent"){
			   if(!validateNotEmpty(frm.budget1.value)){
				   msg=msg+"Fill the Budget\n";
				   todo=false;
			   }
		   }else{
			   if(!validateNotEmpty(frm.budget2.value)){
				   msg=msg+"Fill the Budget\n";
				   todo=false;
			   }
		   }
	   }*/
	 
  }
  
  if(service=="Sell, Rent a Property / Venta, Alquilar una Propiedad"){
	  
	  
	  if(!validateNotEmpty(frm.stypep.value)){	
	  	  if(idioma=='en')	
		   		msg=msg+"Select the Type of Property \n";
		 else		
		 	msg=msg+"Seleccione el tipo de propiedad \n";
           todo=false;
	   }
	  
	  /*if(!validateNotEmpty(frm.slocation.value)){
		   msg=msg+"Fill the location\n";
           todo=false;
	   }
	   if(!validateNotEmpty(frm.slotsize.value)){
		   msg=msg+"Fill the lot size\n";
           todo=false;
	   }
	   if(!validateNotEmpty(frm.secsize.value)){
		   msg=msg+"Fill the Enclosed Construction Size\n";
           todo=false;
	   }
	   if(!validateNotEmpty(frm.sgdescription.value)){
		   msg=msg+"Fill the General Description\n";
           todo=false;
	   }
	   if(!validateNotEmpty(frm.sellprice.value)&&!validateNotEmpty(frm.rentprice.value)){
		   msg=msg+"Fill the sell or rent price\n";
           todo=false;
	   }*/
  }
 /* 
  if((validateNotEmpty(comments))&&(comments.length > 250)){
	 msg = msg + "The comments can't have more of 250 characters"; 
	 todo=false;
  }
 */
 var bandcheck = false;

 for(i=0;i<frm.adicionalserv.length;i++){
	 if(frm.adicionalserv[i].checked){
		 	bandcheck=true;
		 	break;
	 }
 }
 	
 /*if(!bandcheck){ //&& !validateNotEmpty(frm.adicionalserv_txt.value)
	  msg+="Please select at least one option -Adtional Services\n";
	   todo=false;
 }*/
 if(todo==false)
   alert(msg);
  else{
   //alert("Please, do not to press the submit button again!");
   Submit.disabled=true;
   pleaseWait();
  }
   
 return todo;
//return false;
}






function showSectorDescLink() {
	
	var selSector = getElement("selSector");
	var mySectorId = selSector.value;
	var myDiv = getElement("divSectorDescLink");
	var myLink = document.createElement('a');
	var myHref = "javascript:showSectorDesc(" + mySectorId + ")";

	// get rid of any child nodes before add new ones
	if ( myDiv.hasChildNodes() ) {
		var len = myDiv.childNodes.length;
		while ( myDiv.hasChildNodes() ) {
			myDiv.removeChild(myDiv.firstChild);
		}
	}

	if ( mySectorId == 0 ) {
		return false;
	}

	// add child nodes and text
	myLink.setAttribute("href",myHref);
	myLink.setAttribute("style","color: blue;");
	myLinkText = document.createTextNode("Description");
	myLink.appendChild(myLinkText);
	myDiv.appendChild(myLink);

}

function showSectorDesc(mySectorId) {

	window.open(
		'http://www.semusarealty.com/sectordesc.php?sectorId=' + mySectorId,
		'',
		'scrollbars=no,menubar=no,height=400,width=600,resizable=yes,toolbar=no,status=no'
	);

}

function getElement(elemid) {
	return (document.getElementById) ? document.getElementById(elemid) : document.all[elemid];
}

