/*
Copyright (c) 2005,2006,2007 Stefan Pratter

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
  var VSK_VERSION='0.1.0';var VSK_I={name:null };if(window.opera){VSK_I.name='Opera';}else if (navigator.userAgent){var str=navigator.userAgent;if(str.indexOf("Firefox")!=-1){VSK_I.name='Firefox';}else if(str.indexOf("Netscape")!=-1){VSK_I.name='Netscape';}else if(str.indexOf("MSIE")!=-1){VSK_I.name='MSIE';}else if(str.indexOf("Gecko")!=-1){VSK_I.name='Mozilla';}}function v(node){return new VSK_Node(node);}function V(id){var n=document.getElementById(id);return (n ? v(n):null);}vsk_html_node=vsk_h=function(nodeName,className,parentNode,id){var n=document.createElement(nodeName);if(className)n.className=className;if(parentNode){v(n).dock(parentNode);}if(id)n.id=id;return n;};vsk_txt_node=vsk_t=function(text,parentNode){var n=document.createTextNode(text);v(n).dock(parentNode);return n;};function vsk_get_mouse(e){if (e.pageX||e.pageY){vskX=e.pageX;vskY=e.pageY;}else if (e.clientX||e.clientY){vskX=e.clientX+document.documentElement.scrollLeft;vskY=e.clientY+document.documentElement.scrollTop;}}function vsk_rel_target(e){if(!e)var e=event;return (e.relatedTarget ? e.relatedTarget:(e.type=='mouseover' ? e.fromElement: e.toElement ));}function pi(str){return parseInt(str);}function in_array(arr,value){var i;for(i=0;i < arr.length;i++){if(arr[i]==value)return true }return false;}function vsk_rand(min,max){return (Math.round(Math.random()*max)+min);}function VSK_Node(node){this.control(node);}VSK_Node.prototype.abs_x=function(Parent){if(!this.b)return null;var n=this.b,x=0;while(n&&n.parentNode&&n.parentNode.style&&(!Parent||Parent !=n)){x+=n.offsetLeft;if(v(n).s.left==='')n=n.offsetParent;else n=n.parentNode;}return x;};VSK_Node.prototype.abs_y=function(Parent){if(!this.b)return null;var n=this.b,y=0;while(n&&n.parentNode&&n.parentNode.style&&(!Parent||Parent !=n)){y+=n.offsetTop;if(v(n).s.top==='')n=n.offsetParent;else n=n.parentNode;}return y;};VSK_Node.prototype.clear=function(node){if(!this.b)return;while(this.b.childNodes[0])this.b.removeChild(this.b.childNodes[0]);if(node)this.b.appendChild(node);return this;};VSK_Node.prototype.control=function(node){if(!node)return;this.b=node;this.s=node.style;return this;};VSK_Node.prototype.dock=function(toNode){if(this.b&&toNode){toNode.appendChild(this.b);this.vsk_event_fire('dock');}return this;};VSK_Node.prototype.event_add=function(eventName,func){if(!this.b)return;if(this.b.addEventListener)this.b.addEventListener(eventName,func,false);else if(this.b.attachEvent)this.b.attachEvent('on'+eventName,func);return this;};VSK_Node.prototype.fade=function(n){if(!this.s)return;if(n > 100)var n=100;else if(n < 1)var n=1;this.s.filter='alpha(opacity='+n+')';this.s.opacity=n/100;this.s.MozOpacity=n/100;return this;};VSK_Node.prototype.h=function(o){if(!this.s)return;return (this.s.height&&!o ? pi(this.s.height):this.b.offsetHeight);};VSK_Node.prototype.has_parent=function(parentNode){var _p=this.b;if(!_p)return false;while((_p=_p.parentNode)){if(_p==parentNode)return true;}return false;};VSK_Node.prototype.hide=function(hide){if(this.s){this.s.visibility=(hide ? 'hidden':'');this.vsk_event_fire('hide');}return this;};VSK_Node.prototype.html_append=function(){if(!this.b)return;var i;for(i=0;i < arguments.length;i++){v(arguments[i]).dock(this.b);}return this.b;};VSK_Node.prototype.html_a=VSK_Node.prototype.html_append;VSK_Node.prototype.html_insert_after=function(){if(!this.b||!this.b.parentNode)return this;var i,node=this.b,p=this.b.parentNode;for(i=0;i < arguments.length;i++){if(node.nextSibling)p.insertBefore(arguments[i],node.nextSibling);else p.appendChild(arguments[i]);node=arguments[i];}return this;};VSK_Node.prototype.html_ia=VSK_Node.prototype.html_insert_after;VSK_Node.prototype.html_insert_before=function(){if(!this.b||!this.b.parentNode)return this;var i;for(i=0;i < arguments.length;i++)this.b.parentNode.insertBefore(arguments[i],this.b);return this;};VSK_Node.prototype.html_ib=VSK_Node.prototype.html_insert_before;VSK_Node.prototype.move=function(x,y){if(!this.s)return;if(!isNaN(x)&&x !==null)this.s.left=x+'px';if(!isNaN(y)&&y !==null)this.s.top=y+'px';this.vsk_event_fire('move');return this;};VSK_Node.prototype.resize=function(w,h){if(!this.s)return;if(w)this.s.width=w+'px';if(h)this.s.height=h+'px';this.vsk_event_fire('resize');return this;};VSK_Node.prototype.set_pos=function(pos,zIndex){if(pos)this.s.position=pos;if(!isNaN(zIndex))this.s.zIndex=zIndex;return this;};VSK_Node.prototype.t=function(){if(!this.s||this.s.opacity==='')return 100;return (this.s.opacity*100);};VSK_Node.prototype.trim=function(length,reverse){if(!this.b)return;while(this.b.childNodes.length > length){if(!reverse)v(this.b.firstChild).undock();else v(this.b.lastChild).undock();}};VSK_Node.prototype.undock=function(){if(!this.b||!this.b.parentNode)return this;this.b.parentNode.removeChild(this.b);this.vsk_event_fire('undock');return this;};VSK_Node.prototype.v=function(){if(!this.s)return;return (this.s.visibility=='hidden' ? false:true);};VSK_Node.prototype.vsk_event_add=function(name,func,id){if(!this.b)return this;if(!this.b['vsk_on'+name])this.b['vsk_on'+name]=new VegUIDynFunc();var F=this.b['vsk_on'+name];F.add(func,id);return this;};VSK_Node.prototype.vsk_event_fire=function(name){if(!this.b||!this.b['vsk_on'+name])return this;this.b['vsk_on'+name].execute(this.b);return this;};VSK_Node.prototype.vsk_event_unset=function(name,id){if(!this.b||!this.b['vsk_on'+name])return this;this.b['vsk_on'+name].free(id);return this;};VSK_Node.prototype.w=function(o){if(!this.s)return;return (this.s.width&&!o ? pi(this.s.width):this.b.offsetWidth);};VSK_Node.prototype.x=function(){if(!this.s)return;return (this.s.left !=='' ? pi(this.s.left):this.b.offsetLeft);};VSK_Node.prototype.x2=function(){if(!this.s)return;return (this.w()+this.x());};VSK_Node.prototype.y=function(){if(!this.s)return;return (this.s.top !=='' ? pi(this.s.top):this.b.offsetTop);};VSK_Node.prototype.y2=function(){if(!this.s)return;return this.h()+this.y();};VSK_Node.prototype.z=function(){if(!this.s)return;return this.s.zIndex;};function VegUIDynFunc(returnVal){this.Funcs={_l:0, _p:function(fn){this[this._l]=fn;this._l++;}};this.returnVal=returnVal||false;this.add=function(fn,id){if(id){this.Funcs[id]=fn;}else this.Funcs._p(fn);};this.execute=function(argArr){var i,returnVal=this.returnVal;for(i in this.Funcs){if(typeof this.Funcs[i]!='function'||i=='_p')continue;this.Funcs[i](argArr);}return returnVal;};this.free=function(id){delete this.Funcs[id];};}  var vsk_fxInterval;var vsk_Effects=[];var VSK_FX_INTERVAL=25;function vsk_fx_poll(){var i,n;for(i=0;i < vsk_Effects.length;i++){v(vsk_Effects[i]).fx_process();}}VSK_Node.prototype.fx_process=function(){if(!this.b||!this.b.vsk_effects)return null;var i,e;for(i in this.b.vsk_effects){if(typeof this.b.vsk_effects[i].main=='function')this.b.vsk_effects[i].main();}return this;};VSK_Node.prototype.fx_clear=function(clearEffects){if(clearEffects&&clearEffects.length){var i;for(i=0;i < clearEffects.length;i++)this.fx_halt(clearEffects[i],true);}};VSK_Node.prototype.fx_start=function(){this.fx_stop();vsk_fxInterval=setInterval(vsk_fx_poll,VSK_FX_INTERVAL);return this;};VSK_Node.prototype.fx_stop=function(){vsk_fxInterval=clearInterval(vsk_fxInterval);return this;};VSK_Node.prototype.fx_init=function(id,effect,collision){if(this.b){if(!this.b.vsk_effects)this.b.vsk_effects={};this.b.vsk_effects[id]=effect;if(!in_array(vsk_Effects,this.b)){vsk_Effects.push(this.b);}if(collision){var i=0;for(i=0;i < collision.length;i++)this.fx_halt(collision[i]);}this.fx_start();}return this;};VSK_Node.prototype.fx_halt=function(id,silent){if(this.b&&this.b.vsk_effects&&this.b.vsk_effects[id]){var E=this.b.vsk_effects[id];delete this.b.vsk_effects[id];if(E.onhalt&&!silent)E.onhalt(this);if(E.sequence&&!silent)E.sequence.loop();if(E._onhalt&&!silent)E._onhalt(this);}return this;};VSK_Node.prototype.fx_active=function(id){if(!this.b||!this.b.vsk_effects)return false;if(this.b.vsk_effects[id])return true;return false;};function VSK_FX_Sequence(n){this.n=n;this.loopMax=0;this.loopCount=0;}VSK_FX_Sequence.prototype.loop=function(n){if(typeof n !='undefined'){this.loopMax=n;this.loopCount=0;}if(this.loopMax&&this.loopCount==this.loopMax)return;else if(this.loopMax)this.loopCount++;if(typeof this.body=='function'&&this.n)this.body(this.n);};VSK_FX_Sequence.prototype.halt=function(clearEffects){this.n.fx_clear(clearEffects);};  VSK_Node.prototype.fx_morph=function(w,h,x,y,t){if(!this.b)return {};var N=this;var E={type_w:(w < this.w()), type_h:(h < this.h()), type_x:(x < this.x()), type_y:(y < this.y()), w:w, h:h, x:x, y:y, oW:this.w(), oH:this.h(), oX:this.x(), oY:this.y(), iW:0, iH:0, iX:0, iY:0, interval:(t/VSK_FX_INTERVAL), main:function(){this.iW+=(Math.abs(this.w-this.oW)/this.interval);this.iH+=(Math.abs(this.h-this.oH)/this.interval);var w=(N.w()==this.w);var h=(N.h()==this.h);var _iw=Math.floor(this.iW);var _ih=Math.floor(this.iH);if((!w&&this.iW>=1)||(!h&&this.iH>=1)){var _uw=(!w ? (!this.type_w ? N.w()+_iw:N.w()-_iw):null);var _uh=(!h ? (!this.type_h ? N.h()+_ih:N.h()-_ih):null);N.resize((_uw >-1 ? _uw:1),(_uh >-1 ? _uh:1));}if(this.iW >=1)this.iW=(this.iW-_iw);if(this.iH >=1)this.iH=(this.iH-_ih);var _w=(!this.type_w ? (N.w()> this.w):(N.w()< this.w));var _h=(!this.type_h ? (N.h()> this.h):(N.h()< this.h));if(_w||_h){N.resize((_w ? this.w:null),(_h ? this.h:null));}if(this.x !==null&&this.y !==null){this.iX+=(Math.abs(this.x-this.oX)/this.interval);this.iY+=(Math.abs(this.y-this.oY)/this.interval);var _ix=Math.floor(this.iX);var _iy=Math.floor(this.iY);var x=(N.x()==this.x);var y=(N.y()==this.y);if((!x&&this.iX>=1)||(!y&&this.iY>=1)){N.move((!x ? (this.x > N.x()? N.x()+_ix:N.x()-_ix):null), (!y ? (this.y > N.y()? N.y()+_iy:N.y()-_iy):null));}if(this.iX >=1)this.iX-=_ix;if(this.iY >=1)this.iY-=_iy;var _x=(Math.abs(N.x()-this.x)<=(Math.abs(this.oX-this.x)/this.interval));var _y=(Math.abs(N.y()-this.y)<=(Math.abs(this.oY-this.y)/this.interval));if(_x||_y){N.move((_x ? this.x:null), (_y ? this.y:null));}}else {var x=true,y=true;}if(w&&h&&x&&y)N.fx_halt('morph');}};this.fx_init('morph',E);return E;};  VSK_Node.prototype.fx_fade_in=function(n,limit){if(!this.b)return;var N=this.b;var t=(100-this.t());if(!limit)var limit=100;var E={main:function(){var interval=t/(n/VSK_FX_INTERVAL);if(v(N).t()< limit)v(N).fade(v(N).t()+interval);else v(N).fx_halt('fade_in');}};this.fx_init('fade_in',E,['fade_out']);return E;};VSK_Node.prototype.fx_fade_out=function(n,limit){if(!this.b)return;var N=this.b;var t=this.t();if(!limit)var limit=1;var E={main:function(){var interval=t/(n/VSK_FX_INTERVAL);if(v(N).t()> limit)v(N).fade(v(N).t()-interval);else v(N).fx_halt('fade_out');}};this.fx_init('fade_out',E,['fade_in']);return E;};  VSK_Node.prototype.fx_shadow_adjust=function(){if(!this.b||!this.fx_active('shadow'))return this;var E=this.b.vsk_effects['shadow'];var n=v(E.node);n.resize(this.w(1),this.h(1)).move(this.x()+E.oX,this.y()+E.oY);if(!n.b.parentNode){n.set_pos('absolute',this.s.zIndex-1);n.hide(1).dock(this.b.parentNode).hide(0);}n.hide(this.v()^1);return this;};VSK_Node.prototype.fx_shadow=function(t,c,oX,oY){if(!this.b)return {};var n=this.b;if(!this.s.zIndex)this.s.zIndex=1;this.vsk_event_add('move',function(b){v(b).fx_shadow_adjust();});this.vsk_event_add('resize',function(b){v(b).fx_shadow_adjust();});this.vsk_event_add('undock',function(b){v(b).fx_halt('shadow');});this.vsk_event_add('hide',function(b){v(b).fx_shadow_adjust();});var E={oX:oX, oY:oY, t:t, c:c, node:vsk_h('div'), main:function(){}, _onhalt:function(){v(this.node).undock();}};v(E.node).fade(t).s.backgroundColor=c;this.fx_init('shadow',E);this.fx_shadow_adjust();return E;};  var VSK_TTIP_FX_TIME=200;var VSK_TTIP_MAX_WIDTH=500;var VSK_TTIP_FX_TYPE='fade';var VSK_TTIP_USE_SHADOW=false;var VSK_TTIP_SHADOW_TRANSPARENCY=15;var VSK_TTIP_SHADOW_OFFSET_X=5;var VSK_TTIP_SHADOW_OFFSET_Y=5;var VSK_TTIP_SHADOW_COLOR='#000';var VSK_TTIP_NODE=null;var VSK_TTIP={span:true, a:true, p:true };VSK_Node.prototype.ttip_show=function(text){if(!this.b.ttipNode){if(VSK_TTIP_NODE)var t=v(VSK_TTIP_NODE.cloneNode(1));else var t=v(vsk_h('div'));t.s.display='inline';t.s.position='absolute';t.s.zIndex=100000;t.b.className='vsk_tooltip';t.b.innerHTML=text;t.dock(document.body);if(t.w()> VSK_TTIP_MAX_WIDTH)t.resize(VSK_TTIP_MAX_WIDTH);if(VSK_TTIP_FX_TYPE=='fade'){t.fade(1).fx_fade_in(VSK_TTIP_FX_TIME);}else if(VSK_TTIP_FX_TYPE=='morph'){t.s.padding='0px';var h=t.h(1),w=t.w(1),n=t.b;if(w > VSK_TTIP_MAX_WIDTH)w=VSK_TTIP_MAX_WIDTH;t.clear().resize(1,1).fx_morph(w,h,null,null,VSK_TTIP_FX_TIME).onhalt=function(){n.innerHTML=text;};t.s.padding='';}this.b.ttipNode=t.b;if(t.fx_shadow&&VSK_TTIP_USE_SHADOW){t.fx_shadow(VSK_TTIP_SHADOW_TRANSPARENCY, VSK_TTIP_SHADOW_COLOR, VSK_TTIP_SHADOW_OFFSET_X, VSK_TTIP_SHADOW_OFFSET_Y );}}else var t=v(this.b.ttipNode);t.move(vskX+10,vskY+10);};VSK_Node.prototype.ttip_hide=function(){if(!this.b||!this.b.ttipNode)return;if(VSK_TTIP_FX_TYPE=='fade'){var t=new Date().getTime();var id='vsk_ttip_'+t;this.b.ttipNode.id=id;var n=V(id);n.fx_fade_out(VSK_TTIP_FX_TIME).onhalt=function(){V(id).undock();};}else v(this.b.ttipNode).undock();this.b.ttipNode=null;};v(window).event_add('load',function(){var t,n,i,e,ttip;for(t in VSK_TTIP){if(!VSK_TTIP[t])continue;e=document.getElementsByTagName(t);for(i=0;i < e.length;i++){n=e[i];if((ttip=n.getAttribute('vsk_ttip'))){__vsk_ttip_event_show(v(n));__vsk_ttip_event_hide(v(n));}}}});function __vsk_ttip_event_hide(n){n.event_add('mouseout',function(e){var rel=vsk_rel_target(e ? e:event);if(!v(rel).has_parent(n.b)&&n.b !=rel)n.ttip_hide();});}function __vsk_ttip_event_show(n){n.event_add('mousemove',function(e){vsk_get_mouse((e ? e:event));n.ttip_show(n.b.getAttribute('vsk_ttip'));});}
