var config_hdir = "/";
var tmpl_name = "";
var lang = "de";
var logged_in = false;
var uploadwin = null;
var loc = new Object();



/* SCRIPT funcs.js */

loc['upgrade_browser'] = unescape("Du%20benutzt%20einen%20alten%20Browser.%20Wir%20empfehlen%20dir%20eine%20neuere%20Version%20herunterzuladen%2C%20dann%20kannst%20du%20diese%20Seite%20im%20vollen%20Umfang%20nutzen.");
loc['upload'] = unescape("hochladen");
loc['close'] = unescape("Schlie%DFen");

var Ajax = {
 Request: function(method, url, async, post_str, handlers) {
  if (window.XMLHttpRequest) {
   var ajax_handler = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
   var ajax_handler = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
   alert(loc["upgrade_browser"]);
   return false;
  }
  
  if(handlers != undefined && async) {
   ajax_handler.onreadystatechange = function() {
    if(ajax_handler.readyState == 4) {
     if((Response = cleanJSON(ajax_handler.responseText)) !== false) {
      Response = eval('(' + Response + ')');
      if(Response.status == "ok") {
       handlers.onSuccess(Response);
      } else {
       handlers.onError(Response);
      }
     } else {
      handlers.onError(Response);
     }
    }
   }
  }

  ajax_handler.open(method, config_hdir + url, async);
  if(method == "POST") ajax_handler.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ajax_handler.send(post_str == undefined ? null : post_str);
  
  if(handlers != undefined && !async) {
   if((Response = cleanJSON(ajax_handler.responseText)) !== false) {
    Response = eval('(' + Response + ')');
    if(Response.status == "ok") {
     handlers.onSuccess(Response);
    } else {
     handlers.onError(Response);
    }
   }
  }
  
  return true;  
 }
}

String.prototype.BBdecode = function() {
 if((BBdec = CRO()) !== false) {
  BBdec.open("POST", config_hdir + "SmallAJAX.html", false);
  BBdec.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  BBdec.send("func=BBdecode" + unescape("%26") + "string=" + escape(this).replace(new RegExp("\\+", "g"), "%2B"));
  if(BBdec.readyState == 4) {
   if((BB = cleanJSON(BBdec.responseText)) !== false) {
    BB = eval('(' + BB + ')');
    if(BB.status == "ok") {
     return unescape(BB.response);
    } else {
     talk(unescape(BB.error));
     return false;
    }
   }
  }
 } else {
  return false;
 }
}


/* THANKS TO PROTOTYPE.JS */

if(!window.Element) var Element = new Object();

function $(element) {
 return document.getElementById(element);
}

Element.Methods = {
 remove: function(element) {
  element = $(element);
  element.parentNode.removeChild(element);
  return element;
 },

 deleteNextSiblings: function(object) {
  while(object.nextSibling) {
   object.parentNode.removeChild(object.nextSibling);
  }
 },
 
 insertAfter: function(object) {
  object.parentNode.appendChild(object);
 }
};


function CRO() {
 if (window.XMLHttpRequest) {
  return new XMLHttpRequest();
 } else if (window.ActiveXObject) {
  return new ActiveXObject("Microsoft.XMLHTTP");
 } else {
  alert("Du benutzt einen alten Browser. Wir empfehlen dir eine neuere Version herunterzuladen, dann kannst du diese Seite im vollen Umfang nutzen.");
  return false;
 }
}

this.buildSelect = function(opts, sel) {
 var select = document.createElement("SELECT");
 for(a = 0 ; a < opts.length ; a++) {
  select.options[a] = new Option(unescape(opts[a][1]), unescape(opts[a][0]), ((sel != undefined && sel == opts[a][0]) ? true : false), ((sel != undefined && sel == opts[a][0]) ? true : false));
 }
 
 return select;
}

function expandDiv(send_object, object, height, time, pixels) {
 act_height = parseInt(document.getElementById(object).style.height.substr(0, document.getElementById(object).style.height.length-2));
 if(act_height < height) {
  document.getElementById(object).style.height =  String(act_height + pixels) + "px";
  expand = setTimeout(function() { expandDiv(send_object, object, height, time, pixels); }, time);
 } else {
  document.getElementById(object).style.overflow = "auto";
  if(send_object.onmouseover != "") {
   send_object.onmouseover = "";
  }
 }
}
 
