//var PROCESS_REQUEST="Processing request ... please stand by!";
//var POINT_NOT_IN_MAP="Couldn't locate on map.";
//var GOOGEL_MESSAGE="Sorry, we were unable to find address.";
//var KEYWORD_MESSAGE="Please enter keyword";
//var COUNTRY_MESSAGE="Select a Country";
document.write("<script src='scripts/PopUpWithPointer.js'></script>");
document.write("<script src='scripts/yahoo-dom-event.js'></script>");
document.write("<script src='scripts/prototype.js'></script>");
var poly;
var geocoder = new GClientGeocoder(); 
var markers=new Array();
var intervalId;
var secondcalltogmap="N" ;
var baseIcon = new GIcon();
var gmapAddress;
//var balloon  = new Balloon;
baseIcon.shadow = "images/Locator_Shadow.png";
baseIcon.image = "http://www.google.com/mapfiles/marker.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);


function openminfo(index) {
if (markers[index]){
   markers[index].openinfo();
   } else {
   alert (POINT_NOT_IN_MAP);
   }
}

function openalert(index) {
 alert (POINT_NOT_IN_MAP);
}
function openinfo() {	
    var infoTabs = new Array();
    var herf = 'getPartnerDirection.do?begeoid='+this.begeoid + '&siteid='+this.siteid +'&country='+ this.countrycd;
    var data="<table border=0  cellspacing=0 bgcolor='#C0C0C0' width='100%'>";
		data += "<tr bgcolor='#FFFFFF'><td  align='left'><b>"+this.company + "</b></td></tr>";
		data +="<tr bgcolor='#FFFFFF'><td  align='left'> "+this.address + "</td></tr>";
		data +="<tr bgcolor='#FFFFFF'><td  align='left'> "+this.contact + "</td></tr>";		 
		if (drivingDirCountry.match(this.countrycd)!= null)
			data +="<tr bgcolor='#FFFFFF'>"+"<td align='left'><table><tr><td> <a href= " + herf +  " onmouseover=\"window.status="+ DRIVING_DIRECTION +";return true;\" onmouseout=\"window.status='';return false;\"  target='_parent' ><font color='blue'>"+ CLICK_HERE +"&nbsp;</font></a>"+ GET_DIRECTIONS +" </td><td></td></tr></table></td>"+ "</tr>";
		data += "</table>";
    gmapAddress=this.address;
	infoTabs[0]=new GInfoWindowTab( PARTNER_INFO ,"<div style='width:200px; height:200px; overflow : auto;'>"+ data +"</div>");
    var request = GXmlHttp.create();
    request.open("POST", "partnerInfoAjax.do", false);
    request.setRequestHeader('Content-Type','application/x-www-form-urlencoded') ;
    request.send("begeoid="+this.begeoid + '&siteid='+this.siteid +'&country='+ this.countrycd); 
	infoTabs[1]=new GInfoWindowTab(AUTHORIZATION, request.responseText);     
    this.openInfoWindowTabsHtml(infoTabs); 
	//document.getElementById("setDirection").href='getPartnerDirection.do?begeoid='+this.begeoid + '&siteid='+this.siteid +'&country='+ this.countrycd ;
}

 

