$(document).ready(function(){
/* Quicklinks button */
quicklinkgo();

 
// If Javascript is enabled, this function will apply styles to User Tool bar
if ($.browser.msie && $.browser.version == 6) { 
	// no need to animate the User Toolbar, so proceed for all other browsers ...
}
else {
	$(".user_toolbar_wrapper_noscript").removeClass().addClass("user_toolbar_wrapper");
	$(".user_toolbar_noscript").removeClass().addClass("user_toolbar");
	$("body").css({
		paddingTop: "3em"
	
	});
	$("#access_bar_wrapper").css({
		top: "0"
	});
	$("#banner").css({
		paddingTop: "0"
	});
	$("#banner_content").css({
		paddingTop: "1em"
	});
	
	// User Toolbar
	
	$(".user_toolbar a").animate({ 
				marginRight: "-120px"
	  		}, {queue:false, duration:600, easing: 'easeOutElastic'});
	
	$(".user_toolbar a").hover(
		function(){
	 		$(".user_toolbar").stop().animate({ 
				marginRight: "0"
	  		}, 100 );      		
		},
		function(){
	 		$(".user_toolbar").stop().animate({ 
				marginRight: "-120px"
	  		}, {queue:false, duration:600, easing: 'easeOutElastic'})
	});
};

// News Items
$(".news_item").each(function(){
	$(this).hover(
		function(){
     		$(this).animate({ 
				backgroundColor: "#ebfaff" 
			}, "fast" );      		
		},
		function(){
     		$(this).animate({ 
				backgroundColor: "#fff"
      		}, "fast" )
	});	
 
});	


// Expand only the active menu, which is determined by the class name
$("ul.menu > li > a[class=expanded] ").find("+ ul").slideToggle("medium");

// Toggle the selected menu's class and expand or collapse the menu
$("ul.menu > li > a.expanded").click(function() {
	$(this).toggleClass("expanded").toggleClass("collapsed").find("+ ul").slideToggle("medium");
	return false;
});

// Navigation Tabs
$("#navbar .tab").each(function(){
	if ( $(this).hasClass("current") ) 	
	$(this).hover(
		function(){
     		$(this).stop().animate({ 
     			height: "60px" ,
     			lineHeight:  "60px"
      		}, 100 );      		
		},
		function(){
     		$(this).stop().animate({ 
        		height: "60px" ,
     			lineHeight:  "60px"
      		}, {queue:false, duration:600, easing: 'easeOutElastic'})
	});	

	else 	
	$(this).hover(
		function(){
     		$(this).stop().animate({ 
     			height: "60px" ,
     			lineHeight:  "60px"
      		}, 100 );      		
		},
		function(){
     		$(this).stop().animate({ 
        		height: "40px" ,
     			lineHeight:  "40px"
      		}, {queue:false, duration:600, easing: 'easeOutElastic'});
	});		 
});	
		 	
	//Accordian Menu
	$('h3.accordian_header').next('div').hide();


	$('h3.accordian_header').click(function() {
		var $nextDiv = $(this).next('div.accordian_container');
		var $visibleSiblings = $nextDiv.siblings('div.accordian_container:visible');
		
		if ($visibleSiblings.length ) {
			$visibleSiblings.slideUp('fast', function() {
				$nextDiv.slideToggle('fast');
			});
		} else {
	       $nextDiv.slideToggle('fast');
		}
	});
	
});	

/* End Jquery Functions, start custim JS functions */


function quicklinkgo(){
	var btn = document.getElementById('quicklinks_go');
	if(!btn)
		return false;
	btn.style.display='none';//hide the button

	btn = document.getElementById('quicklinks_select');
	if(btn)btn.onchange=function(){this.parentNode.submit();}
}

function cleanOnFocus(field,defaultText){
	try{
		if(!field.tagName == "INPUT" || !field.type=="text" || !field.value)
			return false;
		if(field.value == defaultText)
			field.value='';
	}catch(e){
		return false;
	}
}

function resetOnLostFocus(field,defaultText){
	try{
		if(!field.tagName == "INPUT" || !field.type=="text")
			return false;
		if(!field.value)
			field.value=defaultText;
	}catch(e){
		return false;
	}
}