function collapseDiv(object, time) {
 act_height = parseInt(document.getElementById(object).style.height.substr(0, document.getElementById(object).style.height.length-2));
 if(expand > 0) {
  clearTimeout(expand);
 }
 if(act_height > 0) {
  document.getElementById(object).style.height = String(act_height - 1) + "px"
  setTimeout(function() { collapseDiv(object, time); }, time);
 }
}

this.talk = function(str) {
 alert(str);
}

this.cryptMail = function(mail, decrypt) {
 var nmail = "";
 
 for(m = 0 ; m < mail.length ; m++) {
  if(decrypt) {
   nmail += String.fromCharCode(mail.charCodeAt(m) + 1);
  } else {
  
  }
 }
 
 location.href = 'mailto:' + nmail;
}

function chkWin(win, id, mode) {
 if(eval(win + ".closed") == true) {
  if(mode == undefined) {
   getFiles(id);
  } else {
   eval(mode + ".getFiles(" + id + ");");
  }
 } else {
  setTimeout(function() { chkWin(win, id, mode); }, 1000);
 }
}

this.openUploadWindow = function(address, id, mode) {
 uploadwin = window.open(address, loc["upload"], 'height=500,width=500');
 setTimeout(function() { chkWin('uploadwin', id, mode); }, 1000);
}

this.showMovie = function(movie, mheight, mwidth) {
 var FPV = getFPV();
 if(FPV[0] >= 9) {
  if(FPV[0] > 9 || FPV[2] >= 115) {
   var mov_ext = "mov";
  } else {
   var mov_ext = "flv";
  }
 } else {
  var mov_ext = "flv";
 }
 
 var emb = document.createElement("EMBED");
 emb.setAttribute("type", "application/x-shockwave-flash");
 emb.setAttribute("src", config_hdir + "configs/flvplayer.swf");
 emb.setAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
 emb.setAttribute("flashvars", "file=" + config_hdir + "uploads/videos/" + movie + "." + mov_ext + unescape("%26") + "image=" + config_hdir + "uploads/videos/" + movie + "_b.png");
 emb.setAttribute("allowfullscreen", "true");
 emb.setAttribute("width", mwidth);
 emb.setAttribute("height", mheight);
 
 deleteAllChildNodes(document.getElementById("mov_cont"));
 document.getElementById("mov_cont").appendChild(emb);
}

this.showhideElement = function(elem, vis) {
 document.getElementById(elem).style.display = ((document.getElementById(elem).style.display == "" || document.getElementById(elem).style.display != vis) ? vis : "none");
}

this.GetLocales = function(name) {
 GLreq = CRO();
 if(GLreq) {
  GLreq.open("POST", "/SmallAJAX.html", false);
  GLreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  GLreq.send("func=GetLocales&name=" + name);
  if(GLreq.status == 200) {
   if((GL = cleanJSON(GLreq.responseText)) !== false) {
    GL = eval('(' + GL + ')');
    if(GL.status == "ok") {
     return unescape(GL.response);
    }
   }
  }
 }
 
 return true;
}
 
function InsertLocales(name, obj, chars_after) {
 GetLocales(name, function(req_obj) {
  obj.innerHTML = unescape(req_obj.responseText) + chars_after;
 });
}
 
function changeOpacity(element, act_opacity, max_opacity) {
 if(act_opacity != max_opacity) {
  if(act_opacity < max_opacity) {
   var new_opacity = (parseFloat(act_opacity)+0.05).toFixed(2);
   document.getElementById(element).style.MozOpacity = parseFloat(new_opacity);
   document.getElementById(element).style.opacity = parseFloat(new_opacity);
   document.getElementById(element).style.filter = "alpha(opacity=" + (parseFloat(new_opacity)*100) + ")";
   setTimeout(function() { changeOpacity(element, parseFloat(new_opacity), max_opacity); }, 10);
  } else if(act_opacity > max_opacity) {
   var new_opacity = (parseFloat(act_opacity)-0.05).toFixed(2);
   document.getElementById(element).style.MozOpacity = parseFloat(new_opacity);
   document.getElementById(element).style.opacity = parseFloat(new_opacity);
   document.getElementById(element).style.filter = "alpha(opacity=" + (parseFloat(new_opacity)*100) + ")";
   setTimeout(function() { changeOpacity(element, parseFloat(new_opacity), max_opacity); }, 10);
  }
 }
}

