/****************************************************************************   
*   BrowserCheck function
*   Copyright (C) 2004 Trèfic Net
***************************************************************************/
function checkBrowser() {
    this.agt = navigator.userAgent.toLowerCase()  
    this.major = parseInt(navigator.appVersion) 
    this.minor = parseFloat(navigator.appVersion) 
    this.ns  = ((this.agt.indexOf('mozilla')!=-1) && (this.agt.indexOf('spoofer')==-1) && (this.agt.indexOf('compatible') == -1) && (this.agt.indexOf('opera')==-1) && (this.agt.indexOf('webtv')==-1) && (this.agt.indexOf('hotjava')==-1)) 
    this.ns2 = (this.ns && (this.major == 2)) 
    this.ns3 = (this.ns && (this.major == 3)) 
    this.ns4 = (this.ns && (this.major == 4)) 
    this.ns4up = (this.ns && (this.major >= 4)) 
    this.nsonly = (this.ns && ((this.agt.indexOf(";nav") != -1) || (this.agt.indexOf("; nav") != -1)) ) 
    this.ns6 = (this.ns && (this.major == 5)) 
    this.ns6up = (this.ns && (this.major >= 5)) 
    this.gecko = (this.agt.indexOf('gecko') != -1) 
    this.ie     = ((this.agt.indexOf("msie") != -1) && (this.agt.indexOf("opera") == -1)) 
    this.ie3    = (this.ie && (this.major < 4)) 
    this.ie4    = (this.ie && (this.major == 4) && (this.agt.indexOf("msie 5")==-1) && (this.agt.indexOf("msie 6")==-1)) 
    this.ie4up  = (this.ie && (this.major >= 4)) 
    this.ie5    = (this.ie && (this.major == 4) && (this.agt.indexOf("msie 5.0")!=-1) ) 
    this.ie5_5  = (this.ie && (this.major == 4) && (this.agt.indexOf("msie 5.5") !=-1)) 
    this.ie5up  = (this.ie && !this.ie3 && !this.ie4) 
    this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5)     
    this.ie6    = (this.ie && (this.major == 4) && (this.agt.indexOf("msie 6.0")!=-1) ) 
    this.opera = (this.agt.indexOf("opera") != -1) 
    this.opera2 = (this.agt.indexOf("opera 2") != -1 || this.agt.indexOf("opera/2") != -1) 
    this.opera3 = (this.agt.indexOf("opera 3") != -1 || this.agt.indexOf("opera/3") != -1) 
    this.opera4 = (this.agt.indexOf("opera 4") != -1 || this.agt.indexOf("opera/4") != -1) 
    this.opera5 = (this.agt.indexOf("opera 5") != -1 || this.agt.indexOf("opera/5") != -1) 
    this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4)   
	//
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.mac=this.agent.indexOf("Mac")>-1
	//
	this.site = (this.ie4up || this.ns6up || this.opera5up)
	this.responsor = (this.ie4up || this.ns6up || this.opera5up)
	return this
}
bw=new checkBrowser() //BrowserCheck object

/****************************************************************************   
*   Operating System check
***************************************************************************/

function checkOS() {
	var OpSys;
	if (navigator.userAgent.indexOf('IRIX') != -1) OpSys = 'Irix';
	else if (navigator.userAgent.indexOf('Win') != -1) OpSys = 'Windows';
	else if (navigator.appVersion.indexOf('SunOS') != -1) OpSys = 'SunOS';
	else if (navigator.appVersion.indexOf('Linux') != -1) OpSys = 'Linux';
	else if (navigator.userAgent.indexOf('Mac') != -1) OpSys = 'Macintosh';
	else if (navigator.appName=='WebTV Internet Terminal') OpSys='WebTV';
	else if (navigator.appVersion.indexOf('HP') != -1) OpSys='HP-UX';
	else OpSys = 'other';
	return OpSys;
}

/****************************************************************************   
*   Cookie functions
***************************************************************************/
function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(name, defval) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) {
			break; 
		}
	}
	return defval;
}

function setCookie(name, value) {
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}

/****************************************************************************   
*   voorbeeld
*
*	var expdate = new Date();
*	expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
*	setCookie("visit", visit, expdate, "/", null, false);
***************************************************************************/

/****************************************************************************   
*   Popup checks
***************************************************************************/
function checkPopup() {
	var popupok=false;

	// open popup-window
	win = window.open('','w','scrollbars=no, width=200, height=200');

	// initieer check-variabele
	document.testwin = 0;

	// schrijf check-variabele in popupwindow
	if (win) {
		win.document.open();
		win.document.write('<html><head><scr'+'ipt>opener.document.testwin=1;</scr'+'ipt></head></html>');
		win.document.close();
		win.close();
	}

	// check check-variabele
	if (document.testwin==1) popupok=true;
	
	return popupok;
}

/****************************************************************************   
*   Cookie Check
***************************************************************************/
function checkCookie() {
	var cookieok=false;

	//first, calculate an expiration for your temporary test cookie
	var oneDay= 1*24*60*60*1000;
	var expDate = new Date();
	expDate.setTime(expDate.getTime() + oneDay);
	var cookieExpires = expDate.toGMTString();

	//set your temprorary cookie
	document.cookie="verifyCookie=test; expires="+cookieExpires

	//check to see if ANY cookies exist, including the one you just set
	if (document.cookie.length>0) cookieok=true;

	//now clear out the unwanted stuff
	document.cookie="verifyCookie=CLEAR; expires=Sun, 09-Nov-97 01:00:00 GMT";
	
	return cookieok;
}
