




function isdefined(varobj) {
	if(typeof(varobj)=='undefined') return false;
	else return true;
}
function isempty(varobj) {
	if(typeof(varobj)=='undefined') return true;
	else if(varobj==null||varobj=='') return true;
	else return false;
}
function isfunction(varobj) {
	if(typeof(varobj)=='function') return true;
	else return false;
}
function isobject(varobj) {
	if(varobj!=null&&varobj!=''&&typeof(varobj)=='object') return true;
	else return false;
}
/*Array.prototype.inArray=function(value) {
	for(var i=0;i<this.length;i++) if(this[i]===value) return true;
	return false;
};*/
function isinarray(ar,val) {
	var i=0; for(i=0;i<ar.length;i++) if(ar[i]===value) return true;
	return false;
}
function inheritclass(base,derived) {
	eval(derived+'.prototype=new '+base+'();');
	eval(derived+'.prototype.constructor='+derived+';');
}
function getfreeslot(slotsarray,dupid) {
	var c1=0;
	if(dupid) for(c1=0;c1<slotsarray.length;c1++) if(slotsarray[c1]==dupid) return c1;
	for(c1=0;c1<slotsarray.length;c1++) if(slotsarray[c1]==-1) return c1;
	return -1;
}





function isnum(val) {
	if(val==''||val==null||isNaN(val)) return false;
	else return true;
}
function iseven(num) {
	if(num%2) return false;
	else return true;
}
function isfloat(num) {
	if(isNaN(num)||num.indexOf(".")<0) return false;
	else if(parseFloat(num)) return true;
	return false;
}
function isinrange(num,lbound,ubound) {
	if(num>=lbound&&num<=ubound) return true;
	else return false;
}
var lastrandno=-1;
function getrandnov1(minno,maxno) {
	var thisrandno=Math.floor((maxno-(minno-1))*Math.random())+minno;
	while (thisrandno==lastrandno) thisrandno=Math.floor((maxno-(minno-1))*Math.random())+minno;
	lastrandno=thisrandno;
	return thisrandno;
}
function getrandno(minno,maxno) {
	var tempresult=0;
	var tempcounter1=0;
	// prevent duplicated no and out of range
	while (tempresult==0||tempresult==lastrandno||tempresult<minno||tempresult>maxno) {
		tempcounter1=Math.abs(Math.round(Math.random()*(10-1))+1);
		for (var i=0;i<tempcounter1;i++) tempresult=Math.abs(Math.round(Math.random()*(maxno-minno))+minno);
	}
	lastrandno=tempresult; // update last generated no
	return tempresult;
}
function getdate() {
	var d = new Date();
	return d.getDate();
}
function getmonth() {
	var d = new Date();
	return d.getMonth();
}
function getyear() {
	var d = new Date();
	return d.getFullYear();
}





