(function($){

$.scf.behavior.add('aHrefTargetBehaviour',{autoAttach:"a.target_blank",attach:function(el,settings,jQ){jQ.click(function(){var href=this.href;if(href){window.open(href,"_blank");return false;}});}});$.scf.behavior.add('Anchor',{autoAttach:".Anchor",attach:function(element,settings,jq){var cls=settings.className?settings.className:'External';var hostHeader=null;var hhRegex=/^\s*http:\/\/([\w\.\-]+)/;var match=hhRegex.exec(window.location);if(match!=null&&match.length==2)
hostHeader=match[1];var els=element.getElementsByTagName('A');for(var l=els.length,i=0;i<l;i++){var a=els[i];var hrefHH=null;match=hhRegex.exec(a.getAttribute('href',2));if(match!=null&&match.length==2)
hrefHH=match[1];if(hrefHH!=null&&hrefHH!=hostHeader&&!$(a).hasClass("NoExternalLink"))
$(a).addClass(cls,false).attr('target','_blank');}}})
$.scf.behavior.add('AutoLoad',{attach:function(el){if(el.firstChild&&el.firstChild.tagName=="A"){new System.Ajax().send(el.firstChild.href,{element:el,force:true});}}});$.scf.behavior.add("AutoSuggest",{attach:function(el,settings,jq){el.provider=new _Suggestions();new AutoSuggestTextbox(el,el.provider);jq.focus(function(){if(!el.loaded){if(settings.url){var x=new jQuery.ajax({url:settings.url,complete:function(x){el.loaded=true;el.provider.list=eval(x.responseText);},force:true});}
else if(el.list){el.loaded=true;el.provider.list=el.list;}}});},detach:function(el){el.behavior=null;}})
function _Suggestions(){this.list=[]}
_Suggestions.prototype={requestSuggestions:function(control,bTypeAhead){var aSuggestions=[];var sTextboxValue=control.textbox.value.toLowerCase();if(sTextboxValue.length>0){for(var i=0;i<this.list.length;i++){if(this.list[i].toLowerCase().indexOf(sTextboxValue)==0){aSuggestions.push(this.list[i]);}}}
control.autosuggest(aSuggestions,bTypeAhead);},load:function(){}}
function AutoSuggestTextbox(el,provider){this.cur=-1;this.layer=null;this.provider=provider;this.textbox=el;this.attach();el.provider=provider;}
AutoSuggestTextbox.prototype.autosuggest=function(aSuggestions,bTypeAhead){if(aSuggestions.length>0){if(bTypeAhead){this.typeAhead(aSuggestions[0]);}
this.showSuggestions(aSuggestions);}else{this.hideSuggestions();}};AutoSuggestTextbox.prototype.createDropDown=function(){var me=this;this.layer=document.createElement("div");this.layer.className="AutoSuggest";this.layer.style.visibility="hidden";this.layer.style.width=this.textbox.offsetWidth;this.layer.onmousedown=this.layer.onmouseup=this.layer.onmouseover=function(ev){ev=ev||window.event;oTarget=ev.target||ev.srcElement;if(ev.type=="mousedown"){me.textbox.value=oTarget.firstChild.nodeValue;me.hideSuggestions();}else if(ev.type=="mouseover"){me.highlightSuggestion(oTarget);}else{me.textbox.focus();}};document.body.appendChild(this.layer);};AutoSuggestTextbox.prototype.handleKeyDown=function(ev){switch(ev.keyCode){case 13:case 27:this.hideSuggestions();ev.stopPropagation();ev.returnValue=true;break;case 38:this.previousSuggestion();break;case 40:this.nextSuggestion();break;}};AutoSuggestTextbox.prototype.handleKeyUp=function(ev){var iKeyCode=ev.keyCode;if(iKeyCode==8||iKeyCode==46){this.provider.requestSuggestions(this,false);}
else if(iKeyCode==13){this.hideSuggestions();ev.stopPropagation();ev.returnValue=true;}
else if(iKeyCode<32||(iKeyCode>=33&&iKeyCode<46)||(iKeyCode>=112&&iKeyCode<=123)){}else{this.provider.requestSuggestions(this,true);}};AutoSuggestTextbox.prototype.hideSuggestions=function(){this.layer.style.visibility="hidden";};AutoSuggestTextbox.prototype.highlightSuggestion=function(oSuggestionNode){for(var i=0;i<this.layer.childNodes.length;i++){var oNode=this.layer.childNodes[i];if(oNode==oSuggestionNode){oNode.className="Current"}else if(oNode.className=="Current"){oNode.className="";}}};AutoSuggestTextbox.prototype.attach=function(){var me=this;$(this.textbox).keyup(function(ev){me.handleKeyUp(ev)}).keydown(function(ev){me.handleKeyDown(ev)}).blur(function(ev){me.hideSuggestions(ev)});this.createDropDown();};AutoSuggestTextbox.prototype.nextSuggestion=function(){var me=this;var nodes=this.layer.childNodes;if(nodes.length>0&&this.cur<nodes.length-1){var oNode=nodes[++this.cur];me.highlightSuggestion(oNode);me.textbox.value=oNode.firstChild.nodeValue;}};AutoSuggestTextbox.prototype.previousSuggestion=function(){var nodes=this.layer.childNodes;if(nodes.length>0&&this.cur>0){var oNode=nodes[--this.cur];this.highlightSuggestion(oNode);this.textbox.value=oNode.firstChild.nodeValue;}};AutoSuggestTextbox.prototype.selectRange=function(iStart,iLength){if(this.textbox.createTextRange){var oRange=this.textbox.createTextRange();oRange.moveStart("character",iStart);oRange.moveEnd("character",iLength-this.textbox.value.length);oRange.select();}else if(this.textbox.setSelectionRange){this.textbox.setSelectionRange(iStart,iLength);}
this.textbox.focus();};AutoSuggestTextbox.prototype.showSuggestions=function(aSuggestions){var oDiv=null;this.layer.innerHTML="";for(var i=0;i<aSuggestions.length;i++){oDiv=document.createElement("div");oDiv.appendChild(document.createTextNode(aSuggestions[i]));this.layer.appendChild(oDiv);}
var pos=$(this.textbox).offset();this.layer.style.left=(pos.left)+"px";this.layer.style.top=(pos.top+this.textbox.offsetHeight)+"px";this.layer.style.visibility="visible";};AutoSuggestTextbox.prototype.typeAhead=function(sSuggestion){if(this.textbox.createTextRange||this.textbox.setSelectionRange){var iLen=this.textbox.value.length;this.textbox.value=sSuggestion;this.selectRange(iLen,sSuggestion.length);}};$.scf.behavior.add('Confirm',{attach:function(element,settings){var e=element.onclick;if(e){element.onclick=function(event){var i=confirm(settings.prompt||"Are you sure?");if(i)e(event);}}}});window.getCookie=function(name,defaultValue){if(defaultValue==undefined)defaultValue=null;var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i=0;while(i<clen){var j=i+alen;if(document.cookie.substring(i,j)==arg)
return getCookieVal(j);i=document.cookie.indexOf(" ",i)+1;if(i==0)break;}
return defaultValue;}
window.getCookieVal=function(offset){var endstr=document.cookie.indexOf(";",offset);if(endstr==-1)
endstr=document.cookie.length;return unescape(document.cookie.substring(offset,endstr));}
$.scf.behavior.add('ScfFormBehavior',{autoAttach:"form.CoolForm, form.Scf",attach:function(el,settings,jQ){var form=el;form.focusListeners=[];jQ.find("label").css({textOverflow:'ellipsis'});var _signalFocusListeners=function(evName,ev,element){for(var i=0;i<form.focusListeners.length;i++){form.focusListeners[i](evName,ev,element)}}
window.getForm=function(el){if(el.form)
return el.form;while(el!=null&&el.tagName!='FORM')
el=el.parentNode;return el;};form.attachFocusChange=function(handler){form.focusListeners.push(handler);};form.getOuter=function(el){var oe;if(el.formElement)
oe=document.getElementById(el.formElement.name);else if(!el.name){oe=el;while(oe.parentNode){oe=oe.parentNode;if(oe.formElement){oe=document.getElementById(oe.formElement.name);break;}}}
else if(el.name)
oe=document.getElementById(el.name);if(oe)
return oe;else
return el;};form.getLabel=function(el){if(el){el=form.getOuter(el);if(el.attachedLabel)
return el.attachedLabel;var id=el.id;var lbls=form.getElementsByTagName("LABEL"),n=lbls.length;for(i=0;i<n;i++){if(lbls[i].htmlFor==id){el.attachedLabel=lbls[i];return lbls[i];}}}};form.getData=function(){var obj={};for(var fe=form.elements,l=fe.length,i=0;i<l;i++){var p=fe[i];if(!p.name||p.type=="submit")
continue;if($(p).hasClass('Invalid')){var t=p.name,l=el.getLabel(p);if(l)
t=l.innerText;alert("The field '"+t+"' does not currently validate. Please enter a correct value.");p.focus();return null;}
var value=p.value;if(p.type=="checkbox"){value=(p.checked);}
else if(p.type=="text"){if($(p).hasClass("NumericControl")||$(p).hasClass("IntegerControl")||$(p).hasClass("FloatControl")){try{if(p.value.length!=0){value=(new Number(p.value)).valueOf();}}catch(e){alert("The field '"+t+"' should contain a numeric value.");p.focus();return null;}}}
obj[p.name]=value;}
return obj;};var blur=function(event){event=event||window.event;var src=event.srcElement||event.target;_signalFocusListeners('blur',event,src);var label=form.getLabel(src);if(label)
$(label).removeClass('Focus');}
var focus=function(event){event=event||window.event;var src=event.srcElement||event.target;_signalFocusListeners('focus',event,src);var label=form.getLabel(src);if(label)
$(label).addClass('Focus');}
if(el.addEventListener){el.addEventListener('focus',focus,true);el.addEventListener('blur',blur,true);}
else{el.onfocusin=focus;el.onfocusout=blur;}
$(".Required",el).scf.behavior(function(e,s,j){var label=form.getLabel(e);if(label)$(label).addClass('Required');});}});$.scf.behavior.add('SideBar',{autoAttach:".CoolForm .SideBar",attach:function(el,settings){var form=window.getForm(el);if(form){this.show=function(evName,ev,src){if(evName=='focus'){var l=form.getLabel(src);if(l){el.innerHTML="<h3>"+l.innerHTML+"</h3>"+l.title;var outer=form.getOuter(src);var p=System.DOM.locate(outer);var fs=System.DOM.getElement(src,'FIELDSET');var q=System.DOM.locate(fs);el.style.left=q.x+fs.offsetWidth-el.offsetWidth;el.style.top=p.y;}}
el.style.visibility=(evName=='focus')?'visible':'hidden';}
form.attachFocusChange(this.show);}},detach:function(el){}});$.scf.behavior.add('eMail',{autoAttach:"form.CoolForm input.eMail",attach:function(element,settings,jq){var f=function(event){if(!/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(element.value)){jq.removeClass("Valid").addClass("Invalid");}
else{jq.removeClass("Invalid").addClass("Valid");}}
jq.change(f);}});$.scf.behavior.add('FormHelp',{autoAttach:"form.CoolForm div.FormHelp",attach:function(el,settings,jq){var form=window.getForm(el),legend=$("legend",form).get(0);var setValue=function(l){if(l&&l.title)
jq.html("<h3>"+$(l).text()+"</h3>"+l.title);else if(legend)
setValue(legend);}
if(form){this.show=function(evName,ev,src){if(evName=='focus'){setValue(form.getLabel(src));}}
form.attachFocusChange(this.show);setValue(legend);}}});jQuery.fn.corners=function(options){var doneClass='rounded_by_jQuery_corners';var settings=parseOptions(options);var webkitAvailable=false;try{webkitAvailable=(document.body.style.WebkitBorderRadius!==undefined);var versionIndex=navigator.userAgent.indexOf('Chrome');if(versionIndex>=0)webkitAvailable=false;}catch(err){}
var mozillaAvailable=false;try{mozillaAvailable=(document.body.style.MozBorderRadius!==undefined);var versionIndex=navigator.userAgent.indexOf('Firefox');if(versionIndex>=0&&parseInt(navigator.userAgent.substring(versionIndex+8))<3)mozillaAvailable=false;}catch(err){}
return this.each(function(i,e){$e=jQuery(e);if($e.hasClass(doneClass))return;$e.addClass(doneClass);var classScan=/{(.*)}/.exec(e.className);var s=classScan?parseOptions(classScan[1],settings):settings;var nodeName=e.nodeName.toLowerCase();if(nodeName=='input')e=changeInput(e);if(webkitAvailable&&s.webkit)roundWebkit(e,s);else if(mozillaAvailable&&s.mozilla&&(s.sizex==s.sizey))roundMozilla(e,s);else{var bgColor=backgroundColor(e.parentNode);var fgColor=backgroundColor(e);switch(nodeName){case'a':case'input':roundLink(e,s,bgColor,fgColor);break;default:roundDiv(e,s,bgColor,fgColor);break;}}});function roundWebkit(e,s){var radius=''+s.sizex+'px '+s.sizey+'px';var $e=jQuery(e);if(s.tl)$e.css('WebkitBorderTopLeftRadius',radius);if(s.tr)$e.css('WebkitBorderTopRightRadius',radius);if(s.bl)$e.css('WebkitBorderBottomLeftRadius',radius);if(s.br)$e.css('WebkitBorderBottomRightRadius',radius);}
function roundMozilla(e,s)
{var radius=''+s.sizex+'px';var $e=jQuery(e);if(s.tl)$e.css('-moz-border-radius-topleft',radius);if(s.tr)$e.css('-moz-border-radius-topright',radius);if(s.bl)$e.css('-moz-border-radius-bottomleft',radius);if(s.br)$e.css('-moz-border-radius-bottomright',radius);}
function roundLink(e,s,bgColor,fgColor){var table=tableElement("table");var tbody=tableElement("tbody");table.appendChild(tbody);var tr1=tableElement("tr");var td1=tableElement("td","top");tr1.appendChild(td1);var tr2=tableElement("tr");var td2=relocateContent(e,s,tableElement("td"));tr2.appendChild(td2);var tr3=tableElement("tr");var td3=tableElement("td","bottom");tr3.appendChild(td3);if(s.tl||s.tr){tbody.appendChild(tr1);addCorners(td1,s,bgColor,fgColor,true);}
tbody.appendChild(tr2);if(s.bl||s.br){tbody.appendChild(tr3);addCorners(td3,s,bgColor,fgColor,false);}
e.appendChild(table);if(jQuery.browser.msie)table.onclick=ieLinkBypass;e.style.overflow='hidden';}
function ieLinkBypass(){if(!this.parentNode.onclick)this.parentNode.click();}
function changeInput(e){var a1=document.createElement("a");a1.id=e.id;a1.className=e.className;if(e.onclick){a1.href='javascript:'
a1.onclick=e.onclick;}else{jQuery(e).parent('form').each(function(){a1.href=this.action;});a1.onclick=submitForm;}
var a2=document.createTextNode(e.value);a1.appendChild(a2);e.parentNode.replaceChild(a1,e);return a1;}
function submitForm(){jQuery(this).parent('form').each(function(){this.submit()});return false;}
function roundDiv(e,s,bgColor,fgColor){var div=relocateContent(e,s,document.createElement('div'));e.appendChild(div);if(s.tl||s.tr)addCorners(e,s,bgColor,fgColor,true);if(s.bl||s.br)addCorners(e,s,bgColor,fgColor,false);}
function relocateContent(e,s,d){var $e=jQuery(e);var c;while(c=e.firstChild)d.appendChild(c);if(e.style.height){var h=parseInt($e.css('height'));d.style.height=h+'px';h+=parseInt($e.css('padding-top'))+parseInt($e.css('padding-bottom'));e.style.height=h+'px';}
if(e.style.width){var w=parseInt($e.css('width'));d.style.width=w+'px';w+=parseInt($e.css('padding-left'))+parseInt($e.css('padding-right'));e.style.width=w+'px';}
d.style.paddingLeft=$e.css('padding-left');d.style.paddingRight=$e.css('padding-right');if(s.tl||s.tr){d.style.paddingTop=adjustedPadding(e,s,$e.css('padding-top'),true);}else{d.style.paddingTop=$e.css('padding-top');}
if(s.bl||s.br){d.style.paddingBottom=adjustedPadding(e,s,$e.css('padding-bottom'),false);}else{d.style.paddingBottom=$e.css('padding-bottom');}
e.style.padding=0;return d;}
function adjustedPadding(e,s,pad,top){if(pad.indexOf("px")<0){try{console.error('%s padding not in pixels',(top?'top':'bottom'),e);}
catch(err){}
pad=s.sizey+'px';}
pad=parseInt(pad);if(pad-s.sizey<0){try{console.error('%s padding is %ipx for %ipx corner:',(top?'top':'bottom'),pad,s.sizey,e);}
catch(err){}
pad=s.sizey;}
return pad-s.sizey+'px';}
function tableElement(kind,valign){var e=document.createElement(kind)
e.style.border='none';e.style.borderCollapse='collapse';e.style.borderSpacing=0;e.style.padding=0;e.style.margin=0;if(valign)e.style.verticalAlign=valign;return e;}
function backgroundColor(e){try{var c=jQuery.css(e,"background-color");if(c.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&e.parentNode)
return backgroundColor(e.parentNode);if(c==null)
return"#ffffff";if(c.indexOf("rgb")>-1)
c=rgb2hex(c);if(c.length==4)
c=hexShort2hex(c);return c;}catch(err){return"#ffffff";}}
function hexShort2hex(c){return'#'+
c.substring(1,2)+
c.substring(1,2)+
c.substring(2,3)+
c.substring(2,3)+
c.substring(3,4)+
c.substring(3,4);}
function rgb2hex(c){var x=255;var hex='';var i;var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;var array=regexp.exec(c);for(i=1;i<4;i++)hex+=('0'+parseInt(array[i]).toString(16)).slice(-2);return'#'+hex;}
function parseOptions(options,settings){var options=options||'';var s={sizex:5,sizey:5,tl:false,tr:false,bl:false,br:false,webkit:true,mozilla:true,transparent:false};if(settings){s.sizex=settings.sizex;s.sizey=settings.sizey;s.webkit=settings.webkit;s.transparent=settings.transparent;s.mozilla=settings.mozilla;}
var sizex_set=false;var corner_set=false;jQuery.each(options.split(' '),function(idx,option){option=option.toLowerCase();var i=parseInt(option);if(i>0&&option==i+'px'){s.sizey=i;if(!sizex_set)s.sizex=i;sizex_set=true;}else switch(option){case'no-native':s.webkit=s.mozilla=false;break;case'webkit':s.webkit=true;break;case'no-webkit':s.webkit=false;break;case'mozilla':s.mozilla=true;break;case'no-mozilla':s.mozilla=false;break;case'anti-alias':s.transparent=false;break;case'transparent':s.transparent=true;break;case'top':corner_set=s.tl=s.tr=true;break;case'right':corner_set=s.tr=s.br=true;break;case'bottom':corner_set=s.bl=s.br=true;break;case'left':corner_set=s.tl=s.bl=true;break;case'top-left':corner_set=s.tl=true;break;case'top-right':corner_set=s.tr=true;break;case'bottom-left':corner_set=s.bl=true;break;case'bottom-right':corner_set=s.br=true;break;}});if(!corner_set){if(!settings){s.tl=s.tr=s.bl=s.br=true;}else{s.tl=settings.tl;s.tr=settings.tr;s.bl=settings.bl;s.br=settings.br;}}
return s;}
function alphaBlend(a,b,alpha){var ca=Array(parseInt('0x'+a.substring(1,3)),parseInt('0x'+a.substring(3,5)),parseInt('0x'+a.substring(5,7)));var cb=Array(parseInt('0x'+b.substring(1,3)),parseInt('0x'+b.substring(3,5)),parseInt('0x'+b.substring(5,7)));r='0'+Math.round(ca[0]+(cb[0]-ca[0])*alpha).toString(16);g='0'+Math.round(ca[1]+(cb[1]-ca[1])*alpha).toString(16);b='0'+Math.round(ca[2]+(cb[2]-ca[2])*alpha).toString(16);return'#'
+r.substring(r.length-2)
+g.substring(g.length-2)
+b.substring(b.length-2);}
function addCorners(e,s,bgColor,fgColor,top){if(s.transparent)addTransparentCorners(e,s,bgColor,top);else addAntiAliasedCorners(e,s,bgColor,fgColor,top);}
function addAntiAliasedCorners(e,s,bgColor,fgColor,top){var i,j;var d=document.createElement("div");d.style.fontSize='1px';d.style.backgroundColor=bgColor;var lastarc=0;for(i=1;i<=s.sizey;i++){var coverage,arc2,arc3;arc=Math.sqrt(1.0-Math.pow(1.0-i/s.sizey,2))*s.sizex;var n_bg=s.sizex-Math.ceil(arc);var n_fg=Math.floor(lastarc);var n_aa=s.sizex-n_bg-n_fg;var x=document.createElement("div");var y=d;x.style.margin="0px "+n_bg+"px";x.style.height='1px';x.style.overflow='hidden';for(j=1;j<=n_aa;j++){if(j==1){if(j==n_aa){coverage=((arc+lastarc)*.5)-n_fg;}
else{arc2=Math.sqrt(1.0-Math.pow(1.0-(n_bg+1)/s.sizex,2))*s.sizey;coverage=(arc2-(s.sizey-i))*(arc-n_fg-n_aa+1)*.5;}}
else if(j==n_aa){arc2=Math.sqrt(1.0-Math.pow((s.sizex-n_bg-j+1)/s.sizex,2))*s.sizey;coverage=1.0-(1.0-(arc2-(s.sizey-i)))*(1.0-(lastarc-n_fg))*.5;}
else{arc3=Math.sqrt(1.0-Math.pow((s.sizex-n_bg-j)/s.sizex,2))*s.sizey;arc2=Math.sqrt(1.0-Math.pow((s.sizex-n_bg-j+1)/s.sizex,2))*s.sizey;coverage=((arc2+arc3)*.5)-(s.sizey-i);}
addCornerDiv(s,x,y,top,alphaBlend(bgColor,fgColor,coverage));y=x;var x=y.cloneNode(false);x.style.margin="0px 1px";}
addCornerDiv(s,x,y,top,fgColor);lastarc=arc;}
if(top)
e.insertBefore(d,e.firstChild);else
e.appendChild(d);}
function addCornerDiv(s,x,y,top,color){if(top&&!s.tl)x.style.marginLeft=0;if(top&&!s.tr)x.style.marginRight=0;if(!top&&!s.bl)x.style.marginLeft=0;if(!top&&!s.br)x.style.marginRight=0;x.style.backgroundColor=color;if(top)
y.appendChild(x);else
y.insertBefore(x,y.firstChild);}
function addTransparentCorners(e,s,bgColor,top){var d=document.createElement("div");d.style.fontSize='1px';var strip=document.createElement('div');strip.style.overflow='hidden';strip.style.height='1px';strip.style.borderColor=bgColor;strip.style.borderStyle='none solid';var sizex=s.sizex-1;var sizey=s.sizey-1;if(!sizey)sizey=1;for(var i=0;i<s.sizey;i++){var w=sizex-Math.floor(Math.sqrt(1.0-Math.pow(1.0-i/sizey,2))*sizex);if(i==2&&s.sizex==6&&s.sizey==6)w=2;var x=strip.cloneNode(false);x.style.borderWidth='0 '+w+'px';if(top)x.style.borderWidth='0 '+(s.tr?w:0)+'px 0 '+(s.tl?w:0)+'px';else x.style.borderWidth='0 '+(s.br?w:0)+'px 0 '+(s.bl?w:0)+'px';top?d.appendChild(x):d.insertBefore(x,d.firstChild);}
if(top)
e.insertBefore(d,e.firstChild);else
e.appendChild(d);}};(function($){$.fn.indexer=function(name){return this[0]&&indexer(this[0],name)||null;};$.indexer=function(name){return indexer(document,name);};var $event=$.event,$special=$event.special,$listen=$.listen=function(name,listener,selector,handler){if(typeof listener!='object'){handler=selector;selector=listener;listener=document;}
each(name.split(/\s+/),function(ev){ev=$listen.fixes[ev]||ev;var idxer=indexer(listener,ev)||indexer(listener,ev,new Indexer(ev,listener));idxer.append(selector,handler);idxer.start();});},indexer=function(elem,name,val){return $.data(elem,name+'.indexer',val);};$.extend($listen,{regex:/^((?:\w*?|\*))(?:([#.])([\w-]+))?$/,fixes:{focus:'focusin',blur:'focusout'},cache:function(on){this.caching=on;}});$.each($listen.fixes,function(original,fix){$special[fix]={setup:function(){if($.browser.msie)return false;this.addEventListener(original,$special[fix].handler,true);},teardown:function(){if($.browser.msie)return false;this.removeEventListener(original,$special[fix].handler,true);},handler:function(e){arguments[0]=e=$event.fix(e);e.type=fix;return $event.handle.apply(this,arguments);}};});$.fn.listen=function(name,selector,handler){return this.each(function(){$listen(name,this,selector,handler);});};function Indexer(name,listener){$.extend(this,{ids:{},tags:{},listener:listener,event:name});this.id=Indexer.instances.push(this);};Indexer.instances=[];Indexer.prototype={constructor:Indexer,handle:function(e){var sp=e.stopPropagation;e.stopPropagation=function(){e.stopped=true;sp.apply(this,arguments);};indexer(this,e.type).parse(e);e.stopPropagation=sp;sp=e.data=null;},on:false,bubbles:false,start:function(){if(!this.on){$event.add(this.listener,this.event,this.handle);this.on=true;}},stop:function(){if(this.on){$event.remove(this.listener,this.event,this.handle);this.on=false;}},cache:function(node,handlers){return $.data(node,'listenCache_'+this.id,handlers);},parse:function(e){var node=e.data||e.target,args=arguments,handlers;if(!$listen.caching||!(handlers=this.cache(node))){handlers=[];if(node.id&&this.ids[node.id])
push(handlers,this.ids[node.id]);each([node.nodeName,'*'],function(tag){var klasses=this.tags[tag];if(klasses)
each((node.className+' *').split(' '),function(klass){if(klass&&klasses[klass])
push(handlers,klasses[klass]);});},this);if($listen.caching)
this.cache(node,handlers);}
if(handlers[0]){each(handlers,function(handler){if(handler.apply(node,args)===false){e.preventDefault();e.stopPropagation();}});}
if(!e.stopped&&(node=node.parentNode)&&(node.nodeName=='A'||this.bubbles&&node!=this.listener)){e.data=node;this.parse(e);}
handlers=args=node=null;},append:function(selector,handler){each(selector.split(/\s*,\s*/),function(selector){var match=$listen.regex.exec(selector);if(!match)
throw'$.listen > "'+selector+'" is not a supported selector.';var
id=match[2]=='#'&&match[3],tag=match[1].toUpperCase()||'*',klass=match[3]||'*';if(id)
(this.ids[id]||(this.ids[id]=[])).push(handler);else if(tag){tag=this.tags[tag]=this.tags[tag]||{};(tag[klass]||(tag[klass]=[])).push(handler);}},this);}};function each(arr,fn,scope){for(var i=0,l=arr.length;i<l;i++)
fn.call(scope,arr[i],i);};function push(arr,elems){arr.push.apply(arr,elems);return arr;};$(window).unload(function(){if(typeof Indexer=='function')
each(Indexer.instances,function(idxer){idxer.stop();$.removeData(idxer.listener,idxer.event+'.indexer');idxer.ids=idxer.names=idxer.listener=null;});});})(jQuery);$.scf.behavior.add('LinkPopup',{attach:function(el,settings,jq){el.show=function(){$.scf.behavior.Current.addClass(el,'ShowPopup');};jq.addClass('Hidden');el.link=document.createElement("A");el.link.href="#na";el.link.innerHTML=el.title;el.title="";el.link.onmouseover=function(){if(el.showTmr)clearTimeout(el.showTmr);el.showTmr=setTimeout(el.show,1000);}
el.link.onmouseout=function(){if(el.showTmr)clearTimeout(el.showTmr)};el.link.onclick=el.show;el.parentNode.insertBefore(el.link,el);},detach:function(el){}});$.scf.behavior.add('ShowPopup',{attach:function(el,settings,jq){if(!el.close){el.hide=function(){$.scf.behavior.Current.removeClass(el,'ShowPopup')};jq.click(function(event){el.releaseCapture();var src=event.target;if(src.tagName!='INPUT'&&src.tagName!='LABEL')el.hide();});}
var c=el.getElementsByTagName('INPUT');if(c&&c.length>0)c[0].focus();el.style.cursor='default';el.setCapture();},detach:function(el){}});$.scf.behavior.add("ListView",{attach:function(element,settings){if(!element||element.tagName!="TABLE")return;var a=element.getElementsByTagName("thead");if(a){var tbl=document.createElement("table");tbl.className=element.className;tbl.style.height='10px';tbl.style.borderCollapse="collapse";var thead=document.createElement("thead");tbl.appendChild(thead);System.DOM.insert(element,tbl);var ok=System.DOM.swapNodes(a[0],thead,true);var size=function(){a=tbl.getElementsByTagName("thead")[0].getElementsByTagName('th');for(var i=0;i<a.length;i++){a[i].style.width=(element.rows[0].cells[i].offsetWidth-5)+'px';a[i].style.overflow="hidden";a[i].style.textOverflow="ellipsis";a[i].title=a[i].innerText;}}
setTimeout(size,1);System.Event.add(window,'resize',size);}
a=element.getElementsByTagName("td"),l=a.length;for(var i=0;i<l;i++){var span=document.createElement("SPAN");span.innerHTML=a[i].innerHTML;a[i].innerHTML="";a[i].appendChild(span);}
var div=document.createElement("DIV");element.parentNode.insertBefore(div,element.nextSibling);var span=document.createElement("SPAN");div.appendChild(span);div.style.overflow="auto";if(element.currentStyle){div.style.border=element.currentStyle.border||"1px solid #aaa";element.style.border="";div.style.height=element.currentStyle.height;}
System.DOM.swapNodes(span,element);},detach:function(event){}});$.scf.behavior.add('LoginForm',{attach:function(el,options,jQ){if(!options||!options.currentChallenge)
return;el.login=function(){if(el.tagName!="FORM")
return;if(typeof(options.currentChallenge)=="undefined")
throw new Error(23553,"currentChallenge variable not set");if(typeof(options.usePwdHashing)=="undefined")
throw new Error(23554,"usePwdHashing variable not set");if(options.hashedStorage&&!options.usePwdHashing)
options.usePwdHashing=true;var pwdInput=null;for(i=0;i<el.elements.length;i++){if(el.elements[i].type=="password"){pwdInput=el.elements[i];break;}}
if(pwdInput==null)throw new Error(23555,'Pasword control not found');if(pwdInput.value.length==0)
return;var encryptOrHash=function(s){if(options.usePwdHashing){if(typeof(MD5)!="function")throw new Error(23556,'MD5 function not found');if(options.hashedStorage)
s=MD5(s).toUpperCase();return MD5(s+options.currentChallenge).toUpperCase();}
else{return $.scf.convert.base64.encode(s+"__"+options.currentChallenge);}}
var address=el.action,hash,passwd=pwdInput.value;if(address.indexOf("?")==-1)address+="?";else address+="&"
if(navigator.userAgent.indexOf("Mozilla/")==0&&(parseInt(navigator.appVersion)>=4)){if(passwd)hash=encryptOrHash(passwd);else hash="";var js=0,n=0;for(i=0;i<el.elements.length;i++){if(el.elements[i].tagName=="FIELDSET"||!el.elements[i].name)
continue;if(el.elements[i].name.length<=0||el.elements[i].name.charAt(0)=="_"){continue;}
if(n>0)address+="&";address+=el.elements[i].name;address+="=";if(el.elements[i]==pwdInput)
address+=hash;else if(el.elements[i].type=="checkbox"&&!el.elements[i].checked)
address+="";else if(el.elements[i].type=="radio"&&!el.elements[i].checked)
address+="";else if(el.elements[i].name==".save")
address+="1";else if(el.elements[i].name==".js"){js=1;address+="1";}
else
address+=escape(el.elements[i].value);n++;}
address+="&.hash="+(options.usePwdHashing?"1":"0");if(js==0)
address+="&.js=1";address+="&.md5=1";location.href=address;el.onsubmit=null;return false;}
return true;}
el.location=el.action;el.onsubmit=function(){return el.login();}},detach:function(el){}});$.scf.behavior.add('RegExp',{attach:function(element,settings,jq){var rx=settings.regexp;if(rx){jq.change(function(event){jq.removeClass("Invalid");jq.removeClass("Valid");if(!rx.test(element.value))
jq.addClass("Invalid");else
jq.addClass("Valid");});}}})
$.scf.behavior.add('ResizableTextArea',{autoAttach:"textarea.resizable:not(.processed)'",attach:function(el,settings,textarea){function locateMouse(ev){if(!ev)return{x:-1,y:-1};if(ev.pageX||ev.pageY)return{x:ev.pageX,y:ev.pageY};var b=document.body;return{x:ev.clientX+b.scrollLeft-b.clientLeft,y:ev.clientY+b.scrollTop-b.clientTop}}
textarea.addClass('processed').wrap('<div class="TextareaWrapper"><span></span></div>').parent().append($('<div class="ResizeGrip"></div>').mousedown(resizeStart));var offY=null,offX=textarea.position().left-textarea.parent().position().left;function resizeGrip(){var grip=$('div.ResizeGrip',textarea.parent());grip.css({width:el.offsetWidth+'px',marginLeft:offX});}
$j(window).resize(resizeGrip);resizeGrip();function resizeStart(e){offY=textarea.height()-locateMouse(e).y;textarea.css('opacity',0.25);$j(document).mousemove(doResize).mouseup(endDrag);return false;}
function doResize(e){textarea.height(Math.max(32,offY+locateMouse(e).y)+'px');return false;}
function endDrag(e){$j(document).unbind("mousemove");$j(document).unbind("mouseup");textarea.css('opacity',1);}}});$.scf.behavior.add('ConfirmBehavior',{autoAttach:"button.AutoConfirm, input[type=submit].AutoConfirm",attach:function(element,settings){$(this).click(function(){return confirm(settings.prompt||($(this).attr("title")||$(this).html())+"\n\nAre you sure?")});}});$.scf.behavior.add('DocumentBehavior',{autoAttach:"body",attach:function(el){document.createTable=function(row,col,callback){tbl=document.createElement("table");tBody=document.createElement("tbody");for(var j=0;j<row;j++){rowEl=document.createElement("tr");for(var i=0;i<col;i++){cell=document.createElement("td");if(callback){callback(cell,j,i);}
rowEl.appendChild(cell);}
tBody.appendChild(rowEl);}
tbl.appendChild(tBody);return tbl;};document.createToolbar=function(el,options){if(!options||!options.buttons)
throw new Error("Invalid toolbar options");var p=document.getAbsolutePosition(el);var toolbar=$("<div class='floatToolbar'><div class='tbCapt'></div><div class='tbBtn'></div></div>").appendTo(document.body).hide();toolbar.find("tbCapt").html(options.caption||"");var tbBtn=toolbar.find(".tbBtn");for(var e in options.buttons){var itm=options.buttons[e];if(itm){if(typeof(itm)=='string')itm={text:itm};if(itm.separator)
$("<div></div>").addClass('sep').html('&nbsp;').appendTo(tbBtn);$("<button></button>").attr('unselectable','on').data('btn',e).html(itm.icon?"":itm.text).attr("title",itm.tooltip||itm.text).css(itm.icon?{background:'url("'+itm.icon+'") no-repeat',width:'20px',height:'20px'}:{}).appendTo(tbBtn);}}
toolbar.find("button").click(function(e){var btn=$(e.target).data('btn');if(btn){if(options.click)
options.click.apply(toolbar,[btn]);else
alert('Clicked '+btn);}});toolbar.css({left:p.left+p.width,top:p.top}).show().animate({left:p.left+p.width-toolbar.outerWidth(),top:p.top-toolbar.outerHeight()},50);return toolbar;};document.getAbsolutePosition=function(p){p=$(p);var pos=p.offset();return{position:"absolute",display:"none",marginLeft:0,marginTop:0,top:pos.top,left:pos.left,width:p.outerWidth(),height:p.outerHeight()};}}});$.scf.behavior.add('DualListBehavior',{autoAttach:"select.DualList",attach:function(el,settings){if(el.type!="select-multiple")return;var defaults=$.grep(el.options,function(){return true});if(el.form.attachReset)
el.form.attachReset(function(){left.options.length=0;right.options.length=0;$.each(defaults,function(){if(this.selected)
right.options[right.options.length]=new Option(this.text,this.value);});$.each(defaults,function(){if(!this.selected)
left.options[left.options.length]=new Option(this.text,this.value);});});var createElement=function(tag,id,className){var b=document.createElement(tag);if(id)b.id=id;if(className)b.className=className;return b;};var createButton=function(id,className,onclick,inner){var b=createElement("button",id,(className)?className:"cmd");b.unselectable="true";if(onclick)b.onclick=onclick;if(inner)b.innerHTML=inner;return b;};var left=el.cloneNode(true);el.formElement=document.createElement('input');el.formElement.type="hidden";el.formElement.name=el.name;el.appendChild(el.formElement);for(var a=left.options,l=a.length,i=0;i<l;i++){a[i].selected=el.options[i].selected;}
left.name=null;left.className="List";var right=el.cloneNode(false);right.name=null;right.className="List";el.multiple="multiple";el.get=function(noevent){var s=[];var a=right.options,n=a.length;for(var i=0;i<n;i++)
s.push(escape(a[i].value||a[i].text));el.formElement.value=s.join(',');if(!noevent){$(el).trigger('change');}}
var remove=function(l,all){if(all)l.options.length=0;else{for(var i=0;i<l.options.length;){if(l.options[i].selected)l.options[i]=null;else i++}}}
var move=function(sel1,sel2,all,copy,noevent){var n=0,temp=new Array();for(var i=0;i<sel2.options.length;i++)temp.push(sel2.options[i]);for(var i=0;i<sel1.options.length;i++){if(all||sel1.options[i].selected){temp.push(new Option(sel1.options[i].text,sel1.options[i].value))}}
if($(el).hasClass("Sorted")){var cb=function(a,b){return(a.text>b.text)};temp.sort(cb);}
sel2.options.length=0;for(var i=0,l=temp.length;i<l;i++){n++;var o=new Option(temp[i].text,temp[i].value);sel2.options.add(o)}
if(!copy)remove(sel1,all);if(!noevent&&n>0){el.options.length=0;move(right,el,true,true,true);for(var i=0;i<el.options.length;i++)el.options[i].selected=true;el.get();}
return;}
var tbl=document.createTable(1,3,function(cell,row,col){switch(col){case 0:cell.appendChild(left);left.ondblclick=function(){move(left,right)};break;case 1:cell.style.width="1px";cell.appendChild(createButton(null,"cmd",function(){move(left,right);return false},"&gt;"));cell.appendChild(createButton(null,"cmd",function(){move(left,right,true);return false},"&gt;&gt;"));cell.appendChild(createButton(null,"cmd",function(){move(right,left);return false},"&lt;"));cell.appendChild(createButton(null,"cmd",function(){move(right,left,true);return false},"&lt;&lt;"));break;case 2:cell.appendChild(right);right.ondblclick=function(){move(right,left)}
break;}});el.parentNode.insertBefore(tbl,el);el.style.display="none";tbl.className="DualList Control";tbl.load=function(ar){left.options.length=0;for(i=0;i<ar.length;i++){left.options.add(new Option(ar[i]))}}
tbl.id=el.name;el.id="";el.name=el.name+"_orig";tbl.formElement=el.formElement;move(left,right,false,false,true);el.get(true);return tbl;}});(function($){$.fn.contextMenu=function(options){var defaults={menu:{textAlign:'left',listStyle:'none',listStyleImage:'none',fontFamily:'menu, tahoma',fontSize:'smaller',padding:'1px',margin:'0px',backgroundColor:'#fff',border:'1px solid #999',width:'100px'},item:{margin:'0px',color:'#000',display:'block',cursor:'default',padding:'3px',paddingLeft:'20px',border:'1px solid #fff',backgroundColor:'transparent'},hover:{border:'1px solid #0a246a',backgroundColor:'#c6cee2'}};function hide(){$(".contextMenu").hide()}
if(options&&options.menu){var e=$(this);options.click=options.click||function(event,e,option){alert(option)};e.bind('contextmenu',function(event){var e=$(event.target);var menu=e.data('contextMenu');if(!menu){menu=$("<div></div>").attr('class','contextMenu').appendTo("body").bind('click',function(evt){evt.stopPropagation();return false;}).bind('contextmenu selectstart',function(){return false;}).hide();menu.css({position:'absolute',zIndex:500}).click(function(evt){var mnu=$(evt.target).data("menuItem");options.click(evt,e,mnu);hide();});var ul=$("<ul></ul>").css(defaults.menu);for(var el in options.menu){var itm=options.menu[el];if(itm){if(typeof(itm)=='string')itm={text:itm};$("<li></li>").data('menuItem',el).html(itm.text).css(defaults.item).css(itm.icon?{background:'url("'+itm.icon+'") no-repeat .em .3em'}:{}).hover(function(){$(this).css(defaults.hover)},function(){$(this).css(defaults.item)}).appendTo(ul)}}
ul.appendTo(menu);e.data('contextMenu',menu);}
menu.css({top:event.pageY,left:event.pageX}).show()
$(document).one('click',hide);return false;});}
return this;};})(jQuery);$.scf.behavior.add("SxmlVisualizationBehavior",{attach:function(el,settings,jQ){if(typeof(settings.tree)!='string')
throw new Error("Tree must be passed as html in settings.tree.");var marker=$("<div></div>").attr('id','sxi_marker').css({opacity:.4}).appendTo(jQ);var tree=$("<div></div>").attr('id','sxi_tree').css({top:$(window).height()-245}).appendTo(jQ).html(settings.tree).find("ul>ul>ul").hide();$("<div></div>").attr('id','sxi_tree_ph').appendTo(jQ);if(settings.editLocation.indexOf('cms://')==-1){$("#sxi_tree a").mousedown(function(){var s=this.href;s=s.replace("cms://",settings.editLocation+"?id=");if(s.substr(s.length-1,1)=='/')s=s.substr(0,s.length-1);this.href=s;});}
$("#sxi_tree").contextMenu({click:function(event,e,option){switch(option){case"expand":$("#sxi_tree ul").show();break;case"collapse":$("#sxi_tree ul>ul").hide();break;case"exit":$("#sxi_tree, #sxi_tree_ph").hide(500);$('[rel]','body').attr('rel','');}},menu:{expand:{text:"Expand all",icon:"/res/treeplus.gif"},collapse:{text:"Collapse all",icon:"/res/treeminus.gif"},exit:"Exit"}});$("#sxi_tree a").unbind("contextmenu");var rTmr=null;$(window).resize(function(){clearTimeout(rTmr);rTmr=setTimeout(function(){rTmr=null;$("#sxi_tree").hide().css({top:$(window).height()-245}).show()},40);});function findStackEl(e){var s=e.attr('rel');if(s.indexOf('sv:')==0){var index=parseInt(s.substr(3));return $("#sf"+index);}return null;}
$("#sxi_marker").bind("mousedown",function(event){var sf=$(event.target).parent('li').attr('id');if(sf&&sf.substr(0,2)=='sf')return;var e=marker.data('over');if(e==null)return;var el=findStackEl(e);if(el&&el.length==1){$("#sxi_tree").find("ul>ul>ul").hide();$("#sxi_tree").find("li").removeClass("selected");var te=el;te.addClass("selected");while(te.get(0)){te=te.parent('ul');te.show();}
el.get(0).scrollIntoView();event.stopPropagation();return false;}});var hTmr=null;$('[rel]').mouseenter(function(event){clearTimeout(hTmr);event.stopPropagation();var e=$(this),treeEl=findStackEl(e);if(treeEl&&treeEl.length==1){hTmr=setTimeout(function(){var c=document.getAbsolutePosition(e);switch(e.get(0).tagName){case'BODY':case'HTML':return}
c.top-=2;c.left-=2;c.width+=2;c.height+=2;c.cursor='hand';marker.css(c).data('over',e).attr('title',treeEl.attr('title')).fadeIn(100);},30);}
return false;});marker.mouseleave(function(event){hTmr=setTimeout(function(){marker.fadeOut(200)},400)});}});$.scf.behavior.add('ScfXFormsBehavior',{autoAttach:"form.xforms-form",attach:function(el,s,form){var id=form.attr("id")||"xform1",state={optimize:true,guid:form.find("input[name=XForms-Context]").val(),id:id,url:document.location.href,debug:$('#'+id+"-debug"),timers:{incremental:null,change:null},controls:{focus:null,current:null}};enrich();function ajax(data,handler,useFormDisabling){enableForm(useFormDisabling,false);$.scf.json.post({error:function(x,textStatus,errorThrown){enableForm(useFormDisabling,true);alert("Error:\n\n"+(x.statusText||"Unknown server error"));},url:state.url,data:$j.scf.json.toString({xform10:data}),callback:function(obj){enableForm(useFormDisabling,true);if(obj.xformsError)
alert("XForms error:\n\n"+obj.xformsError);else
handler(obj);}});}
function enableForm(useFormDisabling,ok){if(useFormDisabling)
form.attr("disabled",ok?"":"disabled").scf_busy(!ok);}
function enrich(){if($.fn.datepicker){form.find(".xforms-control.xforms-builtin-type-date").datepicker({buttonImage:"/assets/icons/calendar.png",buttonImageOnly:true,showOn:"button",dateFormat:'yy-mm-dd',changeMonth:true,changeYear:true,showWeek:true,firstDay:1});}}
function ajaxReady(data){if(data){var n=0;if(data.html){var html=$(data.html);if(data.controls&&state.optimize==true){for(var o in data.controls){var ctlOld=$('#'+o),ctlNew=html.find('#'+o);if(ctlOld.hasClass("xforms-output")){ctlOld.html(data.controls[o]);n++;}
else{if(ctlNew.length){var cc=ctlNew.closest(".xforms-cc"),cco=ctlOld.closest(".xforms-cc");cco.after(cc);cco.remove();n++;}
else{n=0;break;}}}}
if(n==0){form.html(html.unwrap().html());if(state.controls.focus)
setTimeout(function(){$('#'+state.controls.focus).focus()},10);}
enrich();}
else if(data.controls){for(var o in data.controls){var ctl=$('#'+o);if(ctl.hasClass("xforms-output"))
ctl.html(data.controls[o]);else
ctl.val(data.controls[o]);}}
if(state.debug)
$(state.debug).html("");$("#xform1-debug").html("--");if(data.debug&&state.debug){var dbg=$(data.debug).unwrap().html();$(state.debug).html(dbg);}}}
function controlChanged(ctl,incremental){var ctlId,o={};if(ctl.hasClass("xforms-check-group")){ctlId=ctl.attr("name");var s="",cbs=ctl.parents(".xforms-control").find(".xforms-check-group:checked");cbs.each(function(){s+=$(this).val()+","});if(s.substr(s.length-1,1)==",")s=s.substr(0,s.length-1);o[ctlId]=s;}
else{ctlId=ctl.attr("id");var data=ctl.val();if($.isArray(data))
data=data.join(",");o[ctlId]=data;}
ajax({id:state.guid,type:"change",incremental:(incremental==true),userValues:o},ajaxReady);}
form.bind({change:function(e){clearTimeout(state.timers.change);state.controls.current=null;var ctl=$(e.target);if(ctl.hasClass('xforms-control')){state.controls.current={name:ctl.attr("name"),value:ctl.val()}
state.timers.change=setTimeout(function(){controlChanged(ctl);},50);}},focusin:function(e){var ctl=$(e.target);state.controls.focus=ctl.attr("id");if(ctl.hasClass('xforms-incremental'))
ctl.attr("x-incremental","1");},focusout:function(e){var ctl=$(e.target);if(ctl.attr("x-incremental")=="1"){clearTimeout(state.timers.incremental);ctl.attr("x-incremental",null);}},keyup:function(e){clearTimeout(state.timers.incremental);var ctl=$(e.target);if(ctl.attr("x-incremental")=="1"){state.timers.incremental=setTimeout(function(){controlChanged(ctl,true);},50);}},click:function(e){var ctl=$(e.target);if(ctl.hasClass('xforms-trigger')){clearTimeout(state.timers.change);var btn=$(e.target);if(!btn.is(":disabled")){var trigger=btn.attr("name"),values={};values[trigger]=1;if(state.controls.current){values[state.controls.current.name]=state.controls.current.value;state.controls.current=null;}
ajax({id:state.guid,trigger:trigger,userValues:values},ajaxReady,false);}
return false;}}});}});$j.scf.behavior.add("BusySmartletBoxBehavior",{autoAttach:".sml_box",attach:function(e,s,j){j.find(".smlboxbtns").append('<b class="busy"></b>');}});$.scf.behavior.add('SmartletBoxCollapsibleBehavior',{autoAttach:".sml_box.collapsible",attach:function(el,options,j){if(!j.hasClass("fs")&&j.find("div.smartlet").length){j.find(".smlboxbtns").append($('<a class="collapse-handle">&nbsp;</a>').click(function(){$('.box-caption',j).trigger("click");}));};function trigger(e){var e=$.Event(e);e.args={box:j.get(0)}
$(document).trigger(e);return e.result;};$('.box-caption',j).addClass("toggleOpen").wrapInner("<em></em>").addClass("link").toggle(function(){$('.box-caption',j).addClass("collapsed");if(trigger('sml_box_Collapse')!=false){$(".smartlet",j).slideUp(100,function(){j.addClass("collapsed");});}},function(){$('.box-caption',j).removeClass("collapsed").addClass("expanded");if(trigger('sml_box_Expand')!=false){$(".smartlet",j).slideDown(100,function(){j.removeClass("collapsed");});}});if($(j).hasClass("collapsed")){$('.box-caption',j).trigger("click");}}});$.scf.behavior.add('SmartletEditor',{attach:function(el){var rs=function(){var pos=$('div.Preview').offset();var w=$(window).width()-pos.left-20;var h=$(window).height()-pos.top-$('.SaveButton').height()-20;if(h<20)h=20;if(w<20)w=20;$('div.Preview').height(h).width(w);};$(window).load(rs).resize(rs);}});$.scf.behavior.add('EditorPreview',{attach:function(el){if(el.tagName!='INPUT')
return;el.onclick=function(){el.form["__smartletJsonData"].value='{"mode": "preview", "smartlet": {"locator": '+el.form["__smartletLocator"].value
+',"syntax": "'+el.form["__smartletName"].value+'","useLocation": "'+el.form["__smartletUseLocation"].value
+'", "name": "'+smartletName+'"}, "data": '+$j(el.form).scf.form.toJSON()+'}';el.form.action=previewLocation;el.form.target="PreviewFrame";el.form.submit();return false;}}});$.scf.behavior.add('EditorSave',{attach:function(el){var readyValidating=function(obj){if(obj.ok==true){window.returnValue=obj;window.close();}
else
alert("Server-side validation of the parameters failed.");}
readyGettingPreset=function(obj){if(obj&&obj.ok){clipboardData.setData("text",obj.presettemplate);alert(obj.feedback);}}
readyAdvancing=function(obj){var url=document.location.href;var dialog="/?id=DLG_ADVANCEDSMARTLET&vipercall="+encodeURIComponent(obj.encodedViper);var s="Edit viper call directly.";if(!obj.ok)s+="\nServer-side validation of the parameters failed.";var retval=showModalDialog(dialog,self,'center: 1; dialogWidth: 800px; dialogHeight: 200px; resizable: 0; scroll: 0; status: 0; help: 0; unadorned: 1');var viper;if(retval&&retval.vipercall)viper=retval.vipercall;if(viper&&(viper!=obj.viper)){var rg=/([\?\&]vipercall=)[^\&]*/;if(url.match(rg))
url=url.replace(rg,"$1"+encodeURIComponent(viper));else{if(url.indexOf("?")==-1)
url+="?";else
url+="&";url+="vipercall=";url+=encodeURIComponent(viper);}
window.name="smartletEditor";window.open(url,"smartletEditor");}}
var validateAndAccept=function(frm,smartletId,locator,useLocation,cb,md){var json='{"mode":"'+md+'", "smartlet": {"locator": '+locator+',"syntax": "'+smartletId+'", "name": "'+smartletName+'", "useLocation": "'+useLocation+'"}, "data": '+$j(frm).scf.form.toJSON()+'}';$.scf.json.post({url:'/?id=SMARTLET_CONTROLLER',data:json,callback:cb});}
if(el.tagName!='INPUT')
return;el.onclick=function(){var name=el.form["__smartletName"].value;var locator=el.form["__smartletLocator"].value;var useLocation=el.form["__smartletUseLocation"].value;if($(this).hasClass("AdvancedButton"))
validateAndAccept(el.form,name,locator,useLocation,readyAdvancing,"get");else if($(this).hasClass("PresetTemplateButton"))
validateAndAccept(el.form,name,locator,useLocation,readyGettingPreset,"getpresettemplate");else
validateAndAccept(el.form,name,locator,useLocation,readyValidating,"validate");return false;}}});$.scf.behavior.add('EditorClose',{attach:function(el){el.onclick=function(){window.close();return false;}}});$.scf.behavior.add('LocatorControl',{attach:function(el){}});$.scf.ready(function(){$(".SmartletEditor").scf.behavior("SmartletEditor");$(".SmartletEditor input.PreviewButton").scf.behavior("EditorPreview");$(".SmartletEditor input.SaveButton").scf.behavior("EditorSave");$(".SmartletEditor input.AdvancedButton").scf.behavior("EditorSave");$(".SmartletEditor input.PresetTemplateButton").scf.behavior("EditorSave");$(".SmartletEditor input.CloseButton").scf.behavior("EditorClose");$(".SmartletEditor .IntegerControl").scf.behavior("RegExp",{regexp:/[0-9]+/});$(".SmartletEditor .FloatControl").scf.behavior("RegExp",{regexp:/[0-9].+/});$(".SmartletEditor .LocatorControl").scf.behavior("LocatorControl");$(".SmartletEditor #tabstrip div[id='']").hide();window.enumProps=function(ob){var s="";var p;for(p in ob){if(s.length!=0)s+="\n";s+=p+":\t"+ob[p];}
return s;}});$.scf.behavior.add('SmartletList',{attach:function(el,settings,jq){var acceptDlg=function(id,name,callback){if(settings.dlg){window.returnValue={"smartlet":{"id":"{"+id+"()}","name":name,"callback":callback}};window.close();}}
$('.sm_group a').click(function(event){var a=$(this);if(a&&a.length>0){acceptDlg(a[0].id,a[0].innerText,a[0].href);}
return false;});$j.scf.behavior.attach(".SmartletList div.sm_group","SmartletGroups");}});$.scf.behavior.add("SmartletGroups",{attach:function(el,settings,jq){var groupMembers=jq.find("div.Smartlet");el.showAll=function(){jq.show();groupMembers.each(function(){$j(this).show();});};el.filter=function(flt){var showCount=0;groupMembers.each(function(){if($j(this).text().toLowerCase().indexOf(flt)==-1){$j(this).hide();}else{$j(this).show();showCount++;}});if(showCount==0){jq.hide();}else{jq.show();}};}});$.scf.behavior.add("SmartletListFilter",{autoAttach:"#smartletfilter",attach:function(el,settings,jq){var groups=$j(".SmartletList div.sm_group");var tmr=null;var allShown=true;filter=function(){allShown=false;var flt=el.value.toLowerCase();groups.each(function(){this.filter(flt);});}
showAll=function(){if(allShown)return;groups.each(function(){this.showAll();});allShown=true;}
el.onkeyup=function(){if(this.value.length<3){tmr=setTimeout(showAll,100);return;}
if(tmr)clearTimeout(tmr);tmr=setTimeout(filter,100);}}});String.prototype.validTags=function(){var s=this;s=s.replace(/<[^> ]*/g,function(match){return match.toLowerCase()}).replace(/<[^>]*>/g,function(match){return match.replace(/ [^=]+=/g,function(match2){return match2.toLowerCase()})}).replace(/<[^>]*>/g,function(match){return match.replace(/( [^=]+=)([^"][^ >]*)/g,"$1\"$2\"")});return s;}
String.prototype.cleanHtml=function(){var s=this.validTags();s=s.replace(/^\s+/,"").replace(/\s+$/,"").replace(/ style="[^"]*"/g,"").replace(/<br>/g,"<br />").replace(/<br \/>\s*<\/(h1|h2|h3|h4|h5|h6|li|p)/g,"</$1").replace(/(<img [^>]+[^\/])>/g,"$1 />").replace(/(<[^\/]>|<[^\/][^>]*[^\/]>)\s*<\/[^>]*>/g,"");return s;}
String.prototype.trim=function(){return(this||"").replace(/^\s+|\s+$/g,"");};String.prototype.base64Encode=function(){var str=this;var charBase64=new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/');var out="",chr1,chr2,chr3,enc1,enc2,enc3,enc4,i=0,len=str.length;do{chr1=str.charCodeAt(i++);chr2=str.charCodeAt(i++);chr3=str.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&0x03)<<4)|(chr2>>4);enc3=((chr2&0x0F)<<2)|(chr3>>6);enc4=chr3&0x3F;out+=charBase64[enc1]+charBase64[enc2];if(isNaN(chr2))
out+='==';else if(isNaN(chr3))
out+=charBase64[enc3]+'=';else
out+=charBase64[enc3]+charBase64[enc4];}
while(i<len);return out;}
$.scf.behavior.add('TabStrip',{autoAttach:"ul.TabStrip",attach:function(el,settings,jq){var clickTab=function(event){var ref=event.target;var tab=$(ref).parent("LI").get(0);if(tab==oldTab||tab.disabled)return;var oldTab=el.activeTab;oldTab.style.zIndex=0;$(oldTab).removeClass("Active");$(oldTab.page).removeClass("Active");$(tab).addClass("Active");$(tab.page).addClass(tab.page,"Active");tab.blur();el.activeTab=tab;tab.style.zIndex=1;}
el.pages=document.createElement("div");el.pages.className="TabPages";if(el.tagName!="UL")return;var swapNodes=function(item1,item2,includeChildren){if(item1.swapNode){return item1.swapNode(item2,includeChildren);}
else{var nextSibling=item1.nextSibling;var parentNode=item1.parentNode;item2.parentNode.replaceChild(item1,item2,includeChildren);return parentNode.insertBefore(item2,nextSibling);}};var addStyleSheet=function(url){if(document.createStyleSheet)
document.createStyleSheet(url);else{var newSS=document.createElement('link');newSS.rel='stylesheet';newSS.type='text/css';newSS.href=url;document.getElementsByTagName("head")[0].appendChild(newSS);}};el.activeTab=null;for(var i=0;i<el.childNodes.length;i++){var tab=el.childNodes[i];if($(tab).hasClass("Active")){el.activeTab=tab;break;}}
el.pages=document.createElement("div");$(el.pages).hasClass("TabPages");el.parentNode.insertBefore(el.pages,el);swapNodes(el,el.pages);var br=document.createElement("br");br.clear="both";el.parentNode.insertBefore(br,el.pages);for(var i=0;i<el.childNodes.length;i++){var tab=el.childNodes[i];if(tab.tagName=="LI"){if(el.activeTab==null&&!tab.disabled)el.activeTab=tab;var tabContent=document.createElement("div");if(tab.firstChild&&tab.firstChild.className=="TabContent"){var span=document.createElement("span");tabContent.appendChild(span);swapNodes(tab.firstChild,span);}
else
tabContent.innerHTML=tab.innerHTML;var ref=document.createElement("A");$(ref).addClass("Tab");$(ref).click(clickTab);ref.innerHTML=el.childNodes[i].title||"Tab";tab.innerHTML="";tab.appendChild(ref);$(tabContent).addClass("Tab");if(el.activeTab==tab)
$(tabContent).addClass("Active");tab.page=tabContent;el.pages.appendChild(tabContent);}}
$(el.activeTab).addClass("Active");$(el.activeTab.page).addClass("Active");addStyleSheet('/assets/behavior/styles/tabstrip.css');return el;},detach:function(el){}})
$.fn.tooltip=function(){$(this).hover(function(){this.tip=this.title;$(this).append('<div class="toolTipWrapper">'
+'<div class="toolTipTop"></div>'
+'<div class="toolTipMid">'
+this.tip
+'</div>'
+'<div class="toolTipBtm"></div>'
+'</div>');this.title="";this.width=$(this).width();$(this).find('.toolTipWrapper').css({left:this.width-22})
$('.toolTipWrapper').fadeIn(300);},function(){$('.toolTipWrapper').fadeOut(100);$(this).children().remove();this.title=this.tip;});};$.scf.behavior.add('WebEdit',{autoAttach:"form.CoolForm textarea.WebEdit",attach:function(el,settings){if(el.tagName!="TEXTAREA")return;el.content=document.createElement("IFRAME");el.content.id=el.id+"_content";el.content.className=el.className;el.content.frameBorder="no";el.content.formElement=el;el.get=function(){el.value=el.content.contentWindow.document.body.innerHTML;return el.value;};var frm=el.parentNode;while(frm&&frm.nodeName!="FORM")frm=frm.parentNode;if(frm)$(frm).submit(el.get);el.style.display="none";var openEditor=function(){var d=el.content.contentWindow.document;d.body.innerHTML=el.value;d.designMode='on';if(el.editCss){var css=d.createElement("link");css.setAttribute("href",editCss);css.setAttribute("rel","stylesheet");css.setAttribute("type","text/css");var h=d.getElementsByTagName("head");if(h&&h.length>0)h[0].appendChild(css);}}
$(el.content).load(openEditor);$j(el.content).blur(el.get);el.clear=function(){el.value="";el.content.contentWindow.document.body.innerHTML="";};el.parentNode.insertBefore(el.content,el);},detach:function(el){if(el.content){el.get();el.className=el.content.className;el.parentNode.removeChild(el.content);el.content=null;el.style.display='';}}});
})(jQuery);
