// ==================================================
// global vars
// ==================================================

var DBW, DBH;					// document afmetingen
var bbmx, bbmy; 				// global mousepos vars voor oa. Help Mouseover
var mmevent 	= 0;			// pas als mmevent op 1 staat zullen de mouse-coords worden uitgelezen

// browser shit

var is_mac		= navigator.platform.indexOf("Mac") != -1;
var is_win		= navigator.platform=="Win32";
var is_safari 	= navigator.userAgent.indexOf("Safari") != -1;
var is_opera 	= navigator.userAgent.indexOf("Opera") > -1;
var is_ie 		= navigator.userAgent.indexOf("MSIE") > 1 && !is_opera; //(navigator.userAgent.indexOf ("IE") != -1);
var is_mozilla	= navigator.userAgent.indexOf("Mozilla/5.") == 0 && !is_opera;
var is_gecko 	= /gecko/i.test(navigator.userAgent);

// ==================================================
// Function: Init Page na onload
// ==================================================

function getEl(el) {
	if (document.getElementById)	return document.getElementById(el);
	if (document.all)				return document.all[el];
	return false;
}

// ==================================================

function ctime() {
	t 	= new Date();
	t2 	= t.getYear().toString()
		+ t.getMonth().toString()
		+ t.getDate().toString()
		+ t.getHours().toString()
		+ t.getMinutes().toString()
		+ t.getSeconds().toString();
	return t2;
}

function go(url) {
	location.href = check_url(url);
}

function ngo(url) {
	window.open(check_url(url));
}

function mail(adr) {
	location.href = "mailto:" + adr;
}

function openmedia(tiepe, pw, ph, file) {
	mx		= (screen.availWidth - pw) / 2;
	my		= (screen.availHeight - ph) / 2;
	popobj 	= window.open('', 'win', 'scrollbars=auto, resizable=1, fullscreen=0, menubar=0, status=0, statusbar=0, left='+mx+', top='+my+', width='+pw+', height='+ph);
	popobj.location.href = 'playmedia.php?w='+pw+'&h='+ph+'&type='+tiepe+'&file='+file;
	//popobj.resizeTo(pw + 0, ph + 0);
	popobj.focus();
	return true;
}

function check_url(url) {

	if (url.substr(0,7).toLowerCase() != "http://") {
		if (url.substr(0,3).toLowerCase() == "www") url = "http://" + url;
	}

	return url;
}

// ==================================================

function popwin(myurl) {
	pw	= 385;
	ph	= 530;
	mx	= window.top.imgx ? window.top.imgx : (screen.availWidth - pw) / 3;
	my	= window.top.imgy ? window.top.imgy : (screen.availHeight - ph) / 3;
	popobj = window.open(myurl, 'winimg', 'scrollbars=1, resizable=1, fullscreen=0, menubar=0, status=0, statusbar=0, left='+mx+', top='+my+', width='+pw+', height='+ph);
	popobj.focus();
	popobj.resizeTo(pw,ph);
}

function popgo(myurl) {
	window.top.opener.focus();
	window.top.opener.location.href = myurl;
	window.focus();
}

function popgoscroll(mywin, myurl, pw, ph, mayscroll) {
	if (is_ie) { pw += 32; ph += 64; }
	if (is_safari) { pw += 0; ph += 22; mywin += Math.random().toString() }
	mx = (screen.availWidth - pw) / 2;
	my = (screen.availHeight - ph) / 2;
	popobj 	= window.open('', mywin, 'scrollbars='+mayscroll+', resizable=1, fullscreen=0, menubar=0, status=0, statusbar=0, left='+mx+', top='+my+', width='+pw+', height='+ph);
	popobj.location.href = myurl;
	popobj.resizeTo(pw + 0, ph + 0);
	popobj.focus();
	return 1;
}

// ==================================================

function hover(obj, flg) {
	if (flg) {
		getEl(obj).style.textDecoration = 'none';
	} else {
		getEl(obj).style.textDecoration = 'underline';
	}
}

// ================================================
//	Help functies 8 mei 2002
// ================================================

function getmouseXY() {
	bbmx	= window.event.clientX + document.body.scrollLeft;
	bbmy	= window.event.clientY + document.body.scrollTop;
}

// ==================================================
// Window resizer: heeft begx, begy, endx, endy nodig
// ==================================================

function winresize() {
	iray = 1 - rray[rtel];
	curw = begw * iray + finw * rray[rtel];
	curh = begh * iray + finh * rray[rtel];
	window.resizeTo(Math.floor(curw), Math.floor(curh));
	rtel++;
	if (rtel >= rray.length) clearInterval(rzid);
}

function getyoff() {
	if (is_safari) return window.pageYOffset;
	if (is_ie || is_mozilla) return document.body.scrollTop;
}

function setyoff(yoff) {
	if (is_safari) window.pageYOffset = yoff;
	if (is_ie || is_mozilla) document.body.scrollTop = yoff;
}

// ==================================================

function setDocsize() {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		DBW = window.innerWidth;
		DBH = window.innerHeight;

		if (DBW == 0 || DBH == 0) {
			try {
				DBW = top.innerWidth;
				DBH = top.innerHeight;
			} catch(e) {
			}
		}

	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		DBW = document.documentElement.clientWidth;
		DBH = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		DBW = document.body.clientWidth;
		DBH = document.body.clientHeight;
	}

	//alert(DBW + ' x ' + DBH);
}

// retourneer absolute top en left corner van relatief object
// handig voor positioneren absolute layers bij bijv. een input-object of span
function obj_curtop(obj) {
	actb_toreturn = 0;
	while(obj){
		actb_toreturn += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return actb_toreturn;
}

function obj_curleft(obj) {
	actb_toreturn = 0;
	while(obj){
		actb_toreturn += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return actb_toreturn;
}


function objHover(objSrc, mode) {
	objSrc.style.color = mode ? '#888' : '#000';
	objSrc.style.backgroundColor = mode ? '#fff' : 'transparent';
}
