function ischeck(){ 
	var cpvalue = document.getElementById('cpvalue').value;
	var imgvalue = document.getElementById('cpcode').value;
	
	if(isEmpty('myform','fname','First Name')==false){
		return false;
	}
	if(isEmpty('myform','lname','Last Name')==false){
		return false;
	}
	if(isEmail('myform','email','Email')==false){
		return false;
	}
	if(isEmpty('myform','phonetxt','Phone')==false){
		return false;
	}
	
	if(isEmpty('myform','cpvalue','Image verification code')==false){
		return false;
	}
	
	if(cpvalue != imgvalue){
		alert("This is not a valid verification code !!");
		return false;
	}
}

function _doDidyou(city,state){
	window.location.href = "searchBymap.php?city="+city+"&state="+state+"&view=List";
}

function show(){
	var ss= document.getElementById('cst_text');
	var len= ss.options.length;
	var str="";
	for(var i=0;i<len;i++){
		if(ss.options[i].selected == true)
		{
			str+= ss.options[i].innerHTML+"<br>";		
		}
	}
	document.getElementById('hidedata').value = str;
	document.getElementById('displayTxt').innerHTML = "";
	document.getElementById('displayTxt').innerHTML = str;
}

function _displayblockAdvSearch(){
	document.getElementById('inline_Block').style.display = 'inline';
	document.getElementById('searchbtn_BoxMargin').style.display = 'none';
	document.getElementById('orBoxs').style.display = 'none';
	document.getElementById('inlinefooter').className = 's_left-footerbig';	
	document.getElementById('searchbtn_BoxMarginEX').style.display = 'inline';
}


function AdvSearchSubmit(){
/*
	var price = document.getElementById('price').value;
	var to_price = document.getElementById('to_price').value;
	
	if(price > 0 && to_price > 0){
		if(to_price <= price){
			alert("To price always grater then price !!");
			return false;
		}
	}
	
	if(price == "" && to_price != "" && price <= to_price){
		alert("Price should not be empty or grater then to price");
		return false;
	}
*/
}

function foreclosure_submit(){
	var cpvalue = document.getElementById('cpvalue').value;
	var imgvalue = document.getElementById('cpcode').value;
	
	if(isEmpty('myform','thisname','Name')==false){
		return false;
	}

	if(isEmail('myform','email','Email')==false){
		return false;
	}

	if(isEmpty('myform','address','Address')==false){
		return false;
	}

	if(isEmpty('myform','content_text','content_text')==false){
		return false;
	}
	
	if(isEmpty('myform','cpvalue','Image verification code')==false){
		return false;
	}
	
	if(cpvalue != imgvalue){
		alert("This is not a valid verification code !!");
		return false;
	}
}

function registration_submit(){
	var cpvalue = document.getElementById('cpvalue').value;
	var imgvalue = document.getElementById('cpcode').value;
	
	if(isEmpty('myform','uname','User Name')==false){
		return false;
	}

	if(isEmpty('myform','password','password')==false){
		return false;
	}

	if(isEmpty('myform','cpassword','Confirm password')==false){
		return false;
	}

	if(isEmpty('myform','fname','First Name')==false){
		return false;
	}
	
	if(isEmpty('myform','lname','Last Name')==false){
		return false;
	}

	if(isEmpty('myform','address','Street Address')==false){
		return false;
	}

	if(isEmpty('myform','country','Country')==false){
		return false;
	}

	if(isEmpty('myform','states','State')==false){
		return false;
	}

	if(isEmpty('myform','citys','City')==false){
		return false;
	}

	if(isEmpty('myform','zip','Zip')==false){
		return false;
	}

	if(isEmail('myform','email','Email')==false){
		return false;
	}
	
	if(isEmpty('myform','phone','Phone')==false){
		return false;
	}
	
	if(isEmpty('myform','cpvalue','Image verification code')==false){
		return false;
	}
	
	if(cpvalue != imgvalue){
		alert("This is not a valid verification code !!");
		return false;
	}
	
}

