


(function(){if(window.jQuery)
var _jQuery=window.jQuery;var jQuery=window.jQuery=function(selector,context){return new jQuery.prototype.init(selector,context);};if(window.$)
var _$=window.$;window.$=jQuery;var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;var isSimple=/^.[^:#\[\.]*$/;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}else if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])
selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem)
if(elem.id!=match[3])
return jQuery().find(selector);else{this[0]=elem;this.length=1;return this;}
else
selector=[];}}else
return new jQuery(context).find(selector);}else if(jQuery.isFunction(selector))
return new jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(selector.constructor==Array&&selector||(selector.jquery||selector.length&&selector!=window&&!selector.nodeType&&selector[0]!=undefined&&selector[0].nodeType)&&jQuery.makeArray(selector)||[selector]);},jquery:"1.2.3",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;this.each(function(i){if(this==elem)
ret=i;});return ret;},attr:function(name,value,type){var options=name;if(name.constructor==String)
if(value==undefined)
return this.length&&jQuery[type||"attr"](this[0],name)||undefined;else{options={};options[name]=value;}
return this.each(function(i){for(name in options)
jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)
value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)
return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)
ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])
jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)
elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)
this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)
this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div");container.appendChild(clone);return jQuery.clean([container.innerHTML])[0];}else
return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)
this[expando]=null;});if(events===true)
this.find("*").andSelf().each(function(i){if(this.nodeType==3)
return;var events=jQuery.data(this,"events");for(var type in events)
for(var handler in events[type])
jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)
if(isSimple.test(selector))
return this.pushStack(jQuery.multiFilter(selector,this,true));else
selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return!selector?this:this.pushStack(jQuery.merge(this.get(),selector.constructor==String?jQuery(selector).get():selector.length!=undefined&&(!selector.nodeName||jQuery.nodeName(selector,"form"))?selector:[selector]));},is:function(selector){return selector?jQuery.multiFilter(selector,this).length>0:false;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)
return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;if(one)
return value;values.push(value);}}
return values;}else
return(this[0].value||"").replace(/\r/g,"");}
return undefined;}
return this.each(function(){if(this.nodeType!=1)
return;if(value.constructor==Array&&/radio|checkbox/.test(this.type))
this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=value.constructor==Array?value:[value];jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)
this.selectedIndex=-1;}else
this.value=value;});},html:function(value){return value==undefined?(this.length?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value==null){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data==undefined&&this.length)
data=jQuery.data(this[0],key);return data==null&&parts[1]?this.data(parts[0]):data;}else
return this.trigger("setData"+parts[1]+"!",[parts[0],value]).each(function(){jQuery.data(this,key,value);});},removeData:function(key){return this.each(function(){jQuery.removeData(this,key);});},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)
elems.reverse();}
var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))
obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script")){scripts=scripts.add(elem);}else{if(elem.nodeType==1)
scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.prototype.init.prototype=jQuery.prototype;function evalScript(i,elem){if(elem.src)
jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)
elem.parentNode.removeChild(elem);}
jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}
if(typeof target!="object"&&typeof target!="function")
target={};if(length==1){target=this;i=0;}
for(;i<length;i++)
if((options=arguments[i])!=null)
for(var name in options){if(target===options[name])
continue;if(deep&&options[name]&&typeof options[name]=="object"&&target[name]&&!options[name].nodeType)
target[name]=jQuery.extend(target[name],options[name]);else if(options[name]!=undefined)
target[name]=options[name];}
return target;};var expando="jQuery"+(new Date()).getTime(),uuid=0,windowData={};var exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i;jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)
window.jQuery=_jQuery;return jQuery;},isFunction:function(fn){return!!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/function/i.test(fn+"");},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;},globalEval:function(data){data=jQuery.trim(data);if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.browser.msie)
script.text=data;else
script.appendChild(document.createTextNode(data));head.appendChild(script);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)
id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])
jQuery.cache[id]={};if(data!=undefined)
jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])
break;if(!name)
jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)
elem.removeAttribute(expando);}
delete jQuery.cache[id];}},each:function(object,callback,args){if(args){if(object.length==undefined){for(var name in object)
if(callback.apply(object[name],args)===false)
break;}else
for(var i=0,length=object.length;i<length;i++)
if(callback.apply(object[i],args)===false)
break;}else{if(object.length==undefined){for(var name in object)
if(callback.call(object[name],name,object[name])===false)
break;}else
for(var i=0,length=object.length,value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}
return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))
value=value.call(elem,i);return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))
elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)
elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}
callback.call(elem);for(var name in options)
elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}
if(jQuery(elem).is(":visible"))
getWH();else
jQuery.swap(elem,props,getWH);return Math.max(0,val);}
return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret;function color(elem){if(!jQuery.browser.safari)
return false;var ret=document.defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}
if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(elem.style,"opacity");return ret==""?"1":ret;}
if(jQuery.browser.opera&&name=="display"){var save=elem.style.outline;elem.style.outline="0 solid black";elem.style.outline=save;}
if(name.match(/float/i))
name=styleFloat;if(!force&&elem.style&&elem.style[name])
ret=elem.style[name];else if(document.defaultView&&document.defaultView.getComputedStyle){if(name.match(/float/i))
name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var getComputedStyle=document.defaultView.getComputedStyle(elem,null);if(getComputedStyle&&!color(elem))
ret=getComputedStyle.getPropertyValue(name);else{var swap=[],stack=[];for(var a=elem;a&&color(a);a=a.parentNode)
stack.unshift(a);for(var i=0;i<stack.length;i++)
if(color(stack[i])){swap[i]=stack[i].style.display;stack[i].style.display="block";}
ret=name=="display"&&swap[stack.length-1]!=null?"none":(getComputedStyle&&getComputedStyle.getPropertyValue(name))||"";for(var i=0;i<swap.length;i++)
if(swap[i]!=null)
stack[i].style.display=swap[i];}
if(name=="opacity"&&ret=="")
ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var style=elem.style.left,runtimeStyle=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;elem.style.left=ret||0;ret=elem.style.pixelLeft+"px";elem.style.left=style;elem.runtimeStyle.left=runtimeStyle;}}
return ret;},clean:function(elems,context){var ret=[];context=context||document;if(typeof context.createElement=='undefined')
context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;jQuery.each(elems,function(i,elem){if(!elem)
return;if(elem.constructor==Number)
elem=elem.toString();if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)
div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)
if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)
tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))
div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}
elem=jQuery.makeArray(div.childNodes);}
if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))
return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)
ret.push(elem);else
ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)
return undefined;var fix=jQuery.isXMLDoc(elem)?{}:jQuery.props;if(name=="selected"&&jQuery.browser.safari)
elem.parentNode.selectedIndex;if(fix[name]){if(value!=undefined)
elem[fix[name]]=value;return elem[fix[name]];}else if(jQuery.browser.msie&&name=="style")
return jQuery.attr(elem.style,"cssText",value);else if(value==undefined&&jQuery.browser.msie&&jQuery.nodeName(elem,"form")&&(name=="action"||name=="method"))
return elem.getAttributeNode(name).nodeValue;else if(elem.tagName){if(value!=undefined){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)
throw"type property can't be changed";elem.setAttribute(name,""+value);}
if(jQuery.browser.msie&&/href|src/.test(name)&&!jQuery.isXMLDoc(elem))
return elem.getAttribute(name,2);return elem.getAttribute(name);}else{if(name=="opacity"&&jQuery.browser.msie){if(value!=undefined){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+
(parseFloat(value).toString()=="NaN"?"":"alpha(opacity="+value*100+")");}
return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100).toString():"";}
name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(value!=undefined)
elem[name]=value;return elem[name];}},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(typeof array!="array")
for(var i=0,length=array.length;i<length;i++)
ret.push(array[i]);else
ret=array.slice(0);return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)
if(array[i]==elem)
return i;return-1;},merge:function(first,second){if(jQuery.browser.msie){for(var i=0;second[i];i++)
if(second[i].nodeType!=8)
first.push(second[i]);}else
for(var i=0;second[i];i++)
first.push(second[i]);return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}
return ret;},grep:function(elems,callback,inv){var ret=[];for(var i=0,length=elems.length;i<length;i++)
if(!inv&&callback(elems[i],i)||inv&&!callback(elems[i],i))
ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!==null&&value!=undefined){if(value.constructor!=Array)
value=[value];ret=ret.concat(value);}}
return ret;}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,innerHTML:"innerHTML",className:"className",value:"value",disabled:"disabled",checked:"checked",readonly:"readOnly",selected:"selected",maxlength:"maxLength",selectedIndex:"selectedIndex",defaultValue:"defaultValue",tagName:"tagName",nodeName:"nodeName"}});jQuery.each({parent:function(elem){return elem.parentNode;},parents:function(elem){return jQuery.dir(elem,"parentNode");},next:function(elem){return jQuery.nth(elem,2,"nextSibling");},prev:function(elem){return jQuery.nth(elem,2,"previousSibling");},nextAll:function(elem){return jQuery.dir(elem,"nextSibling");},prevAll:function(elem){return jQuery.dir(elem,"previousSibling");},siblings:function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},children:function(elem){return jQuery.sibling(elem.firstChild);},contents:function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}},function(name,fn){jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")
ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret));};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;return this.each(function(){for(var i=0,length=args.length;i<length;i++)
jQuery(args[i])[original](this);});};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)
this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)
this.parentNode.removeChild(this);}},empty:function(){jQuery(">*",this).remove();while(this.firstChild)
this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":function(a,i,m){return m[2]=="*"||jQuery.nodeName(a,m[2]);},"#":function(a,i,m){return a.getAttribute("id")==m[2];},":":{lt:function(a,i,m){return i<m[3]-0;},gt:function(a,i,m){return i>m[3]-0;},nth:function(a,i,m){return m[3]-0==i;},eq:function(a,i,m){return m[3]-0==i;},first:function(a,i){return i==0;},last:function(a,i,m,r){return i==r.length-1;},even:function(a,i){return i%2==0;},odd:function(a,i){return i%2;},"first-child":function(a){return a.parentNode.getElementsByTagName("*")[0]==a;},"last-child":function(a){return jQuery.nth(a.parentNode.lastChild,1,"previousSibling")==a;},"only-child":function(a){return!jQuery.nth(a.parentNode.lastChild,2,"previousSibling");},parent:function(a){return a.firstChild;},empty:function(a){return!a.firstChild;},contains:function(a,i,m){return(a.textContent||a.innerText||jQuery(a).text()||"").indexOf(m[3])>=0;},visible:function(a){return"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden";},hidden:function(a){return"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden";},enabled:function(a){return!a.disabled;},disabled:function(a){return a.disabled;},checked:function(a){return a.checked;},selected:function(a){return a.selected||jQuery.attr(a,"selected");},text:function(a){return"text"==a.type;},radio:function(a){return"radio"==a.type;},checkbox:function(a){return"checkbox"==a.type;},file:function(a){return"file"==a.type;},password:function(a){return"password"==a.type;},submit:function(a){return"submit"==a.type;},image:function(a){return"image"==a.type;},reset:function(a){return"reset"==a.type;},button:function(a){return"button"==a.type||jQuery.nodeName(a,"button");},input:function(a){return/input|select|textarea|button/i.test(a.nodeName);},has:function(a,i,m){return jQuery.find(m[3],a).length;},header:function(a){return/h\d/i.test(a.nodeName);},animated:function(a){return jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length;}}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}
return cur;},find:function(t,context){if(typeof t!="string")
return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)
return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false;var re=quickChild;var m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)
for(var c=ret[i].firstChild;c;c=c.nextSibling)
if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))
r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j<rl;j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;for(;n;n=n.nextSibling)
if(n.nodeType==1){var id=jQuery.data(n);if(m=="~"&&merge[id])break;if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~")merge[id]=true;r.push(n);}
if(m=="+")break;}}
ret=r;t=jQuery.trim(t.replace(re,""));foundToken=true;}}
if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0])ret.shift();done=jQuery.merge(done,ret);r=ret=[context];t=" "+t.substr(1,t.length);}else{var re2=quickID;var m=re2.exec(t);if(m){m=[0,m[2],m[3],m[1]];}else{re2=quickClass;m=re2.exec(t);}
m[2]=m[2].replace(/\\/g,"");var elem=ret[ret.length-1];if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2])
oid=jQuery('[@id="'+m[2]+'"]',elem)[0];ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];}else{for(var i=0;ret[i];i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object")
tag="param";r=jQuery.merge(r,ret[i].getElementsByTagName(tag));}
if(m[1]==".")
r=jQuery.classFilter(r,m[2]);if(m[1]=="#"){var tmp=[];for(var i=0;r[i];i++)
if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];break;}
r=tmp;}
ret=r;}
t=t.replace(re2,"");}}
if(t){var val=jQuery.filter(t,r);ret=r=val.r;t=jQuery.trim(val.t);}}
if(t)
ret=[];if(ret&&context==ret[0])
ret.shift();done=jQuery.merge(done,ret);return done;},classFilter:function(r,m,not){m=" "+m+" ";var tmp=[];for(var i=0;r[i];i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;if(!not&&pass||not&&!pass)
tmp.push(r[i]);}
return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}
if(!m)
break;if(m[1]==":"&&m[2]=="not")
r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")
r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i<rl;i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];if(z==null||/href|src|selected/.test(m[2]))
z=jQuery.attr(a,m[2])||'';if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not)
tmp.push(a);}
r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i<rl;i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);if(!merge[id]){var c=1;for(var n=parentNode.firstChild;n;n=n.nextSibling)
if(n.nodeType==1)
n.nodeIndex=c++;merge[id]=true;}
var add=false;if(first==0){if(node.nodeIndex==last)
add=true;}else if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0)
add=true;if(add^not)
tmp.push(node);}
r=tmp;}else{var fn=jQuery.expr[m[1]];if(typeof fn=="object")
fn=fn[m[2]];if(typeof fn=="string")
fn=eval("false||function(a,i){return "+fn+";}");r=jQuery.grep(r,function(elem,i){return fn(elem,i,m,r);},not);}}
return{r:r,t:t};},dir:function(elem,dir){var matched=[];var cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)
matched.push(cur);cur=cur[dir];}
return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])
if(cur.nodeType==1&&++num==result)
break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&(!elem||n!=elem))
r.push(n);}
return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)
return;if(jQuery.browser.msie&&elem.setInterval!=undefined)
elem=window;if(!handler.guid)
handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=function(){return fn.apply(this,arguments);};handler.data=data;handler.guid=fn.guid;}
var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){var val;if(typeof jQuery=="undefined"||jQuery.event.triggered)
return val;val=jQuery.event.handle.apply(arguments.callee.elem,arguments);return val;});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)
elem.addEventListener(type,handle,false);else if(elem.attachEvent)
elem.attachEvent("on"+type,handle);}}
handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)
return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined||(typeof types=="string"&&types.charAt(0)=="."))
for(var type in events)
this.remove(elem,type+(types||""));else{if(types.type){handler=types.handler;types=types.type;}
jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)
delete events[type][handler.guid];else
for(handler in events[type])
if(!parts[1]||events[type][handler].type==parts[1])
delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)
elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)
elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}
ret=null;delete events[type];}}});}
for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data||[]);if(type.indexOf("!")>=0){type=type.slice(0,-1);var exclusive=true;}
if(!elem){if(this.global[type])
jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)
return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event)
data.unshift(this.fix({type:type,target:elem}));data[0].type=type;if(exclusive)
data[0].exclusive=true;if(jQuery.isFunction(jQuery.data(elem,"handle")))
val=jQuery.data(elem,"handle").apply(elem,data);if(!fn&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)
val=false;if(event)
data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)
val=ret;}
if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}
this.triggered=false;}
return val;},handle:function(event){var val;event=jQuery.event.fix(event||window.event||{});var parts=event.type.split(".");event.type=parts[0];var handlers=jQuery.data(this,"events")&&jQuery.data(this,"events")[event.type],args=Array.prototype.slice.call(arguments,1);args.unshift(event);for(var j in handlers){var handler=handlers[j];args[0].handler=handler;args[0].data=handler.data;if(!parts[1]&&!event.exclusive||handler.type==parts[1]){var ret=handler.apply(this,args);if(val!==false)
val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}
if(jQuery.browser.msie)
event.target=event.preventDefault=event.stopPropagation=event.handler=event.data=null;return val;},fix:function(event){var originalEvent=event;event=jQuery.extend({},originalEvent);event.preventDefault=function(){if(originalEvent.preventDefault)
originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)
originalEvent.stopPropagation();originalEvent.cancelBubble=true;};if(!event.target)
event.target=event.srcElement||document;if(event.target.nodeType==3)
event.target=originalEvent.target.parentNode;if(!event.relatedTarget&&event.fromElement)
event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}
if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))
event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)
event.metaKey=event.ctrlKey;if(!event.which&&event.button)
event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;arguments[0].type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;arguments[0].type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){return this.each(function(){jQuery.event.add(this,type,function(event){jQuery(this).unbind(event);return(fn||data).apply(this,arguments);},fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){if(this[0])
return jQuery.event.trigger(type,data,this[0],false,fn);return undefined;},toggle:function(){var args=arguments;return this.click(function(event){this.lastToggle=0==this.lastToggle?1:0;event.preventDefault();return args[this.lastToggle].apply(this,arguments)||false;});},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)
fn.call(document,jQuery);else
jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.apply(document);});jQuery.readyList=null;}
jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)
document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}
jQuery.ready();})();if(jQuery.browser.opera)
document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i<document.styleSheets.length;i++)
if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}
jQuery.ready();},false);if(jQuery.browser.safari){var numStyles;(function(){if(jQuery.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}
if(numStyles===undefined)
numStyles=jQuery("style, link[rel=stylesheet]").length;if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}
jQuery.ready();})();}
jQuery.event.add(window,"load",jQuery.ready);}
jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,change,select,"+"submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});var withinElement=function(event,elem){var parent=event.relatedTarget;while(parent&&parent!=elem)try{parent=parent.parentNode;}catch(error){parent=elem;}
return parent==elem;};jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();});jQuery.fn.extend({load:function(url,params,callback){if(jQuery.isFunction(url))
return this.bind("load",url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}
callback=callback||function(){};var type="GET";if(params)
if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}
var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")
self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=(new Date).getTime();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}
return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}
return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){var jsonp,jsre=/=\?(&|$)/g,status,data;s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));if(s.data&&s.processData&&typeof s.data!="string")
s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(s.type.toLowerCase()=="get"){if(!s.url.match(jsre))
s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))
s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}
if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)
s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}
if(head)
head.removeChild(script);};}
if(s.dataType=="script"&&s.cache==null)
s.cache=false;if(s.cache===false&&s.type.toLowerCase()=="get"){var ts=(new Date()).getTime();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}
if(s.data&&s.type.toLowerCase()=="get"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}
if(s.global&&!jQuery.active++)
jQuery.event.trigger("ajaxStart");if((!s.url.indexOf("http")||!s.url.indexOf("//"))&&s.dataType=="script"&&s.type.toLowerCase()=="get"){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)
script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}
head.appendChild(script);return undefined;}
var requestDone=false;var xml=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();xml.open(s.type,s.url,s.async,s.username,s.password);try{if(s.data)
xml.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)
xml.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xml.setRequestHeader("X-Requested-With","XMLHttpRequest");xml.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}
if(s.beforeSend)
s.beforeSend(xml);if(s.global)
jQuery.event.trigger("ajaxSend",[xml,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xml&&(xml.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}
status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xml)&&"error"||s.ifModified&&jQuery.httpNotModified(xml,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xml,s.dataType);}catch(e){status="parsererror";}}
if(status=="success"){var modRes;try{modRes=xml.getResponseHeader("Last-Modified");}catch(e){}
if(s.ifModified&&modRes)
jQuery.lastModified[s.url]=modRes;if(!jsonp)
success();}else
jQuery.handleError(s,xml,status);complete();if(s.async)
xml=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)
setTimeout(function(){if(xml){xml.abort();if(!requestDone)
onreadystatechange("timeout");}},s.timeout);}
try{xml.send(s.data);}catch(e){jQuery.handleError(s,xml,null,e);}
if(!s.async)
onreadystatechange();function success(){if(s.success)
s.success(data,status);if(s.global)
jQuery.event.trigger("ajaxSuccess",[xml,s]);}
function complete(){if(s.complete)
s.complete(xml,status);if(s.global)
jQuery.event.trigger("ajaxComplete",[xml,s]);if(s.global&&!--jQuery.active)
jQuery.event.trigger("ajaxStop");}
return xml;},handleError:function(s,xml,status,e){if(s.error)s.error(xml,status,e);if(s.global)
jQuery.event.trigger("ajaxError",[xml,s,e]);},active:0,httpSuccess:function(r){try{return!r.status&&location.protocol=="file:"||(r.status>=200&&r.status<300)||r.status==304||r.status==1223||jQuery.browser.safari&&r.status==undefined;}catch(e){}
return false;},httpNotModified:function(xml,url){try{var xmlRes=xml.getResponseHeader("Last-Modified");return xml.status==304||xmlRes==jQuery.lastModified[url]||jQuery.browser.safari&&xml.status==undefined;}catch(e){}
return false;},httpData:function(r,type){var ct=r.getResponseHeader("content-type");var xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0;var data=xml?r.responseXML:r.responseText;if(xml&&data.documentElement.tagName=="parsererror")
throw"parsererror";if(type=="script")
jQuery.globalEval(data);if(type=="json")
data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)
jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else
for(var j in a)
if(a[j]&&a[j].constructor==Array)
jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else
s.push(encodeURIComponent(j)+"="+encodeURIComponent(a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")
this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle(fn,fn2):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)
return false;var opt=jQuery.extend({},optall);var hidden=jQuery(this).is(":hidden"),self=this;for(var p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)
return jQuery.isFunction(opt.complete)&&opt.complete.apply(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}
if(opt.overflow!=null)
this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))
e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}
if(parts[1])
end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}
if(!type||(typeof type=="string"&&!fn))
return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)
queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)
fn.apply(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)
this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)
if(timers[i].elem==this){if(gotoEnd)
timers[i](true);timers.splice(i,1);}});if(!gotoEnd)
this.dequeue();return this;}});var queue=function(elem,type,array){if(!elem)
return undefined;type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)
q=jQuery.data(elem,type+"queue",array?jQuery.makeArray(array):[]);return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)
q[0].apply(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:{slow:600,fast:200}[opt.duration])||400;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)
jQuery(this).dequeue();if(jQuery.isFunction(opt.old))
opt.old.apply(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)
options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)
this.options.step.apply(this.elem,[this.now,this]);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")
this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)
return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=(new Date()).getTime();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}
t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)
if(!timers[i]())
timers.splice(i--,1);if(!timers.length){clearInterval(jQuery.timerId);jQuery.timerId=null;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(0,this.cur());if(this.prop=="width"||this.prop=="height")
this.elem.style[this.prop]="1px";jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=(new Date()).getTime();if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)
if(this.options.curAnim[i]!==true)
done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")
this.elem.style.display="block";}
if(this.options.hide)
this.elem.style.display="none";if(this.options.hide||this.options.show)
for(var p in this.options.curAnim)
jQuery.attr(this.elem.style,p,this.options.orig[p]);}
if(done&&jQuery.isFunction(this.options.complete))
this.options.complete.apply(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}
return true;}};jQuery.fx.step={scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}};jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522&&!/adobeair/i.test(userAgent),fixed=jQuery.css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)
border(offsetParent);if(!fixed&&jQuery.css(offsetParent,"position")=="fixed")
fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}
while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(jQuery.css(parent,"display")))
add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&jQuery.css(parent,"overflow")!="visible")
border(parent);parent=parent.parentNode;}
if((safari2&&(fixed||jQuery.css(offsetChild,"position")=="absolute"))||(mozilla&&jQuery.css(offsetChild,"position")!="absolute"))
add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)
add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}
results={top:top,left:left};}
function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}
function add(l,t){left+=parseInt(l)||0;top+=parseInt(t)||0;}
return results;};})();


var isIE=document.all;var isOpera=window.opera;


(function($){$.fn.extend({mousewheel:function(f){if(!f.guid)f.guid=$.event.guid++;if(!$.event._mwCache)$.event._mwCache=[];return this.each(function(){if(this._mwHandlers)return this._mwHandlers.push(f);else this._mwHandlers=[];this._mwHandlers.push(f);var s=this;this._mwHandler=function(e){e=$.event.fix(e||window.event);var delta=0,returnValue=true;if(e.wheelDelta)delta=e.wheelDelta/120;if(e.detail)delta=-e.detail/3;if(window.opera)delta=-e.wheelDelta;for(var i=0;i<s._mwHandlers.length;i++)
if(s._mwHandlers[i])
if(s._mwHandlers[i].call(s,e,delta)===false){returnValue=false;e.preventDefault();e.stopPropagation();}
return returnValue;};if(this.addEventListener)
if($.browser.mozilla)this.addEventListener('DOMMouseScroll',this._mwHandler,false);else this.addEventListener('mousewheel',this._mwHandler,false);else
$.event.add(this,'mousewheel',this._mwHandler);$.event._mwCache.push($(this));});},unmousewheel:function(f){return this.each(function(){if(f&&this._mwHandlers){for(var i=0;i<this._mwHandlers.length;i++)
if(this._mwHandlers[i]&&this._mwHandlers[i].guid==f.guid)
delete this._mwHandlers[i];}else{if(this.addEventListener)
if($.browser.mozilla)this.removeEventListener('DOMMouseScroll',this._mwHandler,false);else this.removeEventListener('mousewheel',this._mwHandler,false);else
$.event.remove(this,'mousewheel',this._mwHandler);this._mwHandlers=this._mwHandler=null;}});}});$(window).bind('unload',function(){var els=$.event._mwCache||[];for(var i=0;i<els.length;i++)
els[i].unmousewheel();});})(jQuery);


$.fn.pager=function(clas,options){var settings={navId:'nav',navClass:'nav',navAttach:'append',highlightClass:'highlight',prevText:'&laquo;',nextText:'&raquo;',linkText:null,linkWrap:null,height:null}
if(options)$.extend(settings,options);return this.each(function(){var me=$(this);var size;var i=0;var navid='#'+settings.navId;function init(){size=$(clas,me).not(navid).size();if(settings.height==null){settings.height=getHighest();}
if(size>1){makeNav();show();highlight();}
sizePanel();if(settings.linkWrap!=null){linkWrap();}}
function makeNav(){var str='<div id="'+settings.navId+'" class="'+settings.navClass+'">';str+='<a href="#" rel="prev">'+settings.prevText+'</a>';for(var i=0;i<size;i++){var j=i+1;str+='<a href="#" rel="'+j+'">';str+=(settings.linkText==null)?j:settings.linkText[j-1];str+='</a>';}
str+='<a href="#" rel="next">'+settings.nextText+'</a>';str+='</div>';switch(settings.navAttach){case'before':$(me).before(str);break;case'after':$(me).after(str);break;case'prepend':$(me).prepend(str);break;default:$(me).append(str);break;}}
function show(){$(clas).not(navid).hide();var show=$(clas).not(navid).get(i);$(show).show();}
function highlight(){$(navid).find('a').removeClass(settings.highlightClass);var show=$(navid).find('a').get(i+1);$(show).addClass(settings.highlightClass);}
function sizePanel(){if($.browser.msie){$(clas).not(navid).css({height:settings.height});}else{$(clas).not(navid).css({minHeight:settings.height});}}
function getHighest(){var highest=0;$(clas).not(navid).each(function(){if(this.offsetHeight>highest){highest=this.offsetHeight;}});highest=highest+"px";return highest;}
function getNavHeight(){var nav=$(navid).get(0);return nav.offsetHeight;}
function linkWrap(){$(navid).find("a").wrap(settings.linkWrap);}
init();$(this).find(navid).find("a").click(function(){if($(this).attr('rel')=='next'){if(i+1<size){i=i+1;}}else if($(this).attr('rel')=='prev'){if(i>0){i=i-1;}}else{var j=$(this).attr('rel');i=j-1;}
show();highlight();return false;});});}


jQuery.jScrollPane={active:[]};jQuery.fn.jScrollPane=function(settings)
{settings=jQuery.extend({scrollbarWidth:10,scrollbarMargin:5,wheelSpeed:18,showArrows:false,arrowSize:0,animateTo:false,dragMinHeight:1,dragMaxHeight:99999,animateInterval:100,animateStep:3,maintainPosition:true},settings);return this.each(function()
{var $this=jQuery(this);if(jQuery(this).parent().is('.jScrollPaneContainer')){var currentScrollPosition=settings.maintainPosition?$this.offset({relativeTo:jQuery(this).parent()[0]}).top:0;var $c=jQuery(this).parent();var paneWidth=$c.innerWidth();var paneHeight=$c.outerHeight();var trackHeight=paneHeight;if($c.unmousewheel){$c.unmousewheel();}
jQuery('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown',$c).remove();$this.css({'top':0});}else{var currentScrollPosition=0;this.originalPadding=$this.css('paddingTop')+' '+$this.css('paddingRight')+' '+$this.css('paddingBottom')+' '+$this.css('paddingLeft');this.originalSidePaddingTotal=(parseInt($this.css('paddingLeft'))||0)+(parseInt($this.css('paddingRight'))||0);var paneWidth=$this.innerWidth();var paneHeight=$this.innerHeight();var trackHeight=paneHeight;$this.wrap(jQuery('<div></div>').attr({'className':'jScrollPaneContainer'}).css({'height':paneHeight+'px','width':paneWidth+'px'}));jQuery(document).bind('emchange',function(e,cur,prev)
{$this.jScrollPane(settings);});}
var p=this.originalSidePaddingTotal;$this.css({'height':'auto','width':paneWidth-settings.scrollbarWidth-settings.scrollbarMargin-p+'px','paddingRight':settings.scrollbarMargin+'px'});var contentHeight=$this.outerHeight();var percentInView=paneHeight/contentHeight;if(percentInView<.99){var $container=$this.parent();$container.append(jQuery('<div></div>').attr({'className':'jScrollPaneTrack'}).css({'width':settings.scrollbarWidth+'px'}).append(jQuery('<div></div>').attr({'className':'jScrollPaneDrag'}).css({'width':settings.scrollbarWidth+'px'}).append(jQuery('<div></div>').attr({'className':'jScrollPaneDragTop'}).css({'width':settings.scrollbarWidth+'px'}),jQuery('<div></div>').attr({'className':'jScrollPaneDragBottom'}).css({'width':settings.scrollbarWidth+'px'}))));var $track=jQuery('>.jScrollPaneTrack',$container);var $drag=jQuery('>.jScrollPaneTrack .jScrollPaneDrag',$container);if(settings.showArrows){var currentArrowButton;var currentArrowDirection;var currentArrowInterval;var currentArrowInc;var whileArrowButtonDown=function()
{if(currentArrowInc>4||currentArrowInc%4==0){positionDrag(dragPosition+currentArrowDirection*mouseWheelMultiplier);}
currentArrowInc++;};var onArrowMouseUp=function(event)
{jQuery('body').unbind('mouseup',onArrowMouseUp);currentArrowButton.removeClass('jScrollActiveArrowButton');clearInterval(currentArrowInterval);};var onArrowMouseDown=function(){jQuery('body').bind('mouseup',onArrowMouseUp);currentArrowButton.addClass('jScrollActiveArrowButton');currentArrowInc=0;whileArrowButtonDown();currentArrowInterval=setInterval(whileArrowButtonDown,100);};$container.append(jQuery('<a></a>').attr({'href':'javascript:;','className':'jScrollArrowUp'}).css({'width':settings.scrollbarWidth+'px'}).html('Scroll up').bind('mousedown',function()
{currentArrowButton=jQuery(this);currentArrowDirection=-1;onArrowMouseDown();this.blur();return false;}),jQuery('<a></a>').attr({'href':'javascript:;','className':'jScrollArrowDown'}).css({'width':settings.scrollbarWidth+'px'}).html('Scroll down').bind('mousedown',function()
{currentArrowButton=jQuery(this);currentArrowDirection=1;onArrowMouseDown();this.blur();return false;}));if(settings.arrowSize){trackHeight=paneHeight-settings.arrowSize-settings.arrowSize;$track.css({'height':trackHeight+'px',top:settings.arrowSize+'px'})}else{var topArrowHeight=jQuery('>.jScrollArrowUp',$container).height();settings.arrowSize=topArrowHeight;trackHeight=paneHeight-topArrowHeight-jQuery('>.jScrollArrowDown',$container).height();$track.css({'height':trackHeight+'px',top:topArrowHeight+'px'})}}
var $pane=jQuery(this).css({'position':'absolute','overflow':'visible'});var currentOffset;var maxY;var mouseWheelMultiplier;var dragPosition=0;var dragMiddle=percentInView*paneHeight/2;var getPos=function(event,c){var p=c=='X'?'Left':'Top';return event['page'+c]||(event['client'+c]+(document.documentElement['scroll'+p]||document.body['scroll'+p]))||0;};var ignoreNativeDrag=function(){return false;};var initDrag=function()
{ceaseAnimation();currentOffset=$drag.offset(false);currentOffset.top-=dragPosition;maxY=trackHeight-$drag[0].offsetHeight;mouseWheelMultiplier=2*settings.wheelSpeed*maxY/contentHeight;};var onStartDrag=function(event)
{initDrag();dragMiddle=getPos(event,'Y')-dragPosition-currentOffset.top;jQuery('body').bind('mouseup',onStopDrag).bind('mousemove',updateScroll);if(jQuery.browser.msie){jQuery('body').bind('dragstart',ignoreNativeDrag).bind('selectstart',ignoreNativeDrag);}
return false;};var onStopDrag=function()
{jQuery('body').unbind('mouseup',onStopDrag).unbind('mousemove',updateScroll);dragMiddle=percentInView*paneHeight/2;if(jQuery.browser.msie){jQuery('body').unbind('dragstart',ignoreNativeDrag).unbind('selectstart',ignoreNativeDrag);}};var positionDrag=function(destY)
{destY=destY<0?0:(destY>maxY?maxY:destY);dragPosition=destY;$drag.css({'top':destY+'px'});var p=destY/maxY;$pane.css({'top':((paneHeight-contentHeight)*p)+'px'});$this.trigger('scroll');};var updateScroll=function(e)
{positionDrag(getPos(e,'Y')-currentOffset.top-dragMiddle);};var dragH=Math.max(Math.min(percentInView*(paneHeight-settings.arrowSize*2),settings.dragMaxHeight),settings.dragMinHeight);$drag.css({'height':dragH+'px'}).bind('mousedown',onStartDrag);var trackScrollInterval;var trackScrollInc;var trackScrollMousePos;var doTrackScroll=function()
{if(trackScrollInc>8||trackScrollInc%4==0){positionDrag((dragPosition-((dragPosition-trackScrollMousePos)/2)));}
trackScrollInc++;};var onStopTrackClick=function()
{clearInterval(trackScrollInterval);jQuery('body').unbind('mouseup',onStopTrackClick).unbind('mousemove',onTrackMouseMove);};var onTrackMouseMove=function(event)
{trackScrollMousePos=getPos(event,'Y')-currentOffset.top-dragMiddle;};var onTrackClick=function(event)
{initDrag();onTrackMouseMove(event);trackScrollInc=0;jQuery('body').bind('mouseup',onStopTrackClick).bind('mousemove',onTrackMouseMove);trackScrollInterval=setInterval(doTrackScroll,100);doTrackScroll();};$track.bind('mousedown',onTrackClick);if($container.mousewheel){$container.mousewheel(function(event,delta){initDrag();ceaseAnimation();var d=dragPosition;positionDrag(dragPosition-delta*mouseWheelMultiplier);var dragOccured=d!=dragPosition;return!dragOccured;},false);}
var _animateToPosition;var _animateToInterval;function animateToPosition()
{var diff=(_animateToPosition-dragPosition)/settings.animateStep;if(diff>1||diff<-1){positionDrag(dragPosition+diff);}else{positionDrag(_animateToPosition);ceaseAnimation();}}
var ceaseAnimation=function()
{if(_animateToInterval){clearInterval(_animateToInterval);delete _animateToPosition;}};var scrollTo=function(pos,preventAni)
{if(typeof pos=="string"){$e=jQuery(pos,this);if(!$e.length)return;pos=$e.offset({relativeTo:this}).top;}
ceaseAnimation();var destDragPosition=-pos/(paneHeight-contentHeight)*maxY;if(!preventAni||settings.animateTo){_animateToPosition=destDragPosition;_animateToInterval=setInterval(animateToPosition,settings.animateInterval);}else{positionDrag(destDragPosition);}};$this[0].scrollTo=scrollTo;$this[0].scrollBy=function(delta)
{var currentPos=-parseInt($pane.css('top'))||0;scrollTo(currentPos+delta);};initDrag();scrollTo(-currentScrollPosition,true);jQuery.jScrollPane.active.push($this[0]);}else{$this.css({'height':paneHeight+'px','width':paneWidth-this.originalSidePaddingTotal+'px','padding':this.originalPadding});}})};jQuery(window).bind('unload',function(){var els=jQuery.jScrollPane.active;for(var i=0;i<els.length;i++){els[i].scrollTo=els[i].scrollBy=null;}});


