               $(document).ready(function() {
  $(".country-map").click(function(){
     var data= $(this).attr("title");
    $("#search_state").html('<option>Loading...</option>');
     $.ajax({
         type: "POST",
         data: "data="+$(this).attr("title") ,
         url: base_url+"main/get_group",
         success: function(msg){
                     if (msg != ''){
                         $("#search_state").html(msg);
                         //$("#result").html('');
                        
                         if($("#search_state").val() > 0)
                         {
                             $("#search_location").html('<option>Loading...</option>');
                             $.ajax({
                             type: "POST",
                             data: "data="+ $("#search_state").val() ,
                             url: base_url+"main/get_city",
                             success: function(msg){
                                        if (msg != '')
                                        {
                                                var resp = msg.split("|");
                                                $("#rc_logo").attr("src",resp[1]);
                                                $("#rc_tagline").html(resp[2]);
                                                $("#search_location").html(resp[0]);
                                                //$("#result").html('');
                                                $("#search-button").removeAttr('disabled');
                                                $("#search_state").removeAttr('disabled');
                                                $("#search_location").removeAttr('disabled');
                                        }
                                        else
                                        {
                                                $("#search_location").html('<option value="0">Rentals not Available</option>');
                                        }
                                }
                             });
                         }
                         else
                        {
                                $("#search_location").html('');
                        }
                       
                }
                else
                {
                         $("#search_state").html('<option value="0">Rentals not Available</option>');
                         $("#search_location").html('<option value="0">Rentals not Available</option>');
                }
        }
     });      
  });
  
  var flagselected = false;
  
  $('li.flags').each(function(index) {
        if(($(this).children('a').children('img').attr('class')) == "active-flag")
        {
        flagselected = true;
        //alert(index);   
        }
  });
  //alert(flagselected); 
  if(flagselected == false)
  {
      //alert($(".maps li:nth-child(1)").html());
      $(".maps li:nth-child(1)").children('a').children('img').attr('class',"active-flag");
      
  }
  
  $('.maphilighted').fadeIn('slow');
  $('.map').css('margin','auto');    
  $('.map').fadeIn('slow');  
        
if($("#keyword").val()!= defaultkeyword )
        {
                $("#keyword").css('color',"#1A2F47");
        }
        else
        {
                $("#keyword").css('color',"#B3B9BF");
        }
        $("#keyword").keydown(function(){
        if(($("#search_state").val() < 1) || ($("#search_location").val() < 1 ))
        {
                if(($("#search_state").val() < 1) && ($("#search_location").val() < 1 ))
                {
                        alert("Please pick a Country/State and City");
                        $("#keyword").val(defaultkeyword); 
                        $("#keyword").css('color',"#1A2F47");
                        $('#search_state').focus();
                }
                else if($("#search_location").val() < 1)
                { 
                        alert("Please pick a City"); 
                        $("#keyword").val(defaultkeyword); 
                        $("#keyword").css('color',"#1A2F47");
                        $('#search_location').focus();
                } 
        }
  });
   $("#keyword").click(function(){
      if($("#keyword").val()== defaultkeyword )
       {
             $("#keyword").css('color',"#1A2F47");
             $("#keyword").val('');  
       }
  });
   $("#keyword").blur(function(){
      if($("#keyword").val()=='')
       {
           $("#keyword").css('color',"#B3B9BF");
           $("#keyword").val(defaultkeyword); 
       }
  });
 
   $("#footer-marquee-container").html("<marquee behavior='scroll' direction='left' scroolamount='1' loop='INFINITE' SCROLLDELAY='80' onmouseover='this.stop()' onmouseout='this.start()'>"+$("#footer-marquee").html()+"</marquee>");
   $(".silo-city-marquee, .silo-main-marquee").html("<marquee behavior='scroll' direction='left' scroolamount='1' loop='INFINITE' SCROLLDELAY='80' onmouseover='this.stop()' onmouseout='this.start()'>"+$("#footer-marquee").html()+"</marquee>");      
   //$("<a href='http://livechat.boldchat.com/aid/579224233975495980/bc.chat?cwdid=3800590529348702460' onclick=window.open((window.pageViewer && pageViewer.link || function(link){return link;})(this.href + (this.href.indexOf('?')>=0 ? '&amp;' : '?') + 'url=' + escape(document.location.href)), 'Chat4375169711430905296', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480');return false;></a>").appendTo(".bold-chat-button");
}); 
