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];}
}

function ReplaceApostrophe()
{
	var key = window.event.keyCode;
	if (key == 39)
	{
		window.event.keyCode = 96;
		return;
	}
	else
	{
		return;
	}
}

function EnsureNumeric()
{
	//Function: To restrict the entry to numeric characters
	// Get ASCII value of key that user pressed
	var key = window.event.keyCode;

	// Was key that was pressed a numeric character (0-9)?
	if (key == 46)
	{
		return;		
	}
	else if ( key > 47 && key < 58 )
	{
		return; // if so, do nothing
	}
	else
	{
		window.event.returnValue = null; // otherwise, discard character
	}
}

function capitalizeMe(obj) 
{
	val = obj.value;
	newVal = '';
	val = val.split(' ');
	for(var c=0; c < val.length; c++) 
	{
		newVal += val[c].substring(0,1).toUpperCase() + val[c].substring(1,val[c].length) + ' ';
	}
	obj.value = newVal;
}

function Convert_Date(D_Date)
{
	var Date_Char, Final_Date_Char
	var Check_Char = D_Date.charAt(2);
	if (Check_Char == "/")
	{
		Date_Char = D_Date.split("/");
		Final_Date_Char = Date_Char[0];
		Final_Date_Char += "-";
		if(Date_Char[1] == "01")
		{
			Final_Date_Char += "JAN";
		}
		else if(Date_Char[1] == "02")
		{
			Final_Date_Char += "FEB";
		}
		else if(Date_Char[1] == "03")
		{
			Final_Date_Char += "MAR";
		}
		else if(Date_Char[1] == "04")
		{
			Final_Date_Char += "APR";
		}
		else if(Date_Char[1] == "05")
		{
			Final_Date_Char += "MAY";
		}
		else if(Date_Char[1] == "06")
		{
			Final_Date_Char += "JUN";
		}
		else if(Date_Char[1] == "07")
		{
			Final_Date_Char += "JUL";
		}
		else if(Date_Char[1] == "08")
		{
			Final_Date_Char += "AUG";
		}
		else if(Date_Char[1] == "09")
		{
			Final_Date_Char += "SEP";
		}
		else if(Date_Char[1] == "10")
		{
			Final_Date_Char += "OCT";
		}
		else if(Date_Char[1] == "11")
		{
			Final_Date_Char += "NOV";
		}
		else if(Date_Char[1] == "12")
		{
			Final_Date_Char += "DEC";
		}
		Final_Date_Char += "-";
		Final_Date_Char += Date_Char[2];
		
		return Final_Date_Char;
	}
	else if (Check_Char == "-")
	{
		return D_Date.toUpperCase();
	}
	else if (D_Date == "")
	{
		return "";
	}
	else
	{
		alert("Invalid Date! Please Use The Format DD/MM/YYYY or DD-MMM-YYYY");
		return "";
	}
}

function Remove_Company(ID)
{
	var D_Link;
	input_box=confirm("Are You Sure You Want To Remove This Link?");
	if (input_box == true)
	{ 
		D_Link = "Account_Links_Edit.asp?ID="
		D_Link += ID;
		D_Link += "&MODE=DEL";		
		document.form1.action = D_Link;
		document.form1.submit();
	}
}

function Add_Company(ID)
{
	var D_Link;
	input_box=confirm("Are You Sure You Want To Add This Link?");
	if (input_box == true)
	{ 
		D_Link = "Account_Links_Edit.asp?ID="
		D_Link += ID;
		D_Link += "&MODE=ADD";
		//alert(D_Link);
		document.form1.action = D_Link;
		document.form1.submit();
	}
}

function Check_ID_Input()
{
	var URL_Forward;
	if (document.frmMainPage.txtAdID.value.length > 4)
	{
		URL_Forward = "http://www.orangetee.com/"
		URL_Forward += document.frmMainPage.txtAdID.value;
		window.open(URL_Forward);
		document.frmMainPage.txtAdID.value = "";
	}
	else
	{
		alert("Your advertisement ID is invalid!");
		document.frmMainPage.txtAdID.value = "";
	}
}

