$(document).ready(function(){

	  $('select#country').change(function(){
		  document.getElementById("flashMap").changeCountry($(this).val());		  
	  });	
	  
	  
	  $('select#type').change(function(){	    	  
		  setSearchOption();		  
	  });	 
	  

	  $('.slTypeThumb').bt({
		  contentSelector: "$('#type-'+$(this).attr('id')).html()",
		  width:"350px",
		  fill:"rgb(255, 255, 199)",
		  shadow:true,
		  spikeGirth:25,
		  spikeLength:10

	  });	
	  
	  $('.vseTypeThumb').bt({
		  contentSelector: "$('#desc-'+$(this).attr('id')).html()",
		  width:"350px",
		  fill:"rgb(255, 255, 199)",
		  shadow:true,
		  spikeGirth:25,
		  spikeLength:10
		  
	  });	
	  
	  $('.vseTypeMiniThumb').bt({
		  contentSelector: "$('#desc-'+$(this).attr('id')).html()",
		  width:"350px",
		  fill:"rgb(255, 255, 199)",
		  shadow:true,
		  spikeGirth:25,
		  spikeLength:10
		  
	  });	

	  menu.init();
	  
	  $("#tabs").tabs();

	  
	  if( $('select#type').size() > 0 )
	    setSearchOption();
	  
	  if( $('.formErrors').size() > 0 )
		$('.formErrors').prependTo("#guideContentText");

	});
  
  
function setSearchOption()
{
	 if( $("select#type").val() == 'vse' ) {		  
		  $('#housing').attr('disabled',true).prev().addClass("disable"); 
		  $('#month').attr('disabled',true).prev().addClass("disable"); 
		  $('#age').attr('disabled',true).prev().addClass("disable"); 
		  $('#group').attr('disabled',true).prev().addClass("disable"); 
		  $('#cours').attr('disabled',true).prev().addClass("disable"); 
		  //$('#price').attr('disabled',true).prev().addClass("disable"); 
	 } else {
		  $('#housing').attr('disabled',false).prev().removeClass("disable");
		  $('#month').attr('disabled',false).prev().removeClass("disable"); 
		  $('#age').attr('disabled',false).prev().removeClass("disable"); 
		  $('#group').attr('disabled',false).prev().removeClass("disable"); 
		  $('#cours').attr('disabled',false).prev().removeClass("disable"); 
		  //$('#price').attr('disabled',false).prev().removeClass("disable");		 
	 }
}

var menu = {
	  init : function(){
		current = null;
	    menutimer= 0;
	    $(".subnavTrigger").mouseover(function(){   

	      menu.menutimer = window.clearTimeout(menu.menutimer);
	      if(current == null ) {
	        
	    	if(current!=null){
	        	current.find(".subnav").slideUp(200);
	        }
	        
	    	$(this).find(".subnav").slideDown(200);
	        $(this).find('.subMenuLink').addClass('hover');
	        $(this).parent('li').find('a').addClass('hover');
	        current = $(this);
	        
	      }
	    });
	    
	    $(".subnavTrigger").mouseout(function(){
	      menu.menutimer = window.setTimeout("menu.hide()",150);
	    }); 
	    
	  },
	  hide : function()
	  {		  
	    $("#navigation .subnav:visible").slideUp(200);
	    $(current).find('.subMenuLink').removeClass('hover');
	    $(current).parent('li').find('a').removeClass('hover');
	    current=null;	    
	  }
};
	

function debug(str) 
{
  alert(str);
}


function locationSelect(location) 
{
  $('#locationValue').val(location);
  $('#searchBoxForm').submit();
}
  

function locationUpdate(location) 
{
  $('#locationValue').val(location);
}
  
  function countrySelect(str)
  {
    if( $('#searchBoxForm') ) {      
        $('select#country').val(str);        
    }    
  }

