window.onload = function(){
	toggleStateProvince();
}

function toggleStateProvince () {
	if (document.advancedSearch.country_id.value == 'US'){
		document.getElementById('provinces').style.display = "none";
		document.getElementById('states').style.display = "block";
	}
	else if (document.advancedSearch.country_id.value == 'CA'){
		document.getElementById('states').style.display = "none";
		document.getElementById('provinces').style.display = "block";
	}
	else {
		document.getElementById('states').style.display = "none";
		document.getElementById('provinces').style.display = "none";
	}
}

function highlight(x,y){
	if (y){
		x.style.borderColor = "#9DEBFF";
	} else {
		x.style.borderColor = "#E5E5E5";
	}
}

function validateEmailSend(x) {
	errormessage = new String();
	
	if (WithoutContent(x.email_to.value)) {
		errormessage += "\nRecipient Email is required to send.";
	};
	
	if (errormessage.length > 2) {
		alert('Attention:\n' + errormessage);
		return false;
	}
	return true;
}

function sortBy(x) {
	document.advancedSearch.sortBy.value = x;
	document.advancedSearch.submit();
}