function isstring(varobj) {
	if(varobj&&typeof(varobj)=='string') return true;
	else return false;
}
function isinstring(str,strsearch) {
	if(str.search(strsearch)!=-1) return true;
	else return false;
}
function getsubstrlr(str,start,len) {
	return str.substr(start+1,len);
}
function getsubstrrl(str,start,len) {
	return str.substr(str.length-start-(len-1),len);
}
/*function strgreplace(str,with) {
	eval("str.replace(/       "+str+"        /g,with);");
}
function strcireplace(str,with) {
	eval("str.replace(/        "+str+"       /i,with);");
}
function strgcireplace(str,with) {
	eval("str.replace(/          "+str+"       /gi,with);");
}*/
function fixsquote(input) {
	return input.replace(/'/g,'&prime;');
}
function fixdquote(input) {
	return input.replace(/"/g,'&quot;');
}
function fixcr(input) { // Converts carriage returns to <BR> for display in HTML
	var output='';
	for (var i=0;i<input.length;i++) {
		if ((input.charCodeAt(i)==13)&&(input.charCodeAt(i+1)==10)) { i++; output+='<BR>'; }
		else { output+=input.charAt(i); }
	}
	return output;
}
function makemsg() {
	var ar=arguments; var entry=''; var msg=''; var compound='';
	for (var c1=0;c1<ar.length;c1++) {
		entry=ar[c1].substr(0,ar[c1].indexOf('='));
		msg=ar[c1].substr(entry.length+1,ar[c1].length-entry.length-1);
		compound=compound+entry+'='+msg+entry+'EnD';
	}
	return compound;
}
//messages is combined this way:
//entry name + "=" + message text + entry name+"EnD"
//e.g. "EntrY1=msg1EntrY1EnDEntrY2=msg2EntrY2EnDEntrY3=msg3EntrY3EnD"
function extractmsg(msg,entry) {
	var startpos=0; var endpos=0;
	var startentry=entry+'=';
	var endentry=entry+'EnD';
	startpos=msg.indexOf(startentry)+startentry.length;
	endpos=msg.indexOf(endentry);
	return msg.substr(startpos,endpos-startpos);
}
function extractfileext(path) {
	return path.substring(path.lastIndexOf('.')+1,path.length);
}





function isele(varobj) {
	if(varobj&&typeof(varobj)=='object') if(typeof(varobj.style)!='undefined') return true;
	return false;
}
function eleexists(eleid) {
	if(!eleid) return false;
	else return document.getElementById(eleid);
}
function getverifyele(varobj) {
	if(typeof(varobj)=='string') return document.getElementById(varobj);
	else if(isele(varobj)) return varobj;
	else return false;
}
function getelebyid(eleid) {
	return document.getElementById(eleid);
}
function getelebyname(elename) {
	return document.getElementsByName(elename);
}
function getelebytag(tag) {
	return document.getElementsByTagName(tag);
}
/*
The dollar functions is a simple way to grab an element quickly. So instead of document.getElementById('a');, you'd simply just do this instead:$('a');
And if you wanted a whole collection of elements, you can simply do this: $('a','b',obj,obj2,'c','d');
*/
function $() {
	var elements=new Array();
	var i=0; for(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;
}
/*
This function was spawned from developers needing a quick and elegant way of grabbing elements by a className
Simply add a class name to the beginning of the funciton and the 2nd and 3rd arguments are optional and the magic is done for you!
*/
function getelebyclass(searchClass,node,tag) {
	var classElements=new Array();
	if(node==null) node=document;
	if(tag==null) tag='*';
	var els=node.getElementsByTagName(tag);
	var elsLen=els.length;
	var pattern=new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for(i=0,j=0;i<elsLen;i++) {
		if(pattern.test(els[i].className)) {
			classElements[j]=els[i];
			j++;
		}
	}
	return classElements;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function finddupid() {
	var allele=document.getElementsByTagName('*');
	for (var c1=0;c1<allele.length;c1++) {
		for (var c2=0;c2<allele.length;c2++) {
			if (allele[c1].id&&allele[c2].id&&allele[c1].id==allele[c2].id&&c1!=c2) {
				debugmsg('DUP ID FOUND: '+allele[c1].id+' !');
				//alert('DUP ID FOUND: '+allele[c1].id+' !');
				return;
			}
		}
	}
	alert('[ NO DUP ID FOUND ]');
}





function isnewele(ele) {
	if(isempty(ele)) return false;
	else if(!isdefined(ele.eletype)) return false;
	else if(ele.eletype>=1) return true;
	return false;
}

function newele(ele) {
	if(typeof(ele)=='undefined') return false;
	else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(!ele) return false;
	if(typeof(ele.eletype)!='undefined') return ele;
	ele.eletype=1;

	ele.isfont=eleisfont;
	ele.isa=eleisa;
	ele.isimg=eleisimg;
	ele.isspan=eleisspan;
	ele.isdiv=eleisdiv;
	ele.istable=eleistable;
	ele.istr=eleistr;
	ele.istd=eleistd;
	
	ele.getatt=elegetatt;
	ele.addatt=eleaddatt;
	ele.setatt=elesetatt;
	ele.swapatt=eleswapatt;
	
	ele.getclass=elegetclass;
	ele.setclass=elesetclass;
	ele.swapclass=eleswapclass;
	
	ele.getstyle=elegetstyle;
	ele.addstyle=eleaddstyle;
	ele.setstyle=elesetstyle;
	ele.swapstyle=eleswapstyle;
	
	ele.addevent=eleaddevent;
	ele.removeevent=eleremoveevent;
	
	ele.gethtml=elegethtml;
	ele.addhtml=eleaddhtml;
	ele.sethtml=elesethtml;
	ele.swaphtml=eleswaphtml;
	
	ele.getelebyname=elegetelebyname;
	ele.getelebytag=elegetelebytag;
	ele.addnode=eleaddnode;
	ele.copynode=elecopynode;
	ele.emptynode=eleemptynode;
	ele.removenode=eleremovenode;
	
	return ele;
}

function eleisfont(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.tagName.toLowerCase()=='font') return true;
	else return false;
}
function eleisa(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.tagName.toLowerCase()=='a') return true;
	else return false;
}
function eleisimg(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.tagName.toLowerCase()=='img') return true;
	else return false;
}
function eleisspan(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.tagName.toLowerCase()=='span') return true;
	else return false;
}
function eleisdiv(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.tagName.toLowerCase()=='div') return true;
	else return false;
}
function eleistable(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.tagName.toLowerCase()=='table') return true;
	else return false;
}
function eleistr(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.tagName.toLowerCase()=='tr') return true;
	else return false;
}
function eleistd(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.tagName.toLowerCase()=='td') return true;
	else return false;
}

