function doesFormExistByName(strformName)
{
	if ( document.forms == null ) {
		return false;
	}
	
	if ( strformName.length == 0 ) {
		return false;
	}

	for ( doc in document.forms) {
		if ( doc == strformName) {
			return true;
		}
	}
 
	return false;
}

function SubmitFormByName(strformName,strURL)
{
	if (doesFormExistByName(strformName)==false) {
		alert('missing form parameter');
		return;
	}
	
	if (strURL.length > 0){
		document.forms(strformName).action = strURL;
	}

	document.forms(strformName).submit();
}

//functions for the company dropdown list on every page
function redirect(widget) {
		if (widget.selectedIndex >= 0) {
			newUrl = widget.options[widget.selectedIndex].value;
			if (newUrl.length>0) {
				if (newUrl.indexOf("http://") != -1) {
					breakout(newUrl);
				} else {
					window.location.href = newUrl;
				}
			 }
		}
	}
	
function Compaines_redirect(widget) {
		if (widget.selectedIndex >= 0) {
			window.location.href = newUrl = '/goto/ddgoto.asp?cid='+widget.options[widget.selectedIndex].value;
		}
}
	
function breakout(URL) {
		window.open(URL);
}
//end company drop down functions

function closeFloatingBanner(){
	banner = document.getElementById("floating_banner");
	banner.style.display = "none";	
}	

function clearTable(tableName) {
	if  ( $(tableName).rows.length == 0 ) {
		return;
	}
	var rowIndex = 0;
	while (rowIndex < $('tblJobs').rows.length) {
		$(tableName).deleteRow(rowIndex);		
	}	
}

function stripHTML(string) {
	var rString=string.replace(/(<([^>]+)>)/ig,"");
}

function validateInput(type,value) {
	if (type=='email') {
		var pattern=/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
		
		if (pattern.test(value)) {
			return true;			
		}	
	}
	
	return false;
}
/*
documentDimensions -> {x , y}
*/

function documentDimensions(){
	var diemensions=new Array(1);
	
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2) // all but Explorer Mac
	{
		diemensions[0] = document.body.scrollWidth;
		diemensions[1] = document.body.scrollHeight;
	}
	else // Explorer Mac;
		 //would also work in Explorer 6 Strict, Mozilla and Safari
	{
		diemensions[0] = document.body.offsetWidth;
		diemensions[1] = document.body.offsetHeight;
	}
	return diemensions;
}

/*
	clear search box of text on click
*/
function clearSearchField(fieldId,defaultString){

	if (typeof(defaultString) != "string"){
		defaultString = "Search";
	}
	
	if (typeof(fieldId) != "string"){
		fieldId = "field_search";
	}
	
	try{
		var search_field = document.getElementById(fieldId);
		
		if (search_field.value == defaultString){
			search_field.value = "";
		}
	
	} catch(e) {
		//handle error ... :'(

	}

}

/*
	replace search box contents with default text if it's unfocused and nothing is in it.
*/
function unClearSearchField(fieldId,defaultString){

	if (typeof(defaultString) != "string"){
		defaultString = "Search";
	}
	
	if (typeof(fieldId) != "string"){
		fieldId = "field_search";
	}
	
	try{
		var search_field = document.getElementById(fieldId);
		
		if (search_field.value == ""){
			search_field.value = defaultString;
		}
	
	} catch(e) {
		//handle error ... :'(
		
	}

}


var hostName = location.hostname;

