var formfocus;
$(document).ready(function(){
/////////////////////////////////////////////////////////////
// <button> events
/////////////////////////////////////////////////////////////
	$(".allowHover").mouseover(function(){
		$(this).addClass("hover");
	}).mouseout(function(){
		$(this).removeClass("hover");
		$(this).removeClass("click");
	}).mousedown(function(){
		$(this).addClass("click");
	}).mouseup(function(){
		$(this).removeClass("click");
	});

/////////////////////////////////////////////////////////////
// <input class="formfocus" - replace value on focus / blur
/////////////////////////////////////////////////////////////
	$(".formfocus").each(function(){
		if($(this).attr("value") != ""){
			formfocus = $(this).attr("id");
			if(formfocus == "formusername"){
				$(this).attr("id", "formusernameOFF");
			}
			if(formfocus == "formpassword"){
				$(this).attr("id", "formpasswordOFF");
			}	
		}
	});
		
	$(".formfocus").focus(function(){
		formfocus = $(this).attr("id");
		if(formfocus == "formusername"){
			$(this).attr("id", "formusernameOFF");
		}
		if(formfocus == "formpassword"){
			$(this).attr("id", "formpasswordOFF");
		}
	}).blur(function(){

		if($(this).attr("value") == ""){

			if(formfocus.indexOf("formusername") > -1){
				$(this).attr("id", "formusername");
			} else if(formfocus.indexOf("formpassword") > -1) {
				$(this).attr("id", "formpassword");
			}
		}
	});	
/////////////////////////////////////////////////////////////
// search toggle functions
/////////////////////////////////////////////////////////////
	$("#searchtoggle").click(function(){
		$("#searchoptions").toggle();
	});

/////////////////////////////////////////////////////////////
// Ajax News ticker
/////////////////////////////////////////////////////////////
	$("#tickerscroll").initTicker(true)
	
/////////////////////////////////////////////////////////////
// Refresh Page
/////////////////////////////////////////////////////////////
	$("#refresh").click(function(){
		window.location.reload(); 
	}).mouseover(function(){
		$(this).addClass("over");
	}).mouseout(function(){
		$(this).removeClass("over");
	});
});
