$().ready(function() {

	$("#slider").easySlider({
		prevText: 'Previous',
		nextText: 'Next',
        continuous: true, 
        auto: true, 
        pause: 8000,

	});

    
    $('#bulk_county').val('Add (1) county per line');
    $('#bulk_county').focus(function() {
      $(this).val('');
    });
    
    $('#search').focus(function() {
      $(this).val('');
    });
    
    $('#keywords').focus(function() {
      $(this).val('');
    });
    
	$.ajaxSetup ({  
		cache: false  
	});
    
    $("#cmstable tr").hover(
       function()
       {
        $(this).addClass("highlight");
       },
       function()
       {
        $(this).removeClass("highlight");
       }
    )

	$("#cmstable tr").click(function() {
		window.location=$(this).find("a").attr("href");return false;
	});
    
    // Forms  ----------------------------------
	$("#country_id").change(function(){
       
        var id = $(this).val();			  
		var loadUrl = '/ajax/formCounties/' + id;
		var ajaxDiv = '#result_county_id';
        
		$.get(
			loadUrl,
			{language: "php", version: 5},
			function(responseText){
				$(ajaxDiv).html(responseText);
			},
			"html"
		);
        
        $("#county_id")[0].selectedIndex = 0;

	});
    
    // Used only for job listings
	$("#county_id").change(function(){
       
        var id = $(this).val();			  
		var loadUrl = '/ajax/formTowns/' + id;
		var ajaxDiv = '#result_town_id';
        
		$.get(
			loadUrl,
			{language: "php", version: 5},
			function(responseText){
				$(ajaxDiv).html(responseText);
			},
			"html"
		);
        
        $("#town_id")[0].selectedIndex = 0;

	});
    
    // Forms  ----------------------------------
	$("#search_county_id").change(function(){
       
        var id = $(this).val();			  
		var loadUrl = '/ajax/formSearchTowns/' + id;
		var ajaxDiv = '#result_town_id';
        
		$.get(
			loadUrl,
			{language: "php", version: 5},
			function(responseText){
				$(ajaxDiv).html(responseText);
			},
			"html"
		);
        
        $("#county_id")[0].selectedIndex = 0;

	});

    
});

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