function editProfile_submit(){
	

	if(isEmpty('myform','fname','First Name')==false){
		return false;
	}
	
	if(isEmpty('myform','lname','Last Name')==false){
		return false;
	}

	if(isEmpty('myform','address','Street Address')==false){
		return false;
	}

	if(isEmpty('myform','country','Country')==false){
		return false;
	}

	if(isEmpty('myform','states','State')==false){
		return false;
	}

	if(isEmpty('myform','citys','City')==false){
		return false;
	}

	if(isEmpty('myform','zip','Zip')==false){
		return false;
	}

	if(isEmail('myform','email','Email')==false){
		return false;
	}
	
	if(isEmpty('myform','phone','Phone')==false){
		return false;
	}
	
}

function changeImage(ImageName){
		document.getElementById('bigImage').src = ImageName;
}


function isRequest(){
	var cpvalue = document.getElementById('cpvalue').value;
	var imgvalue = document.getElementById('cpcode').value;
	
	if(isEmpty('myform','names','Name')==false){
		return false;
	}
	/*if(isEmpty('myform','phone','Phone')==false){
		return false;
	}*/
	if(isEmail('myform','email','Email')==false){
		return false;
	}
	if(isEmpty('myform','content_text','Comments')==false){
		return false;
	}
	if(isEmpty('myform','cpvalue','Image verification code')==false){
		return false;
	}
	
	if(cpvalue != imgvalue){
		alert("This is not a valid verification code !!");
		return false;
	}
}

// For property popup

function DIVshow(div_id,property_id)
	{
		// close any open windows
		closePopUps();
		var popUp = document.getElementById(div_id);
		popUp.style.visibility = "visible";
		var inputs = popUp.getElementsByTagName("input");
		inputs[0].value = property_id;
	}

	function DIVhide(div_id)
	{
		var popUp = document.getElementById(div_id);
		popUp.style.visibility = "hidden";
	}

	function closePopUps()
	{
		document.getElementById("showing_popup").style.visibility = "hidden";		
		document.getElementById("email_popup").style.visibility = "hidden";
		document.getElementById("more_info_popup").style.visibility = "hidden";		
	}

// End property popup

// For favorite pop up

function DIVshowF(div_id,property_id)
	{
		// close any open windows 
		closePopUps();
		var popUp = document.getElementById(div_id);
		popUp.style.visibility = "visible";
		var inputs = popUp.getElementsByTagName("input");
		inputs[0].value = property_id;
	}

	function DIVhide(div_id)
	{
		var popUp = document.getElementById(div_id);
		popUp.style.visibility = "hidden";
	}

	function closePopUps()
	{
		document.getElementById("showing_popup").style.visibility = "hidden";
		//document.getElementById("email_popup").style.visibility = "hidden";
			
	}

// End for favorite popup


function scheduling_showing(){	
	var cpvalue_scheduling = document.getElementById('cpvalue_scheduling').value;
	var cpcode_scheduling = document.getElementById('cpcode_scheduling').value;
	
	if(isEmpty('showing','names','Name')==false){
		return false;
	}
	if(isEmail('showing','email','Email')==false){
		return false;
	}	
	/*if(isEmpty('showing','phone','Phone')==false){
		return false;
	}*/	
	
	if(isEmpty('showing','cpvalue_scheduling','Image verification code')==false){
		return false;
	}
	
	if(cpvalue_scheduling != cpcode_scheduling){
		alert("This is not a valid verification code !!");
		return false;
	}
}

function emailToFriend(){
	var cpvalue_tofriend = document.getElementById('cpvalue_tofriend').value;
	var cpcode_tofriend = document.getElementById('cpcode_tofriend').value;
	
	if(isEmpty('tofriend','names','Your Name')==false){
		return false;
	}
	if(isEmail('tofriend','yemail','Your Email')==false){
		return false;
	}	
	if(isEmpty('tofriend','fname','Friend Name')==false){
		return false;
	}
	if(isEmail('tofriend','femail','Friend Email')==false){
		return false;
	}	
	
	if(isEmpty('tofriend','cpvalue_tofriend','Image verification code')==false){
		return false;
	}
	
	if(cpvalue_tofriend != cpcode_tofriend){
		alert("This is not a valid verification code !!");
		return false;
	}
}

