/* created by Valentin Agachi - http://agachi.name/ */

var brIE = ( /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) );


function loadScript(path) {
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.src = path;
	document.getElementsByTagName('head')[0].appendChild(script); 
}


function ImgPre() {
	var d=document; 
	if(!d.imgp) d.imgp=new Array();
	var i, j=d.imgp.length, a=ImgPre.arguments; 
	for (i=0; i<a.length; i++) {
		if (a[i].indexOf("#")!=0) { 
			d.imgp[j]=new Image(); d.imgp[j++].src=a[i];
		}
	}
}

/**
 * Browser detect
 */

function is() {
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible')==-1)));
	this.ns2 = (this.ns && (this.major == 3));
	this.ns3 = (this.ns && (this.major == 3));
	this.ns4b = (this.ns && (this.minor < 4.04));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns6 = (this.ns && (this.major >= 5));
	this.opera = (agent.indexOf("opera") != -1);
	this.ie = ((agent.indexOf("msie") != -1) && !this.opera);
	this.ie3 = (this.ie && (this.major == 2));
	this.ie4 = (this.ie && (this.major == 4));
	this.ie5 = (this.ie && (this.major >= 5));
	this.moz = (agent.indexOf('Gecko')!=-1);
	this.win = (agent.indexOf("win")!=-1);
	this.mac = (agent.indexOf("mac")!=-1);
	this.unix = (agent.indexOf("x11")!=-1);
}
var br = new is();



/**
 * Location functions
 */

function go(link, target, w, h) {
	if (target == '_blank') {
		if (!w) w = 700;
		if (!h) h = 500;
		popup(link, w, h);
	} else {
		if (!target) {
			target = document;
		}
		target.location = link;
	}
}

function popup(link, width, height) {
	var left = (screen.width - width - 20) / 2;
	var top = (screen.height - height - 30) / 2;
	var date = new Date();
	var sName = 'win' + date.getHours() + date.getMinutes() + date.getSeconds();
	window.open(link, sName, 'width='+width+',height='+height+',left='+left+',top='+top+',toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes');
	return false;
}

function win_new(link, width, height) {
	var settings = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height;
	cms = window.open(link, 'popup', settings);
}


function popupImg(sPath, sPicURL, sTitle) { 
	window.open(sPath + "lib/image.popup.htm?" + sPicURL + '?' + sTitle, "", "resizable=1,height=200,width=200"); 
}


/**
 * Page onload functions handling
 */

var load = {
	funcs: new Array(),
	register: function(f) {
		if (typeof(f) != 'function') return;
		load.funcs.push(f);
	},
	execute: function() {
		for (var i = 0; i < load.funcs.length; i++) {
			load.funcs[i]();
		}
	}
};
window.onload = load.execute;

/*
var onload_funcs=new Array();
function onload_register(func) {
	if (func != null) {
		window.onload_funcs[window.onload_funcs.length] = func;
	}
}
function do_onload() {
	for (var i = 0; i < window.onload_funcs.length; i++) {
		window.onload_funcs[i]();
	}
}
window.onload = do_onload;
*/


/** 
 * Event handling
 */ 

function addEvent(el, eventName, func) {
	if (el.attachEvent) { // IE
		el.attachEvent("on" + eventName, func);
	} else if (el.addEventListener) { // Gecko / W3C
		el.addEventListener(eventName, func, true);
	} else {
		el["on" + eventName] = func;
	}
};
function removeEvent(el, eventName, func) {
	if (el.detachEvent) { // IE
		el.detachEvent("on" + eventName, func);
	} else if (el.removeEventListener) { // Gecko / W3C
		el.removeEventListener(eventName, func, true);
	} else {
		el["on" + eventName] = null;
	}
};
function eventGetElement(ev) {
	if (brIE) {
		return window.event.srcElement;
	} else {
		return ev.currentTarget;
	}
};



/**
 * Menu hover
 */

var oPreloads = new Object();

function imgButHover(ev) {
	var oImg = eventGetElement(ev);
	oImg.src = oPreloads['o' + oImg.id].src;
}
function imgButNormal(ev) {
	var oImg = eventGetElement(ev);
	oImg.src = oPreloads['n' + oImg.id].src;
}
function imgButSrcGetHover(sSrc) {
	var aSrc = sSrc.split('.');
	aSrc[aSrc.length] = aSrc[aSrc.length - 1];
	aSrc[aSrc.length - 2] = 'o';
	return aSrc.join('.');
}
function imgButSrcGetNormal(sSrc) {
	var aSrc = sSrc.split('.');
	aSrc[aSrc.length - 2] = aSrc[aSrc.length - 1];
	aSrc[aSrc.length - 1] = null;
	return aSrc.join('.');
}
function imgButInit(o) {
	if (o.className.length) {
		if (/imgButHover/.test(o.className)) {
			oPreloads['n' + o.id] = new Image;
			oPreloads['n' + o.id].src = o.src;
			oPreloads['o' + o.id] = new Image;
			oPreloads['o' + o.id].src = imgButSrcGetHover(o.src);
			addEvent(o, 'mouseover', imgButHover);
			addEvent(o, 'mouseout', imgButNormal);
		}
		if (/imgButSelected/.test(o.className)) {
			o.src = imgButSrcGetHover(o.src);
		}
	}
}
function imgButLoad() {
	var aImgs = new Array();
	if (document.getElementById) var aImgs = document.getElementsByTagName('img');
	else if (document.all) var aImgs = document.all.tags('img');	
	if (aImgs.length) for (var i = 0; i < aImgs.length; i++) imgButInit(aImgs[i]);
	aImgs = new Array();
	if (document.getElementById) var aImgs = document.getElementsByTagName('input');
	else if (document.all) var aImgs = document.all.tags('input');	
	if (aImgs.length) for (var i = 0; i < aImgs.length; i++) if (aImgs[i].type == 'image') imgButInit(aImgs[i]);
}
load.register(imgButLoad);




Array.prototype.toString = function() {
	var s = '['+"";
	for (var i in this) {
		if (typeof(this[i]) != 'function') s += i + ': ' + this[i] + ' - ';
	}
	s += ']';
	return s;
}




function doPage(o, link, page) {
	if (typeof(o) == 'string') o = document.getElementById(o);
	var i = o.options[o.selectedIndex].value;
	var s = link;
	if (i != 1) s = link + '?' + page + '=' + i;
	go(s);
}




/* IE :hover */
sfHover = function() {
	var sfEls = document.getElementById("pageMenu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			if (this.className == 's') this.className += 'hover hover';
			else this.className+=" hover";
		}
		sfEls[i].onmouseout=function() {
			if (this.className == 'shover hover') this.className='s';
			else this.className=this.className.replace(new RegExp(" hover\\b"), "");
		}
	}
}
//if (brIE) icd_onload_register(sfHover);



// DF1.1 :: domFunction 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html

//DOM-ready watcher
function domFunction(f, a) {
	var n = 0;
	var t = setInterval(function() {
		var c = true;
		n++;
		if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null)) {
			c = false;
			if (typeof a == 'object') {
				for (var i in a) {
					if ( (a[i] == 'id' && document.getElementById(i) == null) || (a[i] == 'tag' && document.getElementsByTagName(i).length < 1) ) { 
						c = true;
						break; 
					}
				}
			}
			if(!c) { f(); clearInterval(t); }
		}
		if(n >= 60) {
			clearInterval(t);
		}
	}, 250);
};

/* 7464 7464 */