var xmlHttp
var currentFeatured=1;
var currentCondo=1;

function displayVR(){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return
	}
	
	var url="http://www.sporeproperties.com/modules/Detail/vrPage.php"
	
	url=url+"?id="+window.document.getElementById("txtPropertyId").value
	xmlHttp.onreadystatechange=stateDisplayVR
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateDisplayVR() 
{ 
	
	if (xmlHttp.readyState==1)
	{ 
		window.document.getElementById("div_5").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/AJAXConnect.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		window.document.getElementById("div_5").innerHTML =xmlHttp.responseText;
        
	}
}

function changeToAgentMap(){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return
	}
	
	var url="http://www.sporeproperties.com/map/agentmap.php"
	
	url=url+"?id="+window.document.getElementById("txtPropertyId").value
	xmlHttp.onreadystatechange=stateChangeMap
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangeMap() 
{ 
	$propertyId = window.document.getElementById("txtPropertyId").value;

	if (xmlHttp.readyState==1)
	{ 
		window.document.getElementById("div_6").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/AJAXConnect.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		//text = xmlHttp.responseText.split("<span id=\"start\">");
		//actual_text = text[1].split("<span id=\"end\">");
        window.document.getElementById("div_6").innerHTML ="<iframe src=\"http://www.sporeproperties.com/map/agentmap.php?id="+$propertyId+"\"  width=\"100%\" scrolling=\"no\" frameborder=\"0\" height=\"580\"></iframe>";

        
	}
}



function ChangeCondo()
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return
	} 
	var url="modules.php?name=ProjectSearch"
	url=url+"&area="+window.document.getElementById("selDistrict").value
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedCondo
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedCondo() 
{ 
	if (xmlHttp.readyState==1)
	{ 
		document.getElementById("txtHint").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/AJAXConnect.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		text = xmlHttp.responseText.split("<span id=\"spnTest\">");
		actual_text = text[1].split("<span id=\"endTest\">");
        document.getElementById("txtHint").innerHTML=actual_text[0];
	}
} 


function DisplayArea(){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return
	} 
	propertyType = window.document.getElementById("selType").value
	propertyType = propertyType.split("_");
	var url="modules/Gmap/getArea.php"
	url=url+"?areaCode="+propertyType[0]
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedArea
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)

}

function stateChangedArea() 
{ 
	if (xmlHttp.readyState==1)
	{ 														    
		document.getElementById("divArea").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/AJAXConnect.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		document.getElementById("divArea").innerHTML= xmlHttp.responseText;
	}
}

function DisplaySearch(){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return
	} 
	page = window.document.getElementById("selSearch").value
	endlimit = (page-1)*20
	var url="modules.php?name=Search"
	url=url+"&PropertyType="+window.document.getElementById("txtType").value
	
	if(window.document.getElementById("txtAll").value != ""){
		url=url+"&AreaCode=All Listings"
	}else{
		url=url+"&saleStatus="+window.document.getElementById("txtStatus").value	
	}
	
	url=url+"&end_limit="+endlimit+"&page="+window.document.getElementById("selSearch").value
	url=url+"&curr_start_page=1"
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedSearch
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedSearch() 
{ 
	if (xmlHttp.readyState==1)
	{ 														    
		document.getElementById("txtHint").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/AJAXConnect.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		text = xmlHttp.responseText.split("<span id=\"spnTest\">");
		actual_text = text[1].split("<span id=\"endTest\">");
        document.getElementById("txtHint").innerHTML=actual_text[0];
	}
}


function FetchAddress(){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return;
	} 
	postalCode = window.document.getElementById("txtPostal").value;

	
	var url="http://www.sporeproperties.com/map/getPostalAddress.php?pc="+postalCode;
	
	xmlHttp.onreadystatechange=stateFetchAddress;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function stateFetchAddress() 
{ 	
	if (xmlHttp.readyState==1)
	{ 														    
		window.document.getElementById("divFetchAddress").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/loadingbar.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		window.document.getElementById("divFetchAddress").innerHTML="";
		  var xmlDocument = xmlHttp.responseXML;
		  window.document.getElementById("txtAddress").value =xmlDocument;
	      foundadd = xmlDocument.getElementsByTagName('add').item(0).firstChild.data;
	      foundlat = xmlDocument.getElementsByTagName('lat').item(0).firstChild.data;
	      foundlng = xmlDocument.getElementsByTagName('lng').item(0).firstChild.data;
		  window.document.getElementById("txtAddress").value = foundadd;
		  window.document.getElementById("txtLat").value = foundlat;
		  window.document.getElementById("txtLng").value = foundlng;
	}
}


