// Scripts by kev (at) technotik (dot) com
// Copyright technotik.com
// unless stated otherwise in comments


function checkForAlert(error_message, user_message) {
	if(error_message != "")
		alert(error_message);
	if(user_message != "")
		alert(user_message);
} // end checkForAlert()


// From O'Reilly JavaScript: The Definitive Guide
function isBlank(s) {
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '	')) return false;
    }
    return true;
} // end isBlank()


function checkForm(thisForm) {
	for(var i=0; i < thisForm.elements.length; i++) {
		if(thisForm.elements[i].value.length < 1) {
			alert("Please enter " + thisForm.elements[i].name);
			thisForm.elements[i].focus();
			return false;
		}
	}
	return true;
} // end checkForm()


function validateSearch(thisForm) {
	if((thisForm.quick_search.value.length < 3 || isBlank(thisForm.quick_search.value)) && thisForm.tooltype.value == 0) {
		alert("Please enter a valid search word");
		return true;
	}
	else 
		return true;
} // end validateForm()


function	showPopUp(urlString) {
	var width = "500", height = "480";
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + width + ',height=' + height;

	popUpWindow = window.open(urlString, "popUpWindow", styleStr);
	if(popUpWindow)
		popUpWindow.focus();	
} // end showPopUp()



function validateLogin(thisForm) {
	
	if(thisForm.email.value.length < 9) {
		alert("Please enter your email address");
		thisForm.email.focus();
		return false;
	}
	else if(thisForm.pass.value.length < 6) {
		alert("Please enter a value for password at least six characters long");
		thisForm.pass.focus();
		return false;
	}

	return true;
} // end validateLogin()


function validateChangePassword(thisForm) {
	
	if(thisForm.pass.value.length < 6) {
		alert("Please enter a value for password at least six characters long");
		thisForm.pass.focus();
		return false;
	}
	else if(thisForm.pass_check.value.length < 6) {
		alert("Please re-type your password at least six characters long");
		thisForm.pass_check.focus();
		return false;
	}
	return true;
} // end validateChangePassword()