function elegetatt(att,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	return ele.getAttribute(att);
}
function eleaddatt(att,val,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	var natt=document.createAttribute(att);
	natt.nodeValue=val;
	ele.setAttributeNode(natt); 
}
function elesetatt(att,val,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.getAttribute(att)==null||ele.getAttribute(att)==''||!ele.getAttribute(att)) eleaddatt(att,val,ele);
	else ele.setAttribute(att,val);
}
function eleswapatt(att,thatele,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(typeof(thatele)=='string') thatele=document.getElementById(thatele); if(!thatele) return;
	var thisatt=elegetatt(att,ele);
	elesetatt(att,elegetatt(att,thatele),ele);
	elesetatt(att,thisatt,thatele);
}

function elegetclass(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(typeof(ele.className)!='undefined') return ele.className;
	else if(ele.getAttribute('class').length>ele.getAttribute('className').length) return ele.getAttribute('class');
	else if(ele.getAttribute('className').length>=ele.getAttribute('class').length) return ele.getAttribute('className');
}
function elesetclass(classname,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(typeof(ele.className)!='undefined') ele.className=classname;
	else { ele.setAttribute('className',classname); ele.setAttribute('class',classname); }
}
function eleswapclass(thatele,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(typeof(thatele)=='string') thatele=document.getElementById(thatele); if(!thatele) return;
	var thisclass=elegetclass(ele);
	elesetclass(elegetclass(thatele),ele);
	elesetclass(thisclass,thatele);
}

function elegetstyle(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if (isie()&&ele.style.cssText!=null) return ele.style.cssText;
	else return ele.getAttribute('style');
}
function eleaddstyle(styletext,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	var ostyletext='';
	if (isie()&&ele.style.cssText!=null) { ostyletext=ele.style.cssText; ele.style.cssText=ostyletext+styletext; }
	else { ostyletext=ele.getAttribute('style'); ele.setAttribute('style',ostyletext+styletext); }
}
function elesetstyle(styletext,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if (isie()&&ele.style.cssText!=null) ele.style.cssText=styletext;
	else ele.setAttribute('style',styletext);
}
function eleswapstyle(thatele,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(typeof(thatele)=='string') thatele=document.getElementById(thatele); if(!thatele) return;
	var thisstyle=elegetstyle(ele);
	elesetstyle(elegetstyle(thatele),ele);
	elesetstyle(thisstyle,thatele);
}

function eleaddevent(type,fn,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.attachEvent) {
		ele['e'+type+fn]=fn;
		ele[type+fn]=function(){ele['e'+type+fn](window.event);};
		//ele[type+fn]=function(){fn(window.event);};
		return ele.attachEvent('on'+type,ele[type+fn]);
	} else if(ele.addEventListener) {
		ele[type+fn]=fn;
		return ele.addEventListener(type,ele[type+fn],false);
	} else { ele['on'+type]=fn; return true; }
}
function eleremoveevent(type,fn,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	var rcode=0;
	if(ele.detachEvent) {
		rcode=ele.detachEvent('on'+type,ele[type+fn]);
		ele['e'+type+fn]=null;
		ele[type+fn]=null;
	} else if(ele.removeEventListener) {
		rcode=ele.removeEventListener(type,ele[type+fn],false);
		ele[type+fn]=null;
	} else { ele['on'+type]=null; rcode=1; }
	return rcode;
}