function Listing_Search(cType)
{
	//alert("We ARe In");
	if(cType == "LS")
	{
		//alert("LS");
		document.getElementById("Listing_1").innerHTML = LS[0];
		document.getElementById("Listing_2").innerHTML = LS[1];
		document.getElementById("Listing_3").innerHTML = LS[2];
		document.getElementById("Listing_4").innerHTML = LS[3];
		document.getElementById("Listing_5").innerHTML = LS[4];
		document.getElementById("Listing_6").innerHTML = LS[5];
		
		URL_1 = LS_URL[0];
		URL_2 = LS_URL[1];
		URL_3 = LS_URL[2];
		URL_4 = LS_URL[3];
		URL_5 = LS_URL[4];
		URL_6 = LS_URL[5];
		URL_More = "buy/search_results.asp?Type=Landed+Property";
		
		document.getElementById("dLeaseSale_1").innerHTML = "Landed Property";
		document.getElementById("dLeaseSale_2").innerHTML = "For Sale";
	}
	else if (cType == "LL")
	{
		//alert("LL");
		document.getElementById("Listing_1").innerHTML = LL[0];
		document.getElementById("Listing_2").innerHTML = LL[1];
		document.getElementById("Listing_3").innerHTML = LL[2];
		document.getElementById("Listing_4").innerHTML = LL[3];
		document.getElementById("Listing_5").innerHTML = LL[4];
		document.getElementById("Listing_6").innerHTML = LL[5];
		
		URL_1 = LL_URL[0];
		URL_2 = LL_URL[1];
		URL_3 = LL_URL[2];
		URL_4 = LL_URL[3];
		URL_5 = LL_URL[4];
		URL_6 = LL_URL[5];		
		URL_More = "rent/search_results.asp?Type=Landed+Property";

		document.getElementById("dLeaseSale_1").innerHTML = "Landed Property";
		document.getElementById("dLeaseSale_2").innerHTML = "For Lease";
	}	
	else if (cType == "AS")
	{
		//alert("AS");
		document.getElementById("Listing_1").innerHTML = AS[0];
		document.getElementById("Listing_2").innerHTML = AS[1];
		document.getElementById("Listing_3").innerHTML = AS[2];
		document.getElementById("Listing_4").innerHTML = AS[3];
		document.getElementById("Listing_5").innerHTML = AS[4];
		document.getElementById("Listing_6").innerHTML = AS[5];
		
		URL_1 = AS_URL[0];
		URL_2 = AS_URL[1];
		URL_3 = AS_URL[2];
		URL_4 = AS_URL[3];
		URL_5 = AS_URL[4];
		URL_6 = AS_URL[5];			
		URL_More = "buy/search_results.asp?Type=Private+Apartment"

		document.getElementById("dLeaseSale_1").innerHTML = "Private Apartment";
		document.getElementById("dLeaseSale_2").innerHTML = "For Sale";
	}		
	else if (cType == "AL")
	{
		//alert("AL");		
		document.getElementById("Listing_1").innerHTML = AL[0];
		document.getElementById("Listing_2").innerHTML = AL[1];
		document.getElementById("Listing_3").innerHTML = AL[2];
		document.getElementById("Listing_4").innerHTML = AL[3];
		document.getElementById("Listing_5").innerHTML = AL[4];
		document.getElementById("Listing_6").innerHTML = AL[5];
		
		URL_1 = AL_URL[0];
		URL_2 = AL_URL[1];
		URL_3 = AL_URL[2];
		URL_4 = AL_URL[3];
		URL_5 = AL_URL[4];
		URL_6 = AL_URL[5];		
		URL_More = "rent/search_results.asp?Type=Private+Apartment"

		document.getElementById("dLeaseSale_1").innerHTML = "Private Apartment";
		document.getElementById("dLeaseSale_2").innerHTML = "For Lease";
	}			
	else if (cType == "HS")
	{
		//alert("HS");		
		document.getElementById("Listing_1").innerHTML = HS[0];
		document.getElementById("Listing_2").innerHTML = HS[1];
		document.getElementById("Listing_3").innerHTML = HS[2];
		document.getElementById("Listing_4").innerHTML = HS[3];
		document.getElementById("Listing_5").innerHTML = HS[4];
		document.getElementById("Listing_6").innerHTML = HS[5];
		
		URL_1 = HS_URL[0];
		URL_2 = HS_URL[1];
		URL_3 = HS_URL[2];
		URL_4 = HS_URL[3];
		URL_5 = HS_URL[4];
		URL_6 = HS_URL[5];		
		URL_More = "buy/search_results.asp?Type=HDB"

		document.getElementById("dLeaseSale_1").innerHTML = "HDB";
		document.getElementById("dLeaseSale_2").innerHTML = "For Sale";
	}			
	else if (cType == "HL")
	{
		//alert("HL");
		document.getElementById("Listing_1").innerHTML = HL[0];
		document.getElementById("Listing_2").innerHTML = HL[1];
		document.getElementById("Listing_3").innerHTML = HL[2];
		document.getElementById("Listing_4").innerHTML = HL[3];
		document.getElementById("Listing_5").innerHTML = HL[4];
		document.getElementById("Listing_6").innerHTML = HL[5];
		
		URL_1 = HL_URL[0];
		URL_2 = HL_URL[1];
		URL_3 = HL_URL[2];
		URL_4 = HL_URL[3];
		URL_5 = HL_URL[4];
		URL_6 = HL_URL[5];		
		URL_More = "rent/search_results.asp?Type=HDB"

		document.getElementById("dLeaseSale_1").innerHTML = "HDB";
		document.getElementById("dLeaseSale_2").innerHTML = "For Lease";	
	}		
	else if (cType == "CS")
	{
		//alert("CS");		
		document.getElementById("Listing_1").innerHTML = CS[0];
		document.getElementById("Listing_2").innerHTML = CS[1];
		document.getElementById("Listing_3").innerHTML = CS[2];
		document.getElementById("Listing_4").innerHTML = CS[3];
		document.getElementById("Listing_5").innerHTML = CS[4];
		document.getElementById("Listing_6").innerHTML = CS[5];
		
		URL_1 = CS_URL[0];
		URL_2 = CS_URL[1];
		URL_3 = CS_URL[2];
		URL_4 = CS_URL[3];
		URL_5 = CS_URL[4];
		URL_6 = CS_URL[5];		
		URL_More = "buy/search_results.asp?Type=Commercial"
		
		document.getElementById("dLeaseSale_1").innerHTML = "Commercial Property";
		document.getElementById("dLeaseSale_2").innerHTML = "For Sale";
	}			
	else if (cType == "CL")
	{
		//alert("CL");		
		document.getElementById("Listing_1").innerHTML = CL[0];
		document.getElementById("Listing_2").innerHTML = CL[1];
		document.getElementById("Listing_3").innerHTML = CL[2];
		document.getElementById("Listing_4").innerHTML = CL[3];
		document.getElementById("Listing_5").innerHTML = CL[4];
		document.getElementById("Listing_6").innerHTML = CL[5];
		
		URL_1 = CL_URL[0];
		URL_2 = CL_URL[1];
		URL_3 = CL_URL[2];
		URL_4 = CL_URL[3];
		URL_5 = CL_URL[4];
		URL_6 = CL_URL[5];
		URL_More = "rent/search_results.asp?Type=Commercial"

		document.getElementById("dLeaseSale_1").innerHTML = "Commercial Property";
		document.getElementById("dLeaseSale_2").innerHTML = "For Lease";
	}				
}

