// JavaScript Document
function isEmpty(Field, Msg)
{
	if(Field.value == ""){
		alert(Msg)
		Field.focus()
		return true
	}
	return false
}
function isNotSame(Field1, Field2, Msg)
{
	if(Field1.value != Field2.value)
	{
		alert(Msg)
		Field1.focus()
		return true
	}
	return false
}
function isNotValidEmail(Email, Msg)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   	if(reg.test(Email.value) == false) 
	{
      	alert(Msg)
		Email.focus()
      	return true
	}
	return false
}

function isNotNo(Field, Msg)
{
	if(isNaN(Field.value))
	{
		alert(Msg)
		Field.focus()
		return true
	}
	return false
}
function isInvalidLength(Field, Length, Msg)
{
	if(eval(Field.value.length) > eval(Length))
	{
			alert(Msg)
			Field.focus()
			return true
	}
	return false
}
	  
function Clear(Form)
{
	Form.reset
	return false
}

function isNotValidCharacters(Sec)
{
	if(! ( Sec.value == "JK904" || Sec.value == "jk904" || Sec.value == "Jk904" || Sec.value == "jK904") ) 
	{
		alert('The security code you entered was invalid.  Please try again')
		Sec.focus()
		return true 
	}	
	return false
}
/************************************************************/
function ValidateEmpty(Field, ID)
{
	var Msg = document.getElementById(ID)
	if(Field.value == "")
	{
		Msg.className = "ShowError4EmptyTextField"
		return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}
function ValidateEmail(Email, ID)
{
	var Msg = document.getElementById(ID)
	if(Email.value == "")
	{
		Msg.className = "ShowError4EmptyTextField"
		return false
	}
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   	if(reg.test(Email.value) == false) 
	{
	    Msg.className = "ShowError4EmptyTextField"
      	return false
	}
	else
	{
		
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}

function MatchPasswords(Pass1, Pass2, ID)
{
	var Msg = document.getElementById(ID)
	if(Pass1.value != Pass2.value)
	{
		Msg.className = "ShowError4EmptyTextField"
		return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}

function MatchEmails(Email1, Email2, ID)
{
	var Msg = document.getElementById(ID)
	if(Email1.value != Email2.value)
	{
		Msg.className = "ShowError4EmptyTextField"
		return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}

function MatchFields(Field1, Field2, ID)
{
	var Msg = document.getElementById(ID)
	if(Field1.value != Field2.value)
	{
		Msg.className = "ShowError4EmptyTextField"
		return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}

function picvalidate(test,alttext)
{
var text=test.value;
var Temp = text.split('.');
	if(Temp[1]=='swf'||Temp[1]=='bmp'||Temp[1]=='jpg'||Temp[1]=='jpeg'||Temp[1]=='fpx'||Temp[1]=='ico'||Temp[1]=='img'||Temp[1]=='jp2'||Temp[1]=='jpc'||Temp[1]=='j2k'||Temp[1]=='jpf'||Temp[1]=='jpe'||Temp[1]=='jpm'||Temp[1]=='pbm'||Temp[1]=='psd'||Temp[1]=='psp'||Temp[1]=='tja'||Temp[1]=='tif'||Temp[1]=='tiff'||Temp[1]=='wbmp'||Temp[1]=='wap')
	{
	return false;
	}
	else
	{
		alert(alttext);
		test.focus();
		return true;
	}
}

function validateListing1(form)
{
	if(isEmpty(form.resale, "Please Enter Property new or resale")) return false
	if(isEmpty(form.cat, "Please Enter Category")) return false
	
	if(isEmpty(form.address, "Please Enter Address")) return false
	//if(isNotValidEmail(form.email, "Please Enter Valid Email")) return false
	if(isEmpty(form.city, "Please Enter City")) return false

	if(isEmpty(form.state, "Please Enter State")) return false
	if(isEmpty(form.country, "Please Enter Country")) return false
	
	if(isEmpty(form.beds, "Please Enter Number Of Beds")) return false
	if(isEmpty(form.area, "Please Enter Square Foot of Area")) return false
	if(isEmpty(form.mls, "Please Enter MLS")) return false
	if(isEmpty(form.ptype, "Please Enter Property Type")) return false
	if(isEmpty(form.title, "Please Enter Title")) return false
	if(isEmpty(form.links, "Please Enter Link")) return false
	if(isEmpty(form.location, "Please Enter Location")) return false
	if(isEmpty(form.price, "Please Enter Price")) return false
	if(isEmpty(form.aname, "Please Enter Agent Name")) return false
	if(isEmpty(form.aoffice, "Please Enter Agent Office")) return false
	if(isEmpty(form.bdescription, "Please Enter Brief Description")) return false
	if(isEmpty(form.fdescription, "Please Enter Full Description")) return false
	return false
	}
	