function ucword(str) {
 return str.substr(0,1).toUpperCase() + str.substr(1);
}
 
 // DOENST WORK FOR SAFARI... FIX IT WITH CODE BELOW...
 this.typeOf = function(t, mode) { // THANKS TO WWW.CONSTRUCTORS.DE FOR THAT NICE METHOD!
//  if(!mode) {
   return String(t.constructor).split(" ")[1].split("()").join("");
/*  } else {
   switch (mode) {
    case "Array":
     return isArray(t);
     break;
   }
  } */
 }

this.isArray = function(obj) {
 return obj.constructor == Array;
}

this.array_search = function(arr, str) {
 var found = false;
 
 for(a = 0 ; a < arr.length ; a++) {
  if(arr[a] == str) {
   found = a;
   break;
  }
 }
 
 return found;
}

this.chkCheckbox = function(chkbx, colors, is_class) {
 if(chkbx.checked == false) {
  chkbx.checked = true;
  eval("chkbx.parentNode.parentNode." + (is_class ? "className" : "style.backgroundColor") + " = (colors != undefined ? colors[1] : null);");
  
 } else {
  chkbx.checked = false;
  eval("chkbx.parentNode.parentNode." + (is_class ? "className" : "style.backgroundColor") + " = (colors != undefined ? colors[0] : null);");
 }
}

this.getFunctionParams = function(str, func) {
 var regex = new RegExp(func + "(.*);", "gi");
 regex.exec(str);
 var cut_1 = RegExp.$1.substr(1);
 var cut_2 = cut_1.substr(0, (cut_1.length-1));
 var params = cut_2.split(",");
 
 var new_params = new Array();
 for(a = 0 ; a < params.length ; a++) {
  new_params[a] = params[a].replace(/\s+$/,"").replace(/^\s+/,"");
 }
 
 return new_params;
}

this.deleteAllChildNodes = function(object) {
 for(var a = 0 ; 0 < object.childNodes.length ; a++) {
  object.removeChild(object.childNodes[0]);
 }
}

this.deleteNextSiblings = function(object) {
 while(object.nextSibling) {
  object.parentNode.removeChild(object.nextSibling);
 }
}

 this.cleanJSON = function(str, enc) {
  if(str.indexOf("{") == -1) {
   //ERROR! NO JSON! MAYBE FATAL ERROR IN PHP!
   alert("JSON: Es ist ein Fehler aufgetreten. Bitte noch einmal versuchen!");
   return false;
  } else if(str.indexOf("{") > 0) {
   //ERROR! MAYBE SOME NOTICES OR WHITESPACE CHARS IN PHP!
   //SEND str.substr(0, str.indexOf("{")); AS ERROR TO LOG
   return (enc ? eval('(' + str.substr(str.indexOf("{")) + ')') : str.substr(str.indexOf("{")));
  } else {
   return (enc ? eval('(' + str + ')') : str);
  }
 }
 
this.userLoggedIn = function() {
ULIreq = CRO();
 if(ULIreq) {
  ULIreq.open("POST", config_hdir + "SmallAJAX.html", false);
  ULIreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ULIreq.send("func=userLoggedIn");
  if(ULIreq.status == 200) {
   if((ULI = cleanJSON(ULIreq.responseText)) !== false) {
    ULI = eval('(' + ULI + ')');
    if(ULI.status == "ok") {
     return true;
    } else {
     return false;
    }
   }
  }
 }
}
 
 this.userLoggedInTimer = function(func) {
  if(userLoggedIn()) {
   eval(func);
   setTimeout(function() { window.location.reload(); }, 1000);
  } else {
   setTimeout(function() { userLoggedInTimer(func); }, 1000);
  }
 }

this.getBaseDir = function() {
 GBDreq = CRO();
 if(GBDreq) {
  GBDreq.open("POST", "/SmallAJAX.html", false);
  GBDreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  GBDreq.send("func=getBaseDir");
  if(GBDreq.status == 200) {
   if((GBD = cleanJSON(GBDreq.responseText)) !== false) {
    GBD = eval('(' + GBD + ')');
    if(GBD.status == "ok") {
     return unescape(GBD.response);
    }
   }
  }
 }
}

