var axDebug = true;
var ie = navigator.appVersion.indexOf("IE") != -1 ? true:false;
function isAjaxError(transport)
{
	if(transport.responseText.indexOf("Error:") == 0)
	{
		alert(transport.responseText.replace("Error:",""));
		return true;
	}
	return false;
}
function EventListen(o,e,func)
{
	try {
		if(window.addEventListener) o.addEventListener(e.substring(2), func, false);
		else o.attachEvent(e,func);
	} catch(e) {}
	return false;
}
function EventIgnore(o,e,func)
{
	try {
		if(window.addEventListener) o.removeEventListener(e.substring(2), func, false);
		else o.detachEvent(e,func);
	} catch(e) {}
	return false;
}
function GEvent(evt)
{
	try {
		evt = evt ? evt : event;
		if(evt.srcElement) return evt.srcElement;
		else if(evt.target) return evt.target;
		else return evt;
	} catch(e) {}
	return false;
}
function Remove(node)
{
	try {
		if(node == null) return;
		for(var i=(node.childNodes.length-1);i>=0;i--) Remove(node.childNodes[i]);
		node.parentNode.removeChild(node);
	} catch(e) {}
	return false;
}
function Mouse(evt) {
	try {
		var e = evt ? evt : event
		var o = new Object();
		o.X = e.clientX;
		o.Y = e.clientY;
		o.XS = e.clientX;
		o.YS = e.clientY+document.body.scrollTop;
		return o;
	} catch(e) {}
	return false;
}
function Coords(node) {
	try {
		var o = new Object();
		o.X = 0;
		var h = node.offsetHeight, w = node.offsetWidth;
		o.Y = node.offsetHeight;
		while(node && node.nodeName != "BODY") {
			o.X += node.offsetLeft;
			o.Y += node.offsetTop;
			node = node.offsetParent;
		}
		o.Top = o.Y-h;
		o.Right = o.X+w;
		o.MX = o.X+(w/2);
		o.MY = o.Y-(h/2);
		return o;
	} catch(e) {}
	return false;
}
function Resolution() {
	try	{
		var o = new Object();
		o.Width = window.innerWidth ? window.innerWidth : document.body.offsetWidth;
		o.Height = window.innerHeight ? window.innerHeight : document.body.offsetHeight;
		return o;
	}
	catch(e) {}
	return false;
}
function GetElements(o)
{
	var list = [];
	for(i=1;i<arguments.length;i++)
	{
		var l = o.getElementsByTagName(arguments[i]);
		for(j=0;j<l.length;j++) list.push(l[j]);
	}
	return list;
}
//***********************************************************************


function S_Opacity(s,o)
{
	if(ie) s.style.filter = "alpha(opacity="+o+")";
	else
	{
		s.style.MozOpacity = o/100;
		s.style.opacity = o/100;
	}
}
function S_V(id,v) { if(document.getElementById(id)) document.getElementById(id).style.visibility = v; }
function S_D(id,d) { if(document.getElementById(id)) document.getElementById(id).style.display = d; }

function Redirect(url)
{
	oRedirect.p = url;
	setTimeout("oRedirect.Do()",10);
}
var oRedirect = {
	p : "",
	Do : function()
	{
		location.href = this.p;
	}
};

var Test = {
	Up : function(o,type,c)
	{
		if(o == null || typeof(o) == "undefined") return false;
		if((typeof(c) == "object" && array_contains(c,eval("o."+type))) || (typeof(c) != "object" && eval("o."+type) == c)) return o;
		if(o.nodeName == "BODY" || o.nodeName == "HTML") return false;
		while(o != null && o.nodeName != "BODY")
		{
			if((typeof(c) == "object" && array_contains(c,eval("o."+type))) || (typeof(c) != "object" && eval("o."+type) == c)) return o;
			o = o.parentNode;
		}
		return false;
	},
	Down : function(o,type,c)
	{
		for(var i=0;i<o.childNodes.length;i++)
		{
			if(eval("o.childNodes[i]."+type) != c)
			{
				var res = Test.Down(o.childNodes[i],type,c);
				if(res != false) return res;
			}
			else return o.childNodes[i];
		}
		return false;
	},
	DownAtt : function(o,att,c)
	{
		for(var i=0;i<o.childNodes.length;i++)
		{
			if(o.childNodes[i].nodeName == "DIV")
			{
				if(o.childNodes[i].getAttribute(att) != c)
				{
					var res = Test.DownAtt(o.childNodes[i],att,c);
					if(res != false) return res;
				}
				else return o.childNodes[i];
			}
		}
		return false;
	},
	GetChildren : function(o,type,c,list)
	{
		try {
			for(var i=0;i<o.childNodes.length;i++)
			{
				if(eval("o.childNodes[i]."+type) != c)
				{
					Test.GetChildren(o.childNodes[i],type,c,list);
				}
				else list.push(o.childNodes[i]);
			}
		} catch(e) {alert(e.message)}
	}
}
function f() {return false;}
//form tags to omit:
var omitformtags=["input", "textarea", "select"]

