// JavaScript Document

// CLEAR TEXT FROM FORMS AND CHANGE TEXT TO BLACK ONFOCUS 

function clearText(thefield)
{
	if (thefield.defaultValue == thefield.value){
	thefield.value = "";
	}
	thefield.style.color = "#000";
	}

// In the event that a user clicks on a field and enters no data the following will ensure that the default field value is returned to the field onblur.

function loginLabel(thefield)
{
	if (thefield.value == ""){
	thefield.value = "E-mail address";
	}
	thefield.style.color = "#999";
	}

function passwordLabel(thefield)
{
	if (thefield.value == ""){
	thefield.value = "Password";
	}
	thefield.style.color = "#999";
	}

function searchLabel(thefield)
{
	if (thefield.value == ""){
	thefield.value = "Enter Keywords or Job Title";
	}
	thefield.style.color = "#999";
	}

function searchText(thefield)
{
	if (thefield.defaultValue == "Enter Keywords or Job Title"){
	thefield.value = "";
	}
	thefield.style.color = "#000";
	}

	
// Browse categories. This function creates the "Browse Job Categories" link and reveals the categoires on click.

window.onload = function()
{
	if(document.getElementById)
	{
		var linkContainer = document.getElementById('linkContainer');
		var toggle = linkContainer.appendChild(document.createElement('a'));
		toggle.href = '#';
		toggle.appendChild(document.createTextNode('Browse by Category'));
		toggle.onclick = function()
		{
			var linkText = this.firstChild.nodeValue;
			this.firstChild.nodeValue = (linkText == 'Browse by Category') ? 'Browse by Category' : 'Browse by Category';

			
			var tmp = document.getElementsByTagName('ul');
			for (var i=0;i<tmp.length;i++)
			{
				if(tmp[i].className == 'browsecategorybox')
				{
					tmp[i].style.display = (tmp[i].style.display == 'block') ? 'none' : 'block';
				}
			}
			return false;
		}
	}
}


// The following ensures that if someone opts not to enter and search terms the default value does not get sent as the search criteria

function validateSearch(){  
		if   (document.jobSearchForm.kAndEntire.value =="Enter Keywords or Job Title"){
		     document.jobSearchForm.kAndEntire.value = '';
			 document.jobSearchForm.kAndEntire.style.color = '#000';

			}

			document.jobSearchForm.searchSubmit.value='Searching...';
	}