function elegethtml(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	return ele.innerHTML;
}
function eleaddhtml(html,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	ele.innerHTML+=html;
}
function elesethtml(html,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	ele.innerHTML=html;
}
function eleswaphtml(thatele,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(typeof(thatele)=='string') thatele=document.getElementById(thatele); if(!thatele) return;
	if(ele.innerHTML==thatele.innerHTML) return;
	var thishtml=ele.innerHTML;
	ele.innerHTML=thatele.innerHTML;
	thatele.innerHTML=thishtml;
}

function elegetelebyname(elename,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	return ele.getElementsByName(elename);
}
function elegetelebytag(tag,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	return ele.getElementsByTagName(tag);
}
function eleaddnode(pele,bele,tag) {
	if(!pele) pele=this; else if(typeof(pele)=='string') pele=document.getElementById(pele);
	if(bele) if(typeof(bele)=='string') bele=document.getElementById(bele);
	var ar=arguments; var att=''; var val='';
	var nele=0;
	if(tag=='text'&&ar[3]&&ar[3]!='') nele=document.createTextNode(ar[c3]);
	if(tag!='text'){ nele=document.createElement(tag); var c1=0;
		for(c1=3;c1<ar.length;c1++){ if(ar[c1].search('=')!=-1){
			att=ar[c1].substr(0,ar[c1].indexOf('='));
			val=ar[c1].substr(att.length+1,ar[c1].length-att.length-1);
			if(att.toLowerCase()=='style'&&isie()&&nele.style.cssText!=null) nele.style.cssText=val;
			if(!(att.toLowerCase()=='style'&&isie())) {
				if(nele.getAttribute(att)==null||nele.getAttribute(att)==''||!nele.getAttribute(att)) {
					var natt=0; natt=document.createAttribute(att); natt.nodeValue=val; nele.setAttributeNode(natt);
				} else nele.setAttribute(att,val);
			}
		}}
	}
	if(bele) pele.insertBefore(nele,bele);
	else pele.appendChild(nele);
}
/*function insertAfter(parent,node,referenceNode) {
	parent.insertBefore(node,referenceNode.nextSibling);
}*/
function elecopynode(tp,bele,newid,removeoele,ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(typeof(tp)=='string') tp=document.getElementById(tp);
	var eleclone=ele.cloneNode(true);
	if(newid&&newid!='') {
		if(eleclone.getAttribute('id')==null||eleclone.getAttribute('id')==''||!eleclone.getAttribute('id')) {
			var nid=0; nid=document.createAttribute('id'); nid.nodeValue=newid; eleclone.setAttributeNode(nid);
		} else eleclone.setAttribute('id',newid);
	}
	if(bele){ if(typeof(bele)=='string') bele=document.getElementById(bele);
		tp.insertBefore(eleclone,bele);
	} else tp.appendChild(eleclone);
	var op=0; if(ele.parentNode) op=ele.parentNode; else if(ele.parentElement) op=ele.parentElement;
	if(op&&removeoele) op.removeChild(ele);
}
function eleemptynode(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	if(ele.hasChildNodes()) while(ele.childNodes.length>0) ele.removeChild(ele.firstChild);
}
function eleremovenode(ele) {
	if(!ele) ele=this; else if(typeof(ele)=='string') ele=document.getElementById(ele);
	var pele=0; if(ele.parentNode) pele=ele.parentNode; else if(ele.parentElement) pele=ele.parentElement;
	if(pele&&ele) pele.removeChild(ele);
}





function stopevent(e) {
   if(!e) if(window.event) e=window.event; else return;
   if(e.cancelBubble!=null) e.cancelBubble=true;
   if(e.stopPropagation) e.stopPropagation();
   if(e.preventDefault) e.preventDefault();
   if(window.event) e.returnValue=false;
   if(e.cancel!=null) e.cancel=true;
}
function preventdefault(e){
    if(!e) e=window.event;
    if(e.preventDefault) e.preventDefault();
    else e.returnValue=false;
}
function stoppropagation(e){
    if(!e) e=window.event;
    if(e.stopPropagation) e.stopPropagation();
    else e.cancelBubble=true;
}





