 // Del Job Post
function delJob(jobID){
 if (confirm("Are you sure you want to Delete this Job?\nClick OK to delete or Cancel to return.") == true)
     {
     //alert("Clicked OK");
     window.location=('job_list.asp?delID=' + jobID);
     }
}
			
//	FUNCTION TO SET FORM FOCUS TO ANY FIELD - IF NOTHING IS IN IT ALREADY /////////////////////////////////////////////////////////////////////
//	pretty much any form page

function focusField(target)
{
	// The form elements that will be tested. Anything with a dot indicates the "type" attribute of the element
	var formElements = ["input.text", "input.checkbox", "input.radio", "select", "textarea"];
	var selectedNode = null;

	// IE's selection method
	if (typeof document.selection != "undefined" && document.selection != null && typeof window.opera == "undefined")
	{
		var theSelection = document.selection;
		var textRange = document.selection.createRange();

		selectedNode = textRange.parentElement();
	}
	// W3 selection method. Currently only Mozilla & Safari support it. However, neither of them support ranges inside form objects, so this part is redundant. Merely included in case they decide to include support in the future
	else if (typeof window.getSelection != "undefined")
	{
		var theSelection = window.getSelection();

		// The Safari way to get the node that a selection starts in
		if (typeof theSelection.baseNode != "undefined")
		{
			selectedNode = theSelection.baseNode;
		}
		// The Mozilla way to get the node that a selection starts in
		else if (typeof theSelection.getRangeAt != "undefined" && theSelection.rangeCount > 0)
		{
			selectedNode = theSelection.getRangeAt(0).startContainer;
		}
	}

	// If a selected node was found above, check whether it's a selection inside one of the specified form element types
	if (selectedNode != null)
	{
		for (var i = 0; i < formElements.length; i++)
		{
			if (selectedNode.nodeName.toLowerCase() == formElements[i].replace(/([^.]*)\..*/, "$1"))
			{
				return false;
			}
		}
	}

	var forms = document.forms;

	// Do a check of each form element on the page. If one of them has a value, do not focus
	for (var i = 0; i < forms.length; i++)
	{
		var formElements = forms[i];

		for (var j = 0; j < formElements.length; j++)
		{
			if (formElements[j].getAttribute("type") == "checkbox" || formElements[j].getAttribute("type") == "radio")
			{
				if (formElements[j].checked != formElements[j].defaultChecked)
				{
					return false;
				}
			}
			else
			{
				if (typeof formElements[j].defaultValue != "undefined" && formElements[j].value != formElements[j].defaultValue)
				{
					return false;
				}
			}
		}
	}

	// If no form elements were found to be focused -- or with values -- go ahead and focus
	target.focus();

	return false;
}

	//	EXAMPLE
	/*
	<script type="text/javascript" language="JavaScript">
	<!--
	window.onload = initFormFieldFocus;
	function initFormFieldFocus()
	{
	focusField(document.getElementById("email"));

	return true;
	}
	//-->
	</script>

	*/

//	EXECUTING JAVASCRIPT ON PAGE LOAD /////////////////////////////////////////////////////////////////////
function addLoadEvent(func) {
 var oldonload = window.onload;
 if (typeof window.onload != 'function') {
   window.onload = func;
 } else {
   window.onload = function() {
     oldonload();
     func();
   }
 }
}
/* Uses

addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(function() {
  // more code to run on page load
});
*/

//	FORM BUTTONS /////////////////////////////////////////////////////////////////////
  function goToURL(pagename) {
  	var url = pagename;
    location.href = url;
  }
function openNewWindow(pageref,win_name) {
	var remote = window.open(pageref,win_name,"width=400,height=300,toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
	if (remote.opener == null) remote.opener = window;
	remote.opener.name = "parent_window";
}

function radioValue(group){
	// loop through all the buttons
		for ( var i=0; i<group.length; i++ ){
		if ( group[i].checked == true )
	return group[i].value;
	}
	// NOTE: this function returns -1 if none
	// is selected.
	return -1;
}

function SetVisitor(setVisitor) {
  // Create Ajax Request
  createGetRequest();

  // Get Form Values
  var url = "visitor_type_submit.asp?svJ=" + escape(setVisitor) + "&nocache=" + new Date().getTime();

  request.open("GET", url, true);
  request.onreadystatechange = processSetVisitor;
  request.send(null);
}

function processSetVisitor() {
//reset
document.getElementById('saveSetVisitorButtonError').style.display="none";
document.getElementById('saveSetVisitorButtonSet').style.display="none";

  if (request.readyState == 4) {
      if (request.status == 200) {

  		var httpResponse = request.responseText;

  				if (httpResponse=="0"){     // ERROR

                    //Make sure the Error Message is reset to no display Except the one being called
                    document.getElementById('saveSetVisitorButtonSet').style.display="none";
                    $('span.saveSetVisitorButtonError').show('slow');

  				}else if (httpResponse=="1"){   // SET

                    //Make sure the Error Message is reset to no display Except the one being called
                    document.getElementById('saveSetVisitorButtonError').style.display="none";
                    document.getElementById('saveSetVisitorButton').style.display="none";
                    $('span.saveSetVisitorButtonSet').show('slow');

  				}

      } else {
          alert('There was a problem with the request.');
      }
  }

}