/*********************************************/ 
/* JavaScript INIT - FUNCTIONS              */
/*********************************************/
DOM = (document.getElementById) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
Konqueror = (navigator.userAgent.indexOf('Konqueror') > -1) ? 1 : 0;
Konqueror22 = (navigator.userAgent.indexOf('Konqueror 2.2') > -1 || navigator.userAgent.indexOf('Konqueror/2.2') > -1) ? 1 : 0;
Konqueror30 =
	(
		navigator.userAgent.indexOf('Konqueror 3.0') > -1
		|| navigator.userAgent.indexOf('Konqueror/3.0') > -1
		|| navigator.userAgent.indexOf('Konqueror 3;') > -1
		|| navigator.userAgent.indexOf('Konqueror/3;') > -1
		|| navigator.userAgent.indexOf('Konqueror 3)') > -1
		|| navigator.userAgent.indexOf('Konqueror/3)') > -1
	)
	? 1 : 0;
Konqueror31 = (navigator.userAgent.indexOf('Konqueror 3.1') > -1 || navigator.userAgent.indexOf('Konqueror/3.1') > -1) ? 1 : 0;
Konqueror32 = (navigator.userAgent.indexOf('Konqueror 3.2') > -1 || navigator.userAgent.indexOf('Konqueror/3.2') > -1) ? 1 : 0;
Konqueror33 = (navigator.userAgent.indexOf('Konqueror 3.3') > -1 || navigator.userAgent.indexOf('Konqueror/3.3') > -1) ? 1 : 0;
Opera = (navigator.userAgent.indexOf('Opera') > -1) ? 1 : 0;
Opera5 = (navigator.userAgent.indexOf('Opera 5') > -1 || navigator.userAgent.indexOf('Opera/5') > -1) ? 1 : 0;
Opera6 = (navigator.userAgent.indexOf('Opera 6') > -1 || navigator.userAgent.indexOf('Opera/6') > -1) ? 1 : 0;
Opera56 = Opera5 || Opera6;
IE = (navigator.userAgent.indexOf('MSIE') > -1) ? 1 : 0;
IE = IE && !Opera;
IE5 = IE && DOM;
IE4 = (document.all) ? 1 : 0;
IE4 = IE4 && IE && !DOM;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

/*********************************************/ 
/* JavaScript POPUP - FUNCTIONS              */
/*********************************************/
function popup(targetURL,scrWidth,scrHeight,dummy) {
var oTop = (screen.height/2)-(scrHeight/2);
var oLeft = (screen.width/2)-(scrWidth/2);

	if (dummy == 1) {
		paramStr = "scrollbars=no,width="+ scrWidth +",height="+ scrHeight +",toolbar=no,resizable=no,top=0,left=0";
		window.open(targetURL,'popupWin',paramStr);
	} else if (dummy == 2) {
		paramStr = "scrollbars=yes,width="+ scrWidth +",height="+ scrHeight +",toolbar=no,resizable=yes,top="+ oTop +",left="+ oLeft;
		window.open(targetURL,'popupWin',paramStr);
	} else {
		paramStr = "scrollbars=yes,width="+ scrWidth +",height="+ scrHeight +",toolbar=no,resizable=no,top=0,left=0";
		window.open(targetURL,'popupWin',paramStr);
	}
}

/*********************************************/ 
/* JavaScript DEBUGGING - FUNCTIONS          */
/*********************************************/
function debugObj(obj,name)	{
var acc;
var num=0;
	for (i in obj) {
		if (obj[i])	{
			acc+=num +". "+ i +":  "+obj[i]+"\n";
			num++;
		}
	}			  
	alert("Object: "+name+"\n\n"+acc);
}
/*********************************************/ 
/* JavaScript STYLE - FUNCTIONS              */
/*********************************************/
function setActiveStyleSheet(title, reset) {
  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;
    }
  }
  if (reset == 1) {
  createCookie("wstyle", title, 365);
  }
}

function setStyle() {
var style = readCookie("wstyle");
if (style != null) {
setActiveStyleSheet(style, 0);
}
}

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;
}

if (window.addEventListener) window.addEventListener("load",setStyle,false);
else if (window.attachEvent) window.attachEvent("onload",setStyle);
