// Browser Detect Lite  v2.1.4
// http://www.dithered.com/javascript/browser_detect/index.html
// modified by Chris Nott (chris@NOSPAMdithered.com - remove NOSPAM)


function BrowserDetectLite() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser name
   this.isGecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isMozilla   = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   this.isIE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
   this.isSafari    = (ua.indexOf('safari') != - 1);
   this.isOpera     = (ua.indexOf('opera') != -1); 
   this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari); 
   this.isIcab      = (ua.indexOf('icab') != -1); 
   this.isAol       = (ua.indexOf('aol') != -1); 
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isNS && this.isGecko) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isOpera) {
      if (ua.indexOf('opera/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
      }
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isIcab) {
      if (ua.indexOf('icab/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
      }
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin   = (ua.indexOf('win') != -1);
   this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac   = (ua.indexOf('mac') != -1);
   this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetectLite();


/* start windows dimension scripts */
// for an explanation of these functions see http://www.quirksmode.org
// check the screen
function getViewPortHeight()
	{
	var y;
	if (self.innerHeight) // all except Explorer
		{
			y = self.innerHeight;
		}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
		{
			y = document.documentElement.clientHeight;
		}
	else if (document.body) // other Explorers
		{
			y = document.body.clientHeight;
		}
		return y;
	}
function getViewPortWidth()
	{
	var x;
	if (self.innerWidth) // all except Explorer
		{
			x = self.innerWidth;
		}
	else if (document.documentElement && document.documentElement.clientWidth)
		// Explorer 6 Strict Mode
		{
			x = document.documentElement.clientWidth;
		}
	else if (document.body) // other Explorers
		{
			x = document.body.clientWidth;
		}
		return x;
	}
function getScrollOffsetHeight ()
	{
		var y;
		if (self.pageYOffset) // all except Explorer
		{
			y = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
			// Explorer 6 Strict
		{
			y = document.documentElement.scrollTop;
		}
		else if (document.body) // all other Explorers
		{
			y = document.body.scrollTop;
		}
		return y;
	}
function getScrollOffsetWidth ()
	{
		var x;
		if (self.pageXOffset) // all except Explorer
		{
			x = self.pageXOffset;
		}
		else if (document.documentElement && document.documentElement.scrollLeft)
			// Explorer 6 Strict
		{
			x = document.documentElement.scrollLeft;
		}
		else if (document.body) // all other Explorers
		{
			x = document.body.scrollLeft;
		}
		return x;
	}
function getPageHeight ()
	{
		var y;
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight
		if (test1 > test2) // all but Explorer Mac
		{
			y = document.body.scrollHeight;
		}
		else // Explorer Mac;
		     //would also work in Explorer 6 Strict, Mozilla and Safari
		{
			y = document.body.offsetHeight;
		}
		return y;
	}
function getPageWidth ()
	{
		var x;
		var test1 = document.body.scrollWidth;
		var test2 = document.body.offsetWidth
		if (test1 > test2) // all but Explorer Mac
		{
			x = document.body.scrollWidth;
		}
		else // Explorer Mac;
		     //would also work in Explorer 6 Strict, Mozilla and Safari
		{
			x = document.body.offsetWidth;
		}
		return x;
	}
// popup function
function popUpWindow(URL,PWIDTH,PHEIGHT)
	{
		day = new Date();
		id = day.getTime();
		var WWIDTH = self.screen.availWidth;
		var WHEIGHT = self.screen.availHeight;
		var PLEFT = (WWIDTH/2) - (PWIDTH/2);
		var PRIGHT = (WHEIGHT/2) - (PHEIGHT/2);
		var WINFEATURES = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=" + PWIDTH + ",height=" + PHEIGHT + ",left = " + PLEFT + ",top = " + PRIGHT;
		var remote = window.open(URL, id, WINFEATURES);
		if (remote.opener == null)
			{	// if something went wrong
				remote.opener = window;
			}
		remote.opener.name = window.name;
		return remote;
		// eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+PWIDTH+",height="+PHEIGHT+",left = "+PLEFT+",top = "+PRIGHT+"');");
		// left and top should be relative to mouse position
		// like in nicetitle.js, but then with the center on the cursor position
	}

function centerPopUp( url, name, width, height, scrollbars ) { 
 
	if( scrollbars == null ) scrollbars = "0" 
 
	str  = ""; 
	str += "resizable=1,"; 
	str += "scrollbars=" + scrollbars + ","; 
	str += "width=" + width + ","; 
	str += "height=" + height + ","; 
 
	if ( window.screen ) { 
		var ah = screen.availHeight - 30; 
		var aw = screen.availWidth - 10; 
 
		var xc = ( aw - width ) / 2; 
		var yc = ( ah - height ) / 2; 
 
		str += ",left=" + xc + ",screenX=" + xc; 
		str += ",top=" + yc + ",screenY=" + yc; 
	} 
	window.open( url, name, str ); 
} 

// for the updown buttons
// adds udval to the udfield.value in the form with the id udform
// if the field you want is unique you don't need to set udform (leave it false)
function do_up(udform,udfield,udval) {
	if (!udform) {
		object1 = eval('document.getElementById(\'' + udfield + '\')');
	} else {
		object1 = eval('document.getElementById(\'' + udform + '\').' + udfield);
	}
	//alert (object1);
	oldval = Number(object1.value);
	object1.value = oldval+Number(udval);
	return true;
}
// for the updown buttons
// subtracts udval from the udfield.value in form with the id udform
// if the field you want is unique you don't need to set udform (leave it false)
// if the value will be below zero, then don't go further the minimum is 0
function do_down(udform,udfield,udval) {
	if (!udform) {
		object1 = eval('document.getElementById(\'' + udfield + '\')');
	} else {
		object1 = eval('document.getElementById(\'' + udform + '\').' + udfield);
	}
	//alert (object1);
	oldval = Number(object1.value);
	if (oldval >= udval) {
		object1.value = oldval-Number(udval);
	} else {
		object1.value = 0;
	}
	return true;
}

function formSubmit(formName,val) {
	switch (formName){
		case "hide" :
			message="U staat op het punt deze last minute te verbergen.\n\nWilt u doorgaan?";
			obj = eval(document.getElementById('verbergen'));
			break;
		case "show" :
			message="U staat op het punt deze last minute zichtbaar te maken.\n\nWilt u doorgaan?";
			obj = eval(document.getElementById('tonen'));
			break;
		case "delete" :
			message="U staat op het punt deze last minute te verwijderen.\n\nWilt u doorgaan?";
			obj = eval(document.getElementById('verwijderen'));
			break;
	}
	formName = eval (document.getElementById(formName+"form"));
	if (confirm(message)) {
		obj.value = val;
		formName.submit();
	}
}

//email controle
function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
 var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}
