//var cache	= GetCookie('cache') ? GetCookie('cache') : 'on';
cache	= 'off';

function chCache() {
	status = "cache " + (cache = cache=='on' ? 'off':'on')
	SetCookie('cache' , cache , 5000);
}

// undo Symantech's pop-up blocking javascript
if (typeof SymRealWinOpen == 'object') window.open=SymRealWinOpen

/////////////////////////////////////////////////////////////////////
/// browser vars ////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
function lib_bwcheck() {
	this.ver	= navigator.appVersion;
	this.agent	= navigator.userAgent;
	this.dom	= document.getElementById ? 1:0;
	this.opera5	= this.agent.search(/opera 5/i)>-1;

	this.ie4	= (document.all && !this.dom && !this.opera5) ? 1:0;
	this.ie5	= (this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5) ? 1:0; 
	this.ie6	= (this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5) ? 1:0;
	this.ie		= this.ie4 || this.ie5 || this.ie6;

	this.mac	= this.agent.search(/mac/i)>-1;

	this.fire	= this.agent.search(/firefox/i)>-1;
	this.ns6	= (this.dom && parseInt(this.ver) >= 5) ? 1:0;
	this.ns4	= (document.layers && !this.dom) ? 1:0;
	this.ns		= this.ns4 || this.ns6;

	this.bw		= (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
	return this;
}
bw	= new lib_bwcheck();


function printPage(a) {
	if (self.print && !a)	dw("<a href='javascript: doPrint(); void(0)'>Print deze pagina</a><br /><br />")
	else			dw("<a href='" + a + "'>Print deze pagina</a><br /><br />")
}

function doPrint(a) {
	if (self.focus && self.print)	{self.focus(); self.print()}
	else				alert(a)
}

/////////////////////////////////////////////////////////////////////
/// print swf ///////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
function swf(u, h, w , co , bg , trans) { //url, height, width, cache-off, backgroundcolor
	if (cache == 'off') u += '&cache=' + cache + '&' + new Date().getTime();

	var trans1 = trans2 = "";

	if (trans) {
		trans1 = "<PARAM NAME='wmode' VALUE='transparent'>";
		trans2 = " wmode=transparent ";
	}

	dw("\
		<object id=flObj name=flObj type='application/x-shockwave-flash' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width=" + w + " height=" + h + ">\
		<param name=movie value='" + u + "'>" + trans1 + "<param name=bgcolor value=" + bg + "><PARAM NAME=scale VALUE=noscale><param name=quality value=high><PARAM NAME=menu VALUE=false><PARAM NAME=swliveconnect VALUE=true><PARAM NAME=align VALUE=bottom><PARAM NAME=wwwsalign VALUE=T>\
		<embed swLiveConnect=true NAME=flObj " + trans2 + " bgcolor=" + bg + " ALIGN=bottom wwwsALIGN=T src='" + u + "' menu=false scale=noscale quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=" + w + " height=" + h + "></embed>\
		</object>\
	");
}

function dw(a) {document.write(a)}

function swf2(u, h, w) { //url, height, width
	dw('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="' + w + '" HEIGHT="' + h + '" WALIGN="left">');
	dw('<PARAM NAME=movie VALUE="' + u + '"> <PARAM NAME=quality VALUE=high> <PARAM NAME=scale VALUE=noscale> <PARAM NAME=salign VALUE=LT> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="' + u + '" quality=high scale=noscale salign=LT bgcolor=#FFFFFF  WIDTH="' + w + '" HEIGHT="' + h + '" WALIGN="left"');
	dw('TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>');
	dw('</OBJECT>');
}

function chCache() {
	status = "cache " + (cache = cache=='on' ? 'off':'on')
	SetCookie('cache' , cache , 5000);
}

function openPage(myPids , myLangNR) {
	if (myPids == 100) top.location.href = "/"
	else {
		var t	= "";

		if (!myPids)		{myPids		= pids}
		if (myLangNR == null)	{myLangNR	= langNR}

		myPids	= String(myPids).split(/,| /);

		// if 
		if (!myPids[1] && nav[myPids[0]][1]) myPids[1] = nav[myPids[0]][1].split(/,| /)[0]

		for (var i=0; i<myPids.length; i++) {
			if (nav[myPids[i]]) {
				// remove tabs with ids, then remove non-word chars, then remove leading/trainling underscores
				t += "/" + nav[myPids[i]][0].split(/\|/)[myLangNR].replace(/\t*[\d ]*$/g , '-').replace(/\W+/g , '-').replace(/^-+|-+$/g , '').toLowerCase()
			}
		}

		// if language switch...
		if (myLangNR != langNR) {
			// remove leading+trailing slashes, then remove the 1st two GOTOS
			var temp	= document.location.pathname.replace(/^\/+|\/+$/ , '').replace(/^\w+\/?/ , '').replace(/^\w+\/?/ , '');

			// if anything remains, stick it to the end
			if (temp != '')	t += '/' + temp.replace(/\.html?$/ , '')
		}

		top.location.href = "/" + langs[myLangNR] + t + ".htm"
	}
}

function popUp(u , h , w , t , l) {
	window.open(u , "" , "height=" + h + ",width=" + w + ",left=0,top=0,scrollbars=yes"
	+ (t ? ",toolbar=yes"	:"")
	+ (l ? ",location=yes"	:"")
	);
}

function changeOrder(ta , o , n) {
	var t	= ',' + ta.join(',') + ',';
	t	= t.replace( new RegExp("," + ta[o] + "," , "") , ',');

	if (o>n)	t = t.replace( new RegExp("," + ta[n] + "," , "") , ',' + ta[o] + ',' + ta[n] + ',');
	else		t = t.replace( new RegExp("," + ta[n] + "," , "") , ',' + ta[n] + ',' + ta[o] + ',');

	return t.replace(/^,|,$/g , '').split(',');
}

// ttt = realConfirm('Eh...?' , '139,260,330,415' , 1 , 400 , 120);
// question , buttonlabels , cancelbutton , dialogwidth , dialogheight
function realConfirm(q , b , c , w , h) {
	var retVal		= "";
	var args		= new Array();

	args['question']	= q;
	args['buttons']		= b;
	args['cancel']		= c;

	retVal			= window.showModalDialog("/confirm.htm", args, "dialogWidth: " + w + "px; dialogHeight: " + h + "px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: no; status: No; scroll: auto; unadorned: no");

	if (retVal == null || retVal == undefined || retVal == 0)	return null
	else								return retVal
}

function getPage(lang , loc1 , loc2) {
	loc1	= loc1.replace(/^\W+|\W$/g , '').replace(/\W/g , '-').replace(/--/g , '-').toLowerCase();

	if (loc2) {
		loc2			= loc2.replace(/^\W+|\W$/g , '').replace(/\W/g , '-').replace(/--/g , '-').toLowerCase();
		document.location.href	= "/" + lang + "/" + loc1 + "/" + loc2 + "/";
	}
	else	document.location.href	= "/" + lang + "/" + loc1 + "/"
}

/////////////////////////////////////////////////////////////////////
/// focus één na laatste veld, dan op incorrect veld, dan alert /////
/////////////////////////////////////////////////////////////////////
function formNotGood(e , a) {
	var f = e.form;

	if (f.elements[f.elements.length-1].readOnly)	f.elements[f.elements.length-2].focus()
	else						f.elements[f.elements.length-1].focus()

	alert(a);
	e.focus();
	e.select();

	return false;
}

var onloads	= new Array();
addOnload	= function(a)	{onloads.push(a)}
onload		= function()	{for (var i=0; i<onloads.length; i++) onloads[i]()}

function openPop(url , title , reload) {
	var da	= [url , title , self , document.location.href];
	if	(bw.ie) {
		var r	= window.showModalDialog('/modalDialog.htm' , da , 'font-family:Arial; font-size:10; dialogWidth: 700px; dialogHeight: 500px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: yes; status: No; scroll: yes; unadorned: no')
		if (reload && r)	document.location.href = document.location.href
	}
	else {
		popupPage	= window.open('/modalDialog.htm' , "popupPage", "top=0,left=0,resizable=yes,scrollbars=auto,width=700,height=500");
		popupPage.da	= da;
	}
}

function gmaps(pc , title) {
	var wndw	= null;
	var url		= 'http://maps.google.com/maps?saddr=!!!,%20Nederland&daddr=Herengracht%20582-584,%201017%20CJ,%20Amsterdam';

	if	(!pc)					alert('Vul eerst een postcode in en klik dan op zoek')
	else if (!pc.match(/^\d{4}\s*[a-z]{2}$/i))	alert('Vul een correcte postcode in, bijvoorbeeld \'1234 AB\'')
	else						popUp(url.replace(/!!!/ , pc.replace(/W/g , '').toUpperCase()) , 500 , 900 , title)

//	else						wndw=window.open(url.replace(/!!!/ , pc.replace(/W/g , '').toUpperCase()))
//	if (wndw) wndw.focus()
}



var ModalDialog		= new Object();
ModalDialog.open	= function(vars , func) {
	ModalDialog.vars	= vars;
	ModalDialog.close	= func ? func : null;
	ModalDialog.window	= window.open('/modalDialog2.htm' , 'mdw' , 'width=750,height=550,scrollbars=yes,status=yes,resizable=yes');

	var md			= ModalDialog;
	self.onfocus		= function() {
		try {
			if (md.window && md.window.open && !md.window.closed)	md.window.focus()
			else							self.onfocus = md.window = md.close = null
		} catch(err) {1}
	}
}


/////////////////////////////////////////////////////////////////////
/// einde script ////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
