function init()
{
	 //document.write("In JavaScript init() method");

	if (parent.iframeResize)
	{
		var browserName=navigator.appName;

		if (browserName=="Microsoft Internet Explorer")
			var height=document.body.scrollHeight+35;
		else
			var height=document.body.offsetHeight+35;

		parent.iframeResize('cdhbasefrm', height);
	}

}

window.onload = init;

function printWindow()
{
  myPrintWindow = open("/umi/servlet/usingjsp.PrintableCartServlet", "myPrintWindow");
  myPrintWindow.focus();
}

function toggleClass()
{
	if (this.className == 'button')
	{
		this.className = 'buttonO';
	}
	else if (this.className == 'buttonO')
	{
		this.className = 'button';
	}
}

var elems = document.getElementsByTagName("input");

for (var i = 0; i < elems.length; i++)
{
	if (elems[i].className == 'button')
	{
		elems[i].onmouseover = toggleClass;
		elems[i].onmouseout  = toggleClass;
	}
}

function validateForm(form) {
	if ( !isNum( form.quantity.value ) ) {
		alert("Invalid quantity, must be a number");
		form.quantity.focus();
		form.quantity.select();
		return false;
	}
	if ( form.embroider.checked ) {
		e = form.embroidery.value;
		if ( e == "" ) {
			alert("specify embroidery text, 3 characters maximum");
			form.embroidery.focus();
			form.embroidery.select();
			return false;
		}
		if ( e.length > 3 ) {
			alert("embroidery text has to many characters, 3 characters maximum");
			form.embroidery.focus();
			form.embroidery.select();
			return false;
		}
	}
	return true;
}

function validEmail(email) {
	invalidChars = " /:,;"

	if (email == "") {						// cannot be empty
		return false
	}
	for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			// there must be one "@" symbol
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					// and at least one "." after the "@"
		return false
	}
	if (periodPos+3 > email.length)	{		// must be at least 2 characters after the "."
		return false
	}
	return true
}

function isNum(passedVal) {					// Is this a number?
	if (passedVal == "") {
		return false
	}
	for (i=0; i<passedVal.length; i++) {
		if (passedVal.charAt(i) < "0") {
			return false
		}
		if (passedVal.charAt(i) > "9") {
			return false
		}
	}
	return true
}

function validZip(inZip) {					// Is this a valid Zip code?
	if (inZip == "") {
		return true
	}
	if (isNum(inZip)) {						// Check if Zip is numeric
		return true
	}
	return false
}

//document.write("In JavaScript common.js");