var BrowserDetect={
	init: function() {
		this.browser=this.searchString(this.dataBrowser)||"An unknown browser";
		this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";
		this.OS=this.searchString(this.dataOS)||"an unknown OS";
	},
	searchString: function(data) {
		for(var i=0;i<data.length;i++) {
			var dataString=data[i].string;
			var dataProp=data[i].prop;
			this.versionSearchString=data[i].versionSearch||data[i].identity;
			if(dataString) { if(dataString.indexOf(data[i].subString)!=-1) return data[i].identity;
			} else if(dataProp) return data[i].identity;
		}
	},
	searchVersion: function(dataString) {
		var index=dataString.indexOf(this.versionSearchString);
		if(index==-1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]
};
var iever=-1;
function isie() {
	if(iever==-1) {
		BrowserDetect.init();
		iever=BrowserDetect.browser=='Explorer'?BrowserDetect.version:false;
	}
	return iever;
}
var nsver=-1;
function isns() {
	if(nsver==-1) {
		BrowserDetect.init();
		nsver=BrowserDetect.browser=='Netscape'?BrowserDetect.version:false;
	}
	return nsver;
}
var ffver=-1;
function isff() {
	if(ffver==-1) {
		BrowserDetect.init();
		ffver=BrowserDetect.browser=='Firefox'?BrowserDetect.version:false;
	}
	return ffver;
}
var safver=-1;
function issaf() {
	if(safver==-1) {
		BrowserDetect.init();
		safver=BrowserDetect.browser=='Safari'?BrowserDetect.version:false;
	}
	return safver;
}
var chrmver=-1;
function ischrm() {
	if(chrmver==-1) {
		BrowserDetect.init();
		chrmver=BrowserDetect.browser=='Chrome'?BrowserDetect.version:false;
	}
	return chrmver;
}





function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}
function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}





function hidelinkstatus() {
	var a=0;var c1=0;for(c1=0;c1<arguments.length;c1++) {
		a=arguments[c1];if(typeof(a)=='string')a=document.getElementById(arguments[c1]);
		a.onmouseover=function(){window.status='';return true};
		a.onmouseout=function(){window.status='';return true};
	}
}
function hidealllinkstatus() {
	var a=document.body.getElementsByTagName('a');
	var c1=0;for(c1=0;c1<a.length;c1++) {
		a[c1].onmouseover=function(){window.status='';return true};
		a[c1].onmouseout=function(){window.status='';return true};
	}
}





