var printtext;
    var map;
    var geocoder;
   var gdir;
   var place;
   var bounds;
   var gmarkers = [];
   var k=0;
   var countryaddress=[];
      var pagingbackup="";
     var searchresstor="";
function initialize() {
      map = new GMap2(document.getElementById("map"));
		 map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
		geocoder = new GClientGeocoder();
            map.setCenter(new GLatLng(1.3463879115035189, 103.80294799804688), 11);
      bounds= map.getBounds();
	 
	  gdir = new GDirections(map, document.getElementById("resultdis"));
	  GEvent.addListener(gdir, "load", onGDirectionsLoad);
	     GEvent.addListener(gdir, "error", handleErrors);
      GEvent.addListener(map, "dragstart", function() {
          map.closeInfoWindow();
        });
GEvent.addListener(map, "dragend", function() {
          bounds= map.getBounds();
        

		 
        });
        
        GEvent.addListener(map, "zoomend", function() {
          bounds= map.getBounds();
        

		   
        });
		 map.enableScrollWheelZoom();
                 
	  }
          function onGDirectionsLoad(){ 
      

      
 document.getElementById("paging").style.display="none";
 
  document.getElementById("resultdis").style.height=500+"px";

	}

 var aspaccountrycodes="SG$";

var commonwords="about$near$nearto$leftto$rightto$opposite$in$at$street$avenue$atms$branches$branchs$citigold$roads";
var searchdone=false;
function trimSpace(x)
{
				var emptySpace = / /g;
				var trimAfter = x.replace(emptySpace,"");
				return(trimAfter);
}
function textValidate(incomingString, defaultValue)
{
if(trimSpace(incomingString).length == 0 || incomingString.search(/[^a-zA-Z\s ]/g) != -1 || incomingString==defaultValue)
{
   return false;
}
else
   return true;
}
function searchtextcheck(incomingString, defaultValue)
{
    if(trimSpace(incomingString).length == 0 || incomingString.search(/[^0-9a-zA-Z ]/g) != -1 || incomingString==defaultValue)
	 {
       return false;
     }

else

return true;

}
var stxtenter="";
function validate()
{
stxtenter="";
var tovalidate=1;
	if(trimSpace(document.map1.q.value).length==0)
	{
		alert("please enter text to search");
		document.map1.q.focus();
		
		tovalidate=0;
	}else  if(trimSpace(document.map1.q.value).length<4)
	{
		alert("please enter text to search");
		document.map1.q.focus();
		
		tovalidate=0;
	}
		else if(!searchtextcheck(document.map1.q.value,''))
	{
						alert("only alphabets,numbers are accepted");
                        document.map1.q.focus();
                        document.map1.q.select();
						tovalidate=0;
                        
	
	}
       /* if(trimSpace(document.map1.q.value).length<4)
	{
		alert("please enter text to search");
		document.map1.q.focus();
		
		tovalidate=0;
	}*/
        
	if(tovalidate==1)
	{
	if(!(document.map1.atm.checked)&&!(document.map1.branch_atm.checked)&&!(document.map1.gold_center.checked))
		{				 alert("Please choose atleast one  contact Point ")
                        document.map1.atm.focus();
                       
                   tovalidate=0;     
		}
	}

	if(tovalidate==1)
	{
		stxtenter=document.map1.q.value;
		var stxttopass121=stxtenter.replace(/ /g, "$");
			var stxttopass=stxttopass121.toLowerCase();
                
		var stxttopassar=[];
		stxttopassar=stxttopass.split('$');
		
		var lengthch=0;
		var stxttopassfn="";
		for(lengthch=0;lengthch<stxttopassar.length;lengthch++)
		{
		if(commonwords.indexOf(stxttopassar[lengthch])==-1)stxttopassfn+=stxttopassar[lengthch]+"$";
		}
                
		if(document.map1.atm.checked)
		stxttopassfn+='atm$';
		if(document.map1.branch_atm.checked)
		stxttopassfn+='branch$';
		if(document.map1.gold_center.checked)
		stxttopassfn+='citigold';
		
		
		
	markerforsr(stxttopassfn);
	}


}
var nearbycheck=false;
var nearbyloctext="";
var notaspac="";
function callgoogle(searchtxttogle)
{


if(nearbyloctext!=searchtxttogle)
{
nearbyloctext=searchtxttogle;
nearbycheck=true;
}
 if(nearbycheck)
 {notaspac="true";
 geocoder.getLocations(searchtxttogle+" Singapore", fndaddfromgo);
nearbycheck=false;
 }
 else
 {
 
 
    document.getElementById('searchheader').innerHTML ='<img src="images2/search_results.gif" alt="Search results"  title="Search results" />';
     document.getElementById("resultdis").innerHTML = "We're unable to find any match for \""+document.map1.q.value+"\". Please re-enter other details such as the street name or the postal code into the search box above.";
  document.getElementById("paging").style.display="none";
   document.getElementById("addldis").style.display="block";
  document.getElementById("addldis").innerHTML ="";
 }
 }
