/*************************************************REUSABLE FUNCTIONS STARTS********************************************************/

/***********HELP : STARTS**************
FUNCTION NAME : Trim -> To trim the values entered in text box(it will call the LTrim and RTrim functions inside automatically.
FUNCTION NAME : CharAndSpace -> This function will allow only character and space not digits(use for city, relation textbox).
FUNCTION NAME : DigitsAndDot -> This function will allow only Digits and Dot not characters(use for price textbox).
FUNCTION NAME : DigitsOnly -> This function will allow only Digits and not characters even dot also.
FUNCTION NAME : telephoneno -> This function will allow only Digits, +, and -(for eg. telephone no: IN +91  2221113456  Call ).
FUNCTION NAME : GetMonthDays -> This function will will return number of days in the current month.
FUNCTION NAME : GetDays -> This function will will returns the diff betn two dates for month 1=jan,12=Dec
FUNCTION NAME : isNumeric,isInteger -> This function will Checks the number is integer or not.
FUNCTION NAME : daysInFebruary -> This function will checks the posted date is valid or not.
FUNCTION NAME : isDate -> This function will Checks the febraury month.
FUNCTION NAME : closewindow -> This function will Close the window.
FUNCTION NAME : checkimage -> This function will checks the entered image is in .jpg,.gif,.jpeg,.png formot or not.
FUNCTION NAME : backToMain -> This function will redirect to specifie file.
FUNCTION NAME : ageValidate -> This function will to checks age the user's age.
FUNCTION NAME : ValidateDateAfter -> This function will to checks the date after some days.
FUNCTION NAME : SameOrAfterDate -> This function will to checks the date or after some days.
FUNCTION NAME : NotFutureDate -> This function will to checks whether the date is future date or not.
FUNCTION NAME : checkEmail -> This function will to checks for valid email-id.
FUNCTION NAME : selectall -> This function will check and uncheck the checkbox.
FUNCTION NAME : atleastone -> This function will Ask conformation before doing ant task like make active, inactive,delete operations.

/***********HELP : ENDS**************/
//Coding to not to show..
function noError(){return true;}
window.onerror = noError;

function bookmark(address,sitename)
{
	if (window.sidebar)
	{
		window.sidebar.addPanel(sitename, address,"");
	}
	else if( document.all )
	{
		window.external.AddFavorite(address, sitename);
	}
	else if( window.opera && window.print )
	{
		return true;
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

window.onLoad="MM_preloadImages('images/home_up.jpg','images/company_up.jpg','images/tech_up.jpg','images/prod_up.jpg','images/partner_up.jpg','images/news_up.jpg','images/forums_up.jpg','images/investor_up.jpg')"


//General funtion to prevent the JS error...
function xerr()
{
     return(true);
}
onerror=xerr;

//  Trim functions...
function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;

	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While

	return strTemp;
} //End Function

//Function for field name that only allowed Character and Space not Digits...
function CharAndSpace(FieldName)
{
	if(FieldName.value != "")
	{
		var ValidChar = "0123456789~`!@#$%^&*()_+|\\=-][{}:';?><,./'";
		var ValidChars = ValidChar+'"';
		for (j = 0; j < FieldName.value.length; j++)
		{
			var Char = FieldName.value.charAt(j);
			if (ValidChars.indexOf(Char) != -1)
			{
				return  false;
			}
		}
		return true;
	}
}

//Function for field name that only allowed Digits and Dot...
function DigitsAndDot(FieldName)
{
	if(FieldName.value != "")
	{
		var ValidChars = "0123456789.";
		for (j = 0; j < FieldName.value.length; j++)
		{
			var Char = FieldName.value.charAt(j);
			if (ValidChars.indexOf(Char) == -1)
			{
				return  false;
			}
		}
		return true;
	}
}

//Function for field name that only allowed Digits...
function DigitsOnly(FieldName)
{
	if(FieldName.value != '')
	{
		var ValidChars = "0123456789";
		for (j = 0; j < FieldName.value.length; j++)
		{
			var Char = FieldName.value.charAt(j);
			if (ValidChars.indexOf(Char) == -1)
			{
				return  false;
			}
		}
	}
}

//Function for field name that only allowed Digits, +, and -(for eg. telephone no: IN +91  2221113456  Call )...
function telephoneno(FieldName)
{
	if(FieldName.value != "")
	{
		var ValidChars = "0123456789-+  ";
		for (j = 0; j < FieldName.value.length; j++)
		{
			var Char = FieldName.value.charAt(j);
			if (ValidChars.indexOf(Char) == -1)
			{
				return  false;
			}
		}
		return true;
	}
}

/* the function GetMonthDays will return number of days in the current month. */
function GetMonthDays()
{
	DateObj = new Date();
	var CurYear=DateObj.getMonth();
	var FebDays=28;

	if(CurYear%4==1)
	{
		FebDays=29;
	}

	days= new Array(31,FebDays,31,30,31,30,31,31,30,31,30,31);
	return days;
}

//returns the diff betn two dates for month 1=jan,12=Dec
function GetDays(toyear, tomonth, today, fromyear, frommonth, fromday)
{
	DDate= new Date(toyear,tomonth-1,today);
	NDate=	new Date(fromyear,frommonth-1,fromday);

	var Days = new String((NDate-DDate)/86400000);

	return Math.floor(Days);
}

//Check the number is integer or not...
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.-";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++)
   {
      Char = sText.charAt(i);
      if(ValidChars.indexOf(Char) == -1)
      {
         IsNumber = false;
      }
   }
   return IsNumber;
}

