// general class browserInfo --> get browser info ( type of browser, version number,... )
browserInfo = new getBrowserInfo();

// get browser info ( type of browser, version number,... )
browserInfo = new getBrowserInfo();

////////////////////////////////////////////////////////////////
function getBrowserInfo(){
////////////////////////////////////////////////////////////////
/***************************************************************
 output data:
type of browser:
---------------
isDOM		- Document Object Model layer acsess
isMSIE		- Microsoft Explorer browser
isNETSCAPE	- Netscape browser
isMOZILLA	- Mozilla browser (same as isNETSCAPE (versionNumber < 6 ???) )

version number:
--------------
versionNumber --> 4,6,7,...
***************************************************************/

	this.userAgent = window.navigator.userAgent
	
	// get DOM
	this.isDOM = ( document.getElementById ? true : false );
	
	// get type of browser
	this.isMSIE = ( navigator.appName == "Microsoft Internet Explorer" );
	this.isNETSCAPE = ( navigator.appName == "Netscape" );

/* remove for MOZILLA
	this.isMOZILLA = ( this.isNETSCAPE && window.navigator.vendorSub == "" );
	this.isNETSCAPE = ( this.isMOZILLA ? false : this.isNETSCAPE )
*/
	
	// get version of the browser
			this.appVersionNumber = getNumber(navigator.appVersion);
	
	// for MOZILLA  ( default version )
	this.versionNumber = this.appVersionNumber;
	
	// for Microsoft browser
	if ( this.isMSIE ) {
		this.versionNumber = getNumber( navigator.appVersion.substring(22,25) );
	}
	
	// for Netscape browser
	if ( this.isNETSCAPE ) {		
		if( window.navigator.vendorSub != undefined 
		 && window.navigator.vendorSub != ""
		  )
			this.versionNumber = getNumber( window.navigator.vendorSub );
	}
	
	return this;
} // end function getBrowserInfo()
////////////////////////////////////////////////////////////////

// test getBrowserInfo function
////////////////////////////////////////////////////////////////
function testBrowser(){
////////////////////////////////////////////////////////////////
	message = 
	"<p>userAgent [" + browserInfo.userAgent + "]\n</p>" + 
	"<p>vendorSub [" + window.navigator.vendorSub + "]\n</p>" + 
	"<p>is MSIE? [" + browserInfo.isMSIE + "]\n</p>" + 
	"<p>is NETSCAPE? [" + browserInfo.isNETSCAPE + "]\n</p>" + 
//	"<p>is MOZILLA? [" + browserInfo.isMOZILLA + "]\n</p>" + 
	"<p>Version number ["+ browserInfo.versionNumber + "]</p>" +
	"</p>";
	
	document.writeln( message );
} // end function testBrowser(){
////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////
function getNumber ( toConvert ) {
////////////////////////////////////////////////////////////////
  var snum = new String( toConvert );  
  var sec = snum.split('.');  
  var whole = parseInt(sec[0]);  
  var dec = parseInt(sec[1]);  

  return String(whole) + "." + String(dec);  
} // end function getNumber ( toConvert ) 
////////////////////////////////////////////////////////////////

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {
//  	if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  	if ( browserInfo.isNETSCAPE && browserInfo.versionNumber == 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 + ",left = 100,top = 100");
 FileUpWin.focus();
}

function popout() {
	if (top.location != document.location)
		top.location = document.location ;
	}

function checkZipcode()
{
	if (new String(document.searchform.zipcode.value) == "")
	{
		alert(alertZipcode);
		document.searchform.zipcode.focus();
		return false;
	}
	return true ;
}


function checkMail()
{
	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;
	}
	document.form1.submit();
}

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;
	}
	if (document.form1.samsoniteresponse[1].checked)
	{ 
		response = "no";
	}
	if (document.form1.samsoniteresponse[0].checked)
	{ 
		response = "yes";
	}	 
	
	mailresponse = "no";
	mailtype = "";
	
//	if (document.form1.mailresponse2.checked)
//	{ 
//		mailresponse = "yes";
//		
//		if (document.form1.mailtype[1].checked) mailtype = "text";
//		else if (document.form1.mailtype[0].checked) mailtype = "html";
//	}
	if (String(document.form1.mailsubject.options[document.form1.mailsubject.selectedIndex].value).length < 5 ) {
		document.form1.mailsubject.options[document.form1.mailsubject.selectedIndex].value = 
		"<region>global</region><country>"+document.form1.countrycustomer.options[document.form1.countrycustomer.selectedIndex].value+"</country><subject>"+
		document.form1.mailsubject.options[document.form1.mailsubject.selectedIndex].value+"</subject><answer>"+response+"</answer><updates>"+mailresponse+"</updates><format>"+mailtype+"</format>";
	}
	document.form1.submit();
}

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.serialnumber.value) == "")
	{
		alert(alertSerialNumber);
		document.form1.serialnumber.focus();
		return ;
	}
	if (document.form1.countrycustomer.selectedIndex == 0)
	{
		alert(alertCountry);
		document.form1.countrycustomer.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 ;		
	}
	showpopup();
}
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;
}



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_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

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];}
}