function urlencode(str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // %          note: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
    var histogram = {}, histogram_r = {}, code = 0, tmp_arr = [];
    var ret = str.toString();
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    // The histogram is identical to the one in urldecode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    return ret;
}
function postpage(a,t) {
	var bd=document.body;
	var d=document.createElement('div');
	d.style.visibility='hidden';
	var f=document.createElement('form');
	f.action=a; f.target=t; f.method="post";
	var ar=0; ar=arguments; var hname=''; var hval=''; var h=0;
	for (var c1=2;c1<arguments.length;c1++) {
		h=document.createElement('input'); h.type='hidden';
		hname=ar[c1].substr(0,ar[c1].indexOf('='));
		hval=ar[c1].substr(hname.length+1,ar[c1].length-hname.length-1);
		h.name=hname; h.value=hval;
		f.appendChild(h);
	}
	d.appendChild(f);
	bd.appendChild(d);
	f.submit();
}
function postf2m(f,submitf) {
	var fieldh=0; var hiddendone=0; var h=0;
	while (!hiddendone) {
		if (f.elements.length<=0) hiddendone=1;
		for (var c1=0;c1<f.elements.length;c1++) {
			fieldh=f.elements[c1];
			if (fieldh.type.toLowerCase()=='hidden'&&
				fieldh.name!='action'&&
				fieldh.name.substring(0,2)!='h_'&&
				fieldh.name.substring(0,5)!='fatt_') {
				h=document.createElement('input'); h.type='hidden'; h.name='h_'+fieldh.name; h.value=fieldh.value;
				f.removeChild(fieldh);
				f.appendChild(h);
				break;
			}
			if (c1==f.elements.length-1) hiddendone=1;
		}
	}
	var fieldatt=0; var field=0; var et='';
	var slice1=''; var slice2='';
	for (var c1=0;c1<f.elements.length;c1++) {
		if (f.elements[c1].name.substring(0,5)=='fatt_') {
			fieldatt=f.elements[c1];
			eval('field=f.'+fieldatt.name.replace('fatt_','')+';');
			et=fieldatt.value.substr(fieldatt.value.indexOf('_et_')+4);
			if (fieldatt.value.search('_rf')!=-1) {
				if (field.value==null||field.value=='') { alert('Please provide : ['+et+']'); return false; }
			}
			if (fieldatt.value.search('_n')!=-1) { if (field.value!=null&&field.value!='') {
				if (!isFinite(parseInt(field.value))) { alert('Must be number : ['+et+']'); return false; }
			} }
			if (fieldatt.value.search('_mincl')!=-1) { if (field.value!=null&&field.value!='') {
				slice1=fieldatt.value.substr(fieldatt.value.indexOf('_mincl')+6); slice2=slice1;
				if (slice1.search('_')!=-1) slice2=slice1.substr(0,slice1.indexOf('_'));
				if (field.value.length<parseInt(slice2)) { alert('Length not less than '+slice2+' : ['+et+']'); return false; }
			} }
			if (fieldatt.value.search('_maxcl')!=-1) { if (field.value!=null&&field.value!='') {
				slice1=fieldatt.value.substr(fieldatt.value.indexOf('_maxcl')+6); slice2=slice1;
				if (slice1.search('_')!=-1) slice2=slice1.substr(0,slice1.indexOf('_'));
				if (field.value.length>parseInt(slice2)) { alert('Length not more than '+slice2+' : ['+et+']'); return false; }
			} }
			if (fieldatt.value.search('_em')!=-1) { if (field.value!=null&&field.value!='') {
				if (field.value.search('@')==-1||field.value.search('.')==-1||field.value.length<5) { alert('Not an valid e-mail address : ['+et+']'); return false; }
			} }
		}
	}
	if (submitf) f.submit();
	return true;
}
function dl(path) {
	postpage('php/dl.php','_self','file=../'+path);
}





function newaj() {
	var aj=0;
	if(window.XMLHttpRequest) aj=new XMLHttpRequest();
	else if(window.ActiveXObject) aj=new ActiveXObject('Microsoft.XMLHTTP');
	else return -1;/*alert('Your browser does not support the XmlHttpRequest object.')*/;
	
	aj.rurl='';
	aj.rparam='';
	aj.targetdiv=0;
	
	aj.funcloading=function(){showloading('pudivloading0','','c','c');};
	/*aj.funcloading=0;*/
	aj.funcendloading=function(){hideloading('pudivloading0');};
	/*aj.funcendloading=0;*/
	aj.onreceive=0;
	
	aj.setrurl=ajsetrurl;
	aj.setrparam=ajsetrparam;
	aj.settargetdiv=ajsettargetdiv;
	aj.setfuncloading=ajsetfuncloading;
	aj.setfuncendloading=ajsetfuncendloading;
	aj.setonreceive=ajsetonreceive;
	
	aj.onreadystatechange=ajonstatechange;
	
	aj.get=ajget;
	aj.getdiv=ajgetdiv;
	aj.post=ajpost;
	aj.postdiv=ajpostdiv;
	
	aj.setloadingdiv=ajsetloadingdiv;
	aj.setendloadingdiv=ajsetendloadingdiv;
	aj.updatetargetdiv=ajupdatetargetdiv;
	
	return aj;
}

function ajonstatechange() {
	if(this.readyState==4&&this.status==200&&typeof(this.onreceive)=='function') {
		if(typeof(this.funcloading)=='function') this.funcloading();
		this.onreceive(this.responseText);
		if(typeof(this.funcendloading)=='function') this.funcendloading();
	}
}

