// $Id: function.js,v 1.18 2007/05/02 16:57:24 hg Exp $ 

func=new Object();d=document;if(d.layers)d.captureEvents(Event.MOUSEMOVE);d.onmousemove=function(e){var i,mX,mY,z;i=e||0;e=e||event;mX=(i)?e.pageX:e.clientX+d.body.scrollLeft;mY=(i)?e.pageY:e.clientY+d.body.scrollTop;z=true;return z;}
func.domLoad=new Array();func.onLoad=new Array();func.domLoadRegistered=new Array();func.onLoadRegistered=new Array();func.onLoadAdd=function(f){if(!isNaN(func.onLoadRegistered[f]))return;func.onLoadRegistered[f]=func.onLoad.length;func.onLoad.push(f);}
func.domLoadAdd=function(f){if(!isNaN(func.domLoadRegistered[f]))return;func.domLoadRegistered[f]=func.domLoad.length;func.domLoad.push(f);}
func.domLoadAdd('runTags');func.onLoadDel=function(f){if(isNaN(func.onLoadRegistered[f]))return;func.onLoad[func.onLoadRegistered[f]]="";func.onLoadRegistered[f]="deleted";}
func.domLoadDel=function(f){if(isNaN(func.domLoadRegistered[f]))return;func.domLoad[func.domLoadRegistered[f]]="";func.domLoadRegistered[f]="deleted";}
func.domLoaded=function(e){var f;if(func.domLoadedStarted)return;func.domLoadedStarted=true;for(var i in func.domLoad)if(i>0&&func.domLoad[i]){f=func.domLoad[i];func.domLoad[i]="";func.domLoadRegistered[f]="done";eval(f+"(e);");}
f=func.domLoad[0];func.domLoad[0]="";func.domLoadRegistered[f]="done";if(f)eval(f+"(e);");};window.onload=function(e){var f;if(func.onLoadedStarted)return;func.onLoadedStarted=true;func.domLoaded()
for(var i in func.onLoad)if(func.onLoad[i]){f=func.onLoad[i];func.onLoad[i]="";func.onLoadRegistered[f]="done";eval(f+"(e);");}};if(document.addEventListener){document.addEventListener("DOMContentLoaded",func.domLoaded,false);}
function func_addSomething(func_super,func_sub){var of,regex,end="return z;",endRex=eval("/return\\sz;\\s*$/");if(func_super=="load"){func.domLoadAdd(func_sub);return;}
func_super=((func_super=="mousemove")?"document.":"window.")+"on"+func_super;eval("of="+func_super+"+''")
if(of=="undefined"||of=="null")of="{var z=true;"+end+"}";of=of.match(/\{([^\}]*)/);of=of[1]
regex=eval("/z\\s*=\\s*z\\s*&&\\s*\\!\\("+func_sub+"\\(/");if(of.search(regex)!=-1)return;switch(func_super){case'document.onmousemove':func_sub+="(mX,mY)";break;default:func_sub+="(e)";}
eval(func_super+"=function(e){"+of.substring(0,of.search(endRex))+"z=z&&!("+func_sub+"==false);"+end+"}")}
function func_removeSomething(func_super,func_sub){if(func_super=="load"){func.onLoadDel(func_sub);return;}
var of,regex;func_super=((func_super=="mousemove")?"document.":"window.")+"on"+func_super;eval("of="+func_super+"+''")
if(of=="undefined")return;regex=eval("/z\\s*=\\s*z\\s*&&\\s*\\!\\("+func_sub+"\\([^;]*./");of=of.replace(regex,"");eval(func_super+"="+of)}
function replacePlaceholder(txt,values){if(!values)return txt;var regexstr,regex;if(!(values.constructor+"").match(/Array/)){values=new Array(""+values)}
for(var i=0;i<values.length;i++){regexstr="/\\!\\+"+i+"\\-\\!/"
regex=eval(regexstr);while(regex.exec(txt)){txt=txt.replace(eval(regexstr),values[i]);}}
return txt;}
function addRunTagFunc(tag,func){if(!ttr[tag]||ttr[tag]=="undefined"||ttr[tag]=="null")ttr[tag]=Array();ttr[tag].push(func);ttrDo=1;}
var ttr=Array();var ttrDo=0;runTags=function(){while(ttrDo){ttrDo=0;for(var i in ttr)if(ttr[i]){var x=d.getElementsByTagName(i);eval("var tf=function(tag){"+ttr[i].join(";")+"}");for(var j in x)if(j!='namedItem'&&j!='item'&&j!='length')tf(x[j]);ttr[i]=0;}}}
function standardizeEvent(e){if(!e.stopPropagation)e.stopPropagation=new Function('this.cancelBubble=true');if(!e.preventDefault)e.preventDefault=new Function('this.returnValue=true');if(typeof e.layerX=='undefined'&&typeof e.offsetX=='number'){e.layerX=e.offsetX;e.layerY=e.offsetY;};if(typeof e.pageX=='undefined'&&typeof e.clientX=='number'&&typeof document.body.scrollLeft=='number'){e.pageX=e.clientX+document.body.scrollLeft;e.pageY=e.clientY+document.body.scrollTop;};if(!e.target&&e.srcElement){e.target=e.srcElement;e.relatedTarget=null;if(e.type=='mouseout')e.relatedTarget=e.toElement;else if(e.type=='mouseover')e.relatedTarget=e.fromElement;}
if(e.target.nodeType==3)e.target=e.target.parentNode;}
function isParentNode(parent,child,iterationes){if(!child||!child.parentNode||!iterationes)return false
if(child.parentNode==parent)return true
return isParentNode(parent,child.parentNode,iterationes-1)}
function onMouseReally(object,event,iterationes){var e=event,i=iterationes,t=object;return(e.target==t||isParentNode(t,e.target,i))&&t!=e.relatedTarget&&!isParentNode(t,e.relatedTarget,i)}
function preloadImg(src,h,w){var x=document.createElement("img");x.src=src;if(h)x.height=h;if(w)x.width=w;return x;}
function_autoId=0;function getId(e){var id;if(!e.id){do id="auto_"+(function_autoId++);while(d.getElementById(id))
e.id=id;}
return e.id;}
function shuffleArray(array){this.ao=array;this.hasNext=function(){if(this.ac.length==0){this.i=null;return false}
this.i=this.ac.pop()
return true;}
this.getCurrent=function(){if(this.i===null)return null
return this.ao[this.i];}
this.reset=function(){this.ac=new Array();for(var i=0;i<this.ao.length;i++){if(Math.round(Math.random()))this.ac.push(i)
else this.ac.unshift(i)}
this.i=null}
this.reset();}
function cosCurve(fraction){return Math.min(1,Math.max(0,1-Math.cos(fraction*Math.PI*0.5)))}
function sinCurve(fraction){return 1-Math.min(1,Math.max(0,1-Math.sin(fraction*Math.PI*0.5)))}
function aufAbCurve(fraction){return 1-Math.min(1,Math.max(0,0.5*(Math.cos(fraction*Math.PI)+1)))}
function ArrayLX(){var arr=new Array();var current=null;var currentNo=0;this.add=function(e){if(!arr.length)current=e;e.arrayLX_pos=arr.length;arr[arr.length]=e;return arr.length;}
this.getLength=function(){return arr.length}
this.getCurrent=function(){return current}
this.getCurrentNo=function(){currentNo}
this.getNext=function(){if(!arr.length)return null;if(++currentNo>=arr.length)currentNo=0;return current=arr[currentNo];}
this.getRandom=function(){if(arr.length==1)return current;var rand=Math.round(Math.random()*(arr.length-2));currentNob=currentNo;currentNo=(rand>=currentNo)?rand+1:rand;return current=arr[currentNo];}
this.getThisNo=function(no){if(!isNaN(no)&&arr[no])currentNo=no;return current=arr[currentNo];}
this.getThisElement=function(e){if(e&&arr[e.arrayLX_pos])currentNo=e.arrayLX_pos;return current=arr[currentNo];}}
function nodeInsertAfter(node,after){if(!after.parentNode||node===after||!node.nodeType)return;if(after.parentNode.lastChild===after){after.parentNode.appendChild(node);}else{after.parentNode.insertBefore(node,after.nextSibling);}}