this.getTemplateName = function() {
 GTNreq = CRO();
 if(GTNreq) {
  GTNreq.open("POST", "/SmallAJAX.html", false);
  GTNreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  GTNreq.send("func=getTemplateName");
  if(GTNreq.status == 200) {
   if((GTN = cleanJSON(GTNreq.responseText)) !== false) {
    GTN = eval('(' + GTN + ')');
    if(GTN.status == "ok") {
     return unescape(GTN.response);
    }
   }
  }
 }
}

this.getImageSizeCSS = function(image) {
 GISSreq = CRO();
 if(GISSreq) {
  GISSreq.open("POST", "/SmallAJAX.html", false);
  GISSreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  GISSreq.send("func=getImageSizeCSS" + unescape("%26") + "image=" + image);
  if(GISSreq.status == 200) {
   if((GISS = cleanJSON(GIIreq.responseText)) !== false) {
    GISS = eval('(' + GISS + ')');
    if(GISS.status == "ok") {
     return unescape(GISS.response);
    }
   }
  }
 }
}
 
 this.BackgroundImage = function(path) {
  if(/MSIE ((5\.5)|[6])/.test(navigator.userAgent) && navigator.platform == "Win32") {
   return "filter = \"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + path + "',sizingMethod='scale')\";";
  } else {
   return "backgroundImage = \"url('" + path + "')\";";
  }
 }
 
 this.saveToSession = function(vars) {
  if((STSreq = CRO()) !== false) {
   var vars_str = "";
   if(isArray(vars)) {
    for(a = 0 ; a < vars.length ; a++) {
     vars_str += unescape("%26") + vars[a][0] + "=" + escape(vars[a][1]);
    }
   }
 
   STSreq.open("POST", "/SmallAJAX.html", true);
   STSreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   STSreq.send("func=saveToSession" + vars_str);
  } else {
   alert("fehler!");
  }
 }

var Dialog = {
 show: function(headline, content, buttons) {
  window.scrollTo(0, 0);
  var PS = getPageSize();
  var ntab = document.createElement("TABLE");
  ntab.id = "dialog_layer";
  ntab.style.zIndex = "1000";
  ntab.style.width = "100%";
  ntab.style.height = PS[3] + "px";
  ntab.style.position = "absolute";
  eval("ntab.style." + BackgroundImage(config_hdir + "templates/" + tmpl_name + "/images/trans.png"));
  var ntbo = document.createElement("TBODY");
  var ntr = document.createElement("TR");
  var ntd = document.createElement("TD");
 
  var itab = document.createElement("TABLE");
  itab.id = "innerTable";
  var ithead = document.createElement("THEAD");
  itab.style.width = "300px";
  itab.style.backgroundColor = "#FFFFFF";
  itab.className = "templateStyle_2pxborder";
  if(document.getElementById("mov_cont")) {
   itab.style.marginLeft = (getX(document.getElementById("mov_cont")) - 325) + "px";
  } else {
   itab.style.marginLeft = "auto";
   itab.style.marginRight = "auto";
  }
  
  var itheadtr = document.createElement("TR");
  var itheadth = document.createElement("TH");
  itheadth.colSpan = (buttons.length + 1);
  itheadth.className = "templateStyle";
  itheadth.appendChild(document.createTextNode(headline));
  
  itheadtr.appendChild(itheadth);
  ithead.appendChild(itheadtr);
  itab.appendChild(ithead);
  
  var itbody = document.createElement("TBODY");
  var itbodytr = document.createElement("TR");
  var itbodytd = document.createElement("TD");
  itbodytd.style.padding = "5px";
  itbodytd.colSpan = (buttons.length + 1);
  itbodytd.innerHTML = unescape(content);
  
  itbodytr.appendChild(itbodytd);
  itbody.appendChild(itbodytr);
  itab.appendChild(itbody);
  
  var itfoot = document.createElement("TFOOT");
  var itfoottr = document.createElement("TR");
  
  for(b = 0 ; b < buttons.length ; b++) {
   var itfoottd = document.createElement("TD");
   itfoottd.style.textAlign = "center";
   var buttn = document.createElement("INPUT");
   buttn.type = "button";
   buttn.className = "templateStyle_buttn";
   buttn.name = buttn.id = buttons[b][1];
   buttn.value = buttons[b][0];
   buttn.param = buttons[b][2];
   buttn.onclick = function() { eval(this.param); }
   
   itfoottd.appendChild(buttn);
   itfoottr.appendChild(itfoottd);
  }
 
  var itfoottd = document.createElement("TD");
  itfoottd.style.textAlign = "center";
  var buttn = document.createElement("INPUT");
  buttn.type = "button";
  buttn.className = "templateStyle";
  buttn.value = loc["close"];
  buttn.onclick = function() {
   Dialog.close();
  }
  itfoottd.appendChild(buttn);
  itfoottr.appendChild(itfoottd);
 
  itfoot.appendChild(itfoottr);
  itab.appendChild(itfoot);
  
  ntd.appendChild(itab);
  ntr.appendChild(ntd);
  ntbo.appendChild(ntr);
  ntab.appendChild(ntbo);
  document.body.insertBefore(ntab, document.body.firstChild);
 },
 
 close: function() {
  document.getElementById("dialog_layer").parentNode.removeChild(document.getElementById("dialog_layer"));
  document.getElementsByTagName("HTML")[0].style.overflowY = "auto";
  document.getElementsByTagName("HTML")[0].style.overflowX = "hidden";
 }
}


