// Script:   common.js 
// Purpose:  Provides JavaScript that is common to all or most pages on the Hamilton Jewelers site. 
// Author:   Gerry Stanford
// Date Written: September of 2005

//
// TRIMMING FUNCTIONS 
//
// Trim the left side of a value. 
function ltrim(argvalue) {
	while (1) {
    	if (argvalue.substring(0, 1) != " ") break;
		argvalue = argvalue.substring(1, argvalue.length);
	}
	return argvalue;
}
// Trim the right side of a value. 
function rtrim(argvalue) {
	while (1) {
		if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ") break;
		argvalue = argvalue.substring(0, argvalue.length - 1);
	}
	return argvalue;
}
// Trim both sides of a value. 
function trim(argvalue) {
	var tmpstr = ltrim(argvalue);
	return rtrim(tmpstr);
}

//
// FORM VALIDATION
//

// Make sure the main search box is not submitted empty. 
function validateSearch (cri) {
	cri = trim(cri);
	if (cri.length) return true;
	else {
		alert('Please enter the keyword(s) on which you would like to search');
		return false;
	}
}