// install overlay for external pages 
$(function() {		
	// if function argument is given to overlay it is assumed onBeforeLoad event listener
	$("a.overlayTrigger").overlay(function() {
		// grab wrapper element inside content
		var wrap = this.getContent().find("div.wrap");
		// load only for the first time it is opened
		//if (wrap.is(":empty")) {		//condition removed so multiple triggers work.	
			wrap.load(this.getTrigger().attr("href"));	
		//}		
		// if the trigger class includes "noscroll" it will disable scrolling in the overlay to prevent the scrollbar when not needed.			
		var obj= document.getElementById('wrap');
		if (this.getTrigger().attr("class").search("noscroll")!=-1) { obj.style.overflow = "visible"; }	
		else { obj.style.overflow = "auto"; }
	});			
});


function checkLoginFields() {
	if (document.loginForm.username.value != "") document.loginForm.username.style.background = "#fff";
	if (document.loginForm.password.value != "") document.loginForm.password.style.background = "#fff";
}

function toggleLoginFields(obj,action) {
	if (action == "clicked") obj.style.background = "#fff";
	if (action == "unclicked" && obj.value=="") {
		if (obj.name == "username") obj.style.background = "url(images/login_bg_username.gif) top left no-repeat";
		if (obj.name == "password") obj.style.background = "url(images/login_bg_password.gif) top left no-repeat";
	}
}

function toggleSearchFields(obj,action) {
	var keywordText = "Keywords (e.g. Engineer, Manager)";
	var locationText = "Location (e.g. zip, city, state)";
	if (action == "clicked") {
		if (obj.name == "keywords" && obj.value == keywordText) obj.value = "";
		if (obj.name == "location" && obj.value == locationText) obj.value = "";
		obj.className = "textfieldOn";
	}
	if (action == "unclicked" && obj.value=="") {
		if (obj.name == "keywords") obj.value = keywordText;
		if (obj.name == "location") obj.value = locationText;
		obj.className = "textfield";
	}
}

window.onload=checkLoginFields;