//Check the febraury month...
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   }
   return this;
}

//check the posted date is valid or not...
function isDate(dtStr)
{
	var daysInotifymonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("-The date format should be : mm/dd/yyyy.");
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("-Please enter a valid month.");
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInotifymonth[month]){
		alert("-Please enter a valid day.");
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minotifyyear || year>maxYear){
		alert("-Please enter a valid 4 digit year between "+minotifyyear+" and "+maxYear+".");
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("-Please enter a valid date.");
		return false;
	}
return true;
}

//Close the window
function closewindow()
{
	window.close();
}

//Function to check the entered image is in .jpg,.gif,.jpeg,.png formot or not...
function checkimage(formname,fieldname)
{
	if(eval("document."+formname+"."+fieldname+".value") != '')
	{
		imagename=eval("document."+formname+"."+fieldname+".value");
		splitimagename	= imagename.split(".");
		imagenamelen   	= splitimagename.length;
		imageextention	= splitimagename[imagenamelen-1];

                if((imageextention != 'jpg') & (imageextention != 'JPG') & (imageextention != 'gif') & (imageextention != 'jpeg') & (imageextention != 'png'))
		{
			alert("-Please Upload Proper Image.\nAccept image format:\n.gif\n.jpeg\n.jpg\n.png.");
			return false;
		}
	}
	return true;
}

//Function to check the entered image is in .jpg,.gif,.jpeg,.png formot or not...
function checkfile(formname,fieldname)
{
	if(eval("document."+formname+"."+fieldname+".value") != '')
	{
		imagename=eval("document."+formname+"."+fieldname+".value");
		splitimagename	= imagename.split(".");
		imagenamelen   	= splitimagename.length;
		imageextention	= splitimagename[imagenamelen-1];

                if((imageextention != 'jpg') & (imageextention != 'JPG') & (imageextention != 'gif') & (imageextention != 'jpeg') & (imageextention != 'png') & (imageextention != 'pdf') & (imageextention != 'doc') & (imageextention != 'txt') & (imageextention != 'mp3'))
		{
			alert("-Please Upload Proper Image.\nAccept image format:\n.gif\n.jpeg\n.jpg\n.png\n.pdf\n.doc\n.txt\.mp3.");
			return false;
		}
	}
	return true;
}

//Common function to redirect....
function backToMain(frm)
{
	with(frm)
	{
		document.location	=	module_name.value;
	}
}

