/* ================================================================ 
FUNCTION CSSHOVER: The original version of the function "csshover" and the associated 
(x)html is available at http://www.stunicholls.com/menu/pro_drop_1.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
================================================================== */

csshover = function() {
	var cssRule;
	var newSelector;
	for (var i = 0; i < document.styleSheets.length; i++)
		for (var x = 0; x < document.styleSheets[i].rules.length ; x++)
			{
			cssRule = document.styleSheets[i].rules[x];
			if (cssRule.selectorText.indexOf("LI:hover") != -1)
			{
				 newSelector = cssRule.selectorText.replace(/LI:hover/gi, "LI.iehover");
				document.styleSheets[i].addRule(newSelector , cssRule.style.cssText);
			}
		}
	var getElm = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<getElm.length; i++) {
		getElm[i].onmouseover=function() {
			this.className+=" iehover";
		}
		getElm[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", csshover);



/* ================================================================ 
FUNCTION POPUP/POPDOWN: The original version of this function and the associated 
(x)html is available at http://www.stichpunkt.de/beitrag/popup.html
Free to use. Script by Thomas Stich.

<a href="html-or.jpg" onclick="return popup(this,123,456)" title="..."
================================================================== */
 
var pop = null;
 
function popdown() {
  if (pop && !pop.closed) pop.close();
}
 
function popup(obj,w,h,s) {
  var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
  if (!url) return true;
  w = (w) ? w += 0 : 150;  // 150px*150px is the default size
  h = (h) ? h += 0 : 150;
  s = (s) ? s : "auto";
  var args = 'width='+w+',height='+h+',scrollbars='+s+',left=100,top=100,resizable=yes,toolbar=no,status=no,menubar=no';
  popdown();
  pop = window.open(url,'',args);
  return (pop) ? false : true;
}
 
window.onunload = popdown;
/*window.onfocus = popdown;*/



/* ================================================================ 
eMail Encrypter: http://jumk.de/nospam/
================================================================== */

function UnCryptMailto( s ) {
  var n = 0;
  var r = "";
  for( var i = 0; i < s.length; i++) {
    n = s.charCodeAt( i );
    if( n >= 8364 ) {
      n = 128;
    }
    r += String.fromCharCode( n - 1 );
  }
  return r;
}

function linkTo_UnCryptMailto( s ) {
  location.href=UnCryptMailto( s );
}



/* ================================================================ 
Zebra Table: http://v3.thewatchmakerproject.com/journal/309/stripe-your-tables-the-oo-way
================================================================== */

var Event = {
	add: function(obj,type,fn) {
		if (obj.attachEvent) {
			obj['e'+type+fn] = fn;
			obj[type+fn] = function() { obj['e'+type+fn](window.event); }
			obj.attachEvent('on'+type,obj[type+fn]);
		} else
		obj.addEventListener(type,fn,false);
	},
	remove: function(obj,type,fn) {
		if (obj.detachEvent) {
			obj.detachEvent('on'+type,obj[type+fn]);
			obj[type+fn] = null;
		} else
		obj.removeEventListener(type,fn,false);
	}
}
 
function $() {
	var elements = new Array();
	for (var i=0;i<arguments.length;i++) {
		var element = arguments[i];
		if (typeof element == 'string') element = document.getElementById(element);
		if (arguments.length == 1) return element;
		elements.push(element);
	}
	return elements;
}
 
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/,"");
}
 
function addClassName(el,className) {
	removeClassName(el,className);
	el.className = (el.className + " " + className).trim();
}
 
function removeClassName(el,className) {
	el.className = el.className.replace(className,"").trim();
}
 
var ZebraTable = {
	bgcolor: '',
	classname: '',
	stripe: function(el) {
		if (!$(el)) return;
		var rows = $(el).getElementsByTagName('tr');
		for (var i=1,len=rows.length;i<len;i++) {
			if (i % 2 == 0) rows[i].className = 'alt';
			Event.add(rows[i],'mouseover',function() { ZebraTable.mouseover(this); });
			Event.add(rows[i],'mouseout',function() { ZebraTable.mouseout(this); });
		}
	},
	mouseover: function(row) {
		this.bgcolor = row.style.backgroundColor;
		this.classname = row.className;
		addClassName(row,'over');
	},
	mouseout: function(row) {
		removeClassName(row,'over');
		addClassName(row,this.classname);
		row.style.backgroundColor = this.bgcolor;
	}
}
 
window.onload = function() {
	ZebraTable.stripe('tb');
}