function emailListing(formaName){
	var cpvalue_tofriend = eval("window.document."+formaName+".cpvalue_tofriend.value");	
	var cpcode_tofriend = eval("window.document."+formaName+".cpcode_tofriend.value");
			
	if(isEmpty(formaName,'names','From Name')==false){
		return false;
	}
	if(isEmail(formaName,'yemail','From Email')==false){
		return false;
	}	
	if(isEmpty(formaName,'fname','To Name')==false){
		return false;
	}
	if(isEmail(formaName,'femail','To Email')==false){
		return false;
	}	
	
	if(isEmpty(formaName,'cpvalue_tofriend','Image verification code')==false){
		return false;
	}
	
	if(cpvalue_tofriend != cpcode_tofriend){
		alert("This is not a valid verification code !!");
		return false;
	}
}

function moreInfo(){
	var cpvalue_more_info = document.getElementById('cpvalue_more_info').value;
	var cpcode_more_info = document.getElementById('cpcode_more_info').value;
	
	if(isEmpty('more_info','names','Name')==false){
		return false;
	}
	if(isEmail('more_info','email','Email')==false){
		return false;
	}	
	/*if(isEmpty('more_info','phone','Phone')==false){
		return false;
	}*/
	
	if(isEmpty('more_info','cpvalue_more_info','Image verification code')==false){
		return false;
	}
	
	if(cpvalue_more_info != cpcode_more_info){
		alert("This is not a valid verification code !!");
		return false;
	}
}
   
function _clearbox(){
	document.getElementById("mainAddress").value = "";
}

function _checkUser(){
	if(isEmpty('frm','userName','User Name')==false){
		return false;
	}
	if(isEmpty('frm','pws','Password')==false){
		return false;
	}
}

function _docap(c){
	alert(c);
}

function _clear(id){	
	var box_value = document.getElementById(id).value;
	if(box_value == "Enter text above here"){
		document.getElementById(id).value = "";
		document.getElementById(id).focus();		
	}
}

function _clearInform(formaName){	
	var box_value = eval("window.document."+formaName+".cpvalue_tofriend.value");
	if(box_value == "Enter text above here"){
		eval("window.document."+formaName+".cpvalue_tofriend.value=''");
		eval("window.document."+formaName+".cpvalue_tofriend.focus()");		
	}
}


// For us phone -----------------------------------------------------------------------------------------------------------
var p1;	//conversion phone number
var p2; //conversion phone text
var mask="()-"; //this is what phone numbers look like
var oldvalue=""; //the last thing in phonetxt
function ValidatePhone(id){

	p1= window.document.getElementById(id).value;	
	if (p1.length > oldvalue.length)	
		{
			p1=p1.replace("(","");
			p1=p1.replace(")","");
			p1=p1.replace("-","");
			while (p1.search(" ") != -1)
			{
					p1=p1.replace(" ","");
			}
			
		window.document.getElementById(id).value = p1;
		if (p1.length < 4)
			{
				p2=mask.substring(p1.length + 1,13);
				window.document.getElementById(id).value="(" + p1 + p2;
				} else {
					if (p1.length < 7)
						{
							p2=mask.substring(p1.length + 2,13);
							window.document.getElementById(id).value="(" + p1.substring(0,3) + ")" + p1.substring(3,6) + p2;	
							} else {
								p2=mask.substring(p1.length + 3,13)
								window.document.getElementById(id).value="(" + p1.substring(0,3) + ")" + p1.substring(3,6) + "-" + p1.substring(6,10) + p2;
							}
						}
					}
					oldvalue=window.document.getElementById(id).value;
	}
	
	
function Filter4Characters(evt) {
 if(navigator.appName.indexOf('Microsoft')!=-1) {
	  if(event.keyCode < 46 || event.keyCode > 57) {
	   event.returnValue = false;
	  }
 }else{
  var charCode = (evt.which) ? evt.which : event.keyCode
  if (charCode > 31 && (charCode < 48 || charCode > 57))
	return false;

  return true;

}
}