//This function is using for to check age the user's age */
function ageValidate()
{
	var d= new Date();
	var cyear = d.getFullYear();

	var chkage = 0;

	with(document.complateapp)
	{
		if(isDate(month.value+"/"+day.value+"/"+year.value))
		{
			chkage = displayage(year.value, month.value, day.value);//cyear - main_age.value; //Age validation
			//alert(chkage);
			//if((year.value != chkage) && ((year.value < (chkage - 1)) || (year.value > (chkage + 1))))
			if(main_age.value != chkage && age_valid_status.value != 1)
			{
				alert("-The Age calculated from the Date of Birth just entered doesn't match that entered when asking for a quotation.");
				age_valid_status.value = 1;
				day.focus();
				return false;
			}
		}
		else
		{
			day.focus();
			return false;
		}
	}
}

//The function ValidateDateAfter() checks the cancellation date.
function ValidateDateAfter(year, month, day, startyear, startmonth, startday)
{
	if( parseInt(year.value) < parseInt(startyear.value))
	{
		//alert(year.value+" "+startyear.value);
		return false;
	}        //        End of if year.
	else if(parseInt(year.value) == parseInt(startyear.value))
	{
		//alert(month.value+" "+startmonth.value);

		if(parseInt(month.value) < parseInt(startmonth.value))
		{
			//alert(month.value+" "+startmonth.value);
			return false;
		}        //        End of if month.
		else if(parseInt(month.value) == parseInt(startmonth.value))
		{
			if(parseInt(day.value) < parseInt(startday.value))
			{
				//alert(day.value+" "+startday.value);
				return false;
			}        //        End of if day.
			else
			{return true;}
		}        //        End of if month.
		else
		{return true;}
	}        //        End of else if month.
	else
	{
		return true;
	}        //        End of else.
}       //        End of function.

//The function SameOrAfterDate() checks the authorization date and notification date.
function SameOrAfterDate(authyear, authmonth, authday, notifyyear, notifymonth, notifyday)
{

	//        Check for authorization date.
	if( parseInt(authyear.value) > parseInt(notifyyear.value))
	{
		//alert("-Date of notification must be a date after the Policy Start Date.");
		return true;
	}        //        End of if year.
	else if(parseInt(authyear.value) == parseInt(notifyyear.value))
	{
		//alert("compare"+month.value+" "+startmonth.value);

		if(parseInt(authmonth.value) > parseInt(notifymonth.value))
		{
			//alert("-Date of notification must be a date after the Policy Start Date.");
			return true;
		}        //        End of if month.
		else if(parseInt(authmonth.value) == parseInt(notifymonth.value))
		{
			if(parseInt(authday.value) >= parseInt(notifyday.value))
			{
				//alert("-Date of notification must be a date after the Policy Start Date.");
				return true;
			}        //        End of if day.
			else
			{return false;}
		}        //        End of if month.
		else
		{return false;}
	}        //        End of else if month.
	else
	{
		return false;
	}        //        End of else.
}       //        End of function.

//The function NotFutureDate(...) checks if the entered date is not a future date.
function NotFutureDate(year, month, day)
{
	// Get Current Date in variables.
	dateobj = new Date();
	yearobj = dateobj.getFullYear();
	monthobj= dateobj.getMonth()+1;
	dayobj  = dateobj.getDate();

	// Compare if entered year is a future year.
	if(year > parseInt(yearobj))
	{
		return false;
	}
	else if(year == parseInt(yearobj)) // if current year.
	{
		// Compare if entered month is a future month.
		if(month > parseInt(monthobj))
		{
			return false;
		}
		else if(month == parseInt(monthobj)) // current month.
		{
			// Compare if entered date is not a future date.
			if(day > parseInt(dayobj))
			{
				return false;
			}
			else { return true; }
		}
		else { return true; }
	}
	else { return true; }
}

//check email validation
function checkEmail(email)
{
	if(email != ""){
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{
			return true;
		}
		alert("-Invalid E-Mail address! please re-enter.")
		return false;
	}else{
		alert("-Please enter E-Mail address.")
		return false;
	}
}