function getX(el) {
 var x = el.offsetLeft;
 if (!el.offsetParent) return x;
 else return (x+getX(el.offsetParent));
}

 
 this.showImageLayer = function(img, desc, height, width) {
  var PS = getPageSize();
  var ntab = document.createElement("TABLE");
  ntab.id = "imglayer";
  ntab.style.zIndex = "1000";
  ntab.style.width = "100%";
  ntab.style.height = PS[3] + "px";
  ntab.style.position = "absolute";
  eval("ntab.style." + BackgroundImage(config_hdir + "templates/" + tmpl_name + "/images/trans.png"));
  var ntbo = document.createElement("TBODY");
  var ntr = document.createElement("TR");
  var ntd = document.createElement("TD");
  ntd.style.textAlign = "center";
  var ndiv = document.createElement("DIV");
  ndiv.style.width = (width + 20) + "px";
  ndiv.style.padding = "10px";
  ndiv.style.backgroundColor = "#FFFFFF";
  ndiv.style.marginLeft = "auto";
  ndiv.style.marginRight = "auto";
  var nimg = new Image();
  nimg.src = img;
  nimg.alt = desc;
  nimg.title = desc;
  nimg.style.height = height + "px";
  nimg.style.width = width + "px";
  ndiv.appendChild(nimg);
  var nbr = document.createElement("BR");
  ndiv.appendChild(nbr);
  var ntext = document.createTextNode(desc);
  ndiv.appendChild(ntext);
  ntd.appendChild(ndiv);

  var ndiv = document.createElement("DIV");
  ndiv.style.width = (width + 20) + "px";
  ndiv.style.padding = "10px";
  ndiv.style.backgroundColor = "#FFFFFF";
  ndiv.style.marginLeft = "auto";
  ndiv.style.marginRight = "auto";
  ndiv.style.textAlign = "center";
  ndiv.className = "clickable";
  ndiv.onclick = function() {
   document.getElementById("imglayer").parentNode.removeChild(document.getElementById("imglayer"));
   document.getElementsByTagName("HTML")[0].style.overflowY = "auto";
   document.getElementsByTagName("HTML")[0].style.overflowX = "hidden";
  }
  ndiv.innerHTML = loc["close"];
  
  ntd.appendChild(ndiv);
  ntr.appendChild(ntd);
  ntbo.appendChild(ntr);


  ntab.appendChild(ntbo);
  document.body.insertBefore(ntab, document.body.firstChild);
  document.getElementsByTagName("HTML")[0].style.overflowY = "hidden";
  window.scrollTo(0, 0);
 }
 
 
 this.openFSLayer = function(func, inf, full) {
  if(document.getElementById("fslayer")) {
   document.body.removeChild(document.getElementById("fslayer"));
   openFSLayer(func, inf, full);
  } else {
   OFLreq = CRO();
   if(OFLreq) {
    OFLreq.onreadystatechange = function() {
     if(OFLreq.readyState == 4) {
      OFL = eval('(' + OFLreq.responseText + ')');
      if(OFL.status == "ok") {
       var PS = getPageSize();
       var FSLayer = document.createElement("div");
           FSLayer.id = "fslayer";
           FSLayer.style.zIndex = "1000";
           FSLayer.style.position = "absolute";
           FSLayer.style.width = "100%";
           FSLayer.style.height = PS[3] + "px";
       eval("FSLayer.style." + BackgroundImage(getBaseDir() + "templates/" + getTemplateName() + "/images/trans.png"));
       var ILayer = document.createElement("div");
           ILayer.id = "ilayer";
           ILayer.style.width = (full ? (PS[0] - 80) : "400") + "px";
           ILayer.style.padding = "20px";
           ILayer.style.height = (full ? (PS[1] - 80) : "400") + "px";
           ILayer.style.maxHeight = (full ? (PS[1] - 80) : "400") + "px"
           if(window.opera) {
            ILayer.style.overflow = "auto";
           } else {
            ILayer.style.overflowY = "auto";
            ILayer.style.overflowX = "hidden";
           }
           ILayer.style.top = (full ? "20" : (PS[1]/2-200)) + "px";
           ILayer.style.position = "absolute";
           ILayer.style.left = (full ? "20" : (PS[0]/2-225)) + "px";
           
           ILayer.style.backgroundColor = "#FFFFFF";
           ILayer.innerHTML = unescape(OFL.response) + "<div style='width: 400px; text-align: right;'><span style='color: #FF0000;' class='clickable' onclick='closeFSLayer();'>" + GetLocales("close") + "<\/span><\/div>";
           document.getElementsByTagName("html")[0].style.overflow = "hidden";
           
       FSLayer.appendChild(ILayer);
       document.body.insertBefore(FSLayer, document.body.firstChild);
       if(func == "showFile") {
        document.getElementById("file_iframe").style.height = (full ? (PS[3] - 100) : "400") + "px";
        document.getElementById("file_iframe").style.width = (full ? (PS[2] - 80) : "400") + "px";
       }
      } else {
       alert(unescape(OFL.error));
      }
     }
    }
    OFLreq.open("POST", "/LayerAJAX.html", true);
    OFLreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    OFLreq.send("func=" + func + ((inf != undefined && inf != null) ? unescape("%26") + "inf=" + inf : ""));
   }
  }
 }
 
 this.closeFSLayer = function() {
  document.body.removeChild(document.getElementById("fslayer"));
  document.getElementsByTagName("html")[0].style.overflow = "auto";
 }
 
 // getPageSize()
 // Returns array with page width, height and window width, height
 // Core code from - quirksmode.org
 // Edit for Firefox by pHaez
 //
 function getPageSize(){
  var xScroll, yScroll;
	
  if (window.innerHeight && window.scrollMaxY) {
   xScroll = document.body.scrollWidth;
   yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
   xScroll = document.body.scrollWidth;
   yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
   xScroll = document.body.offsetWidth;
   yScroll = document.body.offsetHeight;
  }
	
  var windowWidth, windowHeight;

  if (self.innerHeight) { // all except Explorer
   windowWidth = self.innerWidth;
   windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
   windowWidth = document.documentElement.clientWidth;
   windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
   windowWidth = document.body.clientWidth;
   windowHeight = document.body.clientHeight;
  }	
	
  // for small pages with total height less then height of the viewport
  if(yScroll < windowHeight) {
   pageHeight = windowHeight;
  } else {
   pageHeight = yScroll;
  }

  // for small pages with total width less then width of the viewport
  if(xScroll < windowWidth) {
   pageWidth = windowWidth;
  } else {
   pageWidth = xScroll;
  }

  arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
  return arrayPageSize;
 }

 //
 // getPageScroll()
 // Returns array with x,y page scroll values.
 // Core code from - quirksmode.org
 //
 function getPageScroll(){
  var yScroll;

  if (self.pageYOffset) {
   yScroll = self.pageYOffset;
  } else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
   yScroll = document.documentElement.scrollTop;
  } else if (document.body) { // all other Explorers
   yScroll = document.body.scrollTop;
  }

  arrayPageScroll = new Array('',yScroll) 
  return arrayPageScroll;
}

