//Copyright wwww.duniaupload.com 2010 for my best friend Jossanto
function $(){for(var a=0,b=[];a<arguments.length;++a){b.push(typeof arguments[a]=="string"?document.getElementById(arguments[a]):arguments[a])}return b.length==1?b[0]:b}function $A(c){if(!c){return[]}if(c.toArray){return c.toArray()}for(var b=0,a=[];b<c.length;++b){a.push(c[b])}return a}var Class={create:function(){return function(){this.initialize.apply(this,arguments)}}};Object.extend=function(a,b){for(p in b){a[p]=b[p]}return a};Function.prototype.bind=function(){var a=this,b=$A(arguments),c=b.shift();return function(){return a.apply(c,b.concat($A(arguments)))}};Function.prototype.bindAsEventListener=function(b){var a=this;return function(c){return a.call(b,c||window.event)}};Object.prototype.shift=function(){var a=this[0];this.length--;for(var b=0;b<this.length;++b){this[b]=this[b+1]}return a};var Try={these:function(){for(var c=0,a;c<arguments.length;++c){try{a=arguments[c]();break}catch(b){}}return a}};if(!window.Event){var Event=new Object()}Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,element:function(a){return a.target||a.srcElement},isLeftClick:function(a){return(((a.which)&&(a.which==1))||((a.button)&&(a.button==1)))},pointerX:function(a){return a.pageX||(a.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft))},pointerY:function(a){return a.pageY||(a.clientY+(document.documentElement.scrollTop||document.body.scrollTop))},stop:function(a){if(a.preventDefault){a.preventDefault();a.stopPropagation()}else{a.returnValue=false;a.cancelBubble=true}},observers:false,_observeAndCache:function(d,c,b,a){if(!this.observers){this.observers=[]}if(d.addEventListener){this.observers.push([d,c,b,a]);d.addEventListener(c,b,a)}else{if(d.attachEvent){this.observers.push([d,c,b,a]);d.attachEvent("on"+c,b)}}},unloadCache:function(){if(!Event.observers){return}for(var a=0;a<Event.observers.length;a++){Event.stopObserving.apply(this,Event.observers[a]);Event.observers[a][0]=null}Event.observers=false},observe:function(d,c,b,a){var d=$(d);a=a||false;if(c=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||d.attachEvent)){c="keydown"}this._observeAndCache(d,c,b,a)},stopObserving:function(d,c,b,a){var d=$(d);a=a||false;if(c=="keypress"&&(navigator.appVersion.match(/Konqueror|Safari|KHTML/)||d.detachEvent)){c="keydown"}if(d.removeEventListener){d.removeEventListener(c,b,a)}else{if(d.detachEvent){d.detachEvent("on"+c,b)}}}});function addEvent(d,b,a,c){Event.observe(d,b,a,c)}function removeEvent(d,b,a,c){Event.stopObserving(d,b,a,c)}function addLoadEvent(a){var b=window.onload;if(typeof window.onload!="function"){window.onload=a}else{window.onload=function(){b();a()}}}function getCookie(c){var d=document.cookie.indexOf(c+"=");var a=d+c.length+1;if((!d)&&(c!=document.cookie.substring(0,c.length))){return null}if(d==-1){return null}var b=document.cookie.indexOf(";",a);if(b==-1){b=document.cookie.length}return unescape(document.cookie.substring(a,b))}function setCookie(c,e,a,h,d,g){var b=new Date();b.setTime(b.getTime());if(a){a=a*1000*60*60*24}var f=new Date(b.getTime()+(a));document.cookie=c+"="+escape(e)+((a)?";expires="+f.toGMTString():"")+((h)?";path="+h:"")+((d)?";domain="+d:"")+((g)?";secure":"")}function deleteCookie(a,c,b){if(getCookie(a)){document.cookie=a+"="+((c)?";path="+c:"")+((b)?";domain="+b:"")+";expires=Thu, 01-Jan-1970 00:00:01 GMT"}}if(typeof Array.prototype.push=="undefined"){Array.prototype.push=function(){for(var b=0,a=this.length;b<arguments.length;++b){this[a+b]=arguments[b]}return this.length}}Array.prototype.remove=function(a){for(var b=0;b<this.length;++b){if(this[b]==a){return this.splice(b,1)}}return false};Object.prototype.toQueryString=function(){var c=[];for(var a in this){var b=typeof this[a];if(b!="function"&&b!="object"){c.push([a,encodeURIComponent(this[a])].join("="))}}return c.join("&")};String.prototype.wordWrap=function(d,a,n){var g,f,e,h,k=this.split("\n");if(d>0){for(g=-1,e=k.length;++g<e;){for(h=k[g],k[g]="";h.length>d;f=n?d:(f=h.substr(0,d).match(/\S*$/)).input.length-f[0].length||f.input.length+(f=h.substr(d).match(/^\S*/)).input.length+f[0].length,k[g]+=h.substr(0,f)+((h=h.substr(f)).length?a:"")){}k[g]+=h}}return k.join("\n")};Object.extend(String.prototype,{escapeHTML:function(){var b=document.createElement("div");var a=document.createTextNode(this);b.appendChild(a);return b.innerHTML},getTextWidth:function(){var b=document.createElement("span");Object.extend(b.style,{visibiliy:"hidden",position:"absolute",left:"0px",top:"0px"});b.innerHTML=this;document.body.appendChild(b);var a=b.offsetWidth;document.body.removeChild(b);return a},wordWrap:function(d,a,n){var g,f,e,h,k=this.split("\n");if(d>0){for(g=-1,e=k.length;++g<e;){for(h=k[g],k[g]="";h.length>d;f=n?d:(f=h.substr(0,d).match(/\S*$/)).input.length-f[0].length||f.input.length+(f=h.substr(d).match(/^\S*/)).input.length+f[0].length,k[g]+=h.substr(0,f)+((h=h.substr(f)).length?a:"")){}k[g]+=h}}return k.join("\n")}});function Timer(){this.t=false;this.intv=false;this.start=function(b,a){this.stop();this.t=window.setTimeout(b,a)};this.stop=function(){if(this.t){window.clearTimeout(this.t)}};this.startInterval=function(b,a){this.intv=window.setInterval(b,a)};this.stopInterval=function(){if(this.intv){window.clearInterval(this.intv)}}}var quickEditBase=Class.create();quickEditBase.prototype={initialize:function(){this.options={inputSize:50,maxInput:255,maxCharsVisible:100,textAlign:"left",maxWidth:100,style:{}}},setOptions:function(a){Object.extend(this.options,a||{})},initContainer:function(){if(!this.container){return false}this.oldStyles={backgroundColor:this.container.style.backgroundColor,color:this.container.style.color};this.observers={mouseover:function(){Object.extend(this.container.style,{backgroundColor:"#FFFFE6",cursor:"text",color:"#000"})}.bind(this),mouseout:function(){Object.extend(this.container.style,this.oldStyles)}.bind(this),mouseclick:this.showEditable.bind(this)};Event.observe(this.container,"mouseover",this.observers.mouseover);Event.observe(this.container,"mouseout",this.observers.mouseout);Event.observe(this.container,"click",this.observers.mouseclick)},restoreContainer:function(){if(!this.container){return false}Object.extend(this.container.style,this.oldStyles);this.container.onmouseover=null;Event.stopObserving(this.container,"mouseover",this.observers.mouseover);Event.stopObserving(this.container,"mouseout",this.observers.mouseout);Event.stopObserving(this.container,"click",this.observers.mouseclick)},showEditable:function(){this.editBox=document.createElement("span");this.inputField=document.createElement("input");if(!this.editBox||!this.inputField){return false}this.inputField.value=this.value;this.inputField.size=this.options.inputSize;this.inputField.onkeypress=this.keyPressHandler.bindAsEventListener(this);this.inputField.onblur=this.doUpdate.bind(this);this.inputField.maxLength=this.options.maxInput;this.inputField.style.textAlign=this.options.textAlign;this.editBox.className="qinput";Object.extend(this.editBox.style,this.options.style||{});this.editBox.appendChild(this.inputField);this.container.parentNode.insertBefore(this.editBox,this.container);this.container.style.display="none";this.inputField.setAttribute("autocomplete","off");var a=this.inputField.value.getTextWidth();this.inputField.style.width=(a>this.options.maxWidth?this.options.maxWidth:(a<40?40:a))+"px";this.inputField.focus();this.inputField.select()},hideEditable:function(a){var b=a||this.value;b=str_slice(b.escapeHTML(),this.options.maxCharsVisible);this.container.innerHTML=b;this.container.style.display="";if(this.editBox.parentNode){this.editBox.parentNode.removeChild(this.editBox)}},keyPressHandler:function(c){c=c||window.event;var a=c.keyCode;if(a==Event.KEY_RETURN){this.inputField.onblur=function(){};window.setTimeout(this.doUpdate.bind(this),50);return false}if(a==Event.KEY_ESC){this.hideEditable();return}var d=this.inputField.value+String.fromCharCode(a);var b=d.getTextWidth();this.inputField.style.width=(b>this.options.maxWidth?this.options.maxWidth:(b<40?40:b))+"px";return true},doUpdate:function(){alert("doUpdate() must be implemented");this.hideEditable()}};var Ajax={events:["uninitialized","loading","loaded","interactive","complete"],enabled:(typeof XMLHttpRequest!="undefined"||typeof ActiveXObject!="undefined"),getXMLHttpObject:function(){return Try.these(function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new XMLHttpRequest()})||false}};AjaxRequest=Class.create();AjaxRequest.prototype={initialize:function(b,a){this.options=Object.extend({method:"post",async:true,postData:{},response:"json"},a||{});this.onloading=null;this.onloaded=null;this.oncomplete=null;this.response=null;this.xmlhttp=Ajax.getXMLHttpObject();this.url=b},setOptions:function(a){this.options=Object.extend(this.options,a||{})},request:function(a){this.url=a||this.url;this.xmlhttp.open(this.options.method,this.url+(this.url.indexOf("?")<0?"?":"&")+"ajax="+this.getRand(),this.options.async);if(this.options.async){this.xmlhttp.onreadystatechange=this.stateChange.bind(this)}if(this.options.method=="post"){this.xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=utf-8")}this.xmlhttp.send(this.options.method=="post"?this.options.postData.toQueryString():null)},stateChange:function(){var a=Ajax.events[this.xmlhttp.readyState];if(a=="loading"&&this.onloading!=null){this.onloading.bind(this)()}if(a=="loaded"&&this.onloaded!=null){this.onloaded.bind(this)()}if(a=="complete"&&this.xmlhttp.status==200){this.response=this.getResponse();this.xmlhttp.onreadystatechange=function(){};if(this.oncomplete!=null){this.oncomplete.bind(this)()}}},getResponse:function(type){var type=type||this.options.response;if(type=="json"){try{eval("var resp = "+this.xmlhttp.responseText);return resp}catch(error){return{result:"failed",message:"Returned result is not proper JSON format. Probably parse error."}}}return type=="xml"?this.xmlhttp.responseXML:this.xmlhttp.responseText},getRand:function(){for(var a=0,b="";a<5;++a){b+=String(Math.floor(Math.random()*10000000000))}return b}};Element=new Object();Object.extend(Element,{position:function(a,b){a=$(a);if(!a){return}if(b=="absolute"&&!a._absolute){var c=Element.getOffset(a,false);Object.extend(a.style,{position:"absolute",top:c.offsetTop+"px",left:c.offsetLeft});a._absolute=true}},cumulativeOffset:function(b){var a=0,c=0;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;b=b.offsetParent}while(b);return[c,a]},setOpacity:function(c,b){c=$(c);if(!c){return false}if(c.filters){try{c.filters.alpha.opacity=b}catch(a){c.style.filter="alpha(opacity="+b+")"}}Object.extend(c.style,{opacity:b/100,MozOpacity:b/100,visibility:b<=0?"hidden":"visible"})},getOffset:function(b,d){d=d||false;b=$(b);if(!b){return false}var c=Object.extend(Element.cumulativeOffset(b));var a={offsetWidth:b.offsetWidth,offsetHeight:b.offsetHeight,offsetLeft:c[0],offsetTop:c[1]};a.offsetRight=a.offsetLeft+a.offsetWidth;a.offsetBottom=a.offsetTop+a.offsetHeight;return a},fade:function(a,d,c,b){a=$(a);if(!a){return false}if(d==null){d=100}b=b||10;if(d==c){if(typeof a.onfadefinish=="function"){a.onfadefinish()}return true}d=Element.__getNextStepValue(d,c,b);Element.setOpacity(a,d);window.setTimeout(Element.fade.bind(this,a,d,c,b),10)},__getNextStepValue:function(c,b,a){if(c>b){c-=(c-b)>a?a:c-b}else{c+=(b-c)>a?a:b-c}return c}});var Form={disable:function(d,e){d=$(d);if(!d){return false}var c=d.tagName.toLowerCase();if(c=="form"||c=="input"||c=="textarea"||(c=="fieldset"&&document.all)){d.disabled=e;return true}if(typeof e=="undefined"){e=true}var a=d.getElementsByTagName("input");for(var b=0;b<a.length;++b){a[b].disabled=e}var a=d.getElementsByTagName("textarea");for(var b=0;b<a.length;++b){a[b].disabled=e}}};var Drag=Class.create();Drag.prototype={initialize:function(b,a){this.dragObj=$(b);if(!this.dragObj){return false}this.options={zIndex:1,horizontal:true,vertical:true,leftBound:0,rightBound:-1,topBound:0,bottomBound:-1};Object.extend(this.dragObj.style,{position:"absolute"});this.setOptions(a||this.options);this.lastMousePos=[0,0];this.observers={mouseMove:this.mouseMoveListener.bindAsEventListener(this),mouseDown:this.startDrag.bindAsEventListener(this),mouseUp:this.stopDrag.bindAsEventListener(this)};this.ondrag=null;this.ondragstart=null;this.ondragend=null;Event.observe(this.dragObj,"mousedown",this.observers.mouseDown);Event.observe(this.dragObj,"mouseup",this.observers.mouseUp);this.dragObj.onmousedown=function(){return false}},setBoundary:function(d,b,a,c){this.setOptions({leftBound:c,rightBound:b,topBound:d,bottomBound:a})},setBoundingObject:function(a){a=$(a);if(!a){return false}var b=Element.getOffset(a);this.setBoundary(b.offsetTop,b.offsetRight,b.offsetBottom,b.offsetLeft)},setOptions:function(a){Object.extend(this.options,a||{})},startDrag:function(b){if(!Event.isLeftClick(b)){return false}Object.extend(this.dragObj.style,{zIndex:this.options.zIndex+1});Event.observe(document,"mousemove",this.observers.mouseMove);Event.observe(document,"mouseup",this.observers.mouseUp);document.onselectstart=function(){return false};document.ondragstart=function(){return false};var c=Element.getOffset(this.dragObj,true);var a=(b.pageX||b.pageY)?b.pageX:b.clientX+document.body.scrollLeft;var d=(b.pageY||b.pageY)?b.pageY:b.clientY+document.body.scrollTop;this.relativeX=a-c.offsetLeft;this.relativeY=d-c.offsetTop;this.dragObjOffset=c;if(typeof this.ondragstart=="function"){this.ondragstart(Element.getOffset(this.dragObj,true))}Element.position(this.dragObj,"absolute");return false},stopDrag:function(a){Object.extend(this.dragObj.style,{zIndex:this.options.zIndex});Event.stopObserving(document,"mousemove",this.observers.mouseMove);Event.stopObserving(document,"mouseup",this.observers.mouseUp);document.onselectstart=function(){return true};if(typeof this.ondragend=="function"){this.ondragend(Element.getOffset(this.dragObj,true))}Element.position(this.dragObj,"relative")},mouseMoveListener:function(b){var a=Event.pointerX(b);var d=Event.pointerY(b);if(this.lastMousePos[0]==a&&this.lastMousePos[1]==d){return}var c={left:a-this.relativeX,right:(a-this.relativeX)+this.dragObjOffset.offsetWidth,top:d-this.relativeY,bottom:(d-this.relativeY)+this.dragObjOffset.offsetHeight};if(c.left<this.options.leftBound){c.left=this.options.leftBound}else{if(this.options.rightBound>-1&&(c.right>this.options.rightBound)){c.left=(this.options.rightBound-this.dragObjOffset.offsetWidth)}}if(c.top<this.options.topBound){c.top=this.options.topBound}else{if(this.options.bottomBound>-1&&(c.bottom>this.options.bottomBound)){c.top=(this.options.bottomBound-this.dragObjOffset.offsetHeight)}}if(this.options.horizontal){this.dragObj.style.left=c.left+"px"}if(this.options.vertical){this.dragObj.style.top=c.top+"px"}if(typeof this.ondrag=="function"){this.ondrag(Element.getOffset(this.dragObj,true))}this.lastMousePos=[a,d]}};