

//-------------------preloads and rollovers

if (document.images) {
	var imagesNormal = new Object();
	imagesNormal["menu"] = new Image(800, 33);    
	imagesNormal["menu"].src = "images/rolloever.jpg"; 

	var imagesHilite = new Object(); 
	imagesHilite["menu"] = new Image(800, 33); 
	imagesHilite["menu"].src = "images/rolloever-over.jpg"; 
}


function setImage(imgName, type) {
	if (document.images) {
		if (type == "hilite") {
			document.images["menu"].src = imagesHilite["menu"].src; 
			return true; 
		} else if (type == "normal") {
			document.images["menu"].src = imagesNormal["menu"].src; 
			return true; 
		}
	}
	return false; 
}

//-------------------popups for images

function popPicature(w,h,url,bgcolor) {
var hh = String(parseInt(h,10)+20);
var bc = ' bgcolor="' + bgcolor + '"';
	if(bgcolor.length < 1) bc = '';
		var Properties = 'height=' + hh + ',width=' + String(parseInt(w,10)+25);
		var picature = window.open('','picature',Properties);
		picature.document.writeln('<html><head>');
		picature.document.writeln('<script language="JavaScript">');
		picature.document.writeln('<!-- ');
		picature.document.writeln('function CloseMe() {');
		picature.document.writeln('self.close();');
		picature.document.writeln('}');
		picature.document.writeln('\/\/ -->');
		picature.document.writeln('<\/script>');
		picature.document.write('<\/head><body ' + bc  + '" onBlur="CloseMe()"><center>');
		picature.document.write('<IMG SRC="' + url + '" width="' + w + '" height="' + h + '" border="0"">');
		picature.document.writeln('<\/center><\/body><\/html>');
	}
function popLargePicature(w,h,url,bgcolor) {
var hh = String(parseInt(h,10)+20);
var bc = ' bgcolor="' + bgcolor + '"';
	if(bgcolor.length < 1) bc = '';
		var Properties = 'height=' + 600 + ',width=' + 800 + ',scrollbars=yes';
		var picature = window.open('','picature',Properties);
		picature.document.writeln('<html><head>');
		picature.document.writeln('<script language="JavaScript">');
		picature.document.writeln('<!-- ');
		picature.document.writeln('function CloseMe() {');
		picature.document.writeln('self.close();');
		picature.document.writeln('}');
		picature.document.writeln('\/\/ -->');
		picature.document.writeln('<\/script>');
		picature.document.write('<\/head><body ' + bc  + '" onBlur="CloseMe()"><center>');
		picature.document.write('<IMG SRC="' + url + '" width="' + w + '" height="' + h + '" border="0"">');
		picature.document.writeln('<\/center><\/body><\/html>');
	}

function popMovie(w,h,url,bgcolor) {
var hh = String(parseInt(h,10)+20);
var bc = ' bgcolor="' + bgcolor + '"';
	if(bgcolor.length < 1) bc = '';
		var Properties = 'height=' + hh + ',width=' + String(parseInt(w,10)+25);
		var picature = window.open('','picature',Properties);
		picature.document.writeln('<html><head>');
		picature.document.writeln('<script language="JavaScript">');
		picature.document.writeln('<!-- ');
		picature.document.writeln('function CloseMe() {');
		picature.document.writeln('self.close();');
		picature.document.writeln('}');
		picature.document.writeln('\/\/ -->');
		picature.document.writeln('<\/script>');
		picature.document.write('<\/head><body ' + bc  + '" onBlur="CloseMe()"><center>');
		picature.document.write('<embed SRC="' + url + '" width="' + w + '" height="' + h + '" border="0"">');
		picature.document.writeln('<\/center><\/body><\/html>');
	}

function popSWF(w,h,url,bgcolor) {
var hh = String(parseInt(h,10)+20);
var bc = ' bgcolor="' + bgcolor + '"';
	if(bgcolor.length < 1) bc = '';
		var Properties = 'height=' + hh + ',width=' + String(parseInt(w,10)+25);
		var picature = window.open('','picature',Properties);
		picature.document.writeln('<html><head>');
		picature.document.writeln('<script language="JavaScript">');
		picature.document.writeln('<!-- ');
		picature.document.writeln('function CloseMe() {');
		picature.document.writeln('self.close();');
		picature.document.writeln('}');
		picature.document.writeln('\/\/ -->');
		picature.document.writeln('<\/script>');
		picature.document.write('<\/head><body ' + bc  + '" onBlur="CloseMe()"><center>');
		picature.document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.#version=5,0,30,0" width="' + w + '" height="' + h + '"><param name="movie" value="' + url + '"><param name="quality" value="best"><param name="play" value="true"><embed pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" src="' + url + '" type="application/x-shockwave-flash"  width="' + w + '" height="' + h + ' quality="best" play="true"></object>');
		picature.document.writeln('<\/center><\/body><\/html>');

	}


