//--------------------------------------------------------------------
// global variables
//--------------------------------------------------------------------

var topSearchText

//--------------------------------------------------------------------
// fires when the DOM is ready
//--------------------------------------------------------------------

$(document).ready(function(){
	navHover();
	//topSearch();
	//extWindows()
});

//--------------------------------------------------------------------
// useful functions
//--------------------------------------------------------------------

// navHover() makes fancy mousovers on left navigation and newslisting on startpage
function navHover() {
	$(".nav").css("height",$(".nav").parent().height())
	$(".indexNews, .nav").children("ul").children("li").mouseover(function(){
		$(this).addClass("paHover");
	});
	$(".indexNews ,.nav").children("ul").children("li").mouseout(function(){
		$(this).removeClass("paHover");
	});
}

// topSearch() takes the label and puts it into the searchfield and hides it on focus
function topSearch(){
	$(".topSearch").css("display","none");
	topSearchText = $(".topSearch label").text();
	$(".topSearch :text").val(topSearchText);
	$(".topSearch label").hide();
	$(".topSearch :text").focus(function(){
		if($(this).val() == topSearchText){
			$(this).val("");
		}
	});
	$(".topSearch :text").blur(function(){
		if($(this).val() == ""){
			$(this).val(topSearchText);
		}
	});
	
	$(".topSearch").css("display","block");
}

// extWindows() makes links open in a different window. use rel="external" instead of target="_blank" and rel="popup" or rel="popup|[width]|[height]" for popups
function extWindows(){
	$("a[rel=external]").attr("target","_blank");
	$("a[rel^=popup]").click(function(){
		theHref = $(this).attr("href");
		$(this).attr("href","javascript:void(0)");
		var popupWidth, popupHeight
		var relSplit = $(this).attr("rel").split("|");
		if(relSplit[1]){
			popupWidth = relSplit[1];
			popupHeight = relSplit[2];
		} else {
			popupWidth = 435;
			popupHeight = 350;
		}
		popMeUp(theHref,popupWidth,popupHeight)
	});
	
}
function popMeUp(strURL, strWidth, strHeight) {
    theWin = window.open(strURL, "popupWin", "scrollbars,resizable,height=" + strHeight + ",width=" + strWidth);
    theWin.focus();
}