var addgotfromgle=[]
function fndaddfromgo(response)
{errhand=1;
var alladd="";
var ptxone="";
var ptyone="";
var resstone="";
var loc="en_US";
var relength=0;
var markincounl=0;

 if (!response || response.Status.code != 200) {
 
	       alladd="We're unable to find any match for \""+document.map1.q.value+"\". Please re-enter other details such as the street name or the postal code into the search box above.";
			printtext+="We're unable to find any match for \""+document.map1.q.value+"\". Please re-enter other details such as the street name or the postal code into the search box above.";
	
      } else {

 markincounl=response.Placemark.length;

alladd="<b>Did You Mean</b><br>";
	for(var resst=0;resst<markincounl;resst++)
        {
		
		placech = response.Placemark[resst];
			var selchoi="";
		var ptx=placech.Point.coordinates[1];
        var pty=placech.Point.coordinates[0];
						
			addgotfromgle[resst]=placech.address;
var countrycode="";
try{
			
                         countrycode=response.Placemark[resst].AddressDetails.Country.CountryNameCode;
}catch(e){

}
			if(aspaccountrycodes.indexOf(countrycode)!=-1)
			{notaspac=false;
                        ptxone=ptx;
                        ptyone=pty;
                        resstone=resst;
                        relength++;

	      alladd+='<a href=javascript:placeapprox("'+ptx+'","'+pty+'","'+resst+'","'+loc+'") class="linktxt" style="color:#0088DD;width:232px;">'+placech.address+'</a><br>';
		  }
                       
	   }
      }
       if(notaspac)notinaspaccheck=true;
      if(notaspac){ document.getElementById("resultdis").innerHTML = "We're unable to find any match for \""+document.map1.q.value+"\". Please re-enter other details such as the street name or the postal code into the search box above.";
      document.getElementById('searchheader').innerHTML ='<img src="images2/search_results.gif" alt="Search results"  title="Search results" />';
	        map.setCenter(new GLatLng(1.3463879115035189, 103.80294799804688), 11);
      }
	  else {
          if(relength==1)
          placeapprox(ptxone,ptyone,resstone,loc);
          else
          {
          document.getElementById("resultdis").innerHTML = alladd;
          document.getElementById('searchheader').innerHTML ='<img src="images2/search_results.gif" alt="Search results"  title="Search results" />';
		        map.setCenter(new GLatLng(1.3463879115035189, 103.80294799804688), 11);
          }
          }
  document.getElementById("paging").style.display="none";
 document.getElementById("addldis").style.display="block";
  document.getElementById("addldis").innerHTML ="";

}
var searchres="";
var geoaddlist=[];
var toprinaddls="";
var testpaging='';
var pagingloop=0;
var endind="";
var countryofmarker="";
function markerforsr(searchtxt)
   {  
       var mapbounds = new GLatLngBounds();
       nearbycheck=true;
   searchdone=true;
   toprinaddls="";
   pagingloop=0;
        printtext="";
   k=0;
   var lastpagest=1;
        map.clearOverlays();
		
		var request = GXmlHttp.create();
	    request.open("GET", "GetsrDataxml.jsp?ccode=sg&datareq="+searchtxt+"", true);
		request.onreadystatechange = function() {
		if (request.readyState == 4) 
		{
          var xmlDoc = GXml.parse(request.responseText);
          
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");
		  var result="";
		  if(markers.length==0)
			{
          
			callgoogle(document.map1.q.value);
			}result+='';
				    pagingloop=0;
			
			var category="";

		  for (var i = 0; i < markers.length; i++) 
			{
			k++;
			if( markers.length<=5)
			{
			 testpaging='<a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p>';
			}
			else{
			if(i%5==0)
			{
			var testind=i;
			if(testind>markers.length){endind=markers.length;}
			else {endind=i;}
			pagingloop++;
			testpaging+='';
			if(i!=0)
			{
                        
			result+="</div>";
			if(i==5){
			testpaging+='<div id="paging'+(pagingloop-1)+'" style="display:block"><a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p><p>'+(i-4)+' - '+endind+' of '+markers.length+'</p> <a href=javascript:pagecall("'+(pagingloop)+'")><img hspace="0" src="images2/next_blue.gif" alt="" align="left"  /></a></div>';
			lastpagest=lastpagest+5;
			}
			
			else
			{
			lastpagest=lastpagest+5;
			testpaging+='<div id="paging'+(pagingloop-1)+'" style="display:none"> <a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p><a href=javascript:pagecall("'+(pagingloop-2)+'")><img src="images2/left_icon.gif" alt="" hspace="0" align="left"  /></a> <p>'+(i-4)+' - '+i+' of '+markers.length+'</p><a href=javascript:pagecall("'+(pagingloop)+'")><img hspace="0" src="images2/next_blue.gif" alt="" align="left"  /></a></div>';
			}
			result+="<div id='"+pagingloop+"' style='display:none'>";
			}
			else
			result+="<div id='"+pagingloop+"' style='display:block'>";
			}
		 if((i+1)==(markers.length)){
             testpaging+='<div id="paging'+(pagingloop)+'" style="display:none"><a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p><a href=javascript:pagecall("'+(pagingloop-1)+'")><img src="images2/left_icon.gif" alt="" hspace="0" align="left"  /></a><p>'+lastpagest+' - '+markers.length+' of '+markers.length+'</p> </div>';
		 
		 }
			}
			var fnstind=endind+1;
	
			var newcategory="";
			newcategory=markers[i].getAttribute("category");
			toprinaddls+=markers[i].getAttribute("uniqueid")+'$';
			if(category!=newcategory)
				{
					category=newcategory;
					if(category=='Branch')
                                        result+='<img src="images2/branch.gif" alt="Branch" title="Branch"  />';
                                        else 	if(category=='Citigold')
					result+='<img src="images2/citigoldcentre.gif" alt="Citigold Centre" width="84" height="12" title="Citigold Centre"  />';
					else 	if(category=='ATM')
					result+='<img src="images2/atm.gif" alt="ATM" title="ATM"  />';printtext+="$"+category+"$";
                }
			var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
               
                if(i==0){ map.setCenter(new GLatLng(lat,lng),11);
				}
            var point = new GLatLng(lat,lng);
            var html = '<div style="width: 242px;  float:left" id="getdirdiv"><p class="address1" style="font-weight:normal;"><strong>'+markers[i].getAttribute("title")+'</strong><br />'+markers[i].getAttribute("Address")+'<br></p>  <div class="getdir"><div class="dirhead" ><strong>Get Directions:</strong></div><div class="toheredv" style="padding-bottom:6px;"> <a href="javascript:toshowtextb(\'1\',\''+i+'\');">To here</a><span style="float:left"> /&nbsp; </span> <a href="javascript:toshowtextb(\'2\',\''+i+'\');">From here </a></div>  <div style="visibility:; font-weight:normal;  " class="addressbox" id="quadd"><a target="_blank" href="http://www.citibank.com.">More details</a></div><div class="callnk" id="morediv" style="visibility:hidden;  "><a target="_blank" href="http://www.citibank.com.">More details</a></div></div>';
	
            geoaddlist[i]=markers[i].getAttribute("Geoaddress");
                        countryaddress[i]=markers[i].getAttribute("country");
            var label = markers[i].getAttribute("category");
			result+='<p  ><a href="javascript:myclick(\''+k+'\');" class="atmrow"><b>'+markers[i].getAttribute("title")+'</b><br>'+markers[i].getAttribute("Address")+'</a></p>';
			printtext+=markers[i].getAttribute("title")+" "+markers[i].getAttribute("Address")+"$";
                     var landmark=markers[i].getAttribute("landmark");

var timing= markers[i].getAttribute("timing");     
var bser= markers[i].getAttribute("bser");                     
var marker1 = createMarker(point,label,html,landmark,timing,bser);
            map.addOverlay(marker1);
				mapbounds.extend(marker1.getPoint());
        
			}
			
			result+='</p>'
		document.getElementById('searchheader').innerHTML ='<img src="images2/search_results.gif" alt="Search results"  title="Search results" />';
                        document.getElementById('resultdis').innerHTML =result+'<p style="height:1400px; "></p>';
	
			document.getElementById('paging').innerHTML =testpaging;
                        pagingbackup=testpaging;
	
searchres=document.getElementById("resultdis").innerHTML;
                        var resultfrtext=document.map1.q.value;
                        if(document.map1.atm.checked)
		resultfrtext+=',atm';
		if(document.map1.branch_atm.checked)
		resultfrtext+=',branch';
		if(document.map1.gold_center.checked)
		resultfrtext+=',citigold';
                        	document.getElementById('searchtext').innerHTML = "<p style='padding-bottom:14px;'><span style=' color:#333333 '>Results for:</span> "+resultfrtext+"</p>";
		CSBfleXcroll('dvOverflowContent');
		testpaging="";
		 document.getElementById("paging").style.display="block";
		  document.getElementById("addldis").innerHTML = "";
 document.getElementById("addldis").style.display="none";
 if(markers.length!=0){ 
  map.setZoom(map.getBoundsZoomLevel(mapbounds));

      map.setCenter(mapbounds.getCenter());
	 } else           map.setCenter(new GLatLng(1.3463879115035189, 103.80294799804688), 11);
                  }
		}
	  request.send(null);
	}
