jQuery(
	function ($) 
	{
		new fhn.load();
	}
);

var fhn =
{
	vars:
	{

	}, // vars

	load: function ()
	{
		if($('ul.news-tabs').length > 0){
			$('ul.news-tabs li a').live('click', function(){
				
				//deselect all tabs ready to select one
				$(this).parent().parent().children("li").removeClass("selected");
				$(this).parent().addClass("selected");
				var selectedTab = $(this).attr("class");
				
				if(!$("ol."+selectedTab).is(":visible") ){
					$("ol."+selectedTab).parent().children("ol:visible").fadeOut('fast', function() {
					        // Animation complete
							$("ol."+selectedTab).fadeIn('fast', function() {
							       
							});
					});
				}
				return false;
			});
		}
		
		if($('ul.fhn-assets').length > 0){
			$('ul.fhn-assets li a').live('click', function(){
				
				//deselect all tabs ready to select one
				$(this).parent().parent().children("li").removeClass("selected");
				$(this).parent().addClass("selected");
				
				var selectedTab = $(this).attr("class");
				if($(this).hasClass("wide")){ //fix as there is an extra class in there to make the tab wider take out then put back in
					$(this).removeClass("wide");
					selectedTab = $(this).attr("class");
					$(this).addClass("wide");
				}
					
				
				
				if(!$("div.tab."+selectedTab).is(":visible") ){
					$("div.tab."+selectedTab).parent().children("div.tab:visible").fadeOut('fast', function() {
					        // Animation complete
							$("div.tab."+selectedTab).fadeIn('fast', function() {
							       
							});
					});
				}
				return false;
			});
		}
		if($('#slider1').length > 0){
		  $('#slider1').bxSlider({
		    auto: true,
		    pager: true,
			speed:1000,
			pause:8000
		  });
		}
		if($('#slider2').length > 0){
			$('#slider2').bxSlider({
		      pager: true,
		      buildPager: function(slideIndex){
		        return thumbs[slideIndex];
		        
		      }
		    });
		}
		if($("#subForm").length > 0){
		
			$("#subForm").validate({
					errorLabelContainer: "#errors",
				   	wrapper: "li",
			        invalidHandler: function(e, validator) {
			            var errors = validator.numberOfInvalids();
			
			            if (errors) {
			                //$("div.error span").html(message);
			                $("div.validation").show();
			            } else {
			                $("div.validation").hide();
			            }
			        },
			        onkeyup: false
			        //submitHandler: function() {
			           // $("div.validation").hide();
			            //alert("submit! use link below to go to the other step");
			        //},
			        //debug:false
					
			    });
			
		
		}
		if($('div.article div.answer a.close').length > 0){
			$('div.article div.answer a.close').live('click', function(){
				//we are closing
				if($(this).parent().hasClass("open")){
					$(this).parent().removeClass("open");
					$(this).parent().parent().children('a').show();
				}
				
				return false;
			});
			$('div.article a.readmore').live('click', function(){
				//we are opening
				$(this).parent().children('div.answer').addClass("open");
				//$('div.article div.answer').addClass("open");
				$(this).hide();
			
				
				return false;
			});
		}
		//news menu move to correct place
		if($('div.mod_newsmenu').length > 0){
			  $('div.mod_newsmenu ul.level_1').appendTo("div.left-column div.mod_navigation ul.level_1 li.selected");
		}
	} // Load
}
