/*************************

 SHOW/HIDE ANYTHING
 
 *************************/
function showMoreAnything(blocknum, isOpen) {
	hid = ('hide' + (blocknum));
	unhid = ('click' + (blocknum));
	if( document.getElementById ) {
		if( document.getElementById(hid).style.display ) {
			if( isOpen != 0 ) {
				document.getElementById(hid).style.display = "block";
				document.getElementById(unhid).style.display = "none";
			} else { 
				document.getElementById(hid).style.display = "none";
				document.getElementById(unhid).style.display = "block"; 
			}
		} else { 
			location.href = isOpen;
			return true;
		}
	} else { 
		location.href = isOpen;
		return true;
	}
}

// BEGIN LINK TARGET FUNCTIONS -----------------------

/*************************

 COOKIE FUNCTIONS
 
 *************************/
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}

/*************************

 LOAD THE CHECKBOX
 
 *************************/
function loadLinkPrefs () {
	// check for cookie, else set it to true
	if (readCookie("gsi_linkprefs_cookie")) {
		// read cookie, and set initial value to that of cookie
		initVal = readCookie("gsi_linkprefs_cookie");
	} else {
		// create a cookie and set it to true
		createCookie("gsi_linkprefs_cookie", true, 20000)
		
		// set initial value without reading newly set cookie
		initVal = false;
	}
	
	// based on values from cookie
	openBlank = initVal;
	setCheckbox(eval(initVal))
}

/*************************

 SET CHECKBOX STATE
 
 *************************/
function setCheckbox(state) {
	// variable
	openBlank = state;

	// checkbox
	document.getElementById('linkprefs').checked = state;
	
	// config targets
	setTargets();
	
	// set cookie based on new state!!!
	createCookie("gsi_linkprefs_cookie", state, 20000)
}

/*************************

 CONFIGURE LINKS
 
 *************************/
function setTargets() {
	var link, l = 0;

	if (openBlank == true) {
		while (link = document.links[l++]) {
			// except those starting with ...
			if (link.href.indexOf('http://www.gsi.be') == -1 && link.href.indexOf('http://www.gsi.be') == -1 && link.href.indexOf('javascript') == -1) link.target = '_blank'; 
		}
	} else {
		while (link = document.links[l++]) {
			// except those starting with ...
			if (link.href.indexOf('http://www.gsi.be') == -1 && link.href.indexOf('http://www.gsi.be') == -1 && link.href.indexOf('javascript') == -1) link.target = '_top'; 
		}
	}
}

// END LINK TARGET FUNCTIONS -----------------------


// statusbar msgs
function displayStatusMsg(msgStr) {
  status=msgStr;
  document.returnValue = true;
}


// ----- BEGIN SHARED DW ASSETS -----

// control flash
function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0
	// add frame
	if (top.location == location) {
		top.location.href='http://www.gsi.be/'
	}
	var obj=MM_findObj(objStr);
	if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?frameNum:'')+')');
}
// end control flash

// popup window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// ----- END SHARED DW ASSETS -----

// antispam email links
function fixm(inp) {
	return inp.replace( "#" , "@" ).replace( "," , "." );
}
function listm(inp) {
	document.write( "<a href='" + "m4ilto:".replace( "4" , "a" ) + fixm( inp ) + "'>" + fixm( inp ) + "</a>" );
}

/* Popup Window */
function popup(url,title,width,height) {
	var features = 'width='+width+',height='+height+',scrollbars=yes';
	window.open(url,title,features);
}