function submitBasicSearch(gsupportcountry ) {
		document.plSearchForm.state.value = "";
	     document.plSearchForm.zip.value = "";
	     document.plSearchForm.city.value ="";  
	     document.plSearchForm.latitude.value = "";
	      document.plSearchForm.longitude.value ="";		      
	    document.plSearchForm.lonlatRequired.value  = "Y";	 
		var keyWord = document.plSearchForm.keyWord.value;
    	var city = document.plSearchForm.address.value;
    	var country = document.plSearchForm.country.value;
    	if(country == ""){
    		alert(COUNTRY_MESSAGE);
    		return;
    	}
    	
    var ele2 = document.getElementById("country");
    if (country != null && country !=''){
   	 	setStandbyMessage();
		var address = city;			 
	 	if (gsupportcountry.match(country ) != null){	
		 	if (city ==''){	 
				 address = ele2.options[ele2.options.selectedIndex].text  ;	
				if (internalLocator)
				{
					deSelect("proximity",false);
					document.plSearchForm.milesKms.value="miles";	
					var RadioMiles = document.getElementsByName("milesKms")[0]; 
	    			if (document.plSearchForm.milesKms.value="miles")
	    				RadioMiles.checked = true;
    			}
	
			}   
			else
			{
				address += " " + ele2.options[ele2.options.selectedIndex].text  ;	
			
			}			 
			geocoder.getLocations(address,getInterestedLocationForHome);
		} else {
			//document.plSearchForm.city.value = document.plSearchForm.address.value;	   
		    //geocoder.getLocations(ele2.options[ele2.options.selectedIndex].text,getInterestedLocationForHome);
		    document.plSearchForm.city.value = document.plSearchForm.address.value;
            document.plSearchForm.lonlatRequired.value  = "N";
		    // call function to track web metrics
		    trackFormValues(); 
		    document.plSearchForm.submit();
		}
	 
	}
}

function trackFormValues(){
	var Keyword=document.plSearchForm.keyWord.value;
	var Address=document.plSearchForm.address.value;
	var Country=document.plSearchForm.country.value;
	var SMBSort=document.plSearchForm.smbSort.checked;
	vs_formfieldcapture('Partner Locator Basic', '/Partners and Resellers/Tools/', 'form', 'Partners and Resellers', 'submit', Keyword, Address, Country, SMBSort);
	
}

function deSelect(selName, multiSelect)
	{
		var selObj = document.getElementById(selName) ;	
		
		if(selObj)
		{
			if(multiSelect)
				selObj.selectedIndex = -1;
			else
				selObj.selectedIndex = 0;
		}
	}
 

