/*
Copyright (c) 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];};}