this.number_format = function(number, decimals, dec_point, thousands_sep) { // THANKS TO FOBIT.COM!
 var exponent = "";
 var numberstr = number.toString ();
 var eindex = numberstr.indexOf ("e");
 if (eindex > -1) {
  exponent = numberstr.substring (eindex);
  number = parseFloat (numberstr.substring (0, eindex));
 }
  
 if (decimals != null) {
  var temp = Math.pow (10, decimals);
  number = Math.round (number * temp) / temp;
 }
 var sign = number < 0 ? "-" : "";
 var integer = (number > 0 ?  Math.floor (number) : Math.abs (Math.ceil (number))).toString();
  
 var fractional = number.toString ().substring (integer.length + sign.length);
 dec_point = dec_point != null ? dec_point : ".";
 fractional = decimals != null && decimals > 0 || fractional.length > 1 ? (dec_point + fractional.substring (1)) : "";
 if (decimals != null && decimals > 0) {
  for (i = fractional.length - 1, z = decimals; i < z; ++i) {
   fractional += "0";
  }
 }
  
 thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? thousands_sep : null;
 if (thousands_sep != null && thousands_sep != "") {
  for (i = integer.length - 3; i > 0; i -= 3) {
   integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
  }
 }
 return sign + integer + fractional + exponent;
}

