
function SearchTop(){
	document.frmIndex.submit();
}

function checkformF(){
	if(document.frmSignup.userid.value.search(/\S/)==-1){
		alert("Por favor adicione o seu Login.");
		document.frmSignup.userid.focus();
		return false;
	}
    if(document.frmSignup.fname.value.search(/\S/)==-1){
		alert("Por favor adicione o seu primeiro nome.");
		document.frmSignup.fname.focus();
		return false;
	}
	if(document.frmSignup.lname.value.search(/\S/)==-1){
		alert("Por favor adicione o seu último nome.");
		document.frmSignup.lname.focus();
		return false;
	}
	if(document.frmSignup.address_1.value.search(/\S/)==-1){
		alert("Por favor adicione a sua morada no 1º campo.");
		document.frmSignup.address_1.focus();
		return false;
	}
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_add.value)==null){
		alert("Por favor adicione um email válido");
		document.frmSignup.email_add.focus();
		return false;
	}
	if(document.frmSignup.password.value.search(/\S/)==-1){
		alert("Por favor adicione a sua password.");
		document.frmSignup.password.focus();
		return false;
	}
	if(document.frmSignup.password_confirm.value.search(/\S/)==-1){
		alert("Por favor confirme a sua password.");
		document.frmSignup.password_confirm.focus();
		return false;
	}	
	if(document.frmSignup.password.value != document.frmSignup.password_confirm.value ){
		alert("Por favor insira a mesma password.");
		document.frmSignup.password_confirm.focus();
		return false;
	}
	if(document.frmSignup.cgender[0].checked){
		document.frmSignup.gender.value="M";
	}
	else if(document.frmSignup.cgender[1].checked){
		document.frmSignup.gender.value="F";
	}	
	if(document.frmSignup.country_id.value==""){
		alert("Por favor escolha um país.");
		document.frmSignup.country_id.focus();
		return false;
	}
	if((document.frmSignup.birth_dd.value=="") || (document.frmSignup.birth_mm.value=="") || (document.frmSignup.birth_yy.value=="")){
		alert("Por favor adicione a sua data de nascimento.");
		document.frmSignup.birth_dd.focus();
		return false;
	}
	if(document.frmSignup.country_id.value=="226" && document.frmSignup.state_id.value==""){
		alert("Por favor adicione o concelho.");
		document.frmSignup.state_id.focus();
		return false;
	}
    if(document.frmSignup.move_month.value==""){


        if(document.frmSignup.move.checked==""){
    		alert("Se não está a pensar realizar mudanças brevemente, clique na opção devida.");
    		document.frmSignup.move.focus();
    		return false;
    	}

    }
}

function checkformFEdit(){
	if(document.frmSignup.userid.value.search(/\S/)==-1){
		alert("Por favor adicione o seu Login.");
		document.frmSignup.userid.focus();
		return false;
	}
    if(document.frmSignup.fname.value.search(/\S/)==-1){
		alert("Por favor adicione o seu primeiro nome.");
		document.frmSignup.fname.focus();
		return false;
	}
	if(document.frmSignup.lname.value.search(/\S/)==-1){
		alert("Por favor adicione o seu último nome.");
		document.frmSignup.lname.focus();
		return false;
	}
	if(document.frmSignup.address_1.value.search(/\S/)==-1){
		alert("Por favor adicione a sua morada no 1º campo de morada.");
		document.frmSignup.address_1.focus();
		return false;
	}
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_add.value)==null){
		alert("Por favor adicione um email válido");
		document.frmSignup.email_add.focus();
		return false;
	}


	if(document.frmSignup.cgender[0].checked){
		document.frmSignup.gender.value="M";
	}
	else if(document.frmSignup.cgender[1].checked){
		document.frmSignup.gender.value="F";
	}	
	if(document.frmSignup.country_id.value==""){
		alert("Por favor escolha um país.");
		document.frmSignup.country_id.focus();
		return false;
	}
	if(document.frmSignup.country_id.value=="226" && document.frmSignup.state_id.value==""){
		alert("Por favor escolha um concelho.");
		document.frmSignup.state_id.focus();
		return false;
	}
    if(document.frmSignup.move_month.value==""){
        if(document.frmSignup.move.checked==""){
    		alert("Por favor se não está a pensar mudar-se brevemente, clique na opção respectiva.");
    		document.frmSignup.move.focus();
    		return false;
    	}

    }
}