function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
	  objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
	  objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}


function SubmitText(status, type){ 
	window.document.getElementById("saleStatus").value = status
	window.document.getElementById("PropertyType").value = type
	window.document.frmSub.submit()
	
}

function Change(title){
	if (window.document.getElementById("div" + title).style.display==""){
		window.document.getElementById("div" + title).style.display="none";
	}else{
		window.document.getElementById("div" + title).style.display="";
	};
}

function DisplayAgent(){
	window.document.getElementById("divAgentUse").style.display= "";
}
		
function HideAgent(){
	window.document.getElementById("divAgentUse").style.display= "none";
	window.document.getElementById("divAgentInfor").style.display= "none";
	}
		
function ShowAgentInfo(){
	window.document.getElementById("divAgentInfor").style.display= "";
}
		
function HideAgentInfo(){
	window.document.getElementById("divAgentInfor").style.display= "none";
}
		
function ShowUnit(){
	Type = window.document.getElementById("selStatus").value;
	if(Type == 'For Rent'){
		window.document.getElementById("divUnit").style.display= "";
		window.document.getElementById("divUnitLabel").style.display= "";
	}else{
		window.document.getElementById("divUnit").style.display= "none";
		window.document.getElementById("divUnitLabel").style.display= "none";
	}

}		
		
        //
		// Display the Property Detail in a modeless window
		//
		/*
function ViewProperty(linkage){
	window.showModalDialog("http://$LINK/modules.php?name=ViewProperty&action=view&" + linkage ,"Your Property Listing", "dialogWidth:800px,dialogHeight:600px,dialogTop:150px,dialogLeft:150px,resizable:yes,meunbar:no,toolbar:no,status:no");
}
		
function EditProperty(linkage){
			  window.open("http://$LINK/modules.php?name=ViewProperty&action=edit&" + linkage ,null, "Width=800px,Height=400px,Top=150px,Left=150px,scrollbars=yes,resizable=yes,meunbar=no,toolbar=no,status=no");
		}
  */      
        function Show(){
		var temp;
		temp = window.document.getElementById("divFlash").style.display;
			if (temp == "none"){
				window.document.getElementById("divFlash").style.display= "";
		      window.document.getElementById("indicate").innerText="[ON]";
			}else{
				window.document.getElementById("divFlash").style.display="none";
		      window.document.getElementById("indicate").innerText="[OFF]";
			}
		}
       
  		function limitText(limitNum){
       	   var textTemp;
     	   textTemp = document.getElementById("txaDescription").value;

     		if (document.getElementById("txaDescription").value.length > limitNum) {
		 		document.getElementById("txaDescription").value = textTemp.substring(0, limitNum);
			} else {
				document.getElementById("txtcountdown").value = limitNum - document.getElementById("txaDescription").value.length;
			}
		}
	
	    function PostHotDeal(){
	        document.frmHotDeal.submit();
	    }
	    
        function PostForm()
        {
            temp =0; 
            var errors =""; 
            
	         // Check for the Rental
			if(window.document.getElementById("selStatus").value == 'For Rent')
			{
	     	   if(window.document.getElementById("selUnitRoom").value == '')
	     	   {
			       temp+=1;
				   //alert("Please select the Unit");
				   errors = errors + "Please Select the Unit\n"; 
				}
			}

	        //Check txtAddress
	          if (window.document.getElementById("txtAddress").value =="") 
	          {
	              window.document.getElementById("txtAddress").className = "wrong_info";
	              temp +=1;
	              errors = errors + "Please Enter Address\n";
	          }
	          else
	          {
	              window.document.getElementById("txtAddress").className = "right_info";
	          }
	          
	        // Check txtBlk
	      /*    if (window.document.getElementById("txtBlk").value =="" || window.document.getElementById("txtBlk").value !="0")
	          {
	              window.document.getElementById("txtBlk").className = "wrong_info";
	              temp +=1;
                  errors = errors + "Please Enter Blk/Hse Number\n"; 
	          }
	          else
	          {
	              window.document.getElementById("txtBlk").className = "right_info";
	          }
			*/
	        //Check txtLevel
	          if (window.document.getElementById("txtLevel").value =="")
	          {
	              window.document.getElementById("txtLevel").className = "wrong_info";
	              temp +=1;
	              errors = errors + "Please Enter Unit Level\n"; 
	          }
	          else
	          {
	              window.document.getElementById("txtLevel").className = "right_info";
	          }
	        
	          if (isNaN(window.document.getElementById("txtLevel").value)){
	             //alert('Please Enter Number only for Level')
	             temp +=1;
	             errors = errors + "Please Enter Number only for Level\n"; 
	          }
	
	        // Check Unit
	          if (window.document.getElementById("txtUnit").value =="")
	          {
	              window.document.getElementById("txtUnit").className = "wrong_info";
	              temp +=1;
	              errors = errors + "Please Enter Unit Number\n"; 
	          }
	          else
	          {
	              window.document.getElementById("txtUnit").className = "right_info";
	          }
	        
	          // Comments : Possible there is char in unit number.
	          /**
	          if (isNaN(window.document.getElementById("txtUnit").value)){
	             alert('Please Enter Number only for Unit')
	             temp +=1;
	          }
	          **/
	          
	          // Check Postal
	          if (window.document.getElementById("txtPostal").value =="")
	          {
	              window.document.getElementById("txtPostal").className = "wrong_info";
	              temp +=1;
	              errors = errors + "Please Enter Postal Code\n"; 
	          }
	          else
	          {
	              window.document.getElementById("txtPostal").className = "right_info";
	          }
	        
	          if (isNaN(window.document.getElementById("txtPostal").value)){
	             //alert('Please Enter Number only for Postal Code')
	             temp +=1;
	             errors = errors + "Please Enter Number only for Postal Code\n";
	          }
	          
	           // Check Price
	          if (window.document.getElementById("txtAsk").value =="")
	          {
	              window.document.getElementById("txtAsk").className = "wrong_info";
	              temp +=1;
	              errors = errors + "Please Enter Asking Price\n";
	          }
	          else
	          {
	              window.document.getElementById("txtAsk").className = "right_info";
	          }
	        
	          if (isNaN(window.document.getElementById("txtAsk").value))
	          {
	              temp +=1;
	              errors = errors + "Please Enter Number only for Asking Price\n";
	          }
	          /** 
	          // Check selMap
	          if (window.document.getElementById("selMap").value =="")
	          {
	              window.document.getElementById("selMap").className = "wrong_info";
	              temp +=1;
	              errors = errors + "Please Select AddMap Option\n"; 
	          }
	          else
	          {
	              window.document.getElementById("selMap").className = "right_info";
	          }
	          
	         
	          // Check selMap
	           if (window.document.getElementById("selType").value =="Blank")
	          {
	              window.document.getElementById("selType").className = "wrong_info";
	              temp +=1;
	              errors = errors + "Please Select AddMap option\n"; 
	          }
	          else
	          {
	             window.document.getElementById("selType").className = "right_info";
	          }
              **/
              
              // Check selTour
	          if (window.document.getElementById("selTour").value =="")
	          {
	              window.document.getElementById("selTour").className = "wrong_info";
	              temp +=1;
	              errors = errors + "Please Select 3D Tour option\n";
	          }
	          else
	          {
	              window.document.getElementById("selTour").className = "right_info";
	          }
	          
	          
	          // Check Poster Type
	          if (window.document.getElementById("selPosterType").value =="")
	          {
	              window.document.getElementById("selPosterType").className = "wrong_info";
	              temp +=1;
	              errors = errors + "Please Select Poster As option\n";
	          }
	          else
	          {
	              window.document.getElementById("selPosterType").className = "right_info";
	          }
	                    
	        
	          // Check Area Code
	         
	          if (window.document.getElementById("txtAreaCode").value == "")
	          {
	              window.document.getElementById("selAreaCode").className = "wrong_info";
	              window.document.getElementById("selLandedCode").className = "wrong_info";
		       	  temp +=1;
		       	  errors = errors + "Please Select Area Code option\n";
	          }
	          else 
	          {
	              window.document.getElementById("selAreaCode").className = "right_info";
	         	  window.document.getElementById("selLandedCode").className = "right_info";
	          }
	   
	          
	          if(temp==0)
	          { 
	          	
	              window.document.frmPostProperty.submit();
	          }
	          
	          if (errors != "")
              {
                  alert (errors);
              }
        }

		function Negotiable()
		{
		  if (window.document.getElementById("txtNeg").value == ""){
		     window.document.getElementById("txtNeg").value= "(Neg)";
		  }else{
		     window.document.getElementById("txtNeg").value= "";
		  }
		}

       function PropertyChoice(choice)
        {
         
          var tigger;
          var i;
            	window.document.getElementById("selAreaCode").value ="";
            	window.document.getElementById("selLandedCode").value ="";
              window.document.getElementById("txtAreaCode").value = "";  
              
        	/** This always clear the entry for the property. If the user enters info about the 
        	 *  HDB first, then he wants to change property type to condominium so he choose another 
        	 *  property type. So must erase the pervious information about the HDB
        	**/
        		window.document.getElementById("txtAddress").value="";
        		window.document.getElementById("txtBlk").value="";
        		window.document.getElementById("txtLevel").value="";
        		window.document.getElementById("txtUnit").value="";
        		window.document.getElementById("txtPostal").value="";
        		window.document.getElementById("txtAsk").value="";
        		window.document.getElementById("chkNego").checked="";
        		window.document.getElementById("txtValuation").value="";
        		window.document.getElementById("txtPsf").value="";
        		window.document.getElementById("txtPropAge").value="";
        		window.document.getElementById("selBedroom").value="--------";
        		window.document.getElementById("selBathroom").value="--------";
        		window.document.getElementById("selTenure").value="--------";
        		window.document.getElementById("selAircon").value="--------";
        		window.document.getElementById("selFurnish").value="--------"
        		window.document.getElementById("selLift").value="--------";
        		window.document.getElementById("txaDescription").value="";
        		window.document.getElementById("txaRemarks").value="";
              window.document.getElementById("txtAmenities").value ="";	
        
        		for(i=1; i<= document.all.item("Amenities").length; i++){
        			document.all.item("chk" + i).checked = "";	
        		}
        
              window.document.getElementById("txtPropertyType").value = choice;
              window.document.getElementById("divGeneral").style.display="";
    	      window.document.getElementById("divImage").style.display="";
              window.document.frmPostProperty.selType.selected ="Select One";
              window.document.frmPostProperty.selAreaCode.selected ="Select One";
        
    	      window.document.frmPostProperty.selType.options[0].text = "Select One";
                  if (tigger=="radLanded"){
                      window.document.getElementById("spnUnit").style.display="none";
                      window.document.getElementById("spnUnitWord").style.display="none";
                  }else{
                      window.document.getElementById("spnUnit").style.display="";
                      window.document.getElementById("spnUnitWord").style.display="";
                  }

          if (choice=="Condominium"){
               window.document.getElementById("divCondo").style.display="";
        	      window.document.getElementById("divCondoProject").style.display="";
        	  }else{
                 window.document.getElementById("divCondo").style.display="none";
        		  window.document.getElementById("divCondoProject").style.display="none";
        	  }

             switch(choice)
            {
              case "HDB":
             		window.document.getElementById("divAreaCode").style.display="";
  		     		window.document.getElementById("divLandedCode").style.display="none";
                  window. document.frmPostProperty.selType.length=8;
        		    window.document.frmPostProperty.selType.options[1].text = "1-Room";
        		    window.document.frmPostProperty.selType.options[2].text = "2-Room";
        	   		window.document.frmPostProperty.selType.options[3].text = "3-Room";
        	  		window.document.frmPostProperty.selType.options[4].text = "4-Room";
        	   		window.document.frmPostProperty.selType.options[5].text = "5-Room";
              		window.document.frmPostProperty.selType.options[6].text = "HUDC";
              		window.document.frmPostProperty.selType.options[7].text = "Others";
        	       break;
               case "Condominium":
		     		window.document.getElementById("divAreaCode").style.display="none";       
		     		window.document.getElementById("divLandedCode").style.display="";        
        			window. document.frmPostProperty.selType.length=13;
             		window.document.frmPostProperty.selType.options[1].text = "Studio";
             		window.document.frmPostProperty.selType.options[2].text = "2 Bedrooms";
             		window.document.frmPostProperty.selType.options[3].text = "2 + 1 Bedrooms";
             		window.document.frmPostProperty.selType.options[4].text = "3 Bedrooms";
             		window.document.frmPostProperty.selType.options[5].text = "3+1 Bedrooms";
            		window.document.frmPostProperty.selType.options[6].text = "4 Bedrooms";
          		    window.document.frmPostProperty.selType.options[7].text = "4 +1 Bedrooms";
         	    	window.document.frmPostProperty.selType.options[8].text = "5 Bedrooms";
        	        window.document.frmPostProperty.selType.options[9].text = "5+1 Bedrooms";
        	        window.document.frmPostProperty.selType.options[10].text = "6 Bedrooms";
        	        window.document.frmPostProperty.selType.options[11].text = "6+1 Bedrooms";
        	        window.document.frmPostProperty.selType.options[12].text = "Others";
        	     break;
              case "Commercial":
		     		window.document.getElementById("divAreaCode").style.display="";
		     		window.document.getElementById("divLandedCode").style.display="none";		
        	        window. document.frmPostProperty.selType.length=9;
                  window.document.frmPostProperty.selType.options[1].text = "Conservation";
              	window.document.frmPostProperty.selType.options[2].text = "Factory";
              	window.document.frmPostProperty.selType.options[3].text = "Office";
              	window.document.frmPostProperty.selType.options[4].text = "Restaurant";
              	window.document.frmPostProperty.selType.options[5].text = "Shop";
              	window.document.frmPostProperty.selType.options[6].text = "Shop House";
              	window.document.frmPostProperty.selType.options[7].text = "Warehouse";
              	window.document.frmPostProperty.selType.options[8].text = "Others";
              break;
              case "Landed":
		     		window.document.getElementById("divAreaCode").style.display="none";       
		     		window.document.getElementById("divLandedCode").style.display="";
                  window. document.frmPostProperty.selType.length=7;
                  window.document.frmPostProperty.selType.options[1].text = "Bungalow";
                  window.document.frmPostProperty.selType.options[2].text = "Semi Detached";
            		window.document.frmPostProperty.selType.options[3].text = "Terrace Intermediate";
        	        window.document.frmPostProperty.selType.options[4].text = "Terrace Corner";
        	     	window.document.frmPostProperty.selType.options[5].text = "Townhouse";
                  window.document.frmPostProperty.selType.options[6].text = "Others";
              break;
           }
         }
         function ConfirmDeleteAd(link){
			var Selection = confirm("Are you sure you want to delete?");
		 	
			if (Selection == true){
			 	window.location.href = link; //for both window and netscape 
				//window.showModelessDialog(link);
			}
		}
		
		function RenewAds(link){
			window.showModalDialog(link, "Listing Renew", "dialogHeight: 250px; dialogWidth: 300px; dialogTop: 150px; dialogLeft: 250px; edge: Raised; center: Yes; resizable: No; status: No;");
		 	window.location.reload();
		}
		
		function MassMailer(link){
		 	window.location.href = link; //for both window and netscape 
		}
		
		function OpenWin(link){
			 
			window.open(link, "_blank", "top=200,left=100,menubar=no,width=700,scrollbars=yes,height=500 ");
		}
		
		function OpenNotice(){
			window.open("notice.html", "_blank", "menubar=no,width=400,scrollbars=no,height=400 ");
		}
		
		function GoToCat(link){
			window.location.href = link;
		}
		
		function CheckGotCheck(){
	//		if (document.frmNewProduct.chkIAgree.checked === false){
			var temp=0;
			if (temp == 0){
				window.alert("Please read the terms and conditions");
			}
		}
		
		function CheckHotDeal(){
		    if(document.frmHotDeal.chkIAgree.checked == true){
		       window.document.getElementById("btnSubmit").style.display="";
		    }else{
		       window.document.getElementById("btnSubmit").style.display="none";
		    }
		}	
		
		
		function Check(){
			if (document.frmPostProperty.chkIAgree.checked == true) {
				window.document.getElementById("btnOk").style.display ="none";	
				window.document.getElementById("Submit").style.display = "";
			}else{
				window.document.getElementById("btnOk").style.display="";	
				window.document.getElementById("Submit").style.display = "none";
			}
		}
		
        function SearchNow(link){
     		window.location.href = link;
     	}// JavaScript Document
     	
     	var CurrentTabPage = 1;
     	
     	function ShowTabbed(element){
	        window.document.getElementById("spn_" + element).className = "TabPageShow";
	     	//alert(window.document.getElementById("spn_1").className);
	        window.document.getElementById("div_" + element).className = "show";
	     	if(element == 6){
		     	changeToAgentMap()	
	     	}
	     	if(element == 5){
		      	displayVR()	
	     	}
	     	HideTabbed(element);
	     	CurrentTabPage=element;
     	}
     	
     	function HideTabbed(toHide){
	     	if(CurrentTabPage == toHide){
		     	//window.document.getElementById("spn_" + CurrentTabPage).className = "TabPageShow";
	     	}else{
		     	window.document.getElementById("spn_" + CurrentTabPage).className = "TabPageHide";
		   		window.document.getElementById("div_" + CurrentTabPage).className = "hide";
	       		
     		}
	     	
     	}	
     	
	function ShowTabbedMainPage(element){
     		currentFeatured=1;
     		currentCondo=1;
	        window.document.getElementById("spn_" + element).className = "TabPageShow";
	     	//alert(window.document.getElementById("spn_1").className);
	        window.document.getElementById("div_" + element).className = "show";
	     	HideTabbedMainPage(element);
	     	CurrentTabPage=element;
	    /* 	
	     	switch(element){
	     		case '1':
	     		case '2':
	     				DisplayNewVideos();
	     				break;
	     		case '3':
	     				DisplayNewLaunch();
	     				break;
	     		case '4':
	     				DisplayFeatureAds();
	     				break;
	     	}*/
     		if(element == 2){
     			DisplayNewVideos();
     		}
     		if(element == 3){
     			DisplayNewLaunch();
     		}
     		if(element == 4){
     			DisplayFeatureAds();
     		}
     		
     	
     	}
     	
     	function HideTabbedMainPage(toHide){
          	if(CurrentTabPage == toHide){
		     	//window.document.getElementById("spn_" + CurrentTabPage).className = "TabPageShow";
	     	}else{
		     	window.document.getElementById("spn_" + CurrentTabPage).className = "TabPageHide";
		   		window.document.getElementById("div_" + CurrentTabPage).className = "hide";
	       		
     		}
	     	
     	}	     	