(function(){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},s={array:function(x){var a=['['],b,f,i,l=x.length,v;for(i=0;i<l;i+=1){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}
a[a.length]=v;b=true;}}}
a[a.length]=']';return a.join('');},'boolean':function(x){return String(x);},'null':function(x){return"null";},number:function(x){return isFinite(x)?String(x):'null';},object:function(x){if(x){if(x instanceof Array){return s.array(x);}
var a=['{'],b,f,i,v;for(i in x){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}
a.push(s.string(i),':',v);b=true;}}}
a[a.length]='}';return a.join('');}
return'null';},string:function(x){if(/["\\\x00-\x1f]/.test(x)){x=x.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}
c=b.charCodeAt();return'\\u00'+
Math.floor(c/16).toString(16)+
(c%16).toString(16);});}
return'"'+x+'"';}};Object.toJSON=function(obj){return s.object(obj);};})();String.prototype.parseJSON=function(){try{return!(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(this.replace(/"(\\.|[^"\\])*"/g,'')))&&eval('('+this+')');}catch(e){return false;}};


(function($){$.dimensions={version:'@VERSION'};$.each(['Height','Width'],function(i,name){$.fn['inner'+name]=function(){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';return this.is(':visible')?this[0]['client'+name]:num(this,name.toLowerCase())+num(this,'padding'+torl)+num(this,'padding'+borr);};$.fn['outer'+name]=function(options){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';options=$.extend({margin:false},options||{});var val=this.is(':visible')?this[0]['offset'+name]:num(this,name.toLowerCase())
+num(this,'border'+torl+'Width')+num(this,'border'+borr+'Width')
+num(this,'padding'+torl)+num(this,'padding'+borr);return val+(options.margin?(num(this,'margin'+torl)+num(this,'margin'+borr)):0);};});$.each(['Left','Top'],function(i,name){$.fn['scroll'+name]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(name=='Left'?val:$(window)['scrollLeft'](),name=='Top'?val:$(window)['scrollTop']()):this['scroll'+name]=val;}):this[0]==window||this[0]==document?self[(name=='Left'?'pageXOffset':'pageYOffset')]||$.boxModel&&document.documentElement['scroll'+name]||document.body['scroll'+name]:this[0]['scroll'+name];};});$.fn.extend({position:function(){var left=0,top=0,elem=this[0],offset,parentOffset,offsetParent,results;if(elem){offsetParent=this.offsetParent();offset=this.offset();parentOffset=offsetParent.offset();offset.top-=num(elem,'marginTop');offset.left-=num(elem,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}
return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&$.css(offsetParent,'position')=='static'))
offsetParent=offsetParent.offsetParent;return $(offsetParent);}});function num(el,prop){return parseInt($.css(el.jquery?el[0]:el,prop))||0;};})(jQuery);


$.fn.pager=function(clas,options){var settings={navId:'nav',navClass:'nav',navAttach:'append',highlightClass:'highlight',prevText:'&laquo;',nextText:'&raquo;',linkText:null,linkWrap:null,height:null}
if(options)$.extend(settings,options);return this.each(function(){var me=$(this);var size;var i=0;var navid='#'+settings.navId;function init(){size=$(clas,me).not(navid).size();if(settings.height==null){settings.height=getHighest();}
if(size>1){makeNav();show();highlight();}
sizePanel();if(settings.linkWrap!=null){linkWrap();}}
function makeNav(){var str='<div id="'+settings.navId+'" class="'+settings.navClass+'">';str+='<a href="#" rel="prev">'+settings.prevText+'</a>';for(var i=0;i<size;i++){var j=i+1;str+='<a href="#" rel="'+j+'">';str+=(settings.linkText==null)?j:settings.linkText[j-1];str+='</a>';}
str+='<a href="#" rel="next">'+settings.nextText+'</a>';str+='</div>';switch(settings.navAttach){case'before':$(me).before(str);break;case'after':$(me).after(str);break;case'prepend':$(me).prepend(str);break;default:$(me).append(str);break;}}
function show(){$(clas).not(navid).hide();var show=$(clas).not(navid).get(i);$(show).show();}
function highlight(){$(navid).find('a').removeClass(settings.highlightClass);var show=$(navid).find('a').get(i+1);$(show).addClass(settings.highlightClass);}
function sizePanel(){if($.browser.msie){$(clas).not(navid).css({height:settings.height});}else{$(clas).not(navid).css({minHeight:settings.height});}}
function getHighest(){var highest=0;$(clas).not(navid).each(function(){if(this.offsetHeight>highest){highest=this.offsetHeight;}});highest=highest+"px";return highest;}
function getNavHeight(){var nav=$(navid).get(0);return nav.offsetHeight;}
function linkWrap(){$(navid).find("a").wrap(settings.linkWrap);}
init();$(this).find(navid).find("a").click(function(){if($(this).attr('rel')=='next'){if(i+1<size){i=i+1;}}else if($(this).attr('rel')=='prev'){if(i>0){i=i-1;}}else{var j=$(this).attr('rel');i=j-1;}
show();highlight();return false;});});}

;(function($){$.ui={plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]]);}},call:function(instance,name,args){var set=instance.plugins[name];if(!set){return;}
for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args);}}}},cssCache:{},css:function(name){if($.ui.cssCache[name]){return $.ui.cssCache[name];}
var tmp=$('<div class="ui-resizable-gen">').addClass(name).css({position:'absolute',top:'-5000px',left:'-5000px',display:'block'}).appendTo('body');$.ui.cssCache[name]=!!((!(/auto|default/).test(tmp.css('cursor'))||(/^[1-9]/).test(tmp.css('height'))||(/^[1-9]/).test(tmp.css('width'))||!(/none/).test(tmp.css('backgroundImage'))||!(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor'))));try{$('body').get(0).removeChild(tmp.get(0));}catch(e){}
return $.ui.cssCache[name];},disableSelection:function(e){e.unselectable="on";e.onselectstart=function(){return false;};if(e.style){e.style.MozUserSelect="none";}},enableSelection:function(e){e.unselectable="off";e.onselectstart=function(){return true;};if(e.style){e.style.MozUserSelect="";}},hasScroll:function(e,a){var scroll=/top/.test(a||"top")?'scrollTop':'scrollLeft',has=false;if(e[scroll]>0)return true;e[scroll]=1;has=e[scroll]>0?true:false;e[scroll]=0;return has;}};var _remove=$.fn.remove;$.fn.remove=function(){$("*",this).add(this).trigger("remove");return _remove.apply(this,arguments);};function getter(namespace,plugin,method){var methods=$[namespace][plugin].getter||[];methods=(typeof methods=="string"?methods.split(/,?\s+/):methods);return($.inArray(method,methods)!=-1);}
$.widget=function(name,prototype){var namespace=name.split(".")[0];name=name.split(".")[1];$.fn[name]=function(options){var isMethodCall=(typeof options=='string'),args=Array.prototype.slice.call(arguments,1);if(isMethodCall&&getter(namespace,name,options)){var instance=$.data(this[0],name);return(instance?instance[options].apply(instance,args):undefined);}
return this.each(function(){var instance=$.data(this,name);if(isMethodCall&&instance&&$.isFunction(instance[options])){instance[options].apply(instance,args);}else if(!isMethodCall){$.data(this,name,new $[namespace][name](this,options));}});};$[namespace][name]=function(element,options){var self=this;this.widgetName=name;this.widgetBaseClass=namespace+'-'+name;this.options=$.extend({disabled:false},$[namespace][name].defaults,options);this.element=$(element).bind('setData.'+name,function(e,key,value){return self.setData(key,value);}).bind('getData.'+name,function(e,key){return self.getData(key);}).bind('remove',function(){return self.destroy();});this.init();};$[namespace][name].prototype=$.extend({},$.widget.prototype,prototype);};$.widget.prototype={init:function(){},destroy:function(){this.element.removeData(this.widgetName);},getData:function(key){return this.options[key];},setData:function(key,value){this.options[key]=value;if(key=='disabled'){this.element[value?'addClass':'removeClass'](this.widgetBaseClass+'-disabled');}},enable:function(){this.setData('disabled',false);},disable:function(){this.setData('disabled',true);}};$.ui.mouse={mouseInit:function(){var self=this;this.element.bind('mousedown.'+this.widgetName,function(e){return self.mouseDown(e);});if($.browser.msie){this._mouseUnselectable=this.element.attr('unselectable');this.element.attr('unselectable','on');}
this.started=false;},mouseDestroy:function(){this.element.unbind('.'+this.widgetName);($.browser.msie&&this.element.attr('unselectable',this._mouseUnselectable));},mouseDown:function(e){(this._mouseStarted&&this.mouseUp(e));this._mouseDownEvent=e;var self=this,btnIsLeft=(e.which==1),elIsCancel=(typeof this.options.cancel=="string"?$(e.target).is(this.options.cancel):false);if(!btnIsLeft||elIsCancel||!this.mouseCapture(e)){return true;}
this._mouseDelayMet=!this.options.delay;if(!this._mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){self._mouseDelayMet=true;},this.options.delay);}
if(this.mouseDistanceMet(e)&&this.mouseDelayMet(e)){this._mouseStarted=(this.mouseStart(e)!==false);if(!this._mouseStarted){e.preventDefault();return true;}}
this._mouseMoveDelegate=function(e){return self.mouseMove(e);};this._mouseUpDelegate=function(e){return self.mouseUp(e);};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);return false;},mouseMove:function(e){if($.browser.msie&&!e.button){return this.mouseUp(e);}
if(this._mouseStarted){this.mouseDrag(e);return false;}
if(this.mouseDistanceMet(e)&&this.mouseDelayMet(e)){this._mouseStarted=(this.mouseStart(this._mouseDownEvent,e)!==false);(this._mouseStarted?this.mouseDrag(e):this.mouseUp(e));}
return!this._mouseStarted;},mouseUp:function(e){$(document).unbind('mousemove.'+this.widgetName,this._mouseMoveDelegate).unbind('mouseup.'+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this.mouseStop(e);}
return false;},mouseDistanceMet:function(e){return(Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance);},mouseDelayMet:function(e){return this._mouseDelayMet;},mouseStart:function(e){},mouseDrag:function(e){},mouseStop:function(e){},mouseCapture:function(e){return true;}};$.ui.mouse.defaults={cancel:null,distance:1,delay:0};})(jQuery);


(function($){$.ui=$.ui||{};$.extend($.ui,{plugin:{add:function(w,c,o,p){var a=$.ui[w].prototype;if(!a.plugins[c])a.plugins[c]=[];a.plugins[c].push([o,p]);},call:function(instance,name,arguments){var c=instance.plugins[name];if(!c)return;var o=instance.interaction?instance.interaction.options:instance.options;var e=instance.interaction?instance.interaction.element:instance.element;for(var i=0;i<c.length;i++){if(o[c[i][0]])c[i][1].apply(e,arguments);}}}});$.fn.mouseInteractionDestroy=function(){this.each(function(){if($.data(this,"ui-mouse"))$.data(this,"ui-mouse").destroy();});}
$.ui.mouseInteraction=function(el,o){if(!o)var o={};this.element=el;$.data(this.element,"ui-mouse",this);this.options={};$.extend(this.options,o);$.extend(this.options,{handle:o.handle?($(o.handle,el)[0]?$(o.handle,el):$(el)):$(el),helper:o.helper||'original',preventionDistance:o.preventionDistance||0,dragPrevention:o.dragPrevention?o.dragPrevention.toLowerCase().split(','):['input','textarea','button','select','option'],cursorAt:{top:((o.cursorAt&&o.cursorAt.top)?o.cursorAt.top:0),left:((o.cursorAt&&o.cursorAt.left)?o.cursorAt.left:0),bottom:((o.cursorAt&&o.cursorAt.bottom)?o.cursorAt.bottom:0),right:((o.cursorAt&&o.cursorAt.right)?o.cursorAt.right:0)},cursorAtIgnore:(!o.cursorAt)?true:false,appendTo:o.appendTo||'parent'})
o=this.options;if(!this.options.nonDestructive&&(o.helper=='clone'||o.helper=='original')){o.margins={top:parseInt($(el).css('marginTop'))||0,left:parseInt($(el).css('marginLeft'))||0,bottom:parseInt($(el).css('marginBottom'))||0,right:parseInt($(el).css('marginRight'))||0};if(o.cursorAt.top!=0)o.cursorAt.top=o.margins.top;if(o.cursorAt.left!=0)o.cursorAt.left+=o.margins.left;if(o.cursorAt.bottom!=0)o.cursorAt.bottom+=o.margins.bottom;if(o.cursorAt.right!=0)o.cursorAt.right+=o.margins.right;if(o.helper=='original')
o.wasPositioned=$(el).css('position');}else{o.margins={top:0,left:0,right:0,bottom:0};}
var self=this;this.mousedownfunc=function(e){return self.click.apply(self,[e]);}
o.handle.bind('mousedown',this.mousedownfunc);if($.browser.msie)$(this.element).attr('unselectable','on');}
$.extend($.ui.mouseInteraction.prototype,{plugins:{},currentTarget:null,lastTarget:null,timer:null,slowMode:false,init:false,destroy:function(){this.options.handle.unbind('mousedown',this.mousedownfunc);},trigger:function(e){return this.click.apply(this,arguments);},click:function(e){var o=this.options;window.focus();if(e.which!=1)return true;var targetName=(e.target)?e.target.nodeName.toLowerCase():e.srcElement.nodeName.toLowerCase();for(var i=0;i<o.dragPrevention.length;i++){if(targetName==o.dragPrevention[i])return true;}
if(o.startCondition&&!o.startCondition.apply(this,[e]))return true;var self=this;this.mouseup=function(e){return self.stop.apply(self,[e]);}
this.mousemove=function(e){return self.drag.apply(self,[e]);}
var initFunc=function(){$(document).bind('mouseup',self.mouseup);$(document).bind('mousemove',self.mousemove);self.opos=[e.pageX,e.pageY];}
if(o.preventionTimeout){if(this.timer)clearInterval(this.timer);this.timer=setTimeout(function(){initFunc();},o.preventionTimeout);return false;}
initFunc();return false;},start:function(e){var o=this.options;var a=this.element;o.co=$(a).offset();this.helper=typeof o.helper=='function'?$(o.helper.apply(a,[e,this]))[0]:(o.helper=='clone'?$(a).clone()[0]:a);if(o.appendTo=='parent'){var cp=a.parentNode;while(cp){if(cp.style&&($(cp).css('position')=='relative'||$(cp).css('position')=='absolute')){o.pp=cp;o.po=$(cp).offset();o.ppOverflow=!!($(o.pp).css('overflow')=='auto'||$(o.pp).css('overflow')=='scroll');break;}
cp=cp.parentNode?cp.parentNode:null;};if(!o.pp)o.po={top:0,left:0};}
this.pos=[this.opos[0],this.opos[1]];this.rpos=[this.pos[0],this.pos[1]];if(o.cursorAtIgnore){o.cursorAt.left=this.pos[0]-o.co.left+o.margins.left;o.cursorAt.top=this.pos[1]-o.co.top+o.margins.top;}
if(o.pp){this.pos[0]-=o.po.left;this.pos[1]-=o.po.top;}
this.slowMode=(o.cursorAt&&(o.cursorAt.top-o.margins.top>0||o.cursorAt.bottom-o.margins.bottom>0)&&(o.cursorAt.left-o.margins.left>0||o.cursorAt.right-o.margins.right>0))?true:false;if(!o.nonDestructive)$(this.helper).css('position','absolute');if(o.helper!='original')$(this.helper).appendTo((o.appendTo=='parent'?a.parentNode:o.appendTo)).show();if(o.cursorAt.right&&!o.cursorAt.left)o.cursorAt.left=this.helper.offsetWidth+o.margins.right+o.margins.left-o.cursorAt.right;if(o.cursorAt.bottom&&!o.cursorAt.top)o.cursorAt.top=this.helper.offsetHeight+o.margins.top+o.margins.bottom-o.cursorAt.bottom;this.init=true;if(o._start)o._start.apply(a,[this.helper,this.pos,o.cursorAt,this,e]);this.helperSize={width:$(this.helper).outerWidth(),height:$(this.helper).outerHeight()};return false;},stop:function(e){var o=this.options;var a=this.element;var self=this;$(document).unbind('mouseup',self.mouseup);$(document).unbind('mousemove',self.mousemove);if(this.init==false)return this.opos=this.pos=null;if(o._beforeStop)o._beforeStop.apply(a,[this.helper,this.pos,o.cursorAt,this,e]);if(this.helper!=a&&!o.beQuietAtEnd){$(this.helper).remove();this.helper=null;}
if(!o.beQuietAtEnd){if(o._stop)o._stop.apply(a,[this.helper,this.pos,o.cursorAt,this,e]);}
this.init=false;this.opos=this.pos=null;return false;},drag:function(e){if(!this.opos||($.browser.msie&&!e.button))return this.stop.apply(this,[e]);var o=this.options;this.pos=[e.pageX,e.pageY];if(this.rpos&&this.rpos[0]==this.pos[0]&&this.rpos[1]==this.pos[1])return false;this.rpos=[this.pos[0],this.pos[1]];if(o.pp){this.pos[0]-=o.po.left;this.pos[1]-=o.po.top;}
if((Math.abs(this.rpos[0]-this.opos[0])>o.preventionDistance||Math.abs(this.rpos[1]-this.opos[1])>o.preventionDistance)&&this.init==false)
this.start.apply(this,[e]);else{if(this.init==false)return false;}
if(o._drag)o._drag.apply(this.element,[this.helper,this.pos,o.cursorAt,this,e]);return false;}});})(jQuery);


(function($){$.widget("ui.draggable",$.extend($.ui.mouse,{init:function(){var o=this.options;if(o.helper=='original'&&!(/(relative|absolute|fixed)/).test(this.element.css('position')))
this.element.css('position','relative');this.element.addClass('ui-draggable');(o.disabled&&this.element.addClass('ui-draggable-disabled'));this.mouseInit();},mouseStart:function(e){var o=this.options;if(this.helper||o.disabled||$(e.target).is('.ui-resizable-handle'))return false;var handle=!this.options.handle||!$(this.options.handle,this.element).length?true:false;$(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==e.target)handle=true;});if(!handle)return false;if($.ui.ddmanager)$.ui.ddmanager.current=this;this.helper=$.isFunction(o.helper)?$(o.helper.apply(this.element[0],[e])):(o.helper=='clone'?this.element.clone():this.element);if(!this.helper.parents('body').length)this.helper.appendTo((o.appendTo=='parent'?this.element[0].parentNode:o.appendTo));if(this.helper[0]!=this.element[0]&&!(/(fixed|absolute)/).test(this.helper.css("position")))this.helper.css("position","absolute");this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)};this.cssPosition=this.helper.css("position");this.offset=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.offset.click={left:e.pageX-this.offset.left,top:e.pageY-this.offset.top};this.offsetParent=this.helper.offsetParent();var po=this.offsetParent.offset();if(this.offsetParent[0]==document.body&&$.browser.mozilla)po={top:0,left:0};this.offset.parent={top:po.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:po.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};var p=this.element.position();this.offset.relative=this.cssPosition=="relative"?{top:p.top-(parseInt(this.helper.css("top"),10)||0)+this.offsetParent[0].scrollTop,left:p.left-(parseInt(this.helper.css("left"),10)||0)+this.offsetParent[0].scrollLeft}:{top:0,left:0};this.originalPosition=this.generatePosition(e);this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if(o.cursorAt){if(o.cursorAt.left!=undefined)this.offset.click.left=o.cursorAt.left+this.margins.left;if(o.cursorAt.right!=undefined)this.offset.click.left=this.helperProportions.width-o.cursorAt.right+this.margins.left;if(o.cursorAt.top!=undefined)this.offset.click.top=o.cursorAt.top+this.margins.top;if(o.cursorAt.bottom!=undefined)this.offset.click.top=this.helperProportions.height-o.cursorAt.bottom+this.margins.top;}
if(o.containment){if(o.containment=='parent')o.containment=this.helper[0].parentNode;if(o.containment=='document'||o.containment=='window')this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,$(o.containment=='document'?document:window).width()-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),($(o.containment=='document'?document:window).height()||document.body.parentNode.scrollHeight)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)];if(!(/^(document|window|parent)$/).test(o.containment)){var ce=$(o.containment)[0];var co=$(o.containment).offset();this.containment=[co.left+(parseInt($(ce).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left,co.top+(parseInt($(ce).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top,co.left+Math.max(ce.scrollWidth,ce.offsetWidth)-(parseInt($(ce).css("borderLeftWidth"),10)||0)-this.offset.relative.left-this.offset.parent.left-this.helperProportions.width-this.margins.left-(parseInt(this.element.css("marginRight"),10)||0),co.top+Math.max(ce.scrollHeight,ce.offsetHeight)-(parseInt($(ce).css("borderTopWidth"),10)||0)-this.offset.relative.top-this.offset.parent.top-this.helperProportions.height-this.margins.top-(parseInt(this.element.css("marginBottom"),10)||0)];}}
this.propagate("start",e);this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};if($.ui.ddmanager&&!o.dropBehaviour)$.ui.ddmanager.prepareOffsets(this,e);this.helper.addClass("ui-draggable-dragging");this.mouseDrag(e);return true;},convertPositionTo:function(d,pos){if(!pos)pos=this.position;var mod=d=="absolute"?1:-1;return{top:(pos.top
+this.offset.relative.top*mod
+this.offset.parent.top*mod
-(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollTop)*mod
+(this.cssPosition=="fixed"?this.offsetParent[0].scrollTop:0)*mod
+this.margins.top*mod),left:(pos.left
+this.offset.relative.left*mod
+this.offset.parent.left*mod
-(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollLeft)*mod
+(this.cssPosition=="fixed"?this.offsetParent[0].scrollLeft:0)*mod
+this.margins.left*mod)};},generatePosition:function(e){var o=this.options;var position={top:(e.pageY
-this.offset.click.top
-this.offset.relative.top
-this.offset.parent.top
+(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollTop)
-(this.cssPosition=="fixed"?this.offsetParent[0].scrollTop:0)),left:(e.pageX
-this.offset.click.left
-this.offset.relative.left
-this.offset.parent.left
+(this.cssPosition=="fixed"||(this.cssPosition=="absolute"&&this.offsetParent[0]==document.body)?0:this.offsetParent[0].scrollLeft)
-(this.cssPosition=="fixed"?this.offsetParent[0].scrollLeft:0))};if(!this.originalPosition)return position;if(this.containment){if(position.left<this.containment[0])position.left=this.containment[0];if(position.top<this.containment[1])position.top=this.containment[1];if(position.left>this.containment[2])position.left=this.containment[2];if(position.top>this.containment[3])position.top=this.containment[3];}
if(o.grid){var top=this.originalPosition.top+Math.round((position.top-this.originalPosition.top)/o.grid[1])*o.grid[1];position.top=this.containment?(!(top<this.containment[1]||top>this.containment[3])?top:(!(top<this.containment[1])?top-o.grid[1]:top+o.grid[1])):top;var left=this.originalPosition.left+Math.round((position.left-this.originalPosition.left)/o.grid[0])*o.grid[0];position.left=this.containment?(!(left<this.containment[0]||left>this.containment[2])?left:(!(left<this.containment[0])?left-o.grid[0]:left+o.grid[0])):left;}
return position;},mouseDrag:function(e){this.position=this.generatePosition(e);this.positionAbs=this.convertPositionTo("absolute");this.position=this.propagate("drag",e)||this.position;if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+'px';if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+'px';if($.ui.ddmanager)$.ui.ddmanager.drag(this,e);return false;},mouseStop:function(e){if($.ui.ddmanager&&!this.options.dropBehaviour)
$.ui.ddmanager.drop(this,e);if(this.options.revert){var self=this;$(this.helper).animate(this.originalPosition,parseInt(this.options.revert,10)||500,function(){self.propagate("stop",e);self.clear();});}else{this.propagate("stop",e);this.clear();}
return false;},clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.options.helper!='original'&&!this.cancelHelperRemoval)this.helper.remove();this.helper=null;this.cancelHelperRemoval=false;},plugins:{},uiHash:function(e){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,options:this.options};},propagate:function(n,e){$.ui.plugin.call(this,n,[e,this.uiHash()]);return this.element.triggerHandler(n=="drag"?n:"drag"+n,[e,this.uiHash()],this.options[n]);},destroy:function(){if(!this.element.data('draggable'))return;this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable');this.mouseDestroy();}}));$.extend($.ui.draggable,{defaults:{appendTo:"parent",axis:false,cancel:":input,button",delay:0,distance:0,helper:"original"}});$.ui.plugin.add("draggable","cursor",{start:function(e,ui){var t=$('body');if(t.css("cursor"))ui.options._cursor=t.css("cursor");t.css("cursor",ui.options.cursor);},stop:function(e,ui){if(ui.options._cursor)$('body').css("cursor",ui.options._cursor);}});$.ui.plugin.add("draggable","zIndex",{start:function(e,ui){var t=$(ui.helper);if(t.css("zIndex"))ui.options._zIndex=t.css("zIndex");t.css('zIndex',ui.options.zIndex);},stop:function(e,ui){if(ui.options._zIndex)$(ui.helper).css('zIndex',ui.options._zIndex);}});$.ui.plugin.add("draggable","opacity",{start:function(e,ui){var t=$(ui.helper);if(t.css("opacity"))ui.options._opacity=t.css("opacity");t.css('opacity',ui.options.opacity);},stop:function(e,ui){if(ui.options._opacity)$(ui.helper).css('opacity',ui.options._opacity);}});$.ui.plugin.add("draggable","iframeFix",{start:function(e,ui){$(ui.options.iframeFix===true?"iframe":ui.options.iframeFix).each(function(){$('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css($(this).offset()).appendTo("body");});},stop:function(e,ui){$("div.DragDropIframeFix").each(function(){this.parentNode.removeChild(this);});}});$.ui.plugin.add("draggable","scroll",{start:function(e,ui){var o=ui.options;var i=$(this).data("draggable");o.scrollSensitivity=o.scrollSensitivity||20;o.scrollSpeed=o.scrollSpeed||20;i.overflowY=function(el){do{if(/auto|scroll/.test(el.css('overflow'))||(/auto|scroll/).test(el.css('overflow-y')))return el;el=el.parent();}while(el[0].parentNode);return $(document);}(this);i.overflowX=function(el){do{if(/auto|scroll/.test(el.css('overflow'))||(/auto|scroll/).test(el.css('overflow-x')))return el;el=el.parent();}while(el[0].parentNode);return $(document);}(this);if(i.overflowY[0]!=document&&i.overflowY[0].tagName!='HTML')i.overflowYOffset=i.overflowY.offset();if(i.overflowX[0]!=document&&i.overflowX[0].tagName!='HTML')i.overflowXOffset=i.overflowX.offset();},drag:function(e,ui){var o=ui.options;var i=$(this).data("draggable");if(i.overflowY[0]!=document&&i.overflowY[0].tagName!='HTML'){if((i.overflowYOffset.top+i.overflowY[0].offsetHeight)-e.pageY<o.scrollSensitivity)
i.overflowY[0].scrollTop=i.overflowY[0].scrollTop+o.scrollSpeed;if(e.pageY-i.overflowYOffset.top<o.scrollSensitivity)
i.overflowY[0].scrollTop=i.overflowY[0].scrollTop-o.scrollSpeed;}else{if(e.pageY-$(document).scrollTop()<o.scrollSensitivity)
$(document).scrollTop($(document).scrollTop()-o.scrollSpeed);if($(window).height()-(e.pageY-$(document).scrollTop())<o.scrollSensitivity)
$(document).scrollTop($(document).scrollTop()+o.scrollSpeed);}
if(i.overflowX[0]!=document&&i.overflowX[0].tagName!='HTML'){if((i.overflowXOffset.left+i.overflowX[0].offsetWidth)-e.pageX<o.scrollSensitivity)
i.overflowX[0].scrollLeft=i.overflowX[0].scrollLeft+o.scrollSpeed;if(e.pageX-i.overflowXOffset.left<o.scrollSensitivity)
i.overflowX[0].scrollLeft=i.overflowX[0].scrollLeft-o.scrollSpeed;}else{if(e.pageX-$(document).scrollLeft()<o.scrollSensitivity)
$(document).scrollLeft($(document).scrollLeft()-o.scrollSpeed);if($(window).width()-(e.pageX-$(document).scrollLeft())<o.scrollSensitivity)
$(document).scrollLeft($(document).scrollLeft()+o.scrollSpeed);}}});$.ui.plugin.add("draggable","snap",{start:function(e,ui){var inst=$(this).data("draggable");inst.snapElements=[];$(ui.options.snap===true?'.ui-draggable':ui.options.snap).each(function(){var $t=$(this);var $o=$t.offset();if(this!=inst.element[0])inst.snapElements.push({item:this,width:$t.outerWidth(),height:$t.outerHeight(),top:$o.top,left:$o.left});});},drag:function(e,ui){var inst=$(this).data("draggable");var d=ui.options.snapTolerance||20;var x1=ui.absolutePosition.left,x2=x1+inst.helperProportions.width,y1=ui.absolutePosition.top,y2=y1+inst.helperProportions.height;for(var i=inst.snapElements.length-1;i>=0;i--){var l=inst.snapElements[i].left,r=l+inst.snapElements[i].width,t=inst.snapElements[i].top,b=t+inst.snapElements[i].height;if(!((l-d<x1&&x1<r+d&&t-d<y1&&y1<b+d)||(l-d<x1&&x1<r+d&&t-d<y2&&y2<b+d)||(l-d<x2&&x2<r+d&&t-d<y1&&y1<b+d)||(l-d<x2&&x2<r+d&&t-d<y2&&y2<b+d)))continue;if(ui.options.snapMode!='inner'){var ts=Math.abs(t-y2)<=20;var bs=Math.abs(b-y1)<=20;var ls=Math.abs(l-x2)<=20;var rs=Math.abs(r-x1)<=20;if(ts)ui.position.top=inst.convertPositionTo("relative",{top:t-inst.helperProportions.height,left:0}).top;if(bs)ui.position.top=inst.convertPositionTo("relative",{top:b,left:0}).top;if(ls)ui.position.left=inst.convertPositionTo("relative",{top:0,left:l-inst.helperProportions.width}).left;if(rs)ui.position.left=inst.convertPositionTo("relative",{top:0,left:r}).left;}
if(ui.options.snapMode!='outer'){var ts=Math.abs(t-y1)<=20;var bs=Math.abs(b-y2)<=20;var ls=Math.abs(l-x1)<=20;var rs=Math.abs(r-x2)<=20;if(ts)ui.position.top=inst.convertPositionTo("relative",{top:t,left:0}).top;if(bs)ui.position.top=inst.convertPositionTo("relative",{top:b-inst.helperProportions.height,left:0}).top;if(ls)ui.position.left=inst.convertPositionTo("relative",{top:0,left:l}).left;if(rs)ui.position.left=inst.convertPositionTo("relative",{top:0,left:r-inst.helperProportions.width}).left;}};}});$.ui.plugin.add("draggable","connectToSortable",{start:function(e,ui){var inst=$(this).data("draggable");inst.sortables=[];$(ui.options.connectToSortable).each(function(){if($.data(this,'sortable')){var sortable=$.data(this,'sortable');inst.sortables.push({instance:sortable,shouldRevert:sortable.options.revert});sortable.refresh();sortable.propagate("activate",e,inst);}});},stop:function(e,ui){var inst=$(this).data("draggable");$.each(inst.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;inst.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert)this.instance.options.revert=true;this.instance.mouseStop(e);this.instance.element.triggerHandler("sortreceive",[e,$.extend(this.instance.ui(),{sender:inst.element})],this.instance.options["receive"]);this.instance.options.helper=this.instance.options._helper;}else{this.instance.propagate("deactivate",e,inst);}});},drag:function(e,ui){var inst=$(this).data("draggable"),self=this;var checkPos=function(o){var l=o.left,r=l+o.width,t=o.top,b=t+o.height;return(l<(this.positionAbs.left+this.offset.click.left)&&(this.positionAbs.left+this.offset.click.left)<r&&t<(this.positionAbs.top+this.offset.click.top)&&(this.positionAbs.top+this.offset.click.top)<b);};$.each(inst.sortables,function(i){if(checkPos.call(inst,this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=$(self).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return ui.helper[0];};e.target=this.instance.currentItem[0];this.instance.mouseCapture(e,true,true);this.instance.mouseStart(e,true,true);this.instance.offset.click.top=inst.offset.click.top;this.instance.offset.click.left=inst.offset.click.left;this.instance.offset.parent.left-=inst.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=inst.offset.parent.top-this.instance.offset.parent.top;inst.propagate("toSortable",e);}
if(this.instance.currentItem)this.instance.mouseDrag(e);}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance.mouseStop(e,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();this.instance.placeholder.remove();inst.propagate("fromSortable",e);}};});}});$.ui.plugin.add("draggable","stack",{start:function(e,ui){var group=$.makeArray($(ui.options.stack.group)).sort(function(a,b){return(parseInt($(a).css("zIndex"),10)||ui.options.stack.min)-(parseInt($(b).css("zIndex"),10)||ui.options.stack.min);});$(group).each(function(i){this.style.zIndex=ui.options.stack.min+i;});this[0].style.zIndex=ui.options.stack.min+group.length;}});})(jQuery);