function getInterestedLocationForHome(response) {
try {
		var country = document.plSearchForm.country.value;
		 if (gsupportcountry.match(country ) != null){	
		      if (!response || response.Status.code != 200) {		      	 
			      if (response.Status.code != 500){
			      	removeStandbyMessage();
			        alert(GOOGEL_MESSAGE); 
			        return; 
				 } 			    
		   } 
	     } else {
		     if (!response || response.Status.code != 200) {
			     if (secondcalltogmap == "N"){
			     	secondcalltogmap = "Y" ;
			     	var theForm = document.plSearchForm ;
			     	geocoder.getLocations(theForm.country[theForm.country.selectedIndex].value,getInterestedLocationForHome);
			     	return;
			     }
		     }
	     
	     }
	     var place;	   
	      if (response){	         
		      if  (response.Placemark) { 		        	          	 
	      	  	place = getPlaceMark(response.Placemark); 
	      	  	
	      	  	if (!place && secondcalltogmap == "N") {
	      	  		secondcalltogmap = "Y" ;
			     	var theForm = document.plSearchForm ;
			     	geocoder.getLocations(theForm.country[theForm.country.selectedIndex].value,getInterestedLocationForHome);
			     	return;
	      	  	}	      	    
	      	  } 
      	  }
      	  
	      if (place){ 	

				  document.plSearchForm.latitude.value = place.Point.coordinates[1];
				  document.plSearchForm.longitude.value = place.Point.coordinates[0];
			   if ( gsupportcountry.match(country ) != null){ 

				/*Added for Japan to get city from AddressLine,AdministrativeArea.*/
				if(place.AddressDetails.Country.AddressLine){
					if ( document.plSearchForm.country.value == "JP"){
		  			document.plSearchForm.city.value = place.AddressDetails.Country.AddressLine;
		  			}
				  }
				if(place.AddressDetails.Country.AdministrativeArea){
					if ( document.plSearchForm.country.value == "JP"){
		  			document.plSearchForm.city.value = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;					  
		  			}
				 }
				/*Added  to get city from SubAdministrativeArea.*/
				 if (place.AddressDetails.Country.SubAdministrativeArea) {		  	 	  
			  		   document.plSearchForm.city.value =  place.AddressDetails.Country.SubAdministrativeArea.Locality.LocalityName;
			  	 }

			  if (place.AddressDetails.Country.AdministrativeArea){	
			  	if ( document.plSearchForm.country.value == "US"){
		  			document.plSearchForm.state.value = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
		  		}
		  		 
		  		 if (place.AddressDetails.Country.AdministrativeArea.PostalCode) {
			  		  document.plSearchForm.zip.value = place.AddressDetails.Country.AdministrativeArea.PostalCode.PostalCodeNumber;
			     }
			  		 
		  		if (place.AddressDetails.Country.AdministrativeArea.Locality){
		  			if (place.AddressDetails.Country.AdministrativeArea.Locality.PostalCode) {
			  		  	 document.plSearchForm.zip.value = place.AddressDetails.Country.AdministrativeArea.Locality.PostalCode.PostalCodeNumber;
			  		 }
			  		  
		  			document.plSearchForm.city.value =  place.AddressDetails.Country.AdministrativeArea.Locality.LocalityName;
		  	 	}
		  	 	if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea) {
		  	 	  
			  	 	if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality){
				  	 	if (place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode) {
				  		  	 document.plSearchForm.zip.value = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
				  		 }
			  		 
			  	 	   document.plSearchForm.city.value =  place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
			  	 	}
		  	 	}
		  	 	 
		  	 } 
			  if (place.AddressDetails.Country.Locality) {
			  	document.plSearchForm.city.value =  place.AddressDetails.Country.Locality.LocalityName;
			  	     if (place.AddressDetails.Country.Locality.PostalCode) {
			  		  	 document.plSearchForm.zip.value = place.AddressDetails.Country.Locality.PostalCode.PostalCodeNumber;
			  		 }
			  }	
			  if (place.AddressDetails.Country.PostalCode) {
			   document.plSearchForm.zip.value = place.AddressDetails.Country.PostalCode.PostalCodeNumber;
			  }
			 } 
			  document.plSearchForm.lonlatRequired.value  = "N";			  
		  }else {
			  document.plSearchForm.latitude.value = "";
			  document.plSearchForm.longitude.value ="";
		      document.plSearchForm.city.value = document.plSearchForm.address.value;
			  document.plSearchForm.lonlatRequired.value  = "Y";
			  
		  }
		    secondcalltogmap = "N" ;
		    //code to call tracking method
		    trackFormValues(); 
		    document.plSearchForm.submit(); 
	} catch (e){
			document.plSearchForm.lonlatRequired.value  = "Y";	
			document.plSearchForm.latitude.value = "";
			document.plSearchForm.longitude.value = "";
			document.plSearchForm.submit(); 
	}	 
       
}

