var friendWindow, pfWindow, applyWindow, helpWindow, cvvWndow

function openFriendWindow (loggedIn) {
	myWidth = 500
	myHeight = loggedIn ? 410 : 510
	myTop = screen.height / 2 - myHeight / 2
	myLeft = screen.width / 2 - myWidth / 2
	friendWindow = window.open("", "friendWindow", "top=" + myTop + ",left=" + myLeft + ",height=" + myHeight + ",width=" + myWidth + "," +
		"location=no,resizable=no,titlebar=no,menubar=no,scrollbars=no,toolbar=no")
	friendWindow.focus()
}

function openPfWindow () {
	myWidth = 900
	myHeight = 600
	myTop = screen.height / 2 - myHeight / 2
	myLeft = screen.width / 2 - myWidth / 2
	pfWindow = window.open("", "pfWindow", "top=" + myTop + ",left=" + myLeft + ",height=" + myHeight + ",width=" + myWidth + "," +
		"location=no,resizable=yes,titlebar=no,menubar=no,scrollbars=yes,toolbar=no")
	pfWindow.focus()
}

function openApplyWindow () {
	myWidth = 750
	myHeight = 680
	//availableHeight = window.innerHeight ? window.innerHeight: document.documentElement.clientHeight
	//availableWidth = window.innerWidth ? window.innerWidth: document.documentElement.clientWidth
	myTop = screen.height / 2 - myHeight / 2
	myLeft = screen.width / 2 - myWidth / 2
	applyWindow = window.open("", "applyWindow", "top=" + myTop + ",left=" + myLeft + ",height=" + myHeight + ",width=" + myWidth + "," +
		"location=no,resizable=yes,titlebar=no,menubar=no,scrollbars=yes,toolbar=no")
	applyWindow.focus()
}

function openHelpWindow () {
	myWidth = 800
	myHeight = 725
	myTop = screen.height / 2 - myHeight / 2
	myLeft = screen.width / 2 - myWidth / 2
	helpWindow = window.open("", "helpWindow", "top=" + myTop + ",left=" + myLeft + ",height=" + myHeight + ",width=" + myWidth + "," +
		"location=no,resizable=yes,titlebar=no,menubar=no,scrollbars=yes,toolbar=no")
	helpWindow.focus()
}

function openCvvWindow () {
	myWidth = 700
	myHeight = 400
	myTop = screen.height / 2 - myHeight / 2
	myLeft = screen.width / 2 - myWidth / 2
	cvvWindow = window.open("", "cvvWindow", "top=" + myTop + ",left=" + myLeft + ",height=" + myHeight + ",width=" + myWidth + "," +
		"location=no,resizable=no,titlebar=no,menubar=no,scrollbars=no,toolbar=no")
	cvvWindow.focus()
}

function trOver (myObject) {
	myObject.style.backgroundColor = "#96CAFA"
}
function trOut (myObject) {
	myObject.style.backgroundColor = "white"
}
function showJob (jobID) {
	document.getElementById("job_details_" + jobID).style.display = document.getElementById("job_details_" + jobID).style.display == "none" ? "" : "none"
}
function showJobSeeker (jobSeekerID) {
	document.getElementById("jobSeeker_details_" + jobSeekerID).style.display = document.getElementById("jobSeeker_details_" + jobSeekerID).style.display == "none" ? "" : "none"
}
function doResort (field) {
	document.getElementById("sortField").value = field
	document.getElementById("resortForm").submit()
}
var jobAddedList = ","
var jobSeekerAddedList = ","
function addJobToList (jobID) {
	var myRegExp = new RegExp("," + jobID + ",")
	if (myRegExp.test(jobAddedList))
		jobAddedList = jobAddedList.replace(myRegExp, ",")
	else
		jobAddedList += jobID + ","
}
function addJobSeekerToList (jobSeekerID) {
	var myRegExp = new RegExp("," + jobSeekerID + ",")
	if (myRegExp.test(jobSeekerAddedList))
		jobSeekerAddedList = jobSeekerAddedList.replace(myRegExp, ",")
	else
		jobSeekerAddedList += jobSeekerID + ","
}

function all_checkboxes (myParent, myBoolean) {
	var myElements = document.getElementById(myParent).getElementsByTagName("input")
	for (i = 0; i < myElements.length; i++)
		myElements[i].checked = myBoolean
}

function stateChanged () { 
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.responseText == "OK")
			alert("Your subscription request has been recorded.\n" +
				"For verification purposes an email has been sent to you.\n" +
				"After validating your request, by clicking on the link in that email, your subscription will be activated.")
		else if (xmlHttp.responseText == "DUP")
			alert("This email address is already subscribed to our latest jobs.")
		else
			alert("There was a problem.")
	}
}
function digestSignup (myField) {
	if (validate_email(myField)) {
		alert("Please enter a valid email address.")
		document.getElementById(myField).focus()
		return false
	}
	return true
}

function allJobsDisplay (displayParam) {
	myTDs = document.getElementById("resultsTable").getElementsByTagName("td")
	for (i = 0; i < myTDs.length; i++)
		if (myTDs[i].id.search(/job_details_/) != -1)
			myTDs[i].style.display = displayParam
}

var months = Array("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