function PutAreaCode(){
		    var tiggerArea
		    tiggerArea = window.document.getElementById("selAreaCode").value
		    window.document.getElementById("txtAreaCode").value = tiggerArea
		} 
function PutLandedCode(){
		    var tiggerArea
		    tiggerArea = window.document.getElementById("selLandedCode").value
		    window.document.getElementById("txtAreaCode").value = tiggerArea
		} 

function PropertyNotify(){
	
	var choice ="";
	 
	choice = window.document.getElementById("selEstateType").value;
 			switch(choice)
            {
              case "HDB":
             		window.document.getElementById("divAreaCode").style.display="";
  		     		window.document.getElementById("divLandedCode").style.display="none";
  		     		break;
           	  case "Condominium":
		     		window.document.getElementById("divAreaCode").style.display="none";        
		     		window.document.getElementById("divLandedCode").style.display="";   
					 break;    
        	  case "Commercial":
		     		window.document.getElementById("divAreaCode").style.display="";
		     		window.document.getElementById("divLandedCode").style.display="none";
					 break;		
        	  case "Landed":
		     		window.document.getElementById("divAreaCode").style.display="none";      
		     		window.document.getElementById("divLandedCode").style.display="";
		     		break;
            }
             
}


// ***************************************New Added on 30/10/2006
function DisplayNewLaunch(){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return
	}
	
	var url="http://www.sporeproperties.com/MainTabbed/MainTab3.php"
	xmlHttp.onreadystatechange=stateDisplayNewLaunch
	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}