function checkform(){
	if(document.frmSignup.userid.value.search(/\S/)==-1){
		alert("Por favor adicione o seu Login.");
		document.frmSignup.userid.focus();
		return false;
	}
    if(document.frmSignup.fname.value.search(/\S/)==-1){
		alert("Por favor adicione o seu primeiro nome.");
		document.frmSignup.fname.focus();
		return false;
	}
	if(document.frmSignup.lname.value.search(/\S/)==-1){
		alert("Por favor adicione o seu último nome.");
		document.frmSignup.lname.focus();
		return false;
	}
	if(document.frmSignup.address_1.value.search(/\S/)==-1){
		alert("Por favor adicione a sua morada no 1º campo de morada.");
		document.frmSignup.address_1.focus();
		return false;
	}
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_add.value)==null){
		alert("Por favor adicione um email válido");
		document.frmSignup.email_add.focus();
		return false;
	}
	if(document.frmSignup.password.value.search(/\S/)==-1){
		alert("Por favor adicione a sua password.");
		document.frmSignup.password.focus();
		return false;
	}
	if(document.frmSignup.password_confirm.value.search(/\S/)==-1){
		alert("Por favor confirma a sua password.");
		document.frmSignup.password_confirm.focus();
		return false;
	}	
	if(document.frmSignup.password.value != document.frmSignup.password_confirm.value ){
		alert("Por favor repita a mesma password.");
		document.frmSignup.password_confirm.focus();
		return false;
	}
	
	if(document.frmSignup.country_id.value==""){
		alert("Por favor escolha um país.");
		document.frmSignup.country_id.focus();
		return false;
	}
	if(document.frmSignup.country_id.value=="226" && document.frmSignup.state_id.value==""){
		alert("Por favor escolha um concelho.");
		document.frmSignup.state_id.focus();
		return false;
	}

}

function checkformEdit(){
	if(document.frmSignup.userid.value.search(/\S/)==-1){
		alert("Por favor adicione o seu Login.");
		document.frmSignup.userid.focus();
		return false;
	}
    if(document.frmSignup.fname.value.search(/\S/)==-1){
		alert("Por favor adicione o seu primeiro nome.");
		document.frmSignup.fname.focus();
		return false;
	}
	if(document.frmSignup.lname.value.search(/\S/)==-1){
		alert("Por favor adicione o seu último nome.");
		document.frmSignup.lname.focus();
		return false;
	}
	if(document.frmSignup.address_1.value.search(/\S/)==-1){
		alert("Por favor adicione a sua morada no 1º campo de morada.");
		document.frmSignup.address_1.focus();
		return false;
	}
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmSignup.email_add.value)==null){
		alert("Por favor adicione um email válido");
		document.frmSignup.email_add.focus();
		return false;
	}
	if(document.frmSignup.country_id.value==""){
		alert("Por favor escolha um país.");
		document.frmSignup.country_id.focus();
		return false;
	}
	if(document.frmSignup.country_id.value=="226" && document.frmSignup.state_id.value==""){
		alert("Por favor escolha um concelho.");
		document.frmSignup.state_id.focus();
		return false;
	}

}

function Login(){
	if(document.frmSignup.userid.value==''){
		alert("Por favor insira um login válido");
		document.frmSignup.userid.focus();
		return false;
	}
	if(	document.frmSignup.password.value.search(/\S/)==-1) {
		alert('Por favor insira uma password');
		document.frmSignup.password.focus();
		return false;
	}
	document.frmSignup.hidaction.value="login";
	document.frmSignup.submit();
}

function Search(){
	document.frmEditSearch.hidaction.value="editSearch";
	document.frmEditSearch.submit();
}
function selectcountryS(){
	document.frmEditSearch.action="edit_search.php";
	document.frmEditSearch.submit();
}


function SearchInclude(){
	document.frmSearch.submit();
}

