﻿// JScript File

var propBuzzMapWnd = null;
var propStaticMapWnd = null;

//Allows only numeric values to be entered into the Textbox
function AllowNumeric(textbox)
{
    if(textbox.value.indexOf('.') != -1)
    {
        //ascii code for '.'
        if(event.keyCode == 46){return false;}
        else{return true;}
    }
}

function AllowNumeric(textbox,numbertype)
{
   var bool = true;
   switch(numbertype)
    {
        //Whole Number 
        case 1:
            if(event.keyCode >= 48 && event.keyCode <= 57) {bool = true;}
            else{bool = false;}
        break;

        //Decimal
        case 2:
           if((event.keyCode >= 48 && event.keyCode <= 57) || event.keyCode == 46) {bool = true;}
           else{bool = false;}
           
           if(bool)
           {
                if(textbox.value.indexOf('.') != -1)
                {
                    //ascii code for '.'
                    if(event.keyCode == 46){bool = false;}
                    else{bool = true;}
                }
                else{bool=true;}
            }
        break;   
   }
   
   return bool;
} 

//Quantity box will be re-set to 0 if user left it blank
function QuantityValidation(textbox)
{
    if(textbox.value == "")
    {
        textbox.value = "0";
    } 
}


function TextCase(textbox,texttype)
{
    if(event.keyCode >= 65 && event.keyCode <= 90)
    {
        switch(texttype)
        {
            case "LowerCase":
                textbox.value = textbox.value.toLowerCase();
            break;
            case "UpperCase":
                textbox.value = textbox.value.toUpperCase();
            break;  
        }
    }
}


function NewWindow(URL, Target, width, height, toolbar) 
{ 
    if (Target == "") { Target = "_blank"; }
    if (width == 0) { width = 800; }
    if (height == 0) { height = 600; }
    
    window.open(URL,Target,"width=" + width + ",height=" + height + ",toolbar=" + toolbar); 
    //var a = window.setTimeout("document.form1.submit();",500); 
} 


// Load Page Into Parent Window
// Version 1.0
// Last Updated: May 18, 2000
// Code maintained at: http://www.moock.org/webdesign/javascript/
// Copy permission granted any use provided this notice is unaltered.
// Written by Colin Moock.
function loadinparent(url, closeSelf){
	self.opener.location = url;
	if(closeSelf) self.close();
	}
	
	
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) { //v3.0
  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); 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 roll(img_name1, img_src1, img_name2, img_src2)
   {
   document[img_name1].src = img_src1;
   document[img_name2].src = img_src2;
   }
   
   function OpenPropBuzzMapWindow(p,property_name,type,o)
    {
	    x = (screen.availWidth/2) - (730/2);
	    y = (screen.availHeight/2) - (530/2) - 20;
	    if (propBuzzMapWnd != null) propBuzzMapWnd.close();
    //	propBuzzMapWnd = open("http://www.streetdirectory.com/hdb/hdb.cgi?postalcode="+p+"&property_name="+property_name+"&type="+type+"&o="+o, "HDB", "width=730,height=530,scrollbars=yes,resizable=no,top="+y+",left="+x);
    //	propBuzzMapWnd = open("http://www.streetdirectory.com/place2lease/p2l_map.cgi?postalcode="+p, "HDB", "width=760,height=620,scrollbars=yes,resizable=no,top="+y+",left="+x);
    //	propBuzzMapWnd = open("http://www.street-directory.com/place2lease/routing.php?postalcode="+p, "HDB", "width=760,height=620,scrollbars=yes,resizable=yes,top="+y+",left="+x);
	    //propBuzzMapWnd = window.open("http://www.map.gov.sg/SD_LQ/INLIS_SD_EQUERY/SD/SDHomepage.aspx?strService=SD&strProduct=SD", "HDB", "width=760,height=620,scrollbars=yes,resizable=yes,top="+y+",left="+x);
	//   propBuzzMapWnd = window.open("AgencySearch/SLAAgencySearch.htm?AgencyID=7&SearchType=1&SearchKey="+property_name+"&SearchValue=" + p, "popupwindow", "status=0, toolbar=0, menubar=0, scrollbars=0, width=540, height=650, left=280, top=30");
    	

    propBuzzMapWnd = window.open("AgencySearch/SLAAgencySearch.htm?mWidth=800&mHeight=600&searchVal=" + p, "popupwindow", "status=0, toolbar=0, menubar=0, scrollbars=0, width=560, height=650, left=280, top=30");
    	


    }
	
	function OpenStaticMapWindow(schemeaccountno)
    {
	    x = (screen.availWidth/2) - (730/2);
	    y = (screen.availHeight/2) - (530/2) - 20;
	    if (propStaticMapWnd != null) propStaticMapWnd.close();
    //	propBuzzMapWnd = open("http://www.streetdirectory.com/hdb/hdb.cgi?postalcode="+p+"&property_name="+property_name+"&type="+type+"&o="+o, "HDB", "width=730,height=530,scrollbars=yes,resizable=no,top="+y+",left="+x);
    //	propBuzzMapWnd = open("http://www.streetdirectory.com/place2lease/p2l_map.cgi?postalcode="+p, "HDB", "width=760,height=620,scrollbars=yes,resizable=no,top="+y+",left="+x);
	    propStaticMapWnd = open("staticlocationmap.aspx?AccNo=" + schemeaccountno, "HDB", "width=760,height=620,scrollbars=yes,resizable=yes,top="+y+",left="+x);
    }
