// This file has been modified for the American Web Sites
// Do not overwrite
// 

// functions created by Dreamweaver for preload and swap of images on web site.
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// ============================================================================

function Popup(psUrl,psTarget,y,x) {
 FileUpWin = window.open(psUrl,psTarget,"toolbar=no,location=no,directories=no,scrollbars=no,status=no,resizable=no,width=" + x + ",height=" + y);
 FileUpWin.focus();
}


function PopupScroll(psUrl,psTarget,y,x) {
 FileUpWin = window.open(psUrl,psTarget,"toolbar=no,location=no,directories=no,scrollbars=yes,status=no,resizable=no,width=" + x + ",height=" + y);
 FileUpWin.focus();
}
// ============================================================================

function checkZipcode()
{
	if (new String(document.searchform.zipcode.value) == "")
	{
		alert(alertZipcode);
		document.searchform.zipcode.focus();
		return false;
	}
	return true ;
}

// Modified for the Americas web sites. 8/7/01 KLH
// Used by OptIn email.
function checkMail()
{
	if (new String(document.form1.emailAddress.value) == "" || !emailCheck(document.form1.emailAddress.value))
	{
		alert(alertMail);
		document.form1.emailAddress.focus();
		return false;
	}
	if (document.form1.emailCountry.selectedIndex == 0)
	{
		alert(alertCountry);
		document.form1.emailCountry.focus();
		return false;
	}
	return true;
}

function checkContact()
{
	if (new String(document.form1.mail.value) == "" || !emailCheck(document.form1.mail.value))
	{
		alert(alertMail);
		document.form1.mail.focus();
		return false;
	}
	if (document.form1.countrycustomer.selectedIndex == 0)
	{
		alert(alertCountry);
		document.form1.countrycustomer.focus();
		return false;
	}
	if (document.form1.mailsubject.selectedIndex == 0)
	{
		alert(alertSubject);
		document.form1.mailsubject.focus();
		return false;
	}
	if (new String(document.form1.mailbody.value) == "")
	{
		alert(alertBody);
		document.form1.mailbody.focus();
		return false;
	}
	if (!document.form1.samsoniteresponse[0].checked && !document.form1.samsoniteresponse[1].checked) 
	{
		alert(alertSamsoniteResponse);
		return false;
	}
	showpopup();
}

function checkWarranty()
{
	if (new String(document.form1.firstname.value) == "")
	{
		alert(alertFirstname);
		document.form1.firstname.focus();
		return ;
	}
	if (new String(document.form1.middlename.value) == "")
	{
		alert(alertMiddlename);
		document.form1.middlename.focus();
		return ;
	}
	if (new String(document.form1.lastname.value) == "")
	{
		alert(alertLastname);
		document.form1.lastname.focus();
		return ;
	}
	if (new String(document.form1.address.value) == "")
	{
		alert(alertAddress);
		document.form1.address.focus();
		return ;
	}
	if (new String(document.form1.housenumber.value) == "")
	{
		alert(alertHouseNumber);
		document.form1.housenumber.focus();
		return ;
	}
	if (new String(document.form1.city.value) == "")
	{
		alert(alertCity);
		document.form1.city.focus();
		return ;
	}
	if (new String(document.form1.state.value) == "")
	{
		alert(alertState);
		document.form1.state.focus();
		return ;
	}
	if (new String(document.form1.zipcode.value) == "")
	{
		alert(alertZipcode);
		document.form1.city.focus();
		return ;
	}
	if (document.form1.countrycustomer.selectedIndex == 0)
	{
		alert(alertCountry);
		document.form1.countrycustomer.focus();
		return ;
	}
	if (new String(document.form1.mail.value) == "" || !emailCheck(document.form1.mail.value))
	{
		alert(alertMail);
		document.form1.mail.focus();
		return false;
	}
	if (new String(document.form1.serialnumber.value) == "")
	{
		alert(alertSerialNumber);
		document.form1.serialnumber.focus();
		return ;
	}
	if (document.form1.choicereason.selectedIndex == 0)
	{
		alert(alertChoiceReason);
		document.form1.choicereason.focus();
		return ;
	}
	if (document.form1.mailresponse.value == "Y" && document.form1.mailtype[0].checked == false && document.form1.mailtype[1].checked == false)
	{
		alert(alertMailType);
		return ;		
	}
	document.form1.submit();
}
function changeResponse()
{
	document.form1.mailresponse.value=document.form1.mailresponse.value=='N'?'Y':'N' ;
	if (document.form1.mailresponse.value == "N")
	{
		document.form1.mailtype[0].checked = false ;
		document.form1.mailtype[1].checked = false ;
	}
}

