function trim(text){
	text = text.replace(/^\s+/, "");
	text = text.replace(/\s+$/, "");
	text = text.replace(/\s+/g, " ");
	return text;
}

function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

function popupWindow(strURL){		
	window.open(strURL);
}

function checkAdminForm(objF){		
	
	var objForm = objF;
	
	if(trim(objForm.username.value).length<2){
		alert("Please enter your login username.");
		objForm.username.value = trim(objForm.username.value);
		objForm.username.focus();
		return false;
	}
	
	if(trim(objForm.password.value).length<2){
		alert("Please enter your login password.");
		objForm.password.value = trim(objForm.password.value);
		objForm.password.focus();
		return false;
	}
	
	objForm.fform.disabled = true;
	
	return true;
}

function checkArticleForm(objF){		
	
	var objForm = document.getElementById("dd");
	
	if(trim(objForm.title.value).length<2){
		alert("Please enter your article title.");
		objForm.title.value = trim(objForm.title.value);
		objForm.title.focus();
		return false;
	}
	
	if(trim(objForm.brief.value).length<2){
		alert("Please enter your article brief.");
		objForm.brief.value = trim(objForm.brief.value);
		objForm.brief.focus();
		return false;
	}
	
	if(trim(objForm.source.value).length<2){
		alert("Please enter your article source.");
		objForm.source.value = trim(objForm.source.value);
		objForm.source.focus();
		return false;
	}
	
	objForm.fform.disabled = true;
	
	return true;
}

function checkApartmentForm(){		
	
	var objForm = document.getElementById("aForm");
	
	if(trim(objForm.frm_unit_number.value).length<1){
		alert("Please enter unit number.");
		objForm.frm_unit_number.value = trim(objForm.frm_unit_number.value);
		objForm.frm_unit_number.focus();
		return false;
	}
	
	if(trim(objForm.frm_balcony.value).length<1){
		alert("Please enter balcony area.");
		objForm.frm_balcony.value = trim(objForm.frm_balcony.value);
		objForm.frm_balcony.focus();
		return false;
	}
	
	if(trim(objForm.frm_unit_area.value).length<1){
		alert("Please enter unit area.");
		objForm.frm_unit_area.value = trim(objForm.frm_unit_area.value);
		objForm.frm_unit_area.focus();
		return false;
	}
	
	if(trim(objForm.frm_total_area.value).length<1){
		alert("Please enter total area.");
		objForm.frm_total_area.value = trim(objForm.frm_total_area.value);
		objForm.frm_total_area.focus();
		return false;
	}
	
	if(trim(objForm.frm_price.value).length<1){
		alert("Please enter the apartment price.");
		objForm.frm_price.value = trim(objForm.frm_price.value);
		objForm.frm_price.focus();
		return false;
	}
	
	objForm.fform.disabled = true;
	
	return true;
}

function checkCommentForm(){		
	
	var objForm = document.getElementById("cForm");
	
	objForm.fform.disabled = true;
	
	return true;
}

function checkRegisterForm(){		
	
	var objForm = document.getElementById("registerForm");
	
	if(trim(objForm.frm_name.value).length<2){
		alert("Please enter your name.");
		objForm.frm_name.value = trim(objForm.frm_name.value);
		objForm.frm_name.focus();
		return false;
	}
	
	if(trim(objForm.frm_surname.value).length<2){
		alert("Please enter your surname.");
		objForm.frm_surname.value = trim(objForm.frm_surname.value);
		objForm.frm_surname.focus();
		return false;
	}
	
	if(trim(objForm.frm_tel.value).length<2){
		alert("Please enter your telephone number.");
		objForm.frm_tel.value = trim(objForm.frm_tel.value);
		objForm.frm_tel.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim(objForm.frm_email.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.frm_email.value = trim(objForm.frm_email.value);
		objForm.frm_email.focus();
		return false;
	}
	
	objForm.fform.disabled = true;
	
	return true;
}

function checkAgentForm(){		
	
	var objForm = document.getElementById("agentForm");
	
	if(trim(objForm.frm_agent.value).length<2){
		alert("Please enter your full name.");
		objForm.frm_agent.value = trim(objForm.frm_agent.value);
		objForm.frm_agent.focus();
		return false;
	}
	
	if(trim(objForm.frm_comments.value).length<2){
		alert("Please enter your comments.");
		objForm.frm_comments.value = trim(objForm.frm_comments.value);
		objForm.frm_comments.focus();
		return false;
	}
	
	objForm.fform.disabled = true;
	
	return true;
}

function checkSaleForm(){		
	
	var objForm = document.getElementById("aForm");
	
	objForm.fform.disabled = true;
	
	return true;
}


function checkCompForm(){		
	
	var objForm = document.getElementById("compForm");
	
	if(trim(objForm.words.value).length<2){
		alert("Please enter your 4 word answer.");
		objForm.words.value = trim(objForm.words.value);
		objForm.words.focus();
		return false;
	}
	
	if(trim(objForm.name.value).length<2){
		alert("Please enter your name.");
		objForm.name.value = trim(objForm.name.value);
		objForm.name.focus();
		return false;
	}
	
	if(trim(objForm.number.value).length<2){
		alert("Please enter your contact number.");
		objForm.number.value = trim(objForm.number.value);
		objForm.number.focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim(objForm.email.value)))){
		alert("Please enter a valid email address for yourself.");
		objForm.email.value = trim(objForm.email.value);
		objForm.email.focus();
		return false;
	}
	
	objForm.fform.disabled = true;
	
	return true;
}

function tbox(objR){

	var objForm = document.getElementById("compForm");

	if(objR.checked){objForm.fform.disabled=false;}else{objForm.fform.disabled=true;}
}