var addfrom="";
var addto="";
var addtono="";
var choicesel="";
function pagecall(pageno)
{

for(var jkl=1;jkl<=pagingloop;jkl++)
{
var paginno='paging'+jkl;
if(jkl==pageno){
document.getElementById(jkl).style.display="block";
document.getElementById(paginno).style.display="block";
}
else 
{
document.getElementById(jkl).style.display="none";
document.getElementById(paginno).style.display="none";

}
}
}
function toshowtextb(choice,no)
{
document.getElementById('getdirdiv').style.height=250+"px";
document.getElementById('quadd').style.visibility="visible";

if(choice=='2')
{
errhand="1";
addfromno=no;
choicesel=2;

document.getElementById("quadd").innerHTML='<span style="clear:both; ">End Address</span><br><input type=text name=frmaddto value="" onblur="valset(this.value)" class="dirtextbox"><input type=hidden name=frmaddfrom value=\''+no+'\' ><input type=button name=search value=find onclick=getd() class="btn">';
}
if(choice=='1')
{
errhand="1";
addtono=no;
choicesel=1;

document.getElementById("quadd").innerHTML='<span  style="clear:both; ">Start Address</span><br><input type=text name=frmaddfrom value="" onblur="valset1(this.value)" class="dirtextbox"><input type=hidden name=frmaddto value=\''+no+'\' ><input type=button name=search value=find onclick=getd() class="btn">';
}
document.getElementById('morediv').style.visibility="visible";
}

var searchaddir="";
function valset1(valu)
{
addfrom=valu;
searchaddir=valu;
addto=geoaddlist[addtono]
countryofmarker=countryaddress[addtono];
}

function valset(valu)
{
searchaddir=valu;
addto=valu;
addfrom=geoaddlist[addfromno]
countryofmarker=countryaddress[addfromno];
}

function KeyCheck(e,val)

{

   var KeyID = (window.event) ? event.keyCode : e.keyCode;

if(KeyID==13)
{
valset(val);
getd();
}   
}
function KeyCheck1(e,val)

{

   var KeyID = (window.event) ? event.keyCode : e.keyCode;

if(KeyID==13)
{
valset1(val);
getd();
}   
}
var samecountrycheck="false";
var errorondir=0;
var textondirloc="";
  var markercountryale="";
function getd()
{

markercountryale="";
samecountrycheck="false";


errorondir=1;
if(choicesel==1)
{
addfrom=document.getdir1.frmaddfrom.value;
searchaddir=document.getdir1.frmaddfrom.value;
addto=geoaddlist[addtono]
countryofmarker=countryaddress[addtono];
}
if(choicesel==2)
{
searchaddir=document.getdir1.frmaddto.value;
addto=document.getdir1.frmaddto.value;
addfrom=geoaddlist[addfromno]
countryofmarker=countryaddress[addfromno];
}
var locale="en_US";
if(searchres=="")
searchres=document.getElementById("resultdis").innerHTML;
	markercountryale=countryofmarker;

document.getElementById("resultdis").innerHTML="";
document.toprintdir.fromadd.value=addfrom;
	 document.toprintdir.toadd.value=addto;
gdir.load("from: "+addfrom+" to: "+addto,
                { "locale": locale });
}

 function handleErrors(){

	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	    {
		if(errorondir==1)
		{
		errorondir=2;
		 geocoder.getLocations(searchaddir, fndaddfrodir);
		}
		else{
		    alert("We're unable to find any match for \""+searchaddir+"\" in "+markercountryale+". Please re-enter other details such as the street name or the postal code into the search box above.");
		document.getElementById("resultdis").innerHTML =searchres;  
              document.getElementById("resultdis").style.display="block";
           document.getElementById("paging").innerHTML =pagingbackup;   
	   document.getElementById("paging").style.display="block";
                    
                    }
		 }
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
           {
	   alert("We're unable to find any match for \""+searchaddir+"\" in "+markercountryale+". Please re-enter other details such as the street name or the postal code into the search box above.");
	     document.getElementById("resultdis").innerHTML =searchres;  
              document.getElementById("resultdis").style.display="block";
           document.getElementById("paging").innerHTML =pagingbackup;   
	   document.getElementById("paging").style.display="block";
           }
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	      {
	   alert("We're unable to find any match for \""+searchaddir+"\" in "+markercountryale+". Please re-enter other details such as the street name or the postal code into the search box above.");
	     document.getElementById("resultdis").innerHTML =searchres;  
              document.getElementById("resultdis").style.display="block";
           document.getElementById("paging").innerHTML =pagingbackup;   
	   document.getElementById("paging").style.display="block";
           }

	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	       {
	   alert("We're unable to find any match for \""+searchaddir+"\" in "+markercountryale+". Please re-enter other details such as the street name or the postal code into the search box above.");
	     document.getElementById("resultdis").innerHTML =searchres;  
              document.getElementById("resultdis").style.display="block";
           document.getElementById("paging").innerHTML =pagingbackup;   
	   document.getElementById("paging").style.display="block";
           }

	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	       {
	   alert("We're unable to find any match for \""+searchaddir+"\" in "+markercountryale+". Please re-enter other details such as the street name or the postal code into the search box above.");
	     document.getElementById("resultdis").innerHTML =searchres;  
              document.getElementById("resultdis").style.display="block";
           document.getElementById("paging").innerHTML =pagingbackup;   
	   document.getElementById("paging").style.display="block";
           }
	    
	   else 
	   {
	    
		if(errorondir==1)
		{
		errorondir=2;
		 geocoder.getLocations(searchaddir, fndaddfrodir);
		}else{

	   alert("We're unable to find any match for \""+searchaddir+"\" in "+markercountryale+". Please re-enter other details such as the street name or the postal code into the search box above.");
	    document.getElementById("resultdis").innerHTML =searchres;  
              document.getElementById("resultdis").style.display="block";
           document.getElementById("paging").innerHTML =pagingbackup;   
	   document.getElementById("paging").style.display="block";

		}
	   }
	   
	}
