// both these scripts used in catalogue request page

function checkInfo() {
	
	var location = document.catRequest
	var radio_choice = false
	var errorStart = "Some required information is missing:\n\n"
	var addressError = ""
	var radioError = ""
	var emailError = "";
	if (location.crFirstName.value == "") addressError += '- First Name\n';
	if (location.crLastName.value == "") addressError += '- Last Name\n';
	if (location.crAddress.value == "") addressError += '- Address\n';
	if (location.crCity.value == "") addressError += '- City\n';
	if (location.crState.selectedIndex == 0) addressError += '- State\n';
	if (location.crZip.value == "") addressError += '- Zip\n';
	
	for (var i = 0; i < location.crSource.length; i++){
		if (location.crSource[i].checked) radio_choice = true;
	}
	if (radio_choice == false) radioError = '\n- Please tell us how you found us.\n';
		
	if (location.crEmail.value != "") {
		var AtSym = location.crEmail.value.indexOf('@')
		var Period = location.crEmail.value.lastIndexOf('.')
		var Space = location.crEmail.value.indexOf(' ')
		var Length = location.crEmail.value.length-1

		if ((AtSym < 1)||(Period <= AtSym+1)||(Period == Length)||(Space  != -1)){  
     	 	emailError = '\nThere is a problem with you email address.\n\n';
   		}
	}
	
	if (addressError != "" || radioError != "" || emailError !="") {
		alert(errorStart + addressError + radioError + emailError);
	return false;
	}
}



function setSourceRadio(key) {

	$('#radio_'+key).attr('checked', 'checked'); 
	
}