function ajsetrurl(rurl) {
	this.rurl=rurl;
}
function ajsetrparam(rparam) {
	this.rparam=rparam;
}
function ajsettargetdiv(div) {
	this.targetdiv=newele(div);
}
function ajsetfuncloading(func) {
	if(typeof(func)=='function') this.funcloading=func;
}
function ajsetfuncendloading(func) {
	if(typeof(func)=='function') this.funcendloading=func;
}
function ajsetonreceive(func) {
	if(typeof(func)=='function') this.onreceive=func;
}

function ajget(rurl,onreceive) {
	if(!(this.readyState==4||this.readyState==0)) return;
	this.setrurl(rurl);
	this.setonreceive(onreceive);
	this.open("GET",this.rurl,true);
	this.onreadystatechange=function(){
		if(this.readyState==4&&this.status==200&&typeof(this.onreceive)=='function') {
			this.onreceive(this.responseText);
			if(typeof(this.funcendloading)=='function') this.funcendloading();
		}
	}
	if(typeof(this.funcloading)=='function') this.funcloading();
	this.send(null);
}
function ajgetdiv(rurl,div) {
	this.setrurl(rurl);
	if(div) this.settargetdiv(div);
	this.setfuncloading(this.setloadingdiv);
	this.setfuncendloading(this.setendloadingdiv);
	this.setonreceive(this.updatetargetdiv);
	this.get();
}

function ajpost(rurl,rparam,onreceive) {
	if(!(this.readyState==4||this.readyState==0)) return;
	this.setrurl(rurl);
	this.setrparam(rparam);
	this.setonreceive(onreceive);
	this.open('POST',this.rurl,true);
	this.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	this.setRequestHeader('Content-length',this.rparam.length);
	this.setRequestHeader('Connection','close');
	this.onreadystatechange=function(){
		if(this.readyState==4&&this.status==200&&typeof(this.onreceive)=='function') {
			this.onreceive(this.responseText);
			if(typeof(this.funcendloading)=='function') this.funcendloading();
		}
	}
	if(typeof(this.funcloading)=='function') this.funcloading();
	this.send(this.rparam);
}
function ajpostdiv(rurl,rparam,div) {
	this.setrurl(rurl);
	this.setrparam(rparam);
	if(div) this.settargetdiv(div);
	this.setfuncloading(this.setloadingdiv);
	this.setfuncendloading(this.setendloadingdiv);
	this.setonreceive(this.updatetargetdiv);
	this.post();
}

function ajsetloadingdiv() {
	if(this.targetdiv) {
		if(eleexists('pudivloading0')) {
			showloading('pudivloading0',this.targetdiv,30,30);
		} else {
			this.targetdiv.sethtml("<br><br><br><br><br><br>"+
				"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='gfx/loading/loadingv1.gif' /><br>"+
				"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size='3'>LOADING...</font>");
		}
	}
}
function ajsetendloadingdiv() {
	if(this.targetdiv) {
		if(eleexists('pudivloading0')) {
			hideloading('pudivloading0');
		} else {
		}
	}
}
function ajupdatetargetdiv(html) {
	if(this.targetdiv) this.targetdiv.sethtml(html);
}