function disableselect(e){
	for (i = 0; i < omitformtags.length; i++)
	if (omitformtags[i]==(e.target.tagName.toLowerCase()))
	return;
	return false
}

function reEnable(){return true}

function noSelect(){
	if (typeof document.onselectstart!="undefined")
	{
		document.onselectstart=new Function ("return false")
		if (document.getElementsByTagName)
		{
			tags=document.getElementsByTagName('*')
			for (j = 0; j < tags.length; j++)
			{
				for (i = 0; i < omitformtags.length; i++)
					if (tags[j].tagName.toLowerCase()==omitformtags[i])
					{
						tags[j].onselectstart=function()
						{
						document.onselectstart=new Function ('return true')
						}
						tags[j].onmouseup=function()
						{
						document.onselectstart=new Function ('return false')
						}
					}
			}
		}
	}
	else
	{
	document.onmousedown=disableselect
	document.onmouseup=reEnable
	}
}
var Select = {
	ns : null,
	Add : function()
	{
		noSelect();
	},
	Remove : function()
	{
	}
};





//***********************************************************************
//***********************************************************************
//***********************************************************************
//***********************************************************************
//***********************************************************************
//***********************************************************************
//***********************************************************************
//***********************************************************************


var pil = {
	objects : [],
	count : 0,
	Add : function(action,data,file,callback)
	{
		var b = document.getElementsByTagName('base');
		var temp = "";
		if(b.length > 0) temp = b[0].href;
		if(typeof(cname) != "undefined" && cname != "") temp += cname+"/";
		file = temp+file;
		var t = new pil.AJAX(action,data,callback);
		this.objects[t.id] = t;
		if(data)
		{
			t.r.open("POST",file, true);
			t.r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		}
		else t.r.open("POST",action, true);
		if(t.str != "") t.r.send(t.str);
		else t.r.send(null);
	},
	Ready : function(id)
	{
		if(this.objects[id].r.readyState == 4) pil.Done(id,this.objects[id].r.responseText);
	},
	Done : function(id,js)
	{
		//js = DeWebify(js);
		if(this.objects[id].callback) this.objects[id].callback(js);
		else this.GeneralCallback(js);
		this.objects[id] = null;
	},
	GeneralCallback : function(js)
	{
		eval(js);
	},
	AJAX : function(action,data,callback)
	{
		this.action = action;
		this.id = pil.count;
		pil.count++;
		this.callback = callback;

		this.r = null;
		if(window.XMLHttpRequest) this.r = new XMLHttpRequest();
		else if (window.ActiveXObject) this.r = new ActiveXObject("Microsoft.XMLHTTP");

		if(typeof(pil) != "undefined") eval("this.r.onreadystatechange = function() {if(typeof(pil) != 'undefined') pil.Ready("+this.id+");}");

		this.str = null;
		if(data)
		{
			this.str = "action="+action;
			for(var i=0;i<data.length;i++) this.str += "{@}"+data[i][0]+"="+data[i][1];

			while(this.str.indexOf("&") != -1) this.str = this.str.replace("&","%26");
			while(this.str.indexOf("{@}") != -1) this.str = this.str.replace("{@}","&");
		}
	}
}
function replaceAll(t,o,n)
{
	var i = t.indexOf(o);
	while(i != -1)
	{
		t = t.replace(o,n);
		i = t.indexOf(o);
	}
	return t;
}
function rq(t)
{
	var a = replaceAll(t,"'","`");
	a = replaceAll(a,"\"","~");
	return a;
}
function drq(t)
{
	var a = replaceAll(t,"`","'");
	a = replaceAll(a,"~","\"");
	return a;
}
function drqf(t)
{
	var a = replaceAll(t,"`","&#039;");
	a = replaceAll(a,"~","&quot;");
	a = replaceAll(a,'"',"&quot;");
	a = replaceAll(a,"'","&#039;");
	a = replaceAll(a,'|','\n');
	return a;
}
var ill = {
	worker : "worker.php",
	callbacks : new Array(),

	Add : function(action,data,file,callback) {
		var id = (new Date()).getTime();
		var b = document.getElementsByTagName('base');
		var temp = "";
		if(b.length > 0) temp = b[0].href;
		if(typeof(cname) != "undefined" && cname != "") temp += cname+"/";
		ill.worker = temp+file;
		try {
			var i = document.createElement("iframe");
			var ie = typeof(i.innerText) == "string" ? true : false;
			i.id = id;
			i.style.position = "absolute";i.style.left = "0px";i.style.top = "0px";
			if(axDebug) {i.style.backgroundColor = "white";i.style.width = "300px";i.style.height = "300px";}
			else {i.style.visibility = "hidden";i.style.height = "1px";i.style.width = "1px";}
			this.callbacks[id] = callback ? callback : ill.General;
			document.getElementsByTagName("body")[0].appendChild(i);

			var doc = i.contentDocument ? i.contentDocument : i.contentWindow.document;
			this.Build(action,data,doc,id);
		}
		catch(e) {ThrowException(e,'ill.Add')}
	},

	Build : function(action,data,doc,id) {
		try {
			var worker = this.worker;
			var html = '<html><body><form method="post" action="'+worker+'" id="formaction">';
			html += '<input type="text" name="iid" value="'+id+'">';
			html += '<input type="text" name="action" value="'+action+'">';
			if(data)
			{
				for(var i=0;i<data.length;i++)
					html += '<textarea type="text" name="'+data[i][0]+'">'+data[i][1]+'</textarea>';
			}
			html += "</form></body></html>";
			doc.open();
			doc.write(html);
			doc.close();

			var form = doc.getElementById("formaction");
			if(form) form.submit();
		}
		catch(e) {ThrowException(e,'ill.Build')}
	},

	Completed : function(id,js)
	{
		try {
			var i = document.getElementById(id);
			var doc = i.contentDocument ? i.contentDocument : i.contentWindow.document;
			doc.open();
			doc.write("");
			doc.close();
			Remove(i);
			if(this.callbacks[id]) this.callbacks[id](js);
		}
		catch(e) {ThrowException(e,'ill.Completed')}
	},

	General : function(js)
	{
		//alert(js)
		try
		{
			eval(js);
		}
		catch(e)
		{
		//ThrowException(e,'ill.General')
		}
	}
};
function ThrowException(e,o)
{
	alert("An error occurred in execution from function ["+o+"]\n\nMessage:\n"+e.message);
}