var addgot=[];

 var markercountry="";
  var countrycode="";

	function fndaddfrodir(response)
{errhand=1;
var alladd="";
 var dirsrsm=0;
 var loccount=0;
 var paginbackupd="";
    var request1 = GXmlHttp.create();

		markercountryale=countryofmarker;
	    request1.open("GET", "getcountrycode.jsp?datareq="+countryofmarker, true);
		request1.onreadystatechange = function() {
		if (request1.readyState == 4) 
		{
               var xmlDoc = GXml.parse(request1.responseText);

          var markers = xmlDoc.documentElement.getElementsByTagName("country");
       markercountry=markers[0].getAttribute("present");
        if (!response || response.Status.code != 200) {
      alert("We're unable to find any match for \""+searchaddir+"\" in "+countryofmarker+". Please re-enter other details such as the street name or the postal code into the search box above.");

      } else {

var relength=response.Placemark.length;
alladd="<b>Did You Mean</b><br>";
	for(var resst=0;resst<relength;resst++)
        {
		var loc="en_US";
		placech = response.Placemark[resst];


               try{
           countrycode=placech.AddressDetails.Country.CountryNameCode;
}
catch(e)
{
countrycode=trimSpace(markercountry);
}



			var selchoi="";
			if(choicesel==2)selchoi=addfromno;
						if(choicesel==1)selchoi=addtono;
			addgot[resst]=placech.address;
                      
	      if(trimSpace(countrycode)==(trimSpace(markercountry))){

        dirsrsm++;
        loccount=resst;
         samecountrycheck="true";   
         alladd+=' <a href=javascript:setDirections("'+selchoi+'","'+resst+'","'+loc+'") class="linktxt" style="color:#0088DD;width:232px;">'+placech.address+'</a>';
         }
         

	   }
           if(dirsrsm==1){

           setDirections(selchoi,loccount,loc);alladd="";
           }
		    document.getElementById("paging").style.display="none";
             if(samecountrycheck=="false") {

			alert("We're unable to find any match for \""+searchaddir+"\" in "+countryofmarker+". Please re-enter other details such as the street name or the postal code into the search box above.");
			alladd=searchres;
                           paginbackupd=pagingbackup;
                        }
 document.getElementById('searchheader').innerHTML ='<img src="images2/search_results.gif" alt="Search results"  title="Search results" />';
             document.getElementById("resultdis").innerHTML =alladd;
                 document.getElementById("paging").innerHTML =paginbackupd;   
  document.getElementById("paging").style.display="block";
 document.getElementById("addldis").style.display="block";
  document.getElementById("addldis").innerHTML ="";
      }
      
                }
	  
        
         
                } 
                request1.send(null);
 
     

}
function trimSpace(x)
{
	var emptySpace = / /g;
	var trimAfter = x.replace(emptySpace,"");
	return(trimAfter);
}
  function setDirections(fromAddress, toAddress, locale) {
   var frad=geoaddlist[fromAddress];
  var toad=addgot[toAddress];
  if(choicesel==1){ frad=addgot[toAddress];
  toad=geoaddlist[fromAddress];}
						if(choicesel==2){ frad=geoaddlist[fromAddress];
  toad=addgot[toAddress];}
    document.toprintdir.fromadd.value=frad;
	 document.toprintdir.toadd.value=toad;
document.getElementById("resultdis").innerHTML="";
      gdir.load("from: " + frad + " to: " + toad,
                { "locale": locale });
    }
    function showLocation(address) {
      geocoder.getLocations(address, addAddressToMap);
       
    }
	var pagingnos="";
      function createMarker(point,name,html,landmark,timing,bser) 
{
     
      var icon = new GIcon();
var name1=String(name).toLowerCase();

      if(name1=="atm")
		{
		icon.image = "images2/A1.png";
		icon.shadow = "images2/shadow50.png";
		}
	else if(name1=="branch")
		{
		icon.image = "images2/B1.png";
		icon.shadow = "images2/shadow50.png";
		}
	else if(name1=="citigold")
		{
		icon.image = "images2/C1.png";
		icon.shadow = "images2/shadow50.png";
		}
	    icon.iconSize = new GSize(20, 34);
      icon.shadowSize = new GSize(37, 34);
      icon.iconAnchor = new GPoint(9, 34);
      icon.infoWindowAnchor = new GPoint(9, 2);
      icon.infoShadowAnchor = new GPoint(18, 25);
          
    var marker = new GMarker(point,icon);
	
if((timing!='')&&(landmark!=''))
	var infotextdis='<div style="width:397px;  "44 >'+html+'</div>'
else if((timing!='')||(landmark!=''))
	var infotextdis='<div style="width:287px;  "44 >'+html+'</div>'
else
var infotextdis='<div style="width:247px;  " >'+html+'</div>'
	GEvent.addListener(marker, "click", function() {
var tabs = [];
var tabspresent=0;
if((trimSpace(timing)!='')||(trimSpace(landmark)!='')||(trimSpace(bser)!=''))
{
tabspresent=1;
}
if(tabspresent==0)
tabs.push(new GInfoWindowTab("Address  ","<p class='addressmarker'>Address</p>"+infotextdis));
else
tabs.push(new GInfoWindowTab("Address  ",infotextdis));
if(trimSpace(timing)!='')
{

var timing2=timing.replace(/\<li\> \<\/li\>/g,"")

var timing3=timing2.replace(/\<li\>\<\/ul\>/g,"\<\/ul\>")
tabs.push(new GInfoWindowTab("Timing","<div class='address1'>"+timing3+"</div>"));
tabspresent=1;
}
if(trimSpace(landmark)!='')
{

var landmark2=landmark.replace(/\<li\> \<\/li\>/g,"")

var landmark3=landmark2.replace(/\<li\>\<\/ul\>/g,"\<\/ul\>")

tabs.push(new GInfoWindowTab("Landmark","<div class='address1'>"+landmark3+"</div>"));
tabspresent=1;
}
if(trimSpace(bser)!='')
{

var bser2=bser.replace(/\<li\> \<\/li\>/g,"")

var bser3=bser2.replace(/\<li\>\<\/ul\>/g,"\<\/ul\>")
tabs.push(new GInfoWindowTab("Services","<div class='address1'>"+bser3+"</div>"));
tabspresent=1;
}

  marker.openInfoWindowTabsHtml(tabs);

      
 });


		GEvent.addListener(marker, "dblclick", function() {
      map.zoomIn();
        });

        gmarkers[k] = marker;
        return marker;
      }
  function myclick(i) {
        GEvent.trigger(gmarkers[i], "click");
      }
      var notinaspaccheck=false;
 function markerlocate()
   {   var mapbounds = new GLatLngBounds();
    printtext="";
   k=0;
   nearbycheck=true;
if((document.map1.atm.checked==true)||(document.map1.branch_atm.checked==true)||(document.map1.gold_center.checked==true))
{  
if(searchdone)
{toprinaddls="";
      var stxtenter1=document.map1.q.value;
		var stxttopass1=stxtenter1.replace(/ /g, "$");
var stxttopassar=[];
var stxttopass=stxttopass1.toLowerCase();
		stxttopassar=stxttopass.split('$');

		var lengthch=0;
		var stxttopassfn="";
		for(lengthch=0;lengthch<stxttopassar.length;lengthch++)
		{
		if(commonwords.indexOf(stxttopassar[lengthch])==-1)stxttopassfn+=stxttopassar[lengthch]+"$";
		}


var lastpagest=1;
		if(document.map1.atm.checked)
		stxttopassfn+='atm$';
		if(document.map1.branch_atm.checked)
		stxttopassfn+='branch$';
		if(document.map1.gold_center.checked)
		stxttopassfn+='citigold';
		
		

        printtext="";
   k=0;
        map.clearOverlays();

		var request = GXmlHttp.create();

	    request.open("GET", "GetsrDataxml.jsp?ccode=sg&datareq="+stxttopassfn+"", true);
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;charset=UTF-8;'); 	
		request.onreadystatechange = function() {
		if (request.readyState == 4) 
		{
          var xmlDoc = GXml.parse(request.responseText);
          
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");
		  var result="";
		  if(markers.length==0)
			{
          
                  if(nearbyche){
             if(nearbyloctext!=document.map1.q.value)
             callgoogle(document.map1.q.value);
             else{  
          
             if(notinaspaccheck){
          
             callgoogle(document.map1.q.value);}
             else
             placeapprox(nearbyptx,nearbypty,nearbyinde,nearbyloc);}
                }
                else {
            callgoogle(document.map1.q.value);
            }
            printtext+="We're unable to find any match for \""+document.map1.q.value+"\". Please re-enter other details such as the street name or the postal code into the search box above.";
			}
                        
                        else{
                        result+='';
				
			
       pagingloop=0;
			var category=""
		  for (var i = 0; i < markers.length; i++) 
			{
			k++;
			if( markers.length<=5)
			{
			 testpaging='<a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p>';
			}
			else{
			if(i%5==0)
			{
			var testind=i;
			if(testind>markers.length){endind=markers.length;}
			else {endind=i;}
			pagingloop++;
			testpaging+='';
			if(i!=0)
			{
			result+="</div>";
			if(i==5){
                       	testpaging+='<div id="paging'+(pagingloop-1)+'" style="display:block"><a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p><p>'+(i-4)+' - '+endind+' of '+markers.length+'</p> <a href=javascript:pagecall("'+(pagingloop)+'")><img hspace="0" src="images2/next_blue.gif" alt="" align="left"  /></a></div>';
                        
			lastpagest=lastpagest+5;
			}
			
			else
			{
                        testpaging+='<div id="paging'+(pagingloop-1)+'" style="display:none"> <a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p><a href=javascript:pagecall("'+(pagingloop-2)+'")><img src="images2/left_icon.gif" alt="" hspace="0" align="left"  /></a> <p>'+(i-4)+' - '+i+' of '+markers.length+'</p><a href=javascript:pagecall("'+(pagingloop)+'")><img hspace="0" src="images2/next_blue.gif" alt="" align="left"  /></a></div>';
			
			lastpagest=lastpagest+5;
			}
			result+="<div id='"+pagingloop+"' style='display:none'>";
			}
			else
			result+="<div id='"+pagingloop+"' style='display:block'>";
			}
		 if((i+1)==(markers.length)){
		 testpaging+='<div id="paging'+(pagingloop)+'" style="display:none"><a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p><a href=javascript:pagecall("'+(pagingloop-1)+'")><img src="images2/left_icon.gif" alt="" hspace="0" align="left"  /></a><p>'+lastpagest+' - '+markers.length+' of '+markers.length+'</p> </div>';
		// testpaging+='	<div id="paging'+(pagingloop)+'" style="display:none">	 <p style="margin-left:30px; "><a href=javascript:pagecall("'+(pagingloop-1)+'")><img src="images1/pre.jpg" border="0" alt="previous" title="previous" /></a></p> <p>'+lastpagest+' - '+markers.length+'</p>            <p></p>            <p>of '+markers.length+'</p></div>';
		 	
		 }
			}
			var fnstind=endind+1;
			
			var newcategory="";
			newcategory=markers[i].getAttribute("category");
			toprinaddls+=markers[i].getAttribute("uniqueid")+'$';
			if(category!=newcategory)
				{
					category=newcategory;
					if(category=='Branch')
                                        result+='<img src="images2/branch.gif" alt="Branch" title="Branch"  />';
                                        else 	if(category=='Citigold')
					result+='<img src="images2/citigoldcentre.gif" alt="Citigold Centre" width="84" height="12" title="Citigold Centre"  />';
					else 	if(category=='ATM')
					result+='<img src="images2/atm.gif" alt="ATM" title="ATM"  />';
                                        printtext+="$"+category+"$";
                }
			var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
               
                if(i==0){ map.setCenter(new GLatLng(lat,lng),11);
				}
            var point = new GLatLng(lat,lng);
           
	var html = '<div style="width: 242px;  float:left" id="getdirdiv"><p class="address1" style="font-weight:normal;"><strong>'+markers[i].getAttribute("title")+'</strong><br />'+markers[i].getAttribute("Address")+'<br></p>  <div class="getdir"><div class="dirhead" ><strong>Get Directions:</strong></div><div class="toheredv"style="padding-bottom:6px;" > <a href="javascript:toshowtextb(\'1\',\''+i+'\');">To here</a><span style="float:left;"> /&nbsp; </span> <a href="javascript:toshowtextb(\'2\',\''+i+'\');">From here </a></div>  <div style="visibility:; font-weight:normal; margin-top:6px; " class="addressbox" id="quadd"><a target="_blank" href="http://www.citibank.com.">More details</a></div><div class="callnk" id="morediv" style="visibility:hidden;  "><a target="_blank" href="http://www.citibank.com.">More details</a></div></div>';	
           geoaddlist[i]=markers[i].getAttribute("Geoaddress");
                        countryaddress[i]=markers[i].getAttribute("country");
            var label = markers[i].getAttribute("category");
			result+='<p  ><a href="javascript:myclick(\''+k+'\');" class="atmrow"><b>'+markers[i].getAttribute("title")+'</b><br>'+markers[i].getAttribute("Address")+'</a></p>';
			printtext+=markers[i].getAttribute("title")+" "+markers[i].getAttribute("Address")+"$";
                         var landmark=markers[i].getAttribute("landmark");
var timing= markers[i].getAttribute("timing");  
var bser= markers[i].getAttribute("bser");                      
var marker1 = createMarker(point,label,html,landmark,timing,bser);
            map.addOverlay(marker1);
			mapbounds.extend(marker1.getPoint());
			}
			
			result+='</p>'
			document.getElementById('resultdis').innerHTML =result+'<p style="height:1400px; "></p>';
			document.getElementById('paging').innerHTML =testpaging;
                        pagingbackup=testpaging;
			
searchres=document.getElementById("resultdis").innerHTML;
                        var resultfrtext=document.map1.q.value;
                        if(document.map1.atm.checked)
		resultfrtext+=',atm';
		if(document.map1.branch_atm.checked)
		resultfrtext+=',branch';
		if(document.map1.gold_center.checked)
		resultfrtext+=',citigold';
                        	document.getElementById('searchtext').innerHTML = "<p style='padding-bottom:14px;'><span style=' color:#333333 '>Results for:</span> "+resultfrtext+"</p>";
		CSBfleXcroll('dvOverflowContent');
		testpaging="";
                 document.getElementById('searchheader').innerHTML ='<img src="images2/search_results.gif" alt="Search results"  title="Search results" />';
		 document.getElementById("paging").style.display="block";
		  document.getElementById("addldis").innerHTML = "";
 document.getElementById("addldis").style.display="none";
 if(markers.length!=0){ 
  map.setZoom(map.getBoundsZoomLevel(mapbounds));

      map.setCenter(mapbounds.getCenter());
	 } else           map.setCenter(new GLatLng(1.3463879115035189, 103.80294799804688), 11);
      }
   
                  }
		}
	  request.send(null);
   }
   }
   }
