function checkForm(errMsg) {
	//alert(errMsg.length);
	if(	errMsg!="") {
		//errMsg="<ol>"+errMsg+"</ol>";
		//alert("Please correct error(s) below:<br>"+errMsg);
		return false;
	}
	else return true;
}

function checkAlpha_Num(objName,objTitle) { //Aplpha Numeric using Underscore - useful for usernames
	var filter=/^[A-Z|a-z][A-Z|a-z|0-9|_]*[A-Z|a-z|0-9]+$/
	if (!filter.test(objName.value)) {
		objName.focus();
		return "<li>Invalid input for "+objTitle+".</li>";
	}
	return "";
}

function checkEmpty(objName,objTitle) {
	if (!objName.value) {
		if (objName.type!="hidden")	objName.focus();
		return "<li>Missing input for "+objTitle+".</li>";
	}
	return "";
}

function checkDate(objName,objTitle) {
	var filter=/^(19|20)\d\d[-/](0[1-9]|1[012])[-/](0[1-9]|[12][0-9]|3[01])$/
	if (!filter.test(objName.value)) {
		objName.focus();
		return "<li>Invalid input for "+objTitle+". The set format is yyyy/mm/dd.</li>";
	}
	return "";
}
function checkInteger(objName,objTitle) {
	var filter=/^[0-9]+$/
	if (!filter.test(objName.value)) {
		objName.focus();
		return "<li>Invalid input for "+objTitle+".</li>";
	}
	return "";
}
function checkEmail(objName,objTitle) {
	var filter=/^[\w-_\.]+@[\w-\.]+\.[a-zA-Z0-9]{2,13}$/
	if (!filter.test(objName.value)) {
		objName.focus();
		return "<li>Invalid input for "+objTitle+".</li>";
	}
	return "";
}
function checkDuplicate(objName,objName2,objTitle) {
	if (!(objName.value==objName2.value)) {
		objName2.focus();
		return "<li>Values do not match for "+objTitle+".</li>";
	}
	return "";
}
function checkUrl(objName,objTitle) {
	var filter=/^[\/\.\-\$\&_:\s@\?#a-zA-Z\d]+$/
	if (!filter.test(objName.value)) {
		objName.focus();
		return "<li>Invalid input for "+objTitle+".</li>";
	}
	return "";
}
function checkCheck(objName,objValue,errMessage) {

	if (objName.checked!=objValue) {
		objName.focus();
		return errMessage;
	}
	return "";
}
function checkPhone(objName,objTitle) {
	var filter=/^[\+\(\)\-\s\d]+$/
	if (!filter.test(objName.value)) {
		objName.focus();
		return "<li>Invalid input for "+objTitle+". </li>";
	}
	return "";
}
function checkAddress(objName,objTitle) {
	var filter=/^[\#\(\)\/\'\,\.\-\s_a-zA-Z\d]+$/
	if (!filter.test(objName.value)) {
		objName.focus();
		return "<li>Invalid input for "+objTitle+". </li>";
	}
	return "";
}
function checkName(objName,objTitle) {
	var filter=/^([\'\,\.\-a-zA-Z]+ ?)+$/
	if (!filter.test(objName.value)) {
		objName.focus();
		return "<li>Invalid input for "+objTitle+". </li>";
	}
	return "";
}
function adjustMinMax(max_price,min_price,way){
	if (max_price.selectedIndex<min_price.selectedIndex && way==1) 
		max_price.selectedIndex=min_price.selectedIndex;
	if (min_price.selectedIndex>max_price.selectedIndex && way==2) 
		min_price.selectedIndex=max_price.selectedIndex;
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function a(i) {
i.style.filter = 'Invert()';
}
function verifyForm(f) {
	if (checkAlphaOrNum(f.keyword,"Search Keywords"))	{
		f.action=f.action+"#search";
		f.submit(); 
	}
	else 
		return false;
}
function checkAlpha(objName,objTitle) { //Strictly Alpha
	var filter=/^[A-Z|a-z]+$/
	if (!filter.test(objName.value)) {
		alert("<li>Please input valid value for "+objTitle+". Some valid examples are abc, XYZ, abCD<br> You can only use alphabetics (a-z)<br> May NOT contain numerics or spaces<br> Minnimum length 1<br> Must end in an alphabetic</li>");
		objName.focus();
		return false;
	}
	return true;
}
function checkAlphaSpaces(objName,objTitle) { //Alpha with spaces
	var filter=/^[A-Z|a-z][A-Z|a-z|\s]*[A-Z|a-z]+$/
	if (!filter.test(objName.value)) {
		alert("<li>Please input valid value for "+objTitle+". Some valid examples are abc we, XY Z, abCD<br> You can only use alphabetics (a-z) and spaces<br> May NOT contain numerics or underscores<br> Minnimum length 2<br> Must end in an alphabetic</li>");
		objName.focus();
		return false;
	}
	return true;
}
function checkAlphaNum(objName,objTitle) { //Strictly Aplpha Numeric
	var filter=/^[A-Z|a-z][A-Z|a-z|0-9|\s]*[A-Z|a-z|0-9]+$/
	if (!filter.test(objName.value)) {
		alert("<li>Please input valid value for "+objTitle+". Some valid examples are abc123, abc12b, a bcd<br> Start with an alpha (a-z)<br> May contain alpha (a-z), numerics or spaces<br> End with an alpha(a-z) or numeric<br> Minnimum length 2</li>");
		objName.focus();
		return false;
	}
	return true;
}
function checkAlphaOrNum(objName,objTitle) {
	if (!objName.value) return true; // allowing empty string
	var filter=/^[A-Za-z0-9]([A-Za-z0-9\s]*[A-Za-z0-9])*$/
	if (!filter.test(objName.value)) {
		alert("<li>Please input valid value for "+objTitle+". Some valid examples are abc123, abc 123, abc, 123<br> Start with an alphabetic or numeric<br> May contain alphabetics, numerics or spaces<br> End with an alphabetic or numeric.</li>");
		objName.focus();
		return false;
	}
	return true;
}

//get cookie function
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}	

//end get cookie

function checkcaptcha(objName,objTitle) {
	if (!objName.value) {
		if (objName.type!="hidden")	objName.focus();
		return "<li>Missing input for "+objTitle+".</li>";
	}
	else
	{
		var val=Get_Cookie("captchac");
		//alert(objName.value);
		if (objName.value!=val) {
			objName.focus();
			return "<li>Invalid input for "+objTitle+". </li>";
		}
		return "";
	}
}