var av = navigator.appVersion;
var ua = navigator.userAgent;
var Browser = 0;
var VersionHigh = -1;
var clean = 1;
var current_image = "none";
var old_image = "none";

if ( av.indexOf('MSIE') != -1 )
{
	var VersionString = av.substring(av.indexOf('MSIE')+5, av.length);
	VersionHigh = parseInt( VersionString );
	if(VersionHigh >= 4)
	{
		Browser = 1;
	}
	else
	{
		Browser = 0;
	}
}
else if ( navigator.appName == 'Netscape' )
{
	Browser = 1;
	VersionHigh = parseInt( av );
}

function hilite(imgName){
 	if (document.images) this.document.images[imgName].src = eval(imgName + "2.src");
}

function uit(imgName) {
	if (imgName != current_image){
  	if (document.images) this.document.images[imgName].src = eval(imgName + "1.src");
  }
}

function setpic(imgName) {
	old_image = current_image;
	current_image = imgName;
   	if(old_image != "none") uit(old_image);
}

function jsStatus(strIn) {
	//alert(strIn);
	window.self.status=strIn;
	return true;
}

function showDatePickerFuture(strFormField, myDate, e) {
   myDp = window.open('../include/datepicker.php?future=1&leegKnop=0&field='+strFormField+'&datum='+myDate+'', 'windp', 'toolbar=no,fullscreen=no,location=no,scrollbars=no,resizable=no,menubar=no,status=no,width=315,height=262,top='+(e.screenY-200)+',left='+(e.screenX)+';');
   myDp.focus();
}

function jsShowDownload(strFile) {
   var intWidth = 580;
   var intHeight = 380;
   var intXwin = (toIntDef(parent.screenLeft, 5)-5+((toIntDef(document.body.offsetWidth, 1024)-intWidth)/2));
   var intYwin = ((toIntDef(parent.screenTop, 22)-22)+((toIntDef(parent.document.body.offsetHeight, 728)-intHeight)/2));
   myWindow = window.open("../index/downloadpop.php?file="+strFile.toString(), 'myDLWindow', 'toolbar=no,fullscreen=no,location=no,scrollbars=auto,resizable=yes,menubar=no,status=no,width='+intWidth+',height='+intHeight+',top='+intYwin+',left='+intXwin+';');
   myWindow.focus();
}

function jsOpenOctrooiWindow() {
    REFWindow = window.open("../myImages/octrooi.jpg", "winOctrooi", 'toolbar=no,fullscreen=no,location=no,scrollbars=no,resizable=no,menubar=no,status=no,width=480,height=620,left='+(screen.width-480)/2+',top='+(screen.height-620)/2);
    REFWindow.focus();
}

function jsGoto(choice) {
   if (choice.length>0) {
      if (choice=="contact") {
         document.location = "../index/contact.php";
      } else if (choice=="request") {
         document.location = "../index/inschrijven.php";
      } else if ((choice=="order") || (choice=="examples")) {
         document.location = "../index/bestellen.php";
      } else if (choice=="rekenmodelbasis") {
         parent.frmMain.location = "../rekenmodel/intro.php";
      } else if (choice=="downloads") {
         parent.frmMain.location = "../index/downloads.php";
      }
   } else {
      alert("Error occurred while trying to open the chosen option. \n\nThis option can still be reached when using the menu-options.");
      return;
   }
}

function showMail(strAdress) {
   top.frmMenu.hilite("contact");
   top.frmMenu.setpic("contact");
   document.location = "../index/contact.php?to="+strAdress;
}

function jsValidateField(field_name,field_type){
   var formfield_name = eval("document.FormRef."+field_name);
   if (field_type=="text"){
		if ((formfield_name.value.length)==0) {
			formfield_name.focus();
			return false;
		}else{
		   return true;
		}
   }else if(field_type=="select"){
		if (formfield_name.selectedIndex == 0) {
			formfield_name.focus();
			return false;
		}else{
		   return true;
		}
   }else if(field_type=="email"){
		if ((formfield_name.value.length)>0) {
			apos = formfield_name.value.indexOf('@');
			dotpos = formfield_name.value.lastIndexOf('.');
			lastpos = formfield_name.value.length-1;
			if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2) {
				formfield_name.select();
				return false;
			} else {
			   return true;
			}
		}else{
		   return true;
		}
   }
}

function jsValidateField2(form_name,field_name,field_type){
   var formfield_name = eval("document."+form_name+'.'+field_name);
   if (field_type=="text"){
		if ((formfield_name.value.length)==0) {
			formfield_name.focus();
			return false;
		}else{
		   return true;
		}
   }else if(field_type=="select"){
		if (formfield_name.selectedIndex == 0) {
			formfield_name.focus();
			return false;
		}else{
		   return true;
		}
   }else if(field_type=="email"){
		if ((formfield_name.value.length)>=0) {
			apos = formfield_name.value.indexOf('@');
			dotpos = formfield_name.value.lastIndexOf('.');
			lastpos = formfield_name.value.length-1;
			if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
				formfield_name.select();
				return false;
			} else {
			   return true;
			}
  		}else{
  		   return true;
		}
   }else if(field_type=="picture"){
      var found = 0;
      if ((formfield_name.value.length)>0) {
         var ArrPicture = new Array('jpg','png');

         for (i=0; i<ArrPicture.length; i++){
            if(formfield_name.value.toLowerCase().indexOf(ArrPicture[i]) != -1){
               //extension was found, picturename ok.
               found = 1;
            }
         }
         if (found==1){
            return true;
         }else{
            return false;
         }
		}else{
		   return true;
		}
   }
}