function  catcheck()
{
var searchstvalty=document.map1.q.value;
var searchstvalty1=searchstvalty.toLowerCase();
if(searchstvalty1.indexOf("atm")!=-1)document.map1.atm.checked=true;
if(searchstvalty1.indexOf("branch")!=-1)document.map1.branch_atm.checked=true;
if(searchstvalty1.indexOf("citigold")!=-1)document.map1.gold_center.checked=true;


}
function calllight()
{

document.getElementById('light').style.display='none';
document.getElementById("fade").style.display="none";
}

    function tosa()
    {
 var stxtenter2=document.map1.q.value;
		
		if(document.map1.atm.checked)
		stxtenter2+=',atm';
		if(document.map1.branch_atm.checked)
		stxtenter2+=',branch';
		if(document.map1.gold_center.checked)
		stxtenter2+=',citigold';

		
              //  document.tosave.srls.value=stxtenter2;
   //document.tosave.addrls.value=toprinaddls;

    document.tosave.addr.value=toprinaddls;
  if(toprinaddls!='')
    document.tosave.submit();
    }
var dirlising="";
function todissearch()
	{
	dirlising=document.getElementById("resultdis").innerHTML;
document.getElementById("resultdis").innerHTML=searchres;
 document.getElementById("paging").style.display="block";
 document.getElementById("addldis").style.display="none";
	
	}
	function todisdir()
	{
	pagingnos=document.getElementById("paging").innerHTML;
	searchres=document.getElementById("resultdis").innerHTML;
document.getElementById("resultdis").innerHTML=dirlising;
 document.getElementById("paging").style.display="none";
 document.getElementById("addldis").style.display="block";
	
	}

	function printdir()
    {

		
    document.toprintdir.route.value=document.getElementById("resultdis").innerHTML;;
    document.toprintdir.submit();
    }
	function toprpage()
    {

                 var stxtenter2=document.map1.q.value;
		
		if(document.map1.atm.checked)
		stxtenter2+=',atm';
		if(document.map1.branch_atm.checked)
		stxtenter2+=',branch';
		if(document.map1.gold_center.checked)
		stxtenter2+=',citigold';

		
                document.toprint.srls.value=stxtenter2;
    document.toprint.addrls.value=toprinaddls;
    document.toprint.submit();
    }
    var emailexp=/^([a-zA-Z0-9])([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|([a-zA-Z0-9\-\.]+))\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/

var citiesWith8Phone = new Array("Bangalore","Chennai","Delhi","Hyderabad","Kolkata","Mumbai");

function MM_openBrWindow(theURL,winName,features) 
{ 
  window.open(theURL,winName,features);
}

function isEmail(email)
{
	return emailexp.test(email)
}
function checkEmail(field)
{
	val=field.value.replace(/\s/g,"");
	var stxttopassar=[];
		stxttopassar=val.split(',');
var lengthch=0;
		
		for(lengthch=0;lengthch<stxttopassar.length;lengthch++)
		{
		if(isEmail(stxttopassar[lengthch])==false)
	{
		field.focus();
		field.select();
		return false;
	}
		}
	
}
function retrieveURL() {
    
  
  var url="SendMail.jsp";
  var validationpassed=true;
if(trimSpace(document.senemailfrm.stxemailto.value).length == 0)
	{
        validationpassed=false;
	document.getElementById("stxemailtoreq").style.display="block";

	}
	else {
		document.getElementById("stxemailtoreq").style.display="none";
  if(checkEmail(document.senemailfrm.stxemailto)==false)
		{
                validationpassed=false;
                document.getElementById("stxemailtoinvalid").style.display="block";

		}else{
			document.getElementById("stxemailtoinvalid").style.display="none";
		}
	}
	if(trimSpace(document.senemailfrm.stxemailfrom.value).length == 0)
	{validationpassed=false;
	document.getElementById("stxemailfromreq").style.display="block";

	}
	else {
		document.getElementById("stxemailfromreq").style.display="none";
  if(checkEmail(document.senemailfrm.stxemailfrom)==false)
		{
                validationpassed=false;
                document.getElementById("stxemailfrominvalid").style.display="block";

		}else{
			document.getElementById("stxemailfrominvalid").style.display="none";
		}
	}	
	var copyme="No";
        if(document.senemailfrm.stxemailcopy.checked==true){copyme="yes";}
        if(trimSpace(document.senemailfrm.stxemailcontents.value)!='')
        {
        url=url+"?toemailid="+document.senemailfrm.stxemailto.value+"&fromemailid="+document.senemailfrm.stxemailfrom.value+"&address="+document.senemailfrm.urlofadd.value+"&copyme="+copyme+"&mpermes=<b>Message</b><br>"+document.senemailfrm.stxemailcontents.value;
        }
else	url=url+"?toemailid="+document.senemailfrm.stxemailto.value+"&fromemailid="+document.senemailfrm.stxemailfrom.value+"&address="+document.senemailfrm.urlofadd.value+"&copyme="+copyme;
    if(validationpassed)
    {
    if (window.XMLHttpRequest) { 
      req = new XMLHttpRequest();
      req.onreadystatechange = processStateChange;
      try {
      	req.open("GET", url, true);
      } catch (e) {
        alert("Problem Communicating with Server\n"+e);
      }
      req.send(null);
    } else if (window.ActiveXObject) { 
      
     try
		    {
			    req=new ActiveXObject("Msxml2.XMLHTTP");
		    }
			catch (e)
		    {
			    req=new ActiveXObject("Microsoft.XMLHTTP");
		    }
      if (req) {
        req.onreadystatechange = processStateChange;
        req.open("GET", url, true);
		
        req.send();
      }
    }
    }
  }
 
 
  function processStateChange() {
	 
  
  	  if (req.readyState == 4) { 
	  if (req.status == 200) {
        
      
        document.getElementById('stxemailstatus').style.display="block";
           setTimeout(' calllight();', 3000);
       
      
        
      } else {
        alert("Sorry For inconvenience Mail not Sent");
      }
    }
  }


 var nearbyche=false;
var nearbyad="";
var nearbyptx="";
var nearbypty="";
var nearbyinde="";
var nearbyloc="";

var myData = new Array();
var people = new Array();
var branchls=new Array();
var goldls=new Array();
var resarra=new Array();
function person(key, title, add,distance,category) {
	this.key = key;
	this.title = title;
	this.add = add;
        this.distance = distance;
         this.category = category;
     
}
	var v = "";
function drawArray() {
var category="";
          resarra = new Array();
        var pagingloop=0;
    
      
	if(people.length!=0)
        {
      
          for (var i=0; i<people.length; i++) {
	        var key=people[i].key;
              resarra[resarra.length++] = new person( key, people[i].title, people[i].add,people[i].distance,people[i].category );
        
	}
       }
       if(branchls.length!=0)
        {
       
        for (var i=0; i<branchls.length; i++) {
	
        
               var key=branchls[i].key;
               var title=branchls[i].title;
                resarra[resarra.length++] = new person(key, title, branchls[i].add,branchls[i].distance ,branchls[i].category);
           
	}
        }
          if(goldls.length!=0)
        { 
        for (var i=0; i<goldls.length; i++) {
	
        
               resarra[resarra.length++] = new person(goldls[i].key , goldls[i].title, goldls[i].add,goldls[i].distance,goldls[i].category );
	}
        }
        	v="";
        for(var i=0;i<resarra.length;i++)
        {
        if( resarra.length<=5)
			{
			}
			else{
			if(i%5==0)
			{
			var testind=i;
			if(testind>resarra.length){endind=resarra.length;}
			else {endind=i;}
			pagingloop++;
			
			if(i!=0)
			{
			v+="</div>";
			if(i==5){
			}
			
			else
			{
			}
			v+="<div id='"+pagingloop+"' style='display:none'>";
			}
			else
			v+="<div id='"+pagingloop+"' style='display:block'>";
			}
       
        }
        var newcategory="";
			newcategory=resarra[i].category;
			
			if(category!=newcategory)
				{
					category=newcategory;
                                        if(category=='Branch')
                                        v+='<img src="images2/branch.gif" alt="Branch" title="Branch"  />';
                                        else 	if(category=='Citigold')
					v+='<img src="images2/citigoldcentre.gif" alt="Citigold Centre" width="84" height="12" title="Citigold Centre"  />';
					else 	if(category=='ATM')
					v+='<img src="images2/atm.gif" alt="ATM" title="ATM"  />';
					
                                       
                }
         v+='<p  ><a href="javascript:myclick(\''+resarra[i].key+'\');" class="atmrow"><b>'+resarra[i].title+'</b><br>'+resarra[i].add+'</a></p>';
     
         }
         if(resarra.length==0)v="We're unable to find any match for \""+document.map1.q.value+"\". Please re-enter other details such as the street name or the postal code into the search box above.";
	return v;
}
function sortBydistance(a, b) {
	var x = a.distance;
	var y = b.distance;
	return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}
function placeapprox(ptx,pty,inde,loc)
    {var mapbounds = new GLatLngBounds();
   var googleadd=addgotfromgle[inde];
   nearbyche=true;
    printtext="";
    people = new Array();
branchls=new Array();
goldls=new Array();
   k=0;

   if(searchdone)
   {
      var stxtenter1="";
		
	 nearbyad="";
 nearbyptx=ptx;
 nearbypty=pty;
 nearbyinde=inde;
 nearbyloc=loc;	

var lastpagest=1;
		if(document.map1.atm.checked)
		stxtenter1+='atm$';
		if(document.map1.branch_atm.checked)
		stxtenter1+='branch$';
		if(document.map1.gold_center.checked)
		stxtenter1+='citigold$';
		stxtenter1.replace(/ /, "$");
		var stxttopass1=stxtenter1.replace(/ /g, "$");
var stxttopassar=[];
		stxttopassar=stxttopass1.split('$');
	
		var lengthch=0;
		var stxttopassfn="";
		for(lengthch=0;lengthch<stxttopassar.length;lengthch++)
		{
		if(commonwords.indexOf(stxttopassar[lengthch])==-1)stxttopassfn+=stxttopassar[lengthch]+"$";
		}

        printtext="";
   k=0;
        map.clearOverlays();
		
		var request = GXmlHttp.create();
	   
 request.open("GET", "GetglesrDataxml.jsp?ccode=sg&datareq="+stxtenter1+"&ptx="+ptx+"&pty="+pty+"", true);
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;charset=UTF-8;'); 			
request.onreadystatechange = function() {
		if (request.readyState == 4) 
		{
          var xmlDoc = GXml.parse(request.responseText);
          
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");
		  var result="";
		  if(markers.length==0)
			{
            result="We're unable to find any match for \""+document.map1.q.value+"\". Please re-enter other details such as the street name or the postal code into the search box above.";
          
	
			}result+='';
				    pagingloop=0;
			
			var category=""
        
		  for (var i = 0; i < markers.length; i++) 
			{
			k++;
			if( markers.length<=5)
			{
			 testpaging='<a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p>';
			}
			else{
			if(i%5==0)
			{
			var testind=i;
			if(testind>markers.length){endind=markers.length;}
			else {endind=i;}
			pagingloop++;
			testpaging+='';
			if(i!=0)
			{
			result+="</div>";
			if(i==5){
			testpaging+='<div id="paging'+(pagingloop-1)+'" style="display:block"><a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p><p>'+(i-4)+' - '+endind+' of '+markers.length+'</p><a href=javascript:pagecall("'+(pagingloop)+'")><img hspace="0" src="images2/next_blue.gif" alt="" align="left"  /></a></div>';
			lastpagest=lastpagest+5;
			}
			
			else
			{
			lastpagest=lastpagest+5;
                        testpaging+='<div id="paging'+(pagingloop-1)+'" style="display:none"> <a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p><a href=javascript:pagecall("'+(pagingloop-2)+'")><img src="images2/left_icon.gif" alt="" hspace="0" align="left"  /></a> <p>'+(i-4)+' - '+i+' of '+markers.length+'</p><a href=javascript:pagecall("'+(pagingloop)+'")><img hspace="0" src="images2/next_blue.gif" alt="" align="left"  /></a></div>';
	
			}
			result+="<div id='"+pagingloop+"' style='display:none'>";
			}
			else
			result+="<div id='"+pagingloop+"' style='display:block'>";
			}
		 if((i+1)==(markers.length)){
                 testpaging+='<div id="paging'+(pagingloop)+'" style="display:none"><a href="javascript:callintro()"><img hspace="0" border="0" style=" margin-top:1px; " src="images2/right_blue_arrow.gif" alt="" align="left"  /></a><p style="padding-left:4px; padding-top:0px; padding-right:75px; "><a href="javascript:callintro()">Introduction</a></p><a href=javascript:pagecall("'+(pagingloop-1)+'")><img src="images2/left_icon.gif" alt="" hspace="0" align="left"  /></a><p>'+lastpagest+' - '+markers.length+' of '+markers.length+'</p> </div>';
	
		 
		 }
			}
			var fnstind=endind+1;
	
			var newcategory="";
			newcategory=markers[i].getAttribute("category");
			toprinaddls+=markers[i].getAttribute("uniqueid")+'$';
			if(category!=newcategory)
				{
					category=newcategory;
					if(category=='Branch')
                                        result+='<img src="images2/branch.gif" alt="Branch" title="Branch"  />';
                                        else 	if(category=='Citigold')
					result+='<img src="images2/citigoldcentre.gif" alt="Citigold Centre" width="84" height="12" title="Citigold Centre"  />';
					else 	if(category=='ATM')
					result+='<img src="images2/atm.gif" alt="ATM" title="ATM"  />';
                                        printtext+="$"+category+"$";
                }
			var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
               
                if(i==0){ map.setCenter(new GLatLng(lat,lng),11);
				}
            var point = new GLatLng(lat,lng);
        
    var html = '<div style="width: 242px;  float:left" id="getdirdiv"><p class="address1" style="font-weight:normal;"><strong>'+markers[i].getAttribute("title")+'</strong><br />'+markers[i].getAttribute("Address")+'<br></p>  <div class="getdir"><div class="dirhead" ><strong>Get Directions:</strong></div><div class="toheredv" style="padding-bottom:6px;"> <a href="javascript:toshowtextb(\'1\',\''+i+'\');">To here</a><span style="float:left;"> /&nbsp; </span> <a href="javascript:toshowtextb(\'2\',\''+i+'\');">From here </a></div>  <div style="visibility:; font-weight:normal; " class="addressbox" id="quadd"><a target="_blank" href="http://www.citibank.com.">More details</a></div><div class="callnk" id="morediv" style="visibility:hidden;  "><a target="_blank" href="http://www.citibank.com.">More details</a></div></div>';	
           geoaddlist[i]=markers[i].getAttribute("Geoaddress");
                        countryaddress[i]=markers[i].getAttribute("country");
            var label = markers[i].getAttribute("category");
	
                 
                        if(markers[i].getAttribute("category")=='ATM')
                      {
                        people[people.length++] = new person(k, markers[i].getAttribute("title"), markers[i].getAttribute("Address"),markers[i].getAttribute("distance"),markers[i].getAttribute("category"));
                    }
                        if(markers[i].getAttribute("category")=='Branch')
                     {    
                        branchls[branchls.length++] = new person(k, markers[i].getAttribute("title"), markers[i].getAttribute("Address"),markers[i].getAttribute("distance"),markers[i].getAttribute("category"));
                     }
                        if(markers[i].getAttribute("category")=='Citigold')
                      {
                        goldls[goldls.length++] = new person(k, markers[i].getAttribute("title"), markers[i].getAttribute("Address"),markers[i].getAttribute("distance"),markers[i].getAttribute("category"));
                       }
                        printtext+=markers[i].getAttribute("title")+" "+markers[i].getAttribute("Address")+"$";
                         var landmark=markers[i].getAttribute("landmark");
var timing= markers[i].getAttribute("timing");              
var bser= markers[i].getAttribute("bser");          
var marker1 = createMarker(point,label,html,landmark,timing,bser);
            map.addOverlay(marker1);
				mapbounds.extend(marker1.getPoint());
			}
			    people.sort(sortBydistance);
           branchls.sort(sortBydistance);
                goldls.sort(sortBydistance);
          drawArray();
	     result= v;
			
                       document.getElementById('searchheader').innerHTML ='<img src="images2/search_results.gif" alt="Search results"  title="Search results" />';
			document.getElementById('resultdis').innerHTML =result+'<p style="height:1400px; "></p>';
			
			document.getElementById('paging').innerHTML =testpaging;
                        pagingbackup=testpaging;
			
searchres=document.getElementById("resultdis").innerHTML;
                        var resultfrtext=document.map1.q.value;
                        if(document.map1.atm.checked)
		resultfrtext+=',atm';
		if(document.map1.branch_atm.checked)
		resultfrtext+=',branch';
		if(document.map1.gold_center.checked)
		resultfrtext+=',citigold';
                        	document.getElementById('searchtext').innerHTML = "<p style='padding-bottom:14px;'><span style=' color:#333333 '>Results for:</span> "+resultfrtext+"</p>";
		CSBfleXcroll('dvOverflowContent');
		testpaging="";
		 document.getElementById("paging").style.display="block";
		  document.getElementById("addldis").innerHTML = "";
 document.getElementById("addldis").style.display="none";
 if(markers.length!=0){ 
  map.setZoom(map.getBoundsZoomLevel(mapbounds));

      map.setCenter(mapbounds.getCenter());
	 } else           map.setCenter(new GLatLng(1.3463879115035189, 103.80294799804688), 11);
                  }
                  
		}
	  request.send(null);
          
         
   }

   }
       
   var toplocation="";
   function getParameter(parmeter)
{
	var sli=""
	var a=top.window.location;
        toplocation=a;
	str=new String(a)
	var index = str.indexOf(parmeter);
        
	if(index!=-1)
	{
		var str1 = str.substring(index);
		var index1 = str1.indexOf("&");
		if (index1 == -1)
			{
				var index = str1.indexOf("=");
				var sli = str1.slice(index+1);
			}
		else
			{
				var index = str1.indexOf("=");
				var sli = str1.slice(index+1,index1);
			}
	}
	if(sli=="")
		var sli="";
	return sli;
}
        var preloaded="";
                 preloaded=getParameter("q");
                 toplocationstring=new String(toplocation);
        
                 if(preloaded!=""){
                 searchdone="true";
                 setTimeout(' markerlocate();', 9000)
              
                 }
             function valuefosend()
    {
document.getElementById("stxemailtoreq").style.display="none";
document.getElementById("stxemailtoinvalid").style.display="none";
document.getElementById("stxemailfrominvalid").style.display="none";
document.getElementById("stxemailfromreq").style.display="none";
document.getElementById("stxemailmsgreq").style.display="none";
document.getElementById("stxemailstatus").style.display="none";

	 var stxtenter2=document.map1.q.value;
		var stxttopass1=stxtenter2.replace(/ /g, "$");
var stxttopassar=[];
		stxttopassar=stxttopass1.split('$');
	
		var lengthch=0;
		var stxttopassfn="";
		for(lengthch=0;lengthch<stxttopassar.length;lengthch++)
		{
		if(commonwords.indexOf(stxttopassar[lengthch])==-1)stxttopassfn+=stxttopassar[lengthch]+"$";
		}
   
  
		if(document.map1.atm.checked)
		stxttopassfn+='atm$';
		if(document.map1.branch_atm.checked)
		stxttopassfn+='branch$';
		if(document.map1.gold_center.checked)
		stxttopassfn+='citigold$';

		var stxttopass34=stxttopassfn.replace(/ /g, "$");
		
		 document.getElementById('stxemailstatus').style.display="none";
    document.getElementById('light').style.display='block';

var browserName=navigator.appName; 

var brwheight=1000;
var brwwidth="";
 if (browserName=="Microsoft Internet Explorer")
 {
  brwheight=document.body.clientHeight+"px";
 }
    document.getElementById('fade').style.width=document.documentElement.clientWidth+"px";
        document.getElementById('fade').style.height=brwheight;
        document.getElementById('fade').style.display='block';
         document.getElementById("stxemailto").value="";
         document.getElementById("stxemailfrom").value="";
                  document.senemailfrm.stxemailcontents.value="";
        document.getElementById("stxemailto").focus();
 document.senemailfrm.urlofadd.value="http://"+location.host+"/sg/index.jsp?q="+stxttopass34;
    }


function callintro()
        {
        var resultantsearch=document.getElementById('resultdis').innerHTML  ;
        document.getElementById('searchtext').innerHTML ='';
        document.getElementById('paging').innerHTML ='';
        document.getElementById('resultdis').innerHTML ='<div class="print_wel">The easiest way to locate a Citibank ATM or Branch of the Bank in  Singapore. Just search by the street name, the address or city and we will find what you are looking for in no time at all. <p style="height:500px; "></p> </div>   ';
        document.getElementById('searchheader').innerHTML ='<img src="images2/welcome_to.gif" alt="Welcome to findmyciti.com" title="Welcome to findmyciti.com" />';
        
        }
        function CreateBookmarkLink() {

 title = "Find My CITI"; 

 url =top.location.href;

	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { 
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { 
		return true; }
 }