//Function to open popup...
function openpopup(url,popup_name,height,width,other_properties)
{
	var left		= parseInt((screen.width-350)/2);
	var top			= parseInt((screen.height-300)/2)
	var win_options = 'height='+height+',width='+width+',resizable=no,'
	+ 'scrollbars=1,left=' + left + ',top=' + top;
	window.open(url,popup_name,win_options);
}

//Function to open popup...
function openprintpopup(url,popup_name,height,width,other_properties)
{
	var left		= parseInt((screen.width-350)/2);
	var top			= parseInt((screen.height-300)/2)
	var win_options = 'height='+height+',width='+width+',resizable=no,'
	+ 'scrollbars=1,left=' + left + ',top=' + top;
	window.open(url,popup_name,win_options);
}

//Function to check and uncheck the checkbox...
function selectall(ids,frmname)
{
	var id=ids
	var fname= frmname
	var f1=document.fname.check;
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}
	}else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}

	}
}

//Ask conformation before doing ant task like make active, inactive,delete operations...
function atleastone(frm)
{
	with(frm)
	{
		var count = check.length;
		var i;
		for(i=0; i<count; i++)
		{
			if(check[i].checked)
			{
				var confirmation = confirm("-Do you want to do this operation.");
				if(confirmation) { return true; } else { return false; }
			}
		}
		alert('-Please select atleast one.');
		return false;
	}
}

//AJAX General Function...Check the browser compactibility...
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

//check email ids to your friends
function checkEmailsent(email)
{
	if(email != ""){
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{
			return true;
		}
		alert("-Invalid E-Mail address! Please re-enter.")
		return false;
	}else{
		alert("-Please enter your friend E-Mail address.")
		return false;
	}
}

//check email ids to of admin...
function checkEmailadmin(email)
{
	if(email != ""){
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		{
			return true;
		}
		alert("-Invalid E-Mail address! Please re-enter.");
		return false;
	}else{
		alert("-Please enter E-Mail address.");
		return false;
	}
}

//By clicking on Active, Inactive, Delete button...
function anyone(frm,message)
{
	with(frm)
	{
		var count = check.length;
		var i;
		for(i=0; i < count; i++)
		{
			if(check[i].checked)
			{
				var confirmation = confirm("-Do you want to do this operation.");
				if(confirmation) { return true; } else { return false; }
			}
		}
		alert("-Please select atleast one "+message+".");
		return false;
	}
}
/*************************************************REUSABLE FUNCTIONS ENDS********************************************************/

