function joinFields(form) {
	if (typeof form.monogram1 != "undefined" && (form.monogram1.value != '' || form.monogram2.value != '' || form.monogram3.value != ''))
		form.item_custom1.value = "\n Monogram Text: "+form.monogram1.value+form.monogram2.value+form.monogram3.value;
	if (typeof form.inscribe != "undefined" && form.inscribe.value != '')
		form.item_custom2.value = "\n Inscription Text: "+form.inscribe.value;
		
	return true;
}

function jumpTo2(targ,selObj,restore){
		 //alert ("page/" + selObj.options[selObj.selectedIndex].value);
  eval(targ+".location='"+"http://www.excaliburcutlery.com/" + selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function textIsSet(form) {
	if (typeof form.monogram1 != "undefined") {
	  	if ((returnObjById('Monogram') != null && returnObjById('Monogram').selectedIndex != 0) || (returnObjById('Free Monogram') != null && returnObjById('Free Monogram').selectedIndex != 0)) {
	  		if (!(trim(form.monogram1.value) != '' && trim(form.monogram2.value) != '' && trim(form.monogram3.value) != '')) {
  		 		alert("You have selected Monogramming, but have not entered three initials. Please enter three initials and try again.");
  				return false;	
	  		}
	  		else if (hasNumber(form.monogram1.value) || hasNumber(form.monogram2.value) || hasNumber(form.monogram3.value)) {
	  			alert("Sorry, but numbers are not allowed in monograms. Please replace all numbers with letters.");
  				return false;
	  		}
		}
		else if (trim(form.monogram1.value) != '' || trim(form.monogram2.value) != '' || trim(form.monogram3.value) != '') {
			 alert("You have entered Monogram initials, but have not selected Monogramming. Please select Monogramming option or remove initials.");
			 return false;
		}
	}
	
	if (typeof form.inscribe != "undefined") {
  	if (returnObjById('Inscription') != null && returnObjById('Inscription').selectedIndex != 0) {
  		 if (trim(form.inscribe.value) == '') {
  		 		alert("You have selected Inscription, but have not included any inscription text. Please enter an inscription and try again.");
  				return false;
  		 }
  	}
  	else if (trim(form.inscribe.value) != '') {
  			 alert("You have entered Inscription text, but did not select an Inscription option. Please select an Inscription option or remove Inscription text.");
  			 return false;
  	}
	}
	return true;
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function hasNumber(t) {
	return /\d/.test(t);
}

