﻿function SaveSkills(hiddenfield, displayfield)
{
	var iLength = window.opener.document.frmSearch.elements[displayfield].length + 1;
	var sHiddenField = window.opener.document.frmSearch.elements[hiddenfield];
	var sDisplayField = window.opener.document.frmSearch.elements[displayfield];
	var sSkillsField = document.frmSkills.Skills;
		
	for (count=0; count < document.frmSkills.Skills.length; count++)
	{
		if (document.frmSkills.Skills.options[count].selected) {	
			sDisplayField.length = iLength;
			sDisplayField.options[iLength-1].text = sSkillsField.options[count].text;
			sDisplayField.options[iLength-1].value = sSkillsField.options[count].value;
			
			if (sHiddenField.value == '') {
				sHiddenField.value = sSkillsField.options[count].value;
			}
			else {
				sHiddenField.value = sHiddenField.value + ', ' + sSkillsField.options[count].value;
			}			
			iLength++;
		}
	}	
	window.opener.focus();
	window.close();
	iClickCtr=0;
}

function ClearSearchFields(skillsList) {

	var skillsArray;
	var i, j;
	var sCurType;
	var sCurElement;
	var iLength;
	
	skillsArray = skillsList.split(',');
	j = skillsArray.length;
	
	for (i=0; i<j; i++) 
	{
		sCurElement = skillsArray[i];
		sCurType = document.frmSearch.elements[sCurElement].type;
		if (sCurType == 'hidden') {
			document.frmSearch.elements[sCurElement].value = '';
		}
		if (sCurType.indexOf('select') >= 0) {
			for (count=0; count < document.frmSearch.elements[sCurElement].length; count++)
			{
				document.frmSearch.elements[sCurElement].options[count].text = '';
				document.frmSearch.elements[sCurElement].options[count].value = '';				
			}
			document.frmSearch.elements[sCurElement].length = 0;
		}
	}
}

function OpenWindow(h, w, URL, sWindowName) 
{

	if (CookiesDisabled()) 
	{
		alert('Advanced features of this site, such as logging in and saving searches,\nrequire that you enable cookies in your browser.  If you wish to use\nthose features, you must enable cookies before proceeding.');
		iClickCtr=0;
	}
	else
	{
		var sParameters = 'width=' + w + ',height=' + h;
		sParameters += ',resizable=0,status=0,menubar=0,toolbar=0,location=0,scrollbars=0';
		
		window.open (URL, sWindowName, sParameters);
		iClickCtr=0;
	}
}

function OpenCategoryWin(hiddenfield, displayfield) 
{
	var w = 300;
	var h = 300;
	var sWindowName = 'CatsWin';
	var URL = 'getcategories.asp?hiddenfield=' + hiddenfield + '&displayfield=' + displayfield;

	var sParameters = 'width=' + w + ',height=' + h;
	sParameters += ',resizable=1,status=0,menubar=0,toolbar=0,location=0,scrollbars=0';
	
	window.open (URL, sWindowName, sParameters);
	iClickCtr=0;
}

function OpenSaveSearchWin(sSearchtoSave) 
{
	var w = 300;
	var h = 440;
	var sWindowName = 'SaveSearchWin';
	//var URL = 'saveSearch.asp?hdnSearchString=' + escape(sSearchtoSave);
	var URL = 'saveSearch.asp?hdnSearchString=' + sSearchtoSave;


	var sParameters = 'width=' + w + ',height=' + h;
	sParameters += ',resizable=1,status=0,menubar=0,toolbar=0,location=0,scrollbars=0';
	
	window.open (URL, sWindowName, sParameters);
	iClickCtr=0;
}

function CookiesDisabled() {
	//are cookies off?  return true
	//note: this function returns true if cookies are OFF
	//and returns false if they are ON
	document.cookie = 'cookiesOn=True';
	var cookietext = document.cookie;
	if (cookietext.indexOf('cookiesOn=True') >= 0) {
		return false;
	}
	else {
		return true;
	}	
}

function CookieAlert() {
	//if cookies are disabled, let them know things won't work
	if (CookiesDisabled()) {
		alert('Advanced features of this site, such as logging in and saving searches,\nrequire that you enable cookies in your browser.  If you wish to use\nthose features, you must enable cookies before proceeding.');
	}
}

function CookieRedirect() {
	//if cookies are disabled, let them know things won't work
	if (CookiesDisabled()) {
		CookieAlert();
		return false;
		//window.location = 'cookieerror.htm';
	}
}

function RunSavedSearch(sSavedQuery) {
	window.opener.location = 'showjobs.asp?sSavedQuery=' + sSavedQuery;
	window.opener.focus();
	iClickCtr=0;
}

function RunSavedSearchFromStopEmail(sSavedQuery) {
	window.location = 'showjobs.asp?sSavedQuery=' + sSavedQuery;
	iClickCtr=0;
}

function GetJobInfo(){

	document.frmEmailJob.hdnJobDesc.value = window.opener.SendEmail.JobDesc.value;
	document.frmEmailJob.hdnJobURL.value = window.opener.SendEmail.JobURL.value;
}