function stateDisplayNewLaunch() 
{ 
	if (xmlHttp.readyState==1)
	{
		//window.document.getElementById("div_3").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/AJAXConnect.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		window.document.getElementById("div_3").innerHTML =xmlHttp.responseText;
  	}
}


function ChangeLaunch(LaunchId,counter){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return
	}
	if(currentCondo == counter){
		//window.document.getElementById("sel_"+currentCondo).className = '';
	}else{
		window.document.getElementById("sel_"+counter).className = 'MainTabSelected';
		window.document.getElementById("sel_"+currentCondo).className = '';
		
		currentCondo = counter;
	}	
	
	var url="http://www.sporeproperties.com/MainTabbed/MainTab3_sub.php?LId=" + LaunchId
	xmlHttp.onreadystatechange=stateChangeLaunch
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}
function stateChangeLaunch() 
{ 

	if (xmlHttp.readyState==1)
	{
		//window.document.getElementById("div_MainTab3Main").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/AJAXConnect.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
	      window.document.getElementById("div_MainTab3Main").innerHTML =xmlHttp.responseText;
        
	}
}

// For Div_2
function DisplayNewVideos(){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return
	}
	
	var url="http://www.sporeproperties.com/MainTabbed/MainTab2.php"
	xmlHttp.onreadystatechange=stateShowVideos
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}
function stateShowVideos() 
{ 
	if (xmlHttp.readyState==1)
	{
		//window.document.getElementById("div_2").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/AJAXConnect.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		window.document.getElementById("div_2").innerHTML =xmlHttp.responseText;
 	}
}