function Redirect_ID(cID)
{
	var D_URL;
	if(cID == "1")
	{
		D_URL = URL_1;
	}	
	else if(cID == "2")
	{
		D_URL = URL_2;
	}	
	else if(cID == "3")
	{
		D_URL = URL_3;
	}	
	else if(cID == "4")
	{
		D_URL = URL_4;
	}	
	else if(cID == "5")
	{
		D_URL = URL_5;
	}	
	else if(cID == "6")
	{
		D_URL = URL_6;
	}	
	
	window.open(D_URL);
}

function Redirect_ID_2()
{
	var D_URL;
	D_URL = "http://www.orangetee.com";
	D_URL += URL_2;
	window.open(D_URL);
}

function Redirect_ID_3()
{
	var D_URL;
	D_URL = "http://www.orangetee.com";
	D_URL += URL_3;
	window.open(D_URL);
}

function Redirect_ID_4()
{
	var D_URL;
	D_URL = "http://www.orangetee.com";
	D_URL += URL_4;
	window.open(D_URL);
}

function Redirect_ID_5()
{
	var D_URL;
	D_URL = "http://www.orangetee.com";
	D_URL += URL_5;
	window.open(D_URL);
}

function Redirect_ID_6()
{
	var D_URL;
	D_URL = "http://www.orangetee.com";
	D_URL += URL_6;
	window.open(D_URL);
}

function Redirect_More()
{
	var D_URL;
	D_URL = "https://www.orangetee.com/Visitor_Lounge/propertysearch/";
	D_URL += URL_More;
	window.open(D_URL);
}