function getPlaceMark (placeMarks) {
 var leng = placeMarks.length;
	 for (i = 0 ; i < leng ; i ++) {
	 	var   place = placeMarks [i];
	 	 
	 	if (place.AddressDetails.Country){		 	 
		 	if  (place.AddressDetails.Country.CountryNameCode == document.plSearchForm.country.value){
		 		return place;
		 	}
	    }
	 }
 
	return null;

}
function buildMarker(){
		
		var mapcenter= true;
		markers = new Array();
		var googlesupported = document.getElementById("googlesupported") ;
		var actTypeAdv='PerformAdvanceSearch';
		if (googlesupported) {	
		var totallength = document.getElementById("listIndex") ;		 
		if (totallength) {		 
			lenghtvalue = totallength.innerHTML;
	  	    for(i=0;i<lenghtvalue;i++) { 
	  	    
		  	    var latObj = document.getElementById("latitude" + i) ;
		  	    var longObj = document.getElementById("longitude" + i) ;
		  	    var latvalue =0 ;
		  	     var longvalue =0 ;  	    
		  	     if (latObj) {
			  	     latvalue = latObj.innerHTML;
			  	     latvalue = latvalue.replace(/,/g, "")
		  	     }  	      
		  	     if (longObj) {
		  	     	longvalue = longObj.innerHTML;
		  	     	 longvalue = longvalue.replace(/,/g, "")
		  	     }
		  	      
			  	 if (longvalue != '' && longvalue  != '0' && latvalue != '' && latvalue != '0'){
			  	 	    var markIndex = document.getElementById("markIndex" + i).innerHTML;	  	 	     
			            point = new GLatLng(latvalue ,longvalue);	
			            if (markIndex == '0') {	
			            	mapcenter= false;
			  	    		map.setCenter(point,10);  
			  		        		       	
			  	 	    }           
				        var icon = new GIcon(baseIcon);
				        icon.image = "images/PushPin_"+ i + ".png"; 
				        //icon.image = "images/CiscoPushpin.png" ; // + letter + ".png";  		 
				         markers[markIndex]= new GMarker(point,icon);
				          var addObj = document.getElementById("address" + i) ;
				          if (addObj){
				           markers[markIndex].address = addObj.innerHTML;
				          }
				          
				          var contactObj = document.getElementById("contact" + i) ;
				          if (contactObj){
				           markers[markIndex].contact = contactObj.innerHTML;
				          }			          
			             var companyObj = document.getElementById("beGeoName" + i) ;
			             if (companyObj){
			               markers[markIndex].company =companyObj.innerHTML;
			             }
			              var begeoidObj = document.getElementById("beGeoId" + i) ;   
		                 if (begeoidObj){
		                	var begeoid =  begeoidObj.innerHTML
		                  	markers[markIndex].begeoid = begeoid;
		                  }
		                  
		                  var siteidObj = document.getElementById("siteId" + i) ;   
		                 if (begeoidObj){
		                	var siteId =  siteidObj.innerHTML;
		                  	markers[markIndex].siteid = siteId;
		                  }
		                  if (document.plSearchForm.countryCd[i]){
		                  	markers[markIndex].countrycd = document.plSearchForm.countryCd[i].value;
		                  }
		                  
				         markers[markIndex].openinfo=openinfo;
				         GEvent.addListener(markers[markIndex], "click", markers[markIndex].openinfo);
			       	     map.addOverlay(markers[markIndex]);
			      }	
	         } //for close
         } // if close
         }//if close
	   if  (null!=currAction&&currAction==actTypeAdv){
	       	if (checkSupported()==false)
       			mapcenter=false;
       }
		
		if  (null!=searchType&&searchType==actTypeAdv){      
       		if (checkSupported()==false)
       			mapcenter=false;
       	}
		 
         if (mapcenter == true){
         		centerMap();
         }        	     
}
   
function centerMap(){
		var totallength = document.getElementById("listIndex") ;
   		var latObj = document.getElementById("latreq") ;
  	    var longObj = document.getElementById("longreq") ;
  	    var latvalue ='0';
  	     var longvalue ='0' ;  	    
  	     if (latObj) {
	  	     latvalue = latObj.innerHTML;
  	     }  	      
  	     if (longObj) {
  	     	longvalue = longObj.innerHTML;
  	     }  
  	           
	  	 if (longvalue != '' && longvalue  != '0' && latvalue != '' && latvalue != '0'){
	  	 	 var gpoint = new GLatLng(latvalue ,longvalue);
	  	 	 map.setCenter(gpoint,4); 
	  	 	 if (document.plSearchForm.latitude){
		  	 	 document.plSearchForm.latitude.value = latvalue;
			     document.plSearchForm.longitude.value = longvalue;
		     }
	  	 	 
	  	 } else if (totallength) {
	  	 			var isRecordExistForMultipleRecord=eval(document.plSearchForm.countryCd[0]);
					var isRecordExistForSingleRecord=eval(document.plSearchForm.countryCd);
					if(isRecordExistForMultipleRecord)
					{
						countryCd=document.plSearchForm.countryCd[0].value;
						country=document.plSearchForm.countryName[0].value;
						//geocoder.getLatLng(countryCd,getLatLongForMap)
					}
					else if (isRecordExistForSingleRecord)
					{
						countryCd=document.plSearchForm.countryCd.value;
						country=document.plSearchForm.countryName.value;
						//geocoder.getLatLng(countryCd,getLatLongForMap)
					}
	  	 }
	  	 
   } 