var Hook = {lsn : [],mc : null,mcS : null,mm : null,mmS : null,
Into : function(e,callback)	{if(Hook.lsn[e]) Hook.lsn[e].push(callback);else Hook.lsn[e] = [callback];},
Start : function(){	document.onmousedown = Hook._MouseDown;	document.onmousemove = Hook._MouseMove;	document.onmouseup 	= Hook._MouseUp;	document.onmouseup 	= Hook._MouseUp;	document.ondblclick	= Hook._MouseDblClick;		document.onload		= Hook._Load;	window.onresize		= Hook._Resize;	window.onscroll		= Hook._Scroll;	},
_MouseDown : function(evt){	Hook.mc = Mouse(evt);	return Hook.__P("mousedown",evt);},
_MouseMove : function(evt){Hook.mm = Mouse(evt);	Hook.__P("mousemove",evt);},
_MouseUp : function(evt){Hook.__P("mouseup",evt);},
_MouseDblClick : function(evt){Hook.__P("dblclick",evt);},
_KeyDown : function(evt){Hook.__P("keydown",evt);},
_Load : function(evt){Hook.__P("load",evt);},
_Resize : function(evt){Hook.__P("resize",evt);},
_Scroll : function(evt){Hook.__P("scroll",evt);},
__P : function(e,evt){var ret = true;if(Hook.lsn[e]){for(var i=0;i<Hook.lsn[e].length;i++){var b = Hook.lsn[e][i](evt);if(b == false) ret = false;}}return ret;}
};
Hook.Start();


function over(o) { o.src = o.src.replace(".gif","-.gif"); }
function out(o) { o.src = o.src.replace("-.gif",".gif"); }

function array_remove(array,item)
{
	for(i=0;i<array.length;i++)
	{
		if(array[i] == item)
		{
			array.splice(i,1);
			break;
		}
	}
}
function array_contains(array,it)
{
	for(i=0;i<array.length;i++) if(array[i] == it) return true;
	return false;
}
function trim(s)
{
	if(s == null) return s;
	while(s.indexOf(" ","") != -1) s = s.replace(" ","");
	return s.toString();
}
function htrim(s)
{
	if(s == null) return s;
	while(s.indexOf(" ","") != -1) s = s.replace(" ","");
	while(s.indexOf(";","") != -1) s = s.replace(";","");
	while(s.indexOf('"',"") != -1) s = s.replace('"',"");
	while(s.indexOf("'","") != -1) s = s.replace("'","");
	return s.toString();
}
function isEmpty(s)
{
	var t = trim(s.toString());
	if(t.length == 0) return true;
	return false;
}

function classover(evt)
{
	var o = Event(evt);
	var t = Test.Up(o,"getAttribute('button')","true");
	if(t) o = t;
	o.className = o.getAttribute("hoverclass");
}
function classout(evt)
{
	var o = Event(evt);
	var t = Test.Up(o,"getAttribute('button')","true");
	if(t) o = t;
	o.className = o.getAttribute("regclass");
}
function CleanHTML(s)
{
	d = s.toString();
	d = d.replace(/\s*style=.+>/gi,">");
	d = d.replace(/\s*class=.+>/gi,">");
	d = d.replace(/<\/*[A-Za-z]+:[A-Za-z]+>/gi,"");
	return d;
}