




/*This too is very sad that this isn't part of the DOM core functionality. But hey, it makes for fun references like this! This function however isn't quite a function; it's a prototype that extends the DOM Array object. I remember one day thinking to myself surely I can do this in PHP, it's gotta be in JavaScript. Well, this extension makes it work just like you'd expect if you're a PHP developer.*/
/*Array.prototype.inArray = function (value) {
	for (var i=0; i < this.length; i++) if (this[i] === value) return true;
	return false;
};*/
function getfreeslot(slotsarray,dupid) {
	if (dupid!='') for (var c1=0;c1<=slotsarray.length-1;c1++) if (slotsarray[c1]==dupid) return c1;
	for (var c1=0;c1<=slotsarray.length-1;c1++) if (slotsarray[c1]==-1) return c1;
	return -1;
}





/*
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();
	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;
}
/*
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 getElementsByClass(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 eleexists(eleid) {
	if (document.getElementById(eleid)) return true;
	else return false;
}
function finddupid() {
	var allele=document.getElementsByTagName("*");
	for (var c1=0;c1<=allele.length-1;c1++) {
		for (var c2=0;c2<=allele.length-1;c2++) {
			if (allele[c1].id&&allele[c2].id&&allele[c1].id==allele[c2].id&&c1!=c2) {
				alert('! DUP ID FOUND: '+allele[c1].id+' !');
				return;
			}
		}
	}
	alert('[ NO DUP ID FOUND ]');
}





function addele(peleid,beforeid,tag) {
	var pele=0; if (peleid&&peleid!='') pele=document.getElementById(peleid); else pele=document.body;
	var bele=0; if (beforeid&&beforeid!='') bele=document.getElementById(beforeid);
	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);
		for (var c1=3;c1<=ar.length-1;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 copyele(eleid,targetparentid,beforeid,newid,removeoele) {
	var ele=document.getElementById(eleid);
	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);
	}
	var tp=document.getElementById(targetparentid);
	var bele=0; if (beforeid&&beforeid!='') bele=document.getElementById(beforeid);
	if (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 removeele(eleid) {
	var ele=document.getElementById(eleid);
	var pele=0; if (ele.parentNode) pele=ele.parentNode; else if (ele.parentElement) pele=ele.parentElement;
	if (pele&&ele) pele.removeChild(ele);
}
function emptyele(nodeid) {
	var node=document.getElementById(nodeid);
	if (node.hasChildNodes()) while (node.childNodes.length>=1) node.removeChild(node.firstChild);
}





function getatt(eleid,att) {
	return document.getElementById(eleid).getAttribute(att);
}
function addatt(eleid,att,val) {
	var ele=document.getElementById(eleid);
	var natt=document.createAttribute(att);
	natt.nodeValue=val;
	ele.setAttributeNode(natt); 
}
function setatt(eleid,att,val) {
	var ele=document.getElementById(eleid);
	if (ele.getAttribute(att)==null||ele.getAttribute(att)==''||!ele.getAttribute(att)) addatt(eleid,att,val);
	else ele.setAttribute(att,val);
}
function getstyle(eleid) {
	var ele=document.getElementById(eleid);
	if (isie()&&ele.style.cssText!=null) return ele.style.cssText;
	else return ele.getAttribute('style');
}
function addstyle(eleid,styletext) {
	var ele=document.getElementById(eleid);
	var ostyletext='';
	if (isie()&&ele.style.cssText!=null) { ostyletext=ele.style.cssText; ele.style.cssText=ostyletext+styletext; }
	else { ostyletext=ele.getAttribute('style'); setatt(eleid,'style',ostyletext+styletext); }
}
function setstyle(eleid,styletext) {
	var ele=document.getElementById(eleid);
	if (isie()&&ele.style.cssText!=null) ele.style.cssText=styletext;
	else setatt(eleid,'style',styletext);
}
function addevent(ele,type,fn) {
	var obj=(typeof ele=='string')?document.getElementById(ele):ele;
	if (obj.attachEvent) {
		obj['e'+type+fn]=fn;
		obj[type+fn]=function(){obj['e'+type+fn](window.event);}
		obj.attachEvent('on'+type,obj[type+fn]);
	} else obj.addEventListener(type,fn,false);
}
function removeevent(ele,type,fn) {
	var obj=(typeof ele=='string')?document.getElementById(ele):ele;
	if (obj.detachEvent) {
		obj.detachEvent('on'+type,obj[type+fn]);
		obj[type+fn]=null;
		obj['e'+type+fn]=null;
	} else obj.removeEventListener(type,fn,false);
}
var ehfunc=new Array();
var eheleid=new Array();
var ehtrigger=new Array();
var ehtotal=100;
for (var c1=0;c1<=ehtotal-1;c1++) {
	ehfunc[c1]=-1;
	eheleid[c1]=-1;
	ehtrigger[c1]=-1;
}
function getnewehid() {
	return getfreeslot(ehfunc,'');
}
function addeventv2(ehid,eleid,type,fn) {
	if (ehid==-1) return;
	ehfunc[ehid]=fn;
	eheleid[ehid]=eleid;
	ehtrigger[ehid]=type;
	var obj=(typeof eheleid[ehid]=='string')?document.getElementById(eheleid[ehid]):eheleid[ehid];
	if (obj.attachEvent) obj.attachEvent('on'+ehtrigger[ehid],ehfunc[ehid]);
	else obj.addEventListener(ehtrigger[ehid],ehfunc[ehid],false);
}
function removeeventv2(ehid) {
	if (ehid==-1) return;
	var obj=(typeof eheleid[ehid]=='string')?document.getElementById(eheleid[ehid]):eheleid[ehid];
	if (obj.detachEvent) obj.detachEvent('on'+ehtrigger[ehid],ehfunc[ehid]);
	else obj.removeEventListener(ehtrigger[ehid],ehfunc[ehid],false);
	ehfunc[ehid]=-1;
	eheleid[ehid]=-1;
	ehtrigger[ehid]=-1;
}
function preventdefault(evt){
    var e=evt?evt:window.event;
    if (e.preventDefault) e.preventDefault();
    else e.returnValue=false;
}
function stoppropagation(evt){
    var e=evt?evt:window.event;
    if (e.stopPropagation) e.stopPropagation();
    else e.cancelBubble=true;
} 
function gethtml(eleid) {
	return document.getElementById(eleid).innerHTML;
}
function addhtml(eleid,html) {
	document.getElementById(eleid).innerHTML=document.getElementById(eleid).innerHTML+html;
}
function sethtml(eleid,html) {
	document.getElementById(eleid).innerHTML=html;
}





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();
}
// random no
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 iseven(no) {
	if (no%2) return false;
	else return true;
}
function isinrange(no,lbound,ubound) {
	if (no>=lbound&&no<=ubound) return true;
	else return false;
}





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 isempty(str) {
	if (str==null||str=='') return true;
	else return false;
}
function isinstring(str,strsearch) {
	if (str.search(strsearch)!=-1) return true;
	else return false;
}
function makemsg() {
	var ar=arguments; var entry=''; var msg=''; var compound='';
	for (var c1=0;c1<=ar.length-1;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);
}





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 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-1;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-1;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-1;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);
}
//Gets the browser specific XmlHttpRequest Object
var ajrq=getajrq();
function getajrq() {
	if (window.XMLHttpRequest) return new XMLHttpRequest(); //Not IE
	else if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP'); //IE
	else alert('Your browser does not support the XmlHttpRequest object.');
}			
function postajrq(aj,rurl,rparams,onreceive) {
	if (aj==0) aj=ajrq;
	if (!(aj.readyState==4||aj.readyState==0)) return; //If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call.
	showld();
	aj.open('POST',rurl,true);
	//aj.open("GET","db.php?qid=news",true);
	aj.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	aj.setRequestHeader('Content-length',rparams.length);
	aj.setRequestHeader('Connection','close');
	aj.onreadystatechange=function(){ if(aj.readyState==4&&aj.status==200&&onreceive&&onreceive!=''){ onreceive(aj.responseText);hideld(); }};
	aj.send(rparams);
	//aj.send(null);
}
function postajdiv(aj,rurl,rparams,divid) {
	postajrq(aj,rurl,rparams,function(ajrp){document.getElementById(divid).innerHTML=ajrp;});
}





// 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 .. ? */ }}
}




