// JavaScript Document
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;
}

function addEvent(elm, evType, fn, useCapture) {
	if(elm.addEventListener){
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}else if (elm.attachEvent){
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}else{
		elm['on' + evType] = fn;
	}
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}else{
		window.onload = function() {
			oldonload();
			func();
		}
	}
}



function make_smart_input(id,val){
	var el = $(id);
	addEvent(el,'focus',function(){ clear_input(id,val) });
	addEvent(el,'blur',function(){ set_input(id,val) });
	set_input(id,val);
}

function set_input(id,val){
	var el = $(id);
	el.value = el.value == '' ? val : el.value;
}

function clear_input(id,val){
	var el = $(id);
	el.value = el.value == val ? '' : el.value;
}

function make_hover_list(id){
	var list = $(id);
	if(document.all && list){
		for(i=0; i<list.childNodes.length; i++){
			var node = list.childNodes[i];
			if(node.nodeName=="LI"){
				node.onmouseover=function(){ this.className+=" hover"; }
				//node.onmouseout=function(){ this.className=this.className.replace(" hover",""); }
				node.onmouseout=function(){ this.className=this.className.replace(new RegExp(" hover\\b"),""); }
			}
		}
	}
}

//function pgp_init(){
//	make_hover_list('pgp_nav_list');
//	//make_hover_list('tabs_list');
//	//make_hover_list('quick_list');
//	make_smart_input('q','Search PGP');
//}

//alert("TEST2a");
//addLoadEvent(pgp_init);
//alert("TEST2b");