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_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_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 ChangeBackgroundImage(objTD,newImg){
    objTD.style.background= 'url(' + newImg + ')';
}
function closePopup(){
    window.close();
}
function openPopup(url,w,h,name){
	var str = 'height=' + h + ', width=' + w + ', top=0, left=0, toolbar=0, menubar=0, scrollbars=1, resizable=0,location=0, status=1';
	var win=window.open(url,name,str);
	if (win=="undefined" || win==null)
	    alert("Your browser is having pop-up blocker, you have to allow the pop-ups to use our website");		
	else
	{
		if (window.focus) win.focus();
	}		
}


//subtype
psubtype=new Array(42);
psubtype[0]=new Array(1,1,"1-Room");
psubtype[1]=new Array(2,1,"2-Room");
psubtype[2]=new Array(3,1,"3S");
psubtype[3]=new Array(4,1,"3I");
psubtype[4]=new Array(5,1,"3NG");
psubtype[5]=new Array(6,1,"3A");
psubtype[6]=new Array(7,1,"3Room");
psubtype[7]=new Array(8,1,"4S");
psubtype[8]=new Array(9,1,"4I");
psubtype[9]=new Array(10,1,"4NG");
psubtype[10]=new Array(11,1,"4A");
psubtype[11]=new Array(12,1,"4Room");
psubtype[12]=new Array(13,1,"5S");
psubtype[13]=new Array(14,1,"5I");
psubtype[14]=new Array(15,1,"5A");
psubtype[15]=new Array(16,1,"5Room");
psubtype[16]=new Array(17,1,"EA");
psubtype[17]=new Array(18,1,"EM");
psubtype[18]=new Array(19,1,"JUMBO");
psubtype[19]=new Array(20,1,"EC");
psubtype[20]=new Array(21,2,"Apt");
psubtype[21]=new Array(22,2,"Condo");
psubtype[22]=new Array(23,2,"E.Condo");
psubtype[23]=new Array(24,2,"HUDC");
psubtype[24]=new Array(25,2,"Walkup");
psubtype[25]=new Array(26,2,"SvcApt");
psubtype[26]=new Array(26,2,"Terrace");
psubtype[27]=new Array(28,2,"Semi-D");
psubtype[28]=new Array(29,2,"Detached");
psubtype[29]=new Array(30,2,"Bungalow");
psubtype[30]=new Array(31,2,"House");
psubtype[31]=new Array(32,2,"ClustrHse");
psubtype[32]=new Array(33,2,"TownHse");
psubtype[33]=new Array(34,3,"Office");
psubtype[34]=new Array(35,3,"HDB Shop");
psubtype[35]=new Array(36,3,"Shop");
psubtype[36]=new Array(37,3,"ShopHse");
psubtype[37]=new Array(38,3,"WareHse");
psubtype[38]=new Array(39,3,"Factory");
psubtype[39]=new Array(40,3,"Lounge");
psubtype[40]=new Array(41,3,"Land");
psubtype[41]=new Array(42,4,"New Launches");
//loc
ploc=new Array(33);
ploc[0]=new Array(1,1,"AMK","Ang Mo Kio");
ploc[1]=new Array(2,1,"BEDOK","Bedok");
ploc[2]=new Array(3,1,"BISHAN","Bishan");
ploc[3]=new Array(4,1,"BBATOK","Bukit Batok");
ploc[4]=new Array(5,1,"BMERAH","Bukit Merah");
ploc[5]=new Array(6,1,"BPANJANG","Bukit Panjang");
ploc[6]=new Array(7,1,"BTIMAH","Bukit Timah");
ploc[7]=new Array(8,1,"CENTRAL","Central");
ploc[8]=new Array(9,1,"CCK","Choa Chu Kang");
ploc[9]=new Array(10,1,"CLEMENTI","Clementi");
ploc[10]=new Array(11,1,"GEYLANG","Geylang");
ploc[11]=new Array(12,1,"HOUGANG","Hougang");
ploc[12]=new Array(13,1,"JURONGE","Jurong East");
ploc[13]=new Array(14,1,"JURONGW","Jurong West");
ploc[14]=new Array(15,1,"KLG/WHPO","Kallang/Whampoa");
ploc[15]=new Array(16,1,"MP","Marine Parade");
ploc[16]=new Array(17,1,"PASRIS","Pasir Ris");
ploc[17]=new Array(18,1,"QTOWN","Queenstown");
ploc[18]=new Array(19,1,"SEM","Sembawang");
ploc[19]=new Array(20,1,"SNKG/PGL","Sengkang/Punggol");
ploc[20]=new Array(21,1,"SERANGN","Serangoon");
ploc[21]=new Array(22,1,"TMP/SMEI","Tampines/Simei");
ploc[22]=new Array(23,1,"TPAYOH","Toa Payoh");
ploc[23]=new Array(24,1,"WLANDS","Woodlands");
ploc[24]=new Array(25,1,"YISHUN","Yishun");
ploc[25]=new Array(26,2,"D1-8","City & South West");
ploc[26]=new Array(27,2,"D9-10","Orchard/Tanglin/Holland");
ploc[27]=new Array(28,2,"D11&21","Newton/Bukit Timah/Clementi");
ploc[28]=new Array(29,2,"D12-14","Balestier/Macpherson/Geylang");
ploc[29]=new Array(30,2,"D15-16","East Coast");
ploc[30]=new Array(31,2,"D17-18","Changi/Pasir Ris");
ploc[31]=new Array(32,2,"D19-20","Serangoon/Thomson");
ploc[32]=new Array(33,2,"D22-28","West & North");


function changeType(type,subtype,loc)
{
//alert('abc');
    var source;
  //  alert('333');
    source=document.getElementById(type);
    var obj;
    //alert('111');
    obj=document.getElementById(subtype);
    //alert('aa'+obj.options.length);
    obj.options.length=0;
    obj.options[0]=new Option('- Type -','0');
    var i=0;
    //alert('lenght='+psubtype.length);
    for (i=0;i<psubtype.length;i++)
    {
      //      alert(i);
            if (psubtype[i][1]==source.options[source.selectedIndex].value)
            {
                obj.options[obj.options.length]=new Option(psubtype[i][2],psubtype[i][0]);
            }
    }
   // alert('444');
    obj=document.getElementById(loc);
    obj.options.length=0;
    obj.options[0]=new Option('- Location -','0');
    for (i=0;i<ploc.length;i++)
    {    
        if (source.options[source.selectedIndex].value == "1")
       {
        if (ploc[i][1]==1)
            {
                obj.options[obj.options.length]=new Option(ploc[i][3],ploc[i][0]);
            }
       }
       else if (source.options[source.selectedIndex].value != "0") {        
        if (ploc[i][1]==2)
            {
                obj.options[obj.options.length]=new Option(ploc[i][3],ploc[i][0]);
            }
       }    
    }
}