;(function($){$.widget("ui.droppable",{init:function(){this.element.addClass("ui-droppable");this.isover=0;this.isout=1;var o=this.options,accept=o.accept;o=$.extend(o,{accept:o.accept&&o.accept.constructor==Function?o.accept:function(d){return $(d).is(accept);}});this.proportions={width:this.element.outerWidth(),height:this.element.outerHeight()};$.ui.ddmanager.droppables.push(this);},plugins:{},ui:function(c){return{instance:this,draggable:(c.currentItem||c.element),helper:c.helper,position:c.position,absolutePosition:c.positionAbs,options:this.options,element:this.element};},destroy:function(){var drop=$.ui.ddmanager.droppables;for(var i=0;i<drop.length;i++)
if(drop[i]==this)
drop.splice(i,1);this.element.removeClass("ui-droppable ui-droppable-disabled").removeData("droppable").unbind(".droppable");},enable:function(){this.element.removeClass("ui-droppable-disabled");this.options.disabled=false;},disable:function(){this.element.addClass("ui-droppable-disabled");this.options.disabled=true;},over:function(e){var draggable=$.ui.ddmanager.current;if(!draggable||(draggable.currentItem||draggable.element)[0]==this.element[0])return;if(this.options.accept.call(this.element,(draggable.currentItem||draggable.element))){$.ui.plugin.call(this,'over',[e,this.ui(draggable)]);this.element.triggerHandler("dropover",[e,this.ui(draggable)],this.options.over);}},out:function(e){var draggable=$.ui.ddmanager.current;if(!draggable||(draggable.currentItem||draggable.element)[0]==this.element[0])return;if(this.options.accept.call(this.element,(draggable.currentItem||draggable.element))){$.ui.plugin.call(this,'out',[e,this.ui(draggable)]);this.element.triggerHandler("dropout",[e,this.ui(draggable)],this.options.out);}},drop:function(e,custom){var draggable=custom||$.ui.ddmanager.current;if(!draggable||(draggable.currentItem||draggable.element)[0]==this.element[0])return false;var childrenIntersection=false;this.element.find(".ui-droppable").each(function(){var inst=$.data(this,'droppable');if(inst.options.greedy&&$.ui.intersect(draggable,$.extend(inst,{offset:inst.element.offset()}),inst.options.tolerance)){childrenIntersection=true;return false;}});if(childrenIntersection)return false;if(this.options.accept.call(this.element,(draggable.currentItem||draggable.element))){$.ui.plugin.call(this,'drop',[e,this.ui(draggable)]);this.element.triggerHandler("drop",[e,this.ui(draggable)],this.options.drop);return true;}
return false;},activate:function(e){var draggable=$.ui.ddmanager.current;$.ui.plugin.call(this,'activate',[e,this.ui(draggable)]);if(draggable)this.element.triggerHandler("dropactivate",[e,this.ui(draggable)],this.options.activate);},deactivate:function(e){var draggable=$.ui.ddmanager.current;$.ui.plugin.call(this,'deactivate',[e,this.ui(draggable)]);if(draggable)this.element.triggerHandler("dropdeactivate",[e,this.ui(draggable)],this.options.deactivate);}});$.extend($.ui.droppable,{defaults:{disabled:false,tolerance:'intersect'}});$.ui.intersect=function(draggable,droppable,toleranceMode){if(!droppable.offset)return false;var x1=(draggable.positionAbs||draggable.position.absolute).left,x2=x1+draggable.helperProportions.width,y1=(draggable.positionAbs||draggable.position.absolute).top,y2=y1+draggable.helperProportions.height;var l=droppable.offset.left,r=l+droppable.proportions.width,t=droppable.offset.top,b=t+droppable.proportions.height;switch(toleranceMode){case'fit':if(!((y2-(draggable.helperProportions.height/2)>t&&y1<t)||(y1<b&&y2>b)||(x2>l&&x1<l)||(x1<r&&x2>r)))return false;if(y2-(draggable.helperProportions.height/2)>t&&y1<t)return 1;if(y1<b&&y2>b)return 2;if(x2>l&&x1<l)return 1;if(x1<r&&x2>r)return 2;break;case'intersect':return(l<x1+(draggable.helperProportions.width/2)&&x2-(draggable.helperProportions.width/2)<r&&t<y1+(draggable.helperProportions.height/2)&&y2-(draggable.helperProportions.height/2)<b);break;case'pointer':return(l<((draggable.positionAbs||draggable.position.absolute).left+(draggable.clickOffset||draggable.offset.click).left)&&((draggable.positionAbs||draggable.position.absolute).left+(draggable.clickOffset||draggable.offset.click).left)<r&&t<((draggable.positionAbs||draggable.position.absolute).top+(draggable.clickOffset||draggable.offset.click).top)&&((draggable.positionAbs||draggable.position.absolute).top+(draggable.clickOffset||draggable.offset.click).top)<b);break;case'touch':return((y1>=t&&y1<=b)||(y2>=t&&y2<=b)||(y1<t&&y2>b))&&((x1>=l&&x1<=r)||(x2>=l&&x2<=r)||(x1<l&&x2>r));break;default:return false;break;}};$.ui.ddmanager={current:null,droppables:[],prepareOffsets:function(t,e){var m=$.ui.ddmanager.droppables;var type=e?e.type:null;for(var i=0;i<m.length;i++){if(m[i].options.disabled||(t&&!m[i].options.accept.call(m[i].element,(t.currentItem||t.element))))continue;m[i].visible=m[i].element.is(":visible");if(!m[i].visible)continue;m[i].offset=m[i].element.offset();m[i].proportions={width:m[i].element.outerWidth(),height:m[i].element.outerHeight()};if(type=="dragstart"||type=="sortactivate")m[i].activate.call(m[i],e);}},drop:function(draggable,e){var dropped=false;$.each($.ui.ddmanager.droppables,function(){if(!this.options)return;if(!this.options.disabled&&this.visible&&$.ui.intersect(draggable,this,this.options.tolerance))
dropped=this.drop.call(this,e);if(!this.options.disabled&&this.visible&&this.options.accept.call(this.element,(draggable.currentItem||draggable.element))){this.isout=1;this.isover=0;this.deactivate.call(this,e);}});return dropped;},drag:function(draggable,e){if(draggable.options.refreshPositions)$.ui.ddmanager.prepareOffsets(draggable,e);$.each($.ui.ddmanager.droppables,function(){if(this.disabled||this.greedyChild||!this.visible)return;var intersects=$.ui.intersect(draggable,this,this.options.tolerance);var c=!intersects&&this.isover==1?'isout':(intersects&&this.isover==0?'isover':null);if(!c)return;var parentInstance;if(this.options.greedy){var parent=this.element.parents('.ui-droppable:eq(0)');if(parent.length){parentInstance=$.data(parent[0],'droppable');parentInstance.greedyChild=(c=='isover'?1:0);}}
if(parentInstance&&c=='isover'){parentInstance['isover']=0;parentInstance['isout']=1;parentInstance.out.call(parentInstance,e);}
this[c]=1;this[c=='isout'?'isover':'isout']=0;this[c=="isover"?"over":"out"].call(this,e);if(parentInstance&&c=='isout'){parentInstance['isout']=0;parentInstance['isover']=1;parentInstance.over.call(parentInstance,e);}});}};$.ui.plugin.add("droppable","activeClass",{activate:function(e,ui){$(this).addClass(ui.options.activeClass);},deactivate:function(e,ui){$(this).removeClass(ui.options.activeClass);},drop:function(e,ui){$(this).removeClass(ui.options.activeClass);}});$.ui.plugin.add("droppable","hoverClass",{over:function(e,ui){$(this).addClass(ui.options.hoverClass);},out:function(e,ui){$(this).removeClass(ui.options.hoverClass);},drop:function(e,ui){$(this).removeClass(ui.options.hoverClass);}});})(jQuery);


if(window.Node&&Node.prototype&&!Node.prototype.contains){Node.prototype.contains=function(arg){return!!(this.compareDocumentPosition(arg)&16)}}
(function($){$.extend($.expr[':'],{sortable:"(' '+a.className+' ').indexOf(' ui-sortable ')"});$.fn.sortable=function(o){return this.each(function(){new $.ui.sortable(this,o);});}
var methods="destroy,enable,disable,refresh".split(",");for(var i=0;i<methods.length;i++){var cur=methods[i],f;eval('f = function() { var a = arguments; return this.each(function() { if(jQuery(this).is(".ui-sortable")) jQuery.data(this, "ui-sortable")["'+cur+'"](a); }); }');$.fn["sortable"+cur.substr(0,1).toUpperCase()+cur.substr(1)]=f;};$.fn.sortableInstance=function(){if($(this[0]).is(".ui-sortable"))return $.data(this[0],"ui-sortable");return false;};$.ui.sortable=function(el,o){this.element=el;this.set=[];var options={};var self=this;$.data(this.element,"ui-sortable",this);$(el).addClass("ui-sortable");$.extend(options,o);$.extend(options,{items:options.items||'> li',smooth:options.smooth!=undefined?options.smooth:true,helper:'clone',containment:options.containment?(options.containment=='sortable'?el:options.containment):null,zIndex:options.zIndex||1000,_start:function(h,p,c,t,e){self.start.apply(t,[self,e]);},_beforeStop:function(h,p,c,t,e){self.stop.apply(t,[self,e]);},_drag:function(h,p,c,t,e){self.drag.apply(t,[self,e]);},startCondition:function(){return!self.disabled;}});var items=$(options.items,el);options.floating=/left|right/.test(items.css('float'));if($(el).css('position')=='static')$(el).css('position','relative');options.offset=$(el).offset({border:false});items.each(function(){new $.ui.mouseInteraction(this,options);});items.each(function(){self.set.push([this,null]);});this.options=options;}
$.extend($.ui.sortable.prototype,{plugins:{},currentTarget:null,lastTarget:null,prepareCallbackObj:function(self,that){if(!self.pos)self.pos=[0,0];return{helper:self.helper,position:{left:self.pos[0],top:self.pos[1]},offset:self.options.cursorAt,draggable:self,current:that,options:self.options}},refresh:function(){var self=this;var items=$(this.options.items,this.element);var unique=[];items.each(function(){old=false;for(var i=0;i<self.set.length;i++){if(self.set[i][0]==this)old=true;}
if(!old)unique.push(this);});for(var i=0;i<unique.length;i++){new $.ui.mouseInteraction(unique[i],self.options);}
this.set=[];items.each(function(){self.set.push([this,null]);});},destroy:function(){$(this.element).removeClass("ui-sortable").removeClass("ui-sortable-disabled");$(this.options.items,this.element).mouseInteractionDestroy();},enable:function(){$(this.element).removeClass("ui-sortable-disabled");this.disabled=false;},disable:function(){$(this.element).addClass("ui-sortable-disabled");this.disabled=true;},start:function(that,e){var o=this.options;if(o.hoverClass){that.helper=$('<div class="'+o.hoverClass+'"></div>').appendTo('body').css({height:this.element.offsetHeight+'px',width:this.element.offsetWidth+'px',position:'absolute'});}
if(o.zIndex){if($(this.helper).css("zIndex"))o.ozIndex=$(this.helper).css("zIndex");$(this.helper).css('zIndex',o.zIndex);}
that.firstSibling=$(this.element).prev()[0];$(this.element).triggerHandler("sortstart",[e,that.prepareCallbackObj(this)],o.start);$(this.element).css('visibility','hidden');return false;},stop:function(that,e){var o=this.options;var self=this;o.beQuietAtEnd=true;if(o.smooth){var os=$(this.element).offset();$(this.helper).animate({left:os.left-o.po.left,top:os.top-o.po.top},500,stopIt);}else{stopIt();}
function stopIt(){$(self.element).css('visibility','');if(that.helper)that.helper.remove();if(self.helper!=self.element)$(self.helper).remove();if(o.ozIndex)
$(self.helper).css('zIndex',o.ozIndex);if($(self.element).prev()[0]!=that.firstSibling){$(self.element).triggerHandler("sortupdate",[e,that.prepareCallbackObj(self,that)],o.update);}
$(self.element).triggerHandler("sortstop",[e,that.prepareCallbackObj(self,that)],o.stop);}
return false;},drag:function(that,e){var o=this.options;this.pos=[this.pos[0]-(o.cursorAt.left?o.cursorAt.left:0),this.pos[1]-(o.cursorAt.top?o.cursorAt.top:0)];var nv=$(this.element).triggerHandler("sort",[e,that.prepareCallbackObj(this)],o.sort);var nl=(nv&&nv.left)?nv.left:this.pos[0];var nt=(nv&&nv.top)?nv.top:this.pos[1];var m=that.set;var p=this.pos[1];for(var i=0;i<m.length;i++){var ci=$(m[i][0]);var cio=m[i][0];if(this.element.contains(cio))continue;var cO=ci.offset();cO={top:cO.top,left:cO.left};var mb=function(e){if(true||o.lba!=cio){ci.before(e);o.lba=cio;}}
var ma=function(e){if(true||o.laa!=cio){ci.after(e);o.laa=cio;}}
if(o.floating){var overlap=((cO.left-(this.pos[0]+(this.options.po?this.options.po.left:0)))/this.helper.offsetWidth);if(!(cO.top<this.pos[1]+(this.options.po?this.options.po.top:0)+cio.offsetHeight/2&&cO.top+cio.offsetHeight>this.pos[1]+(this.options.po?this.options.po.top:0)+cio.offsetHeight/2))continue;}else{var overlap=((cO.top-(this.pos[1]+(this.options.po?this.options.po.top:0)))/this.helper.offsetHeight);if(!(cO.left<this.pos[0]+(this.options.po?this.options.po.left:0)+cio.offsetWidth/2&&cO.left+cio.offsetWidth>this.pos[0]+(this.options.po?this.options.po.left:0)+cio.offsetWidth/2))continue;}
if(overlap>=0&&overlap<=0.5){ci.prev().length?ma(this.element):mb(this.element);break;}
if(overlap<0&&overlap>-0.5){ci.next()[0]==this.element?mb(this.element):ma(this.element);break;}}
if($(this.element).prev()[0]!=that.lastSibling){$(this.element).triggerHandler("sortchange",[e,that.prepareCallbackObj(this,that)],this.options.change);that.lastSibling=$(this.element).prev()[0];}
if(that.helper){var to=$(this.element).offset();that.helper.css({top:to.top+'px',left:to.left+'px'});}
$(this.helper).css('left',nl+'px').css('top',nt+'px');return false;}});})(jQuery);


(function($){$.ui.plugin.add("draggable","stop","effect",function(e,ui){var t=ui.helper;if(ui.options.effect[1]){if(t!=this){ui.options.beQuietAtEnd=true;switch(ui.options.effect[1]){case'fade':$(t).fadeOut(300,function(){$(this).remove();});break;default:$(t).remove();break;}}}});$.ui.plugin.add("draggable","start","effect",function(e,ui){if(ui.options.effect[0]){switch(ui.options.effect[0]){case'fade':$(ui.helper).hide().fadeIn(300);break;}}});$.ui.plugin.add("draggable","start","cursor",function(e,ui){var t=$('body');if(t.css("cursor"))ui.options.ocursor=t.css("cursor");t.css("cursor",ui.options.cursor);});$.ui.plugin.add("draggable","stop","cursor",function(e,ui){if(ui.options.ocursor)$('body').css("cursor",ui.options.ocursor);});$.ui.plugin.add("draggable","start","zIndex",function(e,ui){var t=$(ui.helper);if(t.css("zIndex"))ui.options.ozIndex=t.css("zIndex");t.css('zIndex',ui.options.zIndex);});$.ui.plugin.add("draggable","stop","zIndex",function(e,ui){if(ui.options.ozIndex)$(ui.helper).css('zIndex',ui.options.ozIndex);});$.ui.plugin.add("draggable","start","opacity",function(e,ui){var t=$(ui.helper);if(t.css("opacity"))ui.options.oopacity=t.css("opacity");t.css('opacity',ui.options.opacity);});$.ui.plugin.add("draggable","stop","opacity",function(e,ui){if(ui.options.oopacity)$(ui.helper).css('opacity',ui.options.oopacity);});$.ui.plugin.add("draggable","stop","revert",function(e,ui){var o=ui.options;var rpos={left:0,top:0};o.beQuietAtEnd=true;if(ui.helper!=this){rpos=$(ui.draggable.sorthelper||this).offset({border:false});var nl=rpos.left-o.po.left-o.margins.left;var nt=rpos.top-o.po.top-o.margins.top;}else{var nl=o.co.left-(o.po?o.po.left:0);var nt=o.co.top-(o.po?o.po.top:0);}
var self=ui.draggable;$(ui.helper).animate({left:nl,top:nt},500,function(){if(o.wasPositioned)$(self.element).css('position',o.wasPositioned);if(o.stop)o.stop.apply(self.element,[self.helper,self.pos,[o.co.left-o.po.left,o.co.top-o.po.top],self]);if(self.helper!=self.element)window.setTimeout(function(){$(self.helper).remove();},0);});});$.ui.plugin.add("draggable","start","iframeFix",function(e,ui){var o=ui.options;if(!ui.draggable.slowMode){if(o.iframeFix.constructor==Array){for(var i=0;i<o.iframeFix.length;i++){var co=$(o.iframeFix[i]).offset({border:false});$("<div class='DragDropIframeFix' style='background: #fff;'></div>").css("width",$(o.iframeFix[i])[0].offsetWidth+"px").css("height",$(o.iframeFix[i])[0].offsetHeight+"px").css("position","absolute").css("opacity","0.001").css("z-index","1000").css("top",co.top+"px").css("left",co.left+"px").appendTo("body");}}else{$("iframe").each(function(){var co=$(this).offset({border:false});$("<div class='DragDropIframeFix' style='background: #fff;'></div>").css("width",this.offsetWidth+"px").css("height",this.offsetHeight+"px").css("position","absolute").css("opacity","0.001").css("z-index","1000").css("top",co.top+"px").css("left",co.left+"px").appendTo("body");});}}});$.ui.plugin.add("draggable","stop","iframeFix",function(e,ui){if(ui.options.iframeFix)$("div.DragDropIframeFix").each(function(){this.parentNode.removeChild(this);});});$.ui.plugin.add("draggable","start","containment",function(e,ui){var o=ui.options;if(!o.cursorAtIgnore||o.containment.left!=undefined||o.containment.constructor==Array)return;if(o.containment=='parent')o.containment=this.parentNode;if(o.containment=='document'){o.containment=[0-o.margins.left,0-o.margins.top,$(document).width()-o.margins.right,($(document).height()||document.body.parentNode.scrollHeight)-o.margins.bottom];}else{var ce=$(o.containment)[0];var co=$(o.containment).offset({border:false});o.containment=[co.left-o.margins.left,co.top-o.margins.top,co.left+(ce.offsetWidth||ce.scrollWidth)-o.margins.right,co.top+(ce.offsetHeight||ce.scrollHeight)-o.margins.bottom];}});$.ui.plugin.add("draggable","drag","containment",function(e,ui){var o=ui.options;if(!o.cursorAtIgnore)return;var h=$(ui.helper);var c=o.containment;if(c.constructor==Array){if((ui.draggable.pos[0]<c[0]-o.po.left))ui.draggable.pos[0]=c[0]-o.po.left;if((ui.draggable.pos[1]<c[1]-o.po.top))ui.draggable.pos[1]=c[1]-o.po.top;if(ui.draggable.pos[0]+h[0].offsetWidth>c[2]-o.po.left)ui.draggable.pos[0]=c[2]-o.po.left-h[0].offsetWidth;if(ui.draggable.pos[1]+h[0].offsetHeight>c[3]-o.po.top)ui.draggable.pos[1]=c[3]-o.po.top-h[0].offsetHeight;}else{if(c.left&&(ui.draggable.pos[0]<c.left))ui.draggable.pos[0]=c.left;if(c.top&&(ui.draggable.pos[1]<c.top))ui.draggable.pos[1]=c.top;var p=$(o.pp);if(c.right&&ui.draggable.pos[0]+h[0].offsetWidth>p[0].offsetWidth-c.right)ui.draggable.pos[0]=(p[0].offsetWidth-c.right)-h[0].offsetWidth;if(c.bottom&&ui.draggable.pos[1]+h[0].offsetHeight>p[0].offsetHeight-c.bottom)ui.draggable.pos[1]=(p[0].offsetHeight-c.bottom)-h[0].offsetHeight;}});$.ui.plugin.add("draggable","drag","grid",function(e,ui){var o=ui.options;if(!o.cursorAtIgnore)return;ui.draggable.pos[0]=o.co.left+o.margins.left-o.po.left+Math.round((ui.draggable.pos[0]-o.co.left-o.margins.left+o.po.left)/o.grid[0])*o.grid[0];ui.draggable.pos[1]=o.co.top+o.margins.top-o.po.top+Math.round((ui.draggable.pos[1]-o.co.top-o.margins.top+o.po.top)/o.grid[1])*o.grid[1];});$.ui.plugin.add("draggable","drag","axis",function(e,ui){var o=ui.options;if(!o.cursorAtIgnore)return;if(o.constraint)o.axis=o.constraint;o.axis?(o.axis=='x'?ui.draggable.pos[1]=o.co.top-o.margins.top-o.po.top:ui.draggable.pos[0]=o.co.left-o.margins.left-o.po.left):null;});$.ui.plugin.add("draggable","drag","scroll",function(e,ui){var o=ui.options;o.scrollSensitivity=o.scrollSensitivity||20;o.scrollSpeed=o.scrollSpeed||20;if(o.pp&&o.ppOverflow){}else{if((ui.draggable.rpos[1]-$(window).height())-$(document).scrollTop()>-o.scrollSensitivity)window.scrollBy(0,o.scrollSpeed);if(ui.draggable.rpos[1]-$(document).scrollTop()<o.scrollSensitivity)window.scrollBy(0,-o.scrollSpeed);if((ui.draggable.rpos[0]-$(window).width())-$(document).scrollLeft()>-o.scrollSensitivity)window.scrollBy(o.scrollSpeed,0);if(ui.draggable.rpos[0]-$(document).scrollLeft()<o.scrollSensitivity)window.scrollBy(-o.scrollSpeed,0);}});$.ui.plugin.add("draggable","drag","wrapHelper",function(e,ui){var o=ui.options;if(o.cursorAtIgnore)return;var t=ui.helper;if(!o.pp||!o.ppOverflow){var wx=$(window).width()-($.browser.mozilla?20:0);var sx=$(document).scrollLeft();var wy=$(window).height();var sy=$(document).scrollTop();}else{var wx=o.pp.offsetWidth+o.po.left-20;var sx=o.pp.scrollLeft;var wy=o.pp.offsetHeight+o.po.top-20;var sy=o.pp.scrollTop;}
ui.draggable.pos[0]-=((ui.draggable.rpos[0]-o.cursorAt.left-wx+t.offsetWidth+o.margins.right)-sx>0||(ui.draggable.rpos[0]-o.cursorAt.left+o.margins.left)-sx<0)?(t.offsetWidth+o.margins.left+o.margins.right-o.cursorAt.left*2):0;ui.draggable.pos[1]-=((ui.draggable.rpos[1]-o.cursorAt.top-wy+t.offsetHeight+o.margins.bottom)-sy>0||(ui.draggable.rpos[1]-o.cursorAt.top+o.margins.top)-sy<0)?(t.offsetHeight+o.margins.top+o.margins.bottom-o.cursorAt.top*2):0;});})(jQuery);

