/* Put default text in the search box */
function setDefaultText(textObj, defaultText){
	var value = textObj.value;
	if(value == ''){
		textObj.value = defaultText;
		textObj.style.color = '#C0C0C0';
	}	
}

function clearDefaultText(textObj, defaultText){
	var value = textObj.value;
	if(value == defaultText){
		textObj.value = '';
		textObj.style.color = '#000000';
	}	
}

/* Update the catId */
function checkAndSubmit(form){
	var search_word = form.keywords.value;
	if(search_word == 'Search' || search_word == ''){
		//alert('Please enter a phrase to search!');
		//return false;
		form.keywords.value = '';
	}
	
	var selected_radio = getCheckedValue(form.aff);
	//alert(selected_radio);
	if(selected_radio == '10007'){ //'companies' radio	
		// assign industry/catId correlations (arr[industry] = catId)	
		var rel = new Array();
		rel['2'] = '2'; //All Industries
		rel['1'] = '520'; //Advertising & Marketing	
		rel['3'] = '540'; //Automotive
		rel['4'] = '560'; //Biometrics
		rel['6'] = '580'; //Civil Safety
		rel['7'] = '590'; //Consumer Electronics
		rel['8'] = '610'; //Energy
		rel['9'] = '620'; //Franchise
		rel['10'] = '630'; //Green Industries
		rel['11'] = '640'; //Healthcare
		rel['15'] = '680'; //Information Technology
		rel['5'] = '570'; //Life Sciences
		rel['12'] = '650'; //Manufacturing
		rel['13'] = '660'; //Robotics
		rel['14'] = '670'; //Security
		rel['16'] = '700'; //Telecommunication
		rel['17'] = '710'; //Video Games Development
		rel['18'] = '720'; //Web Media & Technology
		rel['19'] = '2000'; //Technology
		//alert(rel);	
		try{
			form.catUpdate.value='true';
			var selected_industry = form.industry.options[form.industry.options.selectedIndex].value;
			//alert(selected_industry);
			form.catId.value = rel[selected_industry];
		}catch(e){}
	}
	form.submit();
}

function checkSubmit(form){
	var search_word = form.keywords.value;
	if(search_word == 'Search' || search_word == ''){
		//alert('Please enter a phrase to search!');
		//return false;
		form.keywords.value = '';
	}
	
	var selected_radio = getCheckedValue(form.aff);
	//alert(selected_radio);
	if(selected_radio == '10007'){ //'companies' radio	
		// assign industry/catId correlations (arr[industry] = catId)	
		var rel = new Array();
		rel['2'] = '2'; //All Industries
		rel['1'] = '520'; //Advertising & Marketing	
		rel['3'] = '540'; //Automotive
		rel['4'] = '560'; //Biometrics
		rel['6'] = '580'; //Civil Safety
		rel['7'] = '590'; //Consumer Electronics
		rel['8'] = '610'; //Energy
		rel['9'] = '620'; //Franchise
		rel['10'] = '630'; //Green Industries
		rel['11'] = '640'; //Healthcare
		rel['15'] = '680'; //Information Technology
		rel['5'] = '570'; //Life Sciences
		rel['12'] = '650'; //Manufacturing
		rel['13'] = '660'; //Robotics
		rel['14'] = '670'; //Security
		rel['16'] = '700'; //Telecommunication
		rel['17'] = '710'; //Video Games Development
		rel['18'] = '720'; //Web Media & Technology
		rel['19'] = '2000'; //Technology
		//alert(rel);	
		try{
			form.catUpdate.value='true';
			var selected_industry = form.industry.options[form.industry.options.selectedIndex].value;
			//alert(selected_industry);
			form.catId.value = rel[selected_industry];
		}catch(e){}
	}
	return true;
}

/**
* Search onSubmit
*/
function checkSearchSubmit(form){
	
	var search_word = form.keywords.value;
	if(search_word == 'Search' || search_word == ''){
		//alert('Please enter a phrase to search!');
		//return false;
		form.keywords.value = '';
	}
	
	return true;
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

/* hide Email */
function hideEmail(name, domain, tld){
	locationstring = 'mai' + 'lto:' + name + '@' + domain + '.' + tld;
    window.location.replace(locationstring);
}