var chpage_act = false;
var new_obj = null;
var new_page = null;

this.showPage = function(obj, page) {
 if(!chpage_act && act_page != page) {
  new_obj = obj;
  new_page = page;
   
  if(page == "index") {
   document.getElementById("div_content").parentNode.insertBefore(document.getElementById("div_index"), document.getElementById("div_content"));
   document.getElementById("div_index").id = "div_ncontent";

   document.getElementById("main_cell").getElementsByTagName("DIV")[(document.getElementById("main_cell").getElementsByTagName("DIV").length-1)].id = "old_index";
   document.getElementById("old_index").parentNode.removeChild(document.getElementById("old_index"));

   obj.parentNode.className = "innerTab_act";
   if(document.getElementById("tab_list_act")) {
    document.getElementById("tab_list_act").parentNode.className = "innerTab";
   }
   
   document.getElementById("div_ncontent").style.display = "block";
   location.hash = null;
   changePage();
  } else {
   if(typeof iTabVars != "undefined") {
    if(typeof iTabVars[page] != "undefined") {
     for(vars in iTabVars[page]) {
      var args = "";
      args += vars + "=" + escape(iTabVars[page][vars]).replace(new RegExp("\\+", "g"), "%2B") + unescape("%26");
     }
    }
   }
   
   var handlers = {
    onSuccess: function(areq) {
     location.hash = "/chP/" + obj.parentNode.id;
     
     var ndiv = document.createElement("DIV");
     ndiv.id = "div_ncontent";
     ndiv.style.overflow = "hidden";
     ndiv.style.marginTop = "5px";
     ndiv.style.width = document.getElementById("div_content").style.width;
     ndiv.style.maxWidth = document.getElementById("div_content").style.maxWidth;
     ndiv.style.minWidth = document.getElementById("div_content").style.minWidth;
     ndiv.innerHTML = unescape(areq.response);
     
     obj.parentNode.className = "innerTab_act";
     if(document.getElementById("tab_list_act")) {
      document.getElementById("tab_list_act").parentNode.className = "innerTab";
     }
     
     document.getElementById("div_content").parentNode.insertBefore(ndiv, document.getElementById("div_content"));
     changePage();
    },
    
    onError: function(areq) {
     alert(unescape(areq.error));
    }
   }
   
   Ajax.Request("POST", "PageAJAX.html", true, "page=" + page + (args != undefined ? unescape("%26") + args : ""), handlers);
  }
 }
}

this.changePage = function() {
 chpage_act = true;
// document.getElementById("div_ncontent").style.height = parseInt(document.getElementById("div_ncontent").scrollHeight) + "px";
 if(act_page == "index") {
  document.getElementById("div_content").id = "div_index";
  document.getElementById("div_index").style.display = "none";
 } else {
  if(document.getElementById("div_content")) {
   document.getElementById("div_content").parentNode.removeChild(document.getElementById("div_content"));
  }
 }
 document.getElementById("div_ncontent").id = "div_content";
 chpage_act = false;
 if(document.getElementById("tab_list_act")) {
  document.getElementById("tab_list_act").id = "";
 }
 new_obj.id = "tab_list_act";
 act_page = new_page;
}