//To select all colums in Agent management...
function SelectAllAgent(ids)
{
	var id=ids;
	var f1=document.frmusers.check;
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in Event management...
function SelectAllEvents(ids)
{
	var id=ids;
	var f1=document.frmevents.check;
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in Property management...
function SelectAllProp(ids)
{
	var id=ids;
	var f1=document.frmprop.check;
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//To select all colums in Property add management...
function SelectAllAgentProp(ids)
{
	var id=ids;
	var f1=document.frmaddprop.check;
	if(id==1)
	{
			for(i=0;i<=f1.length;i++)
			{
			   f1[i].checked=true;
			}
	}
	else
	{
			for(i=0;i<=f1.length;i++)
			{
				f1[i].checked=false;
			}
	}
}

//Validate admin change password...
function chpassadminValidate(frm)
{
	with(frm)
	{
		if(Trim(opwd.value) == '')
		{
			alert("-Please enter your old password.");
			opwd.focus();
			return false;
		}
		if(opwd.value.length<6)
		{
			alert("-Password must be six character length.");
			opwd.focus();
			return false;
		}
		if(Trim(npwd.value) == '')
		{
			alert("-Please enter your new password.");
			npwd.focus();
			return false;
		}
		if(npwd.value.length<6)
		{
			alert("-Password must be six character length.");
			npwd.focus();
			return false;
		}
		if(Trim(rpwd.value) == '')
		{
			alert("-Please re-enter your new password.");
			rpwd.focus();
			return false;
		}
		if(rpwd.value.length<6)
		{
			alert("-Password must be six character length.");
			rpwd.focus();
			return false;
		}
		if(Trim(npwd.value) != Trim(rpwd.value))
		{
			alert("-Incorrect new password.");
			rpwd.value='';
			rpwd.focus();
			return false;
		}
	}
	return true;
}
//Function to validate add agent
function validateAddAgent(frm)
{
	with(frm)
	{
		if(Trim(fname.value) == '')
		{
			alert("-Please enter the firstname.");
			fname.focus();
			return false;
		}

		if(Trim(lname.value) == '')
		{
			alert("-Please enter the lastname.");
			lname.focus();
			return false;
		}

		if(Trim(desc.value) == '')
		{
			alert("-Please enter the description.");
			desc.focus();
			return false;
		}

		if(Trim(spec.value) == '')
		{
			alert("-Please enter the specification.");
			spec.focus();
			return false;
		}

		if(!checkEmail(email.value))
		{
			email.focus();
			return false;
		}

		if(Trim(phone.value) == "")
		{
			alert("-Please enter your contact phone number.");
			phone.focus();
			return false;
		}
		else if(!IsNumeric(phone.value))
		{
			alert("-Phone number should be only numeric.");
			phone.focus();
			return false;
		}

        if((Trim(phone.value) != "") && (phone.value.length < 12))
		{
			alert("-Phone number should be 12 digits");
			phone.focus();
			return false;
		}

		if(Trim(fax.value) != "")
		{
			if(!IsNumeric(fax.value))
			{
				alert("-Fax number should be only numeric.");
				fax.focus();
				return false;
			}
		}

		if(Trim(vmail.value) != "")
		{
			if(!IsNumeric(vmail.value))
			{
				alert("-Voic mail number should be only numeric.");
				fax.focus();
				return false;
			}
		}

		if(Trim(website.value!=''))
		{
			if((Trim(website.value) == '') || (Trim(website.value) == "http://") || (Trim(website.value) == "https://") || (website.value.length < 9))
			{
				alert('-Website should not be empty or invalid.');
				website.focus();
				return false;
			}
		}

		if(photo.value != '')
		{
			if(!checkimage('frmadduser','photo'))
			{
				return false;
			}
		}
	}
	return true;
}

//Function to validate add property
function validateProperty(frm)
{
	with(frm)
	{
		if(Trim(address1.value) == '')
		{
			alert("-Please enter the address1.");
			address1.focus();
			return false;
		}
		if(Trim(address2.value) == '')
		{
			alert("-Please enter the address2.");
			address2.focus();
			return false;
		}
		/*if(Trim(country.value) == 0)
		{
			alert("-Please select the type.");
			country.focus();
			return false;
		}*/

		if(Trim(type.value) == 0)
		{
			alert("-Please select the type.");
			type.focus();
			return false;
		}
		if(Trim(price.value) == '')
		{
			alert("-Please enter the price.");
			price.focus();
			return false;
		}
		if(Trim(bedrooms.value) != "")
		{
			if(!IsNumeric(bedrooms.value))
			{
				alert("-No. of bed rooms should be only numeric.");
				bedrooms.focus();
				return false;
			}
		}
		if(Trim(bathrooms.value) != "")
		{
			if(!IsNumeric(bathrooms.value))
			{
				alert("-No. of bath rooms should be only numeric.");
				bathrooms.focus();
				return false;
			}
		}

		if(Trim(pdesc.value) == '')
		{
			alert("-Please enter the desription.");
			pdesc.focus();
			return false;
		}
		if(propertyphoto.value != '')
		{
			if(!checkimage('frmadduser','propertyphoto'))
			{
				return false;
			}
		}
	}
	return true;
}
//Function to validate add Agent property
function validateAgentProperty(frm)
{
	with(frm)
	{
		if(agentid.value == 0)
		{
			alert("-Please select the Agent to assign this property.");
			agentid.focus();
			return false;
		}
		if(Trim(address1.value) == '')
		{
			alert("-Please enter the address1.");
			address1.focus();
			return false;
		}
		if(Trim(address2.value) == '')
		{
			alert("-Please enter the address2.");
			address2.focus();
			return false;
		}

		if(Trim(type.value) == 0)
		{
			alert("-Please select the type.");
			type.focus();
			return false;
		}
		if(Trim(price.value) == '')
		{
			alert("-Please enter the price.");
			price.focus();
			return false;
		}
		if(Trim(bedrooms.value) != "")
		{
			if(!IsNumeric(bedrooms.value))
			{
				alert("-No. of bed rooms should be only numeric.");
				bedrooms.focus();
				return false;
			}
		}
		if(Trim(bathrooms.value) != "")
		{
			if(!IsNumeric(bathrooms.value))
			{
				alert("-No. of bath rooms should be only numeric.");
				bathrooms.focus();
				return false;
			}
		}

		if(Trim(pdesc.value) == '')
		{
			alert("-Please enter the desription.");
			pdesc.focus();
			return false;
		}
		if(propertyphoto.value != '')
		{
			if(!checkimage('frmadduser','propertyphoto'))
			{
				return false;
			}
		}
		if(rad_coming[0].checked==false && rad_coming[1].checked==false)
		{
			alert("-Please select a Coming Soon Property? option");
			return false;
		}
	}
	return true;
}

//Function to validate the events
function validateEvents(frm)
{
	with(frm)
	{
		if(Trim(title.value) == '')
		{
			alert("-Please enter the title.");
			title.focus();
			return false;
		}
	}
	return true;
}

function validateselling(frm) {
	with(frm)
	{
		if(Trim(fname.value) == '')
		{
			alert("-Please enter your firstname.");
			fname.focus();
			return false;
		}
		if(Trim(lname.value) == '')
		{
			alert("-Please enter your lastname.");
			lname.focus();
			return false;
		}
		if(Trim(phone.value) == "")
		{
			alert("-Please enter your contact phone number.");
			phone.focus();
			return false;
		}
		else if(!IsNumeric(phone.value))
		{
			alert("-Phone number should be only numeric.");
			phone.focus();
			return false;
		}
		if(!checkEmail(email.value))
		{
			email.focus();
			return false;
		}
		if(Trim(txt_property.value) == '')
		{
			alert("-Please enter your Property Address.");
			txt_property.focus();
			return false;
		}
		if(Trim(txt_city.value) == "")
		{
			alert("-Please enter your City.");
			txt_city.focus();
			return false;
		}
		if(Trim(sel_state.value) == "")
		{
			alert("-Please enter your State.");
			sel_state.focus();
			return false;
		}
		if(Trim(txt_zip.value) == '')
		{
			alert("-Please enter the Zip.");
			txt_zip.focus();
			return false;
		}
		else if(!IsNumeric(txt_zip.value))
		{
			alert("-Zip should be only numeric.");
			txt_zip.focus();
			return false;
		}
		if(Trim(txt_security.value) == "")
		{
			alert("-Please enter Security Code.");
			txt_security.focus();
			return false;
		}
	}
	return true;
}

//Function to validate the Request form...
function validateRequest(frm)
{
	with(frm)
	{
		if(Trim(name.value) == '')
		{
			alert("-Please enter your name.");
			name.focus();
			return false;
		}
		if(Trim(phone.value) == "")
		{
			alert("-Please enter your contact phone number.");
			phone.focus();
			return false;
		}
		else if(!IsNumeric(phone.value))
		{
			alert("-Phone number should be only numeric.");
			phone.focus();
			return false;
		}
		if(!checkEmail(email.value))
		{
			email.focus();
			return false;
		}
		if(Trim(subject.value) == '')
		{
			alert("-Please enter the subject.");
			subject.focus();
			return false;
		}
		if(Trim(hdesc.value) == '')
		{
			alert("-Please enter the description.");
			hdesc.focus();
			return false;
		}

	}
	return true;
}

//Funtion to validate the EX Search form
function validateexsearch(frm)
{
	with(frm)
	{
		if(Trim(fname.value) == '')
		{
			alert("-Please enter your firstname.");
			fname.focus();
			return false;
		}
		if(Trim(lname.value) == '')
		{
			alert("-Please enter your lastname.");
			lname.focus();
			return false;
		}
		if(Trim(phone.value) == "")
		{
			alert("-Please enter your contact phone number.");
			phone.focus();
			return false;
		}
		else if(!IsNumeric(phone.value))
		{
			alert("-Phone number should be only numeric.");
			phone.focus();
			return false;
		}
		if(!checkEmail(email.value))
		{
			email.focus();
			return false;
		}
		if(Trim(city.value) == '')
		{
			alert("-Please enter the city.");
			city.focus();
			return false;
		}
		if(bedrooms.value == 0)
		{
			alert("-Please select the No. of bedrooms.");
			bedrooms.focus();
			return false;
		}
		if(bathrooms.value == 0)
		{
			alert("-Please select the No. of bathrooms.");
			bathrooms.focus();
			return false;
		}
		if(minprice.value == 0)
		{
			alert("-Please select the minimum price.");
			minprice.focus();
			return false;
		}
		if(maxprice.value == 0)
		{
			alert("-Please select the maximum price.");
			maxprice.focus();
			return false;
		}
		if(Trim(apptime.value) == '')
		{
			alert("-Please enter approximate time .");
			apptime.focus();
			return false;
		}
		if(Trim(comments.value) == '')
		{
			alert("-Please enter the comments.");
			comments.focus();
			return false;
		}
		//alert("Mail Sent Successfully !!")
	}
	return true;
}

function validatecoming(frm)
{
	with(frm)
	{
		if(Trim(fname.value) == '')
		{
			alert("-Please enter your firstname.");
			fname.focus();
			return false;
		}
		if(Trim(lname.value) == '')
		{
			alert("-Please enter your lastname.");
			lname.focus();
			return false;
		}
		if(Trim(phone.value) == "")
		{
			alert("-Please enter your contact phone number.");
			phone.focus();
			return false;
		}
		else if(!IsNumeric(phone.value))
		{
			alert("-Phone number should be only numeric.");
			phone.focus();
			return false;
		}
		if(!checkEmail(email.value))
		{
			email.focus();
			return false;
		}
		//alert("Mail Sent Successfully !!")
	}
	return true;
}

function validatetellafriend(frm)
{
	with(frm)
	{
		if(Trim(yourfname.value) == '')
		{
			alert("-Please enter your firstname.");
			yourfname.focus();
			return false;
		}
		if(Trim(yourlname.value) == '')
		{
			alert("-Please enter your lastname.");
			yourlname.focus();
			return false;
		}
		if(Trim(youremail.value) == '')
		{
			alert("-Please enter your email.");
			youremail.focus();
			return false;
		}		
		if(!checkEmail(youremail.value))
		{
			youremail.focus();
			return false;
		}		
		if(Trim(fname.value) == '')
		{
			alert("-Please enter your friend's firstname.");
			fname.focus();
			return false;
		}
		if(Trim(lname.value) == '')
		{
			alert("-Please enter your friend's lastname.");
			lname.focus();
			return false;
		}
		if(Trim(email.value) == '')
		{
			alert("-Please enter your friend's email.");
			email.focus();
			return false;
		}		
		if(!checkEmail(email.value))
		{
			email.focus();
			return false;
		}
	}
	return true;
}

function validatefrmrequest(frm){
	with(frm)
	{
		if(Trim(fname.value) == '')
		{
			alert("-Please enter your firstname.");
			fname.focus();
			return false;
		}
		if(Trim(lname.value) == '')
		{
			alert("-Please enter your lastname.");
			lname.focus();
			return false;
		}
		if(!checkEmail(email.value))
		{
			email.focus();
			return false;
		}
		if(Trim(comments.value) == '')
		{
			alert("-Please enter your comments.");
			comments.focus();
			return false;
		}
		if(Trim(security_code.value) == '')
		{
			alert("-Please enter your security code.");
			security_code.focus();
			return false;
		}
		if(security_code.value != captchaval.value)
		{
			alert("-Your security code has been invalid.");
			security_code.focus();
			return false;
		}
	}
	return true;
}

function chk_RequestInfo(getid) {
	setVisible('reqinfo',true);
	document.getElementById('hid_comid').value=getid;
}