;(function($){$.fn.tabs=function(){var method=typeof arguments[0]=='string'&&arguments[0];var args=method&&Array.prototype.slice.call(arguments,1)||arguments;return method=='length'?$.data(this[0],'tabs').$tabs.length:this.each(function(){if(method){var tabs=$.data(this,'tabs');if(tabs)tabs[method].apply(tabs,args);}else
new $.ui.tabs(this,args[0]||{});});};$.ui.tabs=function(el,options){var self=this;this.options=$.extend({},$.ui.tabs.defaults,options);this.element=el;if(options.selected===null)
this.options.selected=null;this.options.event+='.tabs';$(el).bind('setData.tabs',function(event,key,value){if((/^selected/).test(key))
self.select(value);else{self.options[key]=value;self.tabify();}}).bind('getData.tabs',function(event,key){return self.options[key];});$.data(el,'tabs',this);this.tabify(true);};$.ui.tabs.defaults={selected:0,unselect:false,event:'click',disabled:[],cookie:null,spinner:'Loading&#8230;',cache:false,idPrefix:'ui-tabs-',ajaxOptions:{},fx:null,tabTemplate:'<li><a href="#{href}"><span>#{label}</span></a></li>',panelTemplate:'<div></div>',navClass:'ui-tabs-nav',selectedClass:'ui-tabs-selected',unselectClass:'ui-tabs-unselect',disabledClass:'ui-tabs-disabled',panelClass:'ui-tabs-panel',hideClass:'ui-tabs-hide',loadingClass:'ui-tabs-loading'};$.extend($.ui.tabs.prototype,{tabId:function(a){return a.title&&a.title.replace(/\s/g,'_').replace(/[^A-Za-z0-9\-_:\.]/g,'')||this.options.idPrefix+$.data(a);},ui:function(tab,panel){return{instance:this,options:this.options,tab:tab,panel:panel};},tabify:function(init){this.$lis=$('li:has(a[href])',this.element);this.$tabs=this.$lis.map(function(){return $('a',this)[0];});this.$panels=$([]);var self=this,o=this.options;this.$tabs.each(function(i,a){if(a.hash&&a.hash.replace('#',''))
self.$panels=self.$panels.add(a.hash);else if($(a).attr('href')!='#'){$.data(a,'href.tabs',a.href);$.data(a,'load.tabs',a.href);var id=self.tabId(a);a.href='#'+id;var $panel=$('#'+id);if(!$panel.length){$panel=$(o.panelTemplate).attr('id',id).addClass(o.panelClass).insertAfter(self.$panels[i-1]||self.element);$panel.data('destroy.tabs',true);}
self.$panels=self.$panels.add($panel);}
else
o.disabled.push(i+1);});if(init){$(this.element).hasClass(o.navClass)||$(this.element).addClass(o.navClass);this.$panels.each(function(){var $this=$(this);$this.hasClass(o.panelClass)||$this.addClass(o.panelClass);});this.$tabs.each(function(i,a){if(location.hash){if(a.hash==location.hash){o.selected=i;if($.browser.msie||$.browser.opera){var $toShow=$(location.hash),toShowId=$toShow.attr('id');$toShow.attr('id','');setTimeout(function(){$toShow.attr('id',toShowId);},500);}
scrollTo(0,0);return false;}}else if(o.cookie){var index=parseInt($.cookie('ui-tabs'+$.data(self.element)),10);if(index&&self.$tabs[index]){o.selected=index;return false;}}else if(self.$lis.eq(i).hasClass(o.selectedClass)){o.selected=i;return false;}});this.$panels.addClass(o.hideClass);this.$lis.removeClass(o.selectedClass);if(o.selected!==null){this.$panels.eq(o.selected).show().removeClass(o.hideClass);this.$lis.eq(o.selected).addClass(o.selectedClass);}
var href=o.selected!==null&&$.data(this.$tabs[o.selected],'load.tabs');if(href)
this.load(o.selected);o.disabled=$.unique(o.disabled.concat($.map(this.$lis.filter('.'+o.disabledClass),function(n,i){return self.$lis.index(n);}))).sort();$(window).bind('unload',function(){self.$tabs.unbind('.tabs');self.$lis=self.$tabs=self.$panels=null;});}
for(var i=0,li;li=this.$lis[i];i++)
$(li)[$.inArray(i,o.disabled)!=-1&&!$(li).hasClass(o.selectedClass)?'addClass':'removeClass'](o.disabledClass);if(o.cache===false)
this.$tabs.removeData('cache.tabs');var hideFx,showFx,baseFx={'min-width':0,duration:1},baseDuration='normal';if(o.fx&&o.fx.constructor==Array)
hideFx=o.fx[0]||baseFx,showFx=o.fx[1]||baseFx;else
hideFx=showFx=o.fx||baseFx;var resetCSS={display:'',overflow:''};if(!$.browser.msie)
resetCSS.opacity='';function hideTab(clicked,$hide,$show){$hide.animate(hideFx,hideFx.duration||baseDuration,function(){$hide.addClass(o.hideClass).css(resetCSS);if($.browser.msie&&hideFx.opacity)
$hide[0].style.filter='';if($show)
showTab(clicked,$show,$hide);});}
function showTab(clicked,$show,$hide){if(showFx===baseFx)
$show.css('display','block');$show.animate(showFx,showFx.duration||baseDuration,function(){$show.removeClass(o.hideClass).css(resetCSS);if($.browser.msie&&showFx.opacity)
$show[0].style.filter='';$(self.element).triggerHandler('tabsshow',[self.ui(clicked,$show[0])],o.show);});}
function switchTab(clicked,$li,$hide,$show){$li.addClass(o.selectedClass).siblings().removeClass(o.selectedClass);hideTab(clicked,$hide,$show);}
this.$tabs.unbind('.tabs').bind(o.event,function(){var $li=$(this).parents('li:eq(0)'),$hide=self.$panels.filter(':visible'),$show=$(this.hash);if(($li.hasClass(o.selectedClass)&&!o.unselect)||$li.hasClass(o.disabledClass)||$(this).hasClass(o.loadingClass)||$(self.element).triggerHandler('tabsselect',[self.ui(this,$show[0])],o.select)===false){this.blur();return false;}
self.options.selected=self.$tabs.index(this);if(o.unselect){if($li.hasClass(o.selectedClass)){self.options.selected=null;$li.removeClass(o.selectedClass);self.$panels.stop();hideTab(this,$hide);this.blur();return false;}else if(!$hide.length){self.$panels.stop();var a=this;self.load(self.$tabs.index(this),function(){$li.addClass(o.selectedClass).addClass(o.unselectClass);showTab(a,$show);});this.blur();return false;}}
if(o.cookie)
$.cookie('ui-tabs'+$.data(self.element),self.options.selected,o.cookie);self.$panels.stop();if($show.length){var a=this;self.load(self.$tabs.index(this),$hide.length?function(){switchTab(a,$li,$hide,$show);}:function(){$li.addClass(o.selectedClass);showTab(a,$show);});}else
throw'jQuery UI Tabs: Mismatching fragment identifier.';if($.browser.msie)
this.blur();return false;});if(!(/^click/).test(o.event))
this.$tabs.bind('click.tabs',function(){return false;});},add:function(url,label,index){if(index==undefined)
index=this.$tabs.length;var o=this.options;var $li=$(o.tabTemplate.replace(/#\{href\}/,url).replace(/#\{label\}/,label));$li.data('destroy.tabs',true);var id=url.indexOf('#')==0?url.replace('#',''):this.tabId($('a:first-child',$li)[0]);var $panel=$('#'+id);if(!$panel.length){$panel=$(o.panelTemplate).attr('id',id).addClass(o.panelClass).addClass(o.hideClass);$panel.data('destroy.tabs',true);}
if(index>=this.$lis.length){$li.appendTo(this.element);$panel.appendTo(this.element.parentNode);}else{$li.insertBefore(this.$lis[index]);$panel.insertBefore(this.$panels[index]);}
o.disabled=$.map(o.disabled,function(n,i){return n>=index?++n:n});this.tabify();if(this.$tabs.length==1){$li.addClass(o.selectedClass);$panel.removeClass(o.hideClass);var href=$.data(this.$tabs[0],'load.tabs');if(href)
this.load(index,href);}
$(this.element).triggerHandler('tabsadd',[this.ui(this.$tabs[index],this.$panels[index])],o.add);},remove:function(index){var o=this.options,$li=this.$lis.eq(index).remove(),$panel=this.$panels.eq(index).remove();if($li.hasClass(o.selectedClass)&&this.$tabs.length>1)
this.select(index+(index+1<this.$tabs.length?1:-1));o.disabled=$.map($.grep(o.disabled,function(n,i){return n!=index;}),function(n,i){return n>=index?--n:n});this.tabify();$(this.element).triggerHandler('tabsremove',[this.ui($li.find('a')[0],$panel[0])],o.remove);},enable:function(index){var o=this.options;if($.inArray(index,o.disabled)==-1)
return;var $li=this.$lis.eq(index).removeClass(o.disabledClass);if($.browser.safari){$li.css('display','inline-block');setTimeout(function(){$li.css('display','block');},0);}
o.disabled=$.grep(o.disabled,function(n,i){return n!=index;});$(this.element).triggerHandler('tabsenable',[this.ui(this.$tabs[index],this.$panels[index])],o.enable);},disable:function(index){var self=this,o=this.options;if(index!=o.selected){this.$lis.eq(index).addClass(o.disabledClass);o.disabled.push(index);o.disabled.sort();$(this.element).triggerHandler('tabsdisable',[this.ui(this.$tabs[index],this.$panels[index])],o.disable);}},select:function(index){if(typeof index=='string')
index=this.$tabs.index(this.$tabs.filter('[href$='+index+']')[0]);this.$tabs.eq(index).trigger(this.options.event);},load:function(index,callback){var self=this,o=this.options,$a=this.$tabs.eq(index),a=$a[0],bypassCache=callback==undefined||callback===false,url=$a.data('load.tabs');callback=callback||function(){};if(!url||($.data(a,'cache.tabs')&&!bypassCache)){callback();return;}
if(o.spinner){var $span=$('span',a);$span.data('label.tabs',$span.html()).html('<em>'+o.spinner+'</em>');}
var finish=function(){self.$tabs.filter('.'+o.loadingClass).each(function(){$(this).removeClass(o.loadingClass);if(o.spinner){var $span=$('span',this);$span.html($span.data('label.tabs')).removeData('label.tabs');}});self.xhr=null;};var ajaxOptions=$.extend({},o.ajaxOptions,{url:url,success:function(r,s){$(a.hash).html(r);finish();callback();if(o.cache)
$.data(a,'cache.tabs',true);$(self.element).triggerHandler('tabsload',[self.ui(self.$tabs[index],self.$panels[index])],o.load);o.ajaxOptions.success&&o.ajaxOptions.success(r,s);}});if(this.xhr){this.xhr.abort();finish();}
$a.addClass(o.loadingClass);setTimeout(function(){self.xhr=$.ajax(ajaxOptions);},0);},url:function(index,url){this.$tabs.eq(index).removeData('cache.tabs').data('load.tabs',url);},destroy:function(){var o=this.options;$(this.element).unbind('.tabs').removeClass(o.navClass).removeData('tabs');this.$tabs.each(function(){var href=$.data(this,'href.tabs');if(href)
this.href=href;var $this=$(this).unbind('.tabs');$.each(['href','load','cache'],function(i,prefix){$this.removeData(prefix+'.tabs');});});this.$lis.add(this.$panels).each(function(){if($.data(this,'destroy.tabs'))
$(this).remove();else
$(this).removeClass([o.selectedClass,o.unselectClass,o.disabledClass,o.panelClass,o.hideClass].join(' '));});}});$.extend($.ui.tabs.prototype,{rotation:null,rotate:function(ms,continuing){continuing=continuing||false;var self=this,t=this.options.selected;function start(){self.rotation=setInterval(function(){t=++t<self.$tabs.length?t:0;self.select(t);},ms);}
function stop(e){if(!e||e.clientX){clearInterval(self.rotation);}}
if(ms){start();if(!continuing)
this.$tabs.bind(this.options.event,stop);else
this.$tabs.bind(this.options.event,function(){stop();t=self.options.selected;start();});}
else{stop();this.$tabs.unbind(this.options.event,stop);}}});})(jQuery);


(function($){var setDataSwitch={dragStart:"start.draggable",drag:"drag.draggable",dragStop:"stop.draggable",maxHeight:"maxHeight.resizable",minHeight:"minHeight.resizable",maxWidth:"maxWidth.resizable",minWidth:"minWidth.resizable",resizeStart:"start.resizable",resize:"drag.resizable",resizeStop:"stop.resizable"};$.widget("ui.dialog",{init:function(){var self=this,options=this.options,resizeHandles=typeof options.resizable=='string'?options.resizable:'n,e,s,w,se,sw,ne,nw',uiDialogContent=this.element.addClass('ui-dialog-content').wrap('<div/>').wrap('<div/>'),uiDialogContainer=uiDialogContent.parent().addClass('ui-dialog-container').css({position:'relative'}),title=options.title||uiDialogContent.attr('title')||'',uiDialogTitlebar=(this.uiDialogTitlebar=$('<div class="ui-dialog-titlebar"/>')).append('<span class="ui-dialog-title">'+title+'</span>').append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>').prependTo(uiDialogContainer),uiDialog=(this.uiDialog=uiDialogContainer.parent()).appendTo(document.body).hide().addClass('ui-dialog').addClass(options.dialogClass).addClass(uiDialogContent.attr('className')).removeClass('ui-dialog-content').css({position:'absolute',width:options.width,height:options.height,overflow:'hidden',zIndex:options.zIndex}).attr('tabIndex',-1).css('outline',0).keydown(function(ev){if(options.closeOnEscape){var ESC=27;(ev.keyCode&&ev.keyCode==ESC&&self.close());}}).mousedown(function(){self.moveToTop();});this.uiDialogTitlebarClose=$('.ui-dialog-titlebar-close',uiDialogTitlebar).hover(function(){$(this).addClass('ui-dialog-titlebar-close-hover');},function(){$(this).removeClass('ui-dialog-titlebar-close-hover');}).mousedown(function(ev){ev.stopPropagation();}).click(function(){self.close();return false;});var hasButtons=false;$.each(options.buttons,function(){return!(hasButtons=true);});if(hasButtons){var uiDialogButtonPane=$('<div class="ui-dialog-buttonpane"/>').appendTo(uiDialog);$.each(options.buttons,function(name,fn){$('<button/>').text(name).click(function(){fn.apply(self.element[0],arguments);}).appendTo(uiDialogButtonPane);});}
if($.fn.draggable){uiDialog.draggable({handle:'.ui-dialog-titlebar',start:function(e,ui){self.moveToTop();(options.dragStart&&options.dragStart.apply(this,arguments));},drag:options.drag,stop:function(e,ui){(options.dragStop&&options.dragStop.apply(this,arguments));$.ui.dialog.overlay.resize();}});(options.draggable||uiDialog.draggable('disable'));}
if($.fn.resizable){uiDialog.resizable({maxWidth:options.maxWidth,maxHeight:options.maxHeight,minWidth:options.minWidth,minHeight:options.minHeight,start:options.resizeStart,resize:options.resize,handles:resizeHandles,stop:function(e,ui){(options.resizeStop&&options.resizeStop.apply(this,arguments));$.ui.dialog.overlay.resize();}});(options.resizable||uiDialog.resizable('disable'));}
(options.bgiframe&&$.fn.bgiframe&&uiDialog.bgiframe());(options.autoOpen&&this.open());},setData:function(key,value){(setDataSwitch[key]&&this.uiDialog.data(setDataSwitch[key],value));switch(key){case"draggable":this.uiDialog.draggable(value?'enable':'disable');break;case"height":this.uiDialog.height(value);break;case"position":this.position(value);break;case"resizable":(typeof value=='string'&&this.uiDialog.data('handles.resizable',value));this.uiDialog.resizable(value?'enable':'disable');break;case"title":$(".ui-dialog-title",this.uiDialogTitlebar).text(value);break;case"width":this.uiDialog.width(value);break;}
$.widget.prototype.setData.apply(this,arguments);},position:function(pos){var wnd=$(window),doc=$(document),pTop=doc.scrollTop(),pLeft=doc.scrollLeft(),minTop=pTop;if($.inArray(pos,['center','top','right','bottom','left'])>=0){pos=[pos=='right'||pos=='left'?pos:'center',pos=='top'||pos=='bottom'?pos:'middle'];}
if(pos.constructor!=Array){pos=['center','middle'];}
if(pos[0].constructor==Number){pLeft+=pos[0];}else{switch(pos[0]){case'left':pLeft+=0;break;case'right':pLeft+=wnd.width()-this.uiDialog.width();break;default:case'center':pLeft+=(wnd.width()-this.uiDialog.width())/2;}}
if(pos[1].constructor==Number){pTop+=pos[1];}else{switch(pos[1]){case'top':pTop+=0;break;case'bottom':pTop+=wnd.height()-this.uiDialog.height();break;default:case'middle':pTop+=(wnd.height()-this.uiDialog.height())/2;}}
pTop=Math.max(pTop,minTop);this.uiDialog.css({top:pTop,left:pLeft});},open:function(){this.overlay=this.options.modal?new $.ui.dialog.overlay(this):null;this.uiDialog.appendTo('body');this.position(this.options.position);this.uiDialog.show();this.moveToTop(true);var openEV=null;var openUI={options:this.options};this.uiDialogTitlebarClose.focus();this.element.triggerHandler("dialogopen",[openEV,openUI],this.options.open);},moveToTop:function(force){if((this.options.modal&&!force)||!this.options.stack){return;}
var maxZ=this.options.zIndex,options=this.options;$('.ui-dialog:visible').each(function(){maxZ=Math.max(maxZ,parseInt($(this).css('z-index'),10)||options.zIndex);});(this.overlay&&this.overlay.$el.css('z-index',++maxZ));this.uiDialog.css('z-index',++maxZ);},close:function(){(this.overlay&&this.overlay.destroy());this.uiDialog.hide();var closeEV=null;var closeUI={options:this.options};this.element.triggerHandler("dialogclose",[closeEV,closeUI],this.options.close);$.ui.dialog.overlay.resize();},destroy:function(){(this.overlay&&this.overlay.destroy());this.uiDialog.hide();this.element.unbind('.dialog').removeData('dialog').removeClass('ui-dialog-content').hide().appendTo('body');this.uiDialog.remove();}});$.extend($.ui.dialog,{defaults:{autoOpen:true,bgiframe:false,buttons:{},closeOnEscape:true,draggable:true,height:200,minHeight:100,minWidth:150,modal:false,overlay:{},position:'center',resizable:true,stack:true,width:300,zIndex:1000},overlay:function(dialog){this.$el=$.ui.dialog.overlay.create(dialog);}});$.extend($.ui.dialog.overlay,{instances:[],events:$.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),function(e){return e+'.dialog-overlay';}).join(' '),create:function(dialog){if(this.instances.length===0){setTimeout(function(){$('a, :input').bind($.ui.dialog.overlay.events,function(){var allow=false;var $dialog=$(this).parents('.ui-dialog');if($dialog.length){var $overlays=$('.ui-dialog-overlay');if($overlays.length){var maxZ=parseInt($overlays.css('z-index'),10);$overlays.each(function(){maxZ=Math.max(maxZ,parseInt($(this).css('z-index'),10));});allow=parseInt($dialog.css('z-index'),10)>maxZ;}else{allow=true;}}
return allow;});},1);$(document).bind('keydown.dialog-overlay',function(e){var ESC=27;(e.keyCode&&e.keyCode==ESC&&dialog.close());});$(window).bind('resize.dialog-overlay',$.ui.dialog.overlay.resize);}
var $el=$('<div/>').appendTo(document.body).addClass('ui-dialog-overlay').css($.extend({borderWidth:0,margin:0,padding:0,position:'absolute',top:0,left:0,width:this.width(),height:this.height()},dialog.options.overlay));(dialog.options.bgiframe&&$.fn.bgiframe&&$el.bgiframe());this.instances.push($el);return $el;},destroy:function($el){this.instances.splice($.inArray(this.instances,$el),1);if(this.instances.length===0){$('a, :input').add([document,window]).unbind('.dialog-overlay');}
$el.remove();},height:function(){if($.browser.msie&&$.browser.version<7){var scrollHeight=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);var offsetHeight=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);if(scrollHeight<offsetHeight){return $(window).height()+'px';}else{return scrollHeight+'px';}}else{return $(document).height()+'px';}},width:function(){if($.browser.msie&&$.browser.version<7){var scrollWidth=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);var offsetWidth=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);if(scrollWidth<offsetWidth){return $(window).width()+'px';}else{return scrollWidth+'px';}}else{return $(document).width()+'px';}},resize:function(){var $overlays=$([]);$.each($.ui.dialog.overlay.instances,function(){$overlays=$overlays.add(this);});$overlays.css({width:0,height:0}).css({width:$.ui.dialog.overlay.width(),height:$.ui.dialog.overlay.height()});}});$.extend($.ui.dialog.overlay.prototype,{destroy:function(){$.ui.dialog.overlay.destroy(this.$el);}});})(jQuery);


jQuery.fn.farbtastic=function(callback){$.farbtastic(this,callback);return this;};jQuery.farbtastic=function(container,callback){var container=$(container).get(0);return container.farbtastic||(container.farbtastic=new jQuery._farbtastic(container,callback));}
jQuery._farbtastic=function(container,callback){var fb=this;$(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');var e=$('.farbtastic',container);fb.wheel=$('.wheel',container).get(0);fb.radius=84;fb.square=100;fb.width=194;if(navigator.appVersion.match(/MSIE [0-6]\./)){$('*',e).each(function(){if(this.currentStyle.backgroundImage!='none'){var image=this.currentStyle.backgroundImage;image=this.currentStyle.backgroundImage.substring(5,image.length-2);$(this).css({'backgroundImage':'none','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+image+"')"});}});}
fb.linkTo=function(callback){if(typeof fb.callback=='object'){$(fb.callback).unbind('keyup',fb.updateValue);}
fb.color=null;if(typeof callback=='function'){fb.callback=callback;}
else if(typeof callback=='object'||typeof callback=='string'){fb.callback=$(callback);fb.callback.bind('keyup',fb.updateValue);if(fb.callback.get(0).value){fb.setColor(fb.callback.get(0).value);}}
return this;}
fb.updateValue=function(event){if(this.value&&this.value!=fb.color){fb.setColor(this.value);}}
fb.setColor=function(color){var unpack=fb.unpack(color);if(fb.color!=color&&unpack){fb.color=color;fb.rgb=unpack;fb.hsl=fb.RGBToHSL(fb.rgb);fb.updateDisplay();}
return this;}
fb.setHSL=function(hsl){fb.hsl=hsl;fb.rgb=fb.HSLToRGB(hsl);fb.color=fb.pack(fb.rgb);fb.updateDisplay();return this;}
fb.widgetCoords=function(event){var x,y;var el=event.target||event.srcElement;var reference=fb.wheel;if(typeof event.offsetX!='undefined'){var pos={x:event.offsetX,y:event.offsetY};var e=el;while(e){e.mouseX=pos.x;e.mouseY=pos.y;pos.x+=e.offsetLeft;pos.y+=e.offsetTop;e=e.offsetParent;}
var e=reference;var offset={x:0,y:0}
while(e){if(typeof e.mouseX!='undefined'){x=e.mouseX-offset.x;y=e.mouseY-offset.y;break;}
offset.x+=e.offsetLeft;offset.y+=e.offsetTop;e=e.offsetParent;}
e=el;while(e){e.mouseX=undefined;e.mouseY=undefined;e=e.offsetParent;}}
else{var pos=fb.absolutePosition(reference);x=(event.pageX||0*(event.clientX+$('html').get(0).scrollLeft))-pos.x;y=(event.pageY||0*(event.clientY+$('html').get(0).scrollTop))-pos.y;}
return{x:x-fb.width/2,y:y-fb.width/2};}
fb.mousedown=function(event){if(!document.dragging){$(document).bind('mousemove',fb.mousemove).bind('mouseup',fb.mouseup);document.dragging=true;}
var pos=fb.widgetCoords(event);fb.circleDrag=Math.max(Math.abs(pos.x),Math.abs(pos.y))*2>fb.square;fb.mousemove(event);return false;}
fb.mousemove=function(event){var pos=fb.widgetCoords(event);if(fb.circleDrag){var hue=Math.atan2(pos.x,-pos.y)/6.28;if(hue<0)hue+=1;fb.setHSL([hue,fb.hsl[1],fb.hsl[2]]);}
else{var sat=Math.max(0,Math.min(1,-(pos.x/fb.square)+.5));var lum=Math.max(0,Math.min(1,-(pos.y/fb.square)+.5));fb.setHSL([fb.hsl[0],sat,lum]);}
return false;}
fb.mouseup=function(){$(document).unbind('mousemove',fb.mousemove);$(document).unbind('mouseup',fb.mouseup);document.dragging=false;}
fb.updateDisplay=function(){var angle=fb.hsl[0]*6.28;$('.h-marker',e).css({left:Math.round(Math.sin(angle)*fb.radius+fb.width/2)+'px',top:Math.round(-Math.cos(angle)*fb.radius+fb.width/2)+'px'});$('.sl-marker',e).css({left:Math.round(fb.square*(.5-fb.hsl[1])+fb.width/2)+'px',top:Math.round(fb.square*(.5-fb.hsl[2])+fb.width/2)+'px'});$('.color',e).css('backgroundColor',fb.pack(fb.HSLToRGB([fb.hsl[0],1,0.5])));if(typeof fb.callback=='object'){$(fb.callback).css({backgroundColor:fb.color,color:fb.hsl[2]>0.5?'#000':'#fff'});$(fb.callback).each(function(){if(this.value&&this.value!=fb.color){this.value=fb.color;}});}
else if(typeof fb.callback=='function'){fb.callback.call(fb,fb.color);}}
fb.absolutePosition=function(el){var r={x:el.offsetLeft,y:el.offsetTop};if(el.offsetParent){var tmp=fb.absolutePosition(el.offsetParent);r.x+=tmp.x;r.y+=tmp.y;}
return r;};fb.pack=function(rgb){var r=Math.round(rgb[0]*255);var g=Math.round(rgb[1]*255);var b=Math.round(rgb[2]*255);return'#'+(r<16?'0':'')+r.toString(16)+
(g<16?'0':'')+g.toString(16)+
(b<16?'0':'')+b.toString(16);}
fb.unpack=function(color){if(color.length==7){return[parseInt('0x'+color.substring(1,3))/255,parseInt('0x'+color.substring(3,5))/255,parseInt('0x'+color.substring(5,7))/255];}
else if(color.length==4){return[parseInt('0x'+color.substring(1,2))/15,parseInt('0x'+color.substring(2,3))/15,parseInt('0x'+color.substring(3,4))/15];}}
fb.HSLToRGB=function(hsl){var m1,m2,r,g,b;var h=hsl[0],s=hsl[1],l=hsl[2];m2=(l<=0.5)?l*(s+1):l+s-l*s;m1=l*2-m2;return[this.hueToRGB(m1,m2,h+0.33333),this.hueToRGB(m1,m2,h),this.hueToRGB(m1,m2,h-0.33333)];}
fb.hueToRGB=function(m1,m2,h){h=(h<0)?h+1:((h>1)?h-1:h);if(h*6<1)return m1+(m2-m1)*h*6;if(h*2<1)return m2;if(h*3<2)return m1+(m2-m1)*(0.66666-h)*6;return m1;}
fb.RGBToHSL=function(rgb){var min,max,delta,h,s,l;var r=rgb[0],g=rgb[1],b=rgb[2];min=Math.min(r,Math.min(g,b));max=Math.max(r,Math.max(g,b));delta=max-min;l=(min+max)/2;s=0;if(l>0&&l<1){s=delta/(l<0.5?(2*l):(2-2*l));}
h=0;if(delta>0){if(max==r&&max!=g)h+=(g-b)/delta;if(max==g&&max!=b)h+=(2+(b-r)/delta);if(max==b&&max!=r)h+=(4+(r-g)/delta);h/=6;}
return[h,s,l];}
$('*',e).mousedown(fb.mousedown);fb.setColor('#000000');if(callback){fb.linkTo(callback);}}

;(function($){if(!$.fn.jqDock){var jqDock=function(){return{version:1.1,defaults:{size:36,distance:54,coefficient:1.5,duration:500,align:'bottom',labels:false,source:false,loader:null},useJqLoader:$.browser.opera||$.browser.safari,shrinkInterval:100,docks:[],X:0,Y:0,verthorz:{v:{wh:'height',xy:'Y',tl:'top',lead:'Top',trail:'Bottom',act:'ActualInv'},h:{wh:'width',xy:'X',tl:'left',lead:'Left',trail:'Right',act:'Actual'}},elementCss:{position:'relative',borderWidth:0,borderStyle:'none',verticalAlign:'top'},vanillaDiv:'<div style="position:relative;margin:0px;padding:0px;border:0px none;background-color:transparent;">',initDock:function(id){var ME=this,Dock=this.docks[id],op=Dock.Opts,off=0,AI=$('a, img',Dock.Menu),i=0,j,el,wh,acc,upad;this.removeText(Dock.Menu);if(op.orient.vh=='h'){if($.browser.opera||!$.boxModel){AI.css(this.elementCss).filter('a').css({lineHeight:0,fontSize:'0px'})}else{var hcss={display:'block'};hcss['float']='left';AI.css(this.elementCss).filter('img').css(hcss)}}else{AI.not($('a img',Dock.Menu)).wrap(this.vanillaDiv+'</div>').end().css(this.elementCss)}while(i<Dock.Elem.length){el=Dock.Elem[i++];wh=this.keepProportion(el,op.size,{vh:op.orient.inv,inv:op.orient.vh});el.Actual=el.Final=el.Initial=wh[op.vh.wh];el.SizeDiff=el[op.vh.wh]-el.Initial;el.Img.css(wh);el.Img.removeAttr('title').attr({alt:''}).parent('a').removeAttr('title');el.ShrinkStep=Math.floor(el.SizeDiff*this.shrinkInterval/op.duration);Dock[op.vh.inv.wh]=Math.max(Dock[op.vh.inv.wh],op.size+el.Pad[op.vh.inv.lead]+el.Pad[op.vh.inv.trail]);el.Offset=off;el.Centre=el.Offset+el.Pad[op.vh.lead]+(el.Initial/2);off+=el.Initial+el.Pad[op.vh.lead]+el.Pad[op.vh.trail]}i=0;while(i<Dock.Elem.length){el=Dock.Elem[i++];acc=0;upad=el.Pad[op.vh.lead]+el.Pad[op.vh.trail];Dock.Spread+=el.Initial+upad;this.setSizes(id,el.Centre);j=Dock.Elem.length;while(j){acc+=Dock.Elem[--j].Final+upad}Dock[op.vh.wh]=Math.max(Dock[op.vh.wh],acc)}while(i){el=Dock.Elem[--i];el.Final=el.Initial}var wrap=[this.vanillaDiv,'<div class="jqDock" style="position:absolute;top:0px;left:0px;padding:0px;','margin:0px;overflow:visible;height:',Dock.height,'px;width:',Dock.width,'px;"></div></div>'].join('');Dock.Yard=$(Dock.Menu).wrapInner(wrap).find('div.jqDock');$.each([op.vh.lead,op.vh.trail],function(n,v){Dock.Borders[v]=ME.asNumber(Dock.Yard.css('border'+v+'Width'))});if(Dock.Borders[op.vh.lead]){Dock.Yard.css(op.vh.tl,Math.ceil(Dock.Borders[op.vh.lead]/2))}while(i<Dock.Elem.length){el=Dock.Elem[i];this.changeSize(id,i,el.Final,true);el.Img.addClass('jqDockMouse'+id+'_'+(i++))}$(Dock.Menu).show();if(Dock.Opts.labels){$.each(Dock.Elem,function(i){ME.setLabel(id,this.Label)});Dock.Label.hide()}Dock.Yard.bind('mouseover mouseout mousemove',function(e){ME.mouseHandler(e)})},altImage:function(){var alt=$(this).attr('alt');return(alt&&alt.match(/\.(gif|jpg|jpeg|png)$/i))?alt:false},removeText:function(el){var i=el.childNodes.length,j;while(i){j=el.childNodes[--i];if(j.childNodes&&j.childNodes.length){this.removeText(j)}else if(j.nodeType==3){el.removeChild(j)}}},asNumber:function(x){var r=parseInt(x,10);return isNaN(r)?0:r},keepProportion:function(el,dim,orient){var r={},vh=this.verthorz[orient.vh],inv=this.verthorz[orient.inv];r[vh.wh]=dim;r[inv.wh]=Math.round(dim*el[inv.wh]/el[vh.wh]);return r},deltaXY:function(id){var Dock=this.docks[id];if(Dock.Current!==false){var op=Dock.Opts,el=Dock.Elem[Dock.Current],p=el.Pad[op.vh.lead]+el.Pad[op.vh.trail],off=el.Img.offset();Dock.Delta=Math.floor((this[op.vh.xy]-off[op.vh.tl])*(p+el.Initial)/(p+el.Actual))+el.Offset;this.doLabel(id,off)}},setLabel:function(id,label){var Dock=this.docks[id],ME=this,pad={};if(!Dock.Label){Dock.Label=$('<div class="jqDockLabel jqDockMouse'+id+'_00 jqDockLabelImage" style="position:absolute;margin:0px;"></div>').hide().bind('click',function(){Dock.Elem[Dock.Current].Img.trigger('click')}).appendTo(Dock.Yard)}if(label.txt){Dock.Label.text(label.txt);$.each(['Top','Right','Bottom','Left'],function(n,v){pad[v]=ME.asNumber(Dock.Label.css('padding'+v))});$.each(this.verthorz,function(vh,o){label[o.wh]=Dock.Label[o.wh]();label[o.wh+'Pad']=pad[o.lead]+pad[o.trail]})}},doLabel:function(id,off){var Dock=this.docks[id];if(Dock.Opts.labels&&Dock.Current!==false){var el=Dock.Elem[Dock.Current],L=el.Label,op=Dock.Opts,what=typeof off=='string'?off:'move';switch(what){case'show':case'hide':Dock.Label[L.txt?what:'hide']();break;case'change':Dock.Label[0].className=Dock.Label[0].className.replace(/(jqDockLabel)(Link|Image)/,'$1'+(el.Linked?'Link':'Image'));Dock.Label.text(L.txt).css({width:L.width,height:L.height}).hide();break;default:var doff=Dock.Yard.offset(),css={top:off.top-doff.top,left:off.left-doff.left},splt=op.labels.split('');if(splt[0]=='m'){css.top+=Math.floor((el[op.vh.inv.act]-L.height-L.heightPad)/2)}else if(splt[0]=='b'){css.top+=el[op.vh.inv.act]+el.Pad.Top+el.Pad.Bottom-L.height-L.heightPad}if(splt[1]=='c'){css.left+=Math.floor((el[op.vh.act]-L.width-L.widthPad)/2)}else if(splt[1]=='r'){css.left+=el[op.vh.act]+el.Pad.Left+el.Pad.Right-L.width-L.widthPad}Dock.Label.css(css)}}},mouseHandler:function(e){var r=null,t=e.target.className.match(/jqDockMouse(\d+)_(\d+)/),rt=!!(e.relatedTarget)&&e.relatedTarget.tagName!==undefined;if(t){r=false;var id=1*t[1],Dock=this.docks[id],idx=t[2]=='00'?Dock.Current:1*t[2];this.X=e.pageX;this.Y=e.pageY;if(e.type=='mousemove'){if(idx==Dock.Current){this.deltaXY(id);if(Dock.OnDock&&Dock.Expanded){this.setSizes(id);this.factorSizes(id)}}}else{var rel=rt&&e.relatedTarget.className.match(/jqDockMouse(\d+)_(\d+)/);if(e.type=='mouseover'&&(!Dock.OnDock||idx!==Dock.Current)){Dock.Current=idx;this.doLabel(id,'change');this.deltaXY(id);if(Dock.Expanded){this.doLabel(id,'show')}if(rt&&(!rel||rel[1]!=id)){Dock.Timestamp=(new Date()).getTime();this.setSizes(id);Dock.OnDock=true;this.overDock(id)}}else if(rt&&e.type=='mouseout'){if(!rel||rel[1]!=id){Dock.OnDock=false;this.doLabel(id,'hide');var i=Dock.Elem.length;while((i--)){Dock.Elem[i].Final=Dock.Elem[i].Intial}this.offDock(id)}}}}return r},overDock:function(id){var Dock=this.docks[id];if(Dock.OnDock){var ME=this,el=Dock.Elem,i=el.length;while((i--)&&!(el[i].Actual<el[i].Final)){}if(i<0){Dock.Expanded=true;this.deltaXY(id);this.doLabel(id,'show')}else{this.setSizes(id);this.factorSizes(id);setTimeout(function(){ME.overDock(id)},60)}}},offDock:function(id){var Dock=this.docks[id];if(!Dock.OnDock){var ME=this,done=true,i=Dock.Elem.length,el,sz;while(i){el=Dock.Elem[--i];if(el.Actual>el.Initial){sz=el.Actual-el.ShrinkStep;if(sz>el.Initial){done=false}else{sz=el.Initial}this.changeSize(id,i,sz)}}this.deltaXY(id);if(done){while(i<Dock.Elem.length){el=Dock.Elem[i++];el.Actual=el.Final=el.Initial}Dock.Current=Dock.Expanded=false}else{setTimeout(function(){ME.offDock(id)},this.shrinkInterval)}}},setSizes:function(id,mxy){var Dock=this.docks[id],op=Dock.Opts,i=Dock.Elem.length,el,sz;mxy=mxy||Dock.Delta;while(i){el=Dock.Elem[--i];sz=Math.floor(el.SizeDiff*Math.pow(Math.abs(mxy-el.Centre),op.coefficient)/op.attenuation);el.Final=(sz<el.SizeDiff?el[op.vh.wh]-sz:el.Initial)}},factorSizes:function(id){var Dock=this.docks[id],op=Dock.Opts,lapse=op.duration+60;if(Dock.Timestamp){lapse=(new Date()).getTime()-Dock.Timestamp;if(lapse>=op.duration){Dock.Timestamp=0}}if(lapse>60){var f=lapse<op.duration?lapse/op.duration:0,i=0,el;while(i<Dock.Elem.length){el=Dock.Elem[i];this.changeSize(id,i++,(f?Math.floor(el.Initial+((el.Final-el.Initial)*f)):el.Final))}}},changeSize:function(id,idx,dim,force){var Dock=this.docks[id],el=Dock.Elem[idx];if(force||el.Actual!=dim){var op=Dock.Opts,bdr=($.boxModel||op.orient.vh=='v')?0:Dock.Borders[op.vh.lead]+Dock.Borders[op.vh.trail];if(el.Source[2]&&!force&&el.Actual==el.Initial){el.Img[0].src=el.Source[1]}if(Dock.OnDock){this.deltaXY(id)}Dock.Spread+=dim-el.Actual;var css=this.keepProportion(el,dim,op.orient),diff=op.size-css[op.vh.inv.wh],m='margin',z=op.vh.inv;switch(op.align){case'bottom':case'right':css[m+z.lead]=diff;break;case'middle':case'center':css[m+z.lead]=(diff+diff%2)/2;css[m+z.trail]=(diff-diff%2)/2;break;case'top':case'left':css[m+z.trail]=diff;break;default:}Dock.Yard[op.vh.wh](Dock.Spread+bdr);el.Img.css(css);Dock.Yard.css('margin'+op.vh.lead,Math.floor((Dock[op.vh.wh]-Dock.Spread)/2));el.Actual=dim;el.ActualInv=css[op.vh.inv.wh];if(el.Source[2]&&!force&&el.Actual==el.Initial){el.Img[0].src=el.Source[0]}}}}}();$.fn.jqDock=function(opts){return this.filter(function(){var i=jqDock.docks.length;while((i--)&&this!=jqDock.docks[i].Menu){}return(i<0)&&($('img',this).length)}).hide().each(function(){var id=jqDock.docks.length;jqDock.docks[id]={Elem:[],Menu:this,OnDock:false,Expanded:false,Timestamp:0,width:0,height:0,Spread:0,Borders:{},Yard:false,Opts:$.extend({},jqDock.defaults,opts||{}),Current:false,Delta:0,Loaded:0,Label:false};var Dock=jqDock.docks[id],op=Dock.Opts;op.attenuation=Math.pow(op.distance,op.coefficient);op.orient=({left:1,center:1,right:1}[op.align])?{vh:'v',inv:'h'}:{vh:'h',inv:'v'};op.vh=$.extend({},jqDock.verthorz[op.orient.vh],{inv:jqDock.verthorz[op.orient.inv]});op.loader=(op.loader)&&typeof op.loader=='string'&&/^image|jquery$/i.test(op.loader)?op.loader.toLowerCase():'';op.labels=op.labels===true?{top:'bc',left:'tr',right:'tl'}[op.align]||'tc':(typeof op.labels=='string'&&{tl:1,tc:1,tr:1,ml:1,mc:1,mr:1,bl:1,bc:1,br:1}[op.labels]?op.labels:false);$('img',this).each(function(n){var me=$(this),s0=me.attr('src'),s1=(op.source?op.source.call(me[0],n):false)||jqDock.altImage.call(this)||s0,tx=op.labels?me.attr('title')||me.parent('a').attr('title')||'':'';Dock.Elem[n]={Img:me,Source:[s0,s1,!(s0==s1)],Label:{txt:tx,width:0,height:0,widthPad:0,heightPad:0},Initial:0,Actual:0,ActualInv:0,Final:0,Offset:0,Centre:0,Pad:{},Linked:!!me.parent('a').length,width:0,height:0};$.each(['Top','Right','Bottom','Left'],function(i,v){Dock.Elem[n].Pad[v]=jqDock.asNumber(me.css('padding'+v))})});var jqld=(!op.loader&&jqDock.useJqLoader)||op.loader=='jquery';$.each(Dock.Elem,function(i){var me=this,iLoaded=function(){me.height=this.height;me.width=this.width;if(++Dock.Loaded>=Dock.Elem.length){setTimeout(function(){jqDock.initDock(id)},0)}};if(jqld){$('<img />').bind('load',iLoaded).attr({src:this.Source[1]})}else{var pre=new Image();pre.onload=function(){iLoaded.call(this);pre.onload=function(){}};pre.src=this.Source[1]}})}).end()};$.jqDock=function(x){return jqDock[x]?jqDock[x]:null}}})(jQuery);