function buildOneMarkerAdvanceSearch(latvalue,longvalue, company, address , begeoid , siteId,countryCd,index ,markIndex,contact){
		

		var letter = String.fromCharCode("A".charCodeAt(0) + index);
	   // alert("buildOneMarkerAdvanceSearch :" + index);
		if (longvalue != '' && longvalue  != '0' && latvalue != '' && latvalue != '0'){
			point = new GLatLng(latvalue,longvalue);             
			var icon = new GIcon(baseIcon);
			     
	        icon.image = "images/PushPin_"+ index + ".png"; 
	       // var markIndex = markers.length ;	          
			markers[markIndex]= new GMarker(point,icon);
			markers[markIndex].company = company;
			markers[markIndex].address = address;
			markers[markIndex].contact = contact;
			markers[markIndex].begeoid = begeoid;
			markers[markIndex].siteid = siteId;
			markers[markIndex].countrycd = countryCd;
			markers[markIndex].openinfo=openinfo;
			GEvent.addListener(markers[markIndex], "click", markers[markIndex].openinfo);
//			map.addOverlay(markers[markIndex]);
   	    }	       	     
}


function setStandbyMessage(){     
	 scroll(0,0);	  
	 intervalId = setInterval("setProgressStatus(\"" + PROCESS_REQUEST + "\")",50)     
     document.body.style.cursor = 'wait';
}

function removeStandbyMessage(){		 
		clearInterval (intervalId); 
		window.status ="";		  
        document.body.style.cursor = 'default';
}

function setProgressStatus(message){
	window.status = message;
}

function populatePageDD() {	
//document.getElementById("showpageDetail").innerHTML ='<BR>';
	if (document.getElementById("totalPageNo")){
		document.getElementById("paginationComp").style.display = 'block';
		var totalPageValue = document.getElementById("totalPageNo").innerHTML;		
		var currentPageNo = document.getElementById("currentPage").innerHTML;		 
		var pagesize = document.getElementById("pagesize").innerHTML;
		var totalrecord = document.getElementById("totalrecord").innerHTML;		
		var startpage = ((currentPageNo -1)*pagesize) + 1;
		var endpage = currentPageNo * pagesize ;
		 if (endpage > totalrecord)
		   endpage = totalrecord;
		 if (totalrecord!=0)
			 document.getElementById("showpageDetail").innerHTML = SHOWING +" " + startpage + "-" + endpage + " "+ OF + " " + totalrecord ;
		var ele = document.getElementById("pageDropDown");
		for (var i = ele.length - 1; i>=0; i--) {			     
		      ele.remove(i);
	  	}				 
		for (var i =1 ; i<=totalPageValue; i++) {    
		    ele.options.add(new Option(i , i));
		    if (i == currentPageNo){
		   		 selecedIndex = i-1;
		    }
	    }
	  	ele.options.selectedIndex = selecedIndex;
	  	if (document.getElementById("recordCount")!=null)
	  		document.getElementById("recordCount").value=pagesize;
		
  }
}

function nextPage(site){	 
	if ( document.getElementById("totalPageNo")){
	var totalPageValue = document.getElementById("totalPageNo").innerHTML;
 	var pagno = document.getElementById("pageDropDown").value;
 	 if (totalPageValue != 1){
	 	var pagerequest= 1;
		 	if (pagno != totalPageValue){
		 		pagerequest = Number(pagno) + 1;
		 	}
	  	paginateAjaxCall(pagerequest,site);
	  } 
  	}	        	
}

function perviousPage(site){ 
 if ( document.getElementById("totalPageNo")){
	var totalPageValue = document.getElementById("totalPageNo").innerHTML;
 	var pagno = document.getElementById("pageDropDown").value;
 	var pagerequest= totalPageValue;
 	 if (totalPageValue != 1){
	 	if (pagno != 1){
	 		pagerequest = pagno - 1;
	 	}
	  	paginateAjaxCall(pagerequest,site);
  	} 
 } 		        	
}

function onPageSelect(site){
 	var pagerequest = document.getElementById("pageDropDown").value;
 	
 	var totalPageValue = document.getElementById("totalPageNo").innerHTML;
 	if (totalPageValue != 1){
  		paginateAjaxCall(pagerequest,site); 
  	}  		        	
}

