<!--
// name of the cookie
var cookiename;

// all variables passed in the cookie.
var mysettings;	      
var screensize;	      
var language;	                 
var startpage;	

// new selections to store in the cookie
var newsize;
var newlanguage;
var newpage;
var currentpage;

var popupwindow; 

// The array, containing all variables in the cookie string.                 
cookieArray=new Array;
cookieArray[0] = language;	                 
cookieArray[1] = screensize;	      
cookieArray[2] = startpage;	                 


// Funtion to read the cookie and is executed by LoadcookieData.
// Parameter is required when calling the function.
// This function returns the variable(s) as a string.
function readcookie(cookiename) {
    if (document.cookie.length > 0) {              
    	begin = document.cookie.indexOf(cookiename+"=");       
    	if (begin != -1) {           
      	begin += cookiename.length+1;       
      	end = document.cookie.indexOf(";", begin);
      	if (end == -1) end = document.cookie.length;
        	return unescape(document.cookie.substring(begin, end));
    	} 
  	}
}

// Funtion to write the cookie. 
// All 3 parameters are required when calling the function.
function writecookie(cookiename, mysettings, expiredays) {
	var mysettings = language +"&"+ screensize +"&"+ startpage;
	var ExpireDate = new Date();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = cookiename + "=" + escape(mysettings) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}


// this code reads the content of the cookie and fills the array
function LoadcookieData(cookiename) {
	cookiecontent=readcookie(cookiename);
	if (cookiecontent!=null) {
		var cookieArray=cookiecontent.split("&");
		language = cookieArray[0];
		screensize = cookieArray[1];
		startpage = "page.php?page=div-nieuw";			// cookieArray[2]; reset to this value
		writecookie(cookiename,mysettings,100);
	}
	else {
		language = newlanguage;
		screensize = "normal";
		startpage = "page.php?page=div-nieuw";
	}
}


// Funtion to delete the cookie. 
// Parameter is required when calling the function.
function deletecookie(cookiename) {
  if (readcookie(cookiename)) {
    document.cookie = cookiename + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}


// this function is used for debugging purposes only.
function debug(cookiename) {
	LoadcookieData(cookiename);
	alert ("Settings:\n\nStartpage = "+startpage+"\nWindowtype = "+screensize+"\nLanguage = "+language);
}

// this function sets the preferred language version.
function languageversion(cookiename, newlanguage) {
	LoadcookieData(cookiename);
	language = newlanguage;
	writecookie(cookiename,mysettings,100);
}

// this function sets the preferred window type.
function windowtype(cookiename, newsize) {
	LoadcookieData(cookiename);
	screensize = newsize;
	writecookie(cookiename,mysettings,100);
}

// this function sets the current page as the preferred starting page.
function setstartpage(cookiename) {
	LoadcookieData(cookiename);
	if (currentpage == "download") {
		startpage = "../downloads/TreeDownloads.php";
	}
	else {
		startpage = parent.mainFrame.document.location.href;
	}
	writecookie(cookiename,mysettings,100);
	alert ("Settings:\n\nStartpage = "+startpage+"\nWindowtype = "+screensize+"\nLanguage = "+language);
}

// this function detects the URL value of the current page in the mainFrame
function getpagefromUrl() {
	fullurl = parent.mainFrame.document.location.href; 
	newpage =(fullurl.substring(fullurl.lastIndexOf("\\")+1)); // for windows
	newpage =(fullurl.substring(fullurl.lastIndexOf("\/")+1)); // for unix
}

// this function is used to open a new browser window (java style) for the lexicon.
function lexiconwindow(mark) { 
	href = 'lexikon.php#' + mark; 
	popupwindow = window.open(href, 'popup','scrollbars=yes,width=450,height=200'); 
	popupwindow.focus(); 
	return false; 
}; 

// this function is used to open a new browser window (java style) for the overview tables.
function overzichtwindow(mark) { 
	href = 'tbl-overzicht.htm#' + mark; 
	popupwindow = window.open(href, 'popup','scrollbars=yes,width=550,height=240'); 
	popupwindow.focus(); 
	return false; 
}; 

// this function is used to open a new browser window (java style).
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// this function is used link to a new page (java style).
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

// this function is part of the hover image function set
// here the hover images are loaded
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// this function is part of the hover image function set
// here the default image is restored
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// this function is part of the hover image function set
// here the default image is swapped
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// this function is part of the hover image function set
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;
}

// this function is used to load the main page in a new window.
// the layout of the new window fits an A4 when sending it to a printer.
function OpenPrintLayout(pageName,winName,features) { //v2.0
	var url = parent.mainFrame.document.location.href; 
	var DocName =(url.substring(url.lastIndexOf("\=")+1));
	var pageName = ("page-prn?page="+DocName);
	window.open(pageName,winName,features);
}

// this function will load the frameset in a standard browser style window.
function bigscreen(startpage) {
	document.write('<html>');
	document.write('<head>');
	document.write('<title>Duwgati Satinfo - www.duwgati.com</title>');
	document.write('<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">  ');
	document.write('</head>');
	document.write('<frameset rows="110,*" border=0 frameborder=0 cols="*">'); 
	document.write('<frame name="topFrame" src="topframe.php" scrolling="no">');
	document.write('<frame name="mainFrame" src="'+startpage+'">');
	document.write('</frameset>');
	document.write('<noframes>');
	document.write('</noframes>');
	document.write('<body>');  
	document.write('</body>');
	document.write('</html>');
}

// this function will load the frameset in a java style window.
function smallscreen(startpage) {
	javawindow = window.open('','newwindow','scrollbars=yes,resizable=yes');
	javawindow.document.write('<html>');
	javawindow.document.write('<head>');
	javawindow.document.write('<title>Duwgati Satinfo - www.duwgati.com</title>');
	javawindow.document.write('<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">  ');
	javawindow.document.write('</head>');
	javawindow.document.write('<frameset rows="110,*" border=0 frameborder=0 cols="*">'); 
	javawindow.document.write('<frame name="topFrame" src="topframe.php" scrolling="no">');
	javawindow.document.write('<frame name="mainFrame" src="'+startpage+'">');
	javawindow.document.write('</frameset>');
	javawindow.document.write('<noframes>');
	javawindow.document.write('</noframes>');
	javawindow.document.write('<body>');  
	javawindow.document.write('</body>');
	javawindow.document.write('</html>');
}

// this function will read the cookie and load the preferred window type.
function init(cookiename) {
	LoadcookieData(cookiename);
	if (startpage == null) {
		startpage = "page.php?page=div-nieuw";
	}
	if (screensize == "java") {
		smallscreen(startpage);
	}
	else {
		bigscreen(startpage);
	}
}