// For Div_4
function DisplayFeatureAds(){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return
	}
	
	var url="http://www.sporeproperties.com/MainTabbed/MainTab4.php"
	xmlHttp.onreadystatechange=stateDisplayFeatureAds
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}
function stateDisplayFeatureAds() 
{ 
	if (xmlHttp.readyState==1)
	{
		//window.document.getElementById("div_4").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/AJAXConnect.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		window.document.getElementById("div_4").innerHTML =xmlHttp.responseText;
 	}
}


function ChangeFeatured(Id,counter){
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	  alert ("Browser does not support HTTP Request")
	  return
	}
	
	if(currentFeatured != counter){
		window.document.getElementById("selFeature_"+counter).className = 'MainTabSelected';
		window.document.getElementById("selFeature_"+currentFeatured).className = '';
		currentFeatured = counter;
	}	
	
	var url="http://www.sporeproperties.com/MainTabbed/MainTab4_sub.php?FId=" + Id
	xmlHttp.onreadystatechange=stateChangeFeatured
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}
function stateChangeFeatured() 
{ 
	if (xmlHttp.readyState==1)
	{
		//window.document.getElementById("div_MainTab4Main").innerHTML="<img src='http://www.sporeproperties.com/themes/Anagram/images/AJAXConnect.gif'>";
	}else if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
      	window.document.getElementById("div_MainTab4Main").innerHTML =xmlHttp.responseText;
    }
}