// SuperSleight, version 1.1.0
// version 1.1.0 by Jeffrey Barke <http://themechanism.com/> 20071218
// Essential (99% of the) code by Drew McLellan <http://24ways.org/2007/supersleight-transparent-png-in-ie6>
var supersleight = function() {
	var root = false; var applyPositioning = true; var shim = 'x.gif'; // path to a transparent GIF image
	var fnLoadPngs = function() {
		if (root) { root = document.getElementById(root); } else { root = document; } // if supersleight.limitTo called, limit to specified id
		for (var i = root.all.length - 1, obj = null; (obj = root.all[i]); i--) {
			if (obj.currentStyle.backgroundImage.match(/\.png/i) !== null) { bg_fnFixPng(obj); } // background pngs
			if (obj.tagName == 'IMG' && obj.src.match(/\.png$/i) !== null) { el_fnFixPng(obj); } // image elements
			if (applyPositioning && (obj.tagName=='A'||obj.tagName=='a'||obj.tagName=='INPUT'||obj.tagName=='input') && obj.style.position==='') { obj.style.position='relative'; } // apply position to 'active' elements
		}
	};
	var bg_fnFixPng = function(obj) {
		var mode = 'scale'; var bg = obj.currentStyle.backgroundImage; var src = bg.substring(5,bg.length-2);
		if (obj.currentStyle.backgroundRepeat == 'no-repeat') { mode = 'crop'; }
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')";
		obj.style.backgroundImage = 'url(' + shim + ')';
	};
	var el_fnFixPng = function(img) {
		var src = img.src;
		img.style.width = img.width + 'px'; img.style.height = img.height + 'px';
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
		img.src = shim;
	};
	var addLoadEvent = function(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') { window.onload = func; }
		else { window.onload = function() { if (oldonload) { oldonload(); } func(); }; }
	};
	// supersleight object
	return {
		init: function(strPath, blnPos, strId) {
			if (document.getElementById) {
				if (typeof(strPath) != 'undefined' && null !== strPath) { shim = strPath; }
				if (typeof(blnPos) != 'undefined' && null !== blnPos) { applyPositioning = blnPos; }
				if (typeof(strId) != 'undefined' && null !== strId) { root = strId; }
				addLoadEvent(fnLoadPngs);
			} else { return false; }
		},
		limitTo: function(el) { root = el; },
		run: function(strPath, blnPos, strId) {
			if (document.getElementById) {
				if (typeof(strPath) != 'undefined' && null !== strPath) { shim = strPath; }
				if (typeof(blnPos) != 'undefined' && null !== blnPos) { applyPositioning = blnPos; }
				if (typeof(strId) != 'undefined' && null !== strId) { root = strId; }
				fnLoadPngs();
			} else { return false; }
		}
	};
}();
// limit to part of the page ... pass an ID to limitTo:
// supersleight.limitTo('top');
// optional path to a transparent GIF image, apply positioning, limitTo
/*
The init method of the supersleight object takes three optional parameters:
1. String path to the transparent gif file. Note this path is relative to the actual document, not the JavaScript document.
2. Boolean value to apply relative positioning to anchor and input elements. Pass false to leave the elements as they are.
3. String ID of an element to limit SuperSleight's operations to.
To call SuperSleight from a script, use the run method of the supersleight object. This method takes the same three optional parameters as the init method.
*/
//supersleight.init('gfx/fixie6png.gif',false);
function fixiepng(relpos,scope) {
	if (isie()) supersleight.run('gfx/fixie6png.gif',relpos,scope);
}
//var fixpaVersion = navigator.appVersion.split("MSIE");
//var fixpbversion = parseFloat(fixpaVersion[1]);
function fixiepngv1(imgid) {
	if (!isie()) return;
  //if ((fixpbversion >= 5.5) && (document.body.filters)) {
	var img=document.getElementById(imgid);
	if (img.tagName.toLowerCase()!='img') return;
	if (img.src.substring(img.src.length-3,img.src.length).toLowerCase()!="png") return;
	var cid=(img.id)?"id='"+img.id+"' ":"";
	var cclass=(img.className)?"class='"+img.className+"' ":"";
	var ctitle=(img.title)?"title='"+img.title+"' ":"title='"+img.alt+"' ";
	var cstyle=img.style.cssText+";";
	cstyle=cstyle+"display:inline-block;";
	cstyle=cstyle+"width:"+img.width+"px;";
	cstyle=cstyle+"height:"+img.height+"px;";
	if (img.align.toLowerCase()=="left") cstyle=cstyle+"float:left;";
	if (img.align.toLowerCase()=="right") cstyle=cstyle+"float:right;";
	if (img.parentElement.href) cstyle=cstyle+"cursor:hand;";
	cstyle=cstyle+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img.src+"', sizingMethod='scale');";
	var container="<span "+cid+cclass+ctitle+"style=\""+cstyle+"\"></span>";
	img.id=img.id+'pngfixed';
	img.outerHTML=container;
  //}
}
function fixiepngupdatesrcv1(cid,src) {
	var container=document.getElementById(cid);
	container.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')";
}
function fixiepngallv1() {
	if (!isie()) return;
  //if ((fixpbversion >= 5.5) && (document.body.filters)) {
	for(var i=0; i<document.images.length; i++) { fixiepngv1(document.images[i].id); }
  //}
}
function fixie6bgimg() {
	if (isie()==6) { try { document.execCommand("BackgroundImageCache",false,true); } catch(e) { /* just in case this fails .. ? */ }}
}