function onSortSelect(){
 	var sortrequest = document.getElementById("sortType").value; 	 
  	sortAjaxCall(sortrequest); 
  	 		        	
}

function GetXmlHttpObject(handler) {
    var objXMLHttp = null;
    if (window.XMLHttpRequest) {
        objXMLHttp = new XMLHttpRequest();
    } else {
        if (window.ActiveXObject) {
            objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return objXMLHttp;
} 

function paginateAjaxCall(pagerequest, site){
  setStandbyMessage();
  var actTypeBasic='PerformBasicSearch';
  var actTypeAdv='PerformAdvanceSearch';
  document.getElementById("gridbox").innerHTML="<font color='green'>" + PROCESS_REQUEST + "</font>";
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert(HTTP_FAILURE);
        return;
    }
    xmlHttp.onreadystatechange = paginateStateChanged;
    xmlHttp.open("POST", "paginateAjaxSearch.do" , true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    var param = "pageno=" +pagerequest;

    if (site){      
    param += "&site=Y";
    }
    //map.clearOverlays();
	if (null!=currAction){
		if (currAction==actTypeAdv)
		{
			//map.clearOverlays();
			if (isMultiCountry=="Y")
			{
				if (isSupported=="Y")
				{
					map.clearOverlays();
				}
			}
			else if (gsupportcountry.match(suppCountry) != null)
			{
					map.clearOverlays();
			}
		}
		else{
     		if (gsupportcountry.match(suppCountry) != null)
    		{
   	     		map.clearOverlays();
    		}
   		}
   	}
   	
   else	if (null!=searchType){ 
    if (searchType==actTypeAdv)
		{
			if (isMultiCountry=="Y")
			{
				if (isSupported=="Y")
				{
					map.clearOverlays();
				}
			}
			else if (gsupportcountry.match(suppCountry) != null)
			{
					map.clearOverlays();
			}
		}
		else{
     		if (gsupportcountry.match(suppCountry) != null)
    		{
   	     	     	map.clearOverlays();
        	}
   		}
   	}
  	xmlHttp.send(param);
}

function paginateStateChanged (){
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		
		var tempString = xmlHttp.responseText;	
	    if (tempString.match("Application Session")){
	       alert(APPLICATION_SESSION);
	       document.plSearchForm.action = "sessionExpired.do";
	       document.plSearchForm.submit()
	   		  	
	  	}
	   	
		document.getElementById("gridbox").innerHTML = tempString;  	 	 
	 	
	 	populatePageDD();
	  	buildMarker();	
		secondHitForLatLong="N";
	  	removeStandbyMessage();
	}

}

function sortAjaxCall(pagerequest){
  setStandbyMessage();
  document.getElementById("gridbox").innerHTML="<font color='green'>" + PROCESS_REQUEST + "</font>";
  xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
       alert(HTTP_FAILURE);
        return;
    }
  xmlHttp.onreadystatechange = paginateStateChanged;  
  xmlHttp.open("POST", "sortByAjaxSearch.do", true);
  xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded') ;
  var param = "sortby=" +pagerequest;
  var actTypeBasic='PerformBasicSearch';
  var actTypeAdv='PerformAdvanceSearch';
	
if (null!=currAction){
	if (currAction==actTypeAdv)
	{
		//map.clearOverlays();
		if (isMultiCountry=="Y")
		{
			if (isSupported=="Y")
			{
				map.clearOverlays();
			}
		}
		else if (gsupportcountry.match(suppCountry) != null)
		{
				map.clearOverlays();
		}
	}
	else{
		if (gsupportcountry.match(suppCountry) != null){
   	     		map.clearOverlays();
   		}
	}
}
   	
else if (null!=searchType){ 
	if (searchType==actTypeAdv){
			//map.clearOverlays();
			if (isMultiCountry=="Y")
			{
				if (isSupported=="Y")
				{
					map.clearOverlays();
				}
			}
			else if (gsupportcountry.match(suppCountry) != null)
			{
					map.clearOverlays();
			}
	}
	else{
		if (gsupportcountry.match(suppCountry) != null){
   	     	map.clearOverlays();
       	}
   	}
 }
  xmlHttp.send(param); 	   

}

