// TBT-Specific Javascript

function select_area(){
 document.frm.name.select();
}

function trimAll( strValue ) {
/************************************************
DESCRIPTION: Removes leading and trailing spaces.
PARAMETERS: Source string from which spaces will be removed;
RETURNS: Source string with whitespaces removed.
*************************************************/ 

	var objRegExp = /^(\s*)$/;
	//check for all spaces
	if(objRegExp.test(strValue)) {
		strValue = strValue.replace(objRegExp, '');
	    if( strValue.length == 0)
	    return strValue;
	}

	//check for leading & trailing spaces
	objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	if(objRegExp.test(strValue)) {
		//remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
	}
	return strValue;
}

function checkName(){
		var illegalChars = /[^ \a-zA-Z_0-9]/; // allow letters, numbers, and underscores
		var theName = document.getElementById('name');
		theName.value = trimAll(theName.value);
		if(theName.value.length < 2 || theName.value == ''){
			alert("Please enter your pet's name.");
			return false;
		}else if (illegalChars.test(theName.value)) {
			alert("Please use only letters, numbers, and underscores when entering your pet's name.\n");
			theName.value = "";
    	}else{
			document.frm.submit();
		}
}


//TBT Comparison brand details popup

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=500,left = 390,top = 262');");
}

