﻿
$(document).ready(function() {
     
     
     
    $("#btnSearch").focus(function () {$("#divInputs").append("<br/>Searching...<br /><img style='margin-left:45px;z-index:5;' id='loadGif' src='images2/ajax-loader.gif' alt='Searching'/>"); });
    
    $("#btnSearch").click(function () {SearchRequest(); });


        var lblError = $("#lblError");
        var inpt1 = $("#inpt1");
        var inpt2 = $("#inpt2");
        var inpt3 = $("#inpt3");
        var inpt4 = $("#inpt4");
        var inpt5 = $("#inpt5");        
        
        var cityID = "";
        var stateID = "";
        var countryID = "";
        
        var cityAds = new Array();
        var marketAds = 0;
       
            //$("#inpt1").keydown(function(){ LoadCat2();});
            $("#inpt1").keyup(function(){ AutoSuggestCity();ClearSuggest(this);});
            $("#inpt2").keyup(function(){ AutoSuggestBorough();ClearSuggest(this);});
            $("#inpt5").keyup(function(){ AutoSuggestZip();ClearSuggest(this);});
        

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
    function Vendor(){
    
        var vendorID;
        var vendorName;
        var vendorAddress;
        var vendorCityID;
        var vendorBoroughID;
        var vendorZipCode; 
        var vendorPhone; 
        var vendorWebsite;
        var vendorHours;
        var vendorCuisine;
        var vendorProduct;
        var vendorPriceRange;
        var vendorEmail;
      
        var vendorPrefer;
        var vendorNonProfit;
        var vendorCatID;
        var vendorSubID;
        var vendorVaadID;                                                  
        var vendorCouponID;
        var vendorImg;
        var vendorLat;
        var vendorLong; 


            this.setID = function(id) {
                        vendorID = id;
            }
            this.getID = function() {
                        return vendorID;
            }
            ///////////////////////////////////////
            this.setName = function(name) {
                        vendorName = name;
            }
            this.getName = function() {
                        return vendorName;
            }
            ///////////////////////////////////////
            this.setAddress = function(address) {
                        vendorAddress = address;
            }
            this.getAddress = function() {
                        return vendorAddress;
            }
            ///////////////////////////////////////
            this.setCityID = function(id) {
                        vendorCityID = id;
            }
            this.getCityID = function() {
                        return vendorCityID;
            }
            ///////////////////////////////////////
            this.setBoroughID = function(id) {
                        vendorBoroughID = id;
            }
            this.getBoroughID = function() {
                        return vendorBoroughID;
            }
            ///////////////////////////////////////
            this.setZipCode = function(zipCode) {
                        vendorZipCode = zipCode;
            }
            this.getZipCode = function() {
                        return vendorZipCode;
            }
            ///////////////////////////////////////
            this.setPhone = function(phone) {
                        vendorPhone = phone;
            }
             this.getPhone = function() {
                        return vendorPhone;
            }
            ///////////////////////////////////////
            this.setWebsite = function(website) {
                        vendorWebsite = website;
            }
             this.getWebsite = function() {
                        return vendorWebsite;
            }
            ///////////////////////////////////////
            this.setHours = function(hours) {
                        vendorHours = hours;
            }
             this.getHours = function() {
                        return vendorHours;
            }
            ///////////////////////////////////////
            this.setCuisine = function(cuisine) {
                        vendorCuisine = cuisine;
            }
             this.getCuisine = function() {
                        return vendorCuisine;
            }
            ///////////////////////////////////////
            this.setProduct = function(product) {
                        vendorProduct = product;
            }
             this.getProduct = function() {
                        return vendorProduct;
            }
            ///////////////////////////////////////
            this.setPriceRange = function(range) {
                        vendorPriceRange = range;
            }
             this.getPriceRange = function() {
                        return vendorPriceRange;
            }
            ///////////////////////////////////////
            this.setEmail = function(email) {
                        vendorEmail = email;
            }
             this.getEmail = function() {
                        return vendorEmail;
            }
            ///////////////////////////////////////
            this.setPrefer = function(prefer) {
                        vendorPrefer = prefer;
            }
             this.getPrefer = function() {
                        return vendorPrefer;
            }
            ///////////////////////////////////////
            this.setNonProfit = function(profit) {
                        vendorNonProfit = profit;
            }
             this.getNonProfit = function() {
                        return vendorNonProfit;
            }
            ///////////////////////////////////////
            this.setCategory = function(cat) {
                        vendorCatID = cat;
            }
             this.getCategory = function() {
                        return vendorCatID;
            }
            ///////////////////////////////////////
            this.setSubcategory = function(sub) {
                        vendorSubID = sub;
            }
             this.getSubcategory = function() {
                        return vendorSubID;
            }
            ///////////////////////////////////////
            this.setVaad = function(vaad) {
                        vendorVaadID = vaad;
            }
             this.getVaad = function() {
                        return vendorVaadID;
            }
            ///////////////////////////////////////
            this.setCoupon = function(coupon) {
                        vendorCouponID = coupon;
            }
             this.getCoupon = function() {
                        return vendorCouponID;
            }
            ///////////////////////////////////////
            this.setImage = function(image) {
                        vendorImg = image;
            }
             this.getImage= function() {
                        return vendorImg;
            }
            ///////////////////////////////////////
            this.setLatitude = function(latitude) {
                        vendorLat = latitude;
            }
             this.getLatitude = function() {
                        return vendorLat;
            }
            ///////////////////////////////////////
            this.setLongitude = function(longitude) {
                        vendorLong = longitude;
            }
             this.getLongitude = function() {
                        return vendorLong;
            }
            ///////////////////////////////////////
            
            


    }//End Vendor
    
    
    function Vaad(){
    
            var vaadID;
            var vaadName;
            var vaadAddress;
            var vaadCity;
            var vaadState;
            var vaadCountry
            var vaadZipCode;
            var vaadPhone;
            var vaadWebsite;
            
            this.setID = function(id) {
                        vaadID = id;
            }
            this.getID = function() {
                        return vaadID;
            }
            ///////////////////////////////////////
            this.setName = function(name) {
                        vaadName = name;
            }
            this.getName = function() {
                        return vaadName;
            }
            ///////////////////////////////////////
             this.setAddress = function(address) {
                        vaadAddress = address;
            }
            this.getAddress = function() {
                        return vaadAddress;
            }
             ///////////////////////////////////////
            this.setCity = function(city) {
                        vaadCity = city;
            }
            this.getCity = function() {
                        return vaadCity;
            }
             ///////////////////////////////////////
             this.setState = function(state) {
                        vaadState = state;
            }
            this.getState = function() {
                        return vaadState;
            }
             ///////////////////////////////////////
             this.setCountry = function(country) {
                        vaadCountry = country;
            }
            this.getCountry = function() {
                        return vaadCountry;
            }
            ///////////////////////////////////////
            this.setZipCode = function(zipCode) {
                        vaadZipCode = zipCode;
            }
            this.getZipCode = function() {
                        return vaadZipCode;
            }
            ///////////////////////////////////////
            this.setPhone = function(phone) {
                        vaadPhone = phone;
            }
             this.getPhone = function() {
                        return vaadPhone;
            }            
            ///////////////////////////////////////
            this.setWebsite = function(website) {
                        vaadWebsite = website;
            }
             this.getWebsite = function() {
                        return vaadWebsite;
            }
    
    }
    
    
     function MetroCity(){
    
            var metroCityID;
            var metroCityName;
    
            this.setID = function(id) {
                        metroCityID = id;
            }
            this.getID = function() {
                        return metroCityID;
            }
            ///////////////////////////////////////
            this.setName = function(name) {
                        metroCityName = name;
            }
            this.getName = function() {
                        return metroCityName;
            }
    
    }
    
    function Borough(){
    
            var boroughID;
            var boroughName;
    
            this.setID = function(id) {
                        boroughID = id;
            }
            this.getID = function() {
                        return boroughID;
            }
            ///////////////////////////////////////
            this.setName = function(name) {
                        boroughName = name;
            }
            this.getName = function() {
                        return boroughName;
            }
    
    }
    
    function Category(){
    
            var categoryID;
            var categoryName;
    
            this.setID = function(id) {
                        categoryID = id;
            }
            this.getID = function() {
                        return categoryID;
            }
            ///////////////////////////////////////
            this.setName = function(name) {
                        categoryName = name;
            }
            this.getName = function() {
                        return categoryName;
            }
    
    }
    
    
    function Subcategory(){
    
            var subcategoryID;
            var subcategoryName;
            var mainCategory;
    
            this.setID = function(id) {
                        subcategoryID = id;
            }
            this.getID = function() {
                        return subcategoryID;
            }
            ///////////////////////////////////////
            this.setName = function(name) {
                        subcategoryName = name;
            }
            this.getName = function() {
                        return subcategoryName;
            }
            ///////////////////////////////////////
            this.setMainCategory = function(catID) {
                        mainCategory = catID;
            }
            this.getMainCategory = function() {
                        return mainCategory;
            }
    }
    
    
    function Advertisement(){
    
            var imageName;
            var imageLink;
            var adSpace;
            
            
            this.setImageName = function(img) {
                        imageName = img;
            }
            this.getImageName = function() {
                        return imageName;
            }
            this.setImageLink = function(link) {
                        imageLink = link;
            }
            this.getImageLink = function() {
                        return imageLink;
            }
            
            this.setAdSpace = function(space) {
                        adSpace = space;
            }
            this.getAdSpace = function() {
                        return adSpace;
            }
            
            
    }
    
       
/////////////////////////////////////////////////////////////////////////////// End of Class Definitions    
    
    function SearchRequest(){ 
            
        var city = $("#inpt1").val();        
        var borough = $("#inpt2").val();
        var state = $("#inpt3").val();
        var country = $("#inpt4").val();
        var zip = $("#inpt5").val();
        
        SetAdImages(city,state,country);
        
         if(document.getElementById("lblCityTemp")) {
                var lblCityTemp = document.getElementById("lblCityTemp");
                lblCityTemp.parentNode.removeChild(lblCityTemp);
            }
           
         if(document.getElementById("lblBoroughTemp")) {
                var lblBoroughTemp = document.getElementById("lblBoroughTemp");
                lblBoroughTemp.parentNode.removeChild(lblBoroughTemp);
            }  
            
         if(document.getElementById("lblStateTemp")) {
                var lblStateTemp = document.getElementById("lblStateTemp");
                lblStateTemp.parentNode.removeChild(lblStateTemp);
            }
            
        if(document.getElementById("lblCountryTemp")) {
            var lblCountryTemp = document.getElementById("lblCountryTemp");
            lblCountryTemp.parentNode.removeChild(lblCountryTemp);
        } 
        
        if(document.getElementById("lblZipTemp")) {
                var lblZipTemp = document.getElementById("lblZipTemp");
                lblZipTemp.parentNode.removeChild(lblZipTemp);
            }
        
        var lblCityTemp = document.createElement("label");
            lblCityTemp.setAttribute("id","lblCityTemp");
            lblCityTemp.style.visibility = 'hidden';
            lblCityTemp.innerHTML = city;
       
            
        var lblBoroughTemp = document.createElement("label");
            lblBoroughTemp.setAttribute("id","lblBoroughTemp");
            lblBoroughTemp.style.visibility = 'hidden';
            lblBoroughTemp.innerHTML = borough;        
        
       
        var lblStateTemp = document.createElement("label");
            lblStateTemp.setAttribute("id","lblStateTemp");
            lblStateTemp.style.visibility = 'hidden';
            lblStateTemp.innerHTML = state;
            
       
        var lblCountryTemp = document.createElement("label");
            lblCountryTemp.setAttribute("id","lblCountryTemp");
            lblCountryTemp.style.visibility = 'hidden';
            lblCountryTemp.innerHTML = country;
        
        
        var lblZipTemp = document.createElement("label");
            lblZipTemp.setAttribute("id","lblZipTemp");
            lblZipTemp.style.visibility = 'hidden';
            lblZipTemp.innerHTML = zip;
        
        $("#navMenu").append(lblCityTemp);
        $("#navMenu").append(lblBoroughTemp);
        $("#navMenu").append(lblStateTemp);
        $("#navMenu").append(lblCountryTemp);
        $("#navMenu").append(lblZipTemp);
        
        
        
        var btnRefine = document.createElement('input');
        btnRefine.setAttribute("id","btnRefine");
        btnRefine.setAttribute("type","button");
        btnRefine.setAttribute("value","Refine Search");
    
        
        var l = $("#lblCount").html();
        
        var metroCities = new Array();
        var boroughs = new Array();
        var selectedCat = new Array();        
        var vendors = new Array();
        var vaads = new Array();
        var categories = new Array();
        var subcategories = new Array();
        var coupons = new Array();
        

            $.ajax({
                  url: "vendor_get.aspx",
                  data:{city:city, borough:borough, state:state, country:country, zip:zip },
                  async: false,
                  success: function(data){
                                         
                                           
                                           var x=0;
                                           $('Table', data).each(function(data) {
					                                
					                              var id = $(this).find("vendorID").text();                                                  
                                                  var name = $(this).find("vendorName").text(); 
                                                  var cityID = $(this).find("cityID").text();
                                                  var boroughID = $(this).find("boroughID").text();
                                                  var stateID = $(this).find("stateID").text();
                                                  var countryID = $(this).find("countryID").text();
                                                  var address = $(this).find("vendorAddress").text();
                                                  var zipCode = $(this).find("zipCode").text(); 
                                                  var phone = $(this).find("vendorPhone").text(); 
                                                  var website = $(this).find("vendorWebsite").text();
                                                  var hours = $(this).find("vendorHours").text();
                                                  var cuisine = $(this).find("cuisine").text();
                                                  var product = $(this).find("product").text();
//                                                  var priceRange = $(this).find("priceRange").text();
//                                                  var email = $(this).find("vendorEmail").text();
                                                  
                                                  var prefer = $(this).find("vendorPreferred").text();
                                                  var nonProfit = $(this).find("vendorNonProfit").text();
                                                  var catID = $(this).find("catID").text();
                                                  var subID = $(this).find("subID").text();
                                                  var vaadID = $(this).find("vaadID").text();                                                  
                                                  var couponID  = $(this).find("vendorID").text();
					                              var vImg = $(this).find("vendorImage").text();
//                                                  var vLat = $(this).find("vendorLat").text();
//                                                  var vLong = $(this).find("vendorLong").text(); 

                                                  ////////////////////////////////////////////////////// End Find Variables					                              

                                                    var aVendor = new Vendor();
                                                    
                                                    aVendor.setID(id);
                                                    aVendor.setName(name);
                                                    aVendor.setAddress(address);
                                                    aVendor.setCityID(cityID);
                                                    aVendor.setBoroughID(boroughID);
                                                    aVendor.setZipCode(zipCode);
                                                    aVendor.setPhone(phone);
                                                    aVendor.setWebsite(website);
                                                    aVendor.setHours(hours);
                                                    aVendor.setCuisine(cuisine);
                                                    aVendor.setProduct(product);
                                                    aVendor.setPrefer(prefer);
                                                    aVendor.setNonProfit(nonProfit);
                                                    aVendor.setCategory(catID);
                                                    aVendor.setSubcategory(subID);
                                                    aVendor.setVaad(vaadID);
                                                    aVendor.setCoupon(couponID);
                                                    aVendor.setImage(vImg);
                                                   
                                                    vendors[x] = aVendor; 
                                                    x=x+1;                                     
                                                     
                                                    });//End Table
                                         
                                       }//End succes:function(data)

                 });//End of AJAX call
 
 
 
 
            $.ajax({
                  url: "metroCity_get.aspx",
                  data:{city:city,state:state,country:country},
                  async: false,
                  success: function(data){
                  ////////////////////////////////  
//                    alert(data.toString);
//                    if(data == "No Metro"){
//                    
//                    }else{
                                            
                        var cityIndex = 0;
                      $('Table', data).each(function(data) {
                      
                         var cityID = $(this).find("cityID").text();
                         var cityName = $(this).find("cityName").text();
                         

                                        var aCity = new MetroCity();
                                            aCity.setID(cityID);
                                            aCity.setName(cityName);
                                            
                                            metroCities[cityIndex] = aCity;
                                            cityIndex = cityIndex + 1;              
                                      
                                                  
                        });//End Table       
                  
//                    }//End If
                  
                  } //End of success:function(data)
           
            });//End of AJAX call         
            
            
            
             $.ajax({
                  url: "borough_get.aspx",
                  data:{},
                  async: false,
                  success: function(data){
                  ////////////////////////////////  

                                            
                        var bIndex = 0;
                      $('Table', data).each(function(data) {
                      
                         var boroughID = $(this).find("boroughID").text();
                         var boroughName = $(this).find("boroughName").text();
                         

                                        var aBorough = new Borough();
                                            aBorough.setID(boroughID);
                                            aBorough.setName(boroughName);
                                            
                                            boroughs[bIndex] = aBorough;
                                            bIndex = bIndex + 1;              
                                      
                                                  
                        });//End Table       
                  
//                    }//End If
                  
                  } //End of success:function(data)
           
            });//End of AJAX call         
 
 
 
            $.ajax({
                  url: "vaad_get2.aspx",
                  data:{},
                  async: false,
                  success: function(data){
                  ////////////////////////////////  
                    
                                            
                    var vaadIndex = 0;
                  $('Table', data).each(function(data) {
                  
                     var vaadID = $(this).find("vaadID").text();
                     var vaadName = $(this).find("vaadName").text();
                     var vaadAddress = $(this).find("vaadAddress").text();
                     var vaadCity = $(this).find("cityName").text();
                     var vaadState = $(this).find("stateName").text();
                     var vaadCountry = $(this).find("countryName").text();
                     var vaadZipCode = $(this).find("vaadZip").text();
                     var vaadPhone = $(this).find("vaadPhone").text();
                     var vaadWebsite = $(this).find("vaadWebsite").text();    

                                    var aVaad = new Vaad();
                                        aVaad.setID(vaadID);
                                        aVaad.setName(vaadName);
                                        aVaad.setAddress(vaadAddress);
                                        aVaad.setCity(vaadCity);
                                        aVaad.setState(vaadState);
                                        aVaad.setCountry(vaadCountry);
                                        aVaad.setZipCode(vaadZipCode);
                                        aVaad.setPhone(vaadPhone);
                                        aVaad.setWebsite(vaadWebsite);
                                        vaads[vaadIndex] = aVaad;
                                        vaadIndex = vaadIndex + 1;              
                                  
                                              
                    });//End Table       
                  
                  } //End of success:function(data)
           
            });//End of AJAX call                
                 
                 
                 
                 
           
           $.ajax({
                  url: "category_get.aspx",
                  data:{},
                  async: false,
                  success: function(data){
                  ////////////////////////////////  
                    
                    var z = 1;      
                    
                        for(z=1;z<=l;z++){
                        
                            var tempCheck = $("#chk" + z).attr('checked')
                                                
                            if ($("#chk" + z).attr('checked')){                                     
                                            selectedCat[z-1] = $("#lblResult" + z).html()
                                            }
                        
                        }//End For
                       

                        
                    var catIndex = 0;
                  $('Table', data).each(function(data) {
                  
                     var catID = $(this).find("catID").text();
                     var catName = $(this).find("catName").text();                         
                        
                        for(z=0;z<=selectedCat.length;z++){                        
                                if(catName == selectedCat[z]){

                                    var aCategory = new Category();
                                        aCategory.setID(catID);
                                        aCategory.setName(catName);
                                        categories[catIndex] = aCategory;
                                        catIndex = catIndex + 1;                                        
                                                                                
                                  }//End If
                         }//End For 
                                              
                    });//End Table       
                  
                  } //End of success:function(data)
           
            });//End of AJAX call
                    
           
           
           
           $.ajax({
                  url: "subcat_get_results.aspx",
                  data:{},
                  async: false,
                  success: function(data){
                                    
                    var sIndex = 0;
                    $('Table', data).each(function(data) {
                        
                        var subID = $(this).find("subID").text();
                        var subName = $(this).find("subName").text();                        
                        var mainCategory = $(this).find("mainCategory").text();
                        
                        var cIndex = 0;                      
                        for(cIndex=0;cIndex<categories.length;cIndex++){
                                                         
                            var aCat = new Category();
                                aCat = categories[cIndex];                                
                            var cID = aCat.getID();                    

                                if(mainCategory == cID){                                                                   
                                    var aSubcategory = new Subcategory();
                                        aSubcategory.setID(subID);
                                        aSubcategory.setName(subName);
                                        aSubcategory.setMainCategory(mainCategory);
                                        subcategories[sIndex] = aSubcategory;                                 
                                        sIndex = sIndex + 1;
                                            
                                }//End If(mainCategory == cID)  
                                                      
                        }//End For(cIndex=0;cIndex<=categories.length;cIndex++)                       
                    
                    });//End $('Table', data).each(function(data)
                  
                  }//End success:function(data)
           
            });//End of AJAX call
            
            
            
             $.ajax({
                  url: "coupon_get.aspx",
                  data:{},
                  async: false,
                  success: function(data){
                  ////////////////////////////////  

                                            
                        var couponIndex = 0;
                      $('Table', data).each(function(data) {
                        
                             var vendorID = $(this).find("vendorID").text();  
                             
                                    coupons[couponIndex] = vendorID;
                                    couponIndex = couponIndex + 1;              
                                          
                                                      
                            });//End Table   
                  
                  } //End of success:function(data)
           
            });//End of AJAX call         
            
            
            //////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////// End of object & array constructs ////////////////////////////////////   
            ////////////////////////////////////////////////////////////////////////////////////////////////////// 
            
                                 
            $("#lblError").val("");
            $("#centerDiv").empty();             
            
            var disclaimerDiv = document.createElement('div');
                disclaimerDiv.setAttribute("id","disclaimerDiv");
                $("#centerDiv").append(disclaimerDiv);                
                $("#disclaimerDiv").html("We strive to ensure that all food establishments are supervised by an Orthodox organization.  If in doubt on whether not they meet your specific standards please either contact the Supervising Authority or your Rabbi.<br />");    
        
               
                
                
                $("#disclaimerDiv").append(btnRefine);
                $("#btnRefine").click(function () {RefineSearch();LoadCat2();})
            var searchContainerDiv = document.createElement('div');
                searchContainerDiv.setAttribute("id","searchContainerDiv");
                $("#centerDiv").append(searchContainerDiv);
                
                       if(selectedCat.length == 0){ 
                       
                            $("#searchContainerDiv").append("<p>No Categories were selected.<br />Please click the <i>Refine Search</i> button and select at least one category</p>");
                            
                       }
            
            var catIndex = 0;
             var subCount = 1;
                for(catIndex=0;catIndex<categories.length;catIndex++){
                
                    var tempCategory = new Category();
                        tempCategory = categories[catIndex];
                        
                    var tempCatID = tempCategory.getID();
                    var tempCatName = tempCategory.getName();
                    
                    var divCategory = document.createElement("div");
                        divCategory.setAttribute("id","divCategory" + catIndex);
                        divCategory.setAttribute("class","divCategory");
                        
                    var lblCategory = document.createElement("lbl");
                        lblCategory.setAttribute("id","lblCategory" + catIndex);
                        lblCategory.setAttribute("class","lblCategory");
                        
                    $("#searchContainerDiv").append(divCategory);
                    $("#divCategory" + catIndex).append(lblCategory);
                    $("#lblCategory" + catIndex).html(tempCatName);
                    
                    var subIndex = 0;                   
                    
                        for(subIndex=0;subIndex<subcategories.length;subIndex++){
                            
                            var tempSubcategory = new Subcategory();
                                tempSubcategory = subcategories[subIndex];
                                
                            var tempSubcatID = tempSubcategory.getID();
                            var tempSubcatName = tempSubcategory.getName();
                            var tempSubMainCatID = tempSubcategory.getMainCategory();
                                                        
                                if(tempSubMainCatID == tempCatID){                                
                                    
                                    if(tempSubcatName != "0-None"){
                                    var divSubcategory = document.createElement("div");
                                        divSubcategory.setAttribute("id","divSubcategory" + subCount);
                                        divSubcategory.setAttribute("class","divSubcategory");                                        
                                        
                                    var lblSubcategory = document.createElement("lbl");
                                        lblSubcategory.setAttribute("id","lblSubcategory" + subCount);
                                        lblSubcategory.setAttribute("class","lblSubcategory");
                                        
                                    $("#divCategory" + catIndex).append(divSubcategory);
                                    $("#divSubcategory" + subCount).append(lblSubcategory);                                    
                                    
                                    if(tempSubcatName == "0-None"){                                        
                                        $("#lblSubcategory" + subCount).css("margin-bottom",-30);
                                        }else{
                                        $("#lblSubcategory" + subCount).html(tempSubcatName);
                                        }
                                   }
                                    var vendorIndex = 0;
                                    
                                       for(vendorIndex=0;vendorIndex<vendors.length;vendorIndex++){
                                            
                                            var tempVendor = new Vendor();
                                                tempVendor = vendors[vendorIndex];
                                                
                                            var tempVendorID = tempVendor.getID();
                                            var tempVendorName = tempVendor.getName();
                                            var tempVendorAddress = tempVendor.getAddress();
                                            var tempVendorCityID = tempVendor.getCityID();
                                            var tempVendorBoroughID = tempVendor.getBoroughID();
                                            var tempVendorZipCode = tempVendor.getZipCode();
                                            var tempVendorPhone = tempVendor.getPhone();
                                            var tempVendorWebsite = tempVendor.getWebsite();
                                            var tempVendorHours = tempVendor.getHours();                                            
                                            var tempVendorCuisine = tempVendor.getCuisine();
                                            var tempVendorProduct = tempVendor.getProduct();
                                            var tempVendorPrefer = tempVendor.getPrefer();
                                            var tempVendorNonProfit = tempVendor.getNonProfit();
                                            var tempVendorCatID = tempVendor.getCategory();
                                            var tempVendorSubID = tempVendor.getSubcategory();
                                            var tempVendorVaadID = tempVendor.getVaad();
                                            var tempVendorCouponID = tempVendor.getCoupon();
                                            var tempVendorImg = tempVendor.getImage();
                                            
                                              
                                            
                                                if(tempVendorSubID == tempSubcatID){
                                                
                                                    var searchDiv = document.createElement("div");
                                                        searchDiv.setAttribute("id","searchDiv" + vendorIndex);
                                                        searchDiv.setAttribute("style","margin-left:10px");
                                                        
                                                    var hiddenSpan = document.createElement("span");
                                                        hiddenSpan.setAttribute("id","hiddenSpan" + vendorIndex);
                                                        
                                                    var searchImgDiv = document.createElement("div");
                                                        searchImgDiv.setAttribute("id","searchImgDiv" + vendorIndex);
                                                        
                                                    if((tempVendorPrefer == "true")||(tempVendorNonProfit == "true")){                                                      
                                                         var searchImg = document.createElement("img");
                                                          searchImg.setAttribute("id","searchImg" + vendorIndex);
                                                          }
                                                          
                                                    if((tempVendorNonProfit == "true")){                               
                                                       searchDiv.setAttribute("class","searchDiv2");                                                    
                                                       searchImgDiv.setAttribute("class","searchImgDiv2");

                                                      }else{ 
                                                        searchDiv.setAttribute("class","searchDiv");
                                                        searchImgDiv.setAttribute("class","searchImgDiv");                                                      
                                                      }
                                                      
                                                    var lblName = document.createElement("label");
                                                        lblName.setAttribute("id","lblName" + vendorIndex);
                                                        
                                                    var lblCity = document.createElement("label");
                                                        lblCity.setAttribute("id","lblCity" + vendorIndex); 
                                                        
                                                    if(tempVendorBoroughID != 0){
                                                        var lblBorough = document.createElement("label");
                                                            lblBorough.setAttribute("id","lblBorough" + vendorIndex);
                                                      }
                                                    
                                                    if(tempVendorAddress != ""){
                                                        var lblAddress = document.createElement("label");
                                                            lblAddress.setAttribute("id","lblAddress" + vendorIndex);
                                                      }
                                                      
                                                    if(tempVendorZipCode != ""){    
                                                        var lblZip = document.createElement("label");
                                                            lblZip.setAttribute("id","lblZip" + vendorIndex);
                                                          } 
                                                          
                                                    if(tempVendorPhone != ""){
                                                        var lblPhone = document.createElement("label");
                                                            lblPhone.setAttribute("id","lblPhone" + vendorIndex);
                                                          } 
                                                            
                                                    if((tempVendorWebsite != "") && ((tempVendorPrefer == "true")||(tempVendorNonProfit == "true"))){
                                                        var lblWebsite = document.createElement("label");
                                                            lblWebsite.setAttribute("id","lblWebsite" + vendorIndex);
                                                          }
                                                          
                                                    if((tempVendorCuisine != "") && (tempVendorNonProfit != "true")){ 
                                                        var lblCuisine = document.createElement("label");
                                                            lblCuisine.setAttribute("id","lblCuisine" + vendorIndex);
                                                            lblCuisine.setAttribute("class","lblCuisine");
                                                          }       
                                                    
                                                     if(tempVendorNonProfit != "true"){
                                                        var lblReview = document.createElement("label");
                                                            lblReview.setAttribute("id","lblReview" + vendorIndex);
                                                            lblReview.setAttribute("class","lblReview");
                                                                if(tempVendorVaadID !=0){
                                                                    var lblVaad = document.createElement("label");
                                                                    lblVaad.setAttribute("id","lblVaad" + vendorIndex);
                                                                    lblVaad.setAttribute("class","lblVaad");
                                                                    }    
                                                            }
                                                     
                                                     if(tempVendorNonProfit == "true"){
                                                        var lblHotel = document.createElement("label");
                                                            lblHotel.setAttribute("id","lblHotel" + vendorIndex);
                                                            lblHotel.setAttribute("class","lblHotel");
                                                            }
                                                      
                                                    if((tempVendorAddress != "") && (tempVendorZipCode != "")){
                                                        var lblMap = document.createElement("label");
                                                            lblMap.setAttribute("id","lblMap" + vendorIndex);
                                                            lblMap.setAttribute("class","lblMap"); 
                                                            }
                                            
                                            
                                            
                                                    if(tempVendorHours != ""){
                                                        
                                                        var lblHours = document.createElement("label");
                                                            lblHours.setAttribute("id","lblHours" + vendorIndex);
                                                            lblHours.setAttribute("class","lblHours"); 
                                                            }
                                                            
                                                        var lblCoupon = document.createElement("label");
                                                            lblCoupon.setAttribute("id","lblCoupon" + vendorIndex);
                                                            lblCoupon.setAttribute("class","lblCoupon"); 
                                                        
                                                    ///////////////////////////////////////////////////////////////// End Create Elements 
                                                    
                                                   
                                                    $("#divCategory" + catIndex).append(searchDiv);
                                                    $("#searchDiv" + vendorIndex).append(searchImgDiv);
                                                    $("#searchDiv" + vendorIndex).append(hiddenSpan);
                                                    
                                                    if((tempVendorPrefer == "true")||(tempVendorNonProfit == "true")){ 
                                                          $("#searchImgDiv" + vendorIndex).append(searchImg);
                                                          }
                                                          
                                                    $("#searchDiv" + vendorIndex).append(lblName);
                                                    $("#searchDiv" + vendorIndex).append("<br />");
                                                    
                                                    if(tempVendorAddress != ""){
                                                        $("#searchDiv" + vendorIndex).append(lblAddress);
                                                        }
                                                    
                                                    if(tempVendorBoroughID != 0){
                                                        $("#searchDiv" + vendorIndex).append(lblBorough);
                                                        }
                                                        
                                                    $("#searchDiv" + vendorIndex).append(lblCity);
                                                    
                                                    if(tempVendorZipCode != ""){    
                                                        
                                                        $("#searchDiv" + vendorIndex).append(lblZip);
                                                          } 
                                                                                                    
                                                    $("#searchDiv" + vendorIndex).append("<br />");
                                                    
                                                    if(tempVendorPhone != ""){
                                                          $("#searchDiv" + vendorIndex).append(lblPhone);
                                                          $("#searchDiv" + vendorIndex).append("<br />");
                                                          }
                                                      
                                                   
                                                          
                                                    if(tempVendorNonProfit != "true"){
                                                          $("#searchDiv" + vendorIndex).append(lblReview);
                                                              if(tempVendorVaadID !=0){
                                                                $("#searchDiv" + vendorIndex).append(lblVaad);
                                                              }
                                                          }
                                                          
                                                     if((tempVendorCuisine != "") && (tempVendorNonProfit != "true")){
                                                          $("#searchDiv" + vendorIndex).append(lblCuisine);
//                                                          $("#searchDiv" + vendorIndex).append("<br />");
                                                          }
                                                          
                                                    if(tempVendorNonProfit == "true"){
                                                          $("#searchDiv" + vendorIndex).append(lblHotel);                                                      
                                                          }
                                                          
                                                     if((tempVendorAddress != "")&& (tempVendorZipCode != "")){
                                                          $("#searchDiv" + vendorIndex).append(lblMap);
                                                          }
                                            
                                                    if(tempVendorHours != ""){
                                                         
                                                          $("#searchDiv" + vendorIndex).append(lblHours);
                                                          }
                                                     
                                                     
                                                     $("#searchDiv" + vendorIndex).append(lblCoupon);
                                                          
                                                    $("#searchDiv" + vendorIndex).append("<br />");
                                                    $("#searchDiv" + vendorIndex).append(hiddenSpan);
                                                    $("#searchDiv" + vendorIndex).append("<hr />"); 
                                                        
                                                     ///////////////////////////////////////////////////////// End Append Elements
                                                
                                                        if((tempVendorPrefer == "true")||(tempVendorNonProfit == "true")&& (tempVendorWebsite != "")){                                           
                                                              $("#lblName" + vendorIndex).html("<a href='http://" + tempVendorWebsite + "' target='_blank'>" + tempVendorName + "</a>"); 
                                                              $("#lblName" + vendorIndex).css("font-size","14px");
                                                              $("#lblName" + vendorIndex).css("color","blue");
                                                              }else{
                                                              $("#lblName" + vendorIndex).html(tempVendorName); 
                                                              $("#lblName" + vendorIndex).css("font-size","14px");
                                                              $("#lblName" + vendorIndex).css("color","blue");
                                                              }
                                                              
                                                        if(tempVendorAddress != ""){                                                                                                    
                                                              $("#lblAddress" + vendorIndex).html(tempVendorAddress + ", ");                                                  
                                                              $("#lblAddress" + vendorIndex).css("font-size","12px");
                                                              } 
                                                              
                                                        if(tempVendorBoroughID != 0){                                                                                                    
                                                              
                                                               var boroughIndex=0;
                                                                    for(boroughIndex=0;boroughIndex<boroughs.length;boroughIndex++){  
                                                                            
                                                                            var tempBorough = new Borough();
                                                                                tempBorough = boroughs[boroughIndex];
                                                                                
                                                                                tempBoroughID = tempBorough.getID();
                                                                                tempBoroughName = tempBorough.getName();
                                                                                
                                                                                if(tempVendorBoroughID == tempBoroughID){
                                                                                
                                                                                     $("#lblBorough" + vendorIndex).html(tempBoroughName + ", ");                                                  
                                                                                     $("#lblBorough" + vendorIndex).css("font-size","14px");
                                                                                
                                                                                }
                                                                    
                                                                    }
                                                              
//                                                              
                                                              } 
                                                        
                                                        if(metroCities.length > 0){
                                                        
                                                            for(cityIndex=0;cityIndex<metroCities.length;cityIndex++){                                                                        
                                                                        
                                                                        var tempCity = new MetroCity();
                                                                        var tempCity = metroCities[cityIndex];
                                                                            
                                                                        var cityID = tempCity.getID();
                                                                            cityName = tempCity.getName();
                                                                            
                                                                        
                                                                        if(cityID == tempVendorCityID){    
                                                                        
                                                                            $("#lblCity" + vendorIndex).html(cityName + " - ");
                                                                            
                                                                            if(tempVendorNonProfit == "true"){
                                                                                    $("#lblHotel" + vendorIndex).html("<a href='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=hotels+nearby+" + tempVendorAddress + "+" + cityName + "+" + state + "&ie=UTF8&hq=hotels+nearby&hnear=" + tempVendorAddress + ",+" + cityName + ",+" + state + "+" + tempVendorZipCode + "&z=14'" + "target='_blank'>Nearby Hotels</a>&nbsp;&bull;&nbsp;");
                                                                                    $("#lblHotel" + vendorIndex).css("font-size","12px");
                                                                                    }
                                                                                    
                                                                                if((tempVendorAddress != "")&& (tempVendorZipCode != "")){
                                                                                    //     $("#lblMap" + x).html("<a href='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=7360 E. Acoma+Scottsdale+Arizona&ie=UTF8&hq=&hnear=7360 E Acoma Dr,+Scottsdale,+Arizona+85260&z=17' target='_blank'>Map</a>&nbsp;&bull;&nbsp;");
                                                                                    $("#lblMap" + vendorIndex).html("<a href='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" + tempVendorAddress + "+" + cityName + "+" + state + "&ie=UTF8&hq=&hnear=" + tempVendorAddress + ",+" + cityName + ",+" + state + "+" + tempVendorZipCode + "&z=14'" + "target='_blank'>Map</a>");
                                                                                    $("#lblMap" + vendorIndex).css("font-size","12px");
                                                                                    }
                                                                            
                                                                            
                                                                        
                                                                        }
                                                                            
                                                                            
                                                            }
                                                        
                                                        }else{
                                                        
                                                            $("#lblCity" + vendorIndex).html(city + " - ");
                                                            
                                                            if(tempVendorNonProfit == "true"){
                                                                    $("#lblHotel" + vendorIndex).html("<a href='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=hotels+nearby+" + tempVendorAddress + "+" + city + "+" + state + "&ie=UTF8&hq=hotels+nearby&hnear=" + tempVendorAddress + ",+" + city + ",+" + state + "+" + tempVendorZipCode + "&z=14'" + "target='_blank'>Nearby Hotels</a>&nbsp;&bull;&nbsp;");
                                                                    $("#lblHotel" + vendorIndex).css("font-size","12px");
                                                                    }
                                                                    
                                                                if((tempVendorAddress != "")&& (tempVendorZipCode != "")){
                                                                    //     $("#lblMap" + x).html("<a href='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=7360 E. Acoma+Scottsdale+Arizona&ie=UTF8&hq=&hnear=7360 E Acoma Dr,+Scottsdale,+Arizona+85260&z=17' target='_blank'>Map</a>&nbsp;&bull;&nbsp;");
                                                                    $("#lblMap" + vendorIndex).html("<a href='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" + tempVendorAddress + "+" + city + "+" + state + "&ie=UTF8&hq=&hnear=" + tempVendorAddress + ",+" + city + ",+" + state + "+" + tempVendorZipCode + "&z=14'" + "target='_blank'>Map</a>");
                                                                    $("#lblMap" + vendorIndex).css("font-size","12px");
                                                                    }
                                                            
                                                            
                                                            
                                                        
                                                        }
                                                        
                                                        
                                                              
                                                        
                                                        
                                                        if(tempVendorZipCode != ""){ 
                                                              $("#lblZip" + vendorIndex).html(tempVendorZipCode); 
                                                              $("#lblZip" + vendorIndex).css("font-size","12px");
                                                              }
                                                          
                                                        if(tempVendorPhone != ""){
                                                              $("#lblPhone" + vendorIndex).html("Phone: " + tempVendorPhone);
                                                              $("#lblPhone" + vendorIndex).css("font-size","12px");                                                      
                                                              }
                                                              
                                                        if((tempVendorCuisine != "") && (tempVendorNonProfit != "true")){
                                                              if(tempVendorProduct == "true"){
                                                                      $("#lblCuisine" + vendorIndex).html("Product&nbsp;&bull;&nbsp;");
                                                                      $("#lblCuisine" + vendorIndex).simpletip({ content: tempVendorCuisine , position: 'bottom',focus: true, fixed: true });
                                                                      $("#lblCuisine" + vendorIndex).css("font-size","12px");
                                                                }else{
                                                                      $("#lblCuisine" + vendorIndex).html("Cuisine&nbsp;&bull;&nbsp;");
                                                                      $("#lblCuisine" + vendorIndex).simpletip({ content: tempVendorCuisine , position: 'bottom',focus: true, fixed: true });
                                                                      $("#lblCuisine" + vendorIndex).css("font-size","12px");
                                                                      }
                                                             }
                                                        
                                                        if((tempVendorPrefer == "true")||(tempVendorNonProfit == "true")){
                                                        
                                                            if(tempVendorImg == ""){
                                                                    searchImg.setAttribute("src","images2/jew_thumb.jpg");
                                                                    }else{
                                                                    searchImg.setAttribute("src","uploads/" + tempVendorImg);
                                                                    searchImg.setAttribute("width","40px")
                                                                    searchImg.setAttribute("height","40px")
                                                                    }                                                            
                                                             }
                                                             
                                                        if(tempVendorNonProfit != "true"){                                                         
//                                                                
                                                                
                                                            $("#lblReview" + vendorIndex).html("<a href='review_temp.aspx?id=" + tempVendorID + "&city=" + city + "' target='blank'>Reviews</a>&nbsp;&bull;&nbsp;");                                                              
                                                                
                                                                if(tempVendorVaadID !=0){                                                                    
                                                                    
                                                                    var vaadIndex=0;
                                                                    for(vaadIndex=0;vaadIndex<vaads.length;vaadIndex++){                                                                        
                                                                        
                                                                        var tempVaad = new Vaad();
                                                                            tempVaad = vaads[vaadIndex];
                                                                            
                                                                            tempVaadID = tempVaad.getID();
                                                                            tempVaadName = tempVaad.getName();
                                                                            tempVaadAddress = tempVaad.getAddress();
                                                                            tempVaadCity = tempVaad.getCity();
//                                                                            tempVaadState = tempVaad.getState();
//                                                                            tempVaadCountry = tempVaad.getCountry();
                                                                            tempVaadZipCode = tempVaad.getZipCode();
                                                                            tempVaadPhone = tempVaad.getPhone();
                                                                            tempVaadWebsite = tempVaad.getWebsite();
                                                                            
                                                                            if(tempVendorVaadID == tempVaadID){
                                                                                
                                                                                var strVaad = "";
                                                                                strVaad = tempVaadName;
                                                                                strVaad = strVaad + "<br />";
                                                                                if(tempVaadAddress != ""){
                                                                                strVaad = strVaad + (tempVaadAddress + ", ");
                                                                                }
                                                                                strVaad = strVaad + (tempVaadCity);
                                                                                if(tempVaadZipCode != ""){
                                                                                strVaad = strVaad  + " - " + tempVaadZipCode;
                                                                                }
                                                                                strVaad = strVaad + "<br />";
                                                                                if(tempVaadPhone != ""){
                                                                                strVaad = strVaad + tempVaadPhone;
                                                                                strVaad = strVaad + "<br />";
                                                                                }
                                                                                if(tempVaadWebsite != ""){
                                                                                strVaad = strVaad + "<a href='http://" + tempVaadWebsite + "' target='_blank'>Website</a>";
                                                                                }
                                                                            }//End If(tempVendorVaadID == tempVaadID)
                                                                    
                                                                    }//End For
                                                           
                                                                    $("#lblVaad" + vendorIndex).html("<i>Va'ad</i>&nbsp;&bull;&nbsp;");
                                                                    $("#lblVaad" + vendorIndex).simpletip({ content: strVaad ,position: 'bottom', focus: true, fixed: true });
                                                                    $("#lblVaad" + vendorIndex).css("font-size","12px");
                                                                    
                                                                 }// End IF (tempVendorVaadID !=0)
                                                             }
                                                             
//                                                        if(tempVendorNonProfit == "true"){
//                                                            $("#lblHotel" + vendorIndex).html("<a href='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=hotels+nearby+" + tempVendorAddress + "+" + city + "+" + state + "&ie=UTF8&hq=hotels+nearby&hnear=" + tempVendorAddress + ",+" + city + ",+" + state + "+" + tempVendorZipCode + "&z=14'" + "target='_blank'>Nearby Hotels</a>&nbsp;&bull;&nbsp;");
//                                                            $("#lblHotel" + vendorIndex).css("font-size","12px");
//                                                            }
//                                                            
//                                                        if((tempVendorAddress != "")&& (tempVendorZipCode != "")){
//                                                            //     $("#lblMap" + x).html("<a href='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=7360 E. Acoma+Scottsdale+Arizona&ie=UTF8&hq=&hnear=7360 E Acoma Dr,+Scottsdale,+Arizona+85260&z=17' target='_blank'>Map</a>&nbsp;&bull;&nbsp;");
//                                                            $("#lblMap" + vendorIndex).html("<a href='http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=" + tempVendorAddress + "+" + cityName + "+" + state + "&ie=UTF8&hq=&hnear=" + tempVendorAddress + ",+" + city + ",+" + state + "+" + tempVendorZipCode + "&z=14'" + "target='_blank'>Map</a>");
//                                                            $("#lblMap" + vendorIndex).css("font-size","12px");
//                                                            }
                                                            
                                                         if(tempVendorHours != ""){
                                                            $("#lblHours" + vendorIndex).html("&nbsp;&bull;&nbsp;Hours");
                                                            $("#lblHours" + vendorIndex).simpletip({ content: tempVendorHours , position: 'bottom',focus: true, fixed: true });
                                                            $("#lblHours" + vendorIndex).css("font-size","12px");
                                                            }                   
                                                        
                                                        
                                                          
                                                          var cIndex=0;
                                                          
                                                                    for(cIndex=0;cIndex<coupons.length;cIndex++){                                                                        
                                                                        
                                                                        var tempVendID = coupons[cIndex];
                                                                        
                                                                              if(tempVendorID == tempVendID){
                                                                              
                                                                                $("#lblCoupon" + vendorIndex).html("&nbsp;&bull;&nbsp;<a href='http://www.theroamingjew.com/coupon.aspx?id=" + tempVendorID + "' target='_blank' >Coupon</a>");                                                            
                                                                                $("#lblCoupon" + vendorIndex).css("font-size","12px");
                                                                                } 
                                                            
                                                                    }
                                                                      
                                                                                                                
                                                        }// End if(tempVendorSubID == tempSubcatID)

                                                
                                       }// End  for(vendorIndex=0;vendorIndex<vendors.length;vendorIndex++)
                                    
                                    subCount = subCount + 1;
                                
                                }// End if(tempSubMainCatID == tempCatID)  
                        
                        }// End for(subIndex=0;subIndex<subcategories.length;subIndex++) 
                
                }// End for(catIndex=0;catIndex<categories.length;catIndex++)
            
            
            
            for(rSubIndex=1;rSubIndex<subCount;rSubIndex++){
            
                var checkNext = $("#divSubcategory" + rSubIndex).next().attr("class")
                
                if((checkNext == "divSubcategory")||(checkNext == "divCategory")||(checkNext == undefined)){
                    $("#divSubcategory" + rSubIndex).remove();
                
                }
            
            }//End For
            
            
            
             if(marketAds > 0){
                
                var linkCity = $("#lblCityTemp").html();
                var linkState = $("#lblStateTemp").html();
                var linkCountry = $("#lblCountryTemp").html();
                
                   $.get("link_cityID.aspx", { linkCity:linkCity,linkState:linkState,linkCountry:linkCountry}, function(data) {                            
							
                            		    
                            $('Table', data).each(function(data) {                                             
                                           
                                            var linkCityID = $(this).find("cityID").text();                                           
                                            
                                          
                                           $("#disclaimerDiv").append("<div id='divMarketLink' ><a id='marketLink' href='http://www.theroamingjew.com/market_city.aspx?cityID=" + linkCityID + "&cityName=" + $("#lblCityTemp").html() + "' target='_blank' >Click here to view " + marketAds + " Ads in the " + $("#lblCityTemp").html() + " Marketplace</a></div>");
                                            
                                            
                                           
                                });//End Table
                                
                                
				        }); //End of Get 
                
                }
            
            
            
            for(rCatIndex=0;rCatIndex < l;rCatIndex++){
            
               var parent2 = document.getElementById("divCategory" + rCatIndex);
               if(parent2){
               var childCount2 = parent2.getElementsByTagName("span").length;                
               
                if(childCount2 == 0){
                
                    while(parent2.hasChildNodes()){

                    parent2.removeChild(parent2.lastChild);

                    }//End While
                
                }// End If
                }//End If
            } // End For
            
            
            
            var catCounter = 0;
            var needHelp = true;
            
             for(catCounter=0;catCounter <= (categories.length - 1);catCounter++){ 
             
                    if(document.getElementById("divCategory" + catCounter)){ 
                                           
                        if(document.getElementById("divCategory" + catCounter).hasChildNodes()== true){
                                
                                needHelp = false;
                                
                                
                        }// End If
                    }//End If
            }// End For
            
            
            if(needHelp == true){
                
                $("#divCategory0").append("<p>We apologize, No establishments were found fitting your search criteria.<br /><br />Search tips:<ul><li>Be sure to select at least one of the categories on the right side of the search page.</li><li>Be sure to click on one of the cities we suggest as you type.</li><li>Only cities that we suggest will display results</li><li>Broaden your search results by leaving Borough and/or Zip Code blank.</li><li>Or narrow your results by including Borough and/or Zip Code.</li></ul></p><p>It is possible that a city we suggest will have no establishments.  If you would like to see an establishment added to our site, please <a href='http://www.theroamingjew.com/suggest.aspx' target='_blank' >click here</a></p>");
                
            }
            
            
            
            
    }//End of SearchRequest
    
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    function RefineSearch(){    
   
    
    var city = $("#lblCityTemp").html();
    var borough = $("#lblBoroughTemp").html();
    var state = $("#lblStateTemp").html();
    var country = $("#lblCountryTemp").html();
    var zip = $("#lblZipTemp").html();
    
        $("#centerDiv").empty();
        
        var taglineDiv = document.createElement('div');
            taglineDiv.setAttribute("id","taglineDiv");
        var divLabels = document.createElement('div');
        var divInputs = document.createElement('div');
        var divResults = document.createElement('div');
            
            divLabels.setAttribute("id","divLabels");
            divInputs.setAttribute("id","divInputs");
            divResults.setAttribute("id","divResults");
       
       var lbl1 = document.createElement('label');
       var lbl2 = document.createElement('label');
       var lbl3 = document.createElement('label');
       var lbl4 = document.createElement('label');
       var lbl6 = document.createElement('label');
       
            lbl1.setAttribute("id","lbl1");
            lbl2.setAttribute("id","lbl2");
            lbl3.setAttribute("id","lbl3");
            lbl4.setAttribute("id","lbl4");
            lbl6.setAttribute("id","lbl6");
            
            lbl1.innerHTML = "City: ";
            lbl2.innerHTML = "Borough: ";
            lbl3.innerHTML = "State: ";
            lbl4.innerHTML = "Country: ";
            lbl6.innerHTML = "Zip Code: ";
            
       var inpt1 = document.createElement('input');
       var inpt2 = document.createElement('input');
       var inpt3 = document.createElement('input');
       var inpt4 = document.createElement('input');
       var inpt5 = document.createElement('input');
           
           inpt1.setAttribute("id","inpt1");
           inpt2.setAttribute("id","inpt2");
           inpt3.setAttribute("id","inpt3");
           inpt4.setAttribute("id","inpt4");
           inpt5.setAttribute("id","inpt5");
           
           inpt1.setAttribute("type","text");
           inpt2.setAttribute("type","text");
           inpt3.setAttribute("type","text");
           inpt4.setAttribute("type","text");
           inpt5.setAttribute("type","text");
           
           
           inpt3.setAttribute("disabled","true");
           inpt4.setAttribute("disabled","true");
       
        var divError = document.createElement("div"); 
            divError.setAttribute("id","divError");  
        var lblError = document.createElement("label");
		    lblError.setAttribute("id","lblError"); 
    		   
           
        var btnSearch = document.createElement('input');
            btnSearch.setAttribute("id","btnSearch");
            btnSearch.setAttribute("type","button");
            btnSearch.setAttribute("value","Search");
            
        var btnClear = document.createElement('input');
            btnClear.setAttribute("id","btnClear");
            btnClear.setAttribute("type","button");
            btnClear.setAttribute("value","Clear Fields");
            
        var divSuggest1=document.createElement('div');
        var divSuggest2=document.createElement('div');
        var divSuggest3=document.createElement('div');
        var divSuggest4=document.createElement('div');
            divSuggest1.setAttribute("id","divSuggest1");
            divSuggest2.setAttribute("id","divSuggest2");
            divSuggest3.setAttribute("id","divSuggest3"); 
            divSuggest4.setAttribute("id","divSuggest4");  
    
        $("#centerDiv").append(taglineDiv);
        $("#centerDiv").append(divLabels);
        $("#centerDiv").append(divInputs);
        $("#centerDiv").append(divResults);
        
        $("#divLabels").append(lbl1);
        $("#divLabels").append(lbl2);   
        $("#divLabels").append(lbl3);   
        $("#divLabels").append(lbl4);
        $("#divLabels").append(lbl6);
        $("#divLabels").append(divError);
        $("#divError").append(lblError);
        
       
        $("#divInputs").append(inpt1);
        $("#divInputs").append(divSuggest1);
        $("#divInputs").append(inpt2);
        $("#divInputs").append(divSuggest2);
        $("#divInputs").append(inpt3);
        $("#divInputs").append(divSuggest3);
        $("#divInputs").append(inpt4);        
        $("#divInputs").append(inpt5);
        $("#divInputs").append(divSuggest4);
        $("#divInputs").append(btnSearch);
        $("#divInputs").append("<br />");
        $("#divInputs").append("<br />");
        $("#divInputs").append(btnClear);
        
        $("#btnClear").click(function () {ClearFields(); });
       
        
        $("#inpt1").val(city);
        $("#inpt2").val(borough);
        $("#inpt3").val(state);
        $("#inpt4").val(country);
        $("#inpt5").val(zip);
        
        $("#inpt1").keydown(function(){ LoadCat2();});
        $("#inpt1").keyup(function(){ AutoSuggestCity();ClearSuggest(this);});
        $("#inpt3").keyup(function(){ AutoSuggestState();ClearSuggest(this);});
        $("#inpt4").keyup(function(){ AutoSuggestCountry();ClearSuggest(this);});
        $("#inpt5").keyup(function(){ AutoSuggestZip();ClearSuggest(this);});
        
        $("#btnSearch").click(function () {SearchRequest(); });
        $("#centerDiv").click(function () {GetCount(); });
        $("#inpt1").focus(function () {GetCount(); });
        $("#inpt2").focus(function () {GetCount(); });
        $("#inpt3").focus(function () {GetCount(); });
        $("#inpt4").focus(function () {GetCount(); });
        $("#inpt5").focus(function () {GetCount(); });
        
         $("#inpt2").blur(function () { var checkCity = $("#inpt1").val(); if(checkCity == ""){alert("please be sure to select a city before choosing borough");$("#inpt1").focus();} });
    }//End of RefineSearch
    
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 
    
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     function GetCity(cityID,x){ 
        
         $.get("city_get.aspx", { cityID: cityID}, function(data) {					
					    
					     $('Table', data).each(function(data) { 					                       
                    
                            var city = $(this).find("cityName").text();   
                            
                               var lblCity = document.getElementById("lblCity" + x);
                                   lblCity.innerHTML = city + " - ";
                                   $("#lblCity" + x).css("font-size","12px");

                               
                        });//End Table
 
        });
 
 } //End of GetCity
 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
//  
//       function GetState(stateID){ 
//        
//         $.get("state_get.aspx", { stateID: stateID}, function(data) {					
//					    
//					     $('Table', data).each(function(data) { 					                       
//                    
//                            var state = $(this).find("stateName").text();                            
//                             
//                               
//                               alert(state);
//                                
//                               
//                               
//                        });
// 
//        });
// 
// } //End of GetState
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//    function GetCountry(countryID){               
// 
// 
//        var txtCountry = document.getElementById("txtCountry");
//        
//         $.get("country_get.aspx", { countryID: countryID}, function(data) {					
//					    
//					     $('Table', data).each(function(data) { 
//					                      
//                            
//                            var country = $(this).find("countryName").text(); 
//                               
//                               alert(country);                              
//                               
//                        });
//                        
//           });

//	
//	}	

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    function GetCount(){    
    
         var city = $("#inpt1").val();
         var borough = $("#inpt2").val();
         var state = $("#inpt3").val();
         var country = $("#inpt4").val();
         var zipCode = $("#inpt5").val();
                        
                    
                     $.get("category_count2.aspx", { city:city, borough: borough, state:state, country:country, zipCode:zipCode}, function(data) {                            
							
                            		    
                            $('Table', data).each(function(data) { 
                                            
                                            var catID = $(this).find("catID").text();
                                            var record_Count = $(this).find("Record_Count").text();                                           
                                            
                                            
                                            if(document.getElementById("lblCount" + catID)){
                                            
                                            $("#lblCount" + catID).html("("+ record_Count + ")");
                                               
                                                }
                                            
                                            
                                           
                                });//End Table
                                
                                
				        }); //End of Get 

    
    }//End of GetCount
    
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    function GetMarket(){
    
            var marketCity = inpt1.val()
            var marketState = inpt3.val()
            var marketCountry = inpt4.val();
            
            
            $.get("market_count.aspx", { marketCity:marketCity,marketState:marketState,marketCountry:marketCountry}, function(data) {                            
							
                            		    
                            $('Table', data).each(function(data) {                                             
                                           
                                            var market_count = $(this).find("Record_Count").text();                                           
                                            
                                            
                                            if(document.getElementById("lblCount20" )){
                                            
                                                $("#lblCount20").html("("+ market_count + ")");
                                            
                                                marketAds = market_count;
                                               
                                                }
                                            
                                            
                                           
                                });//End Table
                                
                                
				        }); //End of Get 
            
    
    
    }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     function LoadCat2(){
     

        var category_count = 0;
        var checkChk =$("#chkSelectAll").attr("checked");
        
       $("#divResults").empty();           
         
           var divSelectAll = document.createElement('div');
               divSelectAll.setAttribute("id","divSelectAll");
               
           var lblSelectAll = document.createElement('label');
               lblSelectAll.setAttribute("id","lblSelectAll");
               lblSelectAll.setAttribute("class", "lblSelectAll");
               
           var chkSelectAll = document.createElement('input');
               chkSelectAll.setAttribute("type","checkbox");
               chkSelectAll.setAttribute("id","chkSelectAll");
               chkSelectAll.setAttribute("class", "chkSelectAll");
               chkSelectAll.setAttribute("checked", "checked");
               chkSelectAll.onclick = function() { SelectAll(); }
               
               if(checkChk == true){
                    chkSelectAll.setAttribute("checked", "checked");
               }


           var spcr2 = document.createElement('label');
               spcr2.innerHTML = "&nbsp;";
               
               lblSelectAll.innerHTML = "<i><u>Select All Categories</u></i>";
                                                      
                                                     
               $("#divResults").append(divSelectAll);
               divSelectAll.appendChild(chkSelectAll); 
               divSelectAll.appendChild(spcr2); 
               divSelectAll.appendChild(lblSelectAll); 
            
         $.get("category_get.aspx", { }, function(data) {	
    					    
					        var lblCount = document.createElement('label');
                                lblCount.setAttribute("id","lblCount");
                                lblCount.style.visibility = 'hidden';
    					    
					         $('Table', data).each(function(data) {                    
                        
                                
                                var cat = $(this).find("catName").text(); 
                                var active = $(this).find("catActive").text();
                                var priority = $(this).find("catPriority").text();                          
                                var id = $(this).find("catID").text();
                                
                                if(active=="true"){   
                                        category_count = category_count + 1;
                                                                            
                                   var resultDiv = document.createElement('div');
                                       resultDiv.setAttribute("id","div" + id);
                                       resultDiv.style.width = "270px";
                                       resultDiv.style.height = "25px";   
                                       
                                   var catCount = document.createElement('label');
                                       catCount.setAttribute("id","lblCount" + id);
                                       catCount.setAttribute("class", "resultSet");
                                       
                                   var result = document.createElement('label');
                                       result.setAttribute("id","lblResult" + category_count);
                                       result.setAttribute("class", "resultSet");
                                       
                                   var chk = document.createElement('input');
                                       chk.setAttribute("type","checkbox");
                                       chk.setAttribute("id","chk" + category_count);
                                       chk.setAttribute("class", "resultSet");
                                       chk.setAttribute("checked", "checked");
                                       
                                       
                                       if(checkChk == true){
                                       chk.setAttribute("checked", "checked");
                                       }
                                       
                                       lblCount.innerHTML = category_count;
                                       catCount.innerHTML = "(0)";
                                       result.innerHTML = cat;  
                                       
                                       
                                       resultDiv.appendChild(chk);
                                       resultDiv.appendChild(result);
                                       resultDiv.appendChild(catCount);
                                       resultDiv.appendChild(lblCount);
                                       
                                       $("#divResults").append(resultDiv);
                                       
                                       if(id==20){GetMarket();}
                                       
                                       
                                }//End If
                                
                            });//End Each


        });//End Get

}// End LoadCat2
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    function SelectAll(){

    var tempCheck = $("#chkSelectAll").attr('checked');
    
    var category_count = $("#lblCount").html();
    
    if(tempCheck == true){
    
        for(c=1;c<=category_count;c++){
            $("#chk" + c).attr("checked",true);
        }
    }else{
        for(c=1;c<=category_count;c++){
            $("#chk" + c).attr("checked",false);
        }
    
    }

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    function AutoSuggestCity() { 
                
         if(document.getElementById("divContainer1")) {
                var divContainer1 = document.getElementById("divContainer1");
                divContainer1.parentNode.removeChild(divContainer1);
            }
        
        
        var divSuggest1 = document.getElementById("divSuggest1");
            divSuggest1.style.visibility = 'visible';
        var container1 = document.createElement("div");
            container1.setAttribute("id","divContainer1");
            divSuggest1.appendChild(container1);
            
			var city = $("#inpt1").val();
					
						    
       $.get("city_suggest.aspx", { city: city}, function(data) {

												    
                    $('Table', data).each(function(data) { 
                    
                            var city = $(this).find("cityName").text();
                            var state = $(this).find("stateName").text();
                            var country = $(this).find("countryName").text();                              
                            var aCity = document.createElement("div");
                                aCity.setAttribute("class","autoCity");
                                aCity.innerHTML = city + ", " + state + " - " + country;   
                                aCity.onclick = function() { GetSubstring(this, city, state); LoadCat2();GetCount();document.getElementById("divSuggest1").style.visibility = 'hidden';$("#inpt2").removeAttr("disabled");};
                                aCity.onmouseover = function() { document.body.style.cursor = 'pointer'; }; 
                                aCity.onmouseout = function() { document.body.style.cursor = 'default'; };                         
                                container1.appendChild(aCity);  
                                
                                                            
                               
                        });
                     
				}); //End of Get 
    
    } //End of autoSuggestCity

     
    

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

     function autocomplete( textBoxId, containerDivId ) {
            var ac = this;
            this.textbox     = document.getElementById(textBoxId);
            this.div         = document.getElementById(containerDivId);
            this.list        = this.div.getElementsByTagName('div');
            this.pointer     = null;

            this.textbox.onkeydown = function( e ) {
                e = e || window.event;
                
                switch( e.keyCode ) {
                    case 38: //up
                        ac.selectDiv(-1);
                        break;
                    case 40: //down
                        ac.selectDiv(1);
                        break;
                    case 13: //down
                        alert(e.keyCode);
                        break;
                }
            }

            this.selectDiv = function( inc ) {
                if( this.pointer !== null && this.pointer+inc >= 0 && this.pointer+inc < this.list.length ) {
                    this.list[this.pointer].className = '';
                    this.pointer += inc;
                    this.list[this.pointer].className = 'active2';
//                    this.textbox.value = this.list[this.pointer].innerHTML;
                }
                if( this.pointer === null ) {
                    this.pointer = 0;
                    this.list[this.pointer].className = 'active2';
//                    this.textbox.value = this.list[this.pointer].innerHTML;
                }
            }
        } 

new autocomplete( 'inpt1', 'divContainer1' );
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    function GetSubstring(that, city, state){      
    
    var sub1 = that.innerHTML.substring(0,city.length);
    var sub2 = that.innerHTML.substring(city.length + 2,city.length + 2 + state.length);   
    var countryStart = (city.length + state.length + 5);    
    var sub3 = that.innerHTML.substring(countryStart);   
    $("#inpt1").val(sub1);
    $("#inpt3").val(sub2);
    $("#inpt4").val(sub3);
    
        
    }//End of GetSubstring 
    
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    function AutoSuggestBorough() {     
        
                
         if(document.getElementById("divContainer2")) {
                var divContainer2 = document.getElementById("divContainer2");
                divContainer2.parentNode.removeChild(divContainer2);
            }
                
       var divSuggest2 = document.getElementById("divSuggest2");
            divSuggest2.style.visibility = 'visible';
        var container2 = document.createElement("div");
            container2.setAttribute("id","divContainer2");
        
            
            divSuggest2.appendChild(container2);
            
			var borough = $("#inpt2").val();
			var city = $("#inpt1").val();
			var state = $("#inpt3").val();
			var country = $("#inpt4").val();
		
						    
       $.get("borough_suggest.aspx", { borough: borough, city:city, state:state, country:country}, function(data) {

												    
                    $('Table', data).each(function(data) {                    
                    
                            var borough = $(this).find("boroughName").text();                            
                            var aBorough = document.createElement("div");
                                aBorough.setAttribute("class","autoState");
                                aBorough.innerHTML = borough;   
                                aBorough.onclick = function() { $("#inpt2").val(this.innerHTML);LoadCat2();GetCount();document.getElementById("divSuggest2").style.visibility = 'hidden'; };
                                aBorough.onmouseover = function() { document.body.style.cursor = 'pointer'; }; 
                                aBorough.onmouseout = function() { document.body.style.cursor = 'default'; };                         
                                container2.appendChild(aBorough);                               
                               
                        });

				}); //End of Get 
				
    
    } //End of autoSuggestBorough

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    function AutoSuggestZip() {  
        
         if(document.getElementById("divContainer4")) {
                var divContainer4 = document.getElementById("divContainer4");
                divContainer4.parentNode.removeChild(divContainer4);
            }
        
        
        var divSuggest4 = document.getElementById("divSuggest4");
            divSuggest4.style.visibility = 'visible';
        var container4 = document.createElement("div");
            container4.setAttribute("id","divContainer4");        
            
            divSuggest4.appendChild(container4);
            
			var zipCode = $("#inpt5").val();
		
						    
       $.get("zip_suggest.aspx", { zipCode: zipCode}, function(data) {

												    
                    $('Table', data).each(function(data) {                    
                    
                            var zipCode = $(this).find("zipCode").text();                            
                            var aZip = document.createElement("div");
                                aZip.setAttribute("class","autoCountry");
                                aZip.innerHTML = zipCode;   
                                aZip.onclick = function() { $("#inpt5").val(this.innerHTML); LoadCat2();GetCount();document.getElementById("divSuggest4").style.visibility = 'hidden'; };
                                aZip.onmouseover = function() { document.body.style.cursor = 'pointer'; }; 
                                aZip.onmouseout = function() { document.body.style.cursor = 'default'; };                         
                                container4.appendChild(aZip);                               
                               
                        });
                    
                     
			}); //End of Get 
				
				
    
    } //End of AutoSuggestCountry

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    function SetAdImages(city,state,country){
    
        //cityAds is the Array //$("#divC").append("<a href='http://www.google.com' target='_blank' class='adLink' ><img src='images2/h_ad_1_1.jpg' border=0 /></a>");                            

    
        $.get("get_ads.aspx", { city:city, state:state, country:country}, function(data) {                      
                    
					
					var a = 0;							    
                    $('Table', data).each(function(data) {                    
                    
                    
                            var tempAdImage = $(this).find("adImage").text();                            
                            var tempAdLink = $(this).find("adWebsite").text();
                            var tempAdSpace = $(this).find("adSpace").text();
                            
                            
                                if(tempAdSpace == 1){
                                    $("#divC").empty();
                                }else if(tempAdSpace == 2){
                                    $("#divE").empty();
                                }
                                else if(tempAdSpace == 3){
                                    $("#divG").empty();
                                }
                                else if(tempAdSpace == 4){
                                    $("#divI").empty();
                                }
                                else if(tempAdSpace == 5){
                                    $("#sideAds").empty();
                                }
                                
                                                      
                            
                            var anAdvert = new Advertisement(); 
                                anAdvert.setImageName(tempAdImage);
                                anAdvert.setImageLink(tempAdLink);
                                anAdvert.setAdSpace(tempAdSpace);
                                                                
                                cityAds[a] = anAdvert;
                                a=a+1; 
                               
                        });//End Table

               if(cityAds.length > 0){  
                            
                                for(i=0;i<cityAds.length;i++){ 
                                
                                     var anImage = new Advertisement();
                                         anImage = cityAds[i];
                                        
                                     var tempImgName = anImage.getImageName();
                                     var tempImgLink = anImage.getImageLink();
                                     var tempImgSpace = anImage.getAdSpace();
                                     
                                     
                                            if(tempImgSpace == 1){
                                                                                            
                                                $("#divC").append("<a href='http://" + tempImgLink + "' target='_blank' class='adLink' ><img src='uploads/" + tempImgName + "' border=0 width='234' height='60' /></a>");    
                                                $("#divC").cycle({
		                                                            fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		                                                            random:1
	                                                            }); 
	                                                            
                                            }else if(tempImgSpace == 2){
                                            
                                                $("#divE").append("<a href='http://" + tempImgLink + "' target='_blank' class='adLink' ><img src='uploads/" + tempImgName + "' border=0 width='234' height='60' /></a>");
                                                 $("#divE").cycle({
		                                                            fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		                                                            random:1
	                                                            });  
	                                                
                                            }else if(tempImgSpace == 3){
                                            
                                                $("#divG").append("<a href='http://" + tempImgLink + "' target='_blank' class='adLink' ><img src='uploads/" + tempImgName + "' border=0 width='234' height='60' /></a>");
                                                $("#divG").cycle({
                                                                    fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
                                                                    random:1
                                                                });  
                                                
                                            }else if(tempImgSpace == 4){
                                            
                                                $("#divI").append("<a href='http://" + tempImgLink + "' target='_blank' class='adLink' ><img src='uploads/" + tempImgName + "' border=0 width='198' height='60' /></a>");                                            
                                                 $("#divI").cycle({
	                                                                    fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	                                                                    random:1
                                                                    });
                                            
                                            }else if(tempImgSpace == 5){
                                            
                                                $("#sideAds").append("<a href='http://" + tempImgLink + "' target='_blank' class='adLink' ><img src='uploads/" + tempImgName + "' border=0 width='125' height='600' /></a>");
                                                $("#sideAds").cycle({
	                                                                    fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	                                                                    random:1
                                                                    });   
                                            }                                                                                                                             
                                
                                
                                }//End For (i=0;i<=cityAds.length;i++)
                            
                
                
                }//End if(cityAds.length > 0)

			}); //End of Get 
				
				
    
    
   }// End of SetAdImages
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    function ClearFields(){
        
            $("#inpt1").val(" ");
            $("#inpt2").val(" ");
            $("#inpt3").val(" ");
            $("#inpt4").val(" ");
            $("#inpt5").val(" ");
        }

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     function ClearSuggest(that){
               
    
            if(that.value==""){
            
            document.getElementById("divSuggest1").style.visibility = 'hidden';
            document.getElementById("divSuggest2").style.visibility = 'hidden';
            document.getElementById("divSuggest3").style.visibility = 'hidden';
            document.getElementById("divSuggest4").style.visibility = 'hidden';
            
            
            
            }
    
    }        
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
   
   
    
});//End of Document Ready


//    $.ajax({
//                  url: "get_ads.aspx",
//                  data:{city:city, state:state, country:country},
//                  async: false,
//                  success: function(data){ 
//                  
//                              var a = 0;
                              
//                              $('Table', data).each(function(data) {                    
//                    
//                    
//                                    var tempAdImage = $(this).find("adImage").text();                            
//                                    var tempAdLink = $(this).find("adWebsite").text();
//                                    var tempAdSpace = $(this).find("adSpace").text();
//                                    
//                                        if(tempAdSpace == 1){
//                                            $("#divC").empty();
//                                        }else if(tempAdSpace == 2){
//                                            $("#divE").empty();
//                                        }
//                                        else if(tempAdSpace == 3){
//                                            $("#divG").empty();
//                                        }
//                                        else if(tempAdSpace == 4){
//                                            $("#divI").empty();
//                                        }
//                                        else if(tempAdSpace == 5){
//                                            $("#sideAds").empty();
//                                        }
//                                        
//                                    var tempAdAdPlace = $(this).find("adPlace").text();                          
//                                    
//                                    var anAdvert = new Advertisement(); 
//                                        anAdvert.setImageName(tempAdImage);
//                                        anAdvert.setImageLink(tempAdLink);
//                                        anAdvert.setAdSpace(tempAdSpace);
//                                        anAdvert.setAdPlace(tempAdAd);                                
//                                        cityAds[a] = anAdvert;
//                                        a=a+1; 
//                               
//                        });//End Table
                                         
//                                       }//End succes:function(data)

//                 });//End of AJAX call
