// JavaScript Document
	
	/* =======================ajax===================================
		Grobal declares
	================================================================*/
	var xmlHttp
	var whichID
	var strString	
	var gCode
	var compwindow
	var count = "1";
	var lookupid

	///**************************************
//	* http://vertical-scroller.vbarsan.com/
//	*    This notice may not be removed 
//	**************************************/
//	
//	//-- Begin Scroller's Parameters and messages -->
//	//scroller's width
//	var swidth=450;
//	
//	//scroller's height
//	var sheight=20;
//	
//	
//	//scroller's speed 
//	var sspeed=2;
//	var restart=sspeed;
//	var rspeed=sspeed;
//	
//	//scroller's pause 
//	var spause=2000;
//	
//	//scroller's background
//	var sbcolor="#ccffcc";
//	function buildArray(str){
//		singletext[0] = str
//		}
//	//messages: set your own; use as many as you'd like; set up Hyperlinks to
//	//URLs as you normally do: <a target=... href="... URL ...">..message..</a>;
//	var singletext=new Array();
//	//var test = '<?php echo "tryi"; ?>'
//	
//	//singletext[...]='...';
//	//-- end Parameters and message -->
//	
//	//-- begin: Scroller's Algorithm -->
//	var ii=0;
//	function goup(){if(sspeed!=rspeed*16){sspeed=sspeed*2;restart=sspeed;}}
//	
//	function startScroll(){
//	if(document.getElementById){ns6div=document.getElementById('iens6div');ns6div.style.top=sheight+"px";ns6div.innerHTML=singletext[0];sizeup=ns6div.offsetHeight;ns6scroll();}
//	else 
//	if(document.layers){ns4layer=document.ns4div.document.ns4div1;ns4layer.top=sheight;ns4layer.document.write(singletext[0]);ns4layer.document.close();sizeup=ns4layer.document.height;ns4scroll();}
//	else 
//	if(document.all){iediv=iens6div;iediv.style.pixelTop=sheight+"px";iediv.innerHTML=singletext[0];sizeup=iediv.offsetHeight;iescroll();}}
//	function iescroll(){if(iediv.style.pixelTop>0&&iediv.style.pixelTop<=sspeed){iediv.style.pixelTop=0;setTimeout("iescroll()",spause);}else 
//	if(iediv.style.pixelTop>=sizeup*-1){iediv.style.pixelTop-=sspeed+"px";setTimeout("iescroll()",100);}else{if(ii==singletext.length-1)ii=0;else ii++;iediv.style.pixelTop=sheight+"px";iediv.innerHTML=singletext[ii];sizeup=iediv.offsetHeight;iescroll();}}
//	function ns4scroll(){if(ns4layer.top>0&&ns4layer.top<=sspeed){ns4layer.top=0;setTimeout("ns4scroll()",spause);}else 
//	if(ns4layer.top>=sizeup*-1){ns4layer.top-=sspeed;setTimeout("ns4scroll()",100);}else{if(ii==singletext.length-1)ii=0;else ii++;ns4layer.top=sheight;ns4layer.document.write(singletext[ii]);ns4layer.document.close();sizeup=ns4layer.document.height;ns4scroll();}}
//	function ns6scroll(){if(parseInt(ns6div.style.top)>0&&parseInt(ns6div.style.top)<=sspeed){ns6div.style.top=0;setTimeout("ns6scroll()",spause);}else 
//	if(parseInt(ns6div.style.top)>=sizeup*-1){ns6div.style.top=parseInt(ns6div.style.top)-sspeed+"px";setTimeout("ns6scroll()",100);}
//	else{if(ii==singletext.length-1)ii=0;else ii++;
//	ns6div.style.top=sheight+"px";ns6div.innerHTML=singletext[ii];sizeup=ns6div.offsetHeight;ns6scroll();}}
//	//-- end Algorithm -->

	
	//================================draw editor=====================================================================
	function drawBasicEditor(wd,ht){
		var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('modules')) + "fckeditor/" ;
		var oFCKeditor = new FCKeditor( 'editfield' ) ;
		oFCKeditor.BasePath	= sBasePath ;
		oFCKeditor.ToolbarSet = 'Basic';
		oFCKeditor.Width	= wd ;
		oFCKeditor.Height	= ht ;
		oFCKeditor.Value	= '';
		oFCKeditor.Create() ;
		}
	/* =======================ajax===================================
		AJAX functions
	================================================================*/
	
	function ajaxGetFunction(surl,str,objID1,objID2,ref1,ref2,ref3,ref4,qStr1,qStr2,qStr3,qStr4){ 
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  } 
		var url=surl;
		url=url+"?wit="+str;
		url=url+"&"+ref1+"="+qStr1
		url=url+"&"+ref2+"="+qStr2
		url=url+"&"+ref3+"="+qStr3
		url=url+"&"+ref4+"="+qStr4
		url=url+"&page="+objID2
		url=url+"&sid="+Math.random();
		whichID = objID1
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		document.getElementById(whichID).innerHTML="<img src='images/loading.gif' border=0> Generating Data ...";
	}
	
	function stateChanged(){ 
	if (xmlHttp.readyState==4){ 
	document.getElementById(whichID).innerHTML=xmlHttp.responseText;
	}
	}
	
	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;
	}
	//======================POST METHOD
	function getXMLObject()  //XML OBJECT
	{
	   var xmlHttp = false;
	   try {
		 xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers
	   }
	   catch (e) {
		 try {
		   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+
		 }
		 catch (e2) {
		   xmlHttp = false   // No Browser accepts the XMLHTTP Object then false
		 }
	   }
	   if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
		 xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
	   }
	   return xmlHttp;  // Mandatory Statement returning the ajax object created
	}
	
	var xmlhttp = new getXMLObject();	//xmlhttp holds the ajax object
 
	function ajaxPostFunction(surl,str,objID1,sdata) {
	  var getdate = new Date();  //Used to prevent caching during ajax call
	  whichID = objID1;
	  if(xmlhttp) { 
		var txtname = document.getElementById("txtname");
		xmlhttp.open("POST",surl,true); //calling testing.php using POST method
		xmlhttp.onreadystatechange  = handleServerResponse;
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send("wit=" + str+"||"+sdata); //Posting txtname to PHP File
	  }
	}
	 
	function handleServerResponse() {
	   if (xmlhttp.readyState == 4) {
		 if(xmlhttp.status == 200) {
		   document.getElementById(whichID).innerHTML=xmlhttp.responseText; //Update the HTML Form element 
		 }
		 else {
			alert("Error during AJAX call. Please try again");
		 }
	   }
	}
	// ==============================================end====================================================================
	//=======================================TEXT MANIPULATION =============================================================
	function doBlink() {
	  // Blink, Blink, Blink...
	  var blink = document.all.tags("BLINK")
	  for (var i=0; i < blink.length; i++)
		blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
		}
	
	function startBlink() {
	  // Make sure it is IE4
	  if (document.all)
		setInterval("doBlink()",500)
		}
		
	//========================================================VALIDATIONS===================================================
	function validateTell() {
		
		if (!validRequired(frmMain.name,"Your name")) {
		return false;
		}
		if (!validEmail(frmMain.email,"Your email address",true)) {
		return false;
		}
		
		if (!validEmail(frmMain.fmail1,"Friend's email address",true)) {
		return false;
		}
	//document.tellafriend.submit()
	postRequest("popup.php?linkid=sendtell")
	return true;
	}
	
	//************validate login form **************************************************************************************
	 function searchByNo(){
		if (!validRequired(frmMain.txtpropno,"Property No."))
		return false;
		getPropertyByNo('property.php','fs',frmMain.txtpropno.value)
		}
	 function validateUser(){
		 var xstr=""
		 arraylbl = Array("First Name","Last Name","Phone Number","","","","Email","Password","Confirm Password")
		 for (i=0;i<=4;i++){
			 if (i!=3&&i!=4&&!validRequired(frmMain.txt[i],arraylbl[i]))
				return false;
			 xstr+=frmMain.txt[i].value+"~~"
			 }
		 for (i=0;i<=2;i++){
			 if(frmMain.chk[i].checked==true)
			 xstr+=frmMain.chk[i].value+"~~"
			 else
			 xstr+="0~~"
			 } 
		 for (i=5;i<=8;i++){
			 if (i==6){
				 if (!validEmail(frmMain.txt[i],arraylbl[i],true))
				return false;
				 }
			 else{
			 if (!validRequired(frmMain.txt[i],arraylbl[i]))
				return false;
				}
			 xstr+=frmMain.txt[i].value+"~~"
			 }
		 if(frmMain.txt[7].value!=frmMain.txt[8].value){
			 alert("Passwords do not match.  Please re-enter")
			 frmMain.txt[7].value=""
			 frmMain.txt[8].value=""
			 frmMain.txt[7].focus();
			 return false;
			 }
		 if(!MPFSValidate()){;
		 	return false;}
			//alert(xstr)
			
		 xstr = URLEncode(xstr)
		 ajaxGetFunction('modules/mod_updates.php','areg||','cfirmation','','sval','axn','','',xstr,'new','','')
		 }	
		 
	function validateUserProfile(aid){
		 var xstr=""
		 arraylbl = Array("First Name","Last Name","Phone Number","","","")
		 for (i=0;i<=4;i++){
			 if (i!=3&&i!=4&&!validRequired(frmMain.txt[i],arraylbl[i]))
				return false;
			 xstr+=frmMain.txt[i].value+"~~"
			 }
		 for (i=0;i<=2;i++){
			 if(frmMain.chk[i].checked==true)
			 xstr+=frmMain.chk[i].value+"~~"
			 else
			 xstr+="0~~"
			 } 
		//if (!validRequired(frmMain.txt[5],arraylbl[5]))
		//return false;
		xstr+=frmMain.txt[5].value+"~~"

		 xstr+=aid
		 alert(xstr)
		 if(!MPFSValidate()){;
		 	return false;}
			
		 xstr = URLEncode(xstr)
		 ajaxGetFunction('modules/mod_updates.php','amodify||','cfirmation','','sval','','','',xstr,'','','')
		 }
		 
	 
	 function validateEnquiry(){
		 lblArray = Array("Your Name","Email Address","","Subject")
		 var val = ""
		 for (i=0;i<frmMain.etxt.length;i++){
		 	if (i!=2){
				if(i==1){
					if (!validEmail(frmMain.etxt[i],lblArray[i]))
					return false;
					}
				else{
					if (!validRequired(frmMain.etxt[i],lblArray[i]))
					return false;
					}		
		 		}
				if (i==2)val +=frmMain.etxt[i].value+"|"
				else val +=frmMain.etxt[i].value+"~|~"
		 	}
			
			var oEditor = FCKeditorAPI.GetInstance('editfield') ;
			if (trimAll(oEditor.GetXHTML(true))==""){
				alert("Please enter comments.")
				return false;
				}
				val +=oEditor.GetXHTML(true)
			//alert (val)	
		var arrayEnq = val.split("~|~")
		//frmMain.etxt1.value = ""
		//frmMain.etxt2.value = ""
		//frmMain.etxt3.value = ""
		//frmMain.etxt4.value = ""
		//frmMain.etxt5.value = ""
		ajaxGetFunction('modules/mod_ajax_1.php','enq','sendmail','','etxt1','etxt2','etxt4','etxt5',arrayEnq[0],arrayEnq[1],arrayEnq[2],arrayEnq[3])
		
		}
	
	
	
	
	function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
		 if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
	
	function isDecimalKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
		 if (charCode > 31 && charCode != 46 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
		
	function validateListLogin(){
		if (!validEmail(frmMain.txtlst1,"Email"))
		return false;
		if (!validRequired(frmMain.txtlst2,"Password"))
		return false;
		postRequest("property.php?linkid=prop")
		}
		
	function forgotPassword(){
		if (!validEmail(frmMain.txtlst1,"Email"))
		return false;
		ajaxGetFunction("modules/mod_ajax_1.php","getpword","sent","","email","","","",frmMain.txtlst1.value,"","","");
		//postRequest("property.php?linkid=pf")
		}
		
	function validateSubscription(){
		if (!validEmail(frmMain.nl,"Email"))
		return false;
		ajaxGetFunction("modules/mod_updates.php","nletter","msg","","email","","","",frmMain.nl.value,"","","");
		}
	 
	 function checkForm(theForm)
		{
			// Start ------->
			if (!validRequired(theForm.Username,"Username"))
				return false;
			if (!validRequired(theForm.uPassword,"Password"))
				return false;
			ajaxGetFunction('../../admin/modules/mod_ajax_1.php','validateuser','login','','uname','pword','','',frmMain.Username.value,frmMain.uPassword.value,'','')
			// <--------- End
			return true;
		}
	//=====================================================MENU CALLS =======================================================
	function getNews($url,$linkid,$item){
		frmMain.action=$url+"?linkid="+$linkid+"&nid="+$item;
		frmMain.method="post";
		frmMain.submit();
		}
	
	function getProperty($url,$linkid,$item){
		frmMain.action=$url+"?linkid="+$linkid+"&pd="+$item;
		frmMain.method="post";
		frmMain.submit();
		}
	function getPropertyByNo($url,$linkid,$item){
		frmMain.action=$url+"?linkid="+$linkid+"&pn="+$item;
		frmMain.method="post";
		frmMain.submit();
		}
	function callItemspg(surl,cap,axn,pholder,pg){ 
		ajaxGetFunction(surl,axn,pholder,'','','cap','page','','',cap,pg,'')
	 }
	function searchProperty($url,$linkid,ctrl){
		arraylbl = Array("Property","","")
		for (i=0;i<ctrl.length;i++){
			if (i==0&&!validRequired(ctrl[i],arraylbl[i]))
			return false;
			}
		frmMain.action=$url+"?linkid="+$linkid+"&pe="+ctrl[0].value+"&ff="+ctrl[1].value+"&gr="+ctrl[2].value;
		frmMain.method="post";
		frmMain.submit();
		}
	function advancedSearch(){

		postRequest("property.php?linkid=5s4l7t8i&pe=avs")
		}
	
	function postRequest($url){
		frmMain.action=$url;
		frmMain.method="post";
		frmMain.submit();
		}
	function callNewsItems(mth,yr){ 
		ajaxGetFunction('modules/mod_ajax_1.php','listnewsitems','newsarea','','mth','yr','','',mth,yr,'','')
	 	}
	function callNewsletters(mth,yr){ 
		ajaxGetFunction('modules/mod_ajax_1.php','listnewsletters','newsarea','','mth','yr','','',mth,yr,'','')
	 	}
	//open a modal window
	function openmodal(page,iWidth,iHeight,iCaption){
		compwindow=dhtmlmodal.open('compbox', 'iframe', page, iCaption , 'width=' + iWidth + 'px,height=' + iHeight + 'px,center=1,resize=0,scrolling=1')
		
		compwindow.onclose=function(){
				return true;
			}
		}
	//open as a  normal popup
	function popupnormal(page,wd,ht){
		window.open(page,'self','width='+wd+',height='+ht+',scrollbars=yes,status=yes,resizable=yes,top=0,left=0');
		return;
		
		}
	function printPage(){
		print();
		}
	function callSearch(page,keyword){
		frmMain.action=page+"?query="+keyword+"&search=1";
		frmMain.method="post";
		frmMain.submit();
		}
		
	function basicgetAjax(axn){
		ajaxGetFunction('modules/mod_ajax_1.php',axn,'maincontent','','','','','','','','','')
		}
	//=========================================================encode script ========================================================
	function URLEncode(clearString) {
	  var output = '';
	  var x = 0;
	  clearString = clearString.toString();
	  var regex = /(^[a-zA-Z0-9_.]*)/;
	  while (x < clearString.length) {
		var match = regex.exec(clearString.substr(x));
		if (match != null && match.length > 1 && match[1] != '') {
			output += match[1];
		  x += match[1].length;
		} else {
		  if (clearString[x] == ' ')
			output += '+';
		  else {
			var charCode = clearString.charCodeAt(x);
			var hexVal = charCode.toString(16);
			output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
		  }
		  x++;
		}
	  }
	  return output;
	}
	
	//=====================================STRING MANIPULATION===============================================================
	function changeImg(fld,img){
		var image = document.getElementById("pic")
		image.src = "properties/"+fld+"/"+img
		}
	function resetSearch(){
		if(trimAll(frmMain.sitesearch.value) == "")
		frmMain.sitesearch.value = "search ..."
		}
	function clearSearchBox(){
		if(frmMain.sitesearch.value == "search ...")
			frmMain.sitesearch.value = ""
		}
	function trimAll(sString){
		while (sString.substring(0,1) == ' '){
			sString = sString.substring(1, sString.length);
		}
		while (sString.substring(sString.length-1, sString.length) == ' '){
			sString = sString.substring(0,sString.length-1);
		}
		return sString;
	}
	
	function highlight(syr,intI,yr,axn){
		var yrs = ""
		var colid = ""
		//<a href="javascript:alert('<?php echo gmdate("Y")?>')"><?php echo gmdate('Y',$year);?></a>
		for (i=0;i<6;i++){
			yrs = Number(syr)+i
			if (Number(yrs) == Number(yr)) {
				tdid[i].style.background = "#cccccc"
				tdid[i].innerHTML = yr
				}
			else{
				tdid[i].style.background = '';
				tdid[i].innerHTML = "<a class='mainnews' href=\"javascript:highlight('"+syr+"','"+intI+"','"+yrs+"','"+axn+"')\">"+yrs+"</a>"
				}
			}
			newsarea.innerHTML = ""
			ajaxGetFunction('modules/mod_ajax_1.php',axn,'mths','','yr','axn','','',yr,axn,'','')
		}
		
	function setLocationDefaults(ctrl,wd){
		subb.innerHTML = "<select name=\"txt10\" id=\"txt10\" style=\"width:"+wd+"px\" onchange=\"if (frmMain.txt9.value==''){alert('Please select City/Town');this.value='';frmMain.txt9.focus(); return false;} setOther(this.value,'subb','modules/mod_ajax_1.php','txt9','txt10')\"><option></option><option value=\"other\">Other</option></select>"
		loc.innerHTML = "<select name=\"txt11\" id=\"txt11\" style=\"width:"+wd+"px\" onchange=\"if (frmMain.txt10.value==''){alert('Please select Suburb');this.value='';frmMain.txt10.focus(); return false;} setOther(this.value,'loc','modules/mod_ajax_1.php','txt10','txt11')\"><option></option><option value=\"other\">Other</option></select>"
		ajaxGetFunction('modules/mod_ajax_1.php','gettown','tn','txt9','lst','rid','wd','pg','tn',ctrl.options[ctrl.selectedIndex].id,wd,'modules/mod_ajax_1.php')
		}
	function avssetLocationDefaults(ctrl,wd){
		subb.innerHTML = "<select name=\"e\" id=\"e\" style=\"width:"+wd+"px\" onchange=\"if (frmMain.d.value==''){alert('Please select City/Town');this.value='';frmMain.d.focus(); return false;} setOther(this.value,'subb','modules/mod_ajax_2.php','d','e')\"><option></option><option value=\"other\">Other</option></select>"
		ajaxGetFunction('modules/mod_ajax_2.php','gettown','tn','d','lst','rid','wd','pg','tn',ctrl.options[ctrl.selectedIndex].id,wd,'modules/mod_ajax_2.php')
		}
	function setOther(slable,sid,page,parent,ctrl){
		if (slable == "other"){
			if (sid == "ocp") ocp.innerHTML = "<input type=\"text\" name='txt' size=\"28\" class=\"clsInputText\"><input type=\"button\" value=\" \" class=\"btnrefreshbox\" onclick=\"ajaxGetFunction('"+page+"', 'getoccupation','ocp','','lst','lid','wd','pg','ocp','"+parent+"','200','"+page+"')\">"
			if (sid == "tow") tow.innerHTML = "<input type=\"text\" name='txt' size=\"28\" class=\"clsInputText\"><input type=\"button\" value=\" \" class=\"btnrefreshbox\" onclick=\"ajaxGetFunction('"+page+"', 'gettowns','tow','','lst','rid','wd','pg','tow','"+parent+"','200','"+page+"')\">"
			if (sid == "twn") twn.innerHTML = "<input type=\"text\" name='"+ctrl+"' size=\"28\" class=\"clsInputText\"><input type=\"button\" value=\" \" class=\"btnrefreshbox\" onclick=\"ajaxGetFunction('"+page+"', 'gettown','twn','"+ctrl+"','lst','rid','wd','pg','twn','"+parent+"','200','"+page+"')\">"
			if (sid == "tn") tn.innerHTML = "<input type=\"text\" name='"+ctrl+"' size=\"35\" class=\"clsInputText\"><input type=\"button\" value=\" \" class=\"btnrefreshbox\" onclick=\"ajaxGetFunction('"+page+"', 'gettown','tn','"+ctrl+"','lst','rid','wd','pg','tn','"+parent+"','250','"+page+"')\">"
			if (sid == "subb") subb.innerHTML = "<input type=\"text\" name='"+ctrl+"' size=\"35\" class=\"clsInputText\"><input type=\"button\" value=\" \" class=\"btnrefreshbox\" onclick=\"ajaxGetFunction('"+page+"', 'getsuburb','subb','"+ctrl+"','lst','rid','wd','pg','subb','"+parent+"','250','"+page+"')\">"
			if (sid == "loc") loc.innerHTML = "<input type=\"text\" name='"+ctrl+"' size=\"35\" class=\"clsInputText\"><input type=\"button\" value=\" \" class=\"btnrefreshbox\" onclick=\"ajaxGetFunction('"+page+"', 'getlocality','loc','"+ctrl+"','lst','rid','wd','pg','loc','"+parent+"','250','"+page+"')\">"			
			}
		}
		
	function directory(catid,id,cat,axn,ltl){
		ajaxGetFunction('modules/dircontentpage.php',axn,id,'1','catid','cat','ltl','id',catid,cat,ltl,id)
		}
		
	function validateMoving(){
		var arraylbl = Array("Company Name","Phone","","Email","Region","Locality")
		var sval = ""
		
		if (!validRequired(frmMain.txtcat,"Category"))
			return false;
		for (i=0;i<frmMain.txt.length;i++){
			if (i!=2){
				if(i==3){
					if (trimAll(frmMain.txt[i].value)!=""&&!validEmail(frmMain.txt[i],arraylbl[i],true))
					return false;
					}
				else{
					if (!validRequired(frmMain.txt[i],arraylbl[i]))
					return false;
					}
				}
				sval += frmMain.txt[i].value+"~|~"
			}
			var oEditor = FCKeditorAPI.GetInstance('txtbrief') ;
			sval += oEditor.GetXHTML(true) + "~|~"
			var oEditor = FCKeditorAPI.GetInstance('txtadd') ;
			sval += oEditor.GetXHTML(true)+"~|~"+frmMain.hidcid.value+"~|~"+frmMain.txt[4].options[frmMain.txt[4].selectedIndex].id+"~|~"+frmMain.txtcat.value
			sval = URLEncode(sval)
			ajaxGetFunction('modules/mod_updates.php','addcomp||','moving','','sval','','','',sval,'','','')
		}
		
	function valPropertyUpdate(){
		lblArray = Array("Property Type","Offer Type","","Asking Price","","","","Region","","","","","","","","","No. of Rooms","","","","","","","","","","","","","")
		fileArray = Array("Front View","Street View","Hall View","","","")
		var ctrl=""
		var sval = "";
		var files = ""
		var lprd = 0;
		var i=0
		//basic info
		for(i=0;i<=4;i++){
			j=i+1
			ctrl = document.getElementById("txt"+j)
			if (!validRequired(ctrl,lblArray[i]))
			return false;
			sval +=ctrl.value+"~|~";
			}
		//days of week
		for(i=0;i<7;i++){
			ctrl = document.getElementById("chk"+i)
			if(ctrl.checked==true)
				sval +=ctrl.value+",";
			}
			sval +="~|~";
		//time of  day
		for(i=5;i<=6;i++){
			j=i+1
			ctrl = document.getElementById("txt"+j)
			if (!validRequired(ctrl,lblArray[i]))
			return false;
			sval +=ctrl.value+"~|~";
			}
			//description
			var oEditor = FCKeditorAPI.GetInstance('txtPropDesc') ;
			if (trimAll(oEditor.GetXHTML(true))==""){
				alert("Please enter brief but detailed description of property.")
				return false;
				}
			sval = sval + oEditor.GetXHTML(true) + "~|~"
			//locality info
		for(i=7;i<=12;i++){
			j=i+1
			ctrl = document.getElementById("txt"+j)
			if (i==7&&!validRequired(ctrl,lblArray[i]))
			return false;
			sval +=ctrl.value+"~|~";
			}
			//listing period
		for(i=0;i<=2;i++){
			if(frmMain.opt[i].checked==true)
			lprd = frmMain.opt[i].value
			}
		if(lprd==0){
			alert ("Please select a listing period.")
			return false;
			}
		sval +=lprd+"~|~";
			//property details
		for(i=13;i<=27;i++){
			j=i+1
			ctrl = document.getElementById("txt"+j)
			if (i==16&&!validRequired(ctrl,lblArray[i]))
			return false;
			sval +=ctrl.value+"~|~";
			}
		//images
		for (i=1;i<=6;i++){
			ctrl = document.getElementById("file"+i)
			if(i<=3){
				if (!validRequired(ctrl,fileArray[i-1]))
				return false;
				if (valJpgGif(ctrl,"The \"File\" you have  selected for \"Load Picture\" is not allowed!  Supported file types are: JPG, JPEG, GIF, PNG")==false) {ctrl.focus(); return false;};
				}
			if(i>3){
				if (trimAll(ctrl.value)!=""){
					if (valJpgGif(ctrl,"The \"File\" you have  selected for \"Load Picture\" is not allowed!  Supported file types are: JPG, JPEG, GIF, PNG")==false) {ctrl.focus(); return false;};
					}
				}
				files+=ctrl.value+"~|~"
			}
		//property usage
		for(i=28;i<=29;i++){
			j=i+1
			ctrl = document.getElementById("txt"+j)
			sval +=ctrl.value+"~|~";
			}
		//terms of agreement
		lprd=0
		for(i=0;i<=2;i++){
			if(frmMain.ropt[i].checked==true)
			lprd = frmMain.ropt[i].value
			}
		if(lprd==0){
			alert ("Please select type of agreement.")
			return false;
			}
		sval +=lprd+"~|~";
		ctrl = document.getElementById("txt31")
		sval +=ctrl.value
		frmMain.sval.value = sval
		frmMain.subval.value = files
		alert(frmMain.sval.value)
			//ajaxImgPostFunction("modules/mod_singleupload.php","uploadimg",frmMain.file.value)
		generic_onClick("modules/mod_multiupload.php")
	}
	
	function valWantlist(){
		lblArray = Array("Name","","Email","Property Type","","","","","Price","","","Region","","Time Limits","")
		var ctrl=""
		var sval = "";
		var files = ""
		var lprd = 0;
		var i=0
		//basic info
		for(i=0;i<=14;i++){
			j=i+1
			ctrl = document.getElementById("txt"+j)
			if(i!=1&&i!=4&&i!=5&&i!=6&&i!=7&&i!=9&&i!=10&&i!=12&&i!=14){
				if (i==2&&!validEmail(ctrl,lblArray[i],true))
				return false;
				else if (!validRequired(ctrl,lblArray[i]))
				return false;
			}
			sval +=ctrl.value+"~|~";
			}
		//newsletter
		ctrl = document.getElementById("chk")
		if (ctrl.checked==true) sval +="1~|~";
		else sval +="~|~";
		sval += frmMain.txt12.options[frmMain.txt12.selectedIndex].id
		sval = URLEncode(sval)
		ajaxGetFunction("modules/mod_updates.php","wantlist","wantlist","","val","","","",sval,"","","")
	}
	
	function valInterested(){
		lblArray = Array("Firstname","Lastname","Contact No","Email","")
		var ctrl=""
		var sval = "";
		var files = ""
		var lprd = 0;
		var i=0
		//basic info
		for(i=0;i<=4;i++){
			j=i+1
			ctrl = document.getElementById("txt"+j)
			if(i!=4){
				if (i==3&&!validEmail(ctrl,lblArray[i],true))
				return false;
				else if (!validRequired(ctrl,lblArray[i]))
				return false;
			}
			sval +=ctrl.value+"~|~";
			}
			sval +=frmMain.hidID.value;
		//alert (sval)
		sval = URLEncode(sval)
		//alert (sval)
		ajaxGetFunction("modules/mod_updates.php","interested","interested","","val","","","",sval,"","","")
	}
	
	function changePass(){
		arraylbl = Array("Old Password","New Password","Confirm Password")
		for (j=0;j<document.frmMain.txtsec.length;j++){
			if (!validRequired(frmMain.txtsec[j],arraylbl[j]))
			return false;
		}
		//alert(frmMain.hidpass.value)
		if (trimAll(frmMain.txtsec[0].value) != trimAll(frmMain.hidpass.value)){
			alert("Your old password is incorrect.")
			frmMain.txtsec[0].focus();
			return false;
		}
		if (trimAll(frmMain.txtsec[1].value) != trimAll(frmMain.txtsec[2].value)){
			alert("New password and confirm password do not match.  Please retry.")
			frmMain.txtsec[1].focus();
			return false;
		}
		var xconfirm=window.confirm("Are you sure you want to change your password... ?");  
		if(xconfirm==true)
		  {
			cid = frmMain.txtsec[0].value + "~|~" + frmMain.txtsec[1].value + "~|~" + frmMain.txtsec[2].value + "~|~" + frmMain.hidid.value
			//alert (cid)
			//genericAJAX(axn,"strmsg","","lgid","","",cid,"","")
			ajaxGetFunction("modules/mod_updates.php","changepass","cpass","","val","","","",cid,"","","")
		  }
		 else
		 {
		   window.alert("Process Canceled.");
		 } 		
	}
	
	function valPropertyPage1(pg,pid){
		lblArray = Array("Property Type","Offer Type","","Asking Price","","","","Region","","","","","")
		var ctrl=""
		var sval = "";
		var files = ""
		var lprd = 0;
		var i=0
		//basic info
		for(i=0;i<=4;i++){
			j=i+1
			ctrl = document.getElementById("txt"+j)
			if (i!=4&&!validRequired(ctrl,lblArray[i]))
			return false;
			sval +=ctrl.value+"~|~";
			}
		//days of week
		for(i=0;i<7;i++){
			ctrl = document.getElementById("chk"+i)
			if(ctrl.checked==true)
				sval +=ctrl.value+",";
			}
			sval +="~|~";
		//time of  day
		for(i=5;i<=6;i++){
			j=i+1
			ctrl = document.getElementById("txt"+j)
			if (!validRequired(ctrl,lblArray[i]))
			return false;
			sval +=ctrl.value+"~|~";
			}
			//description
			var oEditor = FCKeditorAPI.GetInstance('txtPropDesc') ;
			if (trimAll(oEditor.GetXHTML(true))==""){
				alert("Please enter brief but detailed description of property.")
				return false;
				}
			sval = sval + oEditor.GetXHTML(true) + "~|~"
			//locality info
		for(i=7;i<=12;i++){
			j=i+1
			ctrl = document.getElementById("txt"+j)
			if (i==7&&!validRequired(ctrl,lblArray[i]))
			return false;
			if (ctrl.type == "select-one")
			sval +=ctrl.options[ctrl.selectedIndex].text+"~|~";
			else
			sval +=ctrl.value+"~|~";
			}
			//listing period
		for(i=0;i<=2;i++){
			if(frmMain.opt[i].checked==true)
			lprd = frmMain.opt[i].value
			}
		if(lprd==0){
			alert ("Please select a listing period.")
			return false;
			}
		sval +=lprd+"~|~";
		frmMain.sval.value = sval	
		//alert(frmMain.sval.value)
		//ajaxImgPostFunction("modules/mod_singleupload.php","uploadimg",frmMain.file.value)
		postRequest('property.php?linkid='+pg+'&pid='+pid)
	}
	
	function valPropertyPage2(){
		lblArray = Array("","","","No. of Rooms","","","","","","","","","","","","","")
		fileArray = Array("Front View","Street View","Hall View","","","")
		var ctrl=""
		var sval = "";
		var files = ""
		var lprd = 0;
		var i=0;
		var nmg = 1;
		//property details
		for(i=0;i<=14;i++){
			j=i+14
			ctrl = document.getElementById("txt"+j)
			if (i==3&&!validRequired(ctrl,lblArray[i]))
			return false;
			sval +=ctrl.value+"~|~";
			}
		//images
		if (frmMain.noimg.checked==false){
			nmg=0;
		for (i=1;i<=6;i++){
			ctrl = document.getElementById("file"+i)
			if(i<=3){
				if (!validRequired(ctrl,fileArray[i-1]))
				return false;
				if (valJpgGif(ctrl,"The \"File\" you have  selected for \"Load Picture\" is not allowed!  Supported file types are: JPG, JPEG, GIF, PNG")==false) {ctrl.focus(); return false;};
				}
			if(i>3){
				if (trimAll(ctrl.value)!=""){
					if (valJpgGif(ctrl,"The \"File\" you have  selected for \"Load Picture\" is not allowed!  Supported file types are: JPG, JPEG, GIF, PNG")==false) {ctrl.focus(); return false;};
					}
				}
				files+=ctrl.value+"~|~"
			}
		}
		//property usage
		for(i=15;i<=16;i++){
			j=i+14
			ctrl = document.getElementById("txt"+j)
			sval +=ctrl.value+"~|~";
			}
		//terms of agreement
		lprd=0
		for(i=0;i<=2;i++){
			if(frmMain.ropt[i].checked==true)
			lprd = frmMain.ropt[i].value
			}
		if(lprd==0){
			alert ("Please select type of agreement.")
			return false;
			}
		sval +=lprd+"~|~";
		ctrl = document.getElementById("txt31")
		sval +=ctrl.value

		if(frmMain.chkn.checked==true)sval +="~|~1"
		else sval +="~|~0"
		for(i=0;i<=1;i++){
			if(frmMain.rprm[i].checked==true)
			lprm = frmMain.rprm[i].value
			}
		sval +="~|~"+lprm;
		frmMain.hidpage2.value=sval;
		frmMain.sval.value = frmMain.hidpage1.value+sval+"~|~"+nmg;
		frmMain.subval.value = files;
		//alert(frmMain.subval.value)
		//ajaxImgPostFunction("modules/mod_singleupload.php","uploadimg",frmMain.file.value)
		postRequest("modules/mod_multiupload.php?cnt="+frmMain.pno.value)
	}
	
	//===============================================image validation ===================================================
	function valJpgGif(entered, alertbox) {
		with (entered){
			ext=value.substr(value.lastIndexOf(".")).toLowerCase();
			if (ext!=""&&ext!=".jpg"&&ext!=".gif"&&ext!=".pjpeg"&&ext!=".jpeg"&&ext!=".png"){
				if (alertbox!="") {
					alert(alertbox);
				}
				return false;
			}
			else {return true;}
		}
	}
	
	function backtoPage1(pg){
		var ctrl=""
		var sval = "";
		var files = ""
		var lprd = 0;
		var i=0
		//property details
		for(i=0;i<=14;i++){
			j=i+14
			ctrl = document.getElementById("txt"+j)
			sval +=ctrl.value+"~|~";
			}
		for (i=1;i<=6;i++){
			files+=ctrl.value+"~|~"
		}
		//property usage
		for(i=15;i<=16;i++){
			j=i+14
			ctrl = document.getElementById("txt"+j)
			sval +=ctrl.value+"~|~";
			}
		//terms of agreement
		lprd=0
		for(i=0;i<=2;i++){
			if(frmMain.ropt[i].checked==true)
			lprd = frmMain.ropt[i].value
			}
		sval +=lprd+"~|~";
		ctrl = document.getElementById("txt31")
		sval +=ctrl.value
		ctrl = document.getElementById("chkn")
		if(ctrl.checked==true)sval +="1"
		else if (ctrl.checked==true)sval +="0"
		frmMain.hidpage2.value=sval;
		frmMain.subval.value = files;
		//alert(frmMain.hidpage2.value)
		postRequest('property.php?linkid='+pg)
	}
	
	function toggleSave(){
		if (frmMain.chkI.checked==true) frmMain.btnSave.disabled = false;
		else if (frmMain.chkI.checked==false) frmMain.btnSave.disabled = true;
		}
		
	function setctrl(id,ctrlname){
		//alert(document.getElementById(id))
		ctrl= document.getElementById(id)
		
		ctrl.innerHTML = "<input name='"+ctrlname+"' type=\"file\" class=\"clsInputText\" id='"+ctrlname+"' size=\"50\" />"
		}
		
	function validateDelist(){
		if (!validEmail(frmMain.txtemail,"Username",true))
		return false;
		if (!validRequired(frmMain.txtcode,"Property Code"))
		return false;
		if (!validRequired(frmMain.txtid,"Property #"))
		return false;
		
		ajaxGetFunction('modules/mod_updates.php','delist','delistmsg','','code','id','','',frmMain.txtcode.value,frmMain.txtid.value,'','')
		}
		
	function valSA(){
		var str = ""
		arraylbl = Array("Name","Email","Address","Employer","Travel Date","No of Days to Spend","Accomodation Budget","Do you want shared accomodation ?","Travelling with Partner ?")
		for (i=0;i<frmMain.txtsa.length;i++){
			if (i!=frmMain.txtsa.length-1){
				if (i==1){
					if (!validEmail(frmMain.txtsa[i],arraylbl[i],true))
					return false;
					}
				else{
					if (!validRequired(frmMain.txtsa[i],arraylbl[i]))
					return false;
					}
				}
			str+=frmMain.txtsa[i].value+"|~|"
			}
			
			for (i=0;i<frmMain.txtsa.length;i++){
				frmMain.txtsa[i].value="";
				}
			ajaxGetFunction('modules/mod_updates.php','fifa||','updatefifa','','val','','','',str,'','','')
		}
		
	//=====================calender control===========================
//		user defined onchange handler
	var oldLink = null;
	// code to change the active stylesheet
	function setActiveStyleSheet(link, title) {
	  var i, a, main;
	  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
		  a.disabled = true;
		  if(a.getAttribute("title") == title) a.disabled = false;
		}
	  }
	  if (oldLink) oldLink.style.fontWeight = 'normal';
	  oldLink = link;
	  link.style.fontWeight = 'bold';
	  return false;
	}
	
	// This function gets called when the end-user clicks on some date.
	function selected(cal, date) {
	  cal.sel.value = date; // just update the date in the input field.
	  if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
		// if we add this call we close the calendar on single-click.
		// just to exemplify both cases, we are using this only for the 1st
		// and the 3rd field, while 2nd and 4th will still require double-click.
		cal.callCloseHandler();
	}
	
	// And this gets called when the end-user clicks on the _selected_ date,
	// or clicks on the "Close" button.  It just hides the calendar without
	// destroying it.
	function closeHandler(cal) {
	  cal.hide();                        // hide the calendar
	//  cal.destroy();
	  _dynarch_popupCalendar = null;
	}
	
	// This function shows the calendar under the element having the given id.
	// It takes care of catching "mousedown" signals on document and hiding the
	// calendar if the click was outside.
	
	function showCalendar(id, format, showsTime, showsOtherMonths) {
	  var el = document.getElementById(id);
	  if (_dynarch_popupCalendar != null) {
		// we already have some calendar created
		_dynarch_popupCalendar.hide();                 // so we hide it first.
	  } else {
		// first-time call, create the calendar.
		var cal = new Calendar(1, null, selected, closeHandler);
		// uncomment the following line to hide the week numbers
		// cal.weekNumbers = false;
		if (typeof showsTime == "string") {
		  cal.showsTime = true;
		  cal.time24 = (showsTime == "24");
		}
		if (showsOtherMonths) {
		  cal.showsOtherMonths = true;
		}
		_dynarch_popupCalendar = cal;                  // remember it in the global var
		cal.setRange(1900, 2070);        // min/max year allowed.
		cal.create();
	  }
	  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
	  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
	  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use
	
	  // the reference element that we pass to showAtElement is the button that
	  // triggers the calendar.  In this example we align the calendar bottom-right
	  // to the button.
	  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar
	
	  return false;
	}
	
	var MINUTE = 60 * 1000;
	var HOUR = 60 * MINUTE;
	var DAY = 24 * HOUR;
	var WEEK = 7 * DAY;
	
	/* If this handler returns true then the "date" given as
	parameter will be disabled.  In this example we enable
	only days within a range of 10 days from the current
	date.
	You can use the functions date.getFullYear() -- returns the year
	as 4 digit number, date.getMonth() -- returns the month as 0..11,
	and date.getDate() -- returns the date of the month as 1..31, to
	make heavy calculations here.  However, beware that this function
	should be very fast, as it is called for each day in a month when
	the calendar is (re)constructed.*/
	function isDisabled(date) {
	  var today = new Date();
	  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
	}
	
	function flatSelected(cal, date) {
	  var el = document.getElementById("preview");
	  el.innerHTML = date;
	}
	
	function showFlatCalendar() {
	  var parent = document.getElementById("display");
	
	  // construct a calendar giving only the "selected" handler.
	  var cal = new Calendar(0, null, flatSelected);
	
	  // hide week numbers
	  cal.weekNumbers = false;
	
	  // We want some dates to be disabled; see function isDisabled above
	  cal.setDisabledHandler(isDisabled);
	  cal.setDateFormat("%A, %B %e");
	
	  // this call must be the last as it might use data initialized above; if
	  // we specify a parent, as opposite to the "showCalendar" function above,
	  // then we create a flat calendar -- not popup.  Hidden, though, but...
	  cal.create(parent);
	
	  // ... we can show it here.
	  cal.show();
	}

		
	
	function getWordCount(){
		var lens = (150 - frmMain.txtsa[9].value.length)
		if (lens<0){
			var str = frmMain.txtsa[9].value.substring(0, 150)
			alert("You cannot exceed 150 characters.")
			frmMain.txtsa[9].value = str
			return false;
			}
		if (lens>=0)len.innerHTML = lens + " of 150"
		}