﻿//<![CDATA[

    var ewindow = null; //popwindows object
    var map = null; //map object
 	var zoomLevel=0; //zoom level 	
 	var MyArrayOfMarker=null; //array of al the current markers
 	var MaxIndex=null; 
 	var ZipCodeSearch=null;
 
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/	
    function initialize() {
     map = new GMap2(document.getElementById("map_canvas"));
      if (GBrowserIsCompatible()) {        
        map.setCenter(new GLatLng(39.4507, -119.7605), 13);
      }
    }
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
var dimensions = {width: 0, height: 0};
    if (document.documentElement) {
        dimensions.width = document.documentElement.offsetWidth;
        dimensions.height = document.documentElement.offsetHeight;
    } else if (window.innerWidth && window.innerHeight) {
        dimensions.width = window.innerWidth;
        dimensions.height = window.innerHeight;
    }
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function setSession() {
var CurrentIndexPageChoice=document.getElementById("PageChoice").value;
	MegaJackpot.Default2.SetSession("CurrentIndexPageChoice", CurrentIndexPageChoice, function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		alert("Session value is set to '" + res.request.args.value + "'");
	});
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function setSession_1(){
var CurrentIndexPageChoice1=document.getElementById("PageChoice1").value;
	MegaJackpot.Default2.SetSession("CurrentIndexPageChoice1", CurrentIndexPageChoice1, function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		alert("Session value is set to '" + res.request.args.value + "'");
	});
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function GetFlagZipCode(ZipCode, flag){
	MegaJackpot.Default2.LngLatInfoFromZip(ZipCode,flag,function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		ZipCodeSearch=null; //make sure it is empty
		ZipCodeSearch= new Array();
		for (var i=0; i<res.value.Tables[0].Rows.length;i++)
		{  //the info about the map flag
		    ZipCodeSearch[0]=res.value.Tables[0].Rows[i]["Latitude"];
		    ZipCodeSearch[1]=res.value.Tables[0].Rows[i]["Longitude"];
		    ZipCodeSearch[2]=res.value.Tables[0].Rows[i]["City"]+ ",";
		    if (res.value.Tables[0].Rows[i]["ZipCode"]!=null)
		        ZipCodeSearch[3]=res.value.Tables[0].Rows[i]["ZipCode"]
		        else
		        ZipCodeSearch[3]=res.value.Tables[0].Rows[i]["PostalCode"];
		}
	});
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function setSession_2(){
var flagDisplayMode=document.getElementById("flagDisplayMode").value;
	MegaJackpot.Default2.SetSession("flagDisplayMode", flagDisplayMode, function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		alert("Session value is set to '" + res.request.args.value + "'");
	});
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function getSession() {
	MegaJackpot.Default2.GetSession("test", function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		alert("Session value = " + res.value);
	}); 
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function disable(){
 document.getElementById("ddlSelectCity").disabled=true;
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function enable(){
document.getElementById("ddlSelectCity").disabled=false;
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function Ajax_GetCity(){
     var SelectedState = document.getElementById("ddlCountryState");
    
    if (SelectedState.selectedIndex == 0 && SelectedState.options[0].text=="Select a State") 
        {
                SelectedState.remove(SelectedState.selectedIndex);
                SelectedState.style.color="#000000";                                             
        }
        else
        {    
         MegaJackpot.Default2.SetSession_cities(SelectedState.value, function(res){
		    if(res.error != null) {
			    alert(res.error.Message);
			    return;
		    }
		    else
		    {
		        enable();//enable the city dropdown
		        var DropDownCity = document.getElementById("ddlSelectCity");

		        //clear all the curent City in the list
		        while (DropDownCity.firstChild) {
                  DropDownCity.removeChild(DropDownCity.firstChild);
                }
                
		        var i=0;
		        var oOption="";	  
    		    
		        for (i=0;i<res.value.length;i++)
		        { 
		        oOption = document.createElement("OPTION");
    		    
		        if (i==0)
		        {
		            oOption.text=res.value[i].Value;
                    oOption.value=i;
		        }
		        else
		        {
		            //create a new option in the select
    		       
                    oOption.text=res.value[i].Value;
                    oOption.value=res.value[i].Value;
		        }
                    try
                    {
                        DropDownCity.add(oOption,null); // standards compliant
                    }
                    catch(ex)
                    {
                        DropDownCity.add(oOption); // IE only
                    }
		        }
		        
		          //For Nevada don't bring back properties until a city has been picked 
		         //Ajax_GetMyData('1');//get the State pick
		    }
	    });
	} 
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function Ajax_GetMyData(flag){

    var SelectedState=null
    var State = null; 
    var SelectedCity=null;;
    var City =null;    
    var ZipCode=null;
    
    var CurrentPage=document.getElementById("CurrentPage");
    //("^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z] \d[A-Z]\d$"); //USA and Canada
    //("^\d{5}$"); //USA only
    
    var CurrentAction = document.getElementById("CurrentAction");
    var flagViewAll=document.getElementById("flagViewAll");
    var CurrentContentDiv= document.getElementById("container1");
    
    switch (flag)
    {
            case "1":
                SelectedState=document.getElementById("ddlCountryState");
                State = SelectedState.options[SelectedState.selectedIndex].value; //get the right 
            
            if (State!="0")
            {
              if (CurrentContentDiv.style.display=="none")
            {
                CurrentContentDiv.style.display="block";
                CurrentContentDiv.style.margin="0 auto";
                CurrentContentDiv.style.width="800px";
            }
            else
            {
                CurrentContentDiv.style.display=="none";
            }    
            $("#wrapprerLoader").show('slow');
                MegaJackpot.Default2.GetDataByState(State,"",CurrentPage.value,flagViewAll.value,getDGCallback);
            }
        break;
        case "2":
            SelectedCity=document.getElementById("ddlSelectCity");   
            City = SelectedCity.options[SelectedCity.selectedIndex].text;                
            SelectedState=document.getElementById("ddlCountryState");
            State = SelectedState.options[SelectedState.selectedIndex].value;                  
            if (State!=0)
            {
                if (CurrentContentDiv.style.display=="none")
                {
                    CurrentContentDiv.style.display="block";
                    CurrentContentDiv.style.margin="0 auto";
                    CurrentContentDiv.style.width="800px";
                }
                else
                {
                    CurrentContentDiv.style.display=="none";
                } 
                $("#wrapprerLoader").show('slow');
                MegaJackpot.Default2.GetDataByState(State,City,CurrentPage.value,flagViewAll.value,getDGCallback);
            }
        break;
        case "3":    
         //reset the city dropdown and enable it
         insertOptionCity()
         enable()
       
            ZipCode=document.getElementById("tbSearchByZipCode"); 
            ZipCode.value=ZipCode.value.toUpperCase(); 
            if (ZipCode.value.match(/^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z] \d[A-Z]\d$/)!=null)
            {
                     if (CurrentContentDiv.style.display=="none")
                    {
                        CurrentContentDiv.style.display="block";
                        CurrentContentDiv.style.margin="0 auto";
                        CurrentContentDiv.style.width="800px";
                    }
                    else
                    {
                        CurrentContentDiv.style.display=="none";
                    } 
                if (ZipCode.value.match(/^\d{5}$/) !=null && ZipCode.value.length<6)
                {
                    $("#wrapprerLoader").show('slow');
                    insertOptionState();//reset other text box and selections  
                    GetFlagZipCode(ZipCode.value,0);
                    
                   //The zero is a flag for the country zip code or postal code format, default = 0, use Regular expression
                    MegaJackpot.Default2.GetDataByZipPostal(ZipCode.value,0,CurrentPage.value,flagViewAll.value,getDGCallback); //USA                     
                }
                else
                {
                    if (ZipCode.value.match(/^\d{5}|[A-Z]\d[A-Z] \d[A-Z]\d$/)!=null)
                    {
                        $("#wrapprerLoader").show('slow');  
                        insertOptionState();//reset other text box and selections 
                        GetFlagZipCode(ZipCode.value,1);
                        MegaJackpot.Default2.GetDataByZipPostal(ZipCode.value,1,CurrentPage.value,flagViewAll.value,getDGCallback); //CANADA
                    }
                    else
                     {
                        document.getElementById("tbSearchByZipCode").blur();                        
                       $("#container1").hide('fast');
                       setTimeout('setFooter()',500);
                       //setFooter();
                       $("#error").slideDown('slow');                    
                     }
                }
             }
             else
             {
                CurrentContentDiv.style.display="block";
                CurrentContentDiv.style.margin="0 auto";
                CurrentContentDiv.style.width="800px";
                        
                   document.getElementById("tbSearchByZipCode").blur();
                   $("#container1").hide('slow');
                     setTimeout('setFooter()',500);
                    $("#error").slideDown('slow');
             }
             break;
       default:
            MegaJackpot.Default2.GetDataByState(State,"",CurrentPage.value,getDGCallback);
   }
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function SlideItUp(){
    $("#error").slideUp('slow');
    $("#tbSearchByZipCode").attr("value", "Enter ZIP Code/Postal Code").css("color","#bababa");
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function SetUpDown(){
    var MyDiv=document.getElementById("directions");
    
    if (MyDiv.className=="up")
    {
        document.getElementById("loc").style.display="block";
         MyDiv.className="dwn";
    }
    else
    {
         document.getElementById("loc").style.display="none";
         MyDiv.className="up";
    }
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function changeObjectValueViewAll(){
    var myViewOption = document.getElementById("myView");
     var myViewOption1 = document.getElementById("myView1");
    var MyViewFlag = document.getElementById("flagViewAll");
   
    if (MyViewFlag.value==0)
    {
       MyViewFlag.value=1;
       myViewOption.innerHTML="View Less";
       myViewOption1.innerHTML="View Less";
  
       
    }
    else
    {
       MyViewFlag.value=0; 
       myViewOption.innerHTML="View All";  
       myViewOption1.innerHTML="View All";  
             
    }
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function Ajax_GetMyDataZipPostal(){
    var ZipCode=document.getElementById("tbSearchByZipCode");
    
    //put some regular expression validation here
    var RegularExpressionPostalZip  =  new RegExp("^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z] \d[A-Z]\d$"); //USA and Canada
    var RegularExpressionZip  =  new RegExp("^\d{5}$"); //USA only
 
     if (ZipCode.value.match(RegularExpressionPostalZip)!=-1)
    {
        if (ZipCode.value.match(RegularExpressionZip) !=-1)
        {
           //The zero is a flag for the country zip code or postal code format, default = 0, use Regular expression
           MegaJackpot.Default2.GetDataByZipPostal(ZipCode.value,0,getDGCallback); //USA
        }
        else
        {
            MegaJackpot.Default2.GetDataByZipPostal(ZipCode.value,1,getDGCallback); //CANADA
        }
     }
     else
     {
        //put the error message here 
        var ErrorMsg=document.getElementById("error");
        ErrorMsg.style.visibility="visible";
     }
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function testflash(jurisdiction, SystemCD,CompanyMasterAutoID){
	MegaJackpot.Default2.FlashCounter(jurisdiction, SystemCD,CompanyMasterAutoID,function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		var myValue=document.getElementById("main_counter");
		
		if (res.value=="" && myValue.innerHTML=="")
		{
		   myValue.innerHTML+="<div style='position:absolute;left:25px;'><p style='color:#3a3a3a;  font-size:10px; line-height:14px; align:center'>  This is a STAND-ALONE game is not part<br /> of a wide area progressive jackpot system.</p></div>"; 
		   $('#MsgCounter').hide();
		}
		if (myValue.innerHTML=="")
		{
		    myValue.innerHTML+="<div>"+res.value+"</div>";
		}
		
	}); 
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function Ajax_GetRelatedTheme(jurisdiction,companyMasterAutoID) {
	MegaJackpot.Default2.getRelatedThemes(jurisdiction,companyMasterAutoID,function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		var myValue=document.getElementById("Main_logo");
		//var myDivTheme_Logo=document.getElementById("Theme_logo");
		var myDivFeatureInfo=document.getElementById("Feature_Info");
		
		var tempStr="";
		var strDiv1="";
		var strDiv2="";
		//get the current system
		
		currentJurisdiction=jurisdiction;
		var currentSystemCd=null;
				
		for (var i=0;i<res.value.length;i++)
		{      
		    if  (i==0)
		    currentSystemCd=tempStr[0];
		                     
		    tempStr=res.value[i].split(':');
		    
		     if(tempStr[0]!="057")
		    strDiv1="<img src=\"http://media.igt.com/images/MJ_Logo_S_015.gif\"  style=\"width:260px; height:110px;\" />";
		    else
		    strDiv1="<img src=\"http://media.igt.com/images/MJ_Logo_S_"+ tempStr[0] + ".gif\"  style=\"width:260px; height:110px;\" />";
		   //alert(tempStr[0]);
		    //strDiv2+="<img src=\"http://media.igt.com/images/MJ_Logo_T_"+ tempStr[1] + ".gif\" style=\"left:10px;width:120px; height:120px;\" />";
		   // strDiv3+= "<strong>" + tempStr[2] + "</strong><br /><br />"; 
		   currentSystemCd=tempStr[0];	
		}

		myValue.innerHTML=strDiv1;
		//myDivTheme_Logo.innerHTML=strDiv2;	
		testflash(jurisdiction,currentSystemCd,companyMasterAutoID);  
	

//the goodies of Jquery
$(document).ready(
				function(){
					/*$('#Main_logo').innerfade({
						animationtype: 'slide',
						speed: 750,
						timeout: 2000,
						type: 'random',
						containerheight: '1em'
					});*/
					
					/*$('#Theme_logo').innerfade({
						animationtype: 'slide',
						speed: 750,
						timeout: 2000,
						type: 'random',
						containerheight: '1em'
					});*/

			});
//end of the call back			    
	}); 
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function Ajax_FixString(str1,str2) {
	MegaJackpot.Default2.ReplaceEscapeChar("test", function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		alert("Session value = " + res.value);
	}); 
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function Ajax_getSession_DataMap() {
	MegaJackpot.Default2.GetSession("test", function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		alert("Session value = " + res.value);
	}); 
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function Ajax_getSession_PagingSystem() {
	MegaJackpot.Default2.GetSession_Data("PagingSystem", function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		var MyTopDiv=document.getElementById("ListOfPages");
		var MyTopDiv1=document.getElementById("ListOfPages1");
		MyTopDiv.innerHTML=res.value;
		MyTopDiv1.innerHTML=res.value;
	}); 
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function Ajax_getSession_PageItemListNumber() {
	MegaJackpot.Default2.GetSession_Data("ElementNumber", function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		var MyTopDiv=document.getElementById("ItemList");
		var MyTopDiv1=document.getElementById("ItemList1");
		MyTopDiv.innerHTML=res.value;
		MyTopDiv1.innerHTML=res.value;
	}); 
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function getDGCallback(res){
    $("#wrapprerLoader").hide('fast');
    var  myDivData=document.getElementById("Repeater2");
    var CurrentContentDiv= document.getElementById("container1");
    myDivData.innerHTML ="";
    myDivData.innerHTML = res.value;
    
    if (res.value!="")
    {
        Ajax_getSession_PagingSystem();//the page system
        Ajax_getSession_PageItemListNumber(); //the number of items
        Ajax_PlotPoint();
        
        jQuery(function($) {
         $(".imgPng").pngfix();
        });
        setFooter();//change the footer length
        pageLoad1(); //init the table fx
    }
    else
    {
        document.getElementById("tbSearchByZipCode").blur();
        $("#container1").hide('fast');        
        setTimeout('setFooter()',500);
        $("#error").slideDown('slow');
    }
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function ReplaceDirtyString(MyDirtyStr){
    return MyDirtyStr.replace("\\","");
}
//get the data for the current zip code endter
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function doTest1() {
 MegaJackpot.Default2.Ajax_LoadState();
}

 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
 
function Ajax_PlotPoint(){
	MegaJackpot.Default2.GetSession_Data("coordinateTable", function(res){
		if(res.error != null) {
			alert(res.error.Message);
			return;
		}
		
		var i = 0;
		var tempStr="";
		var myPointLat=null;
		var myPointLng=null;	
		
		tempStr=res.value[i].split(':');
		
		myPointLat=tempStr[3];
		myPointLng=tempStr[4];
		

        if (res.value.length>0 && res.value.length<6)
            zoomLevel=15;
        
         if (res.value.length>5 && res.value.length<11)
            zoomLevel=10;
        
        if (res.value.length>10)
            zoomLevel=6;        
		
		map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(myPointLat, myPointLng),zoomLevel);
		map.addControl(new GLargeMapControl());
		map.addControl(new GScaleControl());
		var myIcon=null;
		var bounds = new GLatLngBounds;
		var LocationDetailArray = new Array();
		var FeaturedGame="more test";
		var EventH=null;
		
		// ========== Close the EWindow if theres a map click ==========
		
		MyArrayOfMarker=new Array();
		var tabs = new Array();	
		var IsZipCodeSearch=false;			
		
		for (i=0;i<res.value.length;i++)
		{                        
		    tempStr=res.value[i].split(':');	
		    LocationDetailArray[i]="<ul id=\"propertydetails\" class=\"shadetabs\">";
		    LocationDetailArray[i]+="<li id=\"firstchild\"><a href=\"\" rel=\"tcontent1\" class=\"selected\">Location Details</a></li>";
		    LocationDetailArray[i]+="<li><a href=\"\" rel=\"tcontent2\">System</a></li></ul>";	    
		    LocationDetailArray[i]+="<div id=\"propertydetailscontainer\">";
		    
		    LocationDetailArray[i]+="<div id=\"tcontent2\"  style=\"position:relative;height:145px\" class=\"tabcontent2\" >";
		    // we are going to display only the system logo
		    //LocationDetailArray[i]+="<div id=\"Theme_logo\" style=\"position:absolute;top:-12px; left:80px;width:240px;height:240px;\"></div>";
		    LocationDetailArray[i]+="<div id=\"Main_logo\" style=\"position:absolute;top:-12px; width:240px; height:240px;\"></div>";
		    LocationDetailArray[i]+="<div id=\"Feature_Info\" style=\"font-size: 8px;position:absolute;top:150px;\"></div>";
		    LocationDetailArray[i]+="<div id=\"MsgCounter\" style=\"position:absolute;top:98px; left:265px;color:red\">*</div>";
		    LocationDetailArray[i]+="<div id=\"main_counter\" style=\"position:absolute;top:108px; left:-5px;\"></div></div>";
		    
		    
		    LocationDetailArray[i]+="<div id=\"tcontent1\" class=\"tabcontent\ style=\" height:150px;top:1px;\" ><div class=\"close\"><a href=\"javascript:closeMarket();\" title=\"Close\"><img src=\"images/btn-close.gif\" /></a></div>";
		    LocationDetailArray[i]+="<br /><br /><p style=\"top:0px\"><strong>"+ReplaceDirtyString(tempStr[0])+"</strong> <br /><br />";
		    LocationDetailArray[i]+=tempStr[5] + "<br />";
		    LocationDetailArray[i]+=tempStr[6] + ", "+tempStr[9]+" "+ tempStr[7] + "<br />";
		    LocationDetailArray[i]+=tempStr[8] + "<br /><br />";
		    
		    //check weather we display the number of kilometer
		    if(tempStr[2].match(/^(-)?(\d*)(\.?)(\d*)$/)!=null)
		    {
		        LocationDetailArray[i]+="<strong>Estimated distance: <span>"+MilesToKiloM(tempStr[2])+"</span></strong>";
		        IsZipCodeSearch=true;
		    }
		    
		    LocationDetailArray[i]+="<a href=\"javascript:SetUpDown();\" id=\"directions\" class=\"up\" title=\"Get Directions\">Get Directions</a></p>";
		    LocationDetailArray[i]+= "<div id=\"loc\" style=\"display:none\"><input id=\"loc_search\" name=\"loc_search\" style=\"color:#bababa;\"value=\"Enter Starting Address\" size=\"\" onclick=\"ClearBox(this);this.focus();\" onKeyPress=\"checkEnter(event,1,\'"+res.value[i]+"\');\" class=\"required\" style=\"width: 175px; height: 18px; margin-right: 2px;\" type=\"text\"> <span class=\"button\" ><a href=\"javascript:OpenWindowsDirection(\'"+res.value[i]+"\')\" >Submit</a></span></div>";
		    LocationDetailArray[i]+="</div>";		    
		   
		    myPoint = new GLatLng(tempStr[3], tempStr[4]);
		    
		    myIcon = new GIcon();
            myIcon.image = "images/numbers/"+(i+1)+".png";
            myIcon.iconSize = new GSize(20,30);
		   
            myMarker = new GMarker(myPoint,myIcon); 
            myMarker.data=res.value[i];
            myMarker.getIcon().iconAnchor=new GPoint(-4,30);
            myMarker.getIcon().infoWindowAnchor = new GPoint(4, 1); 
            MyArrayOfMarker[i]=myMarker;
		}		
		 
                   
		for (i=0;i<MyArrayOfMarker.length;i++)
		{     
		   //var point = new GLatLng(parseFloat(MyArrayOfMarker[i].getLatLng()));   
		 
           updateMarker(MyArrayOfMarker[i],LocationDetailArray[i]); 
           
           //make the magic happen
           ewindow = new EWindow(map, E_STYLE_1);  
           map.addOverlay(ewindow);         
           map.addOverlay(MyArrayOfMarker[i],myIcon);
           bounds.extend(MyArrayOfMarker[i].getLatLng());	        
		}
		
		  if (IsZipCodeSearch==true)
		 {
		  var myPointFalg = new GLatLng(ZipCodeSearch[0], ZipCodeSearch[1]);		    
		  var myIcon1 = new GIcon();
          myIcon1.image = "images/blank.png";
          myIcon1.iconSize = new GSize(1,1);
		   
          var myMarker1 = new GMarker(myPointFalg,myIcon1); 
          myMarker1.data=ZipCodeSearch[2];
          myMarker1.getIcon().iconAnchor=new GPoint(-4,-1);//new GPoint(-4,-1);
          myMarker1.getIcon().infoWindowAnchor = new GPoint(-15, 1); 
          
          map.addOverlay(myMarker1,myIcon1);
          MyArrayOfMarker[res.value.length]=myMarker1;
		}
		
		 if (IsZipCodeSearch==true)
		 {
		      //everything below should happen only for zip code  
		      //updateMarker1(MyArrayOfMarker[res.value.length],"<div style='background-color:white;height:10px;left:100px;top:-15px;color:red;position:absolute'><strong>"+ZipCodeSearch[3]+"</strong></div>"); 
              //ewindow1.openOnMarker(MyArrayOfMarker[res.value.length],"<div style='background-color:white;height:10px;left:100px;top:-55px;color:red;position:absolute'><strong>"+ZipCodeSearch[3]+"</strong></div>"); 
              
              //make the magic happen
              var ewindow1 = new EWindow(map, E_STYLE_2);  
              map.addOverlay(ewindow1);  
                 
              ewindow1.openOnMarker(myMarker1,"<div style='background: url(images/pin-marker-zip.png);transparent;height:32px;width:69px;color:red;position:absolute'><strong><div style='top:5px;left:15px;position:absolute'>"+ZipCodeSearch[3]+"</div></strong></div>"); 
              map.addOverlay(MyArrayOfMarker[res.value.length],myIcon1);  
              bounds.extend(MyArrayOfMarker[res.value.length].getLatLng());            
		}
		map.setCenter(new GLatLng((bounds.getSouthWest().lat() + bounds.getNorthEast().lat())/2, (bounds.getSouthWest().lng()+ bounds.getNorthEast().lng())/2));
		map.setZoom(map.getBoundsZoomLevel(bounds));
		var myZoomLevel=map.getZoom()-1;
		map.setZoom(myZoomLevel);
		LocationDetailArray=null;
		i=null;
		tempStr=null;
		myMarker=null;
		myIcon1=null;
		myMarker1=null;
		
	}); 
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function createTabSytem(){
    var myflowers=new ddtabcontent("propertydetails") //enter ID of Tab Container
    myflowers.setpersist(true) //toogle persistence of the tabs' state
    myflowers.setselectedClassTarget("link") //"link" or "linkparent"
    myflowers.init()
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function OpenWindowsDirection(ArrayOfData){
    var tempStr=ArrayOfData.split(':');
    var AddressTo=document.getElementById("loc_search").value;
    AddressTo=AddressTo.replace(" ", "+");
   // AddressTo=AddressTo.replace(",", "+");
    
    var FromAddress = ReplaceDirtyString(tempStr[0])+"+"+tempStr[5]+ "+," + tempStr[6] + ",+"+tempStr[9]+"+"+ tempStr[7];
    FromAddress=FromAddress.replace(" ","+");
    //FromAddress=FromAddress.replace(",","+");
  
    var MainLink="http://maps.google.com/maps?q=from%3A+"+AddressTo+"+to%3A+"+FromAddress;
    
    if (document.getElementById("loc_search").value!="" && document.getElementById("loc_search").value!="Enter Starting Address")
        window.open(MainLink,'Direction','width=800,height=800');
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 

function updateMarker(marker, tbs) {
    GEvent.addListener(marker, "click", function() {    
    map.panTo(marker.getPoint());
    ewindow.openOnMarker(marker,tbs);
   $(".current_row").addClass("row").removeClass("current_row");
    var tempStr=marker.data.split(':');
    Ajax_GetRelatedTheme(tempStr[10],tempStr[12]) 
    createTabSytem();//test
 });
}
//mouseover events
function updateMarker1(marker, tbs) {
    GEvent.addListener(marker, "click", function() {
    ewindow.openOnMarker(marker,tbs);
 });
} 0
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function closeMarket(){
if (!map.overlay) {
          ewindow.hide();
        }
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function position_window(marker){   
        map.setCenter(new GLatLng( marker.getPoint().lat(), marker.getPoint().lng()), 13);
} 
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function MilesToKiloM(Miles){
  var Miles1=Math.round(Miles*100)/100 ;
  var Klio1= Math.round(Miles1*100*1.609344)/100 ;
  return Miles1 + " mi/" + Klio1 + "km";
}

 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function changeObjectValue(myObjectID,myValue){
    var currentObject=document.getElementById(myObjectID);
    currentObject.value=myValue;
     switch (myObjectID)
     {
     case "PageChoice":
     setSession();
     break
     
     case "PageChoice1":
       setSession_1();
     break
     
     case "flagDisplayMode":
     setSession_2();
     break
     }
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function ClearBox(myObjectID){
    //var currentObject=document.getElementById(myObjectID);
    myObjectID.value="";
    myObjectID.style.color="#000000";
    
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function PutErrorMsg(myObjectID){
    var currentObject=document.getElementById(myObjectID);
    
    if (currentObject.value=="")
    {      
        currentObject.value="Enter ZIP Code/Postal Code";
        currentObject.style.color="#bababa";
    }
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function checkEnter(e,flag,textVal){ //e is event object passed from function invocation
var characterCode;// literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
    e = e;
    characterCode = e.which; //character code is contained in NN4's which property
}
else{
    e = event;
    characterCode = e.keyCode; //character code is contained in IE's keyCode property
}

if(characterCode == 13)
{ //if generated character code is equal to ascii 13 (if enter key)
    if (flag==0)
    {
        changeObjectValue('CurrentPage',1);
        Ajax_GetMyData('3');
        return false;
    }
    else
    {
        if (document.getElementById("loc_search").value!="" && document.getElementById("loc_search").value!="Enter Starting Address")
        OpenWindowsDirection(textVal);
    }
}
else{
    return true;
    }
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
var IE = (navigator.userAgent.indexOf('MSIE') != -1);
function no_scrollbar(){
	if(!IE)
		return;
	var root = document.all[1]; // IE >= 4

	if(root.style.overflow != 'auto')
		root.style.overflow = 'auto';
	document.body.style.width =  '800px';
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function init(){
	no_scrollbar();
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function kH(e) {
var pK = e ? e.which : window.event.keyCode;
return pK != 13;
}
document.onkeypress = kH;
if (document.layers) 
document.captureEvents(Event.KEYPRESS);

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var boomHeight = document.getElementById('pageContent').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (boomHeight + footerHeight) >= 0) {
				footerElement.style.position = 'absolute';
				footerElement.style.top = (windowHeight - footerHeight) + 'px';
			}
			else {
				footerElement.style.position = 'static';
			}
		}
	}
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function ResizeMapDiv(){
  //  var MapDiv= document.getElementById("map_canvas");
  
   var CurrentHeight= document.getElementById("Repeater2").clientHeight;
   alert(CurrentHeight);
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
function myclick(i) {
       pageLoad1();
      var tempStr=MyArrayOfMarker[i-1].data.split(':');
      GEvent.trigger(MyArrayOfMarker[i-1], "click"); 
      Ajax_GetRelatedTheme(tempStr[10],tempStr[12]);    
    } 

   /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 
     function ddlChange(myDroSht,Flag){
            if ((myDroSht.selectedIndex == 0 && myDroSht.options[0].text=="Select a State") || (myDroSht.selectedIndex == 0 && myDroSht.options[0].text=="Select a City")) 
            {
                    myDroSht.options[myDroSht.selectedIndex].text="";    
                    myDroSht.style.color="#000000";                                                             
            }
                
                if (Flag==0)
                {
                    //change happened with State dropdown
                    changeObjectValue('CurrentPage',1);
                    Ajax_GetCity();
                    var myDroSht1=document.getElementById('ddlSelectCity');
                    myDroSht1.style.color="#bababa"; //reset the city list                  
                }
               if (Flag==1)
                {
                   var myDroSht1=document.getElementById('ddlSelectCity');
                   myDroSht1.style.color="#000000"; //reset the city list    
                }
                myDroSht=null; 
        }
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 


//this is never called because default to Nevada
function SetSelectedState(){
    document.getElementById("ddlCountryState").selectedIndex=1;
}     
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 

function insertOptionState()
{
  var elSel = document.getElementById('ddlCountryState');
  //ddlSelectCity
  elSel.style.color="#bababa";
  if (elSel.options[0].text=="") 
     elSel.remove(0);
  
  if (elSel.selectedIndex >= 0 && elSel.options[0].text!= "Select a State" ) 
  {
    var elOptNew = document.createElement('option');
    elOptNew.text = 'Select a State';
    elOptNew.value = '0';
    var elOptOld = elSel.options[0];  
   
    try {
      elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
      elSel.selectedIndex=0;
      insertOptionCity();
    }
    catch(ex) {
      elSel.add(elOptNew, 0); // IE only
      elSel.selectedIndex=0;
      insertOptionCity();
    }
  }
}
 /**************************************************************************************************/
 /* Function*/
 /**/
 /*Description:*/
 /**/
 /**************************************************************************************************/ 

function insertOptionCity()
{
  var elSel = document.getElementById('ddlSelectCity');
  elSel.style.color="#bababa";
  
  if (elSel.selectedIndex >= 0 && elSel.options[0].text!= "Select a City" ) 
  {
    var elOptNew = document.createElement('option');
    elOptNew.text = 'Select a City';
    elOptNew.value = '0';
    var elOptOld = elSel.options[0];  
   
   elSel.disabled=true;//disable;
    try {
      elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
      elSel.selectedIndex=0;
      elSel.disabled=true;
    }
    catch(ex) {
      elSel.add(elOptNew, 0); // IE only
      elSel.selectedIndex=0;
     elSel.disabled=true;
    }
  }
}   
    
window.onresize = function() {
	setFooter();
}

//]]>