function OpenVideoViewer(Id, type){
window.open("http://www.sporeproperties.com/MainTabbed/VideoViewer.php?Id="+Id+"&Type="+type, "", "toolbar=no,width=380,height=425,left=150,top=150,resizable=no");
}


//************************************************************





function SendMails(){
	var Selection = confirm("Disclaimer: I acknowledge and agree to the Terms and Condition of use.");
	if (Selection == true){
		window.document.frmSendMail.submit();
	}
}


function ShowHelp(obj,field,hide)
{
	//Get help object
	var helpObj;
	
	helpObj = window.document.getElementById(field+"_help");

	
		//if help object is shown, hide it ; if object hidden, show it
		if (hide){
		  helpObj.style.display = "none";
		  }
		else{
		  helpObj.style.display = "";
		  }

		//Get location of mouseover object, move help object to the left if will display off-screen
		var divWidth = 340;
		var offsetLeft = getOffsetLeft(obj);
		var screenWidth = (window.innerWidth) ? window.innerWidth - 25 : document.body.clientWidth;
		
		if ((offsetLeft + divWidth) > screenWidth) offsetLeft = screenWidth - divWidth;
		newX = offsetLeft;
	
		//Get location of mouseover object, move help object on top if will display off-screen
		var divHeight = helpObj.offsetHeight;
		var offsetTop = getOffsetTop(obj) + obj.offsetHeight;
		var screenHeight = (window.innerHeight) ? window.innerHeight - 25 : document.body.clientHeight;
		if ((offsetTop + divHeight) > screenHeight + getScrollY()) offsetTop = getOffsetTop(obj) - divHeight;
		newY = offsetTop;	
	
		helpObj.style.top = newY-20;
		helpObj.style.left = newX+10;

}

function getOffsetLeft (elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;}
	return mOffsetLeft;
}

function getOffsetTop (elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) {
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;}
	return mOffsetTop;
}

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape
    scrOfY = window.pageYOffset;}
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM
    scrOfY = document.body.scrollTop;}
  else if( document.documentElement &&
      ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6
    scrOfY = document.documentElement.scrollTop;}
  return scrOfY;
}