function getLatLongForMap(point)
	{
		if (!point)
		{
			if(secondHitForLatLong=="N")
			{
				secondHitForLatLong="Y";
				geocoder.getLatLng(country,getLatLongForMap);
			}
        } 
		else
		{
			var lat=point.lat();
			var lng=point.lng();
			map.setCenter(new GLatLng(lat,lng), 6);
		}
    }


// Added by sshikark for Jan '08 release for no. of records per page
function onNumberSelect(){
 	var pageSize = document.getElementById("recordCount").value;
 	var pageNo = document.getElementById("pageDropDown").value;
 	recordsAjaxCall(pageSize,pageNo); 
 	  	  		        	
}

function recordsAjaxCall(pageSize,pageNo){
  setStandbyMessage();
  document.getElementById("gridbox").innerHTML="<font color='green'>" + PROCESS_REQUEST + "</font>";
  xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert(HTTP_FAILURE);
        return;
    }
  xmlHttp.onreadystatechange = paginateStateChanged;  
  xmlHttp.open("POST", "recordsByAjaxSearch.do", true);
  xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded') ;
  var param = "pageSize="+pageSize+"&pageNo="+pageNo;
  var actTypeBasic='PerformBasicSearch';
  var actTypeAdv='PerformAdvanceSearch';
	
if (null!=currAction){
	if (currAction==actTypeAdv)
	{
		//map.clearOverlays();
		if (isMultiCountry=="Y")
		{
			if (isSupported=="Y")
			{
				map.clearOverlays();
			}
		}
		else if (gsupportcountry.match(suppCountry) != null)
		{
				map.clearOverlays();
		}
	}
	else{
		if (gsupportcountry.match(suppCountry) != null){
   	     		map.clearOverlays();
   		}
	}
}
   	
else if (null!=searchType){ 
	if (searchType==actTypeAdv){
			//map.clearOverlays();
	
			if (isMultiCountry=="Y")
			{
				if (isSupported=="Y")
				{
					map.clearOverlays();
				}
			}
			else if (gsupportcountry.match(suppCountry) != null)
			{
					map.clearOverlays();
			}
	}
	else{
		if (gsupportcountry.match(suppCountry) != null){
   	     	map.clearOverlays();
       	}
   	}
 }
  xmlHttp.send(param); 	   

}    

function openLocatorPopup(popupURL){
	var newURL=popupURL;
	window.open(newURL,'Module', 'toolbar=0, location=0, directories=0, menuBar=0, scrollbars=1, resizable=1, width=1100, height=1000, left=0, top=0'); 
}

function openPopupAjax(popupURL,type,begeoid,site_id){
	var newURL=popupURL;
	insertRecord(newURL,type,begeoid,site_id);
	window.open(newURL,'Module', 'toolbar=0, location=0, directories=0, menuBar=0, scrollbars=1, resizable=1, width=1100, height=1000, left=0, top=0'); 
}

function insertRecord (insertURL,type,begeoid,site_id){
	xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert(HTTP_FAILURE);
        return;
    }
    
  xmlHttp.onreadystatechange = insertStateChanged;  
  xmlHttp.open("POST", "insertRecord.do", true);
  xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded') ;
  var param = "insertURL="+insertURL;
  param+="&urlType="+type+"&begeoid="+begeoid+"&site_id="+site_id;
  xmlHttp.send(param); 	
}

function insertStateChanged (){
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		   var tempString = xmlHttp.responseText;	
		   if (tempString.match("Application Session")){
	       alert(APPLICATION_SESSION);
	       document.plSearchForm.action = "sessionExpired.do";
	       document.plSearchForm.submit();
	   		  	
	  	}
  		
	}
}


function getPartnerDetail(){
	document.getElementById("balloon").style.display="none";
}


function showPartnerPopUp(Customevent,country,begeoid,siteid) {
		document.getElementById("partnerInfoPopUp").innerHTML="";
	    var balloon = new Balloon();
        balloon.showTooltip(Customevent,country,begeoid,siteid,1,250);  
	    }