function SearchTop(){
	document.frmTop.submit();
}

function rowsshown(){
	document.frmPage.submit();
}

function chFrmS(){
	if(	document.frmSearchList.savesearch_name.value.search(/\S/)==-1) {
		alert('Por favor insira um nome para gravar a pesquisa');
		document.frmSearchList.savesearch_name.focus();
		return false;
	}
    opener.document.frmPage.savesearch_name.value = document.frmSearchList.savesearch_name.value;
	opener.document.frmPage.hidaction.value = "SaveSearchListing";
	opener.document.frmPage.submit();
    window.close();
}  

function chFrm(){
	if(	document.frmListing.list_name.value.search(/\S/)==-1) {
		alert('Por favor insira um nome');
		document.frmListing.list_name.focus();
		return false;
	}
    opener.document.frmdetail.list_name.value = document.frmListing.list_name.value;
 opener.document.frmdetail.hidaction.value = "SaveListing";
	opener.document.frmdetail.submit();
    window.close();
}  

function checkformP(Frm){

    if(document.frmAddEdit.country_id.value==""){
		alert("Por favor escolha um país.");
		document.frmAddEdit.country_id.focus();
		return false;
	}		
	if(document.frmAddEdit.country_id.value=="226" && document.form.state_id.value==""){
		alert("Por favor escolha um concelho.");
		document.frmAddEdit.state_id.focus();
		return false;
	}
    if(document.frmAddEdit.city.value==""){
		alert("Por favor insira uma localidade.");
		document.frmAddEdit.city.focus();
		return false;
	}
	if(document.frmAddEdit.zip.value==""){
		alert("Por favor insira um Código Postal.");
		document.frmAddEdit.zip.focus();
		return false;
	}
	return true;
}
function selectcountry(){
	document.frmAddEdit.action="property_add.php";
	document.frmAddEdit.submit();
}

function change_image(num,pic,id,path){
	document.frmdetail.slide.src=path+pic;
}
function callBrochure(id){
	window.open('brochure.php?property_id='+id,'Brochure','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=630,width=565,top=10,left=10');
}
function openSaveListing(id){
	window.open('openSaveListing.php?property_id='+id,'SaveListing','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=300,width=565,top=10,left=10');
}
function openSearchListing(id){
	window.open('openSearchListing.php?property_id='+id,'SaveSearchListing','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=300,width=565,top=10,left=10');
}
function sendMail(id){
	window.open('sendMail.php?property_id='+id,'Sendmail','toolbar=0,scrollbars=1,location=no,statusbar=0,menubar=0,resizable=1,height=420,width=565,top=10,left=10');
}

function send(){
	if(	document.frmContact.fname.value.search(/\S/)==-1) {
		alert('Por favor insira um primeiro nome');
		document.frmContact.fname.focus();
		return false;
	}
	if(	document.frmContact.lname.value.search(/\S/)==-1) {
		alert('Por favor insira um último nome');
		document.frmContact.lname.focus();
		return false;
	}
	if((/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z]{2,5}$/).exec(document.frmContact.email.value)==null){
		alert("Por favor insira um email válido");
		document.frmContact.email.focus();
		return false;
	}
	document.frmContact.pageaction.value="submitform";
	document.frmContact.submit();	
}

function openWindow(obj,wd,ht){

	features = "width="+wd+",height="+ht;      
	features += ",left=10,top=10,screenX=0,screenY=0,location=no,toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no";
	webwindow=window.open(obj, 'webwindow1', features);
	if (parseInt(navigator.appVersion) >= 4) { 
		webwindow.window.focus(); 
	}
}

function notify() {
	pmbox=confirm("Aviso: Deseja realmente apagar?");
	if (pmbox==true) { // Output when OK is clicked
		return;
	} else {
	// Output when Cancel is clicked
	return false;
	}
}

function uncheckSingle(formName,field) {
	var ChckBxs = formName.elements[field];
	if(ChckBxs.length!=-1) {
		for (i = 0; i < ChckBxs.length; i++){
			if(ChckBxs[i].value=="99")
				ChckBxs[i].checked = false ;
		}
		formName.elements[field].checked = false;
	}
}