function popupqf(url)
{
        newwindow=window.open(url,'name','height=400,width=400,scrollbars=no,resize=no');
        if (window.focus) {newwindow.focus()}
}

function popuptext(url)
{
        newwindow=window.open(url,'name','height=400,width=600,scrollbars=yes,resize=no');
        if (window.focus) {newwindow.focus()}
}

//-------------------script for minimal validation of forms

//--check that required fields are non-empty 

function isNotEmpty(elem) {
	var str = elem.value; 
	var re = /.+/;
	if (!str.match(re)) {
		alert("Please fill in the required field."); 
		return false; 
	} else {
		return true; 
	}
}

//--check that email field contains a semi valid email address

function isEmailAddr(elem) {
	var str = elem.value; 
	str = str.tolowercase(); 
	if (str.indexOf("@") > 1) {
		var addr = str.substring(0, str.indexOf("@")); 
		var domain = str.substring(str.indexOf("@") + 1, str.length); 
		//at least the tld required
	if (domain.indexOf(".") == -1) { 
		alert("Verify the domain portion of the email address."); 
		return false; 
	}
	//parse address portion first, character by character 
	for (var i = 0; i < addr.length; i++) {
		oneChar = addr.charAt(i).charCodeAt(0); 
		//dot or hyphen not allowed in first position, dot at last
		if ((i == 0 && (oneChar == 45 || oneChar == 46)) ||
			(i == addr.length - 1 && oneChar == 46)) {
			alert("Verify the user name portion of the email address."); 
			return false; 
		}
		//acceptable characters (- . _ 0-9 a-z)
		if (oneChar == 45 || oneChar == 46 || oneChar == 95 || 
			(oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
			continue; 
		} else {
			alert("Verify the user name portion of the email address."); 
			return false; 

		}
	}
	
	for (i = 0; i < domain.length; i++) {
		oneChar = domain.charAt(i).charCodeAt(0); sw
		if ((i == 0 && (oneChar == 45 || oneChar == 46)) ||

			((i == domain.length - 1 || i == domain.length - 1) && oneChar == 46)) {
			alert("Verify the domain portion of the email address."); 
			return false; 
		}
		if (oneChar == 45 || oneChar == 46 || onechar == 95 ||
			(oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
			continue; 
		} else {
			alert("Verify the domain portion of the email address."); 
			return false; 
		}
	}
	return true; 
}
alert ("The email address may not be formatted correctly. Please verify."); 
return false; 
}




//--check format of credit card

function isCreditCard(elem) {
	var str = elem.value; 
	if (str.length != 16) {
		alert("Your credit card number must be 16 digits long, no spaces."); 
		return false; 
	} else {

	return true; 
	}
}

function isValid(string) {
var valid = '0123456789'; // define valid characters
    for (var i=0; i< string.length; i++) {
       if (valid.indexOf(string.charAt(i)) == -1)
          return false;
    }
    return true;
}

//var test = '123';
//alert(isValid(test)); // returns true



//-------------------script for copying data from one group of fields to the other in shopping cart


function duplicateValues() 
{
	document.billform.x_Ship_To_First_Name.value = document.billform.x_First_Name.value;
	document.billform.x_Ship_To_Last_Name.value = document.billform.x_Last_Name.value;
	document.billform.x_Ship_To_Company.value = document.billform.x_Company.value;
	document.billform.x_Ship_To_Address.value = document.billform.x_Address.value;
	document.billform.x_Ship_To_City.value = document.billform.x_City.value;
	document.billform.x_Ship_To_State.value = document.billform.x_State.value;
	document.billform.x_Ship_To_Zip.value = document.billform.x_Zip.value;
	document.billform.x_Ship_To_Country.value = document.billform.x_Country.value;

}