if(typeof(Regio)=="undefined"){Regio={}}(function($){Regio.Utils={};Regio.Utils.format=function(str,obj){if(typeof(obj)=="object"){for(var i in obj){var re=new RegExp("\\{"+(i)+"\\}","gmi");str=str.replace(re,obj[i])}}else{for(var i=1;i<arguments.length;i++){var re=new RegExp("\\{"+(i-1)+"\\}","gmi");str=str.replace(re,arguments[i])}}return str};Regio.Utils.formatEx=function(str,obj){var matches=str.match(/{([a-zA-Z0-9\.]+)}/gi);if(matches){for(var i=0;i<matches.length;i++){var match=matches[i].replace(/{|}/g,"");var path=match.split(".");var key=obj,found=true;for(var j=0;j<path.length;j++){if(typeof key!="object"){found=false;break}else{key=key[path[j]]}}if(found&&(typeof key!="undefined")){str=str.replace("{"+match+"}",key)}}}return str};Regio.Utils.removeSubstr=function(str){for(var i=1;i<arguments.length;i++){var re=new RegExp(arguments[i],"g");str=str.replace(re,"")}return str};Regio.Utils.initTemplate=function(div,type){div=Regio.Utils.getElement(div);if(!div){throw new Error("Regio.Utils.initTemplate, incorrect div")}var s=Regio.Utils.removeSubstr(new String(div.innerHTML),"<!--","-->"," *\n *"," *\r *","\t");Regio.Utils.empty(div);if(type=="html"){return s}else{if(s==""){return{}}try{return eval("("+s+")")}catch(err){var msg=(err.description?err.description:err);throw new Error("Regio.Utils.initTemplate("+(div.id?div.id:div.name)+") failed with message: "+msg)}}};Regio.Utils.empty=function(div){while(div.childNodes.length>0){div.removeChild(div.childNodes[0])}return div};Regio.Utils.applyDefaults=function(cfg,values){for(var key in values){if(cfg[key]==null){cfg[key]=values[key]}}return cfg};Regio.Utils.getElement=function(div){if(typeof(div)=="string"){div=document.getElementById(div)}return div};Regio.Utils.isArray=function(obj){return((typeof(obj)=="object")&&(obj.constructor==Array))};Regio.Utils.getElementsByClassName=function(element,clsName){var retVal=new Array();var elements=element.getElementsByTagName("*");for(var i=0;i<elements.length;i++){if(elements[i].className.indexOf(" ")>=0){var classes=elements[i].className.split(" ");for(var j=0;j<classes.length;j++){if(classes[j]==clsName){retVal.push(elements[i])}}}else{if(elements[i].className==clsName){retVal.push(elements[i])}}}return retVal};Regio.Utils.createUniqueId=function(prefix){return prefix+Math.random().toString().split(".")[1]};Regio.Utils.createDelayedFunction=function(callback,updateOncePer,strategy){return function(){var args=arguments;var func=arguments.callee;var lastTime=func.last,curTime=Number(new Date());if((typeof lastTime=="undefined")&&(strategy=="FIRST_WAIT")){func.last=lastTime=curTime}clearTimeout(func.timer);if(curTime-lastTime<updateOncePer){func.timer=setTimeout(function(){func.apply(this,args)},updateOncePer/4);return}func.last=curTime;callback.apply(this,args)}};Regio.Collection=function(div,cfg){cfg=cfg||{};div=Regio.Utils.getElement(div);var me=this;var data=[];Regio.Utils.applyDefaults(cfg,{rowTemplate:""});clear();function addItem(obj){if((data.length==0)&&(me.beforeFirstRowAdded)){me.beforeFirstRowAdded(obj)}var childs=addRow(obj);if(me.onNewItem){me.onNewItem(obj,childs)}data.push({childs:childs,object:obj});return childs}function addItems(arr){for(var i=0;i<arr.length;i++){addItem(arr[i])}}function removeItem(obj){for(var i=data.length-1;i>=0;i--){if(data[i].object==obj){with(data[i]){if(me.onRemoveItem){me.onRemoveItem(obj,childs)}for(var j=childs.length-1;j>=0;j--){childs[j].parentNode.removeChild(childs[j])}childs.length=0}data.splice(i,1)}}if((data.length==0)&&(me.afterLastRowRemoved)){me.afterLastRowRemoved(obj)}}function getItemChilds(obj){for(var i=data.length-1;i>=0;i--){if(data[i].object==obj){return data[i].childs}}return false}function clear(){while(data.length>0){removeItem(data[data.length-1])}}function addRow(obj){var elem=document.createElement(div.tagName);if(window.jQuery){jQuery(elem).append(jQuery(Regio.Utils.format(cfg.rowTemplate,obj)))}else{elem.innerHTML=Regio.Utils.format(cfg.rowTemplate,obj)}if(me.beforeDrawRow){me.beforeDrawRow(obj,elem.childNodes)}var childs=[];while(elem.childNodes.length>0){var c=elem.childNodes[0];div.appendChild(c);childs.push(c)}return childs}function getCount(){return data.length}this.addItem=addItem;this.addItems=addItems;this.removeItem=removeItem;this.getItemChilds=getItemChilds;this.clear=clear;this.count=getCount};Regio.ListView=function(div,cfg){cfg=cfg||{};div=Regio.Utils.getElement(div);var me=this;var data=[];var filterObj={filter:function(){return true}};Regio.Utils.applyDefaults(cfg,{rowTemplate:""});if(typeof(cfg.filter)!="undefined"){this.setFilter(cfg.filter)}clear();function clear(){if(me.beforeClear){me.beforeClear()}Regio.Utils.empty(div)}function drawRow(row,i,cnt){var elem=document.createElement(div.tagName);if(window.jQuery){jQuery(elem).append(jQuery(Regio.Utils.format(cfg.rowTemplate,row)))}else{elem.innerHTML=Regio.Utils.format(cfg.rowTemplate,row)}if(this.beforeDrawRow){this.beforeDrawRow(row,elem.childNodes,i,cnt)}while(elem.childNodes.length>0){var c=elem.childNodes[0];if(this.beforeDrawRowChildNode){this.beforeDrawRowChildNode(c,div,row)}div.appendChild(c);if(this.afterDrawRowChildNode){this.afterDrawRowChildNode(c,div,row)}}}function redraw(){clear();execute("current",drawRow,me)}function execute(filterObject,callback,me){if(filterObject=="current"){filterObject=filterObj}if(filterObject.start){filterObject.start()}var cnt=0;for(var i=0;i<data.length;i++){if(filterObject.filter?filterObject.filter(data[i],cnt):true){callback.call(me,data[i],i,cnt);cnt++}}if(filterObject.finish){filterObject.finish()}}this.execute=execute;this.setData=function(arr){if(typeof(arr)!="object"){throw new Error("Regio.ListView.setData, arr is not array")}data=arr;redraw()};this.getData=function(){return data};this.clear=function(){this.setData([])};this.setFilter=function(callback){if(typeof(callback)=="function"){filterObj.filter=callback}else{if(typeof(callback)=="object"){if(!callback.filter){throw new Error('ListView.setFilter callback seems to be filter object but doe not contain "filter" method')}filterObj=callback}}redraw()};this.getFilter=function(){return filterObj};this.refresh=function(){redraw()};return this};window.MapCat={Version:"2.x"};MapCat.Listener=function(listeners,callback,contest){this.callback=callback;this.contest=contest;this.call=function(){return callback.apply(contest,arguments)};this.remove=function(){listeners.removeByFunction(callback)}};MapCat.Listeners=function(){this.list={}};MapCat.Listeners.prototype={add:function(eventName,callback,contest){this.addEx.apply(this,arguments);return this},addEx:function(eventName,callback,contest){var me=this;var rec=new MapCat.Listener(this,callback,contest);if(this.list[eventName]){this.list[eventName].push(rec)}else{this.list[eventName]=[rec]}return rec},removeByFunction:function(func){for(var a in this.list){var arr=this.list[a];for(var i=arr.length-1;i>=0;i--){var rec=arr[i];if(rec.callback==func){arr.splice(i,1)}}if(arr.length==0){delete this.list[a]}}return this},broadcast:function(){var args=[undefined];for(var i=0;i<arguments.length;i++){args.push(arguments[i])}return this.broadcastEx.apply(this,args)},broadcastEx:function(filter,eventName){var result,l,args;function processQueue(l,args){for(var i=0;i<l.length;i++){var rec=l[i];if(filter&&!filter(rec)){continue}var r=rec.call.apply(rec,args);if(typeof(r)!="undefined"&&(r!=null)){result=r}}}args=[];for(var i=1;i<arguments.length;i++){args.push(arguments[i])}if(l=this.list["*"]){processQueue(l,args)}args.shift();if(l=this.list[eventName]){processQueue(l,args)}return result},call:function(){return this.broadcast.apply(this,arguments)}};MapCat.Log={add:function(str){}};MapCat.Component=function(){var result=this.initialization.apply(this,arguments);return result};MapCat._getTagHTML=function(cfg){cfg.id=cfg.id?cfg.id:"";cfg.vars=cfg.vars?cfg.vars:"";cfg.src=cfg.src?cfg.src:"map.swf";cfg.width=typeof(cfg.width)=="undefined"?"100%":cfg.width;cfg.height=typeof(cfg.height)=="undefined"?"100%":cfg.height;cfg.wmode=typeof(cfg.wmode)=="undefined"?"window":cfg.wmode;cfg.bgcolor=typeof(cfg.bgcolor)=="undefined"?"738aa0":cfg.bgcolor;cfg.scale=typeof(cfg.scale)=="undefined"?"noscale":cfg.scale;cfg.quality=typeof(cfg.quality)=="undefined"?"high":cfg.quality;with(cfg){var html='<object codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'"classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="'+cfg.id+'"><param name="quality" value="'+quality+'" /> <param name="scale" value="'+scale+'" /> <param name="allowScriptAccess" value="always" /> <param name="bgcolor" value="'+bgcolor+'" /> <param name="flashvars" value="jsApiID='+apiID+"&"+vars+'" /> <param name="movie" value="'+src+'" /> <param name="wmode" value="'+wmode+'" /> <embed quality="'+quality+'" scale="'+scale+'" width="'+width+'" height="'+height+'"allowscriptaccess="always" bgcolor="'+bgcolor+'" flashvars="jsApiID='+apiID+"&"+vars+'" pluginspage="http://www.macromedia.com/go/getflashplayer" src="'+src+'" wmode="'+wmode+'" type="application/x-shockwave-flash" id="'+cfg.id+'" ></embed></object>'}return html};MapCat._apiList={};MapCat._apiList.register=function(api){MapCat._apiList[api.id]=api};MapCat._flashGateway=function(apiID,func,args){if(MapCat&&MapCat._apiList){var api=MapCat._apiList[apiID];if(api){return api[func].apply(api,args)}}return null};MapCat.Component.prototype={initialization:function(divid,cfg,listeners){cfg=cfg||{};this.id="mapcat_api_"+Math.random().toString().split(".")[1];cfg.apiID=this.id;if(!cfg.id){cfg.id=this.id}MapCat._apiList.register(this);if(!listeners){this.listeners=new MapCat.Listeners()}else{this.listeners=listeners}var flashListener=this.listeners.addEx("*",function(){return this._callFlash.apply(this,arguments)},this);this._flashListenerFilter=function(listener){return(listener!=flashListener)};var div=false;if(typeof divid=="string"){div=document.getElementById(divid)}else{div=divid}this.div=div;this.cfg=cfg;if(navigator.userAgent.match(/safari/i)||(cfg.wmode||"").match(/opaque|transparent/i)){this.initMouseWheel()}this.stack=[];this.addCallback(cfg.loadedEvent?cfg.loadedEvent:"mapcat.loaded",this._flashLoadedEvent,this);return this.restart()},initMouseWheel:function(){var me=this;function addEvent(el,eType,fn,uC){if(el.addEventListener){el.addEventListener(eType,fn,uC);return true}else{if(el.attachEvent){return el.attachEvent("on"+eType,fn)}else{el["on"+eType]=fn}}}function cancelEvent(e){e=e?e:window.event;if(e.stopPropagation){e.stopPropagation()}if(e.preventDefault){e.preventDefault()}e.cancelBubble=true;e.cancel=true;e.returnValue=false;return false}function wheelCallback(e){e=e?e:window.event;var wheelData=(e.detail?e.detail*-1:e.wheelDelta/40)/3;var x=typeof e.offsetX!="undefined"?e.offsetX:e.layerX;var y=typeof e.offsetY!="undefined"?e.offsetY:e.layerY;me.ready(function(){me.broadcast(me.cfg.mouseWheelEvent?me.cfg.mouseWheelEvent:"map.zoom",{x:x,y:y,delta:wheelData})});return cancelEvent(e)}addEvent(this.div,"DOMMouseScroll",wheelCallback,false);addEvent(this.div,"mousewheel",wheelCallback,false)},restart:function(){this.flashLoaded=false;var div=this.div,cfg=this.cfg;var result=false;if(div){div.innerHTML=MapCat._getTagHTML(cfg);var embeds=div.getElementsByTagName("embed");if(!embeds||embeds.length==0){embeds=div.getElementsByTagName("object")}result=embeds.length>0;if(result){this.flash=embeds[0]}if(this.flash){window[cfg.id]=this.flash}}else{result=false}return result},addCallback:function(eventName,callback,me){this.listeners.add(eventName,callback,me)},broadcast:function(){this.call.apply(this,arguments)},call:function(){var res=this.listeners.broadcast.apply(this.listeners,arguments);return res},ready:function(func){if(this.flashLoaded){func.apply(func)}else{this.stack.push(func)}},_flashListener:undefined,_flashListener:undefined,_callLocal:function(){var args=[this._flashListenerFilter];for(var i=0;i<arguments.length;i++){args.push(arguments[i])}return this.listeners.broadcastEx.apply(this.listeners,args)},_callFlash:function(){if(this.flash&&this.flash._javascriptGateway){var args=[];for(var i=0;i<arguments.length;i++){args.push(arguments[i])}var flashresult=null;try{flashresult=this.flash._javascriptGateway(this.id,"callLocal",args)}catch(e){MapCat.Log.add("Exception while calling Flash callback: "+e,MapCat.Log.ERROR)}return flashresult}return null},_flashLoadedEvent:function(){this.flashLoaded=true;while(this.stack.length>0){var f=this.stack.shift();f.apply(f)}}};if(typeof(Regio)=="undefined"){Regio={}}Regio.Cookies={get:function(c_name){if(document.cookie.length>0){c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1){c_start=c_start+c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1){c_end=document.cookie.length}return unescape(document.cookie.substring(c_start,c_end))}}return""},put:function(c_name,value,expiredays){var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+"="+escape(value)+((expiredays==null)?"":";expires="+exdate.toGMTString())}};if(typeof(Regio)=="undefined"){Regio={}}Regio.TreeView=function(div){if(typeof div=="string"){div=document.getElementById(div)}this.div=div};Regio.TreeView.prototype={setData:function(obj){this.data=obj;this._formatTree(this.data)},collapseAllButFirstByDefault:true,wrapTree:true,onFormatObjectItem:undefined,onBranchHeaderClick:undefined,onBeforeBranchProcess:undefined,onFormatBranchHeader:undefined,onGetBranchClass:undefined,onFormatBranch:undefined,_formatTree:function(data){var html="";if(this.wrapTree){html+='<div class="tree" style="overflow: auto; height: 100%;">';html+=this._formatBranch(data,0,true);html+="</div>"}else{html+=this._formatBranch(data,0,true)}this.div.innerHTML=html},_formatBranch:function(branch,level,firstBranch){var html="";if(!this.onFormatBranch){var branchClass=this.onGetBranchClass?this.onGetBranchClass(level,branch):(level>0?"branch":"firstbranch");html+='<div class="'+branchClass+'" style="display: '+(!firstBranch&&this.collapseAllButFirstByDefault?"none":"")+'">'}for(var b in branch){branch[b]._parent_=branch;if(b!="_data_"&&b!="_parent_"){switch(typeof branch[b]){case"object":if(!branch[b].isItem){if(this.onFormatBranch){html+=new String(this.onFormatBranch(b,branch[b])).replace(/{childs}/gmi,this._formatBranch(branch[b],level+1,firstBranch))}else{if(this.onBeforeBranchProcess){this.onBeforeBranchProcess(b,branch[b])}html+='<div class="branch_wrapper">';if(!this.noExpanders){html+='<a href="#" onClick="Regio.TreeView.__branchClick(this.nextSibling.nextSibling, this); return false" class="'+(!firstBranch&&this.collapseAllButFirstByDefault?"collapser":"expander")+'">';html+="&nbsp;";html+="</a>"}html+='<span class="header">';if(this.onFormatBranchHeader){html+=this.onFormatBranchHeader(b,branch[b],level)}else{html+=b;html+="<br />"}html+="</span>";html+=this._formatBranch(branch[b],level+1,firstBranch);html+="</div>"}}else{if(this.onFormatObjectItem){html+=this.onFormatObjectItem(b,branch[b],level)}else{html+='<div class="item">'+b+"</div>"}}break;case"string":case"number":case"boolean":html+='<div class="item '+b+'">'+branch[b]+"</div>";break}firstBranch=false}}if(!this.onFormatBranch){html+="</div>"}return html}};Regio.TreeView.__branchClick=function(div,link){if(this.onBranchHeaderClick){this.onBranchHeaderClick(div,link)}link.className=(link.className=="expander"?"collapser":"expander");if(typeof(jQuery)!="undefined"){$(div).animate({opacity:"toggle",height:"toggle"},200)}else{div.style.display=(div.style.display?"":"none")}return false};if((typeof(Regio)=="undefined")||(typeof(Regio.TreeView)=="undefined")){alert("LayersTree requires Regio.TreeView!")}if((typeof(Regio)=="undefined")||(typeof(Regio.Cookies)=="undefined")){alert("LayersTree requires Regio.Cookies!")}if(((typeof(Regio)=="undefined")||!(Regio.Utils&&Regio.Utils.format)&&(typeof(Regio.formatStr)=="undefined"))&&(typeof(String.prototype.format)=="undefined")){alert("LayersTree requires utils.js!")}if(typeof(jQuery)=="undefined"){alert("LayersTree requires jQuery!")}if((typeof(jQuery)=="undefined")||(!Object.toJSON)){alert("LayersTree requires jQuery.json extension (json.js)!")}if(typeof(Regio.formatStr)=="undefined"){if(Regio.Utils&&Regio.Utils.format){Regio.formatStr=Regio.Utils.format}else{Regio.formatStr=function(str){var args=[];for(var i=1;i<arguments.length;i++){args.push(arguments[i])}return str.format.apply(str,args);return}}}Regio.LayersTree=function(div,cfg,mapcat,id){var div=Regio.Utils.getElement(div);this.mapcat=mapcat;var state=null;id=id?id:div.id?div.id:"";if(cfg.saveStateInCookies){var key="Regio.LayersTree."+id+".state";state=Regio.Cookies.get(key);if(state){state=state.parseJSON()}}cfg.sortable=typeof(cfg.sortable)=="undefined"?true:cfg.sortable;cfg.collapseClasses=(cfg.collapseClasses&&cfg.collapseClasses.length&&(cfg.collapseClasses.length>=2))?cfg.collapseClasses:["collapser","expander"];var tree=new Regio.TreeView(div);tree.noExpanders=true;tree.collapseAllButFirstByDefault=false;tree.wrapTree=false;tree.onFormatObjectItem=onFormatItem;tree.onFormatBranch=onFormatBranch;var myId="LayersTree_"+Math.random().toString().split(".")[1];window[myId]=this;this.myId=myId;var self=this;this.mapcat.addCallback(cfg.loadedEventName?cfg.loadedEventName:"mapcat.layersData.loaded",onLayersListLoaded,this);this.mapcat.addCallback("layers.enabled",onLayerStatusChangedNew,this);var last_ft_data=undefined;var events={list:{},init:function(obj){if(obj){var me=this;for(evs in obj){$(evs.split(",")).each(function(){me.list[this]=obj[evs]})}}},execUserEvent:function(name){this.applyRule(this.list[name])},applyRule:function(selectors){for(j in selectors){if(j=="code"){eval(selectors[j])}else{var props=selectors[j];var elem=$(j,div);var me=this;elem.each(function(){me.applyPropertyes(this,props)})}}},applyPropertyes:function(elem,obj){for(key in obj){var value=obj[key];if(typeof(value)=="object"){this.applyPropertyes(elem[key],value)}else{elem[key]=value}}}};events.init(cfg.events);function findGroupIdByLayerId(lid){for(g in last_ft_data){for(l in last_ft_data[g].layers){if(last_ft_data[g].layers[l].id==lid){return last_ft_data[g].id}}}return false}var groupsList={},userEventsList={};var _checkGroupsList=Regio.Utils.createDelayedFunction(function(){for(var g in groupsList){checkGroupDisabledState(g);checkLayerGroupCheck(g)}groupsList={}},1000,"FIRST_WAIT");var _execUserEvents=Regio.Utils.createDelayedFunction(function(){for(var g in userEventsList){events.execUserEvent(g)}userEventsList={}},1000,"FIRST_WAIT");function onLayerStatusChanged(gid,lid,enabled){var gid=gid;$(document.getElementById("layer_check_"+lid)).attr("disabled",!enabled);$(document.getElementById("layer_"+lid))[enabled?"removeClass":"addClass"]("disabled");userEventsList[enabled?"itemenabled":"itemdisabled"]=true;groupsList[gid]=true;_execUserEvents();_checkGroupsList()}function onLayerStatusChangedNew(arr){var userEventsList={};var groupsList={};for(var i=0;i<arr.length;i++){var rec=arr[i];var enabled=rec.enabled,lid=rec.layerId,gid=rec.groupId;$(document.getElementById("layer_check_"+lid)).attr("disabled",!enabled);$(document.getElementById("layer_"+lid))[enabled?"removeClass":"addClass"]("disabled");userEventsList[enabled?"itemenabled":"itemdisabled"]=true;groupsList[gid]=true}for(var g in groupsList){checkGroupDisabledState(g);checkLayerGroupCheck(g)}for(var g in userEventsList){events.execUserEvent(g)}}function onLayersListLoaded(list){if(state){reorderGroups(state.groupsOrder);var groups=$(state.groupLayersOrder);for(var i=0;i<groups.length;i++){reorderLayers(state.groupsOrder[i],groups[i])}var list=mapcat.call("mapcat.layersData.get")}this.setFTGroupsData(list)}function convertListDataToTreeData(menu){var res={};for(var g=0;g<menu.length;g++){var headerSymbol="";if(menu[g].layers.length>0){headerSymbol=menu[g].layers[0].symbol}res[menu[g].name]={_data_:{id:menu[g].id,symbol:headerSymbol}};var layers=menu[g].layers;for(var i=0;i<layers.length;i++){res[menu[g].name][layers[i].name]={isItem:true,data:layers[i]}}}return res}function callJQPluginExts(plugin,extname,e,ui){if($.ui[plugin]&&$.ui[plugin].prototype.plugins[extname]){var o=ui.options;var c=$.ui[plugin].prototype.plugins[extname];for(var i=0;i<c.length;i++){if(o[c[i][0]]){c[i][1].apply(e,[e,ui])}}}}function makeTreeSortable(){$(".layer_group",div).sortable({items:".layer_name",hoverClass:"sortHelper",handle:cfg.itemDragHandler,update:function(a,b){var gid=(b.current?b.current.element.id:b.element.attr("id")).substring("layer_group_".length);reorderLayers(gid,getLayers(gid));saveTreeState(true)},start:function(e,ui){callJQPluginExts("draggable","start",e,ui)},sort:function(e,ui){callJQPluginExts("draggable","drag",e,ui)},stop:function(e,ui){callJQPluginExts("draggable","stop",e,ui)},axis:"y"});$(div).sortable({items:".layer_group",hoverClass:"sortHelper",handle:cfg.headerDragHandler,update:function(){reorderGroups(getGroups());saveTreeState(true)},helper:"original",start:function(e,ui){callJQPluginExts("draggable","start",e,ui)},sort:function(e,ui){callJQPluginExts("draggable","drag",e,ui)},stop:function(e,ui){callJQPluginExts("draggable","stop",e,ui)},axis:"y"})}function saveTreeState(delayed){if(cfg.saveStateInCookies){if(delayed){setTimeout(Regio.formatStr('window["{0}"].saveTreeState(false)',myId),1000)}else{var json=Object.toJSON(getState());Regio.Cookies.put("Regio.LayersTree."+id+".state",json)}}}function getState(){var groups=getGroups();var layersInGroups=[];$(groups).each(function(){layersInGroups.push(getLayers(this))});var state={groupsOrder:groups,groupLayersOrder:layersInGroups,expandedGroups:getExpandedGroups()};return state}function reorderGroups(idList){mapcat.broadcast("layers.reorderGroups",idList)}function reorderLayers(gid,idList){mapcat.broadcast("layers.reorderLayers",idList)}function getGroups(){var res=[];$(".layer_group",div).each(function(){res.push(this.id.substring("layer_group_".length))});return res}function getLayers(gid){var res=[];if(gid){$("#layer_group_"+gid,div).each(function(){$(".layer_name",this).each(function(){res.push(this.id.substring("layer_".length))})})}else{$(".layer_name",div).each(function(){res.push(this.id.substring("layer_".length))})}return res}function getCheckedLayers(){var res=[];var checks=$("input:checkbox",div).not(".header_check").not(":disabled").filter(":checked").each(function(){res.push(this.id.substring("layer_check_".length))});return res}function getExpandedGroups(){var res=[];$(".layer_group:has(."+cfg.collapseClasses[0]+")",div).each(function(){res.push(this.id.substring("layer_group_".length))});return res}function onFormatItem(name,obj){var privateLayer=false;if(cfg.privateLayersPrefix){privateLayer=(name.length>0)&&(name.substring(0,1)==cfg.privateLayersPrefix);if(privateLayer){name=name.substring(1)}}var tmpl=cfg.itemFormat;if(!tmpl){tmpl='<div class="{layer_class}" id="{layer_div_id}">{layer_name}</div>'}var fmt=$.extend({},obj.data,{layer_name:name,layer_id:obj.data.id,layer_check_id:"layer_check_"+obj.data.id,checkbox_checked_attr:obj.data.checked?'checked="true"':"",checkbox_disabled_attr:obj.data.enabled?"":'disabled="true"',draggable_class:"draggable",layer_div_id:"layer_"+obj.data.id,layer_class:"layer_name"+(obj.data.enabled?"":" disabled")+(privateLayer?" private":""),symbol:obj.data.symbol,checkbox_onclick:Regio.formatStr("window['{0}'].checkLayer(this.checked, '{1}', '{2}', false)",myId,obj.data.id,obj._parent_._data_.id)});var t=Regio.formatStr(new String(tmpl),fmt);return t}function onFormatBranch(name,obj){var privateGroup=false;if(cfg.privateGroupsPrefix){privateGroup=(name.length>0)&&(name.substring(0,1)==cfg.privateGroupsPrefix);if(privateGroup){name=name.substring(1)}}var tmpl=cfg.branchFormat;if(!tmpl){tmpl='<div class="{group_class}" id="{group_div_id}"><div class="group_header"><span class="{draggable_class}">X</span>{group_name} <a href="{collapse_link_href}">x</a></div><div class="{collapse_class}">{childs}</div></div>'}var fmt=$.extend({},obj._data_,{group_name:name,group_id:obj._data_.id,draggable_class:"draggable_header",group_class:"layer_group"+(privateGroup?" private":""),group_div_id:"layer_group_"+obj._data_.id,collapse_link_id:"collapse_link_"+obj._data_.id,collapse_link_href:Regio.formatStr("javascript:window['{0}'].onCollapseLinkClick('{1}')",myId,obj._data_.id),checkbox_onclick:Regio.formatStr("window['{0}'].onLayerGroupChecked(this, '{1}')",myId,obj._data_.id),check_class:"header_check",symbol:obj._data_.symbol});if(!state){fmt.collapse_link_class=cfg.collapseClasses[(formatting_first_group||!cfg.collapseAllButCurrentByDefault)?0:1];fmt.collapse_class="collapse_class_"+obj._data_.id+((formatting_first_group||!cfg.collapseAllButCurrentByDefault)?"":" hidden")}else{var expanded=$(state.expandedGroups).index(obj._data_.id)!=-1;fmt.collapse_link_class=cfg.collapseClasses[expanded?0:1];fmt.collapse_class="collapse_class collapse_class_"+obj._data_.id+(expanded?"":" hidden")}formatting_first_group=false;var t=Regio.formatStr(new String(tmpl),fmt);return t}function onAfterTreeFormatted(treeData,ft_data){$(ft_data).each(function(){checkGroupDisabledState(this.id)});if(cfg.sortable){makeTreeSortable()}$(".collapse_class",div).filter(".hidden").show().hide();events.execUserEvent("privatehide");events.execUserEvent("loaded")}var formatting_first_group=true;function onBeforeTreeFormatted(ft_data){formatting_first_group=true}function checkGroupDisabledState(gid){var group_check=$("#layer_group_"+gid+" .header_check",div);var checks=$("#layer_group_"+gid+" input:checkbox",div).not(".header_check");var enabled_cnt=$(checks).not(":disabled").length;group_check.attr("disabled",enabled_cnt==0?"true":"")}function checkLayerGroupCheck(gid){var group_check=$("#layer_group_"+gid+" .header_check",div);var checks=$("#layer_group_"+gid+" input:checkbox",div).not(".header_check").not(":disabled");var not_checked_cnt=$(checks).not(":checked").length;var checked=(not_checked_cnt==0);if(checks.length>0){group_check.attr("checked",checked?"true":"")}}function toggleGroupCollapsedState(gid,animation){var speed=200;var cl=$(".collapse_class_"+gid,div);var lnk=$("#collapse_link_"+gid,div);var showing=lnk.hasClass(cfg.collapseClasses[1]);if(showing){$(".collapse_class_"+gid,div).removeClass("hidden");cl.animate({opacity:"show",height:"show"},animation?speed:0,function(){$(".collapse_class_"+gid,div).removeClass("hidden");lnk.addClass(cfg.collapseClasses[0]).removeClass(cfg.collapseClasses[1]);if(self.onCollapsedOrExpanded){self.onCollapsedOrExpanded(self)}})}else{cl.animate({opacity:"hide",height:"hide"},animation?speed:0,function(){$(".collapse_class_"+gid,div).addClass("hidden");lnk.removeClass(cfg.collapseClasses[0]).addClass(cfg.collapseClasses[1]);if(self.onCollapsedOrExpanded){self.onCollapsedOrExpanded(self)}})}}this.onCollapseLinkClick=function(gid){toggleGroupCollapsedState(gid,true);saveTreeState(true)};this.checkLayer=function(toggle,lid,gid,modifyCheckbox){if(!gid){gid=findGroupIdByLayerId(lid)}var args={Lid:lid+"",checked:toggle};this.mapcat.broadcast("flash.menu.checkLayer",args);checkLayerGroupCheck(gid);if(modifyCheckbox){$("#layer_check_"+lid,div).attr("checked",toggle)}};this.onLayerGroupChecked=function(checkbox,id){var checks=$("#layer_group_"+id+" input:checkbox",div).not(".header_check").not(":disabled");if(checkbox.checked){checks.not(":checked").click()}else{checks.filter(":checked").click()}};this.getLayers=getLayers;this.getGroups=getGroups;this.getCheckedLayers=getCheckedLayers;this.getExpandedGroups=getExpandedGroups;this.toggleGroup=toggleGroupCollapsedState;this.saveTreeState=saveTreeState;this.sortable=true;this.checkLayer=this.checkLayer;this.showPrivateLayers=function(show){events.execUserEvent(show?"privateshow":"privatehide")};this.setFTGroupsData=function(ft_data){last_ft_data=ft_data;onBeforeTreeFormatted(ft_data);var treeData=convertListDataToTreeData(ft_data);tree.setData(treeData);onAfterTreeFormatted(treeData,ft_data)}};Regio.LonLat=function(e,n){this.e=e;this.n=n};Regio.Session={getID:function(){function _generateSessionID(){var a=new Array("f","e","d","c","b","a","9","8","7","6","5","4","3","2","1","0");var h="";for(var i=0;i<32;i++){h+=a[Math.round(Math.random()*(a.length-1))]}return h}if(!this.sid){this.sid=_generateSessionID()}return this.sid},setID:function(sid){this.sid=sid}};Regio.SymbolList=function(div,cfg,callback){var itemTemplate=Regio.Utils.initTemplate($(div).get(0),"html");$(cfg.symbols).each(function(){var elem=document.createElement("span");elem.innerHTML=Regio.Utils.format(itemTemplate,this);var data=this;$(elem).children().click(function(){if(callback){callback(data,this)}return false});$(div).append($(elem).children())})};if(1){}(function(){var autocomplete=function(input,options){var me=this;var $input=$(input).attr("autocomplete","off");if(options.inputClass){$input.addClass(options.inputClass)}var results=document.createElement("div");var $results=$(results).hide().addClass(options.resultsClass).css("position","absolute");if(options.width>0){$results.css("width",options.width)}$("body").append(results);input.autocompleter=me;var timeout=null;var prev="";var active=-1;var cache={};var keyb=false;var hasFocus=false;var lastKeyPressCode=null;var mouseDownOnSelect=false;var hidingResults=false;var rid=0;function flushCache(){cache={};cache.data={};cache.length=0}flushCache();if(options.data!=null){var sFirstChar="",stMatchSets={},row=[];if(typeof options.uri!="string"){options.cacheLength=1}for(var i=0;i<options.data.length;i++){row=((typeof options.data[i]=="string")?[options.data[i]]:options.data[i]);if(row[0].length>0){sFirstChar=row[0].substring(0,1).toLowerCase();if(!stMatchSets[sFirstChar]){stMatchSets[sFirstChar]=[]}stMatchSets[sFirstChar].push(row)}}for(var k in stMatchSets){options.cacheLength++;addToCache(k,stMatchSets[k])}}$input.keydown(function(e){lastKeyPressCode=e.keyCode;switch(e.keyCode){case 38:e.preventDefault();moveSelect(-1);break;case 40:e.preventDefault();moveSelect(1);break;case 9:case 13:if(selectCurrent()){$input.get(0).blur();e.preventDefault()}break;default:active=-1;if(timeout){clearTimeout(timeout)}timeout=setTimeout(function(){onChange()},options.delay);break}}).focus(function(){hasFocus=true}).blur(function(){hasFocus=false;if(!mouseDownOnSelect){hideResults()}});hideResultsNow();function onChange(){if(lastKeyPressCode==46||(lastKeyPressCode>8&&lastKeyPressCode<32)){return $results.hide()}var v=$input.val();if(v==prev){return}prev=v;if(v.length>=options.minChars){$input.addClass(options.loadingClass);requestData(v)}else{$input.removeClass(options.loadingClass);$results.hide()}}function moveSelect(step){var lis=$("li",results);if(!lis){return}active+=step;if(active<0){active=0}else{if(active>=lis.size()){active=lis.size()-1}}lis.removeClass("ac_over");$(lis[active]).addClass("ac_over")}function selectCurrent(){var li=$("li.ac_over",results)[0];if(!li){var $li=$("li",results);if(options.selectOnly){if($li.length==1){li=$li[0]}}else{if(options.selectFirst){li=$li[0]}}}if(li){selectItem(li);return true}else{return false}}function selectItem(li){if(!li){li=document.createElement("li");li.extra=[];li.selectValue=""}var v=$.trim(li.selectValue?li.selectValue:li.innerHTML);input.lastSelected=v;prev=v;$results.html("");$input.val(v);hideResultsNow();if(options.onItemSelect){setTimeout(function(){options.onItemSelect(li)},1)}}function createSelection(start,end){var field=$input.get(0);if(field.createTextRange){var selRange=field.createTextRange();selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select()}else{if(field.setSelectionRange){field.setSelectionRange(start,end)}else{if(field.selectionStart){field.selectionStart=start;field.selectionEnd=end}}}field.focus()}function autoFill(sValue){if(lastKeyPressCode!=8){$input.val($input.val()+sValue.substring(prev.length));createSelection(prev.length,sValue.length)}}function showResults(){var pos=findPos(input);var iWidth=(options.width>0)?options.width:$input.width();$results.css({width:parseInt(iWidth)+"px",top:(pos.y+input.offsetHeight)+"px",left:pos.x+"px"}).show()}function hideResults(){if(timeout){clearTimeout(timeout)}timeout=setTimeout(hideResultsNow,200)}function hideResultsNow(){if(hidingResults){return}hidingResults=true;if(timeout){clearTimeout(timeout)}var v=$input.removeClass(options.loadingClass).val();if($results.is(":visible")){$results.hide()}if(options.mustMatch){if(!input.lastSelected||input.lastSelected!=v){selectItem(null)}}hidingResults=false}function receiveData(q,data){if(data){$input.removeClass(options.loadingClass);results.innerHTML="";if(!hasFocus||data.length==0){return hideResultsNow()}if($.browser.msie&&!options.noIFrame){$results.append(document.createElement("iframe"))}results.appendChild(dataToDom(data));if(options.autoFill&&($input.val().toLowerCase()==q.toLowerCase())){autoFill(data[0][0])}showResults()}else{hideResultsNow()}}function parseData(data){if(!data){return null}if(options.parse){return options.parse(data)}var parsed=[];var rows=data.split(options.lineSeparator);for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){parsed[parsed.length]=row.split(options.cellSeparator)}}return parsed}function dataToDom(data){var ul=document.createElement("ul");var num=data.length;if((options.maxItemsToShow>0)&&(options.maxItemsToShow<num)){num=options.maxItemsToShow}for(var i=0;i<num;i++){var row=data[i];if(!row){continue}var li=document.createElement("li");if(options.formatItem){li.innerHTML=options.formatItem(row,i,num);li.selectValue=row[0]}else{li.innerHTML=row[0];li.selectValue=row[0]}var extra=null;if(row.length>1){extra=[];for(var j=1;j<row.length;j++){extra[extra.length]=row[j]}}li.extra=extra;ul.appendChild(li);$(li).hover(function(){$("li",ul).removeClass("ac_over");$(this).addClass("ac_over");active=$("li",ul).indexOf($(this).get(0))},function(){$(this).removeClass("ac_over")}).click(function(e){e.preventDefault();e.stopPropagation();selectItem(this)})}$(ul).mousedown(function(){mouseDownOnSelect=true}).mouseup(function(){mouseDownOnSelect=false});return ul}function requestData(q){if(!options.matchCase){q=q.toLowerCase()}var data=options.cacheLength?loadFromCache(q):null;if(data){receiveData(q,data)}else{if((typeof options.uri=="string")&&(options.uri.length>0)){var success=function(data){data=parseData(data);addToCache(q,data);receiveData(q,data)};$.ajax(jQuery.extend({url:makeUrl(q),type:"GET",success:success},options))}else{$input.removeClass(options.loadingClass)}}}function makeUrl(q){if(options.beforeFormatURL){options.beforeFormatURL(options)}var url=Regio.Utils.format(options.uri,{query:encodeURIComponent(q),rid:rid++});for(var i in options.extraParams){url+="&"+i+"="+encodeURIComponent(options.extraParams[i])}return url}function loadFromCache(q){if(!q){return null}if(cache.data[q]){return cache.data[q]}if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var qs=q.substr(0,i);var c=cache.data[qs];if(c){var csub=[];for(var j=0;j<c.length;j++){var x=c[j];var x0=x[0];if(matchSubset(x0,q)){csub[csub.length]=x}}return csub}}}return null}function matchSubset(s,sub){if(!options.matchCase){s=s.toLowerCase()}var i=s.indexOf(sub);if(i==-1){return false}return i==0||options.matchContains}this.flushCache=function(){flushCache()};this.hideResultsNow=function(){hideResultsNow()};this.setExtraParams=function(p){options.extraParams=p};function addToCache(q,data){if(!data||!q||!options.cacheLength){return}if(!cache.length||cache.length>options.cacheLength){flushCache();cache.length++}else{if(!cache[q]){cache.length++}}cache.data[q]=data}function findPos(obj){var curleft=obj.offsetLeft||0;var curtop=obj.offsetTop||0;while(obj=obj.offsetParent){curleft+=obj.offsetLeft;curtop+=obj.offsetTop}return{x:curleft,y:curtop}}};Regio.Autocomplete=function(div,uri,options,data){options=options||{};options.uri=uri;options.data=((typeof data=="object")&&(data.constructor==Array))?data:null;options=$.extend({inputClass:"ac_input",resultsClass:"ac_results",lineSeparator:"\n",cellSeparator:"|",minChars:1,delay:400,matchCase:0,matchSubset:false,matchContains:false,cacheLength:25,mustMatch:0,extraParams:{},loadingClass:"ac_loading",selectFirst:false,selectOnly:false,maxItemsToShow:-1,autoFill:false,width:0},options);options.width=parseInt(options.width,10);$(div).each(function(){var input=this;new autocomplete(input,options)})};jQuery.fn.indexOf=function(e){for(var i=0;i<this.length;i++){if(this[i]==e){return i}}return-1}})();Regio.TreeView2=function(div,cfg){div=Regio.Utils.getElement(div);var me=this;var data={};var drawingFirstBranch=false;Regio.Utils.applyDefaults(cfg,{treeStartsWithHeader:false,treeTemplate:'<div> <div>{a} {b}</div> <div class="childs">  <div>{a} {b}</div> </div></div>',branchFirstItemIsHeaderDescriptor:false});parseTemplate();function parseTemplate(){var tmp=document.createElement("div");tmp.innerHTML=cfg.treeTemplate;var childsElems=Regio.Utils.getElementsByClassName(tmp,"childs");if(!childsElems||!childsElems.length||(childsElems.length!=1)){throw new Error('TreeView2, no or too many "childs" classes in treeTemplate')}cfg.childTemplate=(childsElems[0].innerHTML+"").replace("%7B","{").replace("%7D","}");childsElems[0].innerHTML="";cfg.recordTemplate=(tmp.innerHTML).replace("%7B","{").replace("%7D","}");tmp=null}function drawTree(arr){div.innerHTML="";drawingFirstBranch=true;drawBranch(div,arr,[],cfg)}function drawBranch(parentElement,arr,position,params){var childsElem;if(!Regio.Utils.isArray(arr)){throw new Error("TreeView2, branch must be an array!")}if((position.length>0)||(params&&params.treeStartsWithHeader)){var obj=me.getHeaderDescriptor(arr,position);if(cfg.branchFirstItemIsHeaderDescriptor){arr=arr.slice(1)}childsElem=appendTemplateAndReturnChildsElem(parentElement,cfg.recordTemplate,obj,"beforeDrawHeader",position)}else{childsElem=parentElement}for(var i=0;i<arr.length;i++){var child=arr[i];if(Regio.Utils.isArray(child)){drawBranch(childsElem,child,position.concat([i]));drawingFirstBranch=false}else{drawNode(childsElem,child,position.concat([i]))}}}function drawNode(parentElement,obj,position){appendTemplateAndReturnChildsElem(parentElement,cfg.childTemplate,obj,"beforeDrawNode",position)}function appendTemplateAndReturnChildsElem(parentElement,template,obj,callbackName,position){template=Regio.Utils.formatEx(template,obj);var tmp=document.createElement("div");tmp.innerHTML=template;var childsElems=Regio.Utils.getElementsByClassName(tmp,"childs");if(me[callbackName]){me[callbackName].call(me,obj,tmp.childNodes,drawingFirstBranch,position)}while(tmp.childNodes.length>0){parentElement.appendChild(tmp.childNodes[0])}tmp=null;return(childsElems&&childsElems.length>0)?childsElems[0]:false}this.getHeaderDescriptor=function(branchArr,pos){if(cfg.branchFirstItemIsHeaderDescriptor){if(branchArr.length<1){throw new Error("TreeView2, in branch array, first item is describing header and must exists!")}return branchArr[0]}else{return{}}};this.setData=function(obj){drawTree(obj)};return this};Regio.Preview=function(div,userConf){userConf=userConf||{};var cfg=$.extend({},Regio.Preview.defaultConf,userConf);if(!cfg.src){throw new Error("Wrong src passed to Regio.SmallFTPreview constructor")}this.sft=new MapCat.Component(div,cfg);var me=this;this.listeners=this.sft.listeners;function getDrawFunctionName(type){switch(type){case 1:case"point":return"addPoint";break;case 2:case"line":return"addLine";break;case 3:case"area":return"addPolygon";break}}function drawObject(type,id,points,style){var obj={objectId:id,points:points,color:style.color,colors:style.colors,widths:style.widths,alpha:style.alpha,symbolId:style.symbol,lineColor:style.lineColor,lineWidth:style.lineWidth,lineAlpha:style.lineAlpha,fillColor:style.fillColor,fillAlpha:style.fillAlpha,center:true};me.sft.ready(function(){me.listeners.broadcast(getDrawFunctionName(type),obj)})}this.drawPoint=function(symbol,color,alpha){drawObject(1,"preview",{x:0,y:0},{color:color,alpha:alpha,symbol:symbol})};this.drawLine=function(width,color,alpha){this.drawMultiLine([{width:width,color:color}],alpha)};this.drawMultiLine=function(lines,alpha){var colors=[];var widths=[];for(var i in lines){colors.push(fixColor(lines[i].color));widths.push(lines[i].width)}drawObject(2,"preview",[{x:-12,y:8},{x:12,y:-8}],{colors:colors,alpha:alpha,widths:widths})};this.drawPolygon=function(lineWidth,lineColor,lineAlpha,fillColor,fillAlpha){drawObject(3,"preview",[{x:-12,y:8},{x:10,y:5},{x:12,y:-8},{x:-10,y:-5}],{lineColor:fixColor(lineColor),lineWidth:lineWidth,lineAlpha:lineAlpha,fillColor:fixColor(fillColor),fillAlpha:fillAlpha})};function fixColor(color){if(color){color=color.charAt(0)=="#"?color.substr(1,color.length):color}return color}return this};Regio.Preview.defaultConf={width:"30px",height:"24px",vars:"",wmode:"window"};Regio.SearchList=function(div,cfg){var listeners=new MapCat.Listeners();var div=Regio.Utils.getElement(div);if(!div){throw new Error("Regio.SearchList, provided DIV is incorrect!")}var submitting=false;var lastAjax=null,lastQuery,lastProvider;Regio.Utils.applyDefaults(cfg,{rowsPerPage:20,tabFilter:function(){}});if(!cfg.rowTemplate){cfg.rowTemplate=Regio.Utils.initTemplate(div,"html")}if(typeof(cfg.providers)!="object"){throw new Error("Regio.SearchList, no providers defined!")}var list=new Regio.ListView(div,cfg);list.beforeDrawRow=function(obj,childNodes,i,cnt){listeners.broadcast("row",obj,childNodes,i,cnt)};list.beforeClear=function(){listeners.broadcast("clear")};var paging={curPage:0,pageCount:0,filter:function(obj,cnt,num){return(num>this.curPage*cfg.rowsPerPage)&&(num<=(this.curPage+1)*cfg.rowsPerPage)},setPageCount:function(cnt){if(this.pageCount!=cnt){this.pageCount=cnt;if(this.curPage>cnt-1){this.curPage=cnt-1}if(this.curPage<0){this.curPage=0}listeners.broadcast("page",this.pageCount==0?0:this.curPage+1,this.pageCount)}},resetToRowsCount:function(cnt){var newPageCnt=Math.ceil(cnt/cfg.rowsPerPage);if(this.pageCount!=newPageCnt){this.setPageCount(newPageCnt);this.curPage=0}},setPage:function(p){if((this.curPage!=p)&&(p>=0)&&(p<this.pageCount)){this.curPage=p;list.refresh();listeners.broadcast("page",this.curPage+1,this.pageCount)}},nextPage:function(){this.setPage(this.curPage+1)},prevPage:function(){this.setPage(this.curPage-1)}};paging.setPageCount(0);var tabs={curTab:0,filter:function(obj,cnt){var res=cfg.tabFilter(this.curTab,obj,cnt);if(typeof(res)=="undefined"){res=true}return res},setTab:function(num){if(this.curTab!=num){this.curTab=num;paging.setPage(0);list.refresh();listeners.broadcast("tab",this.curTab)}}};var filter={num:0,start:function(){this.num=0},filter:function(obj,cnt){var tabAccepts=tabs.filter(obj,cnt);if(tabAccepts){this.num++}obj.num=this.num;return paging.filter(obj,cnt,this.num)&&tabAccepts},finish:function(){paging.resetToRowsCount(this.num)}};list.setFilter(filter);function showMessage(msgType,searchType,desc){listeners.broadcast("message",msgType,searchType,desc)}function setListData(arr){list.setData(arr);listeners.broadcast("items",arr);if(arr.length==0){showMessage("empty")}}this.submit=function(query,type){var q=listeners.broadcast("query",query,type);if(q){query=q}if(submitting&&lastAjax){lastAjax.abort()}submitting=true;clear();if(!type){for(var t in cfg.providers){type=t;break}}lastProvider=type;lastQuery=query;function parseData(arr){var old=list.beforeDrawRow;if(window.jQuery&&cfg.animation){list.beforeDrawRow=function(obj,nodes,i,cnt){if(old){old.apply(list,arguments)}if((nodes.length>0)&&(nodes[0].tagName)){var jj=jQuery(nodes[0]);jj.hide(1);window.setTimeout(function(){jj.fadeIn(300)},cnt*100)}}}setListData(arr);list.beforeDrawRow=old}showMessage("wait",type);var provider=cfg.providers[type];if(typeof(provider)=="function"||!jQuery){var onSuccess=function(data){parseData(data)};var onError=function(txt){showMessage("error",type,txt)};provider(query,listeners,onSuccess,onError)}else{var opts={url:Regio.Utils.format(provider.uri,{query:(typeof(query)=="object")?encodeURIComponent(query.query):encodeURIComponent(query)}),error:function(req,desc){showMessage("error",type,desc)},success:function(xml){parseData(provider.parse(xml))}};listeners.broadcast("submit",opts);lastAjax=jQuery.ajax(jQuery.extend(provider,opts))}};this.queryRowCountInTab=function(tab){var tabsFilter={possibleRows:0,start:function(){this.possibleRows=0},filter:function(obj,num){var tabAccepts=cfg.tabFilter(tab,obj,num);if(tabAccepts||(typeof(tabAccepts)=="undefined")){this.possibleRows++}return tabAccepts},finish:function(){}};list.execute(tabsFilter,function(){});return tabsFilter.possibleRows};function clear(){lastQuery=undefined;lastProvider=undefined;list.clear();listeners.broadcast("items",[]);showMessage("clear")}this.clear=function(){clear()};this.refresh=function(tab){if((typeof(tab)=="undefined")||(tab==tabs.curTab)){list.refresh()}};this.nextPage=function(){paging.nextPage()};this.prevPage=function(){paging.prevPage()};this.setTab=function(){return tabs.setTab.apply(tabs,arguments)};this.getDisplayedData=function(){var rows=[];list.execute("current",function(row){rows.push(row)});return rows};this.getCurPage=function(){return paging.curPage>paging.pageCount-1?paging.pageCount-1:paging.curPage+1};this.getPageCount=function(){return paging.pageCount};this.getCurTab=function(){return tabs.curTab};this.getState=function(){var state={data:list.getData(),tab:tabs.curTab,page:paging.curPage,lastQuery:lastQuery,lastProvider:lastProvider};listeners.call("saveState",state);return state};this.setState=function(state){if(state.data.length==0){clear()}else{setListData(state.data)}tabs.setTab(state.tab);paging.setPage(state.page);lastQuery=state.lastQuery;lastProvider=state.lastProvider;listeners.broadcast("restoreState",state)};this.listeners=listeners};Regio.SearchList.createFromMarkup=function(div,cfg){if(!div){div=document}var j=$(".search_container",div);if(j.length<=0){throw new Error('createSearchFromMarkup, element with class = "search_container" must exists within provided div')}var searchDiv=j[0];var search=new Regio.SearchList(searchDiv,cfg);var lastClickedRowData;search.listeners.add("row",function(arr,childs){$(".search_clickable_title",childs).click(function(){search.listeners.broadcast("rowClick",arr,childs);return false})});search.listeners.add("rowClick",function(arr,childs){lastClickedRowData=arr});search.listeners.add("saveState",function(state){state.lastClickedRowData=lastClickedRowData}).add("restoreState",function(state){$(".search_form input[name=q]",div).val(typeof(state.lastQuery)=="object"?state.lastQuery.query:state.lastQuery);lastClickedRowData=state.lastClickedRowData}).add("query",function(q,type){$(".search_form input[name=q]",div).val(typeof(q)=="object"?q.query:q)}).add("message",function(type){$(".search_message",div).hide();$(".search_message_"+type,div).show()}).add("items",function(arr){lastClickedRowData=undefined;$(".search_message",div).hide();$(".search_results_count",div).text(arr.length)}).add("page",function(cur,total){$(".search_current_page",div).text(cur);$(".search_page_count",div).text(total);$(".search_prev_page",div)[cur>1?"show":"hide"]();$(".search_next_page",div)[cur<total?"show":"hide"]()});search.listeners.broadcast("page",0,0);if(!cfg.noSubmitBinding){$(".search_form",div).submit(function(e){if(!e.cancel){search.submit(this.q.value,e.providerName)}return false})}$(".search_form",div).bind("reset",function(){search.clear();return true});$(".search_clear",div).click(function(){search.clear();return false});$(".search_prev_page",div).click(function(){search.prevPage();return false});$(".search_next_page",div).click(function(){search.nextPage();return false});if(cfg.autocomplete){if(!Regio.Autocomplete){throw"Regio.SearchList.Extensions, for autocomplete to work, you have to include Regio.Autocomplete"}if(typeof(cfg.autocomplete)=="boolean"){cfg.autocomplete={}}Regio.Utils.applyDefaults(cfg.autocomplete,{uri:"geoCodeBridge.php?q={query}&matchOptions=AUTOCOMPLETE&max=10&output=ac"});var $input=$(".search_form input[name=q]",div);Regio.Autocomplete($input,cfg.autocomplete.uri,jQuery.extend(cfg.autocomplete,{onItemSelect:function(){$(".search_form",div).submit()}}));search.listeners.add("submit",function(){if(($input.length>0)&&$input[0].autocompleter&&$input[0].autocompleter.hideResultsNow){$input[0].autocompleter.hideResultsNow();$input[0].value=$input[0].value}})}return search};Regio.SearchList.createAutocompleteRegioJGCRemote=function(cfg){if(!cfg){cfg={}}if(!cfg.uri){cfg.uri="http://demo.regio.ee/jsonp/geoCodeBridge.php?user={user}&q={query}&matchOptions=AUTOCOMPLETE&max=10"}return{uri:Regio.Utils.format(cfg.uri,cfg),dataType:"jsonp",parse:function(data){var res=[];for(var i in data){res.push([data[i].address])}return res}}};Regio.Controls={};Regio.FeaturesRenderer=function(){this.listeners=new MapCat.Listeners();this.layers={}};Regio.FeaturesRenderer.prototype={createLayer:function(layer,cfg){cfg=cfg||{};if(cfg.group){layer.setGroup(cfg.group)}layer.cfg=cfg;this.listeners.broadcast("layercreated",layer)},registerLayer:function(layer){var old=this.layers[layer.id];if(old){old.remove()}this.layers[layer.id]=layer},removeLayer:function(layer){delete this.layers[layer.id];this.listeners.broadcast("layerremoved",layer)},clear:function(){for(var i in this.layers){this.layers[i].remove()}},setEditingFeature:function(feature){},stopEditing:function(){this.listeners.broadcast("endEditingFeature",this.getEditingFeature())},getEditingFeature:function(){},getVisibleLayers:function(){res=[];for(var i in this.layers){var layer=this.layers[i];if(layer.getVisibility()==true){res.push(layer)}}return res}};Regio.Controls.Digitizing={};(function(){Regio.Controls.Digitizing.createFromMarkup=function(parent,layer){var featureUserStyles={};var me=this;var listeners=this.listeners=new MapCat.Listeners();var changingTemplate=false;var restarting=false;setEditingElements(false);fillTemplateWithDefaults();showDefaultFeaturePage();$(".only_visible_when_digitizing",parent).hide();layer.renderer.listeners.add("beginEditingFeature",function(feature){$(".only_visible_when_digitizing",parent).show();initTitle();setEditingElements(true);showFeaturePage(feature.type);$(".create_feature[feature="+feature.type.toLowerCase()+"]",parent).addClass("active");listeners.broadcast("beginEditingFeature",feature)}).add("endEditingFeature",function(feature){if(!restarting){$(".only_visible_when_digitizing",parent).hide();setEditingElements(false)}doneTitle();$(".create_feature",parent).removeClass("active");listeners.broadcast("endEditingFeature",feature);if(!feature.isInited()){feature.remove()}if(!restarting){showDefaultFeaturePage()}});$(".create_feature, .create_feature *",parent).click(function(){var type=$(this).attr("feature");if(type){restarting=true;digitizeFeature(type);restarting=false;return false}});$(".feature_style",parent).each(function(){var $e=$(this);$("click,change".split(",")).each(function(){$e.bind(this,function(){if(!changingTemplate){var f=$e.attr("feature").toLowerCase(),v=$e.attr("styleValue"),n=$e.attr("styleName");if(v){var o={};o[n]=v;me.addFeatureStyle(f,o)}me.updateFeature(f,$e[0])}return false})})});$(".digitizing_stop",parent).click(function(){var f=layer.renderer.getEditingFeature();if(f){f.setEditable(false)}return false});$(".digitizing_stop_and_restart",parent).click(function(){var f=layer.renderer.getEditingFeature();if(f){restarting=true;f.setEditable(false);restarting=false;digitizeFeature(f.type)}return false});$(".digitizing_delete",parent).click(function(){var f=layer.renderer.getEditingFeature();if(f){f.remove()}return false});$(".digitizing_delete_and_restart",parent).click(function(){var f=layer.renderer.getEditingFeature();if(f){restarting=true;f.remove();restarting=false;digitizeFeature(f.type)}return false});$(".digitizing_remove_all_features",parent).click(function(){layer.clear();return false});$(".feature_title",parent).change(function(){var f=layer.renderer.getEditingFeature();if(f){setFeatureTitle(f,$(this).val())}});function setFeatureTitle(f,t){f.setTitle(t?t:($(".feature_title",parent).attr("defaultTitle")||"Unnamed"))}function initTitle(){var f=layer.renderer.getEditingFeature();if(f){if(typeof f.title=="undefined"){setFeatureTitle(f)}$(".feature_title",parent).val(f.title)}}function doneTitle(){$(".feature_title",parent).val("")}function fillTemplateWithDefaults(){$(".feature_style[setToDefault]",parent).each(function(){var $this=$(this);var style=addAliaces(Regio.Feature.DefaultStyle);$this.val(style[$this.attr("styleName")])})}function showDefaultFeaturePage(){$(".default_feature_page",parent).each(function(){var t=$(this).attr("feature");showFeaturePage(t);digitizeFeature(t)})}function showFeaturePage(type){$(".only_visible_for_feature_page[feature!="+type.toLowerCase()+"]",parent).hide();$(".only_visible_for_feature_page[feature="+type.toLowerCase()+"]",parent).show();notifyStyleChange(type,collectFeatureStyle(type))}function setEditingElements(enabled){$(".digitizing_stop, .digitizing_delete, .digitizing_delete_and_restart, .digitizing_stop_and_restart, .feature_title",parent)[enabled?"removeAttr":"attr"]("disabled","true")[enabled?"removeClass":"addClass"]("disabled")}function getCamelizedTypeName(type){if(!type){return""}type=(""+type).toLowerCase();type=type.substr(0,1).toUpperCase()+type.substr(1);return type}function digitizeFeature(type){var methodName="create"+getCamelizedTypeName(type);if(layer[methodName]){var feature=layer[methodName]("digitize",collectFeatureStyle(type));feature.listeners.add("click",function(){feature.setEditable(true)});feature.listeners.add("titlechanged",function(){if(feature==layer.renderer.getEditingFeature()){$(".feature_title",parent).val(feature.title)}});return true}else{return false}}function collectFeatureStyle(type,priorityElem){var style=Regio.Feature.DefaultStyle;if(featureUserStyles[type]){style=jQuery.extend({},style,featureUserStyles[type])}$priorityElem=$(priorityElem);$('.feature_style[feature="'+type+'"]',parent).not($priorityElem).add($priorityElem).each(function(){var $elem=$(this);var s=$elem.attr("styleName");if(typeof this.value!="undefined"){var v=$elem.val();style[s]=v}});return style}function addAliaces(style){var style=jQuery.extend({},style);for(var i in style){var p=i.indexOf("Opacity");if(p>=0){var v=100-style[i];if(v<0){v=0}if(v>100){v=100}var key=i.substring(0,p)+"Transparency";if(!style[key]){style[key]=v}}var p=i.indexOf("Transparency");if(p>=0){var v=100-style[i];if(v<0){v=0}if(v>100){v=100}var key=i.substring(0,p)+"Opacity";style[key]=v}}return style}function notifyStyleChange(type,style,excludeElems){function removeEqual(a,b){var r=true,cnt1=0,cnt2=0;for(var i in a){if(a[i]==b[i]){r=false;delete a[i];delete b[i]}cnt1++}for(var i in b){if(a[i]==b[i]){r=false;delete a[i];delete b[i]}cnt2++}if(r){r=cnt1==cnt2}return r}if(!arguments.callee.prev){arguments.callee.prev={}}$excludeElems=$(excludeElems);changingTemplate=true;var prev=arguments.callee.prev;var p=prev[type];if(!p){p={}}var featureElems=$(".feature_style[feature="+type+"]").not($excludeElems);var styleChanges=jQuery.extend({},style);var equal=removeEqual(p,styleChanges);if(!equal){for(var i in p){$(featureElems).filter("[styleName="+i+"][styleValue="+p[i]+"]").removeClass("active")}listeners.broadcast("stylechange",type,style)}for(var i in styleChanges){var styleElems=$(featureElems).filter("[styleName="+i+"]");$(styleElems).filter("[styleValue="+styleChanges[i]+"]").addClass("active");$(styleElems).filter(":not([styleValue])").val(styleChanges[i]).change()}changingTemplate=false;arguments.callee.prev[type]=jQuery.extend({},style)}updateFeature.updateOncePer=250;function updateFeature(ftype,calledByElem){var func=arguments.callee;var lastTime=func.last,curTime=Number(new Date());clearTimeout(func.timer);if(curTime-lastTime<func.updateOncePer){var args=arguments;func.timer=setTimeout(function(){func.apply(this,[ftype])},func.updateOncePer/4);return}arguments.callee.last=curTime;var f=layer.renderer.getEditingFeature();if(f){if(f.type==ftype){var s=collectFeatureStyle(ftype,calledByElem);var sWithAliaces=addAliaces(s);f.setStyle(sWithAliaces);f.draw();notifyStyleChange(ftype,s,calledByElem)}}}this.digitizeFeature=digitizeFeature;this.addFeatureStyle=function(ftype,userStyle){featureUserStyles[ftype]=jQuery.extend({},featureUserStyles[ftype],userStyle);updateFeature(ftype)};this.updateFeature=updateFeature}})();Regio.Controls.LayersTree=function(div,adapter,cfg){div=Regio.Utils.getElement(div);cfg=cfg||{};var data=[];var lastGroup;Regio.Utils.applyDefaults(cfg,{sortable:true,collapseAllButFirstByDefault:true,collapseClasses:["collapser","expander"]});var tree=new Regio.TreeView2(div,{treeTemplate:cfg.treeTemplate||Regio.Utils.initTemplate(div,"html"),branchFirstItemIsHeaderDescriptor:true,treeStartsWithHeader:false});tree.beforeDrawHeader=function(arr,childs,firstBranch){lastGroup={group:arr,$childs:$(childs)};var $subs=$(".childs",childs);$(".collapse_branch",childs).click(function(){var closing=$subs.is(":visible");$subs[closing?"slideUp":"slideDown"](150);$(this)[closing?"addClass":"removeClass"](cfg.collapseClasses[1])[closing?"removeClass":"addClass"](cfg.collapseClasses[0]);return false});if(!firstBranch&&cfg.collapseAllButFirstByDefault){$subs.hide()}$(":checkbox:first",childs).click(function(){checkGroup(arr,$(this).attr("checked"))})};tree.beforeDrawNode=function(layer,childs){$(layer).data("childs",$(childs)).data("groupData",lastGroup);$(":checkbox",childs)[layer.getVisibility()?"attr":"removeAttr"]("checked","true")[layer.disabled?"attr":"removeAttr"]("disabled","true").click(function(){var v=$(this).attr("checked");layer.setVisibility(v);recalcGroup($(layer).data("groupData"))});recalcGroup(lastGroup)};adapter.listeners.add("layercreated",function(layer){registerLayer(layer);layer.listeners.add("visibilitychanged",function(visible){$(":checkbox",$(layer).data("childs"))[visible?"attr":"removeAttr"]("checked","true")})}).add("layerdisabled",function(layer){var $c=$(layer).data("childs");if($c){$c.addClass("disabled");$("input",$c).attr("disabled","true");recalcGroup($(layer).data("groupData"))}}).add("layerenabled",function(layer){var $c=$(layer).data("childs");if($c){$c.removeClass("disabled");$("input",$c).removeAttr("disabled");if($(":checkbox",$c).attr("checked")){layer.setVisibility(true)}recalcGroup($(layer).data("groupData"))}});function checkGroup(group,visible){for(var i=0;i<data.length;i++){var b=data[i];if(b[0].id==group.id){for(var j=1;j<b.length;j++){b[j].setVisibility(visible)}}}}function recalcGroup(groupData){var group=groupData.group;var allVisible=true;var allDisabled=true;for(var i=0;i<data.length;i++){var b=data[i];if(b[0].id==group.id){for(var j=1;j<b.length;j++){if(!b[j].getVisibility()){allVisible=false}if(!b[j].disabled){allDisabled=false}if(!allVisible&&!allDisabled){break}}}}var $c=groupData.$childs;$(":checkbox:first",$c)[allVisible?"attr":"removeAttr"]("checked","true")[allDisabled?"attr":"removeAttr"]("disabled","true")}function sortable(action){if(cfg.sortable){if(action=="destroy"){$(".childs",div).sortable("destroy");$(div).sortable("destroy")}else{$(div).sortable({axis:"y",scroll:true,opacity:0.4})}}}var redraw=Regio.Utils.createDelayedFunction(function(){sortable("destroy");tree.setData(data);sortable()},150,"FIRST_WAIT");function registerLayer(layer){var g=layer.getGroup();if(!g){g=new Regio.LayersGroup("Ungrouped","_ungrouped")}var set=false;for(var i=0;i<data.length;i++){if(data[i][0].id==g.id){data[i].push(layer);set=true}}if(!set){data.push([g]);data[data.length-1].push(layer)}redraw()}};Regio.Feature=function(type,layer,style){var me=this,listeners=new MapCat.Listeners();var hidden=false;style=style||{};draw=function(){};me.type=type;me.layer=layer;me.id=style.id||Regio.Utils.createUniqueId("o_");me.listeners=listeners;this.remove=function(){layer.removeFeature(me)};this.setCoords=function(coords){me.coords=coords;listeners.broadcast("coordschanged")};this.getCoords=function(){return me.coords};this.setStyle=function(style){layer.setFeatureStyle(me,style)};this.getStyle=function(){return layer.getFeatureStyle(me)};this.setTitle=function(title){this.title=title;listeners.broadcast("titlechanged")};this.getTitle=function(){return this.title};this.setEditable=function(edit){if(edit){layer.renderer.setEditingFeature(me)}else{layer.renderer.stopEditing()}};this.draw=function(){if(this.isInited()){draw(me);listeners.broadcast("drawn")}};this.erase=function(){};this.hide=function(){hidden=true;listeners.broadcast("visibilitychanged",!hidden);me.erase()};this.show=function(){hidden=false;listeners.broadcast("visibilitychanged",!hidden);me.draw()};this.isVisible=function(){return!hidden};this.isInited=function(){return(typeof(me.coords)!="undefined")};this.setStyle(style);layer.registerFeature(me)};Regio.Feature.DefaultStyle={strokeColor:"FF0000",strokeWidth:5,strokeOpacity:45,fillColor:"000000",fillOpacity:45,pointIcon:"a",pointColor:"00FF00",pointOpacity:100};Regio.Feature.getCompoundStyle=function(userStyle){userStyle=userStyle||{};function oneOf(){for(var i=0;i<arguments.length;i++){if(typeof(arguments[i])!="undefined"){return arguments[i]}}}var s=jQuery.extend({},Regio.Feature.DefaultStyle,userStyle);s.pointColor=oneOf(s.pointColor,s.color,s.strokeColor);s.pointOpacity=oneOf(s.pointOpacity,s.alpha,s.strokeOpacity);return s};if(1){}(function(){Regio.Layer=function(renderer,lid){var lid=lid||Regio.Utils.createUniqueId("l_");this.id=lid;this.renderer=renderer;this.features={};this.listeners=new MapCat.Listeners();this.visible=true;renderer.registerLayer(this)};Regio.Layer.prototype={createPoint:function(coords,userStyle){if((coords!="digitize")&&(!coords||!coords.e||!coords.n)){throw"No or bad coords given for createPoint"}},createLine:function(points,userStyle){if((points!="digitize")&&(!points||!Regio.Utils.isArray(points))){throw"No or bad points given for createLine"}},createPolygon:function(points,userStyle){if((points!="digitize")&&(!points||!Regio.Utils.isArray(points))){throw"No or bad points given for createPolygon"}},createObjectFromWKT:function(wkt,userStyle,cfg){cfg=cfg||{};if(wkt.match(/^point/i)){var r=/\(([\d\.\-]+) ([\d\.\-]+)\)/.exec(wkt);var x=r[1],y=r[2];if(cfg.srsFrom&&cfg.srsTo){var p=Regio.Coords.Convert(x,y,cfg.srsFrom,cfg.srsTo);x=p.x;y=p.y}this.createPoint({e:x,n:y},userStyle)}},getFeatureStyle:function(feature){return feature.style},setFeatureStyle:function(feature,style){style=style||{};feature.style=jQuery.extend({},Regio.Feature.DefaultStyle,feature.style,style);feature.listeners.broadcast("stylechanged")},removeFeature:function(feature){delete this.features[feature.id];feature.listeners.broadcast("removed");this.listeners.broadcast("featureremoved",feature)},registerFeature:function(feature){var old=this.features[feature.id];if(old){old.remove()}this.features[feature.id]=feature;this.listeners.broadcast("featurecreated",feature)},setEditable:function(feature,edit){},clear:function(){for(var i in this.features){this.removeFeature(this.features[i])}},remove:function(){this.renderer.removeLayer(this)},getState:function(){var arr=[];for(var i in this.features){with(this.features[i]){arr.push({type:type,title:getTitle(),coords:getCoords(),style:getStyle(),visible:isVisible()})}}return arr},setState:function(state){this.clear();for(var i=0;i<state.length;i++){var type=state[i].type;type=(""+type).toLowerCase();type=type.substr(0,1).toUpperCase()+type.substr(1);var method="create"+type;var feature=this[method](state[i].coords,state[i].style);feature.setTitle(state[i].title);if(!state[i].visible){feature.hide()}}},setGroup:function(group){this.group=group},getGroup:function(){return this.group},setVisibility:function(visible){if(this.visible!=visible){this.visible=visible;this.listeners.broadcast("visibilitychanged",visible)}},getVisibility:function(){return this.visible}}})();(function(){Regio.LayersGroup=function(name,id){var id=id||Regio.Utils.createUniqueId("g_");this.id=id;this.name=name}})();(function(){var GroupAdapter=function(rec){this.id=rec.id;this.name=rec.name};var LayerAdapter=function(renderer,rec,group){var layer=new Regio.Layer(renderer,rec.id);layer.cfg=rec;layer.setGroup(group);layer.setVisibility(rec.checked);layer.disabled=!rec.enabled;if(!rec.enabled){layer.listeners.broadcast("layerdisabled",layer)}layer.listeners.add("visibilitychanged",function(value){renderer.mapcat.broadcast("layers.setVisibility",layer.id,value)});renderer.mapcat.addCallback("layer.statusChanged",function(groupId,layerId,status){if(layerId==layer.id){layer.disabled=!status;renderer.listeners.broadcast(status?"layerenabled":"layerdisabled",layer)}});return layer};Regio.Controls.LayersTree.FlashTileAdapter=function(mapcat){var listeners=this.listeners=new MapCat.Listeners();this.mapcat=mapcat;var me=this;var layers=[];mapcat.addCallback("mapcat.layersData.loaded",function(list){for(var g in list){var groupRec=list[g];var group=new Regio.LayersGroup(groupRec.name,groupRec.id);for(var l in groupRec.layers){var layerRec=groupRec.layers[l];var layer=new LayerAdapter(me,layerRec,group);listeners.broadcast("layercreated",layer)}}});this.registerLayer=function(layer){layers.push(layer)}}})();if(1){}(function(){Regio.Controls.FeatureList=function(div,layer,cfg){cfg=cfg||{};div=Regio.Utils.getElement(div);var list=new Regio.Collection(div,{rowTemplate:Regio.Utils.initTemplate(div,"html")});layer.listeners.add("featurecreated",function(feature){var nodes=list.addItem(feature);$(".edit_feature",nodes).click(function(){feature.setEditable(true);return false});$(".remove_feature",nodes).click(function(){feature.remove();return false});$(".hide_show_feature:checkbox",nodes).click(function(e){if($(this).attr("checked")){feature.show()}else{feature.hide()}e.stopPropagation()});$(".static_title",nodes).text(feature.title);$(".editable_title",nodes).bind("change",function(){feature.title=$(this).val();feature.listeners.broadcast("titlechanged")}).val(feature.title);feature.listeners.add("titlechanged",function(){$(".static_title",nodes).text(feature.title);$(".editable_title",nodes).val(feature.title)})});layer.listeners.add("featureremoved",function(feature){list.removeItem(feature)});layer.renderer.listeners.add("beginEditingFeature",function(feature){var nodes=list.getItemChilds(feature);$(nodes).addClass("active");$(".main",nodes).addClass("active")}).add("endEditingFeature",function(feature){var nodes=list.getItemChilds(feature);$(nodes).removeClass("active");$(".main",nodes).removeClass("active")});return list}})();Regio.SearchList.createProviderRegioJGCJSONP=function(key,cfg){cfg=cfg||{};Regio.Utils.applyDefaults(cfg,{uri:"http://kaardid.regio.ee/jgc/geocode?gl=et&output=json&q={query}&key={key}&srs={srs}&sid={sid}&rid={rid}",srs:"epsg:4326"});var lastAjax;var rid=0;return function(query,listeners,onSuccess,onError){var q,z;if(typeof(query)=="object"){q=query.query;z=query.zoom}else{q=query}if(!z){z=10}var opts={type:"GET",dataType:"jsonp",url:Regio.Utils.format(cfg.uri,jQuery.extend({key:key,query:encodeURIComponent(q),srs:cfg.srs,rid:rid++,sid:Regio.Session.getID()},cfg.params)),error:function(req,desc){onError(desc)},success:function(json){if(json.Status&&(json.Status.code!=200)){onError(json.Status.code)}else{if(Regio.Utils.isArray(json)){json=json[0]}var arr=json.placemark||[];for(var i in arr){arr[i].e=arr[i].point.coordinates[0];arr[i].n=arr[i].point.coordinates[1];arr[i].z=z}onSuccess(arr)}}};opts=jQuery.extend(opts,cfg);listeners.broadcast("submit",opts);if(lastAjax){lastAjax.abort()}lastAjax=jQuery.ajax(opts)}};Regio.SearchList.createAutocompleteProvider=function(key,cfg){cfg=cfg||{};Regio.Utils.applyDefaults(cfg,{uri:"http://kaardid.regio.ee/jgc/geocode?gl=et&output=json&ac=true&q={query}&key={key}&srs={srs}&rid={rid}",srs:"epsg:4326"});return{uri:Regio.Utils.format(cfg.uri,$.extend({},cfg,{key:key})),extraParams:{sid:Regio.Session.getID()},dataType:"jsonp",parse:function(data){if(Regio.Utils.isArray(data)){data=data[0]}var arr=data.placemark||[],res=[];for(var i in arr){res.push([arr[i].address])}return res}}};Regio.SearchList.createProviderRegioMulti=function(children){if(!children){throw new Error("Multi Search provider has no children")}var requests=new Array;return function(query,listeners,onSuccess,onError){var q,z;if(typeof(query)=="object"){q=query.query;z=query.zoom}else{q=query}if(!z){z=10}killRequests();$(children).each(function(i){var child=this;requests[i]={status:0,lastAjax:null,data:[]};var opts={type:this.type?this.type:"GET",dataType:this.dataType?this.dataType:"json",url:Regio.Utils.format(this.uri,{query:encodeURIComponent(q)}),error:function(req,desc){onError(desc);requests[i].status=2;killRequests()},success:function(data){requests[i].status=1;requests[i].data=child.parse(data);if(checkComplete()){onAllComplete()}}};listeners.broadcast("submit",opts);requests[i].lastAjax=jQuery.ajax(opts)});function checkComplete(){for(var i in children){if(requests[i]){if(requests[i].status==2){return false}else{if(requests[i].status!=1){return false}}}else{return false}}return true}function onAllComplete(){var allData=new Array();for(var i in children){for(var d in requests[i].data){allData.push(requests[i].data[d])}}onSuccess(allData)}function killRequests(){for(var i in children){if(requests[i]&&requests[i].lastAjax){requests[i].lastAjax.abort()}}}}};if(typeof(Regio)=="undefined"||!Regio.Utils){throw new Error("Regio.Route requires utils.js!")}if(typeof(MapCat)=="undefined"){throw new Error("Regio.Route requires MapCat API v2!")}if(!Regio.TreeView2){throw new Error("Regio.Route requires treeView.2.0.js!")}(function(){var RouteDescription=function(route,div,cfg){div=Regio.Utils.getElement(div);if(div&&!cfg.treeTemplate){cfg.treeTemplate=Regio.Utils.initTemplate(div,"html")}var overview;var tree=new Regio.TreeView2(div,{treeTemplate:cfg.treeTemplate,branchFirstItemIsHeaderDescriptor:false,treeStartsWithHeader:false});tree.getHeaderDescriptor=function(arr,pos){if(pos.length==1){var points=route.getPoints();var res=route.listeners.broadcast("header",arr,pos,points);return res?res:points[pos[0]]}};tree.beforeDrawNode=function(obj,childNodes,drawingFirstBranch,position){return route.listeners.broadcast("row",obj,position,childNodes)};var treeData=[];function setTreeData(data){tree.setData(treeData=data)}this.clear=function(){var cancel=route.listeners.broadcast("clearDescription");if(!cancel){setTreeData([])}};this.setData=function(data,overview){route.listeners.broadcast("drawDescription",data,overview);setTreeData(data)};this.getData=function(){return treeData}};var RouteSegments=function(route){var segments={};var segmentsToBeDrawn={};this.clear=function(){segments={};segmentsToBeDrawn={}};this.updateSegment=function(wayPointNum,segmentID,data){var w=wayPointNum,id=segmentID;if(!segments[w]){segments[w]={}}segments[w][id]=data;if(!segmentsToBeDrawn[w]){segmentsToBeDrawn[w]={}}segmentsToBeDrawn[w][id]=data};this.getUpdatedSegments=function(){for(var i in segments){break}if(!i){return false}else{var tmp=segmentsToBeDrawn;segmentsToBeDrawn={};return tmp}}};Regio.Route=function(div,api,cfg){div=Regio.Utils.getElement(div);var listeners=this.listeners=new MapCat.Listeners();var me=this;var state,started=false,currentProvider;var sessionParams={noCentering:true};var queryesCount=0;var segments=new RouteSegments(me);if(!cfg.providers){throw new Error("Regio.Route, no providers defined!")}var wayPoints=[];var desc=new RouteDescription(me,div,cfg);setState("idle");function clear(){desc.clear();segments.clear();renderPath()}function setState(s){state=s;switch(s){case"started":started=true;break;case"stopped":started=false;setState("idle");break}listeners.broadcast("status",s,started)}function start(provider){currentProvider=provider;setState("started");query(true,true)}function stop(){if(!started){return}if(currentProvider.abort){}setState("stopped")}function query(queryDesc,queryPoints,bbox,generalization){if(!currentProvider){throw new Error("Regio.Route, query - no current provider defined!")}if(!currentProvider.getRoute){throw new Error('Regio.Route, provider does not have "getRoute" function defined')}setState("wait");listeners.broadcast("requestStarted");var complete=function(isError,errorDesc){if(isError){listeners.broadcast("requestError",errorDesc)}else{if(queryPoints){renderPath()}listeners.broadcast("requestComplete",queryesCount,queryDesc,queryPoints,bbox,generalization)}queryesCount++;setState("idle")};if(currentProvider.abort){}currentProvider.getRoute(me,api,queryDesc,queryPoints,bbox,generalization,complete)}function renderPath(){var updates=segments.getUpdatedSegments();listeners.broadcast(updates===false?"clearPath":"drawPath",updates,queryesCount,me,api,segments);if(cfg.renderers){for(var i=0;i<cfg.renderers.length;i++){cfg.renderers[i](updates,queryesCount,me,api,segments)}}}this.addPoints=function(wayPointsArray){stop();clear();var tmp=[];for(var i=0;i<wayPointsArray.length;i++){tmp.push(wayPointsArray[i])}for(var i=0;i<tmp.length;i++){wayPoints.push(tmp[i])}listeners.broadcast("points",wayPoints)};this.clearPoints=function(){stop();clear();wayPoints=[];listeners.broadcast("points",wayPoints)};this.startRouting=function(provider,params){sessionParams=params;if(!provider){for(provider in cfg.providers){break}if(!provider){throw new Error("Regio.Route, can not find default provider!")}}if(typeof(provider)=="string"){provider=cfg.providers[provider]}stop();clear();queryesCount=0;start(provider)};this.stopRouting=function(){stop()};this.updateForBBox=function(bbox,generalization){if(!started){return}query(false,true,bbox,generalization)};this.clear=function(){clear()};this.getSessionParams=function(){return sessionParams||{}};this.setDescription=function(treeData,overview){desc.setData(treeData,overview)};this.getDescription=function(){return desc.getData()};this.getPoints=function(){return wayPoints};this.updateSegment=function(){return segments.updateSegment.apply(segments,arguments)};this.updatePath=function(){query(false,true)};return this}})();Regio.Route.CreateFlashTileRenderer=function(mapcat,cfg){if(!cfg){cfg={}}var defaultStyle={line:{alpha:60,lines:[{color:"000000",width:5},{color:"FF0000",width:3}]}};var hiliteStyle={line:{alpha:60,lines:[{color:"FFFFFF",width:7},{color:"0000FF",width:5}]}};var layerName="FT_ROUTE_"+Math.random().toString().split(".")[1];var listeners=new MapCat.Listeners();mapcat.ready(function(){mapcat.broadcast("layers.addSystemLayer",layerName)});mapcat.addCallback("objects.onClick",function(args){if(args.layerId==layerName){mapcat.broadcast("map.centerToObject",{Lid:args.layerId,obId:args.objectId})}});mapcat.addCallback("objects.onMouseOver",function(args){if(args.layerId==layerName){mapcat.broadcast("layers.restyleObjectAtSystemLayer",args.layerId,args.objectId,hiliteStyle);var ids=getSegmentIDsFromObjectID(args.objectId);listeners.broadcast("overSegment",ids.wayPointNum,ids.segmentID)}});mapcat.addCallback("objects.onMouseOut",function(args){if(args.layerId==layerName){mapcat.broadcast("layers.restyleObjectAtSystemLayer",args.layerId,args.objectId,defaultStyle);var ids=getSegmentIDsFromObjectID(args.objectId);listeners.broadcast("outSegment",ids.wayPointNum,ids.segmentID)}});function getObjectID(wayPointNum,segmentID){return wayPointNum+"_"+segmentID}function getSegmentIDsFromObjectID(objectID){var arr=(objectID+"").split("_");return{wayPointNum:arr[0],segmentID:arr[1]}}function drawSegment(id,segment){mapcat.ready(function(){mapcat.broadcast("layers.addLineToSystemLayer",layerName,{objectId:id,geo:segment.points,colors:["0x990000","0x770000"],widths:[5,3],alpha:100,tooltip:segment.text});mapcat.broadcast("layers.restyleObjectAtSystemLayer",layerName,id,defaultStyle)})}var renderer=function(updates,queryesCount,route,api,segments){if(!updates){mapcat.ready(function(){mapcat.broadcast("layers.clearSystemLayer",layerName)})}for(var wayPointNum in updates){var wayPointSegments=updates[wayPointNum];for(var segmentID in wayPointSegments){var segment=wayPointSegments[segmentID];drawSegment(getObjectID(wayPointNum,segmentID),segment)}}if(queryesCount==0){if(!cfg.noCentering&&!route.getSessionParams().noCentering){setTimeout(function(){mapcat.ready(function(){mapcat.broadcast("layers.centerToSystemLayer",layerName)})},100)}}};renderer.listeners=listeners;listeners.add("hiliteSegment",function(wNum,sID){mapcat.ready(function(){mapcat.broadcast("layers.restyleObjectAtSystemLayer",layerName,getObjectID(wNum,sID),hiliteStyle)})});listeners.add("deHiliteSegment",function(wNum,sID){mapcat.ready(function(){mapcat.broadcast("layers.restyleObjectAtSystemLayer",layerName,getObjectID(wNum,sID),defaultStyle)})});listeners.add("centerSegment",function(wNum,sID){mapcat.ready(function(){mapcat.broadcast("map.centerToObject",{Lid:layerName,obId:getObjectID(wNum,sID)})})});return renderer};Regio.Route.CreateDelfiProvider=function(cfg){cfg=cfg||{};Regio.Utils.applyDefaults(cfg,{bridgePath:"delfiRoutingBridge.php",idPrefix:""});var provider={abort:function(){if(this.lastAjax){this.lastAjax.abort();this.lastAjax=null}},getRoute:function(route,mapapi,queryDescription,querySegments,bbox,generalization,onCompleteCallback){var me=this;var points=route.getPoints(),pointsArr=[];for(var i=0;i<points.length;i++){pointsArr.push([points[i].e,points[i].n].join(","))}var opts={dataType:"xml",error:function(e,t){onCompleteCallback(true,t)},success:function(data){if(queryDescription){me.lastServerParams=$("route server",data).attr("params");var desc=$("route desc",data);var legs=$("route leg",data),arr=[];for(var i=0;i<legs.length;i++){arr.push({id:cfg.idPrefix+$(legs[i]).attr("id"),turn:(""+$(legs[i]).attr("turn")).toLowerCase(),text:decodeURIComponent($(legs[i]).attr("text"))})}route.setDescription([arr,[]],{length:desc.attr("length"),time:desc.attr("time")})}if(querySegments){var wayPointNum=0;var objs=$("route obj",data);objs.each(function(){var id=cfg.idPrefix+$(this).attr("id");var arr=[];$("crd",this).each(function(){arr.push({e:$(this).attr("E"),n:$(this).attr("N")})});route.updateSegment(wayPointNum,id,{text:$(route.getDescription()[wayPointNum]).filter(function(){return this.id==id})[0].text,points:arr})})}if(queryDescription){me.getRoute(route,mapapi,false,querySegments,bbox,generalization,onCompleteCallback);onCompleteCallback()}else{onCompleteCallback()}}};if(queryDescription){opts.url=cfg.bridgePath,opts.type="GET";opts.data={request:"description",points:pointsArr.join(";"),locale:"est",srs:"EPSG:3301"}}else{if(querySegments){if(!bbox){bbox=[0,0,99999999,99999999]}if(!generalization){generalization=100}opts.url=Regio.Utils.format(cfg.bridgePath+"?request=update&points={points}&locale=est&srs=EPSG:3301&gen={gen}&e1={e1}&n1={n1}&e2={e2}&n2={n2}",{points:pointsArr.join(";"),gen:generalization,e1:bbox[0],n1:bbox[1],e2:bbox[2],n2:bbox[3]});opts.type="POST";opts.data=this.lastServerParams?'<?xml version="1.0"?><data><params>'+decodeURIComponent(this.lastServerParams)+"</params></data>":"";opts.contentType="text/xml"}}if(!queryDescription&&!this.lastServerParams){}else{this.abort();this.lastAjax=jQuery.ajax(opts)}}};return provider};if(1){}(function(){var typeMap={point:{id:1,name:"POINT",fixCoords:true},line:{id:2,name:"LINESTRING",fixCoords:false},polygon:{id:3,name:"POLYGON",fixCoords:true},circle:{id:4,name:"CIRCLE",fixCoords:false},rectangle:{id:5,name:"RECTANGLE",fixCoords:false}};function typeMapById(id){for(var i in typeMap){if(typeMap[i].id==id){return typeMap[i]}}}var FTLayer=function(renderer,lid){Regio.Layer.apply(this,arguments);var lid=this.id;function mc(){var args=arguments;renderer.map.ready(function(){renderer.map.broadcast.apply(renderer.map,args)})}mc("layers.addSystemLayer",lid);this.createPoint=function(points,userStyle){Regio.Layer.prototype.createPoint.apply(this,arguments);var f=this._createObject("point",points,userStyle);return f};this.createLine=function(points,userStyle){Regio.Layer.prototype.createLine.apply(this,arguments);var f=this._createObject("line",points,userStyle);return f};this.createPolygon=function(points,userStyle){Regio.Layer.prototype.createPolygon.apply(this,arguments);var f=this._createObject("polygon",points,userStyle);return f};this.createCircle=function(points,userStyle){var f=this._createObject("circle",points,userStyle);return f};this.createRectangle=function(points,userStyle){var f=this._createObject("rectangle",points,userStyle);return f};this._createObject=function(type,points,userStyle){with(typeMap[type]){var typeId=id;var typeName=name;var coordsFix=fixCoords}if((points!="digitize")&&(!points)){throw"No or bad points given for createObject"}var f=new Regio.Feature(type.toLowerCase(),this,userStyle);f.draw=function(){var s=f.style;if(renderer.getEditingFeature()==f){mc("mapcat.restyleEditedObject",jQuery.extend({},{style:{line:{lines:[{color:s.strokeColor,width:s.strokeWidth}],alpha:s.strokeOpacity},area:{lineColor:s.strokeColor,lineWidth:s.strokeWidth,lineAlpha:s.strokeOpacity,fillColor:s.fillColor,fillAlpha:s.fillOpacity},point:{color:s.pointColor,alpha:s.pointOpacity}},symbolId:s.pointIcon,symbol:s.pointIcon},f.style))}else{mc("layers.addObjectToSystemLayer",lid,jQuery.extend({objectId:f.id,featureId:f.id,typeName:typeName,geo:coordsFix?[f.coords]:f.coords,style:{line:{lines:[{color:s.strokeColor,width:s.strokeWidth}],alpha:s.strokeOpacity},area:{lineColor:s.strokeColor,lineWidth:s.strokeWidth,lineAlpha:s.strokeOpacity,fillColor:s.fillColor,fillAlpha:s.fillOpacity},point:{color:s.pointColor,alpha:s.pointOpacity}},symbolId:s.pointIcon,symbol:s.pointIcon,tooltip:f.title},f.style))}};if(points!="digitize"){f.setCoords(points);f.draw()}else{var s=f.style;renderer.stopEditing();mc("mapcat.startEditMode",jQuery.extend({},{type:typeId,lid:lid,sendResponse:1,featureId:f.id,style:{line:{lines:[{color:s.strokeColor,width:s.strokeWidth}],alpha:s.strokeOpacity},area:{lineColor:s.strokeColor,lineWidth:s.strokeWidth,lineAlpha:s.strokeOpacity,fillColor:s.fillColor,fillAlpha:s.fillOpacity},point:{color:s.pointColor,alpha:s.pointOpacity}},symbolId:s.pointIcon,symbol:s.pointIcon},f.style))}f.erase=function(){f.setEditable(false);mc("layers.removeObjectFromSystemLayer",lid,f.id)};f.center=function(){mc("map.centerToObject",{Lid:lid,obId:f.id})};f.listeners.add("titlechanged",function(){mc("objects.setTooltip",lid,f.id,f.title)});return f};this.setFeatureStyle=function(feature,style){Regio.Layer.prototype.setFeatureStyle.apply(this,arguments);var s=feature.style;for(var i in s){if(i.indexOf("Color")){s[i]=Regio.Utils.removeSubstr(""+s[i],"#")}}};this.removeFeature=function(feature){feature.erase();Regio.Layer.prototype.removeFeature.apply(this,arguments)};this.setVisibility=function(visible){mc("layers.setVisibility",lid,Boolean(visible));Regio.Layer.prototype.setVisibility.apply(this,arguments)}};jQuery.extend(FTLayer.prototype,Regio.Layer.prototype);function registerFeatureEventListeners(map,layers){function broadcastFeatureEvent(lid,fid,event,args){var l,f,c;args=args||[];if((l=layers[lid])&&(f=l.features[fid])&&(c=f.listeners)){args.unshift(event);return c.broadcast.apply(c,args)}}map.addCallback("objects.onMouseOver",function(a){broadcastFeatureEvent(a.layerId,a.objectId,"mouseover")});map.addCallback("objects.onMouseOut",function(a){broadcastFeatureEvent(a.layerId,a.objectId,"mouseout")});map.addCallback("objects.onClick",function(a){broadcastFeatureEvent(a.layerId,a.objectId,"click")})}Regio.FeaturesRenderer.FT=function(map){Regio.FeaturesRenderer.apply(this,arguments);function mc(){var args=arguments;map.ready(function(){map.broadcast.apply(map,args)})}var editingFeature=false;this.map=map;var me=this;registerFeatureEventListeners(map,this.layers);function stopEditingFeature(success){if(editingFeature){var tmp=editingFeature;editingFeature=false;tmp.draw();me.listeners.broadcast("endEditingFeature",tmp)}}map.addCallback("mapcat.startEditMode",function(a){if(editingFeature){stopEditingFeature(true)}var l,f;if((l=me.layers[a.lid])&&(f=l.features[a.featureId?a.featureId:a.objectId])){editingFeature=f;me.listeners.broadcast("beginEditingFeature",f)}});map.addCallback("mapcat.editModeResponse",function(a){if(editingFeature){editingFeature.setCoords(typeMapById(a.type).fixCoords?a.geo[0]:a.geo)}});map.addCallback("mapcat.stopEditMode",stopEditingFeature);this.createLayer=function(lid,cfg){var layer=new FTLayer(this,lid);Regio.FeaturesRenderer.prototype.createLayer.apply(this,[layer,cfg]);return layer};this.setEditingFeature=function(feature){if(editingFeature){this.stopEditing()}mc("mapcat.startEditMode",{objectId:feature.id,lid:feature.layer.id,action:"COPY_AND_HIDE",sendResponse:1});Regio.FeaturesRenderer.prototype.setEditingFeature.apply(this,arguments)};this.stopEditing=function(){if(editingFeature){mc("mapcat.stopEditMode",true)}};this.getEditingFeature=function(){Regio.FeaturesRenderer.prototype.getEditingFeature.apply(this,arguments);return editingFeature}};jQuery.extend(Regio.FeaturesRenderer.FT.prototype,Regio.FeaturesRenderer.prototype)})();Regio.SearchList.createStateFetcher=function(cmp){return{get:function(){var state=cmp.getState();var s=null;if(state.lastQuery){s={tab:state.tab,page:state.page,query:{text:state.lastQuery,provider:state.lastProvider}};if(state.lastClickedRowData){s.object={e:state.lastClickedRowData.e,n:state.lastClickedRowData.n,ttip:state.lastClickedRowData.address,layer:state.lastClickedRowData.layer}}}return s},set:function(data){if(!data||!data.query){return}var lastClickedRowData=null;if(data.object){lastClickedRowData={e:data.object.e,n:data.object.n,address:data.object.ttip,layer:data.object.layer}}cmp.listeners.broadcast("startRestoreState",data);var running=false;var itemsListener=function(items){if(running){return}running=true;var state={data:items,lastQuery:data.query.text,lastProvider:data.query.provider,page:data.page,tab:data.tab,lastClickedRowData:lastClickedRowData};cmp.setState(state);cmp.listeners.broadcast("endRestoreState",state);cmp.listeners.removeByFunction(itemsListener)};cmp.submit(data.query.text,data.query.provider);cmp.listeners.add("items",itemsListener)}}};Regio.StateList=function(coms){this.fetchers=coms;this.get=function(){var data={};for(var p in this.fetchers){data[p]=this.fetchers[p].get()}return jQuery.extend({},data)};this.set=function(data){for(var p in this.fetchers){this.fetchers[p].set(data[p])}}};Regio.Layer.createStateFetcher=function(cmp){return{get:function(){var objects=cmp.getState();if(!objects){return null}for(var i=0;i<objects.length;i++){if(!objects[i].coords){objects.splice(i,1)}}return objects},set:function(objects){cmp.setState(objects)}}};Regio.LayersTree.createStateFetcher=function(cmp){return{get:function(){return cmp.getCheckedLayers()},set:function(layers){if(!layers){return}for(var i=0;i<layers.length;i++){cmp.checkLayer(true,layers[i],null,true)}}}};Regio.Route.createStateFetcher=function(cmp){return{get:function(){return cmp.getPoints()},set:function(points){if(points&&points.length>=2){cmp.addPoints(points);cmp.startRouting(undefined,{noCentering:true})}}}};Regio.StateList.ServerAdapter=function(stateList,cfg){if(!cfg||!cfg.url){alert("No url defined in Regio.StateList.ServerAdapter constructor");return}var lastData=null;var lastResult=null;var busy=false;var me=this;if(!parent){parent=document}this.getStateId=function(callback){if(busy){return}var co={};if(typeof callback=="function"){co.success=callback}else{if(typeof callback=="object"){co=$.extend({},callback)}}var data=Object.toJSON(stateList.get());if(lastData==data){if(typeof co.success=="function"){co.success(lastResult)}return}lastData=data;$.ajax({url:cfg.url,dataType:"json",data:{data:data},type:"POST",success:function(data,textStatus){if(data&&data.success&&data.uid){if(typeof co.success=="function"){co.success(data.uid)}lastResult=data.uid}else{var error=data&&data.error?data.error:null;if(typeof co.error=="function"){co.error(error)}}},error:function(XMLHttpRequest,textStatus,errorThrown){if(typeof co.error=="function"){co.error()}},complete:function(){busy=false}})}};jQuery.fn.colorPicker=function(linkTo,cfg){return jQuery.colorPicker(this,linkTo,cfg)};jQuery.colorPicker=function(container,linkTo,userConf){userConf=userConf||{};var _htmlElements="div,span,a,td";var _valueElements="input, select, textarea";var cfg=$.extend({},jQuery.colorPicker.defaultConf,userConf);var f=$.farbtastic(container);var p=$(container);var me=this;var callbacking=false;this.show=function(){if(typeof cfg.showHide=="object"){cfg.showHide.show()}else{if(typeof cfg.showHide=="boolean"){p.show()}}};this.hide=function(){if(typeof cfg.showHide=="object"){cfg.showHide.hide()}else{if(typeof cfg.showHide=="boolean"){p.hide()}}};this.setColor=f.setColor;if(cfg.showHide){this.hide()}$(linkTo).each(function(){this.color=getInitColor(this)||cfg.defaultColor;if(this.color){updateColor(this,this.color)}}).click(function(){var elem=this;f.linkTo(function(color){if(elem.color==color){return}updateColor(elem,color);callbacking=true;doCallback(elem,color);callbacking=false});f.setColor(this.color);if(cfg.showHide){me.show()}}).change(function(){if(callbacking){return}if(this.color==color){return}var color=getInitColor(this);if(checkHexColor(color)){this.color=color;f.setColor(color);if(cfg.colorize){applyColor(this,color)}if(cfg.text){$(this).css("color",cfg.textSameColor?color:f.hsl[2]>0.5?"#000":"#fff")}}});function fixColor(color){if(color){color=color.charAt(0)=="#"?color:color="#"+color}return color}function updateColor(elem,color){elem.color=color;if(cfg.colorize){applyColor(elem,color)}if(cfg.text){addText(elem,color);$(elem).css("color",cfg.textSameColor?color:f.hsl[2]>0.5?"#000":"#fff")}}function doCallback(elem,color){changing=true;$(elem).change();if(typeof cfg.callback=="function"){cfg.callback(elem,color)}changing=false}function applyColor(elem,color){$(elem).css("background-color",color)}function addText(elem,color){if($(elem).is(_htmlElements)){if($(elem).html()!=color){$(elem).html(color)}}else{if($(elem).is(_valueElements)){if($(elem).val()!=color){$(elem).val(color)}}}}function getInitColor(elem){var color=null;if($(elem).is(_htmlElements)){color=$(elem).html()}else{if($(elem).is(_valueElements)){color=$(elem).val()}}if(!checkHexColor(color)){try{color=convertColor(elem.style.backgroundColor)}catch(e){}}return fixColor(checkHexColor(color)?color:null)}function checkHexColor(color){var reg=new RegExp("^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$");return reg.test(color)}function convertColor(color){if(checkHexColor(color)){return color}var reg=new RegExp("^rgb\\(([0-9]+), ([0-9]+), ([0-9]+)\\)$");var rgb=reg.exec(color);if(rgb){var r=Math.round(rgb[1]);var g=Math.round(rgb[2]);var b=Math.round(rgb[3]);return"#"+(r<16?"0":"")+r.toString(16)+(g<16?"0":"")+g.toString(16)+(b<16?"0":"")+b.toString(16)}return null}return this};jQuery.colorPicker.defaultConf={showHide:true,colorize:true,text:false,textSameColor:false,callback:null,defaultColor:""}})(window.jQuery);


if(typeof(Regio)=="undefined"||!Regio.Route){throw new Error('routeDelfiProvider.js requires Regio.Route!');}
if(typeof(jQuery)=="undefined"){throw new Error('routeDelfiProvider.js requires jQuery!');}
Regio.Route.CreateLithuaniaProvider=function(idPrefix){if(!idPrefix)idPrefix='';var provider={abort:function(){if(this.lastAjax){this.lastAjax.abort();this.lastAjax=null;}},getRoute:function(route,mapapi,queryDescription,querySegments,bbox,generalization,onCompleteCallback){var me=this;var points=route.getPoints(),pointsArr=[];for(var i=0;i<points.length;i++){pointsArr.push([points[i].e,points[i].n].join(','));}
var opts={dataType:'xml',error:function(e,t){onCompleteCallback(true,t);},success:function(data){if(queryDescription){me.lastServerParams=$('route server',data).attr('params');var desc=$('route desc',data);var legs=$('route leg',data),arr=[];for(var i=0;i<legs.length;i++){arr.push({id:idPrefix+$(legs[i]).attr('id'),turn:(''+$(legs[i]).attr('turn')).toLowerCase(),text:decodeURIComponent($(legs[i]).attr('text'))})}
route.setDescription([arr,[]],{length:desc.attr('length'),time:desc.attr('time')});}
if(querySegments){var wayPointNum=0;var objs=$('route obj',data);objs.each(function(){var id=idPrefix+$(this).attr('id');var arr=[];$('crd',this).each(function(){arr.push({e:$(this).attr('E'),n:$(this).attr('N')});});route.updateSegment(wayPointNum,id,{text:$(route.getDescription()[wayPointNum]).filter(function(){return this.id==id})[0].text,points:arr})});}
if(queryDescription){me.getRoute(route,mapapi,false,querySegments,bbox,generalization,onCompleteCallback);onCompleteCallback();}else{onCompleteCallback();}}};if(queryDescription){opts.url='delfiRoutingBridge.php',opts.type='GET';opts.data={request:'description',points:pointsArr.join(';'),locale:'lat',srs:'WGS84'};}else if(querySegments){if(!bbox)bbox=[0,0,99999999,99999999];if(!generalization)generalization=100;opts.url=Regio.Utils.format('delfiRoutingBridge.php?request=update&points={points}&locale=lat&srs=WGS84&gen={gen}&e1={e1}&n1={n1}&e2={e2}&n2={n2}',{points:pointsArr.join(';'),gen:generalization,e1:bbox[0],n1:bbox[1],e2:bbox[2],n2:bbox[3]});opts.type='POST';opts.data=this.lastServerParams?'<?xml version="1.0"?><data><params>'+decodeURIComponent(this.lastServerParams)+'</params></data>':'';opts.contentType="text/xml";}
if(!queryDescription&&!this.lastServerParams){}else{this.abort();this.lastAjax=jQuery.ajax(opts);}}}
return provider;}


Regio.Layer.StateConverter=function(cmp){function convertToOld(no){var oo={};switch(no.type){case'point':oo.type=1;oo.style={color:no.style.pointColor,alpha:no.style.pointOpacity,symbolId:no.style.pointIcon};oo.geo=[no.coords];break;case'line':oo.type=2;oo.style={colors:[no.style.strokeColor],widths:[no.style.strokeWidth],alpha:no.style.strokeOpacity};oo.geo=no.coords;break;case'polygon':oo.type=3;oo.style={lineColor:no.style.strokeColor,lineWidth:no.style.strokeWidth,lineAlpha:no.style.strokeOpacity,fillColor:no.style.fillColor,fillAlpha:no.style.fillOpacity};oo.geo=[no.coords];break;}
oo.tooltip=no.title;return oo;}
function convertToNew(oo){var no={};switch(oo.type){case 1:no.type='point';no.style={pointColor:oo.style.color,pointOpacity:oo.style.alpha,pointIcon:oo.style.symbolId};no.coords=oo.geo[0];break;case 2:no.type='line';no.style={strokeColor:oo.style.colors[0],strokeWidth:oo.style.widths[0],strokeOpacity:oo.style.alpha};no.coords=oo.geo;break;case 3:no.type='polygon';no.style={strokeColor:oo.style.lineColor,strokeWidth:oo.style.lineWidth,strokeOpacity:oo.style.lineAlpha,fillColor:oo.style.fillColor,fillOpacity:oo.style.fillAlpha};no.coords=oo.geo[0];break;}
no.title=oo.tooltip;no.visible=true;return no;}
return{get:function(){var data=cmp.get();for(var i=0;i<data.length;i++){data[i]=convertToOld(data[i]);}
return data;},set:function(objects){var data=objects;if(!data)return;for(var i=0;i<data.length;i++){data[i]=convertToNew(data[i]);}
cmp.set(data);}}}


Regio.StateList.LinkComposer=function(stateList,cfg){function compose(){var state=stateList.get();var url='';if(state.map){if(state.map.bbox){with(state.map.bbox){url+='&bbox='+min_e+','+min_n+','+max_e+','+max_n;}}
if(state.map.type){url+='&type='+state.map.type;}}
if(state.objects&&state.objects.length>0){if(state.objects.length>1)return null;if(state.objects[0].type!=1)return null;if(!state.objects[0].geo)return null;with(state.objects[0]){url+='&e='+geo[0].e+'&n='+geo[0].n+'&name='+encodeURI(tooltip)+'&symbol='+encodeURI(style.symbolId)+'&color='+encodeURI(style.color)+'&alpha='+style.alpha;}}
if(state.search){url+='&search='+encodeURI(Object.toJSON(state.search));}
if(state.routing&&state.routing.length>1){url+='&routing='+encodeURI(Object.toJSON(state.routing));}
if(state.layers&&state.layers.length){url+='&layers='+state.layers.join(',');}
return url;}
this.compose=compose;}


String.prototype.format=function(obj){var str=this;if(typeof(obj)=="object"){for(i in obj){var re=new RegExp('\\{'+(i)+'\\}','gmi');str=str.replace(re,obj[i]);}}else{for(var i=0;i<arguments.length;i++){var re=new RegExp('\\{'+(i)+'\\}','gmi');str=str.replace(re,arguments[i]);}}
return str;}
String.prototype.removeSubstr=function(){var str=this;for(var i=0;i<arguments.length;i++){var re=new RegExp(arguments[i],'g');str=str.replace(re,'');}
return str;}
function mapPoint(e,n,z,title){this.e=e;this.n=n;this.z=z;this.title=title;}
function disableButtons(jAnchor,disable){jAnchor[disable?"addClass":"removeClass"]("disabled");jAnchor.each(function(){if(disable){this.href_old=this.href;this.href="javascript:void(false)";}else{this.href=this.href_old;}});}


info={showSearchBoxInfo:function(){searchHandler.hideFooter();$(searchHandler.ALL_RESULTS_CONTAINER_NAME).html(this.getInfoHtml());$(searchHandler.RESULTS_ON_MAP_CONTAINER_NAME).html(this.getInfoHtml());},getInfoHtml:function(){if(this.infoText==undefined){this.infoText='<div id="juhendid" class="juhendid">'+'<div id="juhendid-inner">'+'<div class="info-box">'+'<p>'+LANG["_INFO1"]+'</p>'+'</div>'+'<div class="info-box">'+'<p>'+LANG["_INFO2A"]+'<img src="gfx/start.gif"/>'+'<img src="gfx/end.gif"/>'+
LANG["_INFO2B"]+'<img src="gfx/ico06.gif"/>'+'<img src="gfx/ico07.gif"/>'+'</p>'+'</div>'+'<div class="info-box">'+'<p>'+LANG["_INFO3A"]+'<img src="gfx/plus.gif"/>'+'<img src="gfx/minus.gif"/>'+
LANG["_INFO3B"]+'</p>'+'</div>'+'</div>'+'</div>';}
return this.infoText;},hideSearchBoxInfo:function(){$(searchHandler.ALL_RESULTS_CONTAINER_NAME).html("");}}


function InitUI(mapcat,route,search){var busy=false;$('.nav > ul').tabs().bind('tabsshow',function(){fixTemplate('tab');});$('.nav a').bind("click",function(){toggleSidebar(true);});var sideTabs=$('#sidebar_nav');sideTabs.tabs();sideTabs.tabs('select',1);$('.clear_search_and_switch').click(function(){search.clear();sideTabs.tabs('select',1);return false;});search.listeners.add("submit",function(){sideTabs.tabs('select',2);}).add("row",function(arr,childs){$(".route_set_start",childs).click(function(){route.routePoints.setPoint('start',arr.e,arr.n,arr.text,true);return false;});$(".route_set_end",childs).click(function(){route.routePoints.setPoint('end',arr.e,arr.n,arr.text,true);return false;});});$('.clear_route_and_switch').click(function(){mapcat.broadcast("routing.clear");sideTabs.tabs('select',2);return false;});mapcat.addCallback("resizeButton.stateChanged",function(collapsed){toggleSidebar();});function toggleSidebar(show){if(show){mapcat.broadcast("resizeButton.setButtonState",false);$('.sidepanel:not(.ui-tabs-hide)').show();}else{$('.sidepanel:not(.ui-tabs-hide)').toggle();}
$('#map_div')[show?"removeClass":"toggleClass"]('resized')}
$(function(){var fullscreen=false;var fixFunc=fixTemplate;var $wrapper=$('#regio2, #wrap2'),$o=$('.ui_fullscreen'),$c=$('.ui_fullscreen_close');fixFunc('init');$wrapper.savedWidth=$wrapper.css('width');$wrapper.savedHeight=$wrapper.css('height');$(window).resize(function(){if(fullscreen){fixTemplate('to fullscreen');}});$o.click(function(){$wrapper.css('width','100%').css('height','100%');$c.show();$o.hide();fixFunc('to fullscreen');fullscreen=true;return false;});$c.click(function(){$wrapper.css('width',$wrapper.savedWidth).css('height',$wrapper.savedHeight);$o.show();$c.hide();fixFunc('from fullscreen');fullscreen=false;return false;});});}


if(!window.jQuery)alert('jquery not loaded');if(!String.prototype.format)alert('classes not loaded');Layers={bind:function(f){var me=this;return function(){return f.apply(me,arguments);}},initialize:function(mapcat){this.mapcat=mapcat;this.initTemplates();this.treeDiv=$('#newLayersMenu')[0];this.tree=new Regio.LayersTree(this.treeDiv,this.treeFormat,mapcat);this.tree.onCollapsedOrExpanded=this.bind(this.onCollapsedOrExpanded);this.mapcat.addCallback("mapcat.layersData.loaded",this.onLayersListLoaded,this);this.mapcat.addCallback("layer.visibilityChanged",this.toggeleLayerCheckbox,this);},initTemplates:function(){var tbody=$('#newLayersMenu');var s=new String(tbody.html()).removeSubstr('<!--','-->','\n','\r','\t');this.treeFormat=eval('('+s+')');tbody.empty();},onLayersListLoaded:function(list){$('#scrollableMenu .message').hide();$('#newLayersMenu').show();this.onCollapsedOrExpanded();},deselectAll:function(){var self=this;var checks=this.tree.getCheckedLayers();$(checks).each(function(){self.tree.checkLayer(false,this,null,true);});self.tree.saveTreeState();},expandAll:function(collapseAll){var self=this;var groups=this.tree.getGroups();var exp=this.tree.getExpandedGroups();$(groups).each(function(){if(collapseAll||($.inArray(this,exp)==-1)){self.tree.toggleGroup(this,false);}});self.tree.saveTreeState();},checkLayer:function(toggle,lid){this.tree.checkLayer(toggle,lid,null,false);},toggeleLayerCheckbox:function(groupId,layerId,visible){$('#layer_check_'+layerId,this.treeDiv).attr('checked',visible);},expandOrCollapseAll:function(){this.busy=true;var groups=this.tree.getGroups();var exp=this.tree.getExpandedGroups();if(groups.length==exp.length){this.expandAll(true);$('#open_collapse_groups STRONG').html(LANG['_SHOWALLLAYERS']);}else{this.expandAll();$('#open_collapse_groups STRONG').html(LANG['_HIDEALLLAYERS']);}
this.busy=false;},onCollapsedOrExpanded:function(){if(this.busy)return;var groups=this.tree.getGroups();var exp=this.tree.getExpandedGroups();if(groups.length==exp.length){$('#open_collapse_groups STRONG').html(LANG['_HIDEALLLAYERS']);}else{$('#open_collapse_groups STRONG').html(LANG['_SHOWALLLAYERS']);}}}
function InitLayers(mapcat){Layers.initialize(mapcat);}


if(typeof(Regio)=="undefined"||!Regio.Utils){throw new Error('Include utils.js!');}
if(!Regio.SearchList){throw new Error('Include searchList.js!');}
if(typeof(jQuery)=="undefined"){throw new Error('Search needs jQuery!');}
function InitSearch(mapcat,cfg){var div=$('#allResultsList')[0];var me=this;var map=false;var ll=(cfg.bbox?((cfg.bbox[1]+cfg.bbox[3])/2)+','+((cfg.bbox[0]+cfg.bbox[2])/2):'');var spn=(cfg.bbox?(cfg.bbox[3]-cfg.bbox[1])+','+(cfg.bbox[2]-cfg.bbox[0]):'');var autocomplete=Regio.SearchList.createAutocompleteProvider('delfi',{uri:null});autocomplete.noIFrame=true;var $radios=$('.search_radio input:radio');autocomplete.beforeFormatURL=function(obj){obj.uri=cfg.urls[$radios.filter(':checked').attr('ref')]+'&ll='+ll+'&spn='+spn}
var search=new Regio.SearchList.createFromMarkup($('#tc1.sidepanel')[0],{rowsPerPage:10,rowTemplate:Regio.Utils.initTemplate(div,"html"),animation:true,autocomplete:autocomplete,noSubmitBinding:true,providers:{address:Regio.SearchList.createProviderRegioJGCJSONP('delfi',{uri:cfg.urls.address+'&ll='+ll+'&spn='+spn}),object:{uri:cfg.urls.object,type:'GET',dataType:'xml',parse:function(xml){var objs=[];$(xml).find('res').each(function(){var rec={address:$(this).text(),e:parseFloat($(this).attr('E')),n:parseFloat($(this).attr('N')),z:$(this).attr('z')?$(this).attr('z'):10,lid:$(this).attr('lId'),oid:$(this).attr('oId')}
if(rec.e&&rec.n&&rec.address){objs.push(rec);}});return objs;}}},tabFilter:function(tab,obj){if(tab==1){return map&&(obj.e>=map.min_e)&&(obj.n>=map.min_n)&&(obj.e<=map.max_e)&&(obj.n<=map.max_n);}}});$radios.change(function(){document.searchForm.q.autocompleter.flushCache();});$('.search_tab_0').click(function(){search.setTab(0);});$('.search_tab_1').click(function(){search.setTab(1);});$('#tc1 .search_form').submit(function(){search.submit(this.q.value,this.radiogroup01[0].checked?'address':this.radiogroup01[1].checked?'object':'multi');return false;});mapcat.addCallback("map.onMapParams",function(args){map=args;search.refresh(1);var tab1cnt=search.queryRowCountInTab(1);$('.searchResultsTab1Count').text(tab1cnt);});search.listeners.add("items",function(arr){$('.searchResultsCount').text(arr.length);var tab1cnt=search.queryRowCountInTab(1);$('.searchResultsTab1Count').text(tab1cnt);$('.list_header')[arr.length==0?'slideUp':'slideDown']();if(arr.length>0){search.listeners.broadcast("rowClick",arr[0]);}});var lastRowClicked=null;search.listeners.add('startRestoreState',function(){search.ignoreRowClick=true;search.doNotCenter=true;});function compareNumbers(n1,n2,precision){if(typeof precision=='undefined')precision=11;var pc=n1/n2;var er=Math.pow(10,-precision);return(1-er<pc&&1+er>pc);}
search.listeners.add("restoreState",function(state){search.ignoreRowClick=undefined;if(state.data&&state.lastClickedRowData){for(var i=0;i<state.data.length;i++){if(compareNumbers(state.data[i].e,state.lastClickedRowData.e)&&compareNumbers(state.data[i].n,state.lastClickedRowData.n)&&state.data[i].address==state.lastClickedRowData.address){search.listeners.broadcast("rowClick",state.data[i]);return;}}}});search.listeners.add("endRestoreState",function(state){search.ignoreRowClick=undefined;search.doNotCenter=undefined;});search.listeners.add("rowClick",function(obj,nodes){if(search.ignoreRowClick)return;if(lastRowClicked&&lastRowClicked.lid){var args={Lid:lastRowClicked.lid+'',checked:false};mapcat.broadcast("flash.menu.checkLayer",args);}
lastRowClicked=jQuery.extend(obj);if(Number(obj.oid)){if(!search.doNotCenter){centerToObject(obj);}else{putLocationMarker(obj,true);}}else{putLocationMarker(obj,search.doNotCenter);}},search);mapcat.addCallback("layer.visibilityChanged",function(groupId,layerId,visible){if(lastRowClicked&&lastRowClicked.lid==layerId&&visible==false){lastRowClicked.lid=null;}});mapcat.addCallback("locationMarker.buttonClick",function(action){switch(action){case'close':var first=true;lastRowClicked=null;search.listeners.broadcastEx(function(listener){if(first){first=false;return true;}else{return false;}},'rowClick',null);break;}});search.listeners.add("page",function(cur,total){if(total>1){$('#allResultsList, #resultsOnMap').addClass("paged");$('.list_footer').slideDown();}else{$('.list_footer').slideUp();$('.list_footer').queue(function(){$('#allResultsList, #resultsOnMapList').removeClass("paged");$('.list_footer').dequeue();});}
$('#allResultsPageNumber').text(cur+"/"+total);});search.listeners.add("tab",function(tab){$('#allResults')[tab==0?"addClass":"removeClass"]("active");$('#resultsOnMap')[tab==1?"addClass":"removeClass"]("active");});function putLocationMarker(obj,doNotCenter){var match=obj.address.match(/^((?:.{0,22}(?=,))|(?:.{0,40}(?=,))|.{0,22})/m);var stext=match[1];mapcat.broadcast("mapcat.makeSearchResult",{e:obj.e,n:obj.n,z:obj.z,name:obj.text,shortName:stext,oid:obj.oid,Lid:obj.lid,btnConf:{info:(obj.oid?true:false)},doNotCenter:doNotCenter});}
function centerToObject(obj){mapcat.broadcast("map.centerToObject",{Lid:obj.lid,obId:obj.oid});}
function getSearchResultsLayer(){if(!me.searchLayer){me.searchLayer='SEARCH_RESULTS_LAYER';mapcat.broadcast("layers.addSystemLayer",me.searchLayer);}
return me.searchLayer;};search.listeners.add("clear",function(){mapcat.broadcast("layers.clearSystemLayer",getSearchResultsLayer());mapcat.broadcast("mapcat.removeSearchResult");if(lastRowClicked&&lastRowClicked.lid){var args={Lid:lastRowClicked.lid+'',checked:false};mapcat.broadcast("flash.menu.checkLayer",args);}}).add("row",function(arr,childs){if(search.getCurTab()==1){childs[0].id=arr.num;$(childs).addClass("row");mapcat.broadcast("layers.addPointToSystemLayer",getSearchResultsLayer(),{objectId:arr.num,geo:[{e:arr.e,n:arr.n}],color:'D6951D',alpha:'80',symbolId:(arr.num>9)?'label2_'+arr.num:'label1_'+arr.num,tooltip:arr.address});$(childs).bind("mouseover",function(){mapcat.broadcast("objects.callOnRollOver",getSearchResultsLayer(),arr.num);});$(childs).bind("mouseout",function(){mapcat.broadcast("objects.callOnRollOut",getSearchResultsLayer(),arr.num);});}});mapcat.addCallback("objects.onMouseOver",function(args){$('#'+args.objectId,div).addClass("highlight");});mapcat.addCallback("objects.onMouseOut",function(){$('.row',div).removeClass("highlight");});return search;}


function InitRouting(div,mapcat,cfg){if(cfg&&cfg.noDescription){$('.routing_content').hide();}
var renderer=Regio.Route.CreateFlashTileRenderer(mapcat,cfg);var renderer2=function(updates,queryesCount,route,api,segments){for(var wayPointNum in updates){for(var segmentID in updates[wayPointNum]){updates[wayPointNum][segmentID].text=undefined;}}
renderer(updates,queryesCount,route,api,segments);}
var route=new Regio.Route(div,mapcat.listeners,{providers:{delfiRouting:Regio.Route.CreateLithuaniaProvider()},renderers:[renderer2]});mapcat.addCallback("map.onMapParams",function(args){with(args){var width=max_e-min_e,height=max_n-min_n;route.updateForBBox([min_e-width/2,min_n-height/2,max_e+width/2,max_n+height/2],100);}});route.listeners.add("requestStarted",function(type){$('.route_message').hide();$('.route_message_wait').show();}).add("requestError",function(desc){$('.route_message').hide();$('.route_message_error').show();}).add("requestComplete",function(desc){$('.route_message').hide();}).add("clearDescription",function(){$('.only_visible_when_route').hide();}).add("drawDescription",function(data,overview){$('.route_length').text(overview.length);$('.route_time').text(overview.time);$('.only_visible_when_route').show();});var routePoints={savedStartTxt:$('#startPoint').val(),savedEndTxt:$('#endPoint').val(),points:{},symbols:{start:"A",end:"B"},styles:{start:{color:"0091d5",alpha:80},end:{color:"d82727",alpha:80}},getLayerName:function(){if(!this.layer){this.layer="ROUTE_POINTS";mapcat.broadcast("layers.addSystemLayer",this.layer);}
return this.layer;},setPoint:function(which,e,n,txt,center,noCenteringToRoute){this.points[which]={e:e,n:n,txt:txt}
if(!txt)txt=Regio.Utils.format("{0}:{1}",e,n);$('#'+which+'Point').val(txt);if(center){mapcat.broadcast("map.center",{e:e,n:n,zoom:12});}
if(this.points.start&&this.points.end){this._startRoute([this.points.start,this.points.end],noCenteringToRoute);}
mapcat.broadcast("layers.addPointToSystemLayer",this.getLayerName(),{objectId:which,geo:[{e:e,n:n}],color:this.styles[which].color,alpha:this.styles[which].alpha,symbolId:this.symbols[which],tooltip:txt});},clear:function(){$('#startPoint').val(this.savedStartTxt);$('#endPoint').val(this.savedEndTxt);this.points=[];route.stopRouting();route.clearPoints();mapcat.broadcast("layers.clearSystemLayer",this.getLayerName());},swap:function(){var s=this.points['start'];var e=this.points['end'];if(s&&e){this.setPoint('start',e.e,e.n,e.txt);this.setPoint('end',s.e,s.n,s.txt);}},_startRoute:function(arr,noCenteringToRoute){route.stopRouting();route.clearPoints();route.addPoints(arr);route.startRouting(undefined,{noCentering:noCenteringToRoute});}};function isPointOverMask(e,n){var layerArray=mapcat.call('layers.getObjectsAtPoint',{e:e,n:n},{layers:['mask_layer']});if(layerArray.length){for(var i=0;i<layerArray.length;i++){if(layerArray[i].layerId=='mask_layer')return true;}}
return false;}
mapcat.addCallback("routing.startPointFixed",function(args,noCenteringToRoute){if(!isPointOverMask(args.lon,args.lat)){routePoints.setPoint("start",args.lon,args.lat,args.locationName,args.center,noCenteringToRoute);}
mapcat.broadcast("layers.removeSystemLayer","_ROUTE_POINTS");});mapcat.addCallback("routing.endPointFixed",function(args,noCenteringToRoute){if(!isPointOverMask(args.lon,args.lat)){routePoints.setPoint("end",args.lon,args.lat,args.locationName,args.center,noCenteringToRoute);}
mapcat.broadcast("layers.removeSystemLayer","_ROUTE_POINTS");});mapcat.addCallback("routing.clear",function(){routePoints.clear();});$('.route_message').hide();(function(){$a=$(".routingAButton");$b=$(".routingBButton");var active="active";$a.click(function(){if($a.hasClass(active)){$a.removeClass(active);mapcat.broadcast('mapcat.stopEditMode');}else{$a.addClass(active);$b.removeClass(active);mapcat.broadcast('routing.placeRouteStartPoint');}
return false;});$b.click(function(){if($b.hasClass(active)){$b.removeClass(active);mapcat.broadcast('mapcat.stopEditMode');}else{$b.addClass(active);$a.removeClass(active);mapcat.broadcast('routing.placeRouteEndPoint');}
return false;});var deselect=function(){$a.removeClass(active);$b.removeClass(active);}
mapcat.addCallback("routing.endPointFixed",deselect);mapcat.addCallback("routing.startPointFixed",deselect);})();$('.routingSwapButton').click(function(){routePoints.swap();return false;});$('.generate_random_route_points').click(function(){route.addPoints([{e:679270,n:6491249},{e:642145,n:6456186}]);return false;}).attr('href','#');$('.start_routing').click(function(){route.startRouting();return false;}).attr('href','#');$('.stop_routing').click(function(){route.stopRouting();return false;}).attr('href','#');$('.clear_route_points').click(function(){routePoints.clear();return false;}).attr('href','#');route.clearAll=function(){routePoints.clear();}
route.routePoints=routePoints;return route;}


if(typeof(jQuery)=='undefined'){throw new Error('Email requires jQuery!');}
if(typeof(MapCat)=="undefined"){throw new Error('Regio.Route requires MapCat API v2!');}
if(!Regio.Components){Regio.Components={}}
Regio.Components.Email=function(mapcat,cfg){this.data=new Object();this.last_data=new Object();this.busy=false;var me=this;if(!cfg.lang)lang={missingRecipient:'Recipient not specified',missingSender:'Sender not specified',requestError:'Service unavailable',sendFailed:'Send failed'};else lang=cfg.lang;mapcat.addCallback('email.send',_sendRequest);if(!cfg.url)alert('Specify URL');if(!cfg.method)cfg.method='POST';if(!cfg.success)cfg.success=function(){alert('Email send success');}
if(!cfg.error)cfg.error=function(error){alert(error);}
this.open=function(bug){mapcat.broadcast('email.open',bug);}
this.close=function(){mapcat.broadcast('email.close');}
function checkData(args){if(args.to==null)throw new Error(lang.missingRecipient);if(cfg.fromRequired&&args.from==null)throw new Error(lang.missingSender);}
function _sendRequest(args){if(me.busy)return;try{for(var p in args)if(args[p]=='null')args[p]=null;checkData(args);}catch(e){if(cfg.alert)alert(e);return;}
me.data.to=args.to;me.data.from=args.from;me.data.text=args.text;if(areSimilar(me.data,me.last_data))return;me.busy=true;$.ajax({url:cfg.url,type:cfg.method,dataType:"json",data:me.data,success:function(data){if(data&&data.success){me.last_data=jQuery.extend({},me.data);cfg.success();}else{if(data.error){cfg.error(data.error);}else{cfg.error(lang.sendFailed);}}},complete:function(XMLHttpRequest,textStatus){me.busy=false;},error:function(XMLHttpRequest,textStatus,errorThrown){cfg.error(lang.requestError);}});}
function areSimilar(obj1,obj2){if(!obj1&&!obj2){return true;}
if(!obj1||!obj2){return false;}
for(var p1 in obj1){if(obj1[p1]!==obj2[p1]){return false;}}
for(var p2 in obj2){if(obj1[p2]!==obj2[p2]){return false;}}
return true;}
return this;}


Regio.Dialog=function(userConf,div){var _defConf={onSubmit:null,closeOnSubmit:true,listenOpenClose:true,title:'Send email',width:"auto",height:"auto",modal:false};var cfg=jQuery.extend(_defConf,userConf);if(!div)div=$('<div/>');var dialog=$(div).dialog({autoOpen:false,width:cfg.width||"auto",height:cfg.height||"auto",title:cfg.title||"",modal:cfg.modal});$(div).show();function open(){dialog.dialog("open");}
function close(){dialog.dialog("close");}
function getData(form){if(!form)form=$('form',dialog);if(!form)form=$(dialog);var data={};$('select,input,textarea',form).each(function(){var name=$(this).attr('name');if(name){data[name]=$(this).val();}});return data;}
function submit(arguments){if(typeof callback=='function'){cfg.onSubmit=callback;return;}else if(typeof cfg.onSubmit=='function'){cfg.onSubmit(getData(arguments),arguments);if(cfg.closeOnSubmit){close();}}}
function initialise(){$('form',dialog).submit(function(){submit(this);return false;});}
dialog.open=open;dialog.close=close;dialog.getData=getData;dialog.submit=submit;dialog.initialise=initialise;initialise();return dialog;}


function InitMapControl(mapcat,params){mapControl={};mapControl.params=params;mapControl.MASKREQUEST_REQUEST_IN='getMaskObject';mapControl.maskWKT=null;mapControl.maskColor='738aa0';mapControl.maskAlpha=80;mapControl.rulerOn=false;if(params.maskColor)mapControl.maskColor=params.maskColor;if(params.maskAlpha)mapControl.maskAlpha=params.maskAlpha;mapControl.getMask=function(){var me=this;$.ajax({url:"map.php",type:"POST",dataType:"json",data:{"in":this.MASKREQUEST_REQUEST_IN,"base_id":base_id},success:function(data){if(data.result){me.maskWKT=data.wkt;mapControl.setMask();}else{alert('No mask loaded');}}});}
mapControl.setMask=function(){mapcat.ready(function(){mapcat.broadcast('layers.addSystemLayer','mask_layer');mapcat.broadcast('layers.addObjectToSystemLayer','mask_layer',{objectId:'mask',wkt:mapControl.maskWKT,style:{area:{fillColor:mapControl.maskColor,fillAlpha:mapControl.maskAlpha,lineColor:mapControl.maskColor,lineWidth:0,lineAlpha:0}},noRolloverEffect:true});});}
mapControl.sendEmail=function(){}
mapControl.print=function(){var args=mapcat.call('map.getMapState');var url='print.php?id='+base_id+'&min_n='+args.min_n+'&min_e='+args.min_e+'&max_n='+args.max_n+'&max_e='+args.max_e+'&init_zoom='+args.zoom+'&navi='+args.navi+'&cur_map='+args.cur_map;if(args.lids){url+='&lids='+Layers.tree.getCheckedLayers().join(';')+'&addUrls='+escape(args.addUrls);}
var printWindow=window.open(url,"printPreview","channelmode=0,directories=0,fullscreen=0,location=1,menubar=1,status=0,titlebar=0,toolbar=0,width=636,resizable=1,scrollbars=1",false);}
if(params.mask){mapControl.getMask();}
mapcat.addCallback('mapcat.makeSearchResult',function(args){mapControl.searchResult=args;});mapcat.addCallback("locationMarker.buttonClick",function(action){switch(action){case'info':mapcat.broadcast('info.open',{header:mapControl.searchResult.name,url:'info.php?id='+mapControl.searchResult.oid});break;}});return mapControl;}