// use this to add onload events

function addWindowOnload(fn) {
  if (window.addEventListener){
    window.addEventListener("load", fn, false);
  } else if (window.attachEvent){
    window.attachEvent("onload", fn);
  }
}

// pop

function popup(url,w,h) {
   window.open(url, 'aru', 'location=0,resizable=1,status=0,titlebar=0,directories=0,toolbar=1,menubar=1,scrollbars=1,width='+w+',height='+h);
   return false;
}

// popfeedback

function popfeedback(url,w,h) {
   alert('The popfeedback function has been deprecated.');
   //var popped = window.open(url,'feedback','location=0,resizable=1,status=0,titlebar=0,directories=0,toolbar=0,menubar=0,scrollbars=0,width='+w+',height='+h);
   //return (popped)?false:true;
}

// for adding search plugins

function addEngine( src, img, name, cat) {
    if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function"))
    {
        window.sidebar.addSearchEngine( src, img, name, cat );
    }
    else
    {
        alert("Mozilla or Firefox is required to add a search engine.  Sorry!");
    }
}


// Table Row Alternation
// rewritten by milesck: old version would get ALL <tr> descendants of the table
// (including those of subtables), not just the direct children

addWindowOnload(function(){
	var container = document.getElementById("content");
	if(!container) return;
	var tables = container.getElementsByTagName("table");
	for(var i = 0; i < tables.length; i++){
		var table = tables[i];
		if ((table.className || table.id) && table.className != "expansive" && table.className.indexOf("forcedalternation") == -1)
			continue;
		var row = table.firstChild;
		var j = 0;
		while (row) {
			var tag = row.tagName;
			if (tag) tag = tag.toLowerCase();
			if (tag == 'tbody') {
				row = row.firstChild;
				continue;
			}
			if (tag == 'tr') {
				if(table.className.indexOf("forcealternation") == -1) {
					row.className += j % 2 ? ' odd' : ' even';
				} else {
					row.className += j % 2 ? ' forcedodd' : ' forcedeven';
				}
				j++;
			}
			if (!row.nextSibling && row.parentNode != table)
				row = row.parentNode;
			row = row.nextSibling;
		}
	}
});

// CSS Browser Selector   v0.2.5
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
(function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1 + (parseInt(RegExp.$1) <=6 ? ' ielte6' : '')):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
})();