var currentCss;
var Init;

function getCookie(name) { // use: getCookie("name");
var index = document.cookie.indexOf(name + "=");
if (index == -1) return null;
index = document.cookie.indexOf("=", index) + 1;
var endstr = document.cookie.indexOf(";", index);
if (endstr == -1) endstr = document.cookie.length;
return unescape(document.cookie.substring(index, endstr));
}

var today = new Date();
var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days

function setCookie(name, value) { // use: setCookie("name", value);
if (value != null && value != "")
  document.cookie = name + "=" + escape(value) + "; expires=" + expiry.toGMTString() + "; path=/";
  if(document.cookie.indexOf(name,0)  < 0) {
    alert(MsgCookies);
  }
}


function SetCSS(val){	
//	currentCss = (val + currentCss);
	currentCss = val;

	if(currentCss>3) currentCss=3;
	if(currentCss<1) currentCss=1;
	if(Init!=1) {
                setCookie('CSS',currentCss);
	}
                if(!document.getElementsByTagName) {return;}
	var colCss = document.getElementsByTagName('link');
	for (var i = 0 ; i < colCss.length ; i++ ){
		var LinkCss = colCss[i];
		LinkCss.disabled = true;
	}
	for (var i = 0 ; i < colCss.length ; i++ ){
		var LinkCss = colCss[i];
		if(parseInt(LinkCss.getAttribute("title"))== parseInt(currentCss)) LinkCss.disabled = false;		
	}
                try {
                   document.getElementById("text_size1").style.cursor="hand";
                   document.getElementById("text_size2").style.cursor="hand";
                   document.getElementById("text_size3").style.cursor="hand";
	   if(currentCss==1) document.getElementById("text_size1").style.cursor="arrow";
	   if(currentCss==2) document.getElementById("text_size2").style.cursor="arrow";
	   if(currentCss==3) document.getElementById("text_size3").style.cursor="arrow";
                } 
                catch (e) {}
}


function InitFont() {
                Init=1;
	if(!document.getElementsByTagName) return;
	// retrieve and set current CSS
	if(getCookie('CSS')==null) currentCss = 1;
	else currentCss=parseInt(getCookie('CSS'));
	SetCSS(currentCss);
                Init=0;
}

function openWindow (URL) {
      newWindow = window.open (URL, "winTag", "toolbar=no, directories=no, menubar=no, scrollbars=yes, resizable=no, width=500, height=480");
}

function openWindowPrint (URL) {
      newWindow = window.open (URL, "winTag", "toolbar=no, directories=no, menubar=no, scrollbars=yes, status=no, resizable=no, width=750, height=700");
}

function openGlossary(URL) {
      if(URL == "null#null") return;
      newWindow = window.open (URL, "Glossary", "toolbar=no, directories=no, menubar=no, scrollbars=yes, status=no, resizable=no, width=750, height=700");
}

function openImage(URL) {
      newWindow = window.open (URL, "Image", "toolbar=no, directories=no, menubar=no, scrollbars=yes, status=no, resizable=yes, width=550, height=400");
}

InitFont();

