// set values attributes zoom tool
function SetAttributesValuesZoom(){
	if(!document.getElementById("tools_zoom"))return false;
	var d = document.getElementById("tools_zoom").getElementsByTagName("a");	
	for( var i=0; i < d.length; i++){	 	 
			if (csearch('loadclass'))
			{ 
			var classvalues = unescape(readCookie("loadclass"));
			var classvalue = classvalues.split(";");	
			d[0].className = classvalue[0];
			d[1].className = classvalue[1];
			d[0].setAttribute("title",classvalue[2]);
			d[1].setAttribute("title",classvalue[3]);
			if (d[1].className != "kleiner_disabled")
			d[1].setAttribute("href","#");
			if (d[0].className == "groter_disabled")
			d[0].removeAttribute("href");	 
			}
			else
			{ 
			d[0].setAttribute("title","groter");
			//d[1].setAttribute("title","kleiner");
			d[0].className = "groter";	
			d[1].className = "kleiner_disabled";	
			d[1].removeAttribute("href");
			//cookievars = d[0].className + ";" + d[1].className + ";" + "groter" + ";" + "kleiner";			
			//createCookie("loadclass", escape(cookievars) , 365);	
			//var classvalues = unescape(readCookie("loadclass"));			
			//var classvalue = classvalues.split(";");
			//alert(classvalue[0]);
			//d[0].className = classvalue[0];
			//d[1].className = classvalue[1];			
			}					
	}
} 
function GetLink()	{
	if(!document.getElementById("tools_zoom"))return false;
	var d = document.getElementById("tools_zoom").getElementsByTagName("a");
	for( var i=0; i < d.length; i++){	 	
		d[i].title = d[i].getAttribute("title");
		//d[i].currentclass = d[i].className;
		d[i].onclick = function(){
		//alert(this.title);
			if(this.title == "groter")
			{
			//alert(this.title);
			setActiveStyleSheet(this.title);
			this.setAttribute('title','grootst');
			d[1].setAttribute('href','#');
			d[1].setAttribute('title','kleinst');
			d[1].className = 'kleiner';
			cookievars = 'groter' + ";" + d[1].className + ";" + "grootst" + ";" + "kleinst" ;
			createCookie("loadclass", escape(cookievars) , 365);
			//ook de title attributen en href attributen in cookie zetten
			//bij refresh zijn die namelijk ook lege waarden
			return false;
			}
			if(this.title == "grootst")
			{
			setActiveStyleSheet(this.title);
			this.removeAttribute('href');
			this.className = 'groter_disabled';
			d[1].setAttribute('href','#');
			d[1].setAttribute('title','kleiner');
			d[1].className = 'kleiner';
			cookievars = this.className + ";" + d[1].className + ";" + this.title + ";" + "kleiner";
			createCookie("loadclass", escape(cookievars) , 365); 
			return false;
			}
			if(this.title == "kleiner")
			{
			setActiveStyleSheet('groter');
			this.setAttribute('title','kleinst');
			d[0].setAttribute('href','#');
			d[0].setAttribute('title','grootst');
			d[0].className = 'groter';
			cookievars = d[0].className + ";" + 'kleiner' + ";" + "grootst" + ";" + "kleinst";
			createCookie("loadclass", escape(cookievars) , 365);
			return false;
			}
			if(this.title == "kleinst")
			{ 
			setActiveStyleSheet('normaal');
			d[0].setAttribute('title','groter');
			this.removeAttribute('href');
			d[1].className = 'kleiner_disabled';
			cookievars = 'groter' + ";" + d[1].className  + ";" + "groter" + ";" + this.title ;
			createCookie("loadclass", escape(cookievars) , 365); 
			return false;
			}
		};
	}
} 
function setActiveStyleSheet(title) {
	//alert(title);
  	var i, a, main;
  	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
   		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      	a.disabled = true;
      	if(a.getAttribute("title") == title) a.disabled = false;
    	}
  	}
} 
function getActiveStyleSheet() {
  	var i, a;
  	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    	if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return 				a.getAttribute("title"); 
  	}
  return null;
} 
function getPreferredStyleSheet() {
  	var i, a;
  	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    	if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  	}
  return null;
} 
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 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;
}
//checks if cookie exists
function csearch(naam) { 
  var str = document.cookie; 
  var zstr = naam + "="; 
  var start = str.indexOf(zstr, 0); 
  if(start == -1) { 
    return false; 
  } else { 
    start += zstr.length; 
    var eind = str.indexOf(";", start); 
    if(eind == -1) eind = str.length; 
	return unescape(str.substring(start, eind)); 
  } 
}  
window.onunload = function(e) {
  	var title = getActiveStyleSheet();
  	createCookie("style", title, 365); 
} 
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
//setActiveStyleSheet(title); 