function emailCheck (emailStr) {
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
	//alert("Email address seems incorrect (check @ and .'s)")	
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

if (user.match(userPat)==null) {
    // user is not valid
    //alert("The username doesn't seem to be valid.")
    return false
}

var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        //alert("Destination IP address is invalid!")
	        return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.")	
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   //alert("The address must end in a three-letter domain, or two letter country.")
   return false
}
if (len<2) {
   //var errStr="This address is missing a hostname!"
   var errStr="Het adres mist een hostnaam!"
   //alert(errStr)
   return false
}
return true;
}
// Added by trever for paging features
function pagination(val)
{
	var docLocation = new String(document.location);
	if (docLocation.indexOf("&page=") > -1) {
		var idx = docLocation.indexOf('&page=');
		var tmp = docLocation.substring(0,idx + 6);
//		tmp +='&page=';
//		tmp += val;
//		var tmp2 = docLocation.substring(idx + 7, docLocation.length);
		docLocation = tmp + val;
		
	} else {
		docLocation += '&page=' + val ;
	}
	document.location = docLocation;
}
// Added to do page links 1,2,3,4, etc..
function pageLinks(currentPage, totalPages) {
	for (i=0;i < totalPages ;i++) {
		if (i != currentPage) {
			var onMEn = " onMouseOver=\"window.status='Go to page " + (i+1) + "';return true;\" ";
			var onMEx = " onMouseOut=\"window.status='';return true;\" ";
			document.write("<a " + onMEn + onMEx + " href=\"javascript:pagination('" + i + "');\">");
			document.write(i+1);
			document.write("</a>&nbsp;");
		} else {
			document.write((i+1) + "&nbsp;");
		}
	}
}

function mqzoom(val)
{
	var docLocation = new String(document.location);
	if (docLocation.indexOf("&zoom=") > -1) {
		var idx = docLocation.indexOf('&zoom=');
		var tmp = docLocation.substring(0,idx);
		
		tmp +='&zoom=';
		tmp += val;
		var tmp2 = docLocation.substring(idx + 7, docLocation.length);
		docLocation = tmp + tmp2;
		
	} else {
		docLocation += '&zoom=' + val ;
	}
	document.location = docLocation;
}


function getParams() {
	var idx = document.URL.indexOf('?');
	var params = new Array();
	if (idx != -1) {
	var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
	for (var i=0; i<pairs.length; i++) {
		nameVal = pairs[i].split('=');
		params[nameVal[0]] = nameVal[1];
 	  }
	}
	return params;
}

function findCountryName(countryCode) {
	var ctyLstStr = String(countrylist);
	var indexOfCode = ctyLstStr.indexOf("<option value=\""+countryCode+"\">");
	var partCountry = ctyLstStr.substr(indexOfCode,ctyLstStr.length);
	var indexEndCty = partCountry.indexOf("</option>");
	var ctyString = partCountry.substr(0,indexEndCty);
	return ctyString;
}

function findReasonName(reasonCode) {
	var reasonLstStr = String(producthowlist);
	var indexOfCode = reasonLstStr.indexOf("<option value=\""+reasonCode+"\">");
	var partReason = reasonLstStr.substr(indexOfCode,reasonLstStr.length);
	var indexEndReason = partReason.indexOf("</option>");
	var reasonString = partReason.substr(0,indexEndReason);
	return reasonString;
}