function toIntDef(intIn, intDef) {
   var rw = new Number();
   rw = intIn;
   while ((rw.toString().substr(0, 1)=="0") && (rw.toString().length>1)) {rw = rw.toString().substr(1, rw.toString().length-1);}
   rw = parseInt(rw);
   if ((rw=="") || (isNaN(rw)) || (rw=="undefined")) {rw = intDef;}
   return parseInt(rw);
}

function toStrDef(strIn, strDef) {
   var rw = new String();
   rw = strIn;
   if ((rw==undefined) || (rw=="undefined") || (rw=="")) {rw = strDef;}
   return rw.toString();
}

function toInt(intIn) {
   var rw = new Number();
   rw = parseInt(intIn);
   if ((rw=="") || (isNaN(rw)) || (rw=="undefined")) {rw = 0;}
   return parseInt(rw);
}
//=============================================
// Form colors
function jsChangeColor(el,setColor){
   //setColor ("on", #color)
   if (el) {
      if (el.style) {
         if (setColor=="on"){
            el.style.backgroundColor= "DBE6FF";
         }else{ //off, original state
            el.style.backgroundColor=setColor; //"A5C0D8";
         }
      }
   }
}

//=============================================
// START: Background procedures


//var isIE4;
//if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
//  isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
//}
//
//function getFrameWidth() {
//   var rw = new Number();
//   rw = 922;
//   if (isIE4) {
//      if (self.document) {
//         if (self.document.body) {
//            if (self.document.body.offsetWidth) {
//               rw = toIntDefRichard(self.document.body.offsetWidth, toIntDefRichard(self.document.body.clientWidth, rw));
//            } else if (self.document.body.clientWidth) {
//               rw = toIntDefRichard(self.document.body.clientWidth, rw);
//            }
//         }
//      }
//   }
//   return rw;
//}
//
//function getFrameHeight() {
//   var rw = new Number();
//   rw = 534;
//   if (isIE4) {
//      if (self.document.body) {
//         if (self.document.body) {
//            if (self.document.body.offsetHeight) {
//               rw = toIntDefRichard(self.document.body.offsetHeight, toIntDefRichard(self.document.body.clientHeight, rw));
//            } else if (self.document.body.clientHeight) {
//               rw = toIntDefRichard(self.document.body.clientHeight, rw);
//            }
//         }
//      }
//   }
//   return rw;
//}
//
//var boolResizeRunning = new Boolean();
//var timeoutResizeID;
//boolResizeRunning = false;
//
//function resizeBackground() {
//   if (boolResizeRunning) {clearTimeout(timeoutResizeID);}
//   timeoutResizeID = setTimeout("resizeTimeout();", 250);
//   boolResizeRunning = true;
//}
//
//function resizeTimeout() {
//   boolResizeRunning = false;
//   initBackground();
//}
//
//if (isIE4) {setTimeout("initBackground()", 100);}
//
//function initBackground() {
//   var intWidth = new Number();
//   var intHeight = new Number();
//   intWidth = getFrameWidth();
//   intHeight = getFrameHeight();
//
//   //alert(intWidth);
//   //alert(intHeight);
//   //enkel een background tonen als 't frame groot genoeg is
//   if ((intWidth>=461) && (intHeight>=333)) {
//       //check voor 'cached' backgrounds
//       if ((intWidth==1162) && (intHeight==770)) {
//          setBackground('../images/background/1162_770.gif');
//       } else if ((intWidth==1178) && (intHeight==770)) {
//          setBackground('../images/background/1178_770.gif');
//       } else if ((intWidth==1162) && (intHeight==785)) {
//          setBackground('../images/background/1162_785.gif');
//       } else if ((intWidth==1178) && (intHeight==785)) {
//          setBackground('../images/background/1178_785.gif');
//       } else if ((intWidth==922) && (intHeight==531)) {
//          setBackground('../images/background/922_531.gif');
//       } else if ((intWidth==906) && (intHeight==531)) {
//          setBackground('../images/background/906_531.gif');
//       } else if ((intWidth==922) && (intHeight==534)) {
//          setBackground('../images/background/922_534.gif');
//       } else if ((intWidth==906) && (intHeight==534)) {
//          setBackground('../images/background/906_534.gif');
//       } else if ((intWidth==922) && (intHeight==526)) {
//          setBackground('../images/background/922_526.gif');
//       } else if ((intWidth==906) && (intHeight==526)) {
//          setBackground('../images/background/906_526.gif');
//       } else if ((intWidth==682) && (intHeight==366)) {
//          setBackground('../images/background/682_366.gif');
//       } else if ((intWidth==698) && (intHeight==366)) {
//          setBackground('../images/background/698_366.gif');
//       } else {
//          //geen background in cache, maak er nu een aan
//          setBackground('../images/background/back2.php?height='+intHeight+'&width='+intWidth);
//       }
//       if (self.document) {
//          if (self.document.body) {
//             document.body.onresize = resizeBackground;
//          }
//       }
//   }
//}
//
//function setBackground(strURL) {
//   if (isIE4) {
//      if (self.document) {
//         if (self.document.body) {
//            if (self.document.body.style) {
//               //self.document.body.background = strURL;
//               self.document.body.style.backgroundImage = 'url('+strURL+')';
//            }
//         }
//      }
//   }
//}
//
//function toIntDefRichard(intIn, intDef) {
//   var rw = new Number();
//   rw = parseInt(intIn);
//   if ((rw=="") || (isNaN(rw)) || (rw=="undefined")) {rw = intDef;}
//   return parseInt(rw);
//}

// END: Background procedures
//=============================================