this.changePageEffects = function() {
 var n = false;
 
 if(parseInt(document.getElementById("div_ncontent").style.height.substr(0, (document.getElementById("div_ncontent").style.height.length-2))) < document.getElementById("div_ncontent").scrollHeight) {
  document.getElementById("div_ncontent").style.height = (parseInt(document.getElementById("div_ncontent").style.height.substr(0, (document.getElementById("div_ncontent").style.height.length-2))) + 20) + "px";
  var n = true;
 }
 
 if(document.getElementById("div_content")) {
  if(parseInt(document.getElementById("div_content").style.height.substr(0, (document.getElementById("div_content").style.height.length-2))) > 0) {
   if(parseInt(document.getElementById("div_content").style.height.substr(0, (document.getElementById("div_content").style.height.length-2))) < 20) {
    document.getElementById("div_content").style.height = "0px";
   } else {
    document.getElementById("div_content").style.height = (parseInt(document.getElementById("div_content").style.height.substr(0, (document.getElementById("div_content").style.height.length-2))) - 20) + "px";
    var n = true;
   }
  }
 }
 
 if(n) {
  setTimeout(function() { changePage() }, 10);
 } else {
  if(act_page == "index") {
   document.getElementById("div_content").id = "div_index";
  } else {
   if(document.getElementById("div_content")) {
    document.getElementById("div_content").parentNode.removeChild(document.getElementById("div_content"));
   }
  }
  document.getElementById("div_ncontent").id = "div_content";
  chpage_act = false;
  if(document.getElementById("tab_list_act")) {
   document.getElementById("tab_list_act").id = "";
  }
  new_obj.id = "tab_list_act";
  act_page = new_page;
 }
}

if(location.hash.length > 0) {
 if(location.hash.substr(1, 5) == "/chP/") {
  var ch_p = location.hash.substr(6);
  var ch_p_ival = window.setInterval(function() {
   if($(ch_p) != null) {
    showPage($(ch_p).getElementsByTagName("A")[0], ch_p);
    window.clearInterval(ch_p_ival);
   }
  }, 100);
 }
}

/* GETTING FLASH PLAYER VERSION - THX TO SWFOBJECT! */

this.getFPV = function() {
 var playerVersion = [0,0,0];
 if(typeof navigator.plugins != undefined && typeof navigator.plugins["Shockwave Flash"] == "object") {
  var d = navigator.plugins["Shockwave Flash"].description;
  if (d && !(typeof navigator.mimeTypes != undefined && navigator.mimeTypes["application/x-shockwave-flash"] && !navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
   d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
   playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
   playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
   playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
  }
 } else if (typeof window.ActiveXObject != undefined) {
  var a = null, fp6Crash = false;
  try {
   a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
  } catch(e) {
   try { 
    a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
    playerVersion = [6,0,21];
    a.AllowScriptAccess = "always";	 // Introduced in fp6.0.47
   } catch(e) {
    if (playerVersion[0] == 6) {
     fp6Crash = true;
    }
   }
   
   if (!fp6Crash) {
    try {
     a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
    } catch(e) {}
   }
  }
  
  if (!fp6Crash && a) { // a will return null when ActiveX is disabled
   try {
    d = a.GetVariable("$version");	// Will crash fp6.0.21/23/29
    if (d) {
     d = d.split(" ")[1].split(",");
     playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
    }
   } catch(e) {}
  }
 }
 
 return playerVersion;
}


/* SCRIPT search.js */


function suggest() {
 var searchval = document.forms["article_search_form"].elements[0].value;
 setTimeout(function() {
  if(searchval.length == 0) {
   $('suggest').style.display = "none";
   $('suggest').innerHTML = "";
  } else {
   Sreq = CRO();
   Sreq.onreadystatechange = function() {
    if (Sreq.readyState == 4) {
     $('suggest').innerHTML = unescape(Sreq.responseText);
     if(searchval.length > 0) {
      $('suggest').style.display = "block";
     }
    }
   }
   Sreq.open("POST", "/Suggest_AJ.html", true);
   Sreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   Sreq.send("search=" + escape(searchval));
  }
 }, 10);
}
