
(function(){var
window=this,undefined,_jQuery=window.jQuery,_$=window.$,jQuery=window.jQuery=window.$=function(selector,context){return new jQuery.fn.init(selector,context);},quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,isSimple=/^.[^:#\[\.,]*$/;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;this.context=selector;return this;}
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&&elem.id!=match[3])
return jQuery().find(selector);var ret=jQuery(elem||[]);ret.context=document;ret.selector=selector;return ret;}}else
return jQuery(context).find(selector);}else if(jQuery.isFunction(selector))
return jQuery(document).ready(selector);if(selector.selector&&selector.context){this.selector=selector.selector;this.context=selector.context;}
return this.setArray(jQuery.isArray(selector)?selector:jQuery.makeArray(selector));},selector:"",jquery:"1.3.2",size:function(){return this.length;},get:function(num){return num===undefined?Array.prototype.slice.call(this):this[num];},pushStack:function(elems,name,selector){var ret=jQuery(elems);ret.prevObject=this;ret.context=this.context;if(name==="find")
ret.selector=this.selector+(this.selector?" ":"")+selector;else if(name)
ret.selector=this.selector+"."+name+"("+selector+")";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){return jQuery.inArray(elem&&elem.jquery?elem[0]:elem,this);},attr:function(name,value,type){var options=name;if(typeof name==="string")
if(value===undefined)
return this[0]&&jQuery[type||"attr"](this[0],name);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]){var wrap=jQuery(html,this[0].ownerDocument).clone();if(this[0].parentNode)
wrap.insertBefore(this[0]);wrap.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,function(elem){if(this.nodeType==1)
this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,function(elem){if(this.nodeType==1)
this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},push:[].push,sort:[].sort,splice:[].splice,find:function(selector){if(this.length===1){var ret=this.pushStack([],"find",selector);ret.length=0;jQuery.find(selector,this[0],ret);return ret;}else{return this.pushStack(jQuery.unique(jQuery.map(this,function(elem){return jQuery.find(selector,elem);})),"find",selector);}},clone:function(events){var ret=this.map(function(){if(!jQuery.support.noCloneEvent&&!jQuery.isXMLDoc(this)){var html=this.outerHTML;if(!html){var div=this.ownerDocument.createElement("div");div.appendChild(this.cloneNode(true));html=div.innerHTML;}
return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0];}else
return this.cloneNode(true);});if(events===true){var orig=this.find("*").andSelf(),i=0;ret.find("*").andSelf().each(function(){if(this.nodeName!==orig[i].nodeName)
return;var events=jQuery.data(orig[i],"events");for(var type in events){for(var handler in events[type]){jQuery.event.add(this,type,events[type][handler],events[type][handler].data);}}
i++;});}
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,jQuery.grep(this,function(elem){return elem.nodeType===1;})),"filter",selector);},closest:function(selector){var pos=jQuery.expr.match.POS.test(selector)?jQuery(selector):null,closer=0;return this.map(function(){var cur=this;while(cur&&cur.ownerDocument){if(pos?pos.index(cur)>-1:jQuery(cur).is(selector)){jQuery.data(cur,"closest",closer);return cur;}
cur=cur.parentNode;closer++;}});},not:function(selector){if(typeof selector==="string")
if(isSimple.test(selector))
return this.pushStack(jQuery.multiFilter(selector,this,true),"not",selector);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 this.pushStack(jQuery.unique(jQuery.merge(this.get(),typeof selector==="string"?jQuery(selector):jQuery.makeArray(selector))));},is:function(selector){return!!selector&&jQuery.multiFilter(selector,this).length>0;},hasClass:function(selector){return!!selector&&this.is("."+selector);},val:function(value){if(value===undefined){var elem=this[0];if(elem){if(jQuery.nodeName(elem,'option'))
return(elem.attributes.value||{}).specified?elem.value:elem.text;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(option).val();if(one)
return value;values.push(value);}}
return values;}
return(elem.value||"").replace(/\r/g,"");}
return undefined;}
if(typeof value==="number")
value+='';return this.each(function(){if(this.nodeType!=1)
return;if(jQuery.isArray(value)&&/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=jQuery.makeArray(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[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):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),"slice",Array.prototype.slice.call(arguments).join(","));},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);},domManip:function(args,table,callback){if(this[0]){var fragment=(this[0].ownerDocument||this[0]).createDocumentFragment(),scripts=jQuery.clean(args,(this[0].ownerDocument||this[0]),fragment),first=fragment.firstChild;if(first)
for(var i=0,l=this.length;i<l;i++)
callback.call(root(this[i],first),this.length>1||i>0?fragment.cloneNode(true):fragment);if(scripts)
jQuery.each(scripts,evalScript);}
return this;function root(elem,cur){return table&&jQuery.nodeName(elem,"table")&&jQuery.nodeName(cur,"tr")?(elem.getElementsByTagName("tbody")[0]||elem.appendChild(elem.ownerDocument.createElement("tbody"))):elem;}}};jQuery.fn.init.prototype=jQuery.fn;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);}
function now(){return+new Date;}
jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(typeof target==="boolean"){deep=target;target=arguments[1]||{};i=2;}
if(typeof target!=="object"&&!jQuery.isFunction(target))
target={};if(length==i){target=this;--i;}
for(;i<length;i++)
if((options=arguments[i])!=null)
for(var name in options){var src=target[name],copy=options[name];if(target===copy)
continue;if(deep&&copy&&typeof copy==="object"&&!copy.nodeType)
target[name]=jQuery.extend(deep,src||(copy.length!=null?[]:{}),copy);else if(copy!==undefined)
target[name]=copy;}
return target;};var exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i,defaultView=document.defaultView||{},toString=Object.prototype.toString;jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)
window.jQuery=_jQuery;return jQuery;},isFunction:function(obj){return toString.call(obj)==="[object Function]";},isArray:function(obj){return toString.call(obj)==="[object Array]";},isXMLDoc:function(elem){return elem.nodeType===9&&elem.documentElement.nodeName!=="HTML"||!!elem.ownerDocument&&jQuery.isXMLDoc(elem.ownerDocument);},globalEval:function(data){if(data&&/\S/.test(data)){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.support.scriptEval)
script.appendChild(document.createTextNode(data));else
script.text=data;head.insertBefore(script,head.firstChild);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},each:function(object,callback,args){var name,i=0,length=object.length;if(args){if(length===undefined){for(name in object)
if(callback.apply(object[name],args)===false)
break;}else
for(;i<length;)
if(callback.apply(object[i++],args)===false)
break;}else{if(length===undefined){for(name in object)
if(callback.call(object[name],name,object[name])===false)
break;}else
for(var 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 typeof value==="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 elem&&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,extra){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;if(extra==="border")
return;jQuery.each(which,function(){if(!extra)
val-=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;if(extra==="margin")
val+=parseFloat(jQuery.curCSS(elem,"margin"+this,true))||0;else
val-=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});}
if(elem.offsetWidth!==0)
getWH();else
jQuery.swap(elem,props,getWH);return Math.max(0,Math.round(val));}
return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret,style=elem.style;if(name=="opacity"&&!jQuery.support.opacity){ret=jQuery.attr(style,"opacity");return ret==""?"1":ret;}
if(name.match(/float/i))
name=styleFloat;if(!force&&style&&style[name])
ret=style[name];else if(defaultView.getComputedStyle){if(name.match(/float/i))
name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var computedStyle=defaultView.getComputedStyle(elem,null);if(computedStyle)
ret=computedStyle.getPropertyValue(name);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 left=style.left,rsLeft=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;style.left=ret||0;ret=style.pixelLeft+"px";style.left=left;elem.runtimeStyle.left=rsLeft;}}
return ret;},clean:function(elems,context,fragment){context=context||document;if(typeof context.createElement==="undefined")
context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;if(!fragment&&elems.length===1&&typeof elems[0]==="string"){var match=/^<(\w+)\s*\/?>$/.exec(elems[0]);if(match)
return[context.createElement(match[1])];}
var ret=[],scripts=[],div=context.createElement("div");jQuery.each(elems,function(i,elem){if(typeof elem==="number")
elem+='';if(!elem)
return;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=elem.replace(/^\s+/,"").substring(0,10).toLowerCase();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.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)
div=div.lastChild;if(!jQuery.support.tbody){var hasBody=/<tbody/i.test(elem),tbody=!tags.indexOf("<table")&&!hasBody?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&!hasBody?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(!jQuery.support.leadingWhitespace&&/^\s/.test(elem))
div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);elem=jQuery.makeArray(div.childNodes);}
if(elem.nodeType)
ret.push(elem);else
ret=jQuery.merge(ret,elem);});if(fragment){for(var i=0;ret[i];i++){if(jQuery.nodeName(ret[i],"script")&&(!ret[i].type||ret[i].type.toLowerCase()==="text/javascript")){scripts.push(ret[i].parentNode?ret[i].parentNode.removeChild(ret[i]):ret[i]);}else{if(ret[i].nodeType===1)
ret.splice.apply(ret,[i+1,0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))));fragment.appendChild(ret[i]);}}
return scripts;}
return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)
return undefined;var notxml=!jQuery.isXMLDoc(elem),set=value!==undefined;name=notxml&&jQuery.props[name]||name;if(elem.tagName){var special=/href|src|style/.test(name);if(name=="selected"&&elem.parentNode)
elem.parentNode.selectedIndex;if(name in elem&&notxml&&!special){if(set){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)
throw"type property can't be changed";elem[name]=value;}
if(jQuery.nodeName(elem,"form")&&elem.getAttributeNode(name))
return elem.getAttributeNode(name).nodeValue;if(name=="tabIndex"){var attributeNode=elem.getAttributeNode("tabIndex");return attributeNode&&attributeNode.specified?attributeNode.value:elem.nodeName.match(/(button|input|object|select|textarea)/i)?0:elem.nodeName.match(/^(a|area)$/i)&&elem.href?0:undefined;}
return elem[name];}
if(!jQuery.support.style&&notxml&&name=="style")
return jQuery.attr(elem.style,"cssText",value);if(set)
elem.setAttribute(name,""+value);var attr=!jQuery.support.hrefNormalized&&notxml&&special?elem.getAttribute(name,2):elem.getAttribute(name);return attr===null?undefined:attr;}
if(!jQuery.support.opacity&&name=="opacity"){if(set){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+
(parseInt(value)+''=="NaN"?"":"alpha(opacity="+value*100+")");}
return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100)+'':"";}
name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(set)
elem[name]=value;return elem[name];},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(array!=null){var i=array.length;if(i==null||typeof array==="string"||jQuery.isFunction(array)||array.setInterval)
ret[0]=array;else
while(i)
ret[--i]=array[i];}
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){var i=0,elem,pos=first.length;if(!jQuery.support.getAll){while((elem=second[i++])!=null)
if(elem.nodeType!=8)
first[pos++]=elem;}else
while((elem=second[i++])!=null)
first[pos++]=elem;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))
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)
ret[ret.length]=value;}
return ret.concat.apply([],ret);}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,'0'])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};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),name,selector);};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(selector){var ret=[],insert=jQuery(selector);for(var i=0,l=insert.length;i<l;i++){var elems=(i>0?this.clone(true):this).get();jQuery.fn[original].apply(jQuery(insert[i]),elems);ret=ret.concat(elems);}
return this.pushStack(ret,name,selector);};});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,state){if(typeof state!=="boolean")
state=!jQuery.className.has(this,classNames);jQuery.className[state?"add":"remove"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).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).children().remove();while(this.firstChild)
this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});function num(elem,prop){return elem[0]&&parseInt(jQuery.curCSS(elem[0],prop,true),10)||0;}
var expando="jQuery"+now(),uuid=0,windowData={};jQuery.extend({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];}},queue:function(elem,type,data){if(elem){type=(type||"fx")+"queue";var q=jQuery.data(elem,type);if(!q||jQuery.isArray(data))
q=jQuery.data(elem,type,jQuery.makeArray(data));else if(data)
q.push(data);}
return q;},dequeue:function(elem,type){var queue=jQuery.queue(elem,type),fn=queue.shift();if(!type||type==="fx")
fn=queue[0];if(fn!==undefined)
fn.call(elem);}});jQuery.fn.extend({data:function(key,value){var parts=key.split(".");parts[1]=parts[1]?"."+parts[1]:"";if(value===undefined){var data=this.triggerHandler("getData"+parts[1]+"!",[parts[0]]);if(data===undefined&&this.length)
data=jQuery.data(this[0],key);return data===undefined&&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);});},queue:function(type,data){if(typeof type!=="string"){data=type;type="fx";}
if(data===undefined)
return jQuery.queue(this[0],type);return this.each(function(){var queue=jQuery.queue(this,type,data);if(type=="fx"&&queue.length==1)
queue[0].call(this);});},dequeue:function(type){return this.each(function(){jQuery.dequeue(this,type);});}});(function(){var chunker=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,done=0,toString=Object.prototype.toString;var Sizzle=function(selector,context,results,seed){results=results||[];context=context||document;if(context.nodeType!==1&&context.nodeType!==9)
return[];if(!selector||typeof selector!=="string"){return results;}
var parts=[],m,set,checkSet,check,mode,extra,prune=true;chunker.lastIndex=0;while((m=chunker.exec(selector))!==null){parts.push(m[1]);if(m[2]){extra=RegExp.rightContext;break;}}
if(parts.length>1&&origPOS.exec(selector)){if(parts.length===2&&Expr.relative[parts[0]]){set=posProcess(parts[0]+parts[1],context);}else{set=Expr.relative[parts[0]]?[context]:Sizzle(parts.shift(),context);while(parts.length){selector=parts.shift();if(Expr.relative[selector])
selector+=parts.shift();set=posProcess(selector,set);}}}else{var ret=seed?{expr:parts.pop(),set:makeArray(seed)}:Sizzle.find(parts.pop(),parts.length===1&&context.parentNode?context.parentNode:context,isXML(context));set=Sizzle.filter(ret.expr,ret.set);if(parts.length>0){checkSet=makeArray(set);}else{prune=false;}
while(parts.length){var cur=parts.pop(),pop=cur;if(!Expr.relative[cur]){cur="";}else{pop=parts.pop();}
if(pop==null){pop=context;}
Expr.relative[cur](checkSet,pop,isXML(context));}}
if(!checkSet){checkSet=set;}
if(!checkSet){throw"Syntax error, unrecognized expression: "+(cur||selector);}
if(toString.call(checkSet)==="[object Array]"){if(!prune){results.push.apply(results,checkSet);}else if(context.nodeType===1){for(var i=0;checkSet[i]!=null;i++){if(checkSet[i]&&(checkSet[i]===true||checkSet[i].nodeType===1&&contains(context,checkSet[i]))){results.push(set[i]);}}}else{for(var i=0;checkSet[i]!=null;i++){if(checkSet[i]&&checkSet[i].nodeType===1){results.push(set[i]);}}}}else{makeArray(checkSet,results);}
if(extra){Sizzle(extra,context,results,seed);if(sortOrder){hasDuplicate=false;results.sort(sortOrder);if(hasDuplicate){for(var i=1;i<results.length;i++){if(results[i]===results[i-1]){results.splice(i--,1);}}}}}
return results;};Sizzle.matches=function(expr,set){return Sizzle(expr,null,null,set);};Sizzle.find=function(expr,context,isXML){var set,match;if(!expr){return[];}
for(var i=0,l=Expr.order.length;i<l;i++){var type=Expr.order[i],match;if((match=Expr.match[type].exec(expr))){var left=RegExp.leftContext;if(left.substr(left.length-1)!=="\\"){match[1]=(match[1]||"").replace(/\\/g,"");set=Expr.find[type](match,context,isXML);if(set!=null){expr=expr.replace(Expr.match[type],"");break;}}}}
if(!set){set=context.getElementsByTagName("*");}
return{set:set,expr:expr};};Sizzle.filter=function(expr,set,inplace,not){var old=expr,result=[],curLoop=set,match,anyFound,isXMLFilter=set&&set[0]&&isXML(set[0]);while(expr&&set.length){for(var type in Expr.filter){if((match=Expr.match[type].exec(expr))!=null){var filter=Expr.filter[type],found,item;anyFound=false;if(curLoop==result){result=[];}
if(Expr.preFilter[type]){match=Expr.preFilter[type](match,curLoop,inplace,result,not,isXMLFilter);if(!match){anyFound=found=true;}else if(match===true){continue;}}
if(match){for(var i=0;(item=curLoop[i])!=null;i++){if(item){found=filter(item,match,i,curLoop);var pass=not^!!found;if(inplace&&found!=null){if(pass){anyFound=true;}else{curLoop[i]=false;}}else if(pass){result.push(item);anyFound=true;}}}}
if(found!==undefined){if(!inplace){curLoop=result;}
expr=expr.replace(Expr.match[type],"");if(!anyFound){return[];}
break;}}}
if(expr==old){if(anyFound==null){throw"Syntax error, unrecognized expression: "+expr;}else{break;}}
old=expr;}
return curLoop;};var Expr=Sizzle.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(elem){return elem.getAttribute("href");}},relative:{"+":function(checkSet,part,isXML){var isPartStr=typeof part==="string",isTag=isPartStr&&!/\W/.test(part),isPartStrNotTag=isPartStr&&!isTag;if(isTag&&!isXML){part=part.toUpperCase();}
for(var i=0,l=checkSet.length,elem;i<l;i++){if((elem=checkSet[i])){while((elem=elem.previousSibling)&&elem.nodeType!==1){}
checkSet[i]=isPartStrNotTag||elem&&elem.nodeName===part?elem||false:elem===part;}}
if(isPartStrNotTag){Sizzle.filter(part,checkSet,true);}},">":function(checkSet,part,isXML){var isPartStr=typeof part==="string";if(isPartStr&&!/\W/.test(part)){part=isXML?part:part.toUpperCase();for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){var parent=elem.parentNode;checkSet[i]=parent.nodeName===part?parent:false;}}}else{for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){checkSet[i]=isPartStr?elem.parentNode:elem.parentNode===part;}}
if(isPartStr){Sizzle.filter(part,checkSet,true);}}},"":function(checkSet,part,isXML){var doneName=done++,checkFn=dirCheck;if(!part.match(/\W/)){var nodeCheck=part=isXML?part:part.toUpperCase();checkFn=dirNodeCheck;}
checkFn("parentNode",part,doneName,checkSet,nodeCheck,isXML);},"~":function(checkSet,part,isXML){var doneName=done++,checkFn=dirCheck;if(typeof part==="string"&&!part.match(/\W/)){var nodeCheck=part=isXML?part:part.toUpperCase();checkFn=dirNodeCheck;}
checkFn("previousSibling",part,doneName,checkSet,nodeCheck,isXML);}},find:{ID:function(match,context,isXML){if(typeof context.getElementById!=="undefined"&&!isXML){var m=context.getElementById(match[1]);return m?[m]:[];}},NAME:function(match,context,isXML){if(typeof context.getElementsByName!=="undefined"){var ret=[],results=context.getElementsByName(match[1]);for(var i=0,l=results.length;i<l;i++){if(results[i].getAttribute("name")===match[1]){ret.push(results[i]);}}
return ret.length===0?null:ret;}},TAG:function(match,context){return context.getElementsByTagName(match[1]);}},preFilter:{CLASS:function(match,curLoop,inplace,result,not,isXML){match=" "+match[1].replace(/\\/g,"")+" ";if(isXML){return match;}
for(var i=0,elem;(elem=curLoop[i])!=null;i++){if(elem){if(not^(elem.className&&(" "+elem.className+" ").indexOf(match)>=0)){if(!inplace)
result.push(elem);}else if(inplace){curLoop[i]=false;}}}
return false;},ID:function(match){return match[1].replace(/\\/g,"");},TAG:function(match,curLoop){for(var i=0;curLoop[i]===false;i++){}
return curLoop[i]&&isXML(curLoop[i])?match[1]:match[1].toUpperCase();},CHILD:function(match){if(match[1]=="nth"){var test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(match[2]=="even"&&"2n"||match[2]=="odd"&&"2n+1"||!/\D/.test(match[2])&&"0n+"+match[2]||match[2]);match[2]=(test[1]+(test[2]||1))-0;match[3]=test[3]-0;}
match[0]=done++;return match;},ATTR:function(match,curLoop,inplace,result,not,isXML){var name=match[1].replace(/\\/g,"");if(!isXML&&Expr.attrMap[name]){match[1]=Expr.attrMap[name];}
if(match[2]==="~="){match[4]=" "+match[4]+" ";}
return match;},PSEUDO:function(match,curLoop,inplace,result,not){if(match[1]==="not"){if(match[3].match(chunker).length>1||/^\w/.test(match[3])){match[3]=Sizzle(match[3],null,null,curLoop);}else{var ret=Sizzle.filter(match[3],curLoop,inplace,true^not);if(!inplace){result.push.apply(result,ret);}
return false;}}else if(Expr.match.POS.test(match[0])||Expr.match.CHILD.test(match[0])){return true;}
return match;},POS:function(match){match.unshift(true);return match;}},filters:{enabled:function(elem){return elem.disabled===false&&elem.type!=="hidden";},disabled:function(elem){return elem.disabled===true;},checked:function(elem){return elem.checked===true;},selected:function(elem){elem.parentNode.selectedIndex;return elem.selected===true;},parent:function(elem){return!!elem.firstChild;},empty:function(elem){return!elem.firstChild;},has:function(elem,i,match){return!!Sizzle(match[3],elem).length;},header:function(elem){return/h\d/i.test(elem.nodeName);},text:function(elem){return"text"===elem.type;},radio:function(elem){return"radio"===elem.type;},checkbox:function(elem){return"checkbox"===elem.type;},file:function(elem){return"file"===elem.type;},password:function(elem){return"password"===elem.type;},submit:function(elem){return"submit"===elem.type;},image:function(elem){return"image"===elem.type;},reset:function(elem){return"reset"===elem.type;},button:function(elem){return"button"===elem.type||elem.nodeName.toUpperCase()==="BUTTON";},input:function(elem){return/input|select|textarea|button/i.test(elem.nodeName);}},setFilters:{first:function(elem,i){return i===0;},last:function(elem,i,match,array){return i===array.length-1;},even:function(elem,i){return i%2===0;},odd:function(elem,i){return i%2===1;},lt:function(elem,i,match){return i<match[3]-0;},gt:function(elem,i,match){return i>match[3]-0;},nth:function(elem,i,match){return match[3]-0==i;},eq:function(elem,i,match){return match[3]-0==i;}},filter:{PSEUDO:function(elem,match,i,array){var name=match[1],filter=Expr.filters[name];if(filter){return filter(elem,i,match,array);}else if(name==="contains"){return(elem.textContent||elem.innerText||"").indexOf(match[3])>=0;}else if(name==="not"){var not=match[3];for(var i=0,l=not.length;i<l;i++){if(not[i]===elem){return false;}}
return true;}},CHILD:function(elem,match){var type=match[1],node=elem;switch(type){case'only':case'first':while(node=node.previousSibling){if(node.nodeType===1)return false;}
if(type=='first')return true;node=elem;case'last':while(node=node.nextSibling){if(node.nodeType===1)return false;}
return true;case'nth':var first=match[2],last=match[3];if(first==1&&last==0){return true;}
var doneName=match[0],parent=elem.parentNode;if(parent&&(parent.sizcache!==doneName||!elem.nodeIndex)){var count=0;for(node=parent.firstChild;node;node=node.nextSibling){if(node.nodeType===1){node.nodeIndex=++count;}}
parent.sizcache=doneName;}
var diff=elem.nodeIndex-last;if(first==0){return diff==0;}else{return(diff%first==0&&diff/first>=0);}}},ID:function(elem,match){return elem.nodeType===1&&elem.getAttribute("id")===match;},TAG:function(elem,match){return(match==="*"&&elem.nodeType===1)||elem.nodeName===match;},CLASS:function(elem,match){return(" "+(elem.className||elem.getAttribute("class"))+" ").indexOf(match)>-1;},ATTR:function(elem,match){var name=match[1],result=Expr.attrHandle[name]?Expr.attrHandle[name](elem):elem[name]!=null?elem[name]:elem.getAttribute(name),value=result+"",type=match[2],check=match[4];return result==null?type==="!=":type==="="?value===check:type==="*="?value.indexOf(check)>=0:type==="~="?(" "+value+" ").indexOf(check)>=0:!check?value&&result!==false:type==="!="?value!=check:type==="^="?value.indexOf(check)===0:type==="$="?value.substr(value.length-check.length)===check:type==="|="?value===check||value.substr(0,check.length+1)===check+"-":false;},POS:function(elem,match,i,array){var name=match[2],filter=Expr.setFilters[name];if(filter){return filter(elem,i,match,array);}}}};var origPOS=Expr.match.POS;for(var type in Expr.match){Expr.match[type]=RegExp(Expr.match[type].source+/(?![^\[]*\])(?![^\(]*\))/.source);}
var makeArray=function(array,results){array=Array.prototype.slice.call(array);if(results){results.push.apply(results,array);return results;}
return array;};try{Array.prototype.slice.call(document.documentElement.childNodes);}catch(e){makeArray=function(array,results){var ret=results||[];if(toString.call(array)==="[object Array]"){Array.prototype.push.apply(ret,array);}else{if(typeof array.length==="number"){for(var i=0,l=array.length;i<l;i++){ret.push(array[i]);}}else{for(var i=0;array[i];i++){ret.push(array[i]);}}}
return ret;};}
var sortOrder;if(document.documentElement.compareDocumentPosition){sortOrder=function(a,b){var ret=a.compareDocumentPosition(b)&4?-1:a===b?0:1;if(ret===0){hasDuplicate=true;}
return ret;};}else if("sourceIndex"in document.documentElement){sortOrder=function(a,b){var ret=a.sourceIndex-b.sourceIndex;if(ret===0){hasDuplicate=true;}
return ret;};}else if(document.createRange){sortOrder=function(a,b){var aRange=a.ownerDocument.createRange(),bRange=b.ownerDocument.createRange();aRange.selectNode(a);aRange.collapse(true);bRange.selectNode(b);bRange.collapse(true);var ret=aRange.compareBoundaryPoints(Range.START_TO_END,bRange);if(ret===0){hasDuplicate=true;}
return ret;};}
(function(){var form=document.createElement("form"),id="script"+(new Date).getTime();form.innerHTML="<input name='"+id+"'/>";var root=document.documentElement;root.insertBefore(form,root.firstChild);if(!!document.getElementById(id)){Expr.find.ID=function(match,context,isXML){if(typeof context.getElementById!=="undefined"&&!isXML){var m=context.getElementById(match[1]);return m?m.id===match[1]||typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id").nodeValue===match[1]?[m]:undefined:[];}};Expr.filter.ID=function(elem,match){var node=typeof elem.getAttributeNode!=="undefined"&&elem.getAttributeNode("id");return elem.nodeType===1&&node&&node.nodeValue===match;};}
root.removeChild(form);})();(function(){var div=document.createElement("div");div.appendChild(document.createComment(""));if(div.getElementsByTagName("*").length>0){Expr.find.TAG=function(match,context){var results=context.getElementsByTagName(match[1]);if(match[1]==="*"){var tmp=[];for(var i=0;results[i];i++){if(results[i].nodeType===1){tmp.push(results[i]);}}
results=tmp;}
return results;};}
div.innerHTML="<a href='#'></a>";if(div.firstChild&&typeof div.firstChild.getAttribute!=="undefined"&&div.firstChild.getAttribute("href")!=="#"){Expr.attrHandle.href=function(elem){return elem.getAttribute("href",2);};}})();if(document.querySelectorAll)(function(){var oldSizzle=Sizzle,div=document.createElement("div");div.innerHTML="<p class='TEST'></p>";if(div.querySelectorAll&&div.querySelectorAll(".TEST").length===0){return;}
Sizzle=function(query,context,extra,seed){context=context||document;if(!seed&&context.nodeType===9&&!isXML(context)){try{return makeArray(context.querySelectorAll(query),extra);}catch(e){}}
return oldSizzle(query,context,extra,seed);};Sizzle.find=oldSizzle.find;Sizzle.filter=oldSizzle.filter;Sizzle.selectors=oldSizzle.selectors;Sizzle.matches=oldSizzle.matches;})();if(document.getElementsByClassName&&document.documentElement.getElementsByClassName)(function(){var div=document.createElement("div");div.innerHTML="<div class='test e'></div><div class='test'></div>";if(div.getElementsByClassName("e").length===0)
return;div.lastChild.className="e";if(div.getElementsByClassName("e").length===1)
return;Expr.order.splice(1,0,"CLASS");Expr.find.CLASS=function(match,context,isXML){if(typeof context.getElementsByClassName!=="undefined"&&!isXML){return context.getElementsByClassName(match[1]);}};})();function dirNodeCheck(dir,cur,doneName,checkSet,nodeCheck,isXML){var sibDir=dir=="previousSibling"&&!isXML;for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){if(sibDir&&elem.nodeType===1){elem.sizcache=doneName;elem.sizset=i;}
elem=elem[dir];var match=false;while(elem){if(elem.sizcache===doneName){match=checkSet[elem.sizset];break;}
if(elem.nodeType===1&&!isXML){elem.sizcache=doneName;elem.sizset=i;}
if(elem.nodeName===cur){match=elem;break;}
elem=elem[dir];}
checkSet[i]=match;}}}
function dirCheck(dir,cur,doneName,checkSet,nodeCheck,isXML){var sibDir=dir=="previousSibling"&&!isXML;for(var i=0,l=checkSet.length;i<l;i++){var elem=checkSet[i];if(elem){if(sibDir&&elem.nodeType===1){elem.sizcache=doneName;elem.sizset=i;}
elem=elem[dir];var match=false;while(elem){if(elem.sizcache===doneName){match=checkSet[elem.sizset];break;}
if(elem.nodeType===1){if(!isXML){elem.sizcache=doneName;elem.sizset=i;}
if(typeof cur!=="string"){if(elem===cur){match=true;break;}}else if(Sizzle.filter(cur,[elem]).length>0){match=elem;break;}}
elem=elem[dir];}
checkSet[i]=match;}}}
var contains=document.compareDocumentPosition?function(a,b){return a.compareDocumentPosition(b)&16;}:function(a,b){return a!==b&&(a.contains?a.contains(b):true);};var isXML=function(elem){return elem.nodeType===9&&elem.documentElement.nodeName!=="HTML"||!!elem.ownerDocument&&isXML(elem.ownerDocument);};var posProcess=function(selector,context){var tmpSet=[],later="",match,root=context.nodeType?[context]:context;while((match=Expr.match.PSEUDO.exec(selector))){later+=match[0];selector=selector.replace(Expr.match.PSEUDO,"");}
selector=Expr.relative[selector]?selector+"*":selector;for(var i=0,l=root.length;i<l;i++){Sizzle(selector,root[i],tmpSet);}
return Sizzle.filter(later,tmpSet);};jQuery.find=Sizzle;jQuery.filter=Sizzle.filter;jQuery.expr=Sizzle.selectors;jQuery.expr[":"]=jQuery.expr.filters;Sizzle.selectors.filters.hidden=function(elem){return elem.offsetWidth===0||elem.offsetHeight===0;};Sizzle.selectors.filters.visible=function(elem){return elem.offsetWidth>0||elem.offsetHeight>0;};Sizzle.selectors.filters.animated=function(elem){return jQuery.grep(jQuery.timers,function(fn){return elem===fn.elem;}).length;};jQuery.multiFilter=function(expr,elems,not){if(not){expr=":not("+expr+")";}
return Sizzle.matches(expr,elems);};jQuery.dir=function(elem,dir){var matched=[],cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)
matched.push(cur);cur=cur[dir];}
return matched;};jQuery.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;};jQuery.sibling=function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&n!=elem)
r.push(n);}
return r;};return;window.Sizzle=Sizzle;})();jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)
return;if(elem.setInterval&&elem!=window)
elem=window;if(!handler.guid)
handler.guid=this.guid++;if(data!==undefined){var fn=handler;handler=this.proxy(fn);handler.data=data;}
var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){return typeof jQuery!=="undefined"&&!jQuery.event.triggered?jQuery.event.handle.apply(arguments.callee.elem,arguments):undefined;});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var namespaces=type.split(".");type=namespaces.shift();handler.type=namespaces.slice().sort().join(".");var handlers=events[type];if(jQuery.event.specialAll[type])
jQuery.event.specialAll[type].setup.call(elem,data,namespaces);if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem,data,namespaces)===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 namespaces=type.split(".");type=namespaces.shift();var namespace=RegExp("(^|\\.)"+namespaces.slice().sort().join(".*\\.")+"(\\.|$)");if(events[type]){if(handler)
delete events[type][handler.guid];else
for(var handle in events[type])
if(namespace.test(events[type][handle].type))
delete events[type][handle];if(jQuery.event.specialAll[type])
jQuery.event.specialAll[type].teardown.call(elem,namespaces);for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem,namespaces)===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(event,data,elem,bubbling){var type=event.type||event;if(!bubbling){event=typeof event==="object"?event[expando]?event:jQuery.extend(jQuery.Event(type),event):jQuery.Event(type);if(type.indexOf("!")>=0){event.type=type=type.slice(0,-1);event.exclusive=true;}
if(!elem){event.stopPropagation();if(this.global[type])
jQuery.each(jQuery.cache,function(){if(this.events&&this.events[type])
jQuery.event.trigger(event,data,this.handle.elem);});}
if(!elem||elem.nodeType==3||elem.nodeType==8)
return undefined;event.result=undefined;event.target=elem;data=jQuery.makeArray(data);data.unshift(event);}
event.currentTarget=elem;var handle=jQuery.data(elem,"handle");if(handle)
handle.apply(elem,data);if((!elem[type]||(jQuery.nodeName(elem,'a')&&type=="click"))&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)
event.result=false;if(!bubbling&&elem[type]&&!event.isDefaultPrevented()&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}
this.triggered=false;if(!event.isPropagationStopped()){var parent=elem.parentNode||elem.ownerDocument;if(parent)
jQuery.event.trigger(event,data,parent,true);}},handle:function(event){var all,handlers;event=arguments[0]=jQuery.event.fix(event||window.event);event.currentTarget=this;var namespaces=event.type.split(".");event.type=namespaces.shift();all=!namespaces.length&&!event.exclusive;var namespace=RegExp("(^|\\.)"+namespaces.slice().sort().join(".*\\.")+"(\\.|$)");handlers=(jQuery.data(this,"events")||{})[event.type];for(var j in handlers){var handler=handlers[j];if(all||namespace.test(handler.type)){event.handler=handler;event.data=handler.data;var ret=handler.apply(this,arguments);if(ret!==undefined){event.result=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}
if(event.isImmediatePropagationStopped())
break;}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(event){if(event[expando])
return event;var originalEvent=event;event=jQuery.Event(originalEvent);for(var i=this.props.length,prop;i;){prop=this.props[--i];event[prop]=originalEvent[prop];}
if(!event.target)
event.target=event.srcElement||document;if(event.target.nodeType==3)
event.target=event.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;},proxy:function(fn,proxy){proxy=proxy||function(){return fn.apply(this,arguments);};proxy.guid=fn.guid=fn.guid||proxy.guid||this.guid++;return proxy;},special:{ready:{setup:bindReady,teardown:function(){}}},specialAll:{live:{setup:function(selector,namespaces){jQuery.event.add(this,namespaces[0],liveHandler);},teardown:function(namespaces){if(namespaces.length){var remove=0,name=RegExp("(^|\\.)"+namespaces[0]+"(\\.|$)");jQuery.each((jQuery.data(this,"events").live||{}),function(){if(name.test(this.type))
remove++;});if(remove<1)
jQuery.event.remove(this,namespaces[0],liveHandler);}}}}};jQuery.Event=function(src){if(!this.preventDefault)
return new jQuery.Event(src);if(src&&src.type){this.originalEvent=src;this.type=src.type;}else
this.type=src;this.timeStamp=now();this[expando]=true;};function returnFalse(){return false;}
function returnTrue(){return true;}
jQuery.Event.prototype={preventDefault:function(){this.isDefaultPrevented=returnTrue;var e=this.originalEvent;if(!e)
return;if(e.preventDefault)
e.preventDefault();e.returnValue=false;},stopPropagation:function(){this.isPropagationStopped=returnTrue;var e=this.originalEvent;if(!e)
return;if(e.stopPropagation)
e.stopPropagation();e.cancelBubble=true;},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=returnTrue;this.stopPropagation();},isDefaultPrevented:returnFalse,isPropagationStopped:returnFalse,isImmediatePropagationStopped:returnFalse};var withinElement=function(event){var parent=event.relatedTarget;while(parent&&parent!=this)
try{parent=parent.parentNode;}
catch(e){parent=this;}
if(parent!=this){event.type=event.data;jQuery.event.handle.apply(this,arguments);}};jQuery.each({mouseover:'mouseenter',mouseout:'mouseleave'},function(orig,fix){jQuery.event.special[fix]={setup:function(){jQuery.event.add(this,orig,withinElement,fix);},teardown:function(){jQuery.event.remove(this,orig,withinElement);}};});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){var one=jQuery.event.proxy(fn||data,function(event){jQuery(this).unbind(event,one);return(fn||data).apply(this,arguments);});return this.each(function(){jQuery.event.add(this,type,one,fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data){return this.each(function(){jQuery.event.trigger(type,data,this);});},triggerHandler:function(type,data){if(this[0]){var event=jQuery.Event(type);event.preventDefault();event.stopPropagation();jQuery.event.trigger(event,data,this[0]);return event.result;}},toggle:function(fn){var args=arguments,i=1;while(i<args.length)
jQuery.event.proxy(fn,args[i++]);return this.click(jQuery.event.proxy(fn,function(event){this.lastToggle=(this.lastToggle||0)%i;event.preventDefault();return args[this.lastToggle++].apply(this,arguments)||false;}));},hover:function(fnOver,fnOut){return this.mouseenter(fnOver).mouseleave(fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)
fn.call(document,jQuery);else
jQuery.readyList.push(fn);return this;},live:function(type,fn){var proxy=jQuery.event.proxy(fn);proxy.guid+=this.selector+type;jQuery(document).bind(liveConvert(type,this.selector),this.selector,proxy);return this;},die:function(type,fn){jQuery(document).unbind(liveConvert(type,this.selector),fn?{guid:fn.guid+this.selector+type}:null);return this;}});function liveHandler(event){var check=RegExp("(^|\\.)"+event.type+"(\\.|$)"),stop=true,elems=[];jQuery.each(jQuery.data(this,"events").live||[],function(i,fn){if(check.test(fn.type)){var elem=jQuery(event.target).closest(fn.data)[0];if(elem)
elems.push({elem:elem,fn:fn});}});elems.sort(function(a,b){return jQuery.data(a.elem,"closest")-jQuery.data(b.elem,"closest");});jQuery.each(elems,function(){if(this.fn.call(this.elem,event,this.fn.data)===false)
return(stop=false);});return stop;}
function liveConvert(type,selector){return["live",type,selector.replace(/\./g,"`").replace(/ /g,"|")].join(".");}
jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.call(document,jQuery);});jQuery.readyList=null;}
jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);jQuery.ready();},false);}else if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);jQuery.ready();}});if(document.documentElement.doScroll&&window==window.top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){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,mouseenter,mouseleave,"+"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);};});jQuery(window).bind('unload',function(){for(var id in jQuery.cache)
if(id!=1&&jQuery.cache[id].handle)
jQuery.event.remove(jQuery.cache[id].handle.elem);});(function(){jQuery.support={};var root=document.documentElement,script=document.createElement("script"),div=document.createElement("div"),id="script"+(new Date).getTime();div.style.display="none";div.innerHTML='   <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var all=div.getElementsByTagName("*"),a=div.getElementsByTagName("a")[0];if(!all||!all.length||!a){return;}
jQuery.support={leadingWhitespace:div.firstChild.nodeType==3,tbody:!div.getElementsByTagName("tbody").length,objectAll:!!div.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!div.getElementsByTagName("link").length,style:/red/.test(a.getAttribute("style")),hrefNormalized:a.getAttribute("href")==="/a",opacity:a.style.opacity==="0.5",cssFloat:!!a.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};script.type="text/javascript";try{script.appendChild(document.createTextNode("window."+id+"=1;"));}catch(e){}
root.insertBefore(script,root.firstChild);if(window[id]){jQuery.support.scriptEval=true;delete window[id];}
root.removeChild(script);if(div.attachEvent&&div.fireEvent){div.attachEvent("onclick",function(){jQuery.support.noCloneEvent=false;div.detachEvent("onclick",arguments.callee);});div.cloneNode(true).fireEvent("onclick");}
jQuery(function(){var div=document.createElement("div");div.style.width=div.style.paddingLeft="1px";document.body.appendChild(div);jQuery.boxModel=jQuery.support.boxModel=div.offsetWidth===2;document.body.removeChild(div).style.display='none';});})();var styleFloat=jQuery.support.cssFloat?"cssFloat":"styleFloat";jQuery.props={"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};jQuery.fn.extend({_load:jQuery.fn.load,load:function(url,params,callback){if(typeof url!=="string")
return this._load(url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}
var type="GET";if(params)
if(jQuery.isFunction(params)){callback=params;params=null;}else if(typeof params==="object"){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);if(callback)
self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return this.elements?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:jQuery.isArray(val)?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=now();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:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();},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){s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));var jsonp,jsre=/=\?(&|$)/g,status,data,type=s.type.toUpperCase();if(s.data&&s.processData&&typeof s.data!=="string")
s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(type=="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&&type=="GET"){var ts=now();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}
if(s.data&&type=="GET"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}
if(s.global&&!jQuery.active++)
jQuery.event.trigger("ajaxStart");var parts=/^(\w+:)?\/\/([^\/?#]+)/.exec(s.url);if(s.dataType=="script"&&type=="GET"&&parts&&(parts[1]&&parts[1]!=location.protocol||parts[2]!=location.host)){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();script.onload=script.onreadystatechange=null;head.removeChild(script);}};}
head.appendChild(script);return undefined;}
var requestDone=false;var xhr=s.xhr();if(s.username)
xhr.open(type,s.url,s.async,s.username,s.password);else
xhr.open(type,s.url,s.async);try{if(s.data)
xhr.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)
xhr.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}
if(s.beforeSend&&s.beforeSend(xhr,s)===false){if(s.global&&!--jQuery.active)
jQuery.event.trigger("ajaxStop");xhr.abort();return false;}
if(s.global)
jQuery.event.trigger("ajaxSend",[xhr,s]);var onreadystatechange=function(isTimeout){if(xhr.readyState==0){if(ival){clearInterval(ival);ival=null;if(s.global&&!--jQuery.active)
jQuery.event.trigger("ajaxStop");}}else if(!requestDone&&xhr&&(xhr.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}
status=isTimeout=="timeout"?"timeout":!jQuery.httpSuccess(xhr)?"error":s.ifModified&&jQuery.httpNotModified(xhr,s.url)?"notmodified":"success";if(status=="success"){try{data=jQuery.httpData(xhr,s.dataType,s);}catch(e){status="parsererror";}}
if(status=="success"){var modRes;try{modRes=xhr.getResponseHeader("Last-Modified");}catch(e){}
if(s.ifModified&&modRes)
jQuery.lastModified[s.url]=modRes;if(!jsonp)
success();}else
jQuery.handleError(s,xhr,status);complete();if(isTimeout)
xhr.abort();if(s.async)
xhr=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)
setTimeout(function(){if(xhr&&!requestDone)
onreadystatechange("timeout");},s.timeout);}
try{xhr.send(s.data);}catch(e){jQuery.handleError(s,xhr,null,e);}
if(!s.async)
onreadystatechange();function success(){if(s.success)
s.success(data,status);if(s.global)
jQuery.event.trigger("ajaxSuccess",[xhr,s]);}
function complete(){if(s.complete)
s.complete(xhr,status);if(s.global)
jQuery.event.trigger("ajaxComplete",[xhr,s]);if(s.global&&!--jQuery.active)
jQuery.event.trigger("ajaxStop");}
return xhr;},handleError:function(s,xhr,status,e){if(s.error)s.error(xhr,status,e);if(s.global)
jQuery.event.trigger("ajaxError",[xhr,s,e]);},active:0,httpSuccess:function(xhr){try{return!xhr.status&&location.protocol=="file:"||(xhr.status>=200&&xhr.status<300)||xhr.status==304||xhr.status==1223;}catch(e){}
return false;},httpNotModified:function(xhr,url){try{var xhrRes=xhr.getResponseHeader("Last-Modified");return xhr.status==304||xhrRes==jQuery.lastModified[url];}catch(e){}
return false;},httpData:function(xhr,type,s){var ct=xhr.getResponseHeader("content-type"),xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0,data=xml?xhr.responseXML:xhr.responseText;if(xml&&data.documentElement.tagName=="parsererror")
throw"parsererror";if(s&&s.dataFilter)
data=s.dataFilter(data,type);if(typeof data==="string"){if(type=="script")
jQuery.globalEval(data);if(type=="json")
data=window["eval"]("("+data+")");}
return data;},param:function(a){var s=[];function add(key,value){s[s.length]=encodeURIComponent(key)+'='+encodeURIComponent(value);};if(jQuery.isArray(a)||a.jquery)
jQuery.each(a,function(){add(this.name,this.value);});else
for(var j in a)
if(jQuery.isArray(a[j]))
jQuery.each(a[j],function(){add(j,this);});else
add(j,jQuery.isFunction(a[j])?a[j]():a[j]);return s.join("&").replace(/%20/g,"+");}});var elemdisplay={},timerId,fxAttrs=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function genFx(type,num){var obj={};jQuery.each(fxAttrs.concat.apply([],fxAttrs.slice(0,num)),function(){obj[this]=type;});return obj;}
jQuery.fn.extend({show:function(speed,callback){if(speed){return this.animate(genFx("show",3),speed,callback);}else{for(var i=0,l=this.length;i<l;i++){var old=jQuery.data(this[i],"olddisplay");this[i].style.display=old||"";if(jQuery.css(this[i],"display")==="none"){var tagName=this[i].tagName,display;if(elemdisplay[tagName]){display=elemdisplay[tagName];}else{var elem=jQuery("<"+tagName+" />").appendTo("body");display=elem.css("display");if(display==="none")
display="block";elem.remove();elemdisplay[tagName]=display;}
jQuery.data(this[i],"olddisplay",display);}}
for(var i=0,l=this.length;i<l;i++){this[i].style.display=jQuery.data(this[i],"olddisplay")||"";}
return this;}},hide:function(speed,callback){if(speed){return this.animate(genFx("hide",3),speed,callback);}else{for(var i=0,l=this.length;i<l;i++){var old=jQuery.data(this[i],"olddisplay");if(!old&&old!=="none")
jQuery.data(this[i],"olddisplay",jQuery.css(this[i],"display"));}
for(var i=0,l=this.length;i<l;i++){this[i].style.display="none";}
return this;}},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){var bool=typeof fn==="boolean";return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle.apply(this,arguments):fn==null||bool?this.each(function(){var state=bool?fn:jQuery(this).is(":hidden");jQuery(this)[state?"show":"hide"]();}):this.animate(genFx("toggle",3),fn,fn2);},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(){var opt=jQuery.extend({},optall),p,hidden=this.nodeType==1&&jQuery(this).is(":hidden"),self=this;for(p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)
return opt.complete.call(this);if((p=="height"||p=="width")&&this.style){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;});},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;}});jQuery.each({slideDown:genFx("show",1),slideUp:genFx("hide",1),slideToggle:genFx("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(name,props){jQuery.fn[name]=function(speed,callback){return this.animate(props,speed,callback);};});jQuery.extend({speed:function(speed,easing,fn){var opt=typeof speed==="object"?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&!jQuery.isFunction(easing)&&easing};opt.duration=jQuery.fx.off?0:typeof opt.duration==="number"?opt.duration:jQuery.fx.speeds[opt.duration]||jQuery.fx.speeds._default;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)
jQuery(this).dequeue();if(jQuery.isFunction(opt.old))
opt.old.call(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:[],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.call(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)
this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&(!this.elem.style||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=now();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;var self=this;function t(gotoEnd){return self.step(gotoEnd);}
t.elem=this.elem;if(t()&&jQuery.timers.push(t)&&!timerId){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(timerId);timerId=undefined;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());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=now();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)
jQuery(this.elem).hide();if(this.options.hide||this.options.show)
for(var p in this.options.curAnim)
jQuery.attr(this.elem.style,p,this.options.orig[p]);this.options.complete.call(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.extend(jQuery.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){if(fx.elem.style&&fx.elem.style[fx.prop]!=null)
fx.elem.style[fx.prop]=fx.now+fx.unit;else
fx.elem[fx.prop]=fx.now;}}});if(document.documentElement["getBoundingClientRect"])
jQuery.fn.offset=function(){if(!this[0])return{top:0,left:0};if(this[0]===this[0].ownerDocument.body)return jQuery.offset.bodyOffset(this[0]);var box=this[0].getBoundingClientRect(),doc=this[0].ownerDocument,body=doc.body,docElem=doc.documentElement,clientTop=docElem.clientTop||body.clientTop||0,clientLeft=docElem.clientLeft||body.clientLeft||0,top=box.top+(self.pageYOffset||jQuery.boxModel&&docElem.scrollTop||body.scrollTop)-clientTop,left=box.left+(self.pageXOffset||jQuery.boxModel&&docElem.scrollLeft||body.scrollLeft)-clientLeft;return{top:top,left:left};};else
jQuery.fn.offset=function(){if(!this[0])return{top:0,left:0};if(this[0]===this[0].ownerDocument.body)return jQuery.offset.bodyOffset(this[0]);jQuery.offset.initialized||jQuery.offset.initialize();var elem=this[0],offsetParent=elem.offsetParent,prevOffsetParent=elem,doc=elem.ownerDocument,computedStyle,docElem=doc.documentElement,body=doc.body,defaultView=doc.defaultView,prevComputedStyle=defaultView.getComputedStyle(elem,null),top=elem.offsetTop,left=elem.offsetLeft;while((elem=elem.parentNode)&&elem!==body&&elem!==docElem){computedStyle=defaultView.getComputedStyle(elem,null);top-=elem.scrollTop,left-=elem.scrollLeft;if(elem===offsetParent){top+=elem.offsetTop,left+=elem.offsetLeft;if(jQuery.offset.doesNotAddBorder&&!(jQuery.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(elem.tagName)))
top+=parseInt(computedStyle.borderTopWidth,10)||0,left+=parseInt(computedStyle.borderLeftWidth,10)||0;prevOffsetParent=offsetParent,offsetParent=elem.offsetParent;}
if(jQuery.offset.subtractsBorderForOverflowNotVisible&&computedStyle.overflow!=="visible")
top+=parseInt(computedStyle.borderTopWidth,10)||0,left+=parseInt(computedStyle.borderLeftWidth,10)||0;prevComputedStyle=computedStyle;}
if(prevComputedStyle.position==="relative"||prevComputedStyle.position==="static")
top+=body.offsetTop,left+=body.offsetLeft;if(prevComputedStyle.position==="fixed")
top+=Math.max(docElem.scrollTop,body.scrollTop),left+=Math.max(docElem.scrollLeft,body.scrollLeft);return{top:top,left:left};};jQuery.offset={initialize:function(){if(this.initialized)return;var body=document.body,container=document.createElement('div'),innerDiv,checkDiv,table,td,rules,prop,bodyMarginTop=body.style.marginTop,html='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';rules={position:'absolute',top:0,left:0,margin:0,border:0,width:'1px',height:'1px',visibility:'hidden'};for(prop in rules)container.style[prop]=rules[prop];container.innerHTML=html;body.insertBefore(container,body.firstChild);innerDiv=container.firstChild,checkDiv=innerDiv.firstChild,td=innerDiv.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(checkDiv.offsetTop!==5);this.doesAddBorderForTableAndCells=(td.offsetTop===5);innerDiv.style.overflow='hidden',innerDiv.style.position='relative';this.subtractsBorderForOverflowNotVisible=(checkDiv.offsetTop===-5);body.style.marginTop='1px';this.doesNotIncludeMarginInBodyOffset=(body.offsetTop===0);body.style.marginTop=bodyMarginTop;body.removeChild(container);this.initialized=true;},bodyOffset:function(body){jQuery.offset.initialized||jQuery.offset.initialize();var top=body.offsetTop,left=body.offsetLeft;if(jQuery.offset.doesNotIncludeMarginInBodyOffset)
top+=parseInt(jQuery.curCSS(body,'marginTop',true),10)||0,left+=parseInt(jQuery.curCSS(body,'marginLeft',true),10)||0;return{top:top,left:left};}};jQuery.fn.extend({position:function(){var left=0,top=0,results;if(this[0]){var offsetParent=this.offsetParent(),offset=this.offset(),parentOffset=/^body|html$/i.test(offsetParent[0].tagName)?{top:0,left:0}:offsetParent.offset();offset.top-=num(this,'marginTop');offset.left-=num(this,'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||document.body;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&jQuery.css(offsetParent,'position')=='static'))
offsetParent=offsetParent.offsetParent;return jQuery(offsetParent);}});jQuery.each(['Left','Top'],function(i,name){var method='scroll'+name;jQuery.fn[method]=function(val){if(!this[0])return null;return val!==undefined?this.each(function(){this==window||this==document?window.scrollTo(!i?val:jQuery(window).scrollLeft(),i?val:jQuery(window).scrollTop()):this[method]=val;}):this[0]==window||this[0]==document?self[i?'pageYOffset':'pageXOffset']||jQuery.boxModel&&document.documentElement[method]||document.body[method]:this[0][method];};});jQuery.each(["Height","Width"],function(i,name){var tl=i?"Left":"Top",br=i?"Right":"Bottom",lower=name.toLowerCase();jQuery.fn["inner"+name]=function(){return this[0]?jQuery.css(this[0],lower,false,"padding"):null;};jQuery.fn["outer"+name]=function(margin){return this[0]?jQuery.css(this[0],lower,false,margin?"margin":"border"):null;};var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(document.documentElement["client"+name],document.body["scroll"+name],document.documentElement["scroll"+name],document.body["offset"+name],document.documentElement["offset"+name]):size===undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,typeof size==="string"?size:size+"px");};});})();(function($){$.fn.charCounter=function(max,settings){max=max||100;settings=$.extend({container:"<span>",classname:"charcounter",format:"(%1 characters remaining)",pulse:true},settings);var p;function count(el,container){el=$(el);if(el.val().length>max){el.val(el.val().substring(0,max));if(settings.pulse&&!p){pulse(container,true);};};container.html(settings.format.replace(/%1/,(max-el.val().length)));};function pulse(el,again){if(p){window.clearTimeout(p);p=null;};el.animate({opacity:0.1},100,function(){$(this).animate({opacity:1.0},100);});if(again){p=window.setTimeout(function(){pulse(el)},200);};};return this.each(function(){var container=(!settings.container.match(/^<.+>$/))?$(settings.container):$(settings.container).insertAfter(this).addClass(settings.classname);$(this).bind("keydown",function(){count(this,container);}).bind("keypress",function(){count(this,container);}).bind("keyup",function(){count(this,container);}).bind("focus",function(){count(this,container);}).bind("mouseover",function(){count(this,container);}).bind("mouseout",function(){count(this,container);}).bind("paste",function(){var me=this;setTimeout(function(){count(me,container);},10);});if(this.addEventListener){this.addEventListener('input',function(){count(this,container);},false);};count(this,container);});};})(jQuery);(function(jQuery){jQuery.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,attr){jQuery.fx.step[attr]=function(fx){if(fx.state==0){fx.start=getColor(fx.elem,attr);fx.end=getRGB(fx.end);}
fx.elem.style[attr]="rgb("+[Math.max(Math.min(parseInt((fx.pos*(fx.end[0]-fx.start[0]))+fx.start[0]),255),0),Math.max(Math.min(parseInt((fx.pos*(fx.end[1]-fx.start[1]))+fx.start[1]),255),0),Math.max(Math.min(parseInt((fx.pos*(fx.end[2]-fx.start[2]))+fx.start[2]),255),0)].join(",")+")";}});function getRGB(color){var result;if(color&&color.constructor==Array&&color.length==3)
return color;if(result=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
return[parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];if(result=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
return[parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];if(result=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
return[parseInt(result[1],16),parseInt(result[2],16),parseInt(result[3],16)];if(result=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
return[parseInt(result[1]+result[1],16),parseInt(result[2]+result[2],16),parseInt(result[3]+result[3],16)];return colors[jQuery.trim(color).toLowerCase()];}
function getColor(elem,attr){var color;do{color=jQuery.curCSS(elem,attr);if(color!=''&&color!='transparent'||jQuery.nodeName(elem,"body"))
break;attr="backgroundColor";}while(elem=elem.parentNode);return getRGB(color);};var colors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};})(jQuery);;(function($){var $scrollTo=$.scrollTo=function(target,duration,settings){$(window).scrollTo(target,duration,settings);};$scrollTo.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};$scrollTo.window=function(scope){return $(window)._scrollable();};$.fn._scrollable=function(){return this.map(function(){var elem=this,isWin=!elem.nodeName||$.inArray(elem.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)
return elem;var doc=(elem.contentWindow||elem).document||elem.ownerDocument||elem;return $.browser.safari||doc.compatMode=='BackCompat'?doc.body:doc.documentElement;});};$.fn.scrollTo=function(target,duration,settings){if(typeof duration=='object'){settings=duration;duration=0;}
if(typeof settings=='function')
settings={onAfter:settings};if(target=='max')
target=9e9;settings=$.extend({},$scrollTo.defaults,settings);duration=duration||settings.speed||settings.duration;settings.queue=settings.queue&&settings.axis.length>1;if(settings.queue)
duration/=2;settings.offset=both(settings.offset);settings.over=both(settings.over);return this._scrollable().each(function(){var elem=this,$elem=$(elem),targ=target,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break;}
targ=$(targ,this);case'object':if(targ.is||targ.style)
toff=(targ=$(targ)).offset();}
$.each(settings.axis.split(''),function(i,axis){var Pos=axis=='x'?'Left':'Top',pos=Pos.toLowerCase(),key='scroll'+Pos,old=elem[key],max=$scrollTo.max(elem,axis);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(settings.margin){attr[key]-=parseInt(targ.css('margin'+Pos))||0;attr[key]-=parseInt(targ.css('border'+Pos+'Width'))||0;}
attr[key]+=settings.offset[pos]||0;if(settings.over[pos])
attr[key]+=targ[axis=='x'?'width':'height']()*settings.over[pos];}else{var val=targ[pos];attr[key]=val.slice&&val.slice(-1)=='%'?parseFloat(val)/100*max:val;}
if(/^\d+$/.test(attr[key]))
attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&settings.queue){if(old!=attr[key])
animate(settings.onAfterFirst);delete attr[key];}});animate(settings.onAfter);function animate(callback){$elem.animate(attr,duration,settings.easing,callback&&function(){callback.call(this,target,settings);});};}).end();};$scrollTo.max=function(elem,axis){var Dim=axis=='x'?'Width':'Height',scroll='scroll'+Dim;if(!$(elem).is('html,body'))
return elem[scroll]-$(elem)[Dim.toLowerCase()]();var size='client'+Dim,html=elem.ownerDocument.documentElement,body=elem.ownerDocument.body;return Math.max(html[scroll],body[scroll])
-Math.min(html[size],body[size]);};function both(val){return typeof val=='object'?val:{top:val,left:val};};})(jQuery);;(function($){$.fn.ajaxSubmit=function(options){if(!this.length){log('ajaxSubmit: skipping submit process - no element selected');return this;}
if(typeof options=='function')
options={success:options};var url=$.trim(this.attr('action'));if(url){url=(url.match(/^([^#]+)/)||[])[1];}
url=url||window.location.href||''
options=$.extend({url:url,type:this.attr('method')||'GET'},options||{});var veto={};this.trigger('form-pre-serialize',[this,options,veto]);if(veto.veto){log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');return this;}
if(options.beforeSerialize&&options.beforeSerialize(this,options)===false){log('ajaxSubmit: submit aborted via beforeSerialize callback');return this;}
var a=this.formToArray(options.semantic);if(options.data){options.extraData=options.data;for(var n in options.data){if(options.data[n]instanceof Array){for(var k in options.data[n])
a.push({name:n,value:options.data[n][k]});}
else
a.push({name:n,value:options.data[n]});}}
if(options.beforeSubmit&&options.beforeSubmit(a,this,options)===false){log('ajaxSubmit: submit aborted via beforeSubmit callback');return this;}
this.trigger('form-submit-validate',[a,this,options,veto]);if(veto.veto){log('ajaxSubmit: submit vetoed via form-submit-validate trigger');return this;}
var q=$.param(a);if(options.type.toUpperCase()=='GET'){options.url+=(options.url.indexOf('?')>=0?'&':'?')+q;options.data=null;}
else
options.data=q;var $form=this,callbacks=[];if(options.resetForm)callbacks.push(function(){$form.resetForm();});if(options.clearForm)callbacks.push(function(){$form.clearForm();});if(!options.dataType&&options.target){var oldSuccess=options.success||function(){};callbacks.push(function(data){$(options.target).html(data).each(oldSuccess,arguments);});}
else if(options.success)
callbacks.push(options.success);options.success=function(data,status){for(var i=0,max=callbacks.length;i<max;i++)
callbacks[i].apply(options,[data,status,$form]);};var files=$('input:file',this).fieldValue();var found=false;for(var j=0;j<files.length;j++)
if(files[j])
found=true;var multipart=false;if(options.iframe||found||multipart){if(options.closeKeepAlive)
$.get(options.closeKeepAlive,fileUpload);else
fileUpload();}
else
$.ajax(options);this.trigger('form-submit-notify',[this,options]);return this;function fileUpload(){var form=$form[0];if($(':input[name=submit]',form).length){alert('Error: Form elements must not be named "submit".');return;}
var opts=$.extend({},$.ajaxSettings,options);var s=$.extend(true,{},$.extend(true,{},$.ajaxSettings),opts);var id='jqFormIO'+(new Date().getTime());var $io=$('<iframe id="'+id+'" name="'+id+'" src="about:blank" />');var io=$io[0];$io.css({position:'absolute',top:'-1000px',left:'-1000px'});var xhr={aborted:0,responseText:null,responseXML:null,status:0,statusText:'n/a',getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;$io.attr('src','about:blank');}};var g=opts.global;if(g&&!$.active++)$.event.trigger("ajaxStart");if(g)$.event.trigger("ajaxSend",[xhr,opts]);if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&$.active--;return;}
if(xhr.aborted)
return;var cbInvoked=0;var timedOut=0;var sub=form.clk;if(sub){var n=sub.name;if(n&&!sub.disabled){options.extraData=options.extraData||{};options.extraData[n]=sub.value;if(sub.type=="image"){options.extraData[name+'.x']=form.clk_x;options.extraData[name+'.y']=form.clk_y;}}}
setTimeout(function(){var t=$form.attr('target'),a=$form.attr('action');form.setAttribute('target',id);if(form.getAttribute('method')!='POST')
form.setAttribute('method','POST');if(form.getAttribute('action')!=opts.url)
form.setAttribute('action',opts.url);if(!options.skipEncodingOverride){$form.attr({encoding:'multipart/form-data',enctype:'multipart/form-data'});}
if(opts.timeout)
setTimeout(function(){timedOut=true;cb();},opts.timeout);var extraInputs=[];try{if(options.extraData)
for(var n in options.extraData)
extraInputs.push($('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />').appendTo(form)[0]);$io.appendTo('body');io.attachEvent?io.attachEvent('onload',cb):io.addEventListener('load',cb,false);form.submit();}
finally{form.setAttribute('action',a);t?form.setAttribute('target',t):$form.removeAttr('target');$(extraInputs).remove();}},10);var nullCheckFlag=0;function cb(){if(cbInvoked++)return;io.detachEvent?io.detachEvent('onload',cb):io.removeEventListener('load',cb,false);var ok=true;try{if(timedOut)throw'timeout';var data,doc;doc=io.contentWindow?io.contentWindow.document:io.contentDocument?io.contentDocument:io.document;if((doc.body==null||doc.body.innerHTML=='')&&!nullCheckFlag){nullCheckFlag=1;cbInvoked--;setTimeout(cb,100);return;}
xhr.responseText=doc.body?doc.body.innerHTML:null;xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc;xhr.getResponseHeader=function(header){var headers={'content-type':opts.dataType};return headers[header];};if(opts.dataType=='json'||opts.dataType=='script'){var ta=doc.getElementsByTagName('textarea')[0];xhr.responseText=ta?ta.value:xhr.responseText;}
else if(opts.dataType=='xml'&&!xhr.responseXML&&xhr.responseText!=null){xhr.responseXML=toXml(xhr.responseText);}
data=$.httpData(xhr,opts.dataType);}
catch(e){ok=false;$.handleError(opts,xhr,'error',e);}
if(ok){opts.success(data,'success');if(g)$.event.trigger("ajaxSuccess",[xhr,opts]);}
if(g)$.event.trigger("ajaxComplete",[xhr,opts]);if(g&&!--$.active)$.event.trigger("ajaxStop");if(opts.complete)opts.complete(xhr,ok?'success':'error');setTimeout(function(){$io.remove();xhr.responseXML=null;},100);};function toXml(s,doc){if(window.ActiveXObject){doc=new ActiveXObject('Microsoft.XMLDOM');doc.async='false';doc.loadXML(s);}
else
doc=(new DOMParser()).parseFromString(s,'text/xml');return(doc&&doc.documentElement&&doc.documentElement.tagName!='parsererror')?doc:null;};};};$.fn.ajaxForm=function(options){return this.ajaxFormUnbind().bind('submit.form-plugin',function(){$(this).ajaxSubmit(options);return false;}).each(function(){$(":submit,input:image",this).bind('click.form-plugin',function(e){var form=this.form;form.clk=this;if(this.type=='image'){if(e.offsetX!=undefined){form.clk_x=e.offsetX;form.clk_y=e.offsetY;}else if(typeof $.fn.offset=='function'){var offset=$(this).offset();form.clk_x=e.pageX-offset.left;form.clk_y=e.pageY-offset.top;}else{form.clk_x=e.pageX-this.offsetLeft;form.clk_y=e.pageY-this.offsetTop;}}
setTimeout(function(){form.clk=form.clk_x=form.clk_y=null;},10);});});};$.fn.ajaxFormUnbind=function(){this.unbind('submit.form-plugin');return this.each(function(){$(":submit,input:image",this).unbind('click.form-plugin');});};$.fn.formToArray=function(semantic){var a=[];if(this.length==0)return a;var form=this[0];var els=semantic?form.getElementsByTagName('*'):form.elements;if(!els)return a;for(var i=0,max=els.length;i<max;i++){var el=els[i];var n=el.name;if(!n)continue;if(semantic&&form.clk&&el.type=="image"){if(!el.disabled&&form.clk==el){a.push({name:n,value:$(el).val()});a.push({name:n+'.x',value:form.clk_x},{name:n+'.y',value:form.clk_y});}
continue;}
var v=$.fieldValue(el,true);if(v&&v.constructor==Array){for(var j=0,jmax=v.length;j<jmax;j++)
a.push({name:n,value:v[j]});}
else if(v!==null&&typeof v!='undefined')
a.push({name:n,value:v});}
if(!semantic&&form.clk){var $input=$(form.clk),input=$input[0],n=input.name;if(n&&!input.disabled&&input.type=='image'){a.push({name:n,value:$input.val()});a.push({name:n+'.x',value:form.clk_x},{name:n+'.y',value:form.clk_y});}}
return a;};$.fn.formSerialize=function(semantic){return $.param(this.formToArray(semantic));};$.fn.fieldSerialize=function(successful){var a=[];this.each(function(){var n=this.name;if(!n)return;var v=$.fieldValue(this,successful);if(v&&v.constructor==Array){for(var i=0,max=v.length;i<max;i++)
a.push({name:n,value:v[i]});}
else if(v!==null&&typeof v!='undefined')
a.push({name:this.name,value:v});});return $.param(a);};$.fn.fieldValue=function(successful){for(var val=[],i=0,max=this.length;i<max;i++){var el=this[i];var v=$.fieldValue(el,successful);if(v===null||typeof v=='undefined'||(v.constructor==Array&&!v.length))
continue;v.constructor==Array?$.merge(val,v):val.push(v);}
return val;};$.fieldValue=function(el,successful){var n=el.name,t=el.type,tag=el.tagName.toLowerCase();if(typeof successful=='undefined')successful=true;if(successful&&(!n||el.disabled||t=='reset'||t=='button'||(t=='checkbox'||t=='radio')&&!el.checked||(t=='submit'||t=='image')&&el.form&&el.form.clk!=el||tag=='select'&&el.selectedIndex==-1))
return null;if(tag=='select'){var index=el.selectedIndex;if(index<0)return null;var a=[],ops=el.options;var one=(t=='select-one');var max=(one?index+1:ops.length);for(var i=(one?index:0);i<max;i++){var op=ops[i];if(op.selected){var v=op.value;if(!v)
v=(op.attributes&&op.attributes['value']&&!(op.attributes['value'].specified))?op.text:op.value;if(one)return v;a.push(v);}}
return a;}
return el.value;};$.fn.clearForm=function(){return this.each(function(){$('input,select,textarea',this).clearFields();});};$.fn.clearFields=$.fn.clearInputs=function(){return this.each(function(){var t=this.type,tag=this.tagName.toLowerCase();if(t=='text'||t=='password'||tag=='textarea')
this.value='';else if(t=='checkbox'||t=='radio')
this.checked=false;else if(tag=='select')
this.selectedIndex=-1;});};$.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=='function'||(typeof this.reset=='object'&&!this.reset.nodeType))
this.reset();});};$.fn.enable=function(b){if(b==undefined)b=true;return this.each(function(){this.disabled=!b;});};$.fn.selected=function(select){if(select==undefined)select=true;return this.each(function(){var t=this.type;if(t=='checkbox'||t=='radio')
this.checked=select;else if(this.tagName.toLowerCase()=='option'){var $sel=$(this).parent('select');if(select&&$sel[0]&&$sel[0].type=='select-one'){$sel.find('option').selected(false);}
this.selected=select;}});};function log(){if($.fn.ajaxSubmit.debug&&window.console&&window.console.log)
window.console.log('[jquery.form] '+Array.prototype.join.call(arguments,''));};})(jQuery);(function($){$.extend($.fn,{validate:function(options){if(!this.length){options&&options.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing");return;}
var validator=$.data(this[0],'validator');if(validator){return validator;}
validator=new $.validator(options,this[0]);$.data(this[0],'validator',validator);if(validator.settings.onsubmit){this.find("input, button").filter(".cancel").click(function(){validator.cancelSubmit=true;});if(validator.settings.submitHandler){this.find("input, button").filter(":submit").click(function(){validator.submitButton=this;});}
this.submit(function(event){if(validator.settings.debug)
event.preventDefault();function handle(){if(validator.settings.submitHandler){if(validator.submitButton){var hidden=$("<input type='hidden'/>").attr("name",validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);}
validator.settings.submitHandler.call(validator,validator.currentForm);if(validator.submitButton){hidden.remove();}
return false;}
return true;}
if(validator.cancelSubmit){validator.cancelSubmit=false;return handle();}
if(validator.form()){if(validator.pendingRequest){validator.formSubmitted=true;return false;}
return handle();}else{validator.focusInvalid();return false;}});}
return validator;},valid:function(){if($(this[0]).is('form')){return this.validate().form();}else{var valid=true;var validator=$(this[0].form).validate();this.each(function(){valid&=validator.element(this);});return valid;}},removeAttrs:function(attributes){var result={},$element=this;$.each(attributes.split(/\s/),function(index,value){result[value]=$element.attr(value);$element.removeAttr(value);});return result;},rules:function(command,argument){var element=this[0];if(command){var settings=$.data(element.form,'validator').settings;var staticRules=settings.rules;var existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument));staticRules[element.name]=existingRules;if(argument.messages)
settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages);break;case"remove":if(!argument){delete staticRules[element.name];return existingRules;}
var filtered={};$.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method];delete existingRules[method];});return filtered;}}
var data=$.validator.normalizeRules($.extend({},$.validator.staticRules(element)),element);if(data.required){var param=data.required;delete data.required;data=$.extend({required:param},data);}
return data;}});$.extend($.expr[":"],{blank:function(a){return!$.trim(a.value);},filled:function(a){return!!$.trim(a.value);},unchecked:function(a){return!a.checked;}});$.validator=function(options,form){this.settings=$.extend({},$.validator.defaults,options);this.currentForm=form;this.init();};$.validator.format=function(source,params){if(arguments.length==1)
return function(){var args=$.makeArray(arguments);args.unshift(source);return $.validator.format.apply(this,args);};if(arguments.length>2&&params.constructor!=Array){params=$.makeArray(arguments).slice(1);}
if(params.constructor!=Array){params=[params];}
$.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),n);});return source;};$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:true,ignore:[],ignoreTitle:false,onfocusin:function(element){this.lastActive=element;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass);this.errorsFor(element).hide();}},onfocusout:function(element){if(!this.checkable(element)&&(element.name in this.submitted||!this.optional(element))){this.element(element);}},onkeyup:function(element){if(element.name in this.submitted||element==this.lastElement){this.element(element);}},onclick:function(element){if(element.name in this.submitted)
this.element(element);},highlight:function(element,errorClass,validClass){$(element).addClass(errorClass).removeClass(validClass);},unhighlight:function(element,errorClass,validClass){$(element).removeClass(errorClass).addClass(validClass);}},setDefaults:function(settings){$.extend($.validator.defaults,settings);},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",dateDE:"Bitte geben Sie ein gültiges Datum ein.",number:"Please enter a valid number.",numberDE:"Bitte geben Sie eine Nummer ein.",digits:"Please enter only digits",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){this.labelContainer=$(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm);this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var groups=(this.groups={});$.each(this.settings.groups,function(key,value){$.each(value.split(/\s/),function(index,name){groups[name]=key;});});var rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value);});function delegate(event){var validator=$.data(this[0].form,"validator");validator.settings["on"+event.type]&&validator.settings["on"+event.type].call(validator,this[0]);}
$(this.currentForm).delegate("focusin focusout keyup",":text, :password, :file, select, textarea",delegate).delegate("click",":radio, :checkbox",delegate);if(this.settings.invalidHandler)
$(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler);},form:function(){this.checkForm();$.extend(this.submitted,this.errorMap);this.invalid=$.extend({},this.errorMap);if(!this.valid())
$(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid();},checkForm:function(){this.prepareForm();for(var i=0,elements=(this.currentElements=this.elements());elements[i];i++){this.check(elements[i]);}
return this.valid();},element:function(element){element=this.clean(element);this.lastElement=element;this.prepareElement(element);this.currentElements=$(element);var result=this.check(element);if(result){delete this.invalid[element.name];}else{this.invalid[element.name]=true;}
if(!this.numberOfInvalids()){this.toHide=this.toHide.add(this.containers);}
this.showErrors();return result;},showErrors:function(errors){if(errors){$.extend(this.errorMap,errors);this.errorList=[];for(var name in errors){this.errorList.push({message:errors[name],element:this.findByName(name)[0]});}
this.successList=$.grep(this.successList,function(element){return!(element.name in errors);});}
this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors();},resetForm:function(){if($.fn.resetForm)
$(this.currentForm).resetForm();this.submitted={};this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass);},numberOfInvalids:function(){return this.objectLength(this.invalid);},objectLength:function(obj){var count=0;for(var i in obj)
count++;return count;},hideErrors:function(){this.addWrapper(this.toHide).hide();},valid:function(){return this.size()==0;},size:function(){return this.errorList.length;},focusInvalid:function(){if(this.settings.focusInvalid){try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus();}catch(e){}}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&$.grep(this.errorList,function(n){return n.element.name==lastActive.name;}).length==1&&lastActive;},elements:function(){var validator=this,rulesCache={};return $([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&validator.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in rulesCache||!validator.objectLength($(this).rules()))
return false;rulesCache[this.name]=true;return true;});},clean:function(selector){return $(selector)[0];},errors:function(){return $(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext);},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=$([]);this.toHide=$([]);this.currentElements=$([]);},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers);},prepareElement:function(element){this.reset();this.toHide=this.errorsFor(element);},check:function(element){element=this.clean(element);if(this.checkable(element)){element=this.findByName(element.name)[0];}
var rules=$(element).rules();var dependencyMismatch=false;for(method in rules){var rule={method:method,parameters:rules[method]};try{var result=$.validator.methods[method].call(this,element.value.replace(/\r/g,""),element,rule.parameters);if(result=="dependency-mismatch"){dependencyMismatch=true;continue;}
dependencyMismatch=false;if(result=="pending"){this.toHide=this.toHide.not(this.errorsFor(element));return;}
if(!result){this.formatAndAdd(element,rule);return false;}}catch(e){this.settings.debug&&window.console&&console.log("exception occured when checking element "+element.id
+", check the '"+rule.method+"' method");throw e;}}
if(dependencyMismatch)
return;if(this.objectLength(rules))
this.successList.push(element);return true;},customMetaMessage:function(element,method){if(!$.metadata)
return;var meta=this.settings.meta?$(element).metadata()[this.settings.meta]:$(element).metadata();return meta&&meta.messages&&meta.messages[method];},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor==String?m:m[method]);},findDefined:function(){for(var i=0;i<arguments.length;i++){if(arguments[i]!==undefined)
return arguments[i];}
return undefined;},defaultMessage:function(element,method){return this.findDefined(this.customMessage(element.name,method),this.customMetaMessage(element,method),!this.settings.ignoreTitle&&element.title||undefined,$.validator.messages[method],"<strong>Warning: No message defined for "+element.name+"</strong>");},formatAndAdd:function(element,rule){var message=this.defaultMessage(element,rule.method);if(typeof message=="function")
message=message.call(this,rule.parameters,element);this.errorList.push({message:message,element:element});this.errorMap[element.name]=message;this.submitted[element.name]=message;},addWrapper:function(toToggle){if(this.settings.wrapper)
toToggle=toToggle.add(toToggle.parent(this.settings.wrapper));return toToggle;},defaultShowErrors:function(){for(var i=0;this.errorList[i];i++){var error=this.errorList[i];this.settings.highlight&&this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass);this.showLabel(error.element,error.message);}
if(this.errorList.length){this.toShow=this.toShow.add(this.containers);}
if(this.settings.success){for(var i=0;this.successList[i];i++){this.showLabel(this.successList[i]);}}
if(this.settings.unhighlight){for(var i=0,elements=this.validElements();elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);}}
this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show();},validElements:function(){return this.currentElements.not(this.invalidElements());},invalidElements:function(){return $(this.errorList).map(function(){return this.element;});},showLabel:function(element,message){var label=this.errorsFor(element);if(label.length){label.removeClass().addClass(this.settings.errorClass);label.attr("generated")&&label.html(message);}else{label=$("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(element),generated:true}).addClass(this.settings.errorClass).html(message||"");if(this.settings.wrapper){label=label.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();}
if(!this.labelContainer.append(label).length)
this.settings.errorPlacement?this.settings.errorPlacement(label,$(element)):label.insertAfter(element);}
if(!message&&this.settings.success){label.text("");typeof this.settings.success=="string"?label.addClass(this.settings.success):this.settings.success(label);}
this.toShow=this.toShow.add(label);},errorsFor:function(element){return this.errors().filter("[for='"+this.idOrName(element)+"']");},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name);},checkable:function(element){return/radio|checkbox/i.test(element.type);},findByName:function(name){var form=this.currentForm;return $(document.getElementsByName(name)).map(function(index,element){return element.form==form&&element.name==name&&element||null;});},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case'select':return $("option:selected",element).length;case'input':if(this.checkable(element))
return this.findByName(element.name).filter(':checked').length;}
return value.length;},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):true;},dependTypes:{"boolean":function(param,element){return param;},"string":function(param,element){return!!$(param,element.form).length;},"function":function(param,element){return param(element);}},optional:function(element){return!$.validator.methods.required.call(this,$.trim(element.value),element)&&"dependency-mismatch";},startRequest:function(element){if(!this.pending[element.name]){this.pendingRequest++;this.pending[element.name]=true;}},stopRequest:function(element,valid){this.pendingRequest--;if(this.pendingRequest<0)
this.pendingRequest=0;delete this.pending[element.name];if(valid&&this.pendingRequest==0&&this.formSubmitted&&this.form()){this.currentForm.submit();this.formSubmitted=false;}else if(!valid&&this.pendingRequest==0&&this.formSubmitted){$(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=false;}},previousValue:function(element){return $.data(element,"previousValue")||$.data(element,"previousValue",previous={old:null,valid:true,message:this.defaultMessage(element,"remote")});}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(className,rules){className.constructor==String?this.classRuleSettings[className]=rules:$.extend(this.classRuleSettings,className);},classRules:function(element){var rules={};var classes=$(element).attr('class');classes&&$.each(classes.split(' '),function(){if(this in $.validator.classRuleSettings){$.extend(rules,$.validator.classRuleSettings[this]);}});return rules;},attributeRules:function(element){var rules={};var $element=$(element);for(method in $.validator.methods){var value=$element.attr(method);if(value){rules[method]=value;}}
if(rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)){delete rules.maxlength;}
return rules;},metadataRules:function(element){if(!$.metadata)return{};var meta=$.data(element.form,'validator').settings.meta;return meta?$(element).metadata()[meta]:$(element).metadata();},staticRules:function(element){var rules={};var validator=$.data(element.form,'validator');if(validator.settings.rules){rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{};}
return rules;},normalizeRules:function(rules,element){$.each(rules,function(prop,val){if(val===false){delete rules[prop];return;}
if(val.param||val.depends){var keepRule=true;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element);break;}
if(keepRule){rules[prop]=val.param!==undefined?val.param:true;}else{delete rules[prop];}}});$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)?parameter(element):parameter;});$.each(['minlength','maxlength','min','max'],function(){if(rules[this]){rules[this]=Number(rules[this]);}});$.each(['rangelength','range'],function(){if(rules[this]){rules[this]=[Number(rules[this][0]),Number(rules[this][1])];}});if($.validator.autoCreateRanges){if(rules.min&&rules.max){rules.range=[rules.min,rules.max];delete rules.min;delete rules.max;}
if(rules.minlength&&rules.maxlength){rules.rangelength=[rules.minlength,rules.maxlength];delete rules.minlength;delete rules.maxlength;}}
if(rules.messages){delete rules.messages}
return rules;},normalizeRule:function(data){if(typeof data=="string"){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=true;});data=transformed;}
return data;},addMethod:function(name,method,message){$.validator.methods[name]=method;$.validator.messages[name]=message||$.validator.messages[name];if(method.length<3){$.validator.addClassRules(name,$.validator.normalizeRule(name));}},methods:{required:function(value,element,param){if(!this.depend(param,element))
return"dependency-mismatch";switch(element.nodeName.toLowerCase()){case'select':var options=$("option:selected",element);return options.length>0&&(element.type=="select-multiple"||($.browser.msie&&!(options[0].attributes['value'].specified)?options[0].text:options[0].value).length>0);case'input':if(this.checkable(element))
return this.getLength(value,element)>0;default:return $.trim(value).length>0;}},remote:function(value,element,param){if(this.optional(element))
return"dependency-mismatch";var previous=this.previousValue(element);if(!this.settings.messages[element.name])
this.settings.messages[element.name]={};this.settings.messages[element.name].remote=typeof previous.message=="function"?previous.message(value):previous.message;param=typeof param=="string"&&{url:param}||param;if(previous.old!==value){previous.old=value;var validator=this;this.startRequest(element);var data={};data[element.name]=value;$.ajax($.extend(true,{url:param,mode:"abort",port:"validate"+element.name,dataType:"json",data:data,success:function(response){var valid=response===true;if(valid){var submitted=validator.formSubmitted;validator.prepareElement(element);validator.formSubmitted=submitted;validator.successList.push(element);validator.showErrors();}else{var errors={};errors[element.name]=previous.message=response||validator.defaultMessage(element,"remote");validator.showErrors(errors);}
previous.valid=valid;validator.stopRequest(element,valid);}},param));return"pending";}else if(this.pending[element.name]){return"pending";}
return previous.valid;},minlength:function(value,element,param){return this.optional(element)||this.getLength($.trim(value),element)>=param;},maxlength:function(value,element,param){return this.optional(element)||this.getLength($.trim(value),element)<=param;},rangelength:function(value,element,param){var length=this.getLength($.trim(value),element);return this.optional(element)||(length>=param[0]&&length<=param[1]);},min:function(value,element,param){return this.optional(element)||value>=param;},max:function(value,element,param){return this.optional(element)||value<=param;},range:function(value,element,param){return this.optional(element)||(value>=param[0]&&value<=param[1]);},email:function(value,element){return this.optional(element)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);},url:function(value,element){return this.optional(element)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value));},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);},dateDE:function(value,element){return this.optional(element)||/^\d\d?\.\d\d?\.\d\d\d?\d?$/.test(value);},number:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);},numberDE:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:,\d+)?$/.test(value);},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value);},creditcard:function(value,element){if(this.optional(element))
return"dependency-mismatch";if(/[^0-9-]+/.test(value))
return false;var nCheck=0,nDigit=0,bEven=false;value=value.replace(/\D/g,"");for(n=value.length-1;n>=0;n--){var cDigit=value.charAt(n);var nDigit=parseInt(cDigit,10);if(bEven){if((nDigit*=2)>9)
nDigit-=9;}
nCheck+=nDigit;bEven=!bEven;}
return(nCheck%10)==0;},accept:function(value,element,param){param=typeof param=="string"?param.replace(/,/g,'|'):"png|jpe?g|gif";return this.optional(element)||value.match(new RegExp(".("+param+")$","i"));},equalTo:function(value,element,param){return value==$(param).val();}}});$.format=$.validator.format;})(jQuery);;(function($){var ajax=$.ajax;var pendingRequests={};$.ajax=function(settings){settings=$.extend(settings,$.extend({},$.ajaxSettings,settings));var port=settings.port;if(settings.mode=="abort"){if(pendingRequests[port]){pendingRequests[port].abort();}
return(pendingRequests[port]=ajax.apply(this,arguments));}
return ajax.apply(this,arguments);};})(jQuery);;(function($){$.each({focus:'focusin',blur:'focusout'},function(original,fix){$.event.special[fix]={setup:function(){if($.browser.msie)return false;this.addEventListener(original,$.event.special[fix].handler,true);},teardown:function(){if($.browser.msie)return false;this.removeEventListener(original,$.event.special[fix].handler,true);},handler:function(e){arguments[0]=$.event.fix(e);arguments[0].type=fix;return $.event.handle.apply(this,arguments);}};});$.extend($.fn,{delegate:function(type,delegate,handler){return this.bind(type,function(event){var target=$(event.target);if(target.is(delegate)){return handler.apply(target,arguments);}});},triggerEvent:function(type,target){return this.triggerHandler(type,[$.event.fix({type:type,target:target})]);}});})(jQuery);jQuery.easing['jswing']=jQuery.easing['swing'];jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(x,t,b,c,d){return jQuery.easing[jQuery.easing.def](x,t,b,c,d);},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b;},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeInOutQuad:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b;},easeInCubic:function(x,t,b,c,d){return c*(t/=d)*t*t+b;},easeOutCubic:function(x,t,b,c,d){return c*((t=t/d-1)*t*t+1)+b;},easeInOutCubic:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t+b;return c/2*((t-=2)*t*t+2)+b;},easeInQuart:function(x,t,b,c,d){return c*(t/=d)*t*t*t+b;},easeOutQuart:function(x,t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;},easeInOutQuart:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b;},easeInQuint:function(x,t,b,c,d){return c*(t/=d)*t*t*t*t+b;},easeOutQuint:function(x,t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b;},easeInOutQuint:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b;},easeInSine:function(x,t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b;},easeOutSine:function(x,t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b;},easeInOutSine:function(x,t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b;},easeInExpo:function(x,t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b;},easeOutExpo:function(x,t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b;},easeInOutExpo:function(x,t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b;return c/2*(-Math.pow(2,-10*--t)+2)+b;},easeInCirc:function(x,t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b;},easeOutCirc:function(x,t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b;},easeInOutCirc:function(x,t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b;},easeInElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;},easeOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b;},easeInOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4;}
else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b;},easeInBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b;},easeOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;},easeInOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;},easeInBounce:function(x,t,b,c,d){return c-jQuery.easing.easeOutBounce(x,d-t,0,c,d)+b;},easeOutBounce:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;}},easeInOutBounce:function(x,t,b,c,d){if(t<d/2)return jQuery.easing.easeInBounce(x,t*2,0,c,d)*.5+b;return jQuery.easing.easeOutBounce(x,t*2-d,0,c,d)*.5+c*.5+b;}});(function($){$.extend({metadata:{defaults:{type:'class',name:'metadata',cre:/({.*})/,single:'metadata'},setType:function(type,name){this.defaults.type=type;this.defaults.name=name;},get:function(elem,opts){var settings=$.extend({},this.defaults,opts);if(!settings.single.length)settings.single='metadata';var data=$.data(elem,settings.single);if(data)return data;data="{}";if(settings.type=="class"){var m=settings.cre.exec(elem.className);if(m)
data=m[1];}else if(settings.type=="elem"){if(!elem.getElementsByTagName)return;var e=elem.getElementsByTagName(settings.name);if(e.length)
data=$.trim(e[0].innerHTML);}else if(elem.getAttribute!=undefined){var attr=elem.getAttribute(settings.name);if(attr)
data=attr;}
if(data.indexOf('{')<0)
data="{"+data+"}";data=eval("("+data+")");$.data(elem,settings.single,data);return data;}}});$.fn.metadata=function(opts){return $.metadata.get(this[0],opts);};})(jQuery);(function($){var totalAreas=0;$.fn.autogrow=function(){return this.each(function(){var $textarea=$(this);if($textarea.data('autogrow')){return false;}else{$textarea.data('autogrow',true);}
var interval;var font_size=parseInt($textarea.css('font-size'),10);var original_height=parseInt($textarea.css('height'),10);var min_height=parseInt($textarea.css('min-height'),10);min_height=min_height||original_height;var grow_height=0;totalAreas+=1;var $dummy=$('<div id="autogrow-dummy-'+totalAreas+'"></div>').css({fontSize:$textarea.css('font-size'),fontFamily:$textarea.css('font-family'),paddingLeft:$textarea.css('padding-left'),paddingRight:$textarea.css('padding-right'),paddingTop:$textarea.css('padding-top'),paddingBottom:$textarea.css('padding-bottom'),width:$textarea.css('width'),lineHeight:$textarea.css('line-height'),overflowX:'hidden',display:'block',position:'absolute',top:0,left:'-9999px'}).appendTo('body');$textarea.css({overflow:'hidden',overflowY:'hidden',display:'block',minHeight:min_height+"px"});var startExpand=function(){var height=parseInt($textarea.css('height'),10);var manual=(height!=original_height&&height!=grow_height);if(!manual){stopExpand();interval=window.setInterval(checkExpand,300);}else{$textarea.css({overflow:'auto',overflowY:'auto'});}};var stopExpand=function(){clearInterval(interval);interval=null;};var checkExpand=function(){var html=$textarea.val().replace(/\n/g,'<br>new');if($dummy.html()!==html){$dummy.width($textarea.width()-font_size);$dummy.html(html.replace(/<(script|embed|object)|javascript/g,''));var dummyHeight=Math.max(min_height,$dummy.height()+font_size);if(parseInt($textarea.css("height"),10)!==dummyHeight){$textarea.stop().animate({height:dummyHeight+'px'},100,"linear");grow_height=dummyHeight;}}};$textarea.unbind('.autogrow').bind('focus.autogrow',startExpand).bind('blur.autogrow',stopExpand);return $textarea;});};})(jQuery);(function($){jQuery.fn.prettyDate=function(){function distanceOfTimeInWords(fromTime,toTime,includeSeconds){var fromSeconds=fromTime.getTime();var toSeconds=toTime.getTime();var distanceInSeconds=Math.round(Math.abs(fromSeconds-toSeconds)/1000);var distanceInMinutes=Math.round(distanceInSeconds/60);if(distanceInMinutes<=1){return(!includeSeconds&&(distanceInMinutes===0)?'less than a minute':'1 minute'||distanceInSeconds<5&&'less than 5 seconds'||distanceInSeconds<10&&'less than 10 seconds'||distanceInSeconds<20&&'less than 20 seconds'||distanceInSeconds<40&&'half a minute'||distanceInSeconds<60&&'less than a minute'||'1 minute');}
return(distanceInMinutes<45&&distanceInMinutes+" minutes"||distanceInMinutes<90&&"about 1 hour"||distanceInMinutes<1440&&"about "+(Math.round(distanceInMinutes/60))+" hours"||distanceInMinutes<2880&&"1 day"||distanceInMinutes<43200&&(Math.round(distanceInMinutes/1440))+" days"||distanceInMinutes<86400&&"about 1 month"||distanceInMinutes<525600&&(Math.round(distanceInMinutes/43200))+" months"||distanceInMinutes<1051200&&"about 1 year"||"over "+(Math.round(distanceInMinutes/525600))+" years");}
function prettyDate(timeString){var date=new Date(timeString);var now=new Date();var suffix=(date<now)?" ago":" from now";return distanceOfTimeInWords(date,now,true)+suffix;}
return this.each(function(){var date=prettyDate(this.title);if(date){$(this).text(date);}});};})(jQuery);;jQuery.ui||(function($){var _remove=$.fn.remove,isFF2=$.browser.mozilla&&(parseFloat($.browser.version)<1.9);$.ui={version:"1.7.2",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||!instance.element[0].parentNode){return;}
for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args);}}}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b);},hasScroll:function(el,a){if($(el).css('overflow')=='hidden'){return false;}
var scroll=(a&&a=='left')?'scrollLeft':'scrollTop',has=false;if(el[scroll]>0){return true;}
el[scroll]=1;has=(el[scroll]>0);el[scroll]=0;return has;},isOverAxis:function(x,reference,size){return(x>reference)&&(x<(reference+size));},isOver:function(y,x,top,left,height,width){return $.ui.isOverAxis(y,top,height)&&$.ui.isOverAxis(x,left,width);},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(isFF2){var attr=$.attr,removeAttr=$.fn.removeAttr,ariaNS="http://www.w3.org/2005/07/aaa",ariaState=/^aria-/,ariaRole=/^wairole:/;$.attr=function(elem,name,value){var set=value!==undefined;return(name=='role'?(set?attr.call(this,elem,name,"wairole:"+value):(attr.apply(this,arguments)||"").replace(ariaRole,"")):(ariaState.test(name)?(set?elem.setAttributeNS(ariaNS,name.replace(ariaState,"aaa:"),value):attr.call(this,elem,name.replace(ariaState,"aaa:"))):attr.apply(this,arguments)));};$.fn.removeAttr=function(name){return(ariaState.test(name)?this.each(function(){this.removeAttributeNS(ariaNS,name.replace(ariaState,""));}):removeAttr.call(this,name));};}
$.fn.extend({remove:function(){$("*",this).add(this).each(function(){$(this).triggerHandler("remove");});return _remove.apply(this,arguments);},enableSelection:function(){return this.attr('unselectable','off').css('MozUserSelect','').unbind('selectstart.ui');},disableSelection:function(){return this.attr('unselectable','on').css('MozUserSelect','none').bind('selectstart.ui',function(){return false;});},scrollParent:function(){var scrollParent;if(($.browser.msie&&(/(static|relative)/).test(this.css('position')))||(/absolute/).test(this.css('position'))){scrollParent=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test($.curCSS(this,'position',1))&&(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));}).eq(0);}else{scrollParent=this.parents().filter(function(){return(/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));}).eq(0);}
return(/fixed/).test(this.css('position'))||!scrollParent.length?$(document):scrollParent;}});$.extend($.expr[':'],{data:function(elem,i,match){return!!$.data(elem,match[3]);},focusable:function(element){var nodeName=element.nodeName.toLowerCase(),tabIndex=$.attr(element,'tabindex');return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:'a'==nodeName||'area'==nodeName?element.href||!isNaN(tabIndex):!isNaN(tabIndex))&&!$(element)['area'==nodeName?'parents':'closest'](':hidden').length;},tabbable:function(element){var tabIndex=$.attr(element,'tabindex');return(isNaN(tabIndex)||tabIndex>=0)&&$(element).is(':focusable');}});function getter(namespace,plugin,method,args){function getMethods(type){var methods=$[namespace][plugin][type]||[];return(typeof methods=='string'?methods.split(/,?\s+/):methods);}
var methods=getMethods('getter');if(args.length==1&&typeof args[0]=='string'){methods=methods.concat(getMethods('getterSetter'));}
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&&options.substring(0,1)=='_'){return this;}
if(isMethodCall&&getter(namespace,name,options,args)){var instance=$.data(this[0],name);return(instance?instance[options].apply(instance,args):undefined);}
return this.each(function(){var instance=$.data(this,name);(!instance&&!isMethodCall&&$.data(this,name,new $[namespace][name](this,options))._init());(instance&&isMethodCall&&$.isFunction(instance[options])&&instance[options].apply(instance,args));});};$[namespace]=$[namespace]||{};$[namespace][name]=function(element,options){var self=this;this.namespace=namespace;this.widgetName=name;this.widgetEventPrefix=$[namespace][name].eventPrefix||name;this.widgetBaseClass=namespace+'-'+name;this.options=$.extend({},$.widget.defaults,$[namespace][name].defaults,$.metadata&&$.metadata.get(element)[name],options);this.element=$(element).bind('setData.'+name,function(event,key,value){if(event.target==element){return self._setData(key,value);}}).bind('getData.'+name,function(event,key){if(event.target==element){return self._getData(key);}}).bind('remove',function(){return self.destroy();});};$[namespace][name].prototype=$.extend({},$.widget.prototype,prototype);$[namespace][name].getterSetter='option';};$.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+'-disabled'+' '+this.namespace+'-state-disabled').removeAttr('aria-disabled');},option:function(key,value){var options=key,self=this;if(typeof key=="string"){if(value===undefined){return this._getData(key);}
options={};options[key]=value;}
$.each(options,function(key,value){self._setData(key,value);});},_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'+' '+
this.namespace+'-state-disabled').attr("aria-disabled",value);}},enable:function(){this._setData('disabled',false);},disable:function(){this._setData('disabled',true);},_trigger:function(type,event,data){var callback=this.options[type],eventName=(type==this.widgetEventPrefix?type:this.widgetEventPrefix+type);event=$.Event(event);event.type=eventName;if(event.originalEvent){for(var i=$.event.props.length,prop;i;){prop=$.event.props[--i];event[prop]=event.originalEvent[prop];}}
this.element.trigger(event,data);return!($.isFunction(callback)&&callback.call(this.element[0],event,data)===false||event.isDefaultPrevented());}};$.widget.defaults={disabled:false};$.ui.mouse={_mouseInit:function(){var self=this;this.element.bind('mousedown.'+this.widgetName,function(event){return self._mouseDown(event);}).bind('click.'+this.widgetName,function(event){if(self._preventClickEvent){self._preventClickEvent=false;event.stopImmediatePropagation();return false;}});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(event){event.originalEvent=event.originalEvent||{};if(event.originalEvent.mouseHandled){return;}
(this._mouseStarted&&this._mouseUp(event));this._mouseDownEvent=event;var self=this,btnIsLeft=(event.which==1),elIsCancel=(typeof this.options.cancel=="string"?$(event.target).parents().add(event.target).filter(this.options.cancel).length:false);if(!btnIsLeft||elIsCancel||!this._mouseCapture(event)){return true;}
this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){self.mouseDelayMet=true;},this.options.delay);}
if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(event)!==false);if(!this._mouseStarted){event.preventDefault();return true;}}
this._mouseMoveDelegate=function(event){return self._mouseMove(event);};this._mouseUpDelegate=function(event){return self._mouseUp(event);};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);($.browser.safari||event.preventDefault());event.originalEvent.mouseHandled=true;return true;},_mouseMove:function(event){if($.browser.msie&&!event.button){return this._mouseUp(event);}
if(this._mouseStarted){this._mouseDrag(event);return event.preventDefault();}
if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,event)!==false);(this._mouseStarted?this._mouseDrag(event):this._mouseUp(event));}
return!this._mouseStarted;},_mouseUp:function(event){$(document).unbind('mousemove.'+this.widgetName,this._mouseMoveDelegate).unbind('mouseup.'+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(event.target==this._mouseDownEvent.target);this._mouseStop(event);}
return false;},_mouseDistanceMet:function(event){return(Math.max(Math.abs(this._mouseDownEvent.pageX-event.pageX),Math.abs(this._mouseDownEvent.pageY-event.pageY))>=this.options.distance);},_mouseDelayMet:function(event){return this.mouseDelayMet;},_mouseStart:function(event){},_mouseDrag:function(event){},_mouseStop:function(event){},_mouseCapture:function(event){return true;}};$.ui.mouse.defaults={cancel:null,distance:1,delay:0};})(jQuery);(function($){$.widget("ui.sortable",$.extend({},$.ui.mouse,{_init:function(){var o=this.options;this.containerCache={};this.element.addClass("ui-sortable");this.refresh();this.floating=this.items.length?(/left|right/).test(this.items[0].item.css('float')):false;this.offset=this.element.offset();this._mouseInit();},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var i=this.items.length-1;i>=0;i--)
this.items[i].item.removeData("sortable-item");},_mouseCapture:function(event,overrideHandle){if(this.reverting){return false;}
if(this.options.disabled||this.options.type=='static')return false;this._refreshItems(event);var currentItem=null,self=this,nodes=$(event.target).parents().each(function(){if($.data(this,'sortable-item')==self){currentItem=$(this);return false;}});if($.data(event.target,'sortable-item')==self)currentItem=$(event.target);if(!currentItem)return false;if(this.options.handle&&!overrideHandle){var validHandle=false;$(this.options.handle,currentItem).find("*").andSelf().each(function(){if(this==event.target)validHandle=true;});if(!validHandle)return false;}
this.currentItem=currentItem;this._removeCurrentsFromItems();return true;},_mouseStart:function(event,overrideHandle,noActivation){var o=this.options,self=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(event);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");$.extend(this.offset,{click:{left:event.pageX-this.offset.left,top:event.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(event);this.originalPageX=event.pageX;this.originalPageY=event.pageY;if(o.cursorAt)
this._adjustOffsetFromHelper(o.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};if(this.helper[0]!=this.currentItem[0]){this.currentItem.hide();}
this._createPlaceholder();if(o.containment)
this._setContainment();if(o.cursor){if($('body').css("cursor"))this._storedCursor=$('body').css("cursor");$('body').css("cursor",o.cursor);}
if(o.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",o.opacity);}
if(o.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",o.zIndex);}
if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!='HTML')
this.overflowOffset=this.scrollParent.offset();this._trigger("start",event,this._uiHash());if(!this._preserveHelperProportions)
this._cacheHelperProportions();if(!noActivation){for(var i=this.containers.length-1;i>=0;i--){this.containers[i]._trigger("activate",event,self._uiHash(this));}}
if($.ui.ddmanager)
$.ui.ddmanager.current=this;if($.ui.ddmanager&&!o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this,event);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(event);return true;},_mouseDrag:function(event){this.position=this._generatePosition(event);this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs){this.lastPositionAbs=this.positionAbs;}
if(this.options.scroll){var o=this.options,scrolled=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!='HTML'){if((this.overflowOffset.top+this.scrollParent[0].offsetHeight)-event.pageY<o.scrollSensitivity)
this.scrollParent[0].scrollTop=scrolled=this.scrollParent[0].scrollTop+o.scrollSpeed;else if(event.pageY-this.overflowOffset.top<o.scrollSensitivity)
this.scrollParent[0].scrollTop=scrolled=this.scrollParent[0].scrollTop-o.scrollSpeed;if((this.overflowOffset.left+this.scrollParent[0].offsetWidth)-event.pageX<o.scrollSensitivity)
this.scrollParent[0].scrollLeft=scrolled=this.scrollParent[0].scrollLeft+o.scrollSpeed;else if(event.pageX-this.overflowOffset.left<o.scrollSensitivity)
this.scrollParent[0].scrollLeft=scrolled=this.scrollParent[0].scrollLeft-o.scrollSpeed;}else{if(event.pageY-$(document).scrollTop()<o.scrollSensitivity)
scrolled=$(document).scrollTop($(document).scrollTop()-o.scrollSpeed);else if($(window).height()-(event.pageY-$(document).scrollTop())<o.scrollSensitivity)
scrolled=$(document).scrollTop($(document).scrollTop()+o.scrollSpeed);if(event.pageX-$(document).scrollLeft()<o.scrollSensitivity)
scrolled=$(document).scrollLeft($(document).scrollLeft()-o.scrollSpeed);else if($(window).width()-(event.pageX-$(document).scrollLeft())<o.scrollSensitivity)
scrolled=$(document).scrollLeft($(document).scrollLeft()+o.scrollSpeed);}
if(scrolled!==false&&$.ui.ddmanager&&!o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this,event);}
this.positionAbs=this._convertPositionTo("absolute");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';for(var i=this.items.length-1;i>=0;i--){var item=this.items[i],itemElement=item.item[0],intersection=this._intersectsWithPointer(item);if(!intersection)continue;if(itemElement!=this.currentItem[0]&&this.placeholder[intersection==1?"next":"prev"]()[0]!=itemElement&&!$.ui.contains(this.placeholder[0],itemElement)&&(this.options.type=='semi-dynamic'?!$.ui.contains(this.element[0],itemElement):true)){this.direction=intersection==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(item)){this._rearrange(event,item);}else{break;}
this._trigger("change",event,this._uiHash());break;}}
this._contactContainers(event);if($.ui.ddmanager)$.ui.ddmanager.drag(this,event);this._trigger('sort',event,this._uiHash());this.lastPositionAbs=this.positionAbs;return false;},_mouseStop:function(event,noPropagation){if(!event)return;if($.ui.ddmanager&&!this.options.dropBehaviour)
$.ui.ddmanager.drop(this,event);if(this.options.revert){var self=this;var cur=self.placeholder.offset();self.reverting=true;$(this.helper).animate({left:cur.left-this.offset.parent.left-self.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:cur.top-this.offset.parent.top-self.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){self._clear(event);});}else{this._clear(event,noPropagation);}
return false;},cancel:function(){var self=this;if(this.dragging){this._mouseUp();if(this.options.helper=="original")
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");else
this.currentItem.show();for(var i=this.containers.length-1;i>=0;i--){this.containers[i]._trigger("deactivate",null,self._uiHash(this));if(this.containers[i].containerCache.over){this.containers[i]._trigger("out",null,self._uiHash(this));this.containers[i].containerCache.over=0;}}}
if(this.placeholder[0].parentNode)this.placeholder[0].parentNode.removeChild(this.placeholder[0]);if(this.options.helper!="original"&&this.helper&&this.helper[0].parentNode)this.helper.remove();$.extend(this,{helper:null,dragging:false,reverting:false,_noFinalSort:null});if(this.domPosition.prev){$(this.domPosition.prev).after(this.currentItem);}else{$(this.domPosition.parent).prepend(this.currentItem);}
return true;},serialize:function(o){var items=this._getItemsAsjQuery(o&&o.connected);var str=[];o=o||{};$(items).each(function(){var res=($(o.item||this).attr(o.attribute||'id')||'').match(o.expression||(/(.+)[-=_](.+)/));if(res)str.push((o.key||res[1]+'[]')+'='+(o.key&&o.expression?res[1]:res[2]));});return str.join('&');},toArray:function(o){var items=this._getItemsAsjQuery(o&&o.connected);var ret=[];o=o||{};items.each(function(){ret.push($(o.item||this).attr(o.attribute||'id')||'');});return ret;},_intersectsWith:function(item){var x1=this.positionAbs.left,x2=x1+this.helperProportions.width,y1=this.positionAbs.top,y2=y1+this.helperProportions.height;var l=item.left,r=l+item.width,t=item.top,b=t+item.height;var dyClick=this.offset.click.top,dxClick=this.offset.click.left;var isOverElement=(y1+dyClick)>t&&(y1+dyClick)<b&&(x1+dxClick)>l&&(x1+dxClick)<r;if(this.options.tolerance=="pointer"||this.options.forcePointerForContainers||(this.options.tolerance!="pointer"&&this.helperProportions[this.floating?'width':'height']>item[this.floating?'width':'height'])){return isOverElement;}else{return(l<x1+(this.helperProportions.width/2)&&x2-(this.helperProportions.width/2)<r&&t<y1+(this.helperProportions.height/2)&&y2-(this.helperProportions.height/2)<b);}},_intersectsWithPointer:function(item){var isOverElementHeight=$.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,item.top,item.height),isOverElementWidth=$.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,item.left,item.width),isOverElement=isOverElementHeight&&isOverElementWidth,verticalDirection=this._getDragVerticalDirection(),horizontalDirection=this._getDragHorizontalDirection();if(!isOverElement)
return false;return this.floating?(((horizontalDirection&&horizontalDirection=="right")||verticalDirection=="down")?2:1):(verticalDirection&&(verticalDirection=="down"?2:1));},_intersectsWithSides:function(item){var isOverBottomHalf=$.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,item.top+(item.height/2),item.height),isOverRightHalf=$.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,item.left+(item.width/2),item.width),verticalDirection=this._getDragVerticalDirection(),horizontalDirection=this._getDragHorizontalDirection();if(this.floating&&horizontalDirection){return((horizontalDirection=="right"&&isOverRightHalf)||(horizontalDirection=="left"&&!isOverRightHalf));}else{return verticalDirection&&((verticalDirection=="down"&&isOverBottomHalf)||(verticalDirection=="up"&&!isOverBottomHalf));}},_getDragVerticalDirection:function(){var delta=this.positionAbs.top-this.lastPositionAbs.top;return delta!=0&&(delta>0?"down":"up");},_getDragHorizontalDirection:function(){var delta=this.positionAbs.left-this.lastPositionAbs.left;return delta!=0&&(delta>0?"right":"left");},refresh:function(event){this._refreshItems(event);this.refreshPositions();},_connectWith:function(){var options=this.options;return options.connectWith.constructor==String?[options.connectWith]:options.connectWith;},_getItemsAsjQuery:function(connected){var self=this;var items=[];var queries=[];var connectWith=this._connectWith();if(connectWith&&connected){for(var i=connectWith.length-1;i>=0;i--){var cur=$(connectWith[i]);for(var j=cur.length-1;j>=0;j--){var inst=$.data(cur[j],'sortable');if(inst&&inst!=this&&!inst.options.disabled){queries.push([$.isFunction(inst.options.items)?inst.options.items.call(inst.element):$(inst.options.items,inst.element).not(".ui-sortable-helper"),inst]);}};};}
queries.push([$.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):$(this.options.items,this.element).not(".ui-sortable-helper"),this]);for(var i=queries.length-1;i>=0;i--){queries[i][0].each(function(){items.push(this);});};return $(items);},_removeCurrentsFromItems:function(){var list=this.currentItem.find(":data(sortable-item)");for(var i=0;i<this.items.length;i++){for(var j=0;j<list.length;j++){if(list[j]==this.items[i].item[0])
this.items.splice(i,1);};};},_refreshItems:function(event){this.items=[];this.containers=[this];var items=this.items;var self=this;var queries=[[$.isFunction(this.options.items)?this.options.items.call(this.element[0],event,{item:this.currentItem}):$(this.options.items,this.element),this]];var connectWith=this._connectWith();if(connectWith){for(var i=connectWith.length-1;i>=0;i--){var cur=$(connectWith[i]);for(var j=cur.length-1;j>=0;j--){var inst=$.data(cur[j],'sortable');if(inst&&inst!=this&&!inst.options.disabled){queries.push([$.isFunction(inst.options.items)?inst.options.items.call(inst.element[0],event,{item:this.currentItem}):$(inst.options.items,inst.element),inst]);this.containers.push(inst);}};};}
for(var i=queries.length-1;i>=0;i--){var targetData=queries[i][1];var _queries=queries[i][0];for(var j=0,queriesLength=_queries.length;j<queriesLength;j++){var item=$(_queries[j]);item.data('sortable-item',targetData);items.push({item:item,instance:targetData,width:0,height:0,left:0,top:0});};};},refreshPositions:function(fast){if(this.offsetParent&&this.helper){this.offset.parent=this._getParentOffset();}
for(var i=this.items.length-1;i>=0;i--){var item=this.items[i];if(item.instance!=this.currentContainer&&this.currentContainer&&item.item[0]!=this.currentItem[0])
continue;var t=this.options.toleranceElement?$(this.options.toleranceElement,item.item):item.item;if(!fast){item.width=t.outerWidth();item.height=t.outerHeight();}
var p=t.offset();item.left=p.left;item.top=p.top;};if(this.options.custom&&this.options.custom.refreshContainers){this.options.custom.refreshContainers.call(this);}else{for(var i=this.containers.length-1;i>=0;i--){var p=this.containers[i].element.offset();this.containers[i].containerCache.left=p.left;this.containers[i].containerCache.top=p.top;this.containers[i].containerCache.width=this.containers[i].element.outerWidth();this.containers[i].containerCache.height=this.containers[i].element.outerHeight();};}},_createPlaceholder:function(that){var self=that||this,o=self.options;if(!o.placeholder||o.placeholder.constructor==String){var className=o.placeholder;o.placeholder={element:function(){var el=$(document.createElement(self.currentItem[0].nodeName)).addClass(className||self.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!className)
el.style.visibility="hidden";return el;},update:function(container,p){if(className&&!o.forcePlaceholderSize)return;if(!p.height()){p.height(self.currentItem.innerHeight()-parseInt(self.currentItem.css('paddingTop')||0,10)-parseInt(self.currentItem.css('paddingBottom')||0,10));};if(!p.width()){p.width(self.currentItem.innerWidth()-parseInt(self.currentItem.css('paddingLeft')||0,10)-parseInt(self.currentItem.css('paddingRight')||0,10));};}};}
self.placeholder=$(o.placeholder.element.call(self.element,self.currentItem));self.currentItem.after(self.placeholder);o.placeholder.update(self,self.placeholder);},_contactContainers:function(event){for(var i=this.containers.length-1;i>=0;i--){if(this._intersectsWith(this.containers[i].containerCache)){if(!this.containers[i].containerCache.over){if(this.currentContainer!=this.containers[i]){var dist=10000;var itemWithLeastDistance=null;var base=this.positionAbs[this.containers[i].floating?'left':'top'];for(var j=this.items.length-1;j>=0;j--){if(!$.ui.contains(this.containers[i].element[0],this.items[j].item[0]))continue;var cur=this.items[j][this.containers[i].floating?'left':'top'];if(Math.abs(cur-base)<dist){dist=Math.abs(cur-base);itemWithLeastDistance=this.items[j];}}
if(!itemWithLeastDistance&&!this.options.dropOnEmpty)
continue;this.currentContainer=this.containers[i];itemWithLeastDistance?this._rearrange(event,itemWithLeastDistance,null,true):this._rearrange(event,null,this.containers[i].element,true);this._trigger("change",event,this._uiHash());this.containers[i]._trigger("change",event,this._uiHash(this));this.options.placeholder.update(this.currentContainer,this.placeholder);}
this.containers[i]._trigger("over",event,this._uiHash(this));this.containers[i].containerCache.over=1;}}else{if(this.containers[i].containerCache.over){this.containers[i]._trigger("out",event,this._uiHash(this));this.containers[i].containerCache.over=0;}}};},_createHelper:function(event){var o=this.options;var helper=$.isFunction(o.helper)?$(o.helper.apply(this.element[0],[event,this.currentItem])):(o.helper=='clone'?this.currentItem.clone():this.currentItem);if(!helper.parents('body').length)
$(o.appendTo!='parent'?o.appendTo:this.currentItem[0].parentNode)[0].appendChild(helper[0]);if(helper[0]==this.currentItem[0])
this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")};if(helper[0].style.width==''||o.forceHelperSize)helper.width(this.currentItem.width());if(helper[0].style.height==''||o.forceHelperSize)helper.height(this.currentItem.height());return helper;},_adjustOffsetFromHelper:function(obj){if(obj.left!=undefined)this.offset.click.left=obj.left+this.margins.left;if(obj.right!=undefined)this.offset.click.left=this.helperProportions.width-obj.right+this.margins.left;if(obj.top!=undefined)this.offset.click.top=obj.top+this.margins.top;if(obj.bottom!=undefined)this.offset.click.top=this.helperProportions.height-obj.bottom+this.margins.top;},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var po=this.offsetParent.offset();if(this.cssPosition=='absolute'&&this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0])){po.left+=this.scrollParent.scrollLeft();po.top+=this.scrollParent.scrollTop();}
if((this.offsetParent[0]==document.body)||(this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=='html'&&$.browser.msie))
po={top:0,left:0};return{top:po.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:po.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var p=this.currentItem.position();return{top:p.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:p.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()};}else{return{top:0,left:0};}},_cacheMargins:function(){this.margins={left:(parseInt(this.currentItem.css("marginLeft"),10)||0),top:(parseInt(this.currentItem.css("marginTop"),10)||0)};},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};},_setContainment:function(){var o=this.options;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.helperProportions.width-this.margins.left,($(o.containment=='document'?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!(/^(document|window|parent)$/).test(o.containment)){var ce=$(o.containment)[0];var co=$(o.containment).offset();var over=($(ce).css("overflow")!='hidden');this.containment=[co.left+(parseInt($(ce).css("borderLeftWidth"),10)||0)+(parseInt($(ce).css("paddingLeft"),10)||0)-this.margins.left,co.top+(parseInt($(ce).css("borderTopWidth"),10)||0)+(parseInt($(ce).css("paddingTop"),10)||0)-this.margins.top,co.left+(over?Math.max(ce.scrollWidth,ce.offsetWidth):ce.offsetWidth)-(parseInt($(ce).css("borderLeftWidth"),10)||0)-(parseInt($(ce).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,co.top+(over?Math.max(ce.scrollHeight,ce.offsetHeight):ce.offsetHeight)-(parseInt($(ce).css("borderTopWidth"),10)||0)-(parseInt($(ce).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top];}},_convertPositionTo:function(d,pos){if(!pos)pos=this.position;var mod=d=="absolute"?1:-1;var o=this.options,scroll=this.cssPosition=='absolute'&&!(this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,scrollIsRootNode=(/(html|body)/i).test(scroll[0].tagName);return{top:(pos.top
+this.offset.relative.top*mod
+this.offset.parent.top*mod
-($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollTop():(scrollIsRootNode?0:scroll.scrollTop()))*mod)),left:(pos.left
+this.offset.relative.left*mod
+this.offset.parent.left*mod
-($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())*mod))};},_generatePosition:function(event){var o=this.options,scroll=this.cssPosition=='absolute'&&!(this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,scrollIsRootNode=(/(html|body)/i).test(scroll[0].tagName);if(this.cssPosition=='relative'&&!(this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0])){this.offset.relative=this._getRelativeOffset();}
var pageX=event.pageX;var pageY=event.pageY;if(this.originalPosition){if(this.containment){if(event.pageX-this.offset.click.left<this.containment[0])pageX=this.containment[0]+this.offset.click.left;if(event.pageY-this.offset.click.top<this.containment[1])pageY=this.containment[1]+this.offset.click.top;if(event.pageX-this.offset.click.left>this.containment[2])pageX=this.containment[2]+this.offset.click.left;if(event.pageY-this.offset.click.top>this.containment[3])pageY=this.containment[3]+this.offset.click.top;}
if(o.grid){var top=this.originalPageY+Math.round((pageY-this.originalPageY)/o.grid[1])*o.grid[1];pageY=this.containment?(!(top-this.offset.click.top<this.containment[1]||top-this.offset.click.top>this.containment[3])?top:(!(top-this.offset.click.top<this.containment[1])?top-o.grid[1]:top+o.grid[1])):top;var left=this.originalPageX+Math.round((pageX-this.originalPageX)/o.grid[0])*o.grid[0];pageX=this.containment?(!(left-this.offset.click.left<this.containment[0]||left-this.offset.click.left>this.containment[2])?left:(!(left-this.offset.click.left<this.containment[0])?left-o.grid[0]:left+o.grid[0])):left;}}
return{top:(pageY
-this.offset.click.top
-this.offset.relative.top
-this.offset.parent.top
+($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollTop():(scrollIsRootNode?0:scroll.scrollTop())))),left:(pageX
-this.offset.click.left
-this.offset.relative.left
-this.offset.parent.left
+($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())))};},_rearrange:function(event,i,a,hardRefresh){a?a[0].appendChild(this.placeholder[0]):i.item[0].parentNode.insertBefore(this.placeholder[0],(this.direction=='down'?i.item[0]:i.item[0].nextSibling));this.counter=this.counter?++this.counter:1;var self=this,counter=this.counter;window.setTimeout(function(){if(counter==self.counter)self.refreshPositions(!hardRefresh);},0);},_clear:function(event,noPropagation){this.reverting=false;var delayedTriggers=[],self=this;if(!this._noFinalSort&&this.currentItem[0].parentNode)this.placeholder.before(this.currentItem);this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var i in this._storedCSS){if(this._storedCSS[i]=='auto'||this._storedCSS[i]=='static')this._storedCSS[i]='';}
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");}else{this.currentItem.show();}
if(this.fromOutside&&!noPropagation)delayedTriggers.push(function(event){this._trigger("receive",event,this._uiHash(this.fromOutside));});if((this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!noPropagation)delayedTriggers.push(function(event){this._trigger("update",event,this._uiHash());});if(!$.ui.contains(this.element[0],this.currentItem[0])){if(!noPropagation)delayedTriggers.push(function(event){this._trigger("remove",event,this._uiHash());});for(var i=this.containers.length-1;i>=0;i--){if($.ui.contains(this.containers[i].element[0],this.currentItem[0])&&!noPropagation){delayedTriggers.push((function(c){return function(event){c._trigger("receive",event,this._uiHash(this));};}).call(this,this.containers[i]));delayedTriggers.push((function(c){return function(event){c._trigger("update",event,this._uiHash(this));};}).call(this,this.containers[i]));}};};for(var i=this.containers.length-1;i>=0;i--){if(!noPropagation)delayedTriggers.push((function(c){return function(event){c._trigger("deactivate",event,this._uiHash(this));};}).call(this,this.containers[i]));if(this.containers[i].containerCache.over){delayedTriggers.push((function(c){return function(event){c._trigger("out",event,this._uiHash(this));};}).call(this,this.containers[i]));this.containers[i].containerCache.over=0;}}
if(this._storedCursor)$('body').css("cursor",this._storedCursor);if(this._storedOpacity)this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex)this.helper.css("zIndex",this._storedZIndex=='auto'?'':this._storedZIndex);this.dragging=false;if(this.cancelHelperRemoval){if(!noPropagation){this._trigger("beforeStop",event,this._uiHash());for(var i=0;i<delayedTriggers.length;i++){delayedTriggers[i].call(this,event);};this._trigger("stop",event,this._uiHash());}
return false;}
if(!noPropagation)this._trigger("beforeStop",event,this._uiHash());this.placeholder[0].parentNode.removeChild(this.placeholder[0]);if(this.helper[0]!=this.currentItem[0])this.helper.remove();this.helper=null;if(!noPropagation){for(var i=0;i<delayedTriggers.length;i++){delayedTriggers[i].call(this,event);};this._trigger("stop",event,this._uiHash());}
this.fromOutside=false;return true;},_trigger:function(){if($.widget.prototype._trigger.apply(this,arguments)===false){this.cancel();}},_uiHash:function(inst){var self=inst||this;return{helper:self.helper,placeholder:self.placeholder||$([]),position:self.position,absolutePosition:self.positionAbs,offset:self.positionAbs,item:self.currentItem,sender:inst?inst.element:null};}}));$.extend($.ui.sortable,{getter:"serialize toArray",version:"1.7.2",eventPrefix:"sort",defaults:{appendTo:"parent",axis:false,cancel:":input,option",connectWith:false,containment:false,cursor:'auto',cursorAt:false,delay:0,distance:1,dropOnEmpty:true,forcePlaceholderSize:false,forceHelperSize:false,grid:false,handle:false,helper:"original",items:'> *',opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1000}});})(jQuery);(function($){$.widget("ui.draggable",$.extend({},$.ui.mouse,{_init:function(){if(this.options.helper=='original'&&!(/^(?:r|a|f)/).test(this.element.css("position")))
this.element[0].style.position='relative';(this.options.addClasses&&this.element.addClass("ui-draggable"));(this.options.disabled&&this.element.addClass("ui-draggable-disabled"));this._mouseInit();},destroy:function(){if(!this.element.data('draggable'))return;this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable"
+" ui-draggable-dragging"
+" ui-draggable-disabled");this._mouseDestroy();},_mouseCapture:function(event){var o=this.options;if(this.helper||o.disabled||$(event.target).is('.ui-resizable-handle'))
return false;this.handle=this._getHandle(event);if(!this.handle)
return false;return true;},_mouseStart:function(event){var o=this.options;this.helper=this._createHelper(event);this._cacheHelperProportions();if($.ui.ddmanager)
$.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};$.extend(this.offset,{click:{left:event.pageX-this.offset.left,top:event.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(event);this.originalPageX=event.pageX;this.originalPageY=event.pageY;if(o.cursorAt)
this._adjustOffsetFromHelper(o.cursorAt);if(o.containment)
this._setContainment();this._trigger("start",event);this._cacheHelperProportions();if($.ui.ddmanager&&!o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this,event);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(event,true);return true;},_mouseDrag:function(event,noPropagation){this.position=this._generatePosition(event);this.positionAbs=this._convertPositionTo("absolute");if(!noPropagation){var ui=this._uiHash();this._trigger('drag',event,ui);this.position=ui.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,event);return false;},_mouseStop:function(event){var dropped=false;if($.ui.ddmanager&&!this.options.dropBehaviour)
dropped=$.ui.ddmanager.drop(this,event);if(this.dropped){dropped=this.dropped;this.dropped=false;}
if((this.options.revert=="invalid"&&!dropped)||(this.options.revert=="valid"&&dropped)||this.options.revert===true||($.isFunction(this.options.revert)&&this.options.revert.call(this.element,dropped))){var self=this;$(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){self._trigger("stop",event);self._clear();});}else{this._trigger("stop",event);this._clear();}
return false;},_getHandle:function(event){var handle=!this.options.handle||!$(this.options.handle,this.element).length?true:false;$(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==event.target)handle=true;});return handle;},_createHelper:function(event){var o=this.options;var helper=$.isFunction(o.helper)?$(o.helper.apply(this.element[0],[event])):(o.helper=='clone'?this.element.clone():this.element);if(!helper.parents('body').length)
helper.appendTo((o.appendTo=='parent'?this.element[0].parentNode:o.appendTo));if(helper[0]!=this.element[0]&&!(/(fixed|absolute)/).test(helper.css("position")))
helper.css("position","absolute");return helper;},_adjustOffsetFromHelper:function(obj){if(obj.left!=undefined)this.offset.click.left=obj.left+this.margins.left;if(obj.right!=undefined)this.offset.click.left=this.helperProportions.width-obj.right+this.margins.left;if(obj.top!=undefined)this.offset.click.top=obj.top+this.margins.top;if(obj.bottom!=undefined)this.offset.click.top=this.helperProportions.height-obj.bottom+this.margins.top;},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var po=this.offsetParent.offset();if(this.cssPosition=='absolute'&&this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0])){po.left+=this.scrollParent.scrollLeft();po.top+=this.scrollParent.scrollTop();}
if((this.offsetParent[0]==document.body)||(this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=='html'&&$.browser.msie))
po={top:0,left:0};return{top:po.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:po.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)};},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var p=this.element.position();return{top:p.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:p.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()};}else{return{top:0,left:0};}},_cacheMargins:function(){this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)};},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()};},_setContainment:function(){var o=this.options;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.helperProportions.width-this.margins.left,($(o.containment=='document'?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!(/^(document|window|parent)$/).test(o.containment)&&o.containment.constructor!=Array){var ce=$(o.containment)[0];if(!ce)return;var co=$(o.containment).offset();var over=($(ce).css("overflow")!='hidden');this.containment=[co.left+(parseInt($(ce).css("borderLeftWidth"),10)||0)+(parseInt($(ce).css("paddingLeft"),10)||0)-this.margins.left,co.top+(parseInt($(ce).css("borderTopWidth"),10)||0)+(parseInt($(ce).css("paddingTop"),10)||0)-this.margins.top,co.left+(over?Math.max(ce.scrollWidth,ce.offsetWidth):ce.offsetWidth)-(parseInt($(ce).css("borderLeftWidth"),10)||0)-(parseInt($(ce).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,co.top+(over?Math.max(ce.scrollHeight,ce.offsetHeight):ce.offsetHeight)-(parseInt($(ce).css("borderTopWidth"),10)||0)-(parseInt($(ce).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top];}else if(o.containment.constructor==Array){this.containment=o.containment;}},_convertPositionTo:function(d,pos){if(!pos)pos=this.position;var mod=d=="absolute"?1:-1;var o=this.options,scroll=this.cssPosition=='absolute'&&!(this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,scrollIsRootNode=(/(html|body)/i).test(scroll[0].tagName);return{top:(pos.top
+this.offset.relative.top*mod
+this.offset.parent.top*mod
-($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollTop():(scrollIsRootNode?0:scroll.scrollTop()))*mod)),left:(pos.left
+this.offset.relative.left*mod
+this.offset.parent.left*mod
-($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())*mod))};},_generatePosition:function(event){var o=this.options,scroll=this.cssPosition=='absolute'&&!(this.scrollParent[0]!=document&&$.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,scrollIsRootNode=(/(html|body)/i).test(scroll[0].tagName);if(this.cssPosition=='relative'&&!(this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0])){this.offset.relative=this._getRelativeOffset();}
var pageX=event.pageX;var pageY=event.pageY;if(this.originalPosition){if(this.containment){if(event.pageX-this.offset.click.left<this.containment[0])pageX=this.containment[0]+this.offset.click.left;if(event.pageY-this.offset.click.top<this.containment[1])pageY=this.containment[1]+this.offset.click.top;if(event.pageX-this.offset.click.left>this.containment[2])pageX=this.containment[2]+this.offset.click.left;if(event.pageY-this.offset.click.top>this.containment[3])pageY=this.containment[3]+this.offset.click.top;}
if(o.grid){var top=this.originalPageY+Math.round((pageY-this.originalPageY)/o.grid[1])*o.grid[1];pageY=this.containment?(!(top-this.offset.click.top<this.containment[1]||top-this.offset.click.top>this.containment[3])?top:(!(top-this.offset.click.top<this.containment[1])?top-o.grid[1]:top+o.grid[1])):top;var left=this.originalPageX+Math.round((pageX-this.originalPageX)/o.grid[0])*o.grid[0];pageX=this.containment?(!(left-this.offset.click.left<this.containment[0]||left-this.offset.click.left>this.containment[2])?left:(!(left-this.offset.click.left<this.containment[0])?left-o.grid[0]:left+o.grid[0])):left;}}
return{top:(pageY
-this.offset.click.top
-this.offset.relative.top
-this.offset.parent.top
+($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollTop():(scrollIsRootNode?0:scroll.scrollTop())))),left:(pageX
-this.offset.click.left
-this.offset.relative.left
-this.offset.parent.left
+($.browser.safari&&this.cssPosition=='fixed'?0:(this.cssPosition=='fixed'?-this.scrollParent.scrollLeft():scrollIsRootNode?0:scroll.scrollLeft())))};},_clear:function(){this.helper.removeClass("ui-draggable-dragging");if(this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval)this.helper.remove();this.helper=null;this.cancelHelperRemoval=false;},_trigger:function(type,event,ui){ui=ui||this._uiHash();$.ui.plugin.call(this,type,[event,ui]);if(type=="drag")this.positionAbs=this._convertPositionTo("absolute");return $.widget.prototype._trigger.call(this,type,event,ui);},plugins:{},_uiHash:function(event){return{helper:this.helper,position:this.position,absolutePosition:this.positionAbs,offset:this.positionAbs};}}));$.extend($.ui.draggable,{version:"1.7.2",eventPrefix:"drag",defaults:{addClasses:true,appendTo:"parent",axis:false,cancel:":input,option",connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,delay:0,distance:1,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false}});$.ui.plugin.add("draggable","connectToSortable",{start:function(event,ui){var inst=$(this).data("draggable"),o=inst.options,uiSortable=$.extend({},ui,{item:inst.element});inst.sortables=[];$(o.connectToSortable).each(function(){var sortable=$.data(this,'sortable');if(sortable&&!sortable.options.disabled){inst.sortables.push({instance:sortable,shouldRevert:sortable.options.revert});sortable._refreshItems();sortable._trigger("activate",event,uiSortable);}});},stop:function(event,ui){var inst=$(this).data("draggable"),uiSortable=$.extend({},ui,{item:inst.element});$.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(event);this.instance.options.helper=this.instance.options._helper;if(inst.options.helper=='original')
this.instance.currentItem.css({top:'auto',left:'auto'});}else{this.instance.cancelHelperRemoval=false;this.instance._trigger("deactivate",event,uiSortable);}});},drag:function(event,ui){var inst=$(this).data("draggable"),self=this;var checkPos=function(o){var dyClick=this.offset.click.top,dxClick=this.offset.click.left;var helperTop=this.positionAbs.top,helperLeft=this.positionAbs.left;var itemHeight=o.height,itemWidth=o.width;var itemTop=o.top,itemLeft=o.left;return $.ui.isOver(helperTop+dyClick,helperLeft+dxClick,itemTop,itemLeft,itemHeight,itemWidth);};$.each(inst.sortables,function(i){this.instance.positionAbs=inst.positionAbs;this.instance.helperProportions=inst.helperProportions;this.instance.offset.click=inst.offset.click;if(this.instance._intersectsWith(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];};event.target=this.instance.currentItem[0];this.instance._mouseCapture(event,true);this.instance._mouseStart(event,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._trigger("toSortable",event);inst.dropped=this.instance.element;inst.currentItem=inst.element;this.instance.fromOutside=inst;}
if(this.instance.currentItem)this.instance._mouseDrag(event);}else{if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger('out',event,this.instance._uiHash(this.instance));this.instance._mouseStop(event,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();if(this.instance.placeholder)this.instance.placeholder.remove();inst._trigger("fromSortable",event);inst.dropped=false;}};});}});$.ui.plugin.add("draggable","cursor",{start:function(event,ui){var t=$('body'),o=$(this).data('draggable').options;if(t.css("cursor"))o._cursor=t.css("cursor");t.css("cursor",o.cursor);},stop:function(event,ui){var o=$(this).data('draggable').options;if(o._cursor)$('body').css("cursor",o._cursor);}});$.ui.plugin.add("draggable","iframeFix",{start:function(event,ui){var o=$(this).data('draggable').options;$(o.iframeFix===true?"iframe":o.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(event,ui){$("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this);});}});$.ui.plugin.add("draggable","opacity",{start:function(event,ui){var t=$(ui.helper),o=$(this).data('draggable').options;if(t.css("opacity"))o._opacity=t.css("opacity");t.css('opacity',o.opacity);},stop:function(event,ui){var o=$(this).data('draggable').options;if(o._opacity)$(ui.helper).css('opacity',o._opacity);}});$.ui.plugin.add("draggable","scroll",{start:function(event,ui){var i=$(this).data("draggable");if(i.scrollParent[0]!=document&&i.scrollParent[0].tagName!='HTML')i.overflowOffset=i.scrollParent.offset();},drag:function(event,ui){var i=$(this).data("draggable"),o=i.options,scrolled=false;if(i.scrollParent[0]!=document&&i.scrollParent[0].tagName!='HTML'){if(!o.axis||o.axis!='x'){if((i.overflowOffset.top+i.scrollParent[0].offsetHeight)-event.pageY<o.scrollSensitivity)
i.scrollParent[0].scrollTop=scrolled=i.scrollParent[0].scrollTop+o.scrollSpeed;else if(event.pageY-i.overflowOffset.top<o.scrollSensitivity)
i.scrollParent[0].scrollTop=scrolled=i.scrollParent[0].scrollTop-o.scrollSpeed;}
if(!o.axis||o.axis!='y'){if((i.overflowOffset.left+i.scrollParent[0].offsetWidth)-event.pageX<o.scrollSensitivity)
i.scrollParent[0].scrollLeft=scrolled=i.scrollParent[0].scrollLeft+o.scrollSpeed;else if(event.pageX-i.overflowOffset.left<o.scrollSensitivity)
i.scrollParent[0].scrollLeft=scrolled=i.scrollParent[0].scrollLeft-o.scrollSpeed;}}else{if(!o.axis||o.axis!='x'){if(event.pageY-$(document).scrollTop()<o.scrollSensitivity)
scrolled=$(document).scrollTop($(document).scrollTop()-o.scrollSpeed);else if($(window).height()-(event.pageY-$(document).scrollTop())<o.scrollSensitivity)
scrolled=$(document).scrollTop($(document).scrollTop()+o.scrollSpeed);}
if(!o.axis||o.axis!='y'){if(event.pageX-$(document).scrollLeft()<o.scrollSensitivity)
scrolled=$(document).scrollLeft($(document).scrollLeft()-o.scrollSpeed);else if($(window).width()-(event.pageX-$(document).scrollLeft())<o.scrollSensitivity)
scrolled=$(document).scrollLeft($(document).scrollLeft()+o.scrollSpeed);}}
if(scrolled!==false&&$.ui.ddmanager&&!o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(i,event);}});$.ui.plugin.add("draggable","snap",{start:function(event,ui){var i=$(this).data("draggable"),o=i.options;i.snapElements=[];$(o.snap.constructor!=String?(o.snap.items||':data(draggable)'):o.snap).each(function(){var $t=$(this);var $o=$t.offset();if(this!=i.element[0])i.snapElements.push({item:this,width:$t.outerWidth(),height:$t.outerHeight(),top:$o.top,left:$o.left});});},drag:function(event,ui){var inst=$(this).data("draggable"),o=inst.options;var d=o.snapTolerance;var x1=ui.offset.left,x2=x1+inst.helperProportions.width,y1=ui.offset.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))){if(inst.snapElements[i].snapping)(inst.options.snap.release&&inst.options.snap.release.call(inst.element,event,$.extend(inst._uiHash(),{snapItem:inst.snapElements[i].item})));inst.snapElements[i].snapping=false;continue;}
if(o.snapMode!='inner'){var ts=Math.abs(t-y2)<=d;var bs=Math.abs(b-y1)<=d;var ls=Math.abs(l-x2)<=d;var rs=Math.abs(r-x1)<=d;if(ts)ui.position.top=inst._convertPositionTo("relative",{top:t-inst.helperProportions.height,left:0}).top-inst.margins.top;if(bs)ui.position.top=inst._convertPositionTo("relative",{top:b,left:0}).top-inst.margins.top;if(ls)ui.position.left=inst._convertPositionTo("relative",{top:0,left:l-inst.helperProportions.width}).left-inst.margins.left;if(rs)ui.position.left=inst._convertPositionTo("relative",{top:0,left:r}).left-inst.margins.left;}
var first=(ts||bs||ls||rs);if(o.snapMode!='outer'){var ts=Math.abs(t-y1)<=d;var bs=Math.abs(b-y2)<=d;var ls=Math.abs(l-x1)<=d;var rs=Math.abs(r-x2)<=d;if(ts)ui.position.top=inst._convertPositionTo("relative",{top:t,left:0}).top-inst.margins.top;if(bs)ui.position.top=inst._convertPositionTo("relative",{top:b-inst.helperProportions.height,left:0}).top-inst.margins.top;if(ls)ui.position.left=inst._convertPositionTo("relative",{top:0,left:l}).left-inst.margins.left;if(rs)ui.position.left=inst._convertPositionTo("relative",{top:0,left:r-inst.helperProportions.width}).left-inst.margins.left;}
if(!inst.snapElements[i].snapping&&(ts||bs||ls||rs||first))
(inst.options.snap.snap&&inst.options.snap.snap.call(inst.element,event,$.extend(inst._uiHash(),{snapItem:inst.snapElements[i].item})));inst.snapElements[i].snapping=(ts||bs||ls||rs||first);};}});$.ui.plugin.add("draggable","stack",{start:function(event,ui){var o=$(this).data("draggable").options;var group=$.makeArray($(o.stack.group)).sort(function(a,b){return(parseInt($(a).css("zIndex"),10)||o.stack.min)-(parseInt($(b).css("zIndex"),10)||o.stack.min);});$(group).each(function(i){this.style.zIndex=o.stack.min+i;});this[0].style.zIndex=o.stack.min+group.length;}});$.ui.plugin.add("draggable","zIndex",{start:function(event,ui){var t=$(ui.helper),o=$(this).data("draggable").options;if(t.css("zIndex"))o._zIndex=t.css("zIndex");t.css('zIndex',o.zIndex);},stop:function(event,ui){var o=$(this).data("draggable").options;if(o._zIndex)$(ui.helper).css('zIndex',o._zIndex);}});})(jQuery);var soundManager=null;function SoundManager(smURL,smID){this.flashVersion=8;this.debugMode=true;this.useConsole=true;this.consoleOnly=false;this.waitForWindowLoad=false;this.nullURL='null.mp3';this.allowPolling=true;this.useFastPolling=false;this.useMovieStar=false;this.bgColor='#ffffff';this.useHighPerformance=false;this.flashLoadTimeout=1000;this.wmode=null;this.allowFullScreen=true;this.defaultOptions={'autoLoad':false,'stream':true,'autoPlay':false,'onid3':null,'onload':null,'whileloading':null,'onplay':null,'onpause':null,'onresume':null,'whileplaying':null,'onstop':null,'onfinish':null,'onbeforefinish':null,'onbeforefinishtime':5000,'onbeforefinishcomplete':null,'onjustbeforefinish':null,'onjustbeforefinishtime':200,'multiShot':true,'multiShotEvents':false,'position':null,'pan':0,'volume':100};this.flash9Options={'isMovieStar':null,'usePeakData':false,'useWaveformData':false,'useEQData':false,'onbufferchange':null,'ondataerror':null};this.movieStarOptions={'onmetadata':null,'useVideo':false,'bufferTime':null};var SMSound=null;var _s=this;this.version=null;this.versionNumber='V2.95a.20090717';this.movieURL=null;this.url=null;this.altURL=null;this.swfLoaded=false;this.enabled=false;this.o=null;this.id=(smID||'sm2movie');this.oMC=null;this.sounds={};this.soundIDs=[];this.muted=false;this.isFullScreen=false;this.isIE=(navigator.userAgent.match(/MSIE/i));this.isSafari=(navigator.userAgent.match(/safari/i));this.debugID='soundmanager-debug';this.debugURLParam=/([#?&])debug=1/i;this.specialWmodeCase=false;this._onready=[];this._debugOpen=true;this._didAppend=false;this._appendSuccess=false;this._didInit=false;this._disabled=false;this._windowLoaded=false;this._hasConsole=(typeof console!='undefined'&&typeof console.log!='undefined');this._debugLevels=['log','info','warn','error'];this._defaultFlashVersion=8;this._oRemoved=null;this._oRemovedHTML=null;var _$=function(sID){return document.getElementById(sID);};this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.netStreamTypes=['aac','flv','mov','mp4','m4v','f4v','m4a','mp4v','3gp','3g2'];this.netStreamPattern=new RegExp('\\.('+this.netStreamTypes.join('|')+')(\\?.*)?$','i');this.filePattern=null;this.features={buffering:false,peakData:false,waveformData:false,eqData:false,movieStar:false};this.sandbox={'type':null,'types':{'remote':'remote (domain-based) rules','localWithFile':'local with file access (no internet access)','localWithNetwork':'local with network (internet access only, no local access)','localTrusted':'local, trusted (local + internet access)'},'description':null,'noRemote':null,'noLocal':null};this._setVersionInfo=function(){if(_s.flashVersion!=8&&_s.flashVersion!=9){alert('soundManager.flashVersion must be 8 or 9. "'+_s.flashVersion+'" is invalid. Reverting to '+_s._defaultFlashVersion+'.');_s.flashVersion=_s._defaultFlashVersion;}
_s.version=_s.versionNumber+(_s.flashVersion==9?' (AS3/Flash 9)':' (AS2/Flash 8)');if(_s.flashVersion>8){_s.defaultOptions=_s._mergeObjects(_s.defaultOptions,_s.flash9Options);_s.features.buffering=true;}
if(_s.flashVersion>8&&_s.useMovieStar){_s.defaultOptions=_s._mergeObjects(_s.defaultOptions,_s.movieStarOptions);_s.filePatterns.flash9=new RegExp('\\.(mp3|'+_s.netStreamTypes.join('|')+')(\\?.*)?$','i');_s.features.movieStar=true;}else{_s.useMovieStar=false;_s.features.movieStar=false;}
_s.filePattern=_s.filePatterns[(_s.flashVersion!=8?'flash9':'flash8')];_s.movieURL=(_s.flashVersion==8?'soundmanager2.swf':'soundmanager2_flash9.swf');_s.features.peakData=_s.features.waveformData=_s.features.eqData=(_s.flashVersion>8);};this._overHTTP=(document.location?document.location.protocol.match(/http/i):null);this._waitingForEI=false;this._initPending=false;this._tryInitOnFocus=(this.isSafari&&typeof document.hasFocus=='undefined');this._isFocused=(typeof document.hasFocus!='undefined'?document.hasFocus():null);this._okToDisable=!this._tryInitOnFocus;this.useAltURL=!this._overHTTP;var flashCPLink='http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html';this.strings={notReady:'Not loaded yet - wait for soundManager.onload() before calling sound-related methods',appXHTML:'soundManager._createMovie(): appendChild/innerHTML set failed. May be app/xhtml+xml DOM-related.',localFail:'soundManager: Loading this page from local/network file system (not over HTTP?) Flash security likely restricting JS-Flash access. Consider adding current URL to "trusted locations" in the Flash player security settings manager at '+flashCPLink+', or simply serve this content over HTTP.',waitFocus:'soundManager: Special case: Waiting for focus-related event..',waitImpatient:'soundManager: Getting impatient, still waiting for Flash.. ;)',waitForever:'soundManager: Waiting indefinitely for Flash...',needFunction:'soundManager.onready(): Function object expected'};this.supported=function(){return(_s._didInit&&!_s._disabled);};this.getMovie=function(smID){return _s.isIE?window[smID]:(_s.isSafari?_$(smID)||document[smID]:_$(smID));};this.loadFromXML=function(sXmlUrl){try{_s.o._loadFromXML(sXmlUrl);}catch(e){_s._failSafely();return true;}};this.createSound=function(oOptions){var _cs='soundManager.createSound(): ';if(!_s._didInit){throw _s._complain(_cs+_s.strings.notReady,arguments.callee.caller);}
if(arguments.length==2){oOptions={'id':arguments[0],'url':arguments[1]};}
var thisOptions=_s._mergeObjects(oOptions);var _tO=thisOptions;if(_tO.id.toString().charAt(0).match(/^[0-9]$/)){var complaint=_cs+'Warning: Sound ID "'+_tO.id+'" should be a string, starting with a non-numeric character';_s._wD(complaint,2);}
_s._wD(_cs+_tO.id+' ('+_tO.url+')',1);if(_s._idCheck(_tO.id,true)){_s._wD(_cs+_tO.id+' exists',1);return _s.sounds[_tO.id];}
if(_s.flashVersion>8&&_s.useMovieStar){if(_tO.isMovieStar===null){_tO.isMovieStar=(_tO.url.match(_s.netStreamPattern)?true:false);}
if(_tO.isMovieStar){_s._wD(_cs+'using MovieStar handling');}
if(_tO.isMovieStar&&(_tO.usePeakData||_tO.useWaveformData||_tO.useEQData)){_s._wD('Warning: peak/waveform/eqData features unsupported for non-MP3 formats');_tO.usePeakData=false;_tO.useWaveformData=false;_tO.useEQData=false;}}
_s.sounds[_tO.id]=new SMSound(_tO);_s.soundIDs[_s.soundIDs.length]=_tO.id;if(_s.flashVersion==8){_s.o._createSound(_tO.id,_tO.onjustbeforefinishtime);}else{_s.o._createSound(_tO.id,_tO.url,_tO.onjustbeforefinishtime,_tO.usePeakData,_tO.useWaveformData,_tO.useEQData,_tO.isMovieStar,(_tO.isMovieStar?_tO.useVideo:false),(_tO.isMovieStar?_tO.bufferTime:false));}
if(_tO.autoLoad||_tO.autoPlay){if(_s.sounds[_tO.id]){_s.sounds[_tO.id].load(_tO);}}
if(_tO.autoPlay){_s.sounds[_tO.id].play();}
return _s.sounds[_tO.id];};this.createVideo=function(oOptions){if(arguments.length==2){oOptions={'id':arguments[0],'url':arguments[1]};}
if(_s.flashVersion>=9){oOptions.isMovieStar=true;oOptions.useVideo=true;}else{_s._wD('soundManager.createVideo(): flash 9 required for video. Exiting.',2);return false;}
if(!_s.useMovieStar){_s._wD('soundManager.createVideo(): MovieStar mode not enabled. Exiting.',2);}
return _s.createSound(oOptions);};this.destroySound=function(sID,bFromSound){if(!_s._idCheck(sID)){return false;}
for(var i=0;i<_s.soundIDs.length;i++){if(_s.soundIDs[i]==sID){_s.soundIDs.splice(i,1);continue;}}
_s.sounds[sID].unload();if(!bFromSound){_s.sounds[sID].destruct();}
delete _s.sounds[sID];};this.destroyVideo=this.destroySound;this.load=function(sID,oOptions){if(!_s._idCheck(sID)){return false;}
_s.sounds[sID].load(oOptions);};this.unload=function(sID){if(!_s._idCheck(sID)){return false;}
_s.sounds[sID].unload();};this.play=function(sID,oOptions){if(!_s._didInit){throw _s._complain('soundManager.play(): '+_s.strings.notReady,arguments.callee.caller);}
if(!_s._idCheck(sID)){if(typeof oOptions!='Object'){oOptions={url:oOptions};}
if(oOptions&&oOptions.url){_s._wD('soundController.play(): attempting to create "'+sID+'"',1);oOptions.id=sID;_s.createSound(oOptions);}else{return false;}}
_s.sounds[sID].play(oOptions);};this.start=this.play;this.setPosition=function(sID,nMsecOffset){if(!_s._idCheck(sID)){return false;}
_s.sounds[sID].setPosition(nMsecOffset);};this.stop=function(sID){if(!_s._idCheck(sID)){return false;}
_s._wD('soundManager.stop('+sID+')',1);_s.sounds[sID].stop();};this.stopAll=function(){_s._wD('soundManager.stopAll()',1);for(var oSound in _s.sounds){if(_s.sounds[oSound]instanceof SMSound){_s.sounds[oSound].stop();}}};this.pause=function(sID){if(!_s._idCheck(sID)){return false;}
_s.sounds[sID].pause();};this.pauseAll=function(){for(var i=_s.soundIDs.length;i--;){_s.sounds[_s.soundIDs[i]].pause();}};this.resume=function(sID){if(!_s._idCheck(sID)){return false;}
_s.sounds[sID].resume();};this.resumeAll=function(){for(var i=_s.soundIDs.length;i--;){_s.sounds[_s.soundIDs[i]].resume();}};this.togglePause=function(sID){if(!_s._idCheck(sID)){return false;}
_s.sounds[sID].togglePause();};this.setPan=function(sID,nPan){if(!_s._idCheck(sID)){return false;}
_s.sounds[sID].setPan(nPan);};this.setVolume=function(sID,nVol){if(!_s._idCheck(sID)){return false;}
_s.sounds[sID].setVolume(nVol);};this.mute=function(sID){if(typeof sID!='string'){sID=null;}
if(!sID){_s._wD('soundManager.mute(): Muting all sounds');for(var i=_s.soundIDs.length;i--;){_s.sounds[_s.soundIDs[i]].mute();}
_s.muted=true;}else{if(!_s._idCheck(sID)){return false;}
_s._wD('soundManager.mute(): Muting "'+sID+'"');_s.sounds[sID].mute();}};this.muteAll=function(){_s.mute();};this.unmute=function(sID){if(typeof sID!='string'){sID=null;}
if(!sID){_s._wD('soundManager.unmute(): Unmuting all sounds');for(var i=_s.soundIDs.length;i--;){_s.sounds[_s.soundIDs[i]].unmute();}
_s.muted=false;}else{if(!_s._idCheck(sID)){return false;}
_s._wD('soundManager.unmute(): Unmuting "'+sID+'"');_s.sounds[sID].unmute();}};this.unmuteAll=function(){_s.unmute();};this.toggleMute=function(sID){if(!_s._idCheck(sID)){return false;}
_s.sounds[sID].toggleMute();};this.getMemoryUse=function(){if(_s.flashVersion==8){return 0;}
if(_s.o){return parseInt(_s.o._getMemoryUse(),10);}};this.disable=function(bNoDisable){if(typeof bNoDisable=='undefined'){bNoDisable=false;}
if(_s._disabled){return false;}
_s._disabled=true;_s._wD('soundManager.disable(): Shutting down',1);for(var i=_s.soundIDs.length;i--;){_s._disableObject(_s.sounds[_s.soundIDs[i]]);}
_s.initComplete(bNoDisable);};this.canPlayURL=function(sURL){return(sURL?(sURL.match(_s.filePattern)?true:false):null);};this.getSoundById=function(sID,suppressDebug){if(!sID){throw new Error('SoundManager.getSoundById(): sID is null/undefined');}
var result=_s.sounds[sID];if(!result&&!suppressDebug){_s._wD('"'+sID+'" is an invalid sound ID.',2);}
return result;};this.onready=function(oMethod,oScope){if(oMethod&&oMethod instanceof Function){if(_s._didInit){_s._wD('soundManager.onready(): Queueing handler');}
if(!oScope){oScope=window;}
_s._addOnReady(oMethod,oScope);_s._processOnReady();return true;}else{throw _s.strings.needFunction;}};this.oninitmovie=function(){};this.onload=function(){soundManager._wD('soundManager.onload()',1);};this.onerror=function(){};this._idCheck=this.getSoundById;this._complain=function(sMsg,oCaller){var sPre='Error: ';if(!oCaller){return new Error(sPre+sMsg);}
var e=new Error('');var stackMsg=null;if(e.stack){try{var splitChar='@';var stackTmp=e.stack.split(splitChar);stackMsg=stackTmp[4];}catch(ee){stackMsg=e.stack;}}
if(typeof console!='undefined'&&typeof console.trace!='undefined'){console.trace();}
var errorDesc=sPre+sMsg+'. \nCaller: '+oCaller.toString()+(e.stack?' \nTop of stacktrace: '+stackMsg:(e.message?' \nMessage: '+e.message:''));return new Error(errorDesc);};var _doNothing=function(){return false;};_doNothing._protected=true;this._disableObject=function(o){for(var oProp in o){if(typeof o[oProp]=='function'&&typeof o[oProp]._protected=='undefined'){o[oProp]=_doNothing;}}
oProp=null;};this._failSafely=function(bNoDisable){if(typeof bNoDisable=='undefined'){bNoDisable=false;}
if(!_s._disabled||bNoDisable){_s._wD('soundManager: Failed to initialise.',2);_s.disable(bNoDisable);}};this._normalizeMovieURL=function(smURL){var urlParams=null;if(smURL){if(smURL.match(/\.swf(\?.*)?$/i)){urlParams=smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?')+4);if(urlParams){return smURL;}}else if(smURL.lastIndexOf('/')!=smURL.length-1){smURL=smURL+'/';}}
return(smURL&&smURL.lastIndexOf('/')!=-1?smURL.substr(0,smURL.lastIndexOf('/')+1):'./')+_s.movieURL;};this._getDocument=function(){return(document.body?document.body:(document.documentElement?document.documentElement:document.getElementsByTagName('div')[0]));};this._getDocument._protected=true;this._setPolling=function(bPolling,bHighPerformance){if(!_s.o||!_s.allowPolling){return false;}
_s.o._setPolling(bPolling,bHighPerformance);};this._createMovie=function(smID,smURL){var specialCase=null;var remoteURL=(smURL?smURL:_s.url);var localURL=(_s.altURL?_s.altURL:remoteURL);if(_s.debugURLParam.test(window.location.href.toString())){_s.debugMode=true;}
if(_s._didAppend&&_s._appendSuccess){return false;}
_s._didAppend=true;_s._setVersionInfo();_s.url=_s._normalizeMovieURL(_s._overHTTP?remoteURL:localURL);smURL=_s.url;if(_s.useHighPerformance&&_s.useMovieStar&&_s.defaultOptions.useVideo===true){specialCase='soundManager note: disabling highPerformance, not applicable with movieStar mode + useVideo';_s.useHighPerformance=false;}
_s.wmode=(!_s.wmode&&_s.useHighPerformance&&!_s.useMovieStar?'transparent':_s.wmode);if(_s.wmode!==null&&_s.flashLoadTimeout!==0&&!_s.useHighPerformance&&!_s.isIE&&navigator.platform.match(/win32/i)){_s.specialWmodeCase=true;_s._wD('soundManager note: Removing wmode, preventing off-screen SWF loading issue');_s.wmode=null;}
if(_s.flashVersion==8){_s.allowFullScreen=false;}
var oEmbed={name:smID,id:smID,src:smURL,width:'100%',height:'100%',quality:'high',allowScriptAccess:'always',bgcolor:_s.bgColor,pluginspage:'http://www.macromedia.com/go/getflashplayer',type:'application/x-shockwave-flash',wmode:_s.wmode,allowfullscreen:(_s.allowFullScreen?'true':'false')};if(!_s.wmode){delete oEmbed.wmode;}
var oMovie=null;var tmp=null;if(_s.isIE){oMovie=document.createElement('div');var movieHTML='<object id="'+smID+'" data="'+smURL+'" type="application/x-shockwave-flash" width="100%" height="100%"><param name="movie" value="'+smURL+'" /><param name="AllowScriptAccess" value="always" /><param name="quality" value="high" />'+(_s.wmode?'<param name="wmode" value="'+_s.wmode+'" /> ':'')+'<param name="bgcolor" value="'+_s.bgColor+'" /><param name="allowFullScreen" value="'+(_s.allowFullScreen?'true':'false')+'" /><!-- --></object>';}else{oMovie=document.createElement('embed');for(tmp in oEmbed){if(oEmbed.hasOwnProperty(tmp)){oMovie.setAttribute(tmp,oEmbed[tmp]);}}}
var oD=document.createElement('div');oD.id=_s.debugID+'-toggle';var oToggle={position:'fixed',bottom:'0px',right:'0px',width:'1.2em',height:'1.2em',lineHeight:'1.2em',margin:'2px',textAlign:'center',border:'1px solid #999',cursor:'pointer',background:'#fff',color:'#333',zIndex:10001};oD.appendChild(document.createTextNode('-'));oD.onclick=_s._toggleDebug;oD.title='Toggle SM2 debug console';if(navigator.userAgent.match(/msie 6/i)){oD.style.position='absolute';oD.style.cursor='hand';}
for(tmp in oToggle){if(oToggle.hasOwnProperty(tmp)){oD.style[tmp]=oToggle[tmp];}}
var oTarget=_s._getDocument();if(oTarget){_s.oMC=_$('sm2-container')?_$('sm2-container'):document.createElement('div');if(!_s.oMC.id){_s.oMC.id='sm2-container';_s.oMC.className='movieContainer';var s=null;var oEl=null;if(_s.useHighPerformance){s={position:'fixed',width:'8px',height:'8px',bottom:'0px',left:'0px',overflow:'hidden'};}else{s={position:'absolute',width:'8px',height:'8px',top:'-9999px',left:'-9999px'};}
var x=null;for(x in s){if(s.hasOwnProperty(x)){_s.oMC.style[x]=s[x];}}
try{if(!_s.isIE){_s.oMC.appendChild(oMovie);}
oTarget.appendChild(_s.oMC);if(_s.isIE){oEl=_s.oMC.appendChild(document.createElement('div'));oEl.className='sm2-object-box';oEl.innerHTML=movieHTML;}
_s._appendSuccess=true;}catch(e){throw new Error(_s.strings.appXHTML);}}else{_s.oMC.appendChild(oMovie);if(_s.isIE){oEl=_s.oMC.appendChild(document.createElement('div'));oEl.className='sm2-object-box';oEl.innerHTML=movieHTML;}
_s._appendSuccess=true;}
if(!_$(_s.debugID)&&((!_s._hasConsole||!_s.useConsole)||(_s.useConsole&&_s._hasConsole&&!_s.consoleOnly))){var oDebug=document.createElement('div');oDebug.id=_s.debugID;oDebug.style.display=(_s.debugMode?'block':'none');if(_s.debugMode&&!_$(oD.id)){try{oTarget.appendChild(oD);}catch(e2){throw new Error(_s.strings.appXHTML);}
oTarget.appendChild(oDebug);}}
oTarget=null;}
if(specialCase){_s._wD(specialCase);}
_s._wD('-- SoundManager 2 '+_s.version+(_s.useMovieStar?', MovieStar mode':'')+(_s.useHighPerformance?', high performance mode, ':', ')+((_s.useFastPolling?'fast':'normal')+' polling mode')+(_s.wmode?', wmode: '+_s.wmode:'')+' --',1);_s._wD('soundManager._createMovie(): Trying to load '+smURL+(!_s._overHTTP&&_s.altURL?' (alternate URL)':''),1);};this._writeDebug=function(sText,sType,bTimestamp){if(!_s.debugMode){return false;}
if(typeof bTimestamp!='undefined'&&bTimestamp){sText=sText+' | '+new Date().getTime();}
if(_s._hasConsole&&_s.useConsole){var sMethod=_s._debugLevels[sType];if(typeof console[sMethod]!='undefined'){console[sMethod](sText);}else{console.log(sText);}
if(_s.useConsoleOnly){return true;}}
var sDID='soundmanager-debug';try{var o=_$(sDID);if(!o){return false;}
var oItem=document.createElement('div');if(++_s._wdCount%2===0){oItem.className='sm2-alt';}
if(typeof sType=='undefined'){sType=0;}else{sType=parseInt(sType,10);}
oItem.appendChild(document.createTextNode(sText));if(sType){if(sType>=2){oItem.style.fontWeight='bold';}
if(sType==3){oItem.style.color='#ff3333';}}
o.insertBefore(oItem,o.firstChild);}catch(e){}
o=null;};this._writeDebug._protected=true;this._wdCount=0;this._wdCount._protected=true;this._wD=this._writeDebug;this._wDAlert=function(sText){alert(sText);};if(window.location.href.indexOf('debug=alert')+1&&_s.debugMode){_s._wD=_s._wDAlert;}
this._toggleDebug=function(){var o=_$(_s.debugID);var oT=_$(_s.debugID+'-toggle');if(!o){return false;}
if(_s._debugOpen){oT.innerHTML='+';o.style.display='none';}else{oT.innerHTML='-';o.style.display='block';}
_s._debugOpen=!_s._debugOpen;};this._toggleDebug._protected=true;this._debug=function(){_s._wD('--- soundManager._debug(): Current sound objects ---',1);for(var i=0,j=_s.soundIDs.length;i<j;i++){_s.sounds[_s.soundIDs[i]]._debug();}};this._debugTS=function(sEventType,bSuccess,sMessage){if(typeof sm2Debugger!='undefined'){try{sm2Debugger.handleEvent(sEventType,bSuccess,sMessage);}catch(e){}}};this._debugTS._protected=true;this._mergeObjects=function(oMain,oAdd){var o1={};for(var i in oMain){if(oMain.hasOwnProperty(i)){o1[i]=oMain[i];}}
var o2=(typeof oAdd=='undefined'?_s.defaultOptions:oAdd);for(var o in o2){if(o2.hasOwnProperty(o)&&typeof o1[o]=='undefined'){o1[o]=o2[o];}}
return o1;};this.createMovie=function(sURL){if(sURL){_s.url=sURL;}
_s._initMovie();};this.go=this.createMovie;this._initMovie=function(){if(_s.o){return false;}
_s.o=_s.getMovie(_s.id);if(!_s.o){if(!_s.oRemoved){_s._createMovie(_s.id,_s.url);}else{if(!_s.isIE){_s.oMC.appendChild(_s.oRemoved);}else{_s.oMC.innerHTML=_s.oRemovedHTML;}
_s.oRemoved=null;_s._didAppend=true;}
_s.o=_s.getMovie(_s.id);}
if(_s.o){_s._wD('soundManager._initMovie(): Got '+_s.o.nodeName+' element ('+(_s._didAppend?'created via JS':'static HTML')+')',1);if(_s.flashLoadTimeout>0){_s._wD('soundManager._initMovie(): Waiting for ExternalInterface call from Flash..');}}
if(typeof _s.oninitmovie=='function'){setTimeout(_s.oninitmovie,1);}};this.waitForExternalInterface=function(){if(_s._waitingForEI){return false;}
_s._waitingForEI=true;if(_s._tryInitOnFocus&&!_s._isFocused){_s._wD(_s.strings.waitFocus);return false;}
if(_s.flashLoadTimeout>0){if(!_s._didInit){_s._wD(_s.strings.waitImpatient);}
setTimeout(function(){if(!_s._didInit){_s._wD('soundManager: No Flash response within reasonable time after document load.\nPossible causes: Loading '+_s.movieURL+' failed, Flash version under '+_s.flashVersion+', no support, flash blocked or JS-Flash security error.',2);if(!_s._overHTTP){_s._wD(_s.strings.localFail,2);}
_s._debugTS('flashtojs',false,': Timed out'+(_s._overHTTP)?' (Check flash security or flash blockers)':' (No plugin/missing SWF?)');}
if(!_s._didInit&&_s._okToDisable){_s._failSafely(true);}},_s.flashLoadTimeout);}else if(!_s._didInit){_s._wD(_s.strings.waitForever);}};this.handleFocus=function(){if(_s._isFocused||!_s._tryInitOnFocus){return true;}
_s._okToDisable=true;_s._isFocused=true;_s._wD('soundManager.handleFocus()');if(_s._tryInitOnFocus){window.removeEventListener('mousemove',_s.handleFocus,false);}
_s._waitingForEI=false;setTimeout(_s.waitForExternalInterface,500);if(window.removeEventListener){window.removeEventListener('focus',_s.handleFocus,false);}else if(window.detachEvent){window.detachEvent('onfocus',_s.handleFocus);}};this.initComplete=function(bNoDisable){if(_s._didInit){return false;}
_s._didInit=true;_s._wD('-- SoundManager 2 '+(_s._disabled?'failed to load':'loaded')+' ('+(_s._disabled?'security/load error':'OK')+') --',1);if(_s._disabled||bNoDisable){_s._wD('soundManager.initComplete(): calling soundManager.onerror()',1);_s._processOnReady();_s._debugTS('onload',false);_s.onerror.apply(window);return false;}else{_s._debugTS('onload',true);}
if(_s.waitForWindowLoad&&!_s._windowLoaded){_s._wD('soundManager: Waiting for window.onload()');if(window.addEventListener){window.addEventListener('load',_s._initUserOnload,false);}else if(window.attachEvent){window.attachEvent('onload',_s._initUserOnload);}
return false;}else{if(_s.waitForWindowLoad&&_s._windowLoaded){_s._wD('soundManager: Document already loaded');}
_s._initUserOnload();}};this._addOnReady=function(oMethod,oScope){_s._onready.push({'method':oMethod,'scope':(oScope||null),'fired':false});};this._processOnReady=function(){if(!_s._didInit){return false;}
var status={success:(!_s._disabled)};var queue=[];for(var i=0,j=_s._onready.length;i<j;i++){if(_s._onready[i].fired!==true){queue.push(_s._onready[i]);}}
if(queue.length){_s._wD('soundManager: Firing '+queue.length+' onready() item'+(queue.length>1?'s':''));for(i=0,j=queue.length;i<j;i++){if(queue[i].scope){queue[i].method.apply(queue[i].scope,[status]);}else{queue[i].method(status);}
queue[i].fired=true;}}};this._initUserOnload=function(){window.setTimeout(function(){_s._processOnReady();_s._wD('soundManager.initComplete(): calling soundManager.onload()',1);_s.onload.apply(window);_s._wD('soundManager.onload() complete',1);});};this.init=function(){_s._wD('-- soundManager.init() --');_s._initMovie();if(_s._didInit){_s._wD('soundManager.init(): Already called?');return false;}
if(window.removeEventListener){window.removeEventListener('load',_s.beginDelayedInit,false);}else if(window.detachEvent){window.detachEvent('onload',_s.beginDelayedInit);}
try{_s._wD('Attempting to call Flash from JS..');_s.o._externalInterfaceTest(false);if(!_s.allowPolling){_s._wD('Polling (whileloading()/whileplaying() support) is disabled.',1);}
_s._setPolling(true,_s.useFastPolling?true:false);if(!_s.debugMode){_s.o._disableDebug();}
_s.enabled=true;_s._debugTS('jstoflash',true);}catch(e){_s._wD('js/flash exception: '+e.toString());_s._debugTS('jstoflash',false);_s._failSafely(true);_s.initComplete();return false;}
_s.initComplete();};this.beginDelayedInit=function(){_s._wD('soundManager.beginDelayedInit()');_s._windowLoaded=true;setTimeout(_s.waitForExternalInterface,500);setTimeout(_s.beginInit,20);};this.beginInit=function(){if(_s._initPending){return false;}
_s.createMovie();_s._initMovie();_s._initPending=true;return true;};this.domContentLoaded=function(){_s._wD('soundManager.domContentLoaded()');if(document.removeEventListener){document.removeEventListener('DOMContentLoaded',_s.domContentLoaded,false);}
_s.go();};this._externalInterfaceOK=function(){if(_s.swfLoaded){return false;}
_s._wD('soundManager._externalInterfaceOK()');_s._debugTS('swf',true);_s._debugTS('flashtojs',true);_s.swfLoaded=true;_s._tryInitOnFocus=false;if(_s.isIE){setTimeout(_s.init,100);}else{_s.init();}};this._setSandboxType=function(sandboxType){var sb=_s.sandbox;sb.type=sandboxType;sb.description=sb.types[(typeof sb.types[sandboxType]!='undefined'?sandboxType:'unknown')];_s._wD('Flash security sandbox type: '+sb.type);if(sb.type=='localWithFile'){sb.noRemote=true;sb.noLocal=false;_s._wD('Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html',2);}else if(sb.type=='localWithNetwork'){sb.noRemote=false;sb.noLocal=true;}else if(sb.type=='localTrusted'){sb.noRemote=false;sb.noLocal=false;}};this.reboot=function(){_s._wD('soundManager.reboot()');if(_s.soundIDs.length){_s._wD('Destroying '+_s.soundIDs.length+' SMSound objects...');}
for(var i=_s.soundIDs.length;i--;){_s.sounds[_s.soundIDs[i]].destruct();}
try{if(_s.isIE){_s.oRemovedHTML=_s.o.innerHTML;}
_s.oRemoved=_s.o.parentNode.removeChild(_s.o);_s._wD('Flash movie removed.');}catch(e){_s._wD('Warning: Failed to remove flash movie.',2);}
_s.enabled=false;_s._didInit=false;_s._waitingForEI=false;_s._initPending=false;_s._didAppend=false;_s._appendSuccess=false;_s._disabled=false;_s._waitingForEI=true;_s.swfLoaded=false;_s.soundIDs={};_s.sounds=[];_s.o=null;for(i=_s._onready.length;i--;){_s._onready[i].fired=false;}
_s._wD('soundManager: Rebooting...');window.setTimeout(soundManager.beginDelayedInit,20);};this.destruct=function(){_s._wD('soundManager.destruct()');_s.disable(true);};SMSound=function(oOptions){var _t=this;this.sID=oOptions.id;this.url=oOptions.url;this.options=_s._mergeObjects(oOptions);this.instanceOptions=this.options;this._iO=this.instanceOptions;this.pan=this.options.pan;this.volume=this.options.volume;this._lastURL=null;this._debug=function(){if(_s.debugMode){var stuff=null;var msg=[];var sF=null;var sfBracket=null;var maxLength=64;for(stuff in _t.options){if(_t.options[stuff]!==null){if(_t.options[stuff]instanceof Function){sF=_t.options[stuff].toString();sF=sF.replace(/\s\s+/g,' ');sfBracket=sF.indexOf('{');msg[msg.length]=' '+stuff+': {'+sF.substr(sfBracket+1,(Math.min(Math.max(sF.indexOf('\n')-1,maxLength),maxLength))).replace(/\n/g,'')+'... }';}else{msg[msg.length]=' '+stuff+': '+_t.options[stuff];}}}
_s._wD('SMSound() merged options: {\n'+msg.join(', \n')+'\n}');}};this._debug();this.id3={};this.resetProperties=function(bLoaded){_t.bytesLoaded=null;_t.bytesTotal=null;_t.position=null;_t.duration=null;_t.durationEstimate=null;_t.loaded=false;_t.playState=0;_t.paused=false;_t.readyState=0;_t.muted=false;_t.didBeforeFinish=false;_t.didJustBeforeFinish=false;_t.isBuffering=false;_t.instanceOptions={};_t.instanceCount=0;_t.peakData={left:0,right:0};_t.waveformData={left:[],right:[]};_t.eqData=[];};_t.resetProperties();this.load=function(oOptions){if(typeof oOptions!='undefined'){_t._iO=_s._mergeObjects(oOptions);_t.instanceOptions=_t._iO;}else{oOptions=_t.options;_t._iO=oOptions;_t.instanceOptions=_t._iO;if(_t._lastURL&&_t._lastURL!=_t.url){_s._wD('SMSound.load(): Using manually-assigned URL');_t._iO.url=_t.url;_t.url=null;}}
if(typeof _t._iO.url=='undefined'){_t._iO.url=_t.url;}
_s._wD('soundManager.load(): '+_t._iO.url,1);if(_t._iO.url==_t.url&&_t.readyState!==0&&_t.readyState!=2){_s._wD('soundManager.load(): current URL already assigned.',1);return false;}
_t.url=_t._iO.url;_t._lastURL=_t._iO.url;_t.loaded=false;_t.readyState=1;_t.playState=0;try{if(_s.flashVersion==8){_s.o._load(_t.sID,_t._iO.url,_t._iO.stream,_t._iO.autoPlay,(_t._iO.whileloading?1:0));}else{_s.o._load(_t.sID,_t._iO.url,_t._iO.stream?true:false,_t._iO.autoPlay?true:false);if(_t._iO.isMovieStar&&_t._iO.autoLoad&&!_t._iO.autoPlay){_t.pause();}}}catch(e){_s._wD('SMSound.load(): Exception: JS-Flash communication failed, or JS error.',2);_s._debugTS('onload',false);_s.onerror();_s.disable();}};this.unload=function(){if(_t.readyState!==0){_s._wD('SMSound.unload(): "'+_t.sID+'"');if(_t.readyState!=2){_t.setPosition(0,true);}
_s.o._unload(_t.sID,_s.nullURL);_t.resetProperties();}};this.destruct=function(){_s._wD('SMSound.destruct(): "'+_t.sID+'"');_s.o._destroySound(_t.sID);_s.destroySound(_t.sID,true);};this.play=function(oOptions){if(!oOptions){oOptions={};}
_t._iO=_s._mergeObjects(oOptions,_t._iO);_t._iO=_s._mergeObjects(_t._iO,_t.options);_t.instanceOptions=_t._iO;if(_t.playState==1){var allowMulti=_t._iO.multiShot;if(!allowMulti){_s._wD('SMSound.play(): "'+_t.sID+'" already playing (one-shot)',1);return false;}else{_s._wD('SMSound.play(): "'+_t.sID+'" already playing (multi-shot)',1);}}
if(!_t.loaded){if(_t.readyState===0){_s._wD('SMSound.play(): Attempting to load "'+_t.sID+'"',1);_t._iO.stream=true;_t._iO.autoPlay=true;_t.load(_t._iO);}else if(_t.readyState==2){_s._wD('SMSound.play(): Could not load "'+_t.sID+'" - exiting',2);return false;}else{_s._wD('SMSound.play(): "'+_t.sID+'" is loading - attempting to play..',1);}}else{_s._wD('SMSound.play(): "'+_t.sID+'"');}
if(_t.paused){_t.resume();}else{_t.playState=1;if(!_t.instanceCount||_s.flashVersion>8){_t.instanceCount++;}
_t.position=(typeof _t._iO.position!='undefined'&&!isNaN(_t._iO.position)?_t._iO.position:0);if(_t._iO.onplay){_t._iO.onplay.apply(_t);}
_t.setVolume(_t._iO.volume,true);_t.setPan(_t._iO.pan,true);_s.o._start(_t.sID,_t._iO.loop||1,(_s.flashVersion==9?_t.position:_t.position/1000));}};this.start=this.play;this.stop=function(bAll){if(_t.playState==1){_t.playState=0;_t.paused=false;if(_t._iO.onstop){_t._iO.onstop.apply(_t);}
_s.o._stop(_t.sID,bAll);_t.instanceCount=0;_t._iO={};}};this.setPosition=function(nMsecOffset,bNoDebug){if(typeof nMsecOffset=='undefined'){nMsecOffset=0;}
var offset=Math.min(_t.duration,Math.max(nMsecOffset,0));_t._iO.position=offset;if(!bNoDebug){}
_s.o._setPosition(_t.sID,(_s.flashVersion==9?_t._iO.position:_t._iO.position/1000),(_t.paused||!_t.playState));};this.pause=function(){if(_t.paused||_t.playState===0){return false;}
_s._wD('SMSound.pause()');_t.paused=true;_s.o._pause(_t.sID);if(_t._iO.onpause){_t._iO.onpause.apply(_t);}};this.resume=function(){if(!_t.paused||_t.playState===0){return false;}
_s._wD('SMSound.resume()');_t.paused=false;_s.o._pause(_t.sID);if(_t._iO.onresume){_t._iO.onresume.apply(_t);}};this.togglePause=function(){_s._wD('SMSound.togglePause()');if(_t.playState===0){_t.play({position:(_s.flashVersion==9?_t.position:_t.position/1000)});return false;}
if(_t.paused){_t.resume();}else{_t.pause();}};this.setPan=function(nPan,bInstanceOnly){if(typeof nPan=='undefined'){nPan=0;}
if(typeof bInstanceOnly=='undefined'){bInstanceOnly=false;}
_s.o._setPan(_t.sID,nPan);_t._iO.pan=nPan;if(!bInstanceOnly){_t.pan=nPan;}};this.setVolume=function(nVol,bInstanceOnly){if(typeof nVol=='undefined'){nVol=100;}
if(typeof bInstanceOnly=='undefined'){bInstanceOnly=false;}
_s.o._setVolume(_t.sID,(_s.muted&&!_t.muted)||_t.muted?0:nVol);_t._iO.volume=nVol;if(!bInstanceOnly){_t.volume=nVol;}};this.mute=function(){_t.muted=true;_s.o._setVolume(_t.sID,0);};this.unmute=function(){_t.muted=false;var hasIO=typeof _t._iO.volume!='undefined';_s.o._setVolume(_t.sID,hasIO?_t._iO.volume:_t.options.volume);};this.toggleMute=function(){if(_t.muted){_t.unmute();}else{_t.mute();}};this._whileloading=function(nBytesLoaded,nBytesTotal,nDuration){if(!_t._iO.isMovieStar){_t.bytesLoaded=nBytesLoaded;_t.bytesTotal=nBytesTotal;_t.duration=Math.floor(nDuration);_t.durationEstimate=parseInt((_t.bytesTotal/_t.bytesLoaded)*_t.duration,10);if(_t.durationEstimate===undefined){_t.durationEstimate=_t.duration;}
if(_t.readyState!=3&&_t._iO.whileloading){_t._iO.whileloading.apply(_t);}}else{_t.bytesLoaded=nBytesLoaded;_t.bytesTotal=nBytesTotal;_t.duration=Math.floor(nDuration);_t.durationEstimate=_t.duration;if(_t.readyState!=3&&_t._iO.whileloading){_t._iO.whileloading.apply(_t);}}};this._onid3=function(oID3PropNames,oID3Data){_s._wD('SMSound._onid3(): "'+this.sID+'" ID3 data received.');var oData=[];for(var i=0,j=oID3PropNames.length;i<j;i++){oData[oID3PropNames[i]]=oID3Data[i];}
_t.id3=_s._mergeObjects(_t.id3,oData);if(_t._iO.onid3){_t._iO.onid3.apply(_t);}};this._whileplaying=function(nPosition,oPeakData,oWaveformDataLeft,oWaveformDataRight,oEQData){if(isNaN(nPosition)||nPosition===null){return false;}
if(_t.playState===0&&nPosition>0){nPosition=0;}
_t.position=nPosition;if(_t._iO.usePeakData&&typeof oPeakData!='undefined'&&oPeakData){_t.peakData={left:oPeakData.leftPeak,right:oPeakData.rightPeak};}
if(_t._iO.useWaveformData&&typeof oWaveformDataLeft!='undefined'&&oWaveformDataLeft){_t.waveformData={left:oWaveformDataLeft.split(','),right:oWaveformDataRight.split(',')};}
if(_t._iO.useEQData&&typeof oEQData!='undefined'&&oEQData){_t.eqData=oEQData;}
if(_t.playState==1){if(_t.isBuffering){_t._onbufferchange(0);}
if(_t._iO.whileplaying){_t._iO.whileplaying.apply(_t);}
if(_t.loaded&&_t._iO.onbeforefinish&&_t._iO.onbeforefinishtime&&!_t.didBeforeFinish&&_t.duration-_t.position<=_t._iO.onbeforefinishtime){_s._wD('duration-position &lt;= onbeforefinishtime: '+_t.duration+' - '+_t.position+' &lt= '+_t._iO.onbeforefinishtime+' ('+(_t.duration-_t.position)+')');_t._onbeforefinish();}}};this._onload=function(bSuccess){bSuccess=(bSuccess==1?true:false);_s._wD('SMSound._onload(): "'+_t.sID+'"'+(bSuccess?' loaded.':' failed to load? - '+_t.url),(bSuccess?1:2));if(!bSuccess){if(_s.sandbox.noRemote===true){_s._wD('SMSound._onload(): Reminder: Flash security is denying network/internet access',1);}
if(_s.sandbox.noLocal===true){_s._wD('SMSound._onload(): Reminder: Flash security is denying local access',1);}}
_t.loaded=bSuccess;_t.readyState=bSuccess?3:2;if(_t._iO.onload){_t._iO.onload.apply(_t);}};this._onbeforefinish=function(){if(!_t.didBeforeFinish){_t.didBeforeFinish=true;if(_t._iO.onbeforefinish){_s._wD('SMSound._onbeforefinish(): "'+_t.sID+'"');_t._iO.onbeforefinish.apply(_t);}}};this._onjustbeforefinish=function(msOffset){if(!_t.didJustBeforeFinish){_t.didJustBeforeFinish=true;if(_t._iO.onjustbeforefinish){_s._wD('SMSound._onjustbeforefinish(): "'+_t.sID+'"');_t._iO.onjustbeforefinish.apply(_t);}}};this._onfinish=function(){if(_t._iO.onbeforefinishcomplete){_t._iO.onbeforefinishcomplete.apply(_t);}
_t.didBeforeFinish=false;_t.didJustBeforeFinish=false;if(_t.instanceCount){_t.instanceCount--;if(!_t.instanceCount){_t.playState=0;_t.paused=false;_t.instanceCount=0;_t.instanceOptions={};}
if(!_t.instanceCount||_t._iO.multiShotEvents){if(_t._iO.onfinish){_s._wD('SMSound._onfinish(): "'+_t.sID+'"');_t._iO.onfinish.apply(_t);}}}else{if(_t.useVideo){}}};this._onmetadata=function(oMetaData){_s._wD('SMSound.onmetadata()');if(!oMetaData.width&&!oMetaData.height){_s._wD('No width/height given, assuming defaults');oMetaData.width=320;oMetaData.height=240;}
_t.metadata=oMetaData;_t.width=oMetaData.width;_t.height=oMetaData.height;if(_t._iO.onmetadata){_s._wD('SMSound._onmetadata(): "'+_t.sID+'"');_t._iO.onmetadata.apply(_t);}
_s._wD('SMSound.onmetadata() complete');};this._onbufferchange=function(bIsBuffering){if(_t.playState===0){return false;}
if(bIsBuffering==_t.isBuffering){_s._wD('_onbufferchange: ignoring false default / loaded sound');return false;}
_t.isBuffering=(bIsBuffering==1?true:false);if(_t._iO.onbufferchange){_s._wD('SMSound._onbufferchange(): '+bIsBuffering);_t._iO.onbufferchange.apply(_t);}};this._ondataerror=function(sError){if(_t.playState>0){_s._wD('SMSound._ondataerror(): '+sError);if(_t._iO.ondataerror){_t._iO.ondataerror.apply(_t);}}else{}};};this._onfullscreenchange=function(bFullScreen){_s._wD('onfullscreenchange(): '+bFullScreen);_s.isFullScreen=(bFullScreen==1?true:false);if(!_s.isFullScreen){try{window.focus();_s._wD('window.focus()');}catch(e){}}};if(window.addEventListener){window.addEventListener('focus',_s.handleFocus,false);window.addEventListener('load',_s.beginDelayedInit,false);window.addEventListener('unload',_s.destruct,false);if(_s._tryInitOnFocus){window.addEventListener('mousemove',_s.handleFocus,false);}}else if(window.attachEvent){window.attachEvent('onfocus',_s.handleFocus);window.attachEvent('onload',_s.beginDelayedInit);window.attachEvent('unload',_s.destruct);}else{_s._debugTS('onload',false);soundManager.onerror();soundManager.disable();}
if(document.addEventListener){document.addEventListener('DOMContentLoaded',_s.domContentLoaded,false);}}
if(typeof SM2_DEFER=='undefined'||!SM2_DEFER){soundManager=new SoundManager();}
(function($){jQuery.flashVersion=function(){var playerVersion=function(){if($.browser.msie){try{var axo=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');try{axo.AllowScriptAccess='always';}
catch(e){return'6,0,0';}}catch(e){}
return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g,',').match(/^,?(.+),?$/)[1];}else{try{if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){return(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g,",").match(/^,?(.+),?$/)[1];}}catch(e){}}
return'0,0,0';};var ver=playerVersion().split(',');return{major:ver[0],minor:ver[1],release:ver[2]};};})(jQuery);if(!window.console)
{var names=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];window.console={};for(var i=0;i<names.length;++i){window.console[names[i]]=function(){};}}
(function($){var pageTracker;$.trackPage=function(account_id,options){var host=(("https:"==document.location.protocol)?"https://ssl.":"http://www.");var script;var settings=$.extend({},{onload:true,status_code:200,visitor_type:''},options);var src=host+'google-analytics.com/ga.js';var init_analytics=function(){if(typeof _gat!=undefined){debug('Google Analytics loaded');pageTracker=_gat._getTracker(account_id);if(settings.status_code==null||settings.status_code==200){$.trackPageview();if(settings.visitor_type.length>0){pageTracker._setVar(settings.visitor_type);}}else{debug('Tracking error '+settings.status_code);$.trackPageview("/"+settings.status_code+".html?page="+document.location.pathname+document.location.search+"&from="+document.referrer);}
if($.isFunction(settings.callback)){settings.callback();}}
else{throw"_gat is undefined";}}
var load_script=function(){$.ajax({type:"GET",url:src,success:function(){init_analytics();},dataType:"script",cache:true});}
if(settings.onload==true||settings.onload==null){$(window).load(load_script);}else{load_script();}}
$.trackEvent=function(category,action,label,value){if(typeof pageTracker=='undefined'){debug('FATAL: pageTracker is not defined');}else{pageTracker._trackEvent(category,action,label,value);}};$.trackPageview=function(url){if(typeof pageTracker=='undefined'){debug('FATAL: pageTracker is not defined');}else{if(url){pageTracker._trackPageview(url);}else{pageTracker._trackPageview();}}};$.fn.track=function(options){return this.each(function(){var element=$(this);if(element.hasClass('tracked')){return false;}else{element.addClass('tracked');}
var settings=$.extend({},$.fn.track.defaults,options);var category=evaluate(element,settings.category);var action=evaluate(element,settings.action);var label=evaluate(element,settings.label);var value=evaluate(element,settings.value);var event_name=evaluate(element,settings.event_name);var message="category:'"+category+"' action:'"+action+"' label:'"+label+"' value:'"+value+"'";debug('Tracking '+event_name+' '+message);element.bind(event_name+'.track',function(){var skip=settings.skip_internal&&(element[0].hostname==location.hostname);if(!skip){$.trackEvent(category,action,label,value);debug('Tracked '+message);}else{debug('Skipped '+message);}
return true;});});function evaluate(element,text_or_function){if(typeof text_or_function=='function'){text_or_function=text_or_function(element);}
return text_or_function;};};function debug(message){if(typeof console!='undefined'&&typeof console.debug!='undefined'&&$.fn.track.defaults.debug){console.debug(message);}};$.fn.track.defaults={category:function(element){return(element[0].hostname==location.hostname)?'internal':'external';},action:'click',label:function(element){return element.attr('href');},value:null,skip_internal:true,event_name:'click',debug:false};})(jQuery);String.prototype.trim=function(){return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1");};(function($){jQuery.debug=function(){if(window.console&&!window.opera){console.debug(arguments);}else if(window.opera){window.opera.postError(arguments.join(' | '));}else{window.alert(arguments.join(' | '));}};jQuery.fn.delay=function(time,callback){return this.animate({marginLeft:'-=0px'},time,function(){if($.isFunction(callback)){callback.apply($(this));}});};jQuery.isNotBlank=function(str){return str&&(/\S/).test(str);};jQuery.fn.exists=function(){return this.size()>0;};jQuery.fn.toggleClasses=function(classes){var $nodes=this;$.each(classes.split(/\s+/),function(index,value){$nodes.toggleClass(value);});return this;};jQuery.leaveMsg=function(status){window.onbeforeunload=null;if(status){window.onbeforeunload=null;window.onbeforeunload=function(e){$(document).trigger('onBeforeUnload');return status;};}else{window.onbeforeunload=function(e){$(document).trigger('onBeforeUnload');return;};}};jQuery.leaveMsg();})(jQuery);if(jQuery.browser.msie){(function($){function fade(effect){return function(speed,callback){var png=/\.png/,hasPng=false,$node=this;$node.children().andSelf().each(function(){hasPng=!!png.exec($(this).css('background-image'));return!hasPng;});if(hasPng){return $node.delay(speed,function(){$(this)[effect]();if($.isFunction(callback)){callback.apply($node);}});}else{return $node.animate({opacity:effect},speed,callback);}};}
$.fn.extend({fadeIn:fade('show'),fadeOut:fade('hide')});})(jQuery);}
var Class={create:function(){return function(){this.initialize.apply(this,arguments);};}};var SC={USER:window.settings.userId,CURRENT_USER:window.settings.currentUser,SECRET_TOKEN:window.settings.secretToken,FX_FAST:150,FX_MEDIUM:300,FX_SLOW:600,FX_SLOWER:1500,EASING:'easeInOutExpo',EASING_OUT:'easeOutExpo',ENTER_KEY:13,ESCAPE_KEY:27,UP_KEY:38,DOWN_KEY:40,DEFAULT_VOLUME:80,FORM_INVALID_COLOR:'#ffeac8',FORM_VALID_COLOR:'#e3ffbb',FORM_NORMAL_COLOR:'#ffffc7',DEBUG_MODE:/debug/.test(window.location.hash),SLOW:function(){return $.browser.mozilla&&($.browser.version.match(/^1\.[0-8]/)||(/linux/i).test(navigator.platform));}(),asset_url:function(path){return"http://a1."+document.location.host+path;},media_url:function(path){return"http://media."+document.location.host+path;},returnTrue:function(){return true;},returnFalse:function(){return false;},xhr:{partial:function(xhr){xhr.setRequestHeader('Accept',"text/html+partial");},scJson:function(xhr){xhr.setRequestHeader('Accept',"soundcloud/json");},json:function(xhr){xhr.setRequestHeader('Accept',"application/json");},js:function(xhr){xhr.setRequestHeader('Accept',"text/javascript");}},noop:function(){return this;}};$(function(){$.ajaxSetup({beforeSend:SC.xhr.js});Helpers.notice();if(SC.PlayerManager){SC.playerManager=new SC.PlayerManager($('#main-wrapper').find('div.player, a[id^=player-]'));}
$(document).trigger('throbberStop');});var Helpers={plural:function(num,singular,plural){return parseInt(num,10)===1?singular:plural;},throttle:function(delay,fn){var last=null,partial=fn;if(delay>0){partial=function(){var now=new Date(),scope=this,args=arguments;clearTimeout(partial.futureTimeout);partial.futureTimeout=null;if(last===null||now-last>delay){fn.apply(scope,args);last=now;}else{partial.futureTimeout=setTimeout(function(){fn.apply(scope,args);},delay);}};}
return partial;},jeditableAjaxCall:function(value,settings){var data={};data[settings.name]=value;$.scAjax({url:settings.path,type:'update',accept:'text/javascript',data:data,async:false,callback:function(response){settings.data=$("<div>"+response+"</div>").text();}});return value;},hms:function(ms){return{h:Math.floor(ms/(60*60*1000)),m:Math.floor((ms/60000)%60),s:Math.floor((ms/1000)%60)};},timecode:function(ms){var hms=Helpers.hms(ms),tc=[];if(hms.h>0){tc.push(hms.h);}
tc.push((hms.m<10&&hms.h>0?"0"+hms.m:hms.m));tc.push((hms.s<10?"0"+hms.s:hms.s));return tc.join('.');},msToWords:function(ms){var p=Helpers.plural,hms=Helpers.hms(ms),words=[];if(hms.h>0){words.push(hms.h);words.push(p(hms.h,'hour','hours'));}
if(hms.m>0){words.push(hms.m);words.push(p(hms.m,'minute','minutes'));}
if(hms.h===0&&hms.m===1&&hms.s>0){words.push('and');}
if(hms.h===0&&hms.m<=1&&hms.s>0){words.push(hms.s);words.push(p(hms.s,'second','seconds'));}
return words.join(' ');},sToWords:function(s){return Helpers.msToWords(s*1000);},timeToMillis:function(time){var times=time.split(/,|\.|:/);if(times.length===2){return(parseInt(times[0],10)*60+parseInt(times[1],10))*1000;}
return parseInt(times[0],10)*1000;},toMB:function(bytes){var megaBytes=bytes/(1024*1024);return Math.floor(megaBytes*100)/100;},convertTimeToWellFormattedString:function(time){return time.replace(/[\,\:\ \;]+/,".");},trimTextLines:function(text){return text.replace(/\n[ \t]+/g,'\n').trim();},cleanScripts:function(str){return str.replace(/[\"\'][\s]*javascript:(.*)[\"\']/g,"\"\"").replace(/<script/g,"").replace(/<object/g,"").replace(/<link/g,"").replace(/eval\((.*)\)/g,"");},hash32:function(str){var hash=16777619;for(var i=str.length;i>0;i-=1){hash=(hash&0xFF)^str.charCodeAt(i);hash=(hash*21661362613)%4294967296;}
return hash;},objToUrl:function(obj){var r=[];$.each(obj,function(index,value){r.push((encodeURIComponent(index)+'='+encodeURIComponent(value)));});return r.join('&');},notice:function(msg){var $node,$body=$('body:first');if(msg){$('#flash-notice').remove();$node=$('<div id="flash-notice">'+msg+'</div>').prependTo($body);}else{$node=$('#flash-notice');}
$node.css({left:($body.width()-$node.width())/2}).show().animate({'bottom':30},1000,'easeOutBack').delay(2000).fadeOut(4000,'easeInExpo',function(){$(this).remove();});},getId:function(el){var id=$(el).attr('id').match(/\d+/)[0];if(!id){return;}
return parseInt(id,10);},getIdFromPath:function(el){var href=$(el).attr('href');return parseInt(href.substring(href.lastIndexOf('/')+1),10);},getLastNumInPath:function(path){var result=parseInt(path.match(/\D*\/(\d*)(\/\D*)?$/)[1],10);if(result.toString()==="NaN"){return"";}
return result;},getParamInQuery:function(path,param){var match=path.match(new RegExp("(?:\\?|&)"+param+"=([^&]*)(?:&|$)"));if(match){return decodeURIComponent(match[1]);}},setParamInQuery:function(path,param,value){return path.replace(new RegExp("(\\?|&)"+param+"=([^&]*)(&|$)"),"$1"+param+"="+value+"$3");},json:function(jsonData){try{return eval("("+jsonData+")");}catch(err){return null;}},setCookie:function(name,value,options){if(!name){return false;}
options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires==='number'||options.expires.toUTCString)){var date;if(typeof options.expires==='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');return true;},getCookie:function(name){var cookieValue=null;$.each(document.cookie.split(';'),function(index,value){var cookie=$.trim(value);if(cookie.substring(0,name.length+1)===(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));return;}});return cookieValue;},removeCookie:function(name){this.setCookie(name);},setVolume:function(value){if(typeof value==='number'){Helpers.setCookie('_default_volume',value,{expires:365,path:'/'});return true;}else{throw'volume value has to a number';}},getVolume:function(){return(typeof Helpers.getCookie('_default_volume')==='string')?parseInt(Helpers.getCookie('_default_volume'),10):SC.DEFAULT_VOLUME;},setCaretToEnd:function($inputs){this.setCaretPosition($inputs,$inputs.val().length);},setCaretPosition:function($input,caretPosition){var input=$($input)[0];if(document.selection){input.focus();var oSel=document.selection.createRange();oSel.moveStart('character',-input.value.length);oSel.moveStart('character',caretPosition);oSel.moveEnd('character',0);oSel.select();}else if(input.selectionStart||input.selectionStart===0||input.selectionStart==='0'){input.selectionStart=caretPosition;input.selectionEnd=caretPosition;input.focus();}else{input.focus();}},isNormalClick:function(ev){return!(ev.which>1||ev.metaKey||ev.shiftKey||ev.ctrlKey);},enableGuiBlock:function(msg){msg=msg||"Please wait until the transaction is over";var $block=$('<div id="gui-block" class="modal-fade"></div>').css('opacity',0).appendTo('body').show();$block.click(function(){Helpers.notice(msg);});},removeGuiBlock:function(){$('#gui-block').remove();},linkToForm:function(action,method){var input=$(document.createElement('input')).attr({type:'hidden',name:'_method',value:method});var form=$(document.createElement('form')).attr({method:'POST',action:action}).hide();form.append(input).submit(function(){$(document).trigger('ajaxStart');});$("body").append(form);return form;},insertItemForm:function(form,intoElement,validatorFunction,counter){validatorFunction=validatorFunction||SC.returnTrue;form.ajaxForm({success:function(responseText){$(responseText).appendTo(intoElement).hide().slideDown(SC.FX_SLOW,SC.EASING_OUT);$(intoElement).parents('.hidden').removeClass('hidden');if(typeof counter!=='undefined'){$(counter).increment(1);}
form.trigger("onItemFormLoad");},beforeSubmit:Helpers.formValidator(validatorFunction),clearForm:true});},validateEmail:function(value){return(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i).test(value);},formValidator:function(validator){return function(formArray,jqForm){var valid=validator();if(!valid){$(jqForm).addClass("invalid").trigger("invalid");}else{$(jqForm).removeClass("invalid");}
return valid;};},removePlayer:function(node,callback){$(node).closest('li.player').slideUp(function(){SC.playerManager.remove($('div.player',this));$(this).remove();if($.isFunction(callback)){callback();}});},getPlayerNode:function(link){var $link=$(link);var $player=$link.closest('div.player');if($link.parents('ol.tracks:first').exists()){var itemId=$link.closest('li').attr('id');$player=$('#'+itemId.replace(/listing/,'players')+' .player:first');}
if(!$player.exists()){throw"No player could be found for this node";}
return $player;},getPlayer:function(link){if(SC.playerManager.players.length){return SC.playerManager.get(this.getPlayerNode(link).attr('id'));}else if(!SC.playerManager.soundManager.supported()){$(document).trigger('onSoundManagerFail');throw"SoundCloud player initialization failed";}else{return false;}},getCommentPrefix:function($node){return['@',$node.find('a.user-name:first').attr('href').replace(/.*\//,''),': '].join('');},hideDialogOnClickOutside:function(dialog,evnt,remove){var hideDialog=function(evt){var hits=$.grep(dialog.find("*"),function(o){return(o===evt.target);});if(evt.target!==evnt.target&&hits.length===0){$(document).unbind('mouseup.dialog',hideDialog);dialog.hide(SC.FX_FAST,function(){if(remove){dialog.remove();}});$("#main-content a.button.active:first").removeClass("active");dialog.trigger('onClose');}};if(dialog.is(':visible')){$(document).unbind('mouseup.dialog',hideDialog);}else{$(document).bind('mouseup.dialog',hideDialog);}},urlencodedToObject:function(str){var r={};$.each(str.split('&'),function(){var pair=this.split('=');r[pair[0]]=pair[1];});return r;},timeStringToTimeObject:function(str){var i=parseInt,m=str.match(/(?:(\d)+h\D*)*(?:(\d)+m\D*)*(?:(\d)+s\D*)*(?:(\d*)\D*)*/i);return{hours:i('0'+m[1],10),minutes:i('0'+m[2],10),seconds:i('0'+m[3],10),millis:i('0'+m[4],10)};},timeStringToMillis:function(str){var time=this.timeStringToTimeObject(str);return((time.hours*60+time.minutes)*60+time.seconds)*1000+time.millis;},waitForImage:function(src,callback){var i=new Image(),t=null,ms=500;function bust(u){return u+(u.indexOf('?')>=0?'&':'?')+(new Date()).getTime();}
$(i).bind('load',function(){clearTimeout(t);t=null;callback();}).bind('error',function(){ms=ms*1.25;t=setTimeout(function(){i.src=bust(src);},ms);});i.src=bust(src);return i;},waitForBgImage:function($elem,callback){return Helpers.waitForImage($elem.css('background').match(/url\((.*)\)/)[1],callback);},timeout:function(delay,fn,expired){var t=setTimeout(function(){fn=null;expired();},delay);return function(){clearTimeout(t);t=null;return($.isFunction(fn)&&fn());};},require:function(src,condition,callback){if(!condition()){$('<script>').attr('src',src).attr('type','text/javascript').appendTo($('head'));}
var t=setInterval(function(){if(condition()){clearTimeout(t);t=null;callback();}},100);},permalize:function(string){return string.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9\-]/g,"")||this.randomString(12);},randomString:function(length,previous){var chars="0123456789abcdefghiklmnopqrstuvwxyz";var randomstring="";for(var i=0;i<length;i=i+1){var rnum=Math.floor(Math.random()*chars.length);randomstring+=chars.substring(rnum,rnum+1);}
return randomstring!==previous?randomstring:this.randomstring(length,previous);}};(function($){$.fn.actionIntent=function(){var okToShow='ok-to-show';var okToHide='ok-to-hide';var actionButtons='.action-buttons';return this.each(function(){$(this).unbind('mouseenter, mouseleave').mouseenter(function(ev){var actions=$(this).find(actionButtons);actions.addClass(okToShow).addClass(okToHide).delay(300,function(){if(actions.hasClass(okToShow)){actions.fadeIn('slow',function(){$(this).css('opacity','1');});}});}).mouseleave(function(ev){$(this).find(actionButtons).filter('.'+okToHide).stop().dequeue().removeClass(okToShow).removeClass(okToHide).hide();});});};})(jQuery);$(document).ajaxError(function(){if(SC.DEBUG_MODE){try{console.error(arguments);}catch(msg){}}});(function(){var mapping=undefined;jQuery.pluralize=function(num,sentence){if(!mapping){var words=[["comment","comments"],["track","tracks"],["contact","contacts"],["favorite","favorites"],["post","posts"],["is","are"],["was","were"]];mapping=[{},{}];jQuery.each(words,function(i,pair){mapping[0][pair[0]]=pair[1];mapping[1][pair[1]]=pair[0];});}
var direction=mapping[num===1?1:0];return $.map(sentence.split(/\s+/),function(word){return(direction[word.toLowerCase()]||word).replace(/^[a-z]/,function(a){return(/[A-Z]/).test(word[0])?a.toUpperCase():a;});}).join(' ');};})();jQuery.fn.increment=function(inc){return this.each(function(){var $node=$(this);var newValue;$node.html($node.html().replace(/\d+/,function(num){newValue=Math.max(parseInt(num,10)+inc,0);return newValue;}));if(newValue===0){$node.trigger('onReducedToZero');}
$.each($node[0].childNodes,function(id,node){if(node.data){node.data=$.pluralize(newValue,node.data);}else if(node.innerHTML){node.innerHTML=$.pluralize(newValue,node.innerHTML);}});});};(function($){$.fn.validateField=function(callerSettings){return this.each(function(){var $form=$(this).parents('form:first');if($form.validate&&$(this).val()){$form.validate().element(this);}});};})(jQuery);jQuery.fn.SCValidate=function(options,submitHandler){var validations={rules:{},messages:{}};for(var rule in options){validations.rules[rule]=SC.formsettings.rules[options[rule]];if(typeof SC.formsettings.messages[options[rule]]!=='undefined'){validations.messages[rule]=SC.formsettings.messages[options[rule]];}}
if(typeof submitHandler==="function"){validations.submitHandler=submitHandler;}
this.validate(validations);return this;};var remoteFailsafe=function(url){return function(input){return{url:url,timeout:10000,error:function(request,status){var validator=$(input).parents('form').data('validator');request.abort();if(status==="timeout"&&validator.formSubmitted){validator.currentForm.submit();}}};};};SC.formsettings={rules:{username:{required:true,validusername:true,rangelength:[3,25],remote:remoteFailsafe("/users/unique_username")},userPermalink:{required:true,validpermalink:true,rangelength:[3,25],remote:remoteFailsafe("/users/unique_permalink")},email:{required:true,email:true,rangelength:[3,100],remote:remoteFailsafe("/users/unique_email")},password:{required:true,rangelength:[4,50]},passwordConfirmation:{required:true,rangelength:[4,50],equalTo:"#user_password"},text:{required:true,text:true},terms:{required:true}},messages:{username:{required:"Please enter a username",rangelength:$.format("Your username should have between {0} and {1} characters"),remote:$.format("Sorry, that username is already taken")},userPermalink:{required:"Please enter your profile permalink",rangelength:$.format("Your profile address should have between {0} and {1} characters"),remote:$.format("Sorry, that url is already taken")},email:{required:"Please enter an e-mail address",remote:$.format("Sorry, {0} is already registered with another account"),rangelength:$.format("Your e-mail should have between {0} and {1} characters"),email:"Please enter a valid e-mail address"},password:{required:"Please provide a valid password",rangelength:$.format("Your password should have between {0} and {1} characters")},passwordConfirmation:{required:"Please repeat your password",rangelength:$.format("Your password should have between {0} and {1} characters"),equalTo:"Oops, that's not the same password as the first one"},terms:{required:"Please read and accept the terms first"}}};SC.metaInfoValidationRules=function(type,title){type=type||"track";title=title||type;var dic={success:"",rules:{},messages:{}};var r=dic.rules;r[type+"[title]"]={required:true,rangelength:[1,150]};r[type+"[bpm]"]={number:true};r[type+"[isrc]"]={isrc:true};r[type+"[purchase_url]"]={urlwithouthttp:true};r[type+"[video_url]"]={urlwithouthttp:true};r[type+"[ean]"]={ean:true};r[type+"[release_year]"]={required:function(element){return $("#"+type+"_release_month").val().trim()!==""||$("#"+type+"_release_day").val().trim()!=="";}};r[type+"[release_month]"]={required:function(element){return $("#"+type+"_release_day").val().trim()!=="";}};var m=dic.messages;m[type+"[title]"]={required:"Please give this "+title+" a title",rangelength:$.format("The "+title+" title must be between {0} and {1} characters")};m[type+"[release_year]"]={required:"Sorry, you must provide year"};m[type+"[release_month]"]={required:"Sorry, you must provide year"};m[type+"[isrc]"]={isrc:"ISRC must be of the format CC-XXX-YY-NNNNN"};return dic;};SC.isValidCreditCard=function(type,ccnum){if(type){type=type.toLowerCase();}else{return false;}
if(ccnum){ccnum=ccnum.split(/-| /g).join("");}else{return false;}
var re;if(type==="visa"){re=/^4(\d{12}|\d{15})$/;}else if(type==="mc"||type==="mastercard"){re=/^5[1-5]\d{14}$/;}else if(type==="discover"){re=/^6011\d{12}$/;}else if(type==="amex"||type==="american_express"){re=/^3[4,7]\d{13}$/;}else if(type==="diners"){re=/^3[0,6,8]\d{12}$/;}
if(!re.test(ccnum)){return false;}
var checksum=0;var i,l;for(i=(2-(ccnum.length%2)),l=ccnum.length;i<=l;i+=2){checksum+=parseInt(ccnum.charAt(i-1),10);}
for(i=(ccnum.length%2)+1,l=ccnum.length;i<=l;i+=2){var digit=parseInt(ccnum.charAt(i-1),10)*2;if(digit<10){checksum+=digit;}else{checksum+=(digit-9);}}
return(checksum%10)===0;};jQuery.validator.setDefaults({highlight:function(element,errorClass){var $element=$(element);if(!$element.is(':radio, :checkbox')){if(!$element.data('origBackgroundColor')){$element.data('origBackgroundColor',$element.css("backgroundColor"));}
$element.stop().animate({backgroundColor:SC.FORM_INVALID_COLOR},SC.FX_SLOW,"easeOutSine");}
$element.removeClass("valid").addClass(errorClass);},unhighlight:function(element,errorClass){var $element=$(element);if($element.data('origBackgroundColor')){$element.css({backgroundColor:$element.data('origBackgroundColor')});}
$element.removeClass(errorClass);},success:function(label,field){$(field).filter('input:not(:radio, :checkbox), textarea').addClass("valid").stop().css({backgroundColor:SC.FORM_VALID_COLOR});}});jQuery.validator.addMethod("validusername",function(value,element){return this.optional(element)||(/[a-z]/i).test(value);},"At least one letter please");jQuery.validator.addMethod("validpermalink",function(value,element){return this.optional(element)||(/^([a-z\d]+)([\-_][a-z\d]+)*$/).test(value);},"Please use only lower case letters and numbers. Type - (minus) or _ (underscore) to separate words");jQuery.validator.addMethod("isrc",function(value,element){return this.optional(element)||value.replace(/\W/g,"").length===12;},"ISRC must be of the format CC-XXX-YY-NNNNN");jQuery.validator.addMethod("ean",function(value,element){var length;return this.optional(element)||((length=value.replace(/\D/g,"").length)===12||length===13);},"EAN/UPC must be 12 or 13 digits long");jQuery.validator.addMethod("validcreditcard",function(value,element,params){var $typeElement=$(params[0]);var type=$typeElement.filter(':checked').val();if(!type){$typeElement.parents('form:first').validate().element(params[0]);}
return this.optional(element)||SC.isValidCreditCard(type,value);},"Please check your credit card number");jQuery.validator.addMethod("dependency",function(value,element,params){return this.optional(element)||$(params[0]).size()>0;},"Dependent element does not exist.");jQuery.validator.addMethod("nowhitespace",function(value,element){return this.optional(element)||(/^\S+$/i).test(value);},"No spaces or tabs please");jQuery.validator.addMethod("urlwithouthttp",function(value,element){return this.optional(element)||(/^((https?|ftp):\/\/)?(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i).test(value);},"please enter a valid url");jQuery.validator.addMethod("promotion",function(value,element,params){if(this.optional(element)){return"dependency-mismatch";}
var remoteUrl=params.remoteUrl();var previous=this.previousValue(element);if(!this.settings.messages[element.name]){this.settings.messages[element.name]={};}
this.settings.messages[element.name].remote=typeof previous.message==="function"?previous.message(value):previous.message;params=typeof params==="string"&&{url:params}||params;if(previous.old!==value){previous.old=value;var validator=this;this.startRequest(element);var data={};data[element.name]=value;$.ajax($.extend(true,{url:remoteUrl,mode:"abort",port:"validate"+element.name,data:data,success:function(response){var errors=params.errors(response);var valid=errors.length===0;if(valid){var submitted=validator.formSubmitted;validator.prepareElement(element);validator.formSubmitted=submitted;validator.successList.push(element);validator.showErrors();if(typeof params.valid==='function'){params.valid(response);}}else{var errorMessages={};errorMessages[element.name]=errors.join("\n");$(element).data('remoteErrors',errorMessages[element.name]);validator.showErrors(errorMessages);if(typeof params.invalid==='function'){params.invalid(response);}}
previous.valid=valid;validator.stopRequest(element,valid);}},params));return"pending";}else if(this.pending[element.name]){return"pending";}
return previous.valid;},function(params,element){return $(element).data('remoteErrors');});(function($){$.fn.typeahead=function(callerSettings){$(this.selector).live('click.typeahead',function(){var $input=$(this);$input.die('click.typeahead');var settings=$.extend({collection:'',filterPrefixString:'',defaultSearchText:$input.val(),delay:600,update:null},callerSettings||{});var callback=function($lists){if($.isFunction(settings.update)){settings.update.apply($input,[$lists]);}};var query,value,filterRx,updateTimeout,$collection=$(settings.collection).find('li'),$parent=$(settings.collection).closest('ul');$input.keyup(function(ev){value=$(ev.target).val().trim().toLowerCase();if(value!==query){query=value;filterRx=new RegExp(settings.filterPrefixString+query);clearTimeout(updateTimeout);updateTimeout=null;if(query.length===0){$collection.each(function(){this.className=this.className.replace(/\s*hidden\s*/g,'');});callback($collection);}else{updateTimeout=setTimeout(function(){$collection.not('.selected').each(function(){this.className=this.className.replace(/\s*hidden\s*/g,'');if(!filterRx.test(this.id)){this.className=this.className+" hidden";}});callback($collection);},settings.delay);}}}).click(function(){$input.keyup();this.select();}).focus(function(){this.value=(this.value===settings.defaultSearchText)?"":this.value;$input.removeClass('blank');}).blur(function(){if(this.value===""){$input.addClass('blank').val(settings.defaultSearchText);}}).focus();});return this;};})(jQuery);(function($){$.fn.capslock=function(){return this.keypress(function(ev){var which=ev.which||ev.keyCode||-1;var shift_status=false;if(ev.shiftKey){shift_status=ev.shiftKey;}else if(ev.modifiers){shift_status=!!(ev.modifiers&4);}
if(((which>=65&&which<=90)&&!shift_status)||((which>=97&&which<=122)&&shift_status)){$(this).addClass("capslock");}else{$(this).removeClass("capslock");}});};})(jQuery);(function($){var tickerId=null;var $body=$("body:first");var currentFrame=0;function tick(){if(tickerId===null){currentFrame=0;tickerId=setInterval(function(){$body.each(function(){this.className=this.className.replace(/frame\d+/g,'');}).addClass("frame"+((currentFrame+1)%16));currentFrame=currentFrame+1;},150);}}
function stopTick(){clearInterval(tickerId);tickerId=null;$body.each(function(){this.className=this.className.replace(/frame\d+/g,'');});}
jQuery.fn.throb=function(start){$(document).trigger(start?'throbberStart':'throbberStop');return this.each(function(){if(start){$(this).addClass("loading").blur().attr("disabled",true);}else{$(this).removeClass("loading").removeAttr("disabled");}});};$(document).bind('throbberStart',tick).bind('throbberStop onContentLoaded',stopTick);jQuery.fn.throbberform=function(){this.not('.throbberform').each(function(){var $form=$(this);$form.addClass('throbberform').submit(function(){$form.find("input:submit, button").throb(true);}).bind("invalid-form",function(){stopTick();$form.find("input:submit, input:reset, button, a.submit").throb(false);$('.error:first',$form).each(function(){$.scrollTo($(this).offset().top-40,{easing:'easeOutExpo',speed:SC.FX_MEDIUM,axis:'y'});});});});return this;};})(jQuery);$(function(){$('input:submit, input:reset, input:button, button, a.submit, a.user-action, #crop-button').live('click.throbber',function(ev){if(!$(ev.target).closest('form').hasClass('throbberform')&&ev.which===1){setTimeout(function(){$(ev.target).throb(true);},10);}});$('<div style="width: 200px;height: 300px;" class ="loading aural"></div>').appendTo($('body:first'));$("form").throbberform();});(function($){$.editableSC=function(node,callerSettings){var settings=$.extend({cssclass:'edit-field',enableReturns:false,maxLength:Infinity,placeholder:undefined,title:'Click to edit'},callerSettings||{});var $el=$(node);var togglePlaceholder=function(status){if(settings.placeholder&&!(/\S/).test($el.text())){$el.html('<span class="placeholder">'+settings.placeholder+'</span>');}};togglePlaceholder();$el.mousedown(function(){this.contentEditable=true;}).click(function(){$el.addClass(settings.cssclass).trigger('onEditStart');if(settings.placeholder&&$el.find('span.placeholder').size()){this.innerHTML='';}}).focus(function(){$el.trigger('onEditFocus');}).keydown(function(ev){if(ev.keyCode===13){$el.trigger('onEditEnter');if(!settings.enableReturns){ev.preventDefault();}}else if(ev.keyCode===27){$el.trigger('onEditEscape');}else{if(settings.maxLength<Infinity&&$el.text().trim().length>=settings.maxLength){ev.preventDefault();}}}).blur(function(){$el.removeClass(settings.cssclass).trigger('onEditBlur');togglePlaceholder();this.contentEditable=false;}).attr('title',settings.title);};$.editableSC.generateButtons=function(node){$.editableSC.removeButtons();var $node=$(node);var $buttons=$('<div class="form-buttons" id="editing-buttons"><div id="editing-buttons-inner"></div></div>').appendTo($('body:first'));var positionButtons=function(){$buttons.css({top:$node.offset().top+$node.height(),left:$node.offset().left+$node.width()-$buttons.width()});};$buttons.find("div").append('<input type="submit" value="Save changes" class ="default"/>').append('<a href="#cancel-editing" class="cancel">Cancel</a>');positionButtons();$('a.cancel',$buttons).bind('click',function(ev){$node.trigger('onEditCancel');ev.stopPropagation();return false;});$('input',$buttons).bind('click',function(ev){$node.trigger('onEditSubmit');ev.stopPropagation();return false;});$node.unbind('keyup.editableButtons').bind('keyup.editableButtons',function(){positionButtons();});$('body:first').live('click.editableButtons',function(ev){var $target=$(ev.target);var clickInside=$target.closest('.editable').size()>0||$target.closest('#editing-buttons').size()>0;if(!clickInside){$.editableSC.removeButtons();$node.trigger('onClickOutside');}});$(window).unbind('blur.editable').bind('blur.editable',function(){$.editableSC.removeButtons();});};$.editableSC.removeButtons=function(){$('body:first').die('click.editableButtons');$('#editing-buttons').remove();};$.fn.editableSC=function(callerSettings){return this.each(function(){$.editableSC(this,callerSettings);});};})(jQuery);var soundManager=window.soundManager;soundManager.debugMode=SC.DEBUG_MODE;soundManager.useHighPerformance=false;soundManager.flashLoadTimeout=0;soundManager.flashVersion=8;soundManager.url=SC.asset_url('/swf/');soundManager.useConsole=true;soundManager.defaultOptions.volume=Helpers.getVolume();SC.PlayerManager=Class.create();SC.PlayerManager.prototype={initialize:function(players){var self=this;self.players=[];self.soundManager=window.soundManager;self.activePlayer=null;self.soundManager.players=self.players;var initSM=function(status){if(!status.success){self.soundManager.reboot();}};self.soundManager.oninitmovie=function(e){$(document).trigger('onSoundManagerDOM');};self.soundManager.onload=function(){$(document).trigger('onSoundManagerLoad');self.add(players);if(/play/.test(location.hash)){self.playFirst();}};self.soundManager.onready(initSM);$(document).bind('onFinish',function(ev){if(self.isContinuous(ev.target)){self.playNext(ev.target);}});$(document).bind('beforeunload',this.soundManager.destruct,false);},add:function(players){var self=this;players.each(function(){self.players.push(new SC.Player(this,self));});},get:function(domId){var player=null;$(this.players).each(function(){if(this.player&&this.player.id===domId){player=this;return false;}});return player;},remove:function(removePlayers){var result=[];$.each(this.players,function(){if(jQuery.inArray(this.player,removePlayers)<0){result.push(this);}else{this.stop();}});this.players=result;},stopAll:function(pl){$(this.players).each(function(){if(this!==pl&&this.enabled){this.stop();}});},playFirst:function(){var self=this;if(self.players.length>0){for(var i=0;i<self.players.length;i+=1){if(typeof self.players[i]!=="undefined"){self.players[i].play();break;}}}},playNext:function(pl){var index=0;var pm=this;var players=pm.players;var current;var next;while(index<players.length){if(next&&pm.isContinuous(next.player)){next.play(1);return;}
if(players[index].player.id===pl.id){current=players[index];}
if(current){next=players[index+1];}
index+=1;}
$('div.pagination:first a.next').each(function(){window.location=this.href+'#play';return;});$('#overview-list a.show-more:first').each(function(){window.location.hash='play';$(this).click();$(document).one('onContentLoaded',function(ev){pm.playNext(pl);});return;});return;},isContinuous:function(node){var $player=$(node);return $player.parents('.set:first').exists()||($player.is('.medium')&&$player.is(':visible'));}};$(function(){var toggleFavorite=function($link){var status=$link.hasClass("create")?"Remove from favorites":"Save to favorites";$link.toggleClass("destroy").toggleClass("create").attr('title',status).find('span').html(status);return $link;};$('a.favorite').live('click',function(ev){if(ev.which===3){return false;}
var $link=$(this);var create=$link.hasClass("create");toggleFavorite($link);var $player=null;try{$player=Helpers.getPlayerNode($link);$('body#you.favorites').each(function(){Helpers.removePlayer($player,function(){$("#user-tabs a.favorites-count").increment(-1);});});$("#main-nav a.favorites-count").increment(create?1:-1);$player.trigger('onFavorite');}catch(error){}
$.scAjax({url:$link.attr('href'),type:create?'update':'destroy',callback:function(response,xhr,message){},error:function(){toggleFavorite($link);}});return false;});});(function($){var toggleContactLink=function($link,update){var newText=update?"Stop following":"Start following";$('a.contact-link').filter(function(){return this.href===$link[0].href;}).toggleClass('destroy',update).toggleClass('update',!update).html('<span>'+newText+'</span>').attr('title',newText).toggleClass('remove-contact',update).toggleClass('add-contact',!update);};$('a.contact-link').live('click',function(ev){if(ev.which===3){return false;}
var $link=$(this).closest('a');var update=$link.hasClass("update");toggleContactLink($link,update);$('body.current-user.contacts:first').each(function(){$link.parents("li:first").fadeOut('slow');$("#tabs li.current a, #users h1:first").increment(-1);});$.scAjax({url:$link.attr('href'),type:update?'update':'destroy',callback:function(response,xhr,message){var jsonResponse=Helpers.json(response);if(jsonResponse&&jsonResponse.notice){Helpers.notice(jsonResponse.notice);}},error:function(){toggleContactLink($link,!update);}});return false;});})(jQuery);(function($){var allUploaders=0;$.fn.uploader=function(customSettings){return this.each(function(){$.uploader(this,customSettings);});};$.uploader=function(button,customSettings){if($.flashVersion().major<9){return false;}
var $button=$(button);var uploaderId="scUploader"+allUploaders;var filesSelected=0;var positionOverlay=function(){var inline=$button.css('display')==='inline',width=inline?$button.outerWidth():$button.innerWidth(),height=inline?$button.outerHeight():$button.innerHeight();$('#container-'+uploaderId).css({position:'absolute',top:$button.offset().top,left:$button.is(':visible')?$button.offset().left:'-5000px',width:width,height:height,zIndex:750}).find('object:first').css({width:width,height:height});};var hideFlash=function(){$('#container-'+uploaderId).css('left','-5000px');};var settings=$.extend(true,{path:'/swf/Swiff.Uploader.swf?'+new Date().getTime(),debug:false,multiple:true,queued:true,queueAtOnce:false,typeFilter:null,method:'post',maxFileSize:Infinity,callBacks:{onLoad:function(){document.getElementById(uploaderId).register(uploaderId,settings.multiple,settings.queued,settings.queueAtOnce);},onError:function(){var errorType=arguments[1];var errorStatus=parseInt(arguments[2],10);if(errorStatus<200&&errorStatus>299){$.post('/errors/swfupload',$.extend($.flashVersion(),arguments[0]||{},{resource:String(window.location),user:SC.USER,current:SC.CURRENT_USER.permalink,error:errorType,message:errorStatus}));}},onBrowse:function(){return settings.typeFilter;},onAllSelect:function(files){if(files[0].size>settings.maxFileSize){document.getElementById(uploaderId).removeFile();Helpers.notice('The file is too big, it has to be less than '+Helpers.toMB(settings.maxFileSize)+'MB');}else{hideFlash();$(document).trigger('ajaxStart');$button.throb(true);}},onAllComplete:function(){$button.throb(false);$(document).trigger('throbberStop').trigger('onUploaderUpdate');},onMouseOver:function(){$button.addClass('hover');},onMouseOut:function(){$button.removeClass('hover');}}},customSettings||{});if(!settings.multiple){settings.queued=false;}
var callBacks=settings.callBacks||this;var prepare={},self=this;$.each(['onLoad','onBrowse','onSelect','onAllSelect','onCancel','onBeforeOpen','onOpen','onProgress','onComplete','onError','onAllComplete','onMouseOver','onMouseOut'],function(index,value){var fn=callBacks[value]||{};prepare[value]=function(){if(settings.debug){$.debug(value,settings,arguments);}
$button.trigger(value,[document.getElementById(uploaderId),arguments]);if($.isFunction(fn)){return fn.apply(self,arguments);}else{return null;}};});$.uploader.callBacks[uploaderId]=prepare;var flashvars={};$.each(prepare,function(index,value){flashvars[index]='$.uploader.callBacks.'+uploaderId+'.'+index;});$('<div id="container-'+uploaderId+'" ></div>').appendTo('body:first').get(0).innerHTML='<object width="100" height="120" type="application/x-shockwave-flash" id="'+uploaderId+'" data="'+settings.path+'"><param name="allowScriptAccess" value="always"/><param name="wMode" value="transparent"/><param name="swLiveConnect" value="true"/><param name="flashvars" value="'+Helpers.objToUrl(flashvars)+'"/><param value="'+settings.path+'" name="movie"/></object>';$(window).resize(positionOverlay).load(positionOverlay).bind("unload.upload",function(){try{document.getElementById(uploaderId).removeFile();}
catch(msg){}});$(document).bind('onUploaderUpdate onZoomClose onZoomDisplay onUrlChange onFormSizeChanged',positionOverlay).bind('onZoomDisplay',hideFlash).trigger('onUploaderUpdate');allUploaders=allUploaders+1;return uploaderId;};$.uploader.callBacks={};$.uploader.fileFilters={images:{"Gif, Jpeg, and Png images are supported":"*.jpg;*.gif;*.png;*.jpeg"},audio:{"Aiff, Wave, MP3, Ogg, Flac and AAC files are supported":"*.mp3;*.aiff;*.aif;*.wav;*.flac;*.fla;*.mp4;*.m4a;*.mp4a;*.aac;*.ogg;*.ogv;*.oga;*.ogx"}};})(jQuery);$(function(){var moveSeekhead=function(ev){var $display=$(this);var settings=$display.data('scrubber');if(!settings.offset||!settings.width){settings.width=$display.width();settings.offset=$display.offset().left;}
var relative=(ev.pageX||-1)-settings.offset;if(relative<0||relative>settings.progress.width()){settings.seekhead.hide();return;}else{settings.position=Math.round(settings.duration*(relative/settings.width));settings.timecode.text(Helpers.timecode(settings.position));settings.seekhead.css('left',relative).show();if(settings.scrubbing){Helpers.throttle(100,function(){settings.player.play(settings.position);})();}
return;}};$(document).bind('onPlay',function(ev){$('div.seekhead:first',ev.target).each(function(){var $display=$(this);var settings=$display.data('scrubber');if(!settings){$display.bind('mouseover mousemove',function(ev){moveSeekhead.apply(this,[ev]);}).mouseout(function(ev){if(ev.relatedTarget&&(/marker/).test(ev.relatedTarget.className)){return;}else{settings.seekhead.hide();}}).mouseleave(function(){settings.scrubbing=false;settings.seekhead.hide();}).mousedown(function(ev){settings.scrubbing=true;}).mouseup(function(ev){settings.scrubbing=false;}).click(function(ev){settings.player.seek(settings.position);}).removeClass('hidden').show();settings=$display.data('scrubber',{seekhead:$display.find('div:first').hide(),timecode:$display.find('span:first'),progress:$display.siblings('div.progress:first'),player:Helpers.getPlayer($display),duration:$display.parents('div.mode:first').metadata().trackDuration,position:0,scrubbing:false}).data('scrubber');}});});$('a.play').live('click',function(ev){Helpers.getPlayer(this).playPause();return false;});$('a.unheard').live('click',function(){var $link=$(this).throb(true);$.scAjax({url:this.href,type:'create',data:{"play[undisclosed]":"1"},callback:function(response){$link.throb(false).fadeOut(SC.FX_SLOW);}});return false;});$(document).bind('onPlay onFavorite',function(ev){$('a.unheard:first:visible',ev.target).fadeOutRemove();$('#unheard-title').attr('id','');});var waitForErrorTimeout;$(document).bind('onSoundManagerFail',function(){if(Helpers.getCookie('_hide-flash-block')==="true"){return;}
var showError=function(){if(SC.playerManager.soundManager.supported()){return;}
$.zoomable($('body:first'),{height:250,src:function(display){var sm=SC.playerManager.soundManager;var $error=$('<div id="flashblock-error"></div>');$error.append('<h2>Whoa! Flash content failed</h2>');$error.append('<p>"Don\'t hate the player, hate the game." We don\'t really know exactly why this happened but try reloading the page or check our update <a href="http://support.soundcloud.com/soundcloud/topics/flashblock_message_read_here" target="_blank">here</a> for more details. Sorry about that.</p>');$error.append($(sm.oMC).addClass('return-to-dom'));$error.append('<p class="checkbox"><input type="checkbox" id="hide-flash-block"/><label for="hide-flash-block">Don\'t show this message again</label></p>');display($error);}});clearTimeout(waitForErrorTimeout);waitForErrorTimeout=setTimeout(10000,showError);};$('#hide-flash-block').live('click',function(ev){Helpers.setCookie('_hide-flash-block',this.checked?"true":"false",{expires:365,path:'/'});});});$(document).bind('onSoundManagerLoad',function(){$('#flashblock-error').each(function(){var sm=SC.playerManager.soundManager;$.closeZoomScreen(function(){$(sm.oMC).addClass('aural').show();sm.reboot();});});});$(document).bind('onTrackProcessed',function(ev){$(ev.target).removeClass('processing').find('div.waveform-display-loading').fadeOut(1000);});$(document).bind('onPlay onStop onFinish onPause',function(ev){$('div.container:first, a.play',ev.target).toggleClass('playing',ev.type==='onPlay');});$('div.timecodes span.editable').live('click',function(){var $node=$(this);var player=Helpers.getPlayer($node);var totalTime=player.duration;var initial=$node.text();var setTimeValue=function(){var newTime=Math.min(Helpers.timeToMillis($node.text()),totalTime);player.play(newTime);return Helpers.timecode(newTime);};if(totalTime&&player.sound&&player.sound.loaded){$node.editableSC({cssclass:'time-edit'}).bind('onEditBlur onEditEnter',setTimeValue);}});$('#tracks, #playlists').filter('.show').each(function(){$(window).bind('keydown',function(event){if((/html/i).test(event.target.tagName)){if(event.keyCode===32){if(SC.playerManager.activePlayer){SC.playerManager.activePlayer.playPause();}else{SC.playerManager.playFirst();}
event.preventDefault();}else{}}});});});SC.Player=Class.create();SC.Player.prototype={RENDERING_FAILED:"<div class=\"background\"></div><div class=\"inner-content failed\"><div class=\"background\"></div><h4>Sorry, that track is too hot for us!</h4><p>Oh, damn! We couldn't create the waveform for your track. We're checking it right now and will try to fix it asap!</p></div>",initialize:function(playerEl,playerMgr){var self=this;self.player=playerEl;self.playerManager=playerMgr;if(playerEl.tagName.toLowerCase()==='div'){self.notLoaded=false;self.uri=null;self.initPlayerInDom();}else{self.notLoaded=true;self.uri=playerEl.href;}},initPlayerInDom:function(){var self=this;var $playerNode=$(self.player);self.playerId=self.player.id.split(/-/)[1];self.playerProperties=$playerNode.metadata();self.enabled=false;self.commentIds={};if(self.playerProperties){if(self.playerProperties.preprocessingReady){self._setUpPlayerProperties();self._initializeSound();}else{self._pingPlayerProperties();}}},_pingPlayerProperties:function(){var self=this;if(!$('#'+self.player.id).exists()){return;}
$.getJSON(this.playerProperties.propertiesUri,function(json){self.playerProperties=json;if(self.playerProperties.renderingFailed){$('div.waveform-display-loading:first',self.player).html(self.RENDERING_FAILED);}else{if(self.playerProperties.preprocessingReady){self._setUpPlayerProperties();$("span.duration:first",self.timecodes).text(Helpers.timecode(self.playerProperties.trackDuration));self.waveformDisplay.get(0).src=self.playerProperties.waveformUrl;self._initializeSound();$(self.player).trigger('onTrackProcessed');}else{setTimeout(function(){self._pingPlayerProperties();},15000);}}});},playPause:function(){if(this.playing){this.pause();}else{this.play();}},seek:function(pos){if(this.playing){this.play(pos);}else{this.sound.setPosition(pos);}},play:function(pos){var self=this;if(self.notLoaded){$(self.player).trigger('onPlayerLoadStart');$.scAjax({url:self.uri,type:'show',callback:function(response){var $response=$(response);$(self.player).replaceWith($response);self.player=$response[0];self.initPlayerInDom();self.notLoaded=false;self.play(1);$(self.player).trigger('onPlayerLoadEnd');}});return false;}else if(!self.playerProperties.preprocessingReady){Helpers.notice('Please wait, the track isn\'t ready yet');return false;}
if(this.sound){var options={volume:Helpers.getVolume()};this.playerManager.stopAll(this);if(!this.playing){this.playerPlayedMarker.removeClass('aural');}
if(typeof pos!=='undefined'){this.sound.stop();this.sound.play(options);this.sound.setPosition(Math.min(this.sound.durationEstimate,pos));}else{if(this.sound.playState===0&&(this.sound.position===0||this.sound.position===null)){this.sound.play(options);}else if(this.sound.position===this.sound.durationEstimate){this.sound.play(options);}else{this.sound.togglePause();this.sound.setVolume(Helpers.getVolume());}}
this.commentQueue=this.playerProperties.timestampedComments&&this.playerProperties.timestampedComments.slice();this.playerManager.activePlayer=this;this.playing=true;$(this.player).trigger('onPlay');}
return this;},pause:function(){this.sound.pause();this.playing=false;$(this.player).trigger('onPause');},stop:function(){if(this.sound){this.sound.stop();}
this.playing=false;$(this.player).trigger('onStop');},_stopAfterFinish:function(){this.playerPlayedMarker.addClass('aural');this.sound.setPosition(0);this.stop();$(this.player).trigger('onFinish');},_loadingProgress:function(){this.waveformDisplayLoaded.attr('style',['width: ',this.sound.duration*100/this.sound.durationEstimate,'%;'].join(''));},_showProgress:function(){var position=this.sound.position,positionNode=this.trackPosition[0],cq=this.commentQueue;if(positionNode&&!(/editing/).test(positionNode.className)){positionNode.innerHTML=Helpers.timecode(position);}
this.playerPlayedMarker.attr('style',['width: ',position*100/this.sound.durationEstimate,'%;'].join(''));if(this.showComments&&cq.length){if(position>cq[0].tc&&position<cq[0].tc+this.commentFadeOutTime){$(this.player).trigger('onTimedComment',[cq.shift().id]);}else if(position>cq[0].tc){while(cq[0]&&position>cq[0].tc){cq.shift();}}}},_setUpPlayerProperties:function(){this.trackDisplay=$('div.display:first',this.player);this.waveformDisplay=$('img.waveform:first',this.trackDisplay);this.waveformDisplayLoaded=$("<div class='progress'></div>").prependTo(this.trackDisplay);this.playerPlayedMarker=$('div.playhead:first',this.trackDisplay);this.playButton=$('a.play:first',this.player);this.timecodes=$('div.timecodes:first',this.player);this.trackPosition=$('span:first',this.timecodes);this.commentFadeOutTime=1000;this.playing=false;this.sound=null;this.duration=this.playerProperties.trackDuration;this.enabled=true;this.showComments=$(this.player).is('.medium, .large');this.commentQueue=[];$(this.player).data('metadata',this.playerProperties);},_initializeSound:function(){if(!this.sound){var self=this,pp=this.playerProperties,sm=self.playerManager.soundManager,delay=SC.SLOW?1000:250,initSMSound=function(){sm.createSound({id:'player-'+self.playerId,url:SC.media_url('/stream/'+pp.uid+'?stream_token='+pp.token+(SC.SECRET_TOKEN?'&secret_token='+SC.SECRET_TOKEN:'')),onfinish:function(){self._stopAfterFinish();},whileloading:Helpers.throttle(delay,function(){self._loadingProgress();}),whileplaying:Helpers.throttle(delay,function(){self._showProgress();})});self.sound=sm.getSoundById('player-'+self.playerId);};initSMSound();}}};$(function(){var defaultCommentText=$('div.timed-comment-form textarea:first').val();var seekheadIndex=parseInt($('div.seekhead:first').css('z-index'),10);var $commentBody=function(child){return $(child).parents('li.timestamped-comment:first').find('div.timestamped-comment-inner:first');};var getCommentId=function(child){var rx=/comment-(\d+)/;var item=$(child).closest('li')[0];return item&&item.id&&rx.test(item.id)?item.id.match(rx)[1]:null;};var hideTimedComment=function(child,ms){var wait=ms||500;$commentBody(child).delay(wait,function(){$(this).filter(':not(.persist)').hide().parents('ol.timestamped-comments:first').css('z-index',seekheadIndex-100).trigger('onTimedCommentHide');});};var showTimedComment=function(child,persist){var $body=$commentBody(child);var $commentMainNode=$body.parents('li:first');var $allComments=$('> li',$commentMainNode.parent());var busy=$allComments.filter('.create').exists()||$body.hasClass('persist');if(!busy){$allComments.not('.template').css('z-index','1000').end().find('div.timestamped-comment-inner').removeClass('persist').addClass('aural');$commentMainNode.css('z-index','1010').trigger('onTimedCommentShow');$body.removeClass('aural').stop(true).show().find('div.content:first').css({left:parseInt($commentMainNode.css('left'),10)/100*-325});$commentMainNode.find('div.tooltip:first').hide();if(persist){$body.toggleClass('persist');$body.toggle($body.hasClass('persist'));}
$body.not('.inited').addClass('inited').unbind('mouseenter mouseleave').bind('mouseenter',function(ev){showTimedComment(this);}).bind('mouseleave',function(){hideTimedComment(this);});}
$commentMainNode.parents('ol.timestamped-comments').css('z-index',seekheadIndex+100);};var activateReplyForm=function(form){$(form).not('.activated').addClass('activated').bind('submit',function(){$(this).find('input:submit').throb(true).end().ajaxSubmit({resetForm:true,beforeSubmit:function(fields,form){var commentText=$('textarea',form).val();if(commentText!==defaultCommentText&&$.isNotBlank(commentText)){return true;}else{$(form).trigger('invalid');return false;}
return false;},success:function(response,status,form){var $res=$(response);var $comment=$(form).parents('li:first');$comment.removeClass('create').find('div.timestamped-comment-inner:first').removeClass('persist').end().find('div.replies:first ol:first').append($res.find('.for-player:first').html()).end().find('input:submit').attr('value','Reply').throb(false).end().find('div.replies input').show().end().find('div.marker:first, div.replies:first').show().end().find('div.timed-comment-form:first').hide();$('#comments-list').prepend($res.find('.for-list:first').html());$comment.parents('div.player:first').trigger('onTimedCommentCreate');}});return false;});};var showReplyForm=function(child,id){showTimedComment(child,true);return $commentBody(child).show().removeClass('aural').addClass('persist').parents('li:first').addClass('create').end().find('div.timed-comment-form:first').slideDown(SC.FX_MEDIUM,function(){var $area=$('textarea:first',this).autogrow();$('a.user-image-tiny',this).css({backgroundImage:SC.CURRENT_USER.avatarTiny?'url('+SC.CURRENT_USER.avatarTiny+')':''}).attr('href',SC.CURRENT_USER.permalink||'/');$('input[name*=parent_id]',this).val(getCommentId($(this).parents('li').find('li:first')));if(id>0){$area.val(Helpers.getCommentPrefix($('#timestamped-comment-'+id)));Helpers.setCaretToEnd($area);}else{setTimeout(function(){$area.selectNow();},150);}}).find('form:first').each(function(){activateReplyForm(this);});};$('li.timestamped-comment div.marker').live('click',function(ev){var pos=Helpers.timeToMillis($(this).parents('li:first').find('span.time').text());Helpers.getPlayer(this).play(pos);return false;});$('li.timestamped-comment div.marker a').live('click',function(){showTimedComment(this,true);return false;});$('li.timestamped-comment div.marker').liveDelegate('mouseover',function(){showTimedComment(this);}).liveDelegate('mouseout',function(){hideTimedComment(this);});$(document).bind('onTimedCommentShow onTimedCommentHide',function(event){});$(document).bind('onTimedComment',function(ev,id){var $comment=$('#timestamped-comment-'+id);showTimedComment($comment);hideTimedComment($comment,5000);});$('li input.reply').live('click',function(){$(this).throb(false).hide();showReplyForm(this,getCommentId($commentBody(this).find('li:last')));return false;});$('div.timed-comment-form textarea').live('keypress',function(ev){if(ev.keyCode===SC.ENTER_KEY){$(this).parents('form:first').submit();ev.preventDefault();return false;}else if(ev.keyCode===SC.ESCAPE_KEY){$(this).parents('li:first').find('a.close:first').click();}});var activateTooltip=function(list){var $list=$(list);var settings=$list.data('tc');if($('li.create',$list).exists()||!$('li.template',$list).exists()){return;}
if(!settings){$list.data('tc',{template:$list.find('li.template:first').clone(true).removeClass('aural').removeClass('template').addClass('hover').addClass('first').find('div.replies:first').hide().find('li').remove().end().end().find('div.marker:first').hide().end().find('div.timestamped-comment-inner:first').removeClass('aural').end().find('div.tooltip:first').show().removeClass('hidden').end().find('input:submit').val('Post').end().find('input[name*=parent_id]').remove().end(),position:0,duration:parseInt($list.parents('div.mode:first').metadata().trackDuration,10),width:$list.width(),offset:$list.offset().left});settings=$list.data('tc');$(window).resize(function(){$list.data('tc',$.extend(settings,{width:$list.width()}));});}
var $newComment=settings.template.clone(true).hide().appendTo($list).delay(500,function(){$(this).show();});var $commentContent=$newComment.find('div.content:first');var timeHeader=$newComment.find('div.header span:first');var timeTooltip=$newComment.find('div.tooltip:first span:first');$list.unbind('mousemove mouseout mousedown').mousemove(function(ev,songPosition){if(ev.target===this){var relative;if(songPosition){relative=songPosition/settings.duration;settings.position=songPosition;}else{relative=(ev.pageX-settings.offset)/settings.width;settings.position=settings.duration*relative;}
var timecode=Helpers.timecode(settings.position);timeHeader.text(timecode);timeTooltip.text(timecode);$commentContent.attr('style',['left: ',relative*-60,'px;'].join(''));$newComment.css('left',relative*100+'%');ev.stopPropagation();}}).mouseout(function(ev){$newComment.remove();}).mousedown(function(ev){if(this===ev.target){$newComment.parents('ol.timestamped-comments:first').unbind('mousemove mouseout mousedown');$newComment.removeClass('hover').find('div.form-header:first span:first').text(Helpers.timecode(settings.position));showReplyForm(timeTooltip,0).find('input[name*=timestamp]').val(settings.position);}});return;};$('ol.timestamped-comments').liveDelegate('mouseover',function(event){activateTooltip(this);});$('li.timestamped-comment a.close, div.timed-comment-form a.cancel').live('click',function(ev){var $mainCommentNode=$(ev.target).parents('li.timestamped-comment:first');if($mainCommentNode.find('ol li').size()===0){$(this).parents('li.timestamped-comment:first').remove();}else{$commentBody(this).removeClass('persist first').hide().parents('li:first').removeClass('create').end().find('div.timed-comment-form:first').hide().end().find('div.replies input').throb(false).show();}
return false;});$('li.comment a.remove, div.comment-header a.remove').live('click',function(){var $link=$(this).blur();$commentBody($link).addClass('persist');$.dialog($link,{headline:"Do you really want to remove this comment?",ok:function(){$.dialogRemove();var commentId=getCommentId($link);var $comment=$('#comment-'+commentId).fadeOutRemove();var $tcomment=$('#timestamped-comment-'+commentId);if($tcomment.exists()){$tcomment.closest('div.player').trigger('onTimedCommentRemove');if($tcomment.siblings('li').exists()){$tcomment.slideUp(SC.FX_MEDIUM,function(){$tcomment.remove();});}else{$tcomment.parents('li:first').remove();}}else{$comment.trigger('onRegularCommentRemove');}
$.scAjax({url:$link.attr('href'),type:'destroy',accept:'soundcloud/json',callback:function(response){Helpers.notice("The comment has been deleted");}});},cancel:function(){$.dialogRemove();$commentBody($link).removeClass('persist');}});return false;});$("#no-timestamp-comment-form").ajaxForm({resetForm:true,beforeSubmit:Helpers.formValidator(function(){return($("#no-timestamp-comment-form textarea").val().trim()!=="");}),success:function(responseText){$("#comments-list").prepend($(responseText).find(".for-list:first").html());var c=$($("#comments-list").children().get(0));c.hide().slideDown("slow");$("#no-timestamp-comment-form").find('input.loading').throb(false);setTimeout(function(){SC.playerManager.add($("div.mini",c).parent());},0);$(document).trigger('onRegularCommentCreate');}}).find('textarea').autogrow().end();$('a.comments-toggle').live('click',function(){var $link=$(this);var $player=$link.parents('div.player:first').toggleClass('no-comments');var text=$player.hasClass('no-comments')?'Show the comments':'Hide the comments';$link.attr('title',text).text(text);return false;});$(document).bind('onTimedCommentCreate onTimedCommentRemove onRegularCommentCreate onRegularCommentRemove',function(ev){var delta=/create/i.test(ev.type)?1:-1;var isTimed=/timed/i.test(ev.type);var ownTrackComment=$(ev.target).metadata()&&$(ev.target).metadata().userName===SC.CURRENT_USER.permalink;if(isTimed){$('span.timed-count:first').increment(delta);$('a.stats:first .comments',ev.target).increment(delta);}else{$("span.regular-count").increment(delta);}
$("h3.comment-count dfn").increment(delta);$('td.comments:first').filter(function(){return ownTrackComment||$('#overview').length===0;}).siblings().increment(delta);$('#comments-list-headers').slideDown();$("#comments-list").show();$('#comments-list li').actionIntent();});$('body#tracks.show').each(function(){$('#comments-list a.go-to-comment').live('click',function(){showTimedComment($('#timestamped-comment-'+getCommentId(this)));$.scrollTo($('#main-content-inner'),{speed:SC.FX_SLOW,easing:'easeOutExpo'});return false;});$('#comments-list li.comment a.reply').live('click',function(){var id=getCommentId(this);var $comment=$(this).closest('li');var $tcomment=$('#timestamped-comment-'+id);if($tcomment.exists()){showTimedComment($tcomment);showReplyForm($tcomment,getCommentId($tcomment));$.scrollTo($('#main-content-inner'),{speed:SC.FX_SLOW,easing:'easeOutExpo'});}else{$('#comment_parent_id').val(id);$('#comment_body').val(Helpers.getCommentPrefix($('#comment-'+id)));$.scrollTo($('h3.comment-add-header:first'),{speed:SC.FX_SLOW,easing:'easeOutExpo',onAfter:function(){Helpers.setCaretToEnd($("#comment_body"));}});}
return false;});var checkDeepLink=function(){var commentRx=/comment-(\d+)/,newCommentRx=/new-timed-comment-at-(\d+)/,loc=window.location,hash=loc.hash,commentId=loc.pathname.match(commentRx)&&loc.pathname.match(commentRx)[1],$nc=commentId&&$('#comment-'+commentId);if(/reply/.test(hash)){if($('body.restricted:first').exists()){$(document).trigger('onActionPrevented');return;}else if($nc.exists()){$nc.find('a.reply').click();return;}else{Helpers.notice('the linked comment was removed');return;}}else if(hash.match(newCommentRx)){if($('body.restricted:first').exists()){$(window).load(function(){$(document).trigger('onActionPrevented');});return;}else{var timecode=parseInt(hash.match(newCommentRx)[1],10);$('ol.timestamped-comments:first').trigger('mouseover').trigger('mousemove',[timecode]).trigger('mousedown');}}else if($nc){$nc.each(function(){if($nc.find('a.go-to-comment:first').exists()){$nc.find('a.go-to-comment:first').click();}else{$.scrollTo($nc,{easing:'easeOutExpo',speed:SC.FX_SLOW,axis:'y'});}});return;}else{return;}};checkDeepLink();});var addRemoveButtons=function(players){if(!SC.CURRENT_USER){return;}
var userRx=new RegExp(SC.CURRENT_USER.permalink+'$');$('li.timestamped-comment a.user-name',players).filter(function(){return userRx.test(this.href)||userRx.test($(this).parents('.player').metadata().userName);}).each(function(){var $node=$(this).parents('.comment-header');$node.find('a.remove').remove().end().prepend('<a class="remove" href="'+$node.metadata().permalink+'">Remove</a>');});};if($('div.player:first').exists()){addRemoveButtons($('div.player'));}
$(document).bind('onTimedCommentCreate onPlayerLoadEnd onContentLoaded',function(ev){addRemoveButtons(ev.target);});});(function($){$.fn.editableField=function(callerSettings){return this.each(function(){var $node=$(this);var original=$node.text();var settings=$.extend({path:'/no-path-set',name:'/no-field-name-set',title:'Click here to change the title'},callerSettings||{});var dataObj={};$node.editableSC({title:settings.title,maxLength:settings.maxLength||Infinity}).bind('onEditStart',function(ev){$.editableSC.generateButtons(ev.target);}).bind('onEditEnter onEditSubmit',function(ev){var $node=$(this);$node.blur();$.editableSC.removeButtons();original=Helpers.cleanScripts($node.text().trim());dataObj[settings.name]=original;$.scAjax({url:settings.path,type:'update',headers:'text/javascript',data:dataObj,async:false});}).bind('onEditCancel onEditEscape onClickOutside',function(ev){$node.blur().text(original);$.editableSC.removeButtons();});});};$.fn.editableDescription=function(callerSettings){return this.each(function(){var $node=$(this);var settings=$.extend({name:null,path:null,minHeight:150,placeholder:'Click here to write a description'},callerSettings||{});var dataObj={};var originalHtml;$node.editableSC({enableReturns:true,cssclass:'active',placeholder:settings.placeholder}).bind('onEditStart',function(ev){originalHtml=$node.html();$node.find('p').each(function(){this.innerHTML=this.innerHTML.replace(/</gm,"&lt;").replace(/>/gm,"&gt;").replace(/\s\s+/gm,' ');this.innerHTML=this.innerHTML.replace(/&lt;br\s?\/?&gt;/gm,'<br>');});$.editableSC.generateButtons(ev.target);}).bind('onEditBlur',function(ev){$node.find('p').each(function(){this.innerHTML=this.innerHTML.replace(/&lt;/gm,"<").replace(/&gt;/gm,">");});}).bind('onEditSubmit',function(ev){var html=($node.text().trim()===settings.placeholder)?"":$node.html();$node.blur();$.editableSC.removeButtons();originalHtml=Helpers.cleanScripts(html.replace(new RegExp('<br\\s?\/?>','mig'),'\n').replace(new RegExp('<p>','mig'),'').replace(new RegExp('<\/p>','mig'),'\n\n'));dataObj[settings.name]=originalHtml;$.scAjax({url:settings.path,type:'update',headers:'text/javascript',data:dataObj,async:false});}).bind('onEditEscape onEditCancel',function(ev){$node.blur().html(originalHtml);$.editableSC.removeButtons();});});};})(jQuery);(function($){$.scAjax=function(callerSettings){var settings=$.extend({url:undefined,type:'show',data:{},async:true,accept:'application/json, text/javascript, soundcloud/json',callback:null,error:null},callerSettings||{});var showErrors=true;$(document).bind('onBeforeUnload',function(){showErrors=false;});var allMethods={show:'GET',update:'PUT',destroy:'DELETE',create:'POST'};var method=allMethods[settings.type];if(method==='PUT'||method==='DELETE'){settings.data._method=method;method=allMethods.create;}
return $.ajax({url:settings.url,type:method,data:settings.data,complete:function(xhr,message){if(xhr.status<400&&$.isFunction(settings.callback)){settings.callback(xhr.responseText||xhr.responseXML,xhr,message);}},error:function(XMLHttpRequest,textStatus,errorThrown){if(showErrors){Helpers.notice("Oops, something went wrong, please try again or reload this page.");if($.isFunction(settings.error)){settings.error(XMLHttpRequest,textStatus,errorThrown);}}},beforeSend:function(xhr){xhr.setRequestHeader('Accept',settings.accept);}});};})(jQuery);$(function(){$("#show-feedback-form, a.feedback").live('click',function(ev){var protocol=document.location.protocol,href=$(this).attr('href'),timeout=setTimeout(function(){window.location=href;},5000);$('#gsfn-container').remove();$.getScript(protocol+'//s3.amazonaws.com/getsatisfaction.com/javascripts/feedback-v2.js',function(){clearTimeout(timeout);timeout=null;var feedback_widget_options={};feedback_widget_options.display="overlay";feedback_widget_options.company="soundcloud";feedback_widget_options.placement="left";feedback_widget_options.color="#222";feedback_widget_options.style="idea";feedback_widget_options.container=$('<div id="gsfn-container"></div>').appendTo('body:first')[0].id;GSFN.feedback_widget.prototype.local_base_url="http://support.soundcloud.com";GSFN.feedback_widget.prototype.local_ssl_base_url="http://support.soundcloud.com";var feedback_widget=new GSFN.feedback_widget(feedback_widget_options);feedback_widget.show();});return false;});});(function($){jQuery.fn.fadeOutRemove=function(){return this.each(function(){$(this).fadeOut(SC.FX_FAST,function(){$(this).remove();});});};jQuery.fn.scrollLink=function(callerSettings){return this.each(function(){var settings=$.extend({speed:SC.FX_MEDIUM,target:this.href.match(/#.*/)[0]},callerSettings||{});$(this).click(function(){$.scrollTo(settings.target,{easing:'easeOutExpo',speed:settings.speed,axis:'y'});return false;});});};})(jQuery);(function($){$.fn.tapper=function(callback){var self=this,samples=[],t_reset=null,t_down=null,t_post=null;var $a=$('span.bpm-tapper',self).css({'-moz-user-select':'none','-khtml-user-select':'none'}),$bpm=$('span.bpm-value',self),average=parseFloat($bpm.text());$a.each(function(){$bpm.not('.active').click(function(){$a.fadeIn('fast');$bpm.attr('title','').addClass('active').editableSC().bind('onEditBlur onEditEnter',function(){var value=$bpm.text();$bpm.text(isNaN(parseFloat(value,10))?"":value);callback($bpm.text());});});}).click(function(){return false;}).mousedown(function(){samples.push(new Date());$a.addClass('tap-down');samples=samples.slice(-20);var beats=samples.length-1;if(beats>0){var bpm=60000*beats/(samples[beats]-samples[0]);average=parseFloat(bpm.toFixed(1));$bpm.text(average);}
return false;}).mouseup(function(){clearTimeout(t_down);t_down=setTimeout(function(){$a.removeClass('tap-down');},50);clearTimeout(t_post);t_post=setTimeout(function(){callback(average);},2000);clearTimeout(t_reset);t_reset=setTimeout(function(){samples.splice(0);},3000);return false;});return this;};})(jQuery);(function($){var customEventType='click.dialog';$.dialogRemove=function($dialog){$('#dialog-screen').each(function(){$(this).remove();$(document).trigger('onDialogRemoved');});$(document).unbind(customEventType);};$.dialog=function(scope,callerSettings,ev){var $scope=$(scope);var settings=$.extend({headline:null,copy:null,eventTrigger:customEventType,ok:null,cancel:null,center:false,buttons:true,throb:false,okLabel:'Yes',cancelLabel:'Cancel',specialClass:'dialog',extraContent:null},callerSettings||{});$.dialogRemove();$scope.blur();var $dialog=$('<div id="dialog-screen"><div class="content-wrapper"></div><span class="close" title="Close">Close</span>').appendTo($('body:first'));var $content=$dialog.find('.content-wrapper:first');var $arrow=$('<div id="dialog-screen-arrow"></div>').appendTo($dialog);setTimeout(function(){$dialog.addClass(settings.specialClass);if(settings.headline){$content.append('<h4>'+settings.headline+'</h4>');}
if(settings.copy){$content.append((typeof settings.copy!=='string')?$(settings.copy):$('<p class="content">'+settings.copy+'</p>'));}
if(settings.buttons){$content.append('<div class="form-buttons"><a href="#ok" class="user-action tiny submit">'+settings.okLabel+'</a><a href="#" class="cancel">'+settings.cancelLabel+'</a></div>').find('a.user-action').click(function(){if($.isFunction(settings.ok)){$(this).throb(true);if(settings.throb){$scope.throb(true);}
settings.ok.apply($scope,[$dialog]);}else{$.dialogRemove($scope);}
return false;}).bind('keypress',function(ev){if(ev.keyCode===13){$(this).trigger('click');return false;}}).end().find('a.cancel').click(function(){if($.isFunction(settings.cancel)){settings.cancel.apply($scope,[$dialog]);}else{$.dialogRemove($scope);}
return false;});}
if(settings.extraContent){$content.append(settings.extraContent);}
$scope.parents('.action-buttons:first').removeClass('ok-to-hide').each(function(){var $actions=$(this);$(document).one('onDialogRemoved',function(){$actions.hide();});});function positionDialog(){var dialogOffset=7;var originX=(settings.center||!ev)?$scope.offset().left:ev.pageX;var originY=$scope.offset().top;var arrowHeight=$arrow.height();var arrowWidth=$arrow.width();var xPosNormal=originX-parseInt($arrow.css('left'),10)-Math.ceil($arrow.width()/2)+(settings.center?$scope.outerWidth()/2:0);var xPosFlip=originX-$dialog.innerWidth()+parseInt($arrow.css('left'),10)+dialogOffset;var yPosNormal=originY+arrowHeight+dialogOffset+(parseInt($scope.css('height'),10)||$scope.innerHeight());var yPosFlip=originY-$dialog.innerHeight()-arrowHeight-dialogOffset;var flipY=(yPosNormal+$dialog.innerHeight()>=(window.innerHeight||$(window).height())+$(document).scrollTop());var flipX=(xPosNormal+$dialog.innerWidth()>$(document).width());$dialog.css({top:flipY?yPosFlip:yPosNormal,left:flipX?xPosFlip:xPosNormal});$arrow.addClass((flipY?'bottom':'top')+'-'+(flipX?'right':'left'));}
$(document).bind(customEventType,function(ev){if($(ev.target).parents('#dialog-screen').exists()||ev.target.id==="dialog-screen"||$('#zoom-screen').is(':visible')){return;}else{$.dialogRemove($scope);}});var resizeTimer=null;$(window).bind('resize',function(){if(resizeTimer){clearTimeout(resizeTimer);}
resizeTimer=setTimeout(positionDialog,100);});positionDialog();$dialog.show();setTimeout(function(){$content.find('a.user-action:first, :button:first').eq(0).focus();},100);$(document).trigger('open.dialog');},10);return $dialog;};$.fn.dialog=function(callerSettings){return this.each(function(){var eventType=callerSettings.eventTrigger||customEventType;$(this).unbind(eventType).bind(eventType,function(ev){$.dialog($(this),callerSettings,ev);return false;});});};})(jQuery);(function($){var customEventType='click.pulldown';$.pulldownHide=function(){var $pulldown=$('body:first > .pulldown').hide();$('a.pulldown-active, div.pulldown-active').removeClass('active pulldown-active').after($pulldown);$(document).unbind(customEventType).trigger('onPulldownClose');};$.pulldown=function(scope,callerSettings){var $scope=$(scope);var settings=$.extend({node:$scope.siblings(".pulldown:first"),callback:null,align:'left'},callerSettings||{});$.pulldownHide();if($scope.hasClass('pulldown-active')){return false;}
setTimeout(function(){var $pulldown=settings.node.addClass('pulldown').appendTo(document.body);var left=$scope.offset().left+1;if(settings.align==='right'){left+=$scope.innerWidth();left-=$pulldown.innerWidth();}
$pulldown.css({position:'absolute',top:$scope.offset().top+$scope.innerHeight(),left:left,zIndex:700});$scope.addClass('active pulldown-active');if($.isFunction(settings.callback)){settings.callback.apply($scope,[$pulldown]);}
$pulldown.show();$(document).bind(customEventType,function(ev){if($(ev.target).parents('.pulldown').exists()||$(ev.target).hasClass('pulldown')||$('#zoom-screen').is(':visible')){return;}else{$.pulldownHide();}}).trigger('onPulldownOpen');},10);};$.fn.pulldown=function(callerSettings){return this.click(function(){$.pulldown(this,callerSettings);return false;});};})(jQuery);(function($){var customEventType='click.zoom';$.closeZoomScreen=function(callback){$('#zoom-screen .return-to-dom:first').hide().removeClass('return-to-dom').appendTo('body:first');$('#zoom-screen').remove();$('body:first').unbind(customEventType);$(document).trigger('onZoomClose');if($.isFunction(callback)){callback();}};$.zoomable=function(ev,callerSettings){var $scope=$(ev.target||ev);var settings=$.extend({src:$.zoomable.content.id,width:400,height:300,offsetDefault:28,showCloseButton:true,closeButton:'<span id="zoom-screen-close">Close</span>',eventTrigger:customEventType,beforeDisplay:function(data){return data;},callback:function(){},beforeClose:null},callerSettings||{});var windowWidth=$(document).width();var windowHeight=window.innerHeight||$(window).height();$.closeZoomScreen();var $zoomContainer=$('<div id="zoom-screen"><div id="zoom-screen-loader"></div></div>').appendTo('body').hide();var $closeButton=$(settings.closeButton).prependTo($zoomContainer).hide();var $loader=$('<div id="zoom-content-wrapper"></div>').appendTo($zoomContainer).hide();var checkAndClose=function(evt){if($.isFunction(settings.beforeClose)){settings.beforeClose.apply($scope,[$loader,evt]);}else{$.closeZoomScreen();}};$('body:first').bind('click.zoom',function(ev){if(Helpers.isNormalClick(ev)){var $target=$(ev.target);var clickedOutside=!($target.parents('#zoom-screen').size()>0||$target.attr('id')==='zoom-screen');var clickedOnClose=($target.attr('id')===$closeButton.attr('id')&&$closeButton.attr('id'));var clickedOnCancel=$target.hasClass('cancel');if((clickedOnClose||clickedOutside||clickedOnCancel)&&$zoomContainer.is(':visible')){checkAndClose();return!(clickedOnClose||clickedOnCancel);}}});$zoomContainer.keydown(function(ev){if(ev.keyCode===27){checkAndClose();return false;}});var displayFinal=function(content,width,height){var widthFinal=(width||settings.width);var heightFinal=(height||settings.height);$loader.append($(settings.beforeDisplay(content)).show());$zoomContainer.animate({width:widthFinal,height:heightFinal,top:Math.max(((windowHeight-heightFinal)/2)+$(document).scrollTop(),0),left:(windowWidth-widthFinal-settings.offsetDefault)/2},SC.FX_MEDIUM,"easeInOutExpo",function(){$('#zoom-screen-loader').hide();if(settings.showCloseButton){$closeButton.fadeIn("fast");}
$closeButton.add('a.cancel',$loader).click(function(ev){checkAndClose(ev);return false;});if($loader.find('object,embed').exists()){$loader.show();settings.callback.apply($scope,[$loader]);}else{$loader.fadeIn('slow',function(){settings.callback.apply($scope,[$loader]);});}
$(this).css({marginLeft:0-((widthFinal+settings.offsetDefault)/2),left:'50%'});});$(document).trigger('onZoomDisplay');};$zoomContainer.show().css({left:ev.pageX||$scope.offset().left,top:ev.pageY||$scope.offset().top,width:0,height:0,opacity:0}).animate({opacity:1,width:settings.width,height:settings.height,top:Math.max(((windowHeight-settings.height)/2)+$(document).scrollTop(),0),left:(windowWidth-settings.width-settings.offsetDefault)/2},SC.FX_SLOW,"easeInOutExpo",function(){$(this).css({filter:''});if($.isFunction(settings.src)){settings.src.apply($scope,[displayFinal]);}});};var getHref=function(node){return $(node).closest('a')[0].href;};var getIdFromHash=function(node){var hash=getHref(node).match(/#(.*)/);if(hash){return hash[1];}else{console.error('No url hash could be extracted from this node',node);return false;}};$.zoomable.content={dom:function(domNode,callback){var $node=$(domNode).addClass('return-to-dom');var width=$node.width()||parseInt($node.css('width'),10);var height=$node.height()||parseInt($node.css('height'),10);callback($node,width,height);},id:function(callback){var id=getIdFromHash(this);if(id){$.zoomable.content.dom(document.getElementById(getIdFromHash(this)),callback);}},image:function(callback){var img=new Image();img.onload=function(){$(img).bind('click',function(ev){$.closeZoomScreen();});callback(img,img.width,img.height);};img.src=getHref(this);},json:function(callback){$.getJSON(getHref(this),function(data){callback(data);});},loadHtml:function(callback){$('<div class="zoom-html-load-container"></div>').load(getHref(this),function(){callback(this.innerHTML);});}};$.fn.zoomable=function(callerSettings){return this.each(function(){$(this).unbind(customEventType).bind(customEventType,function(ev){$.zoomable(ev,callerSettings);return false;});});};})(jQuery);(function($){var updateAvatars=function(badgeHeight,columns,badgesPerPage){var offset=(Math.ceil($(this).scrollTop()/badgeHeight)*columns);$('li',this).not('.hidden').each(function(index){if(!(/loaded/).test(this.className)&&index>=offset){$(this).addClass('loaded').find('a.icon-path:first').each(function(){$(this).css({backgroundImage:['url(',this.href,')'].join('')});});}
if(index>offset+badgesPerPage){return false;}});};$.fn.lazyAvatars=function(callerSettings){var settings=$.extend({columns:2,badgeHeight:21,badgesPerPage:38},callerSettings||{});var thisPlugin=arguments.callee,selector=this.selector,offset;var refreshTimeout;var refresh=function(selection){refreshTimeout=setTimeout(function(){$(selection).each(function(){updateAvatars.apply(this,[settings.badgeHeight,settings.columns,settings.badgesPerPage]);refreshTimeout=null;});},10);};var init=function(){var $list=$(selector);$list.unbind('scroll').scroll(function(ev){refresh(this);});refresh($list);};init();$(document).bind('onContentLoaded onListUpdated',init);return this;};})(jQuery);(function($){$.replaceLink=function(link,callerSettings){var $link=$(link);if($link.size()===0){return false;}
var settings=$.extend({target:$link,url:$link.attr('href'),delay:0,callback:null},callerSettings||{});var loadAndreplace=function(){$.scAjax({url:settings.url,type:'show',callback:function(response){$(settings.target).after(response).throb(false).remove();if($.isFunction(settings.callback)){settings.callback();}
$(document).trigger('onContentLoaded');}});};if(settings.delay){setTimeout(loadAndreplace,settings.delay);}else{loadAndreplace();}
return true;};$.fn.replaceLink=function(){return this.live('click',function(){$.replaceLink(this);});};})(jQuery);(function($){$.fn.liveDelegate=function(eventType,callback,callerSettings){var $nodes=this,settings=$.extend({observer:$nodes.parents('body:first'),bindAlways:false},callerSettings||{});try{var classRx=new RegExp($nodes.selector.split(/\s/).reverse()[0].match(/\.([\w\-]+)/)[1]);}catch(e){console.log('This plugin needs a class selector on last/before last specific node, like $("div:first a.play") or $("div:first a.play span")');}
function activate(){settings.observer.bind(eventType,function(event){if(classRx.test([event.target.className,event.target.parentNode.className])){callback.apply(event.target,[event]);}});}
if(settings.bindAlways){activate();}else{$nodes.eq(0).each(activate);}
return $nodes;};})(jQuery);$(function(){$.fn.liveautoselect=function(){return this.die('click.autoselect').live('click.autoselect',function(){this.select();});};$.fn.autoselect=function(){return this.bind('click.autoselect',function(){this.select();});};$.fn.selectNow=function(){return this.each(function(){this.select();});};$("body#invites.activate #invite_invite_code,"+"body#sessions.forgot_password #username_or_email,"+"body#sessions.reset_password #user_password,"+"#public-track-login #username").focus();$("#pages.widgets, #tracks.network, #groups.dropbox").find("div.dropbox-badge input, input.dropbox-url").add('#client_applications.show #main-content-inner form:first input, #invite-url, #gifts.show .gift-url, #playlists #side-content input.url:first, #pages .embed-code input').autoselect();});(function($){$.tracksSelector=function(scope,callerSettings){var $scope=$(scope);var settings=$.extend({partial:'no-path-to-partial',beforeDisplay:function($list){return $list;},onSelect:function($selection,ev){$selection.parents('.pane:first').siblings('.pane').find('ul:first').prepend($selection);},onConfirm:function($selection,ev){$.closeZoomScreen();}},callerSettings||{});$scope.zoomable({src:function(callback){$.zoomable.content.dom($('#track-selector'),callback);},callback:function($container){var $selectedTracks=$('#selected-tracks ul:first').empty();var $userTracks=$('#available-tracks ul:first').addClass('loading');$container.find('a.user-action.loading:first').throb(false);$.scAjax({url:$scope.attr('href'),type:'show',accept:'soundcloud/json',callback:function(partial){var $list=settings.beforeDisplay($(partial));$userTracks.empty().removeClass('loading').append($list);$container.find('ul').unbind('click.trackswap').bind('click.trackswap',function(ev){settings.onSelect($(ev.target).closest('li'),ev);return false;}).end().find('a.user-action:first').unbind('click').click(function(ev){settings.onConfirm($('#selected-tracks li'),ev);return false;});}});}});};$.fn.tracksSelector=function(callerSettings){return this.each(function(){$.tracksSelector(this,callerSettings);});};})(jQuery);$(function(){$("div.announcement a.announcement-close").one('click',function(){$(this).parent("div.announcement").css('margin-bottom','0').animate({opacity:0,height:0,padding:0},SC.FX_MEDIUM,"easeInExpo");$.scAjax({url:this.href,type:'update'});return false;});});$(function(){$('body#sessions').filter('.reset_password').each(function(){$('#reset-password').SCValidate({'user[password]':'password','user[password_confirmation]':'passwordConfirmation'});}).end().filter('.login').each(function(){$('input[name=username]:first').selectNow();$('#unlock-form input[tabindex]').each(function(index){this.setAttribute('tabindex',10+index);});}).end();});$(function(){var videoHosts=/(video\.google|vimeo|youtube|viddler)\.com/;$('a.video, a.help-screencast').live('click.video',function(ev){var $link=$(this);var href=$link.attr('href');if(videoHosts.test(href)){var oembedService=/vimeo/.test(href)?'http://vimeo.com/api/oembed.json':'http://oohembed.com/oohembed/';var settings=$.extend({width:640,height:400,autoplay:1},$link.metadata()||{});$.zoomable(ev,{width:settings.width,height:settings.height,src:function(callback){$.getJSON(oembedService+'?url='+escape(href)+'&width='+settings.width+'&color=FF7700&callback=?',function(data){var html=data.html.replace('&amp;fullscreen','&amp;autoplay=1&amp;fullscreen').replace(/(.com\/v\/.*)/,'$1&amp;autoplay=1').replace(/ style=\W.*;\W/,'').replace(/height=\W[0-9]*\W/g,'height="'+settings.height+'"').replace(/width=\W[0-9]*\W/g,'width="'+settings.width+'"');callback(html);});}});return false;}});});$(function(){$('#dashboard-settings').each(function(){function updateDependentCheckboxes($radio){var enabled=($radio.val()==='true');$radio.parents('.dependent').find('div.secondary input').enable(enabled).end().find('div.secondary label').toggleClass('disabled',!enabled).end();}
$('#dashboard-settings input:radio').bind('change',function(){updateDependentCheckboxes($(this));}).filter(':checked').each(function(){updateDependentCheckboxes($(this));}).end();});$('#overview-list a.close').live('click',function(ev){var $link=$(this);var removeItem=function(){Helpers.removePlayer($link);var $item=$link.parents('li:first').slideUp(SC.FX_FAST,SC.EASING);$item.find('div.player').each(function(){SC.playerManager.remove($(this));});$.scAjax({url:$link.attr('href'),type:'destroy'});$.dialogRemove();};if($link.hasClass('confirm')&&!ev.shiftKey){$.dialog($link,{headline:"Remove this item?",center:true,okLabel:"Remove it",extraContent:"<span class=\"extra-content\"><a href=\"/settings/dashboard\">Change Dashboard settings</a></span>",copy:$('<span class="radiobutton">'+'<input type="checkbox" value="false" id="remember-dialog-setting" name="dashboard[confirm_close]"/>'+' '+'<label for="remember-dialog-setting">'+'Don\'t ask me again'+'</label>'+' </span>'),ok:function(){$('#remember-dialog-setting:checked').each(function(){$('#overview-list a').removeClass('confirm');$link.attr('href',$link.attr('href')+'&dashboard[confirm_close]=false');});removeItem();}},ev);}else{removeItem();}
return false;});$('#overview-list a.delete-conversation').live('click',function(ev){$.dialog(this,{headline:"Are you sure you want to delete all messages in this conversation?",okLabel:"Yes",cancelLabel:"Cancel",center:true,ok:function(){$.scAjax({url:ev.target.href,type:'destroy',callback:function(responseBody){var response=Helpers.json(responseBody);$("div#message-"+response.removed_events.join(", div#message-")).parents("li.message").slideUp(SC.FX_FAST);$.dialogRemove();Helpers.notice(response.notice);}});}},ev);return false;});$('#overview-list a.dashboard-message-mark-button').live('click',function(ev){var $link=$(this).fadeOut('slow'),newRead=($link.is(".unread")?1:0);$('a.message-count').increment(newRead?-1:1);$.scAjax({url:this.href,type:'update',data:{'mailbox_item[read]':newRead}});return false;});$("#overview-list li.message").each(function(){var message=this,max=380,$inner=$('div.message-body-inner',message);if($inner.height>max){$('<div class="see-more"><a href="#">See the whole message</a></div>').find('a').click(function(){$inner.css('height',max).animate({height:$inner.height},'fast','easeInOutExpo');$('div.message-body',message).css('max-height','none');$(this).fadeOut('fast');return false;}).end().insertAfter($('div.message-body',message));}});$('#monitoring').live('click',function(){var element=$(this).fadeOut(SC.FAST,SC.EASING);$.scAjax({url:this.href,type:'destroy',callback:function(response,xhr,message){Helpers.notice(response);}});return false;});var actionIntent=function(){$('div.dashboard-item, #comments-list li').actionIntent();};actionIntent();$("a.show-more").live('click',function(){var $last=$(this).prev('li');$(this).throb(true);$.replaceLink(this,{callback:function(){actionIntent();SC.playerManager.add($last.nextAll('li').find('div.player, a[id^=player-]'));}});});$("a.see-all").live('click',function(){$(this).siblings("div.rest").slideDown(SC.FX_MEDIUM).end().remove();});});$(function(){var $header=$('#header'),showAfter=120,keepOpenFor=500,updateIndex=function(index){if($.browser.msie&&$.browser.version<8){$header.css('z-index',index);}};$('#main-nav > li').each(function(){var $item=$(this);$item.mouseenter(function(ev){$item.stop().dequeue().delay(showAfter,function(){$item.addClass('hover');updateIndex(300);}).siblings().stop().dequeue().removeClass('hover');}).mouseleave(function(ev){$item.stop().dequeue().delay(keepOpenFor,function(){$item.removeClass('hover');updateIndex(100);});});});});$(function(){$('body#email.edit').each(function(){var makeEmailPrimary=function(id){var $primaryMarker=$('#primary-marker');$primaryMarker.parents('li:first').removeClass('primary').find('a.delete-email-link').show();$('#email-address-for-'+id).parents('li:first').addClass('primary').end().find('a.delete-email-link').hide().end().append($primaryMarker);$("#notification-email").fadeOut('slow',function(){$(this).text($("#email-address-for-"+id+" span.email-uri:first").text()).fadeIn('slow');});};$("#additional_email").ajaxForm({url:"/emails",type:'POST',resetForm:true,success:function(html){var $res=$(html);Helpers.notice($res.find('.flash:first').html());$res.find("li:first").insertAfter($("li.email-address:last")).hide().slideDown(SC.FX_SLOW,SC.EASING_OUT);}});$("#user-email-list").find('input:radio').live('click',function(e){var id=$(e.target).val();$.scAjax({url:"/"+SC.USER,type:'update',data:{"user[email]":$("#email-address-for-"+id+" span.email-uri:first").text()},callback:function(){makeEmailPrimary(id);}});}).end().find('a.delete-email-link').live('click',function(evt){var $email=$(evt.target);$.dialog($email,{headline:"Do you really want to delete this email?",ok:function(){$.scAjax({url:$email.attr('href'),type:'destroy',callback:function(responseBody){var response=Helpers.json(responseBody);if(response.primaryId){$email.parents('.email-address').fadeOut('slow');makeEmailPrimary(response.primaryId);}
Helpers.notice(response.flash);}});$.dialogRemove();}},evt);return false;}).end();});});$(function(){$('body#client_applications').filter('.show').each(function(){$("#consumer_key").get(0).select();Helpers.waitForImage($("#avatar").addClass('loading').attr('src'),function(){$("#avatar").removeClass('loading').attr('src',$("#avatar").attr('src'));});$("input.click-select").autoselect();}).end().filter('.edit, .new').each(function(){$("#client_application_name").focus();$("#client_application_application_type_desktop_application").click(function(){$("#callback_url_field").slideUp(SC.FAST,function(){$("#client_application_callback_url").val("");});});$("#client_application_application_type_web_application").click(function(){$("#callback_url_field").slideDown(SC.FAST);});$("#ui_keep_icon").click(function(){$("#client_application_icon_field").slideUp(SC.FAST,function(){$("#client_application_icon").val("");});});$("#ui_change_icon").click(function(){$("#client_application_icon_field").slideDown(SC.FAST);});$("#new_client_application, .edit_client_application").validate({rules:{"client_application[name]":{required:true},"client_application[url]":{url:true},"client_application[support_url]":{url:true},"client_application[callback_url]":{url:true}},messages:{"client_application[name]":{required:"Please enter an application name"},"client_application[url]":{url:"This needs to be a valid URL, be sure to include http://"},"client_application[support_url]":{url:"This needs to be a valid URL, be sure to include http://"},"client_application[callback_url]":{url:"This needs to be a valid URL, be sure to include http://"}}});}).end().filter('.index').each(function(){$('table.listing a.delete').dialog({headline:"Do you really want to remove this application?",ok:function(){Helpers.linkToForm(this.attr('href'),'delete').submit();}});});});$(function(){$('#faqs').each(function(index){$('ul.questions a').scrollLink();});});$(function(){$("body#groups").filter('.show, .tracks').each(function(){$('div.moderate-info:first').live('onReducedToZero',function(){$(this).hide();});$('a.tracks-count').live('onReducedToZero',function(){$('abbr',this).each(function(){$(this).text($(this).text().replace(/ \+.*\)/m,')'));});});}).end().filter(".edit, .edit_groups").each(function(){$('a.button.delete').dialog({headline:"Do you really want to remove this group?",ok:function(){Helpers.linkToForm(this.attr('href'),'delete').submit();}});$('li.user').live('click',function(ev){var $badge=$(ev.target).closest('li');var $source=$badge.parents('.pane');var $target=$source.siblings('.pane');var promote=$target.is('.moderators');if($badge.is('.creator')){Helpers.notice($badge.attr('title'));}else{$.scAjax({url:$badge.find('a.moderator-path').attr('href'),type:promote?'update':'destroy'});$target.find('ul:first').append($badge.hide().slideDown());$target.filter('.moderators').find('h3').increment(1);$source.filter('.moderators').find('h3').increment(-1);}});}).end().filter(".new, .edit").each(function(){var $form=$('#new_group');$form.validate({success:"",rules:{'group[name]':{required:true}},messages:{'group[name]':{required:'The group needs a name'}}});$form.find('input:text:first').selectNow();}).end().filter(".discussion").each(function(){Helpers.insertItemForm($("#group-comment-form"),$("#comments-list"),function(){return($("#group-comment-form textarea").val().trim()!=="");},$("#comments, a.comments-count"));$("#group-comment-form").bind("onItemFormLoad",function(){$('#comments-list li').actionIntent();});$('#group-comment-form textarea').autogrow();$('#comments-list a.reply').live('click',function(){var $comment=$(this).closest('li');$('#group_post_body').val(Helpers.getCommentPrefix($comment));$.scrollTo($('#group-comment-form:first').siblings('h3'),{speed:SC.FX_SLOW,easing:'easeOutExpo',onAfter:function(){Helpers.setCaretToEnd($("#group_post_body"));}});return false;});$('li.comment a.remove').die().live('click',function(){var $link=$(this).blur();$.dialog($link,{headline:"Do you really want to remove this comment?",ok:function(){$link.parents('li').remove();$.dialogRemove();$.scAjax({url:$link.attr('href'),type:'destroy',accept:'soundcloud/json',callback:function(response){Helpers.notice("The comment has been deleted");}});}});return false;});});$(function(){$("#monitor_tracks, #monitor_discussion").each(function(){var $link=$(this);$(this).siblings(':checkbox').click(function(){var create=$(this).is(":checked");$.scAjax({url:$link.attr('href'),type:create?'update':'destroy'});});});var toggleMembership=function($link){var create=$link.hasClass("create");var newStatus=!create?"Join Group":"Leave Group";$link.toggleClass("destroy").toggleClass("create").attr('title',newStatus).find('span').html(newStatus);$link.parents('div.actions').find('.members').increment(create?1:-1);return $link;};$('a.membership').live('click',function(ev){if(ev.which===3){return false;}
var $link=$(this);var create=$link.hasClass("create");toggleMembership($link);$.scAjax({url:$link.attr('href'),type:create?'update':'destroy',callback:function(response,xhr,message){},error:function(){toggleMembership($link);}});return false;});$('a.add-to-group').live('click',function(ev){var $link=$(this);var $panel=$link.siblings('.groups-list:first');$.pulldown($link,{node:$panel});});$('.groups-list ul a').live('click',function(ev){var $link=$(this).throb(),$panel=$link.parents('div.groups-list:first'),create=$link.hasClass('create-group'),$privateForm=$panel.find('div.group-form:first'),contributeQuota=SC.CURRENT_USER.quota.contributions_per_track,updateGroup=function(){$.scAjax({url:$link.attr("href"),type:create?'create':'destroy',callback:function(response){$link.toggleClass('create-group').toggleClass('remove-group').throb(false).each(function(){var txt=$link.text();$link.text(create?txt.replace('+','-'):txt.replace('-','+'));});if(create&&$('a.remove-group',$panel).length>=contributeQuota){$('a.create-group',$panel).addClass('disabled');}else if(!create){$('a.create-group.disabled',$panel).removeClass('disabled');}
$('a.destroy').filter('[href='+$link.attr('href')+']').each(function(){Helpers.removePlayer(this);});$.pulldownHide();}});};if(!$link.hasClass('disabled')){updateGroup($link.throb(true));}
return false;});var unmoderatedTracksCount=function(delta){$('a.moderate var, var.unapproved, div.moderate-info h3').increment(delta);};var removeTrack=function($link){$.scAjax({url:$link.attr('href'),type:'destroy',callback:function(response,xhr,message){Helpers.removePlayer($link,function(){unmoderatedTracksCount(-1);});$.dialogRemove();}});};$('a.contribution').live('click',function(ev){if(ev.which===3){return false;}
var $link=$(this);$link.filter('.approve').each(function(){$link.throb(true);$.scAjax({url:$link.attr('href'),type:'update',callback:function(response,xhr,message){$link.parents("div.moderate-track").slideUp(function(){$(this).remove();}).siblings("a.close").removeClass("hidden");unmoderatedTracksCount(-1);$('a.tracks-count').increment(1);}});});$link.filter('.destroy').each(function(){$.dialog($link,{headline:"Do you really want to remove this track from the group?",ok:function(){removeTrack($(this));}},ev);});return false;});});});$(function(){$("body#pages").each(function(){var steps=['dashboard','upload','profile','player'];$('ul.walk-though-screens a').each(function(i,link){$(link).click(function(){$.scrollTo('#tour-'+steps[i],{easing:'easeOutExpo',speed:SC.FX_MEDIUM,axis:'y'});return false;});});$('#pages.contact #text').focus();$('#jobs, #contact, #support').validate({rules:{text:"required"},messages:{text:"Please enter a message"},submitHandler:function(form){$(form).ajaxSubmit({success:function(){Helpers.notice("The message is on its way!");},resetForm:true});}});$('ul.scroll a').scrollLink();}).filter(".videos").each(function(){var hash=!!location.hash&&location.hash.replace('#','');$('a.video').each(function(index){this.id=this.id+'-link';}).click(function(ev){window.location.hash=this.id.replace('-link','');ev.preventDefault();});if(hash&&$('#'+hash).size){$('#'+hash+'-link').click();}}).end().filter(".support").each(function(){$('#gsfn_search_query').focus();}).end().filter('.widgets').each(function(){$('#imonsc-customize').each(function(){var messageClass,typeClass,colorClass,secondaryColor,$messages=$('div.message-chooser:first > a',this),$types=$('div.form-chooser:first > a',this),$colors=$('div.color-chooser:first > div',this),$preview=$('#sc-badge'),$embed=$('#sc-badge-code'),customClass=function(node){return $(node)[0].className.replace(/\s*(active|\{.*\})\s*/g,'');},updateBadge=function(){messageClass=customClass($messages.filter('.active')).replace('message-','');typeClass=customClass($types.filter('.active')).replace('imonsc-','');colorClass=customClass($colors.filter('.active'));$preview.removeClass().addClass(messageClass+' '+typeClass+' '+colorClass);$embed.val($('#badge-'+messageClass+'-code-'+typeClass).val().replace(/%COLOR/g,colorClass));if(secondaryColor){$embed.val($embed.val().replace(/color: #\w{0,6};/,'color: #'+secondaryColor+';'));}};$messages.add($types).add($colors).click(function(ev){var ctl=$(ev.target);ctl.addClass('active').siblings().removeClass('active');secondaryColor=ctl.metadata().color;updateBadge();return false;});$colors.filter('.active:first').click();});}).end();$(window).load(function(){$('#flickr-pics').each(function(){Helpers.require(SC.asset_url('/javascripts/classes/flickr_thumbs.js'),function(){return!!$.fn.flickrThumbs;},function(){$('#flickr-pics').flickrThumbs('soundcloud');});});});$('a.zoom, a.artwork').live('click',function(ev){$.zoomable(ev,{src:$.zoomable.content[this.href.match(/#.*/)?'id':'image']});return false;});});$(function(){$('body#invites').filter('.new').each(function(){var $form=$("#invite-form");$form.submit(function(){if(!$form.valid()){return false;}
var isEmail=$('#invite_email').is(':visible');$("#invite_invite_type").val(isEmail?0:1);if(isEmail){return true;}else{$form.ajaxSubmit({beforeSend:SC.xhr.js,clearForm:true,success:function(responseText){var response=Helpers.json(responseText);if(response.text.trim().toLowerCase()!=="failed"){$('#invite-url').val(response.text);$('#invite-url-group').slideDown(SC.FX_SLOW,SC.EASING_OUT);$("#invite-form").slideUp(SC.FX_SLOW,SC.EASING_OUT);Helpers.notice(response.flash.notice);}}});return false;}});$('#tabs ul.tabs:first a').click(function(){var email=this.id==='email-invite-button';$(this).parents('li:first').addClass('current').siblings('li').removeClass('current');$('#email-fields, #invite-message-field')[email?'slideDown':'slideUp'](SC.FX_FAST);return false;});$('#another-invite').click(function(){$('#invite-url').clearFields();$('#invite-url-group').slideUp(SC.FX_SLOW,SC.EASING_OUT);$("#invite-form").slideDown(SC.FX_SLOW,SC.EASING_OUT);});$("#invite_email").blur(function(){$(this).val($(this).val().trim());});$("#invite_first_name").focus();}).end().filter('.show').each(function(){$('#signup-form').SCValidate({"user[username]":"username","user[password]":"password","user[terms_of_use]":"terms"});$("#user_password, #user_password_confirmation, #password").capslock();$('#track-login-form-container, #signup-form-container').each(function(){var $node=$(this);$('#main-content').zoomable({showCloseButton:false,width:parseInt($node.css('width'),10),height:parseInt($node.css('height'),10),src:function(callback){$.zoomable.content.dom($('#'+$node[0].id),callback);},callback:function($zoom){$zoom.find('input:password:first').focus();$zoom.find('a.cancel').click(function(ev){window.location=ev.target.href;});}}).click();});});$("#invite-form").validate({rules:{"invite[email]":{required:'#invite_email:visible',email:true,rangelength:[3,100],remote:"/users/unique_email"}},messages:{"invite[email]":{remote:$.format("{0} is already a SoundCloud member"),required:"Please enter an e-mail address",rangelength:$.format("Your e-mail should have between {0} and {1} characters"),email:"Please enter a valid e-mail address"}}});});$(function(){$('body#messages').filter('.new').each(function(){$('#message_subject').focus();}).end().filter('.show').each(function(){var scrollTo=function(id){if(id){$.scrollTo(id,{easing:'easeInOutExpo',speed:SC.FX_SLOW,axis:'y',onAfter:function(){if(id==="#reply-header"){$('#message_body')[0].setSelectionRange(0,0);$('#message_body').focus();}}});}
return false;};if(window.location.hash.toLowerCase()==="#reply"){scrollTo("#reply-header");}else if($("#main-content .message-wrapper").size()>1&&window.location.hash.toLowerCase()!=="#conversation"){scrollTo("#message-"+Helpers.getLastNumInPath(window.location.toString()));}
$("#reply-on-message").click(function(){return scrollTo("#reply-header");});$("#delete-message").dialog({headline:"Are you sure you wish to delete this conversation?",ok:function(){Helpers.linkToForm(this.attr('href'),'delete').submit();}});Helpers.insertItemForm($("#message-form"),$("#messages-list"),SC.returnTrue);$(".prev a, .next a").hover(function(){$(".preview .preview-"+$(this).parent().attr("class")).fadeIn('slow');},function(){$(".preview .preview-"+$(this).parent().attr("class")).fadeOut('fast');});}).end().filter('.index').each(function(){$("table td a.delete-message-link").dialog({headline:"Are you sure you wish to delete this conversation?",ok:function(){var $link=this;$.scAjax({url:$link.attr('href'),type:'destroy',callback:function(response){var $msg=$link.parent().parent();$msg.fadeOut('slow');if($msg.is(".unread")){$('a.message-count').increment(-1);}
$("div.messages-header h1").increment(-1);Helpers.notice("The conversation has been deleted");$.dialogRemove();}});}});$("table td.unread a").click(function(){var $a=$(this);$.scAjax({url:this.href,type:'update',data:{'mailbox_item[read]':1},callback:function(res){$a.fadeOut('slow',function(){$a.parent("tr.unread").removeClass("unread");});if($('body:first').is('.outbox')){$('a.message-count').increment(-1);}}});return false;});}).end().find('#message_body').autogrow();var msgDialogSettings={};msgDialogSettings.width=470;msgDialogSettings.height=300;msgDialogSettings.src=function(callback){$.getJSON($(this).closest('a').attr('href'),function(data){callback(data.form_html);});};msgDialogSettings.beforeClose=function($container,evt){if($.isNotBlank($container.find('input:text').val())||$.isNotBlank($container.find('textarea:first').val())){if(!$('.modal-fade:first').is(':visible')){$.dialog((evt?evt.target:$container.find('input:visible:first')),{headline:"Your message hasn't been sent yet. Sure you want to close it?",ok:function(){$.closeZoomScreen();$.dialogRemove();}},evt);$container.find('input:visible').blur();}}else{$.closeZoomScreen();}};msgDialogSettings.callback=function($container){var $form=$container.find('form');$form.validate({success:"",rules:{'message[subject]':{required:'#message_body:blank'},'message[body]':{required:'#message_subject:blank'}},messages:{'message[subject]':{required:'The message needs either a subject or text'},'message[body]':{required:'The message needs either a subject or text'}}});$form.throbberform().ajaxForm({beforeSubmit:function(){var valid=$form.valid();if(!valid){$('input:visible, textarea',$form).keypress(function(ev){$form.valid();});}
return valid;},success:function(responseBody){$.closeZoomScreen(function(){Helpers.notice('The message was sent');});}}).find("input[name=redirect_to]").remove().end().find('input:text:first').keydown(function(ev){if(ev.keyCode===SC.ENTER_KEY){return false;}}).end().find('input:text:first, textarea.reply:first').focus();};$('a.send-message').live('click',function(ev){if(ev.which===3){return false;}
$.zoomable(ev,msgDialogSettings);return false;});});$(function(){$("body#oauth").each(function(){$('a.signup').click(function(){$('form#signup-form').show();$('form.existing-user').hide();$('#user_email').focus();return false;});$('a.forgot-password').click(function(){$('form.existing-user').hide();$('form.forgot-password').show();$('#username_or_email').focus();return false;});$('a.login').click(function(){$('form.existing-user').show();$('form.forgot-password').hide();$('form#signup-form').hide();$('#username').focus();return false;});$('form.forgot-password:first').ajaxForm({success:function(response){$('a.login').click();Helpers.notice(response);},error:function(response){Helpers.notice(response.responseText);}});var authorize=function(grant){return function(){$("#grant").val(grant?"true":"");$("form.existing-user").submit();};};$("#authorize").click(authorize(true));$("a.cancel").click(authorize(false));var $signupForm=$('#signup-form');$signupForm.SCValidate({"user[email]":"email","user[password]":"password","user[password_confirmation]":"passwordConfirmation","user[terms_of_use]":"terms"}).ajaxForm({beforeSubmit:function(){var isValid=$signupForm.valid();$('#signup_authorize').throb(isValid);return isValid;},success:function(){$("#grant").val("true");$("form.existing-user").submit();},error:function(){$('#signup_authorize').throb(false);Helpers.notice('Oops something went wrong while signing up.');}}).each(function(){$("#user_password, #user_password_confirmation, #password").capslock();$('#username').focus();});$("#verify-code").autoselect().selectNow();});});$(function(){$("#header-search").each(function(){var $searchField=$(this);$searchField.data('defaultText',$searchField.val()).blur(function(){if(!$searchField.val()){$searchField.val($searchField.data('defaultText'));}
$searchField.addClass("blurred");}).focus(function(){if($searchField.val()===$searchField.data('defaultText')){$(this).val("");}
$searchField.removeClass("blurred");}).siblings('div.search-selector').pulldown({align:'right',callback:function($pulldown){$pulldown.find('a').unbind('click').bind('click',function(){if($searchField.val()&&$searchField.val()!==$searchField.data('defaultText')){this.href=this.href.split('?')[0]+'?q='+encodeURIComponent($searchField.val());return true;}else{$searchField.parents('form:first').attr('action',this.href);var newDefaultText="Search "+$(this).text().toLowerCase();$searchField.val(newDefaultText);$searchField.data('defaultText',newDefaultText);$.pulldownHide();return false;}});}});});$("body#search").each(function(){$("#q").selectNow().parents('form:first').validate({success:"",rules:{"q":{required:true,minlength:4}},messages:{"q":{required:"Please enter your search term",minlength:"Your search term should be at least 4 characters long"}}});});});$(function(){$("body#pro, body#gifts").filter('.choose, .edit, .new').each(function(){var $form=$('#new-subscription, #new-gift');var $promo=$('#promo-code');var checkPromoTimeout;$form.submit(function(){if($(this).valid()){Helpers.enableGuiBlock("Please wait until the transaction is over");return true;}else{$(this).trigger('invalid');return false;}}).validate({rules:{"billing_address[first_name]":{required:true},"billing_address[last_name]":{required:true},"billing_address[address_first_line]":{required:true},"billing_address[zip_code]":{required:true},"billing_address[city]":{required:true},"billing_address[country_code]":{required:true},"billing_address[state_code]":{required:true},"billing_address[vat_no]":{required:true},"credit_card[number]":{required:'#credit-card-info:visible',validcreditcard:['input[name="credit_card[type]"]']},"credit_card[verification_value]":{required:'#credit-card-info:visible',digits:true,minlength:3},"credit_card[first_name]":{required:'#credit-card-info:visible'},"credit_card[last_name]":{required:'#credit-card-info:visible'},"promo_code":{minlength:6,promotion:{remoteUrl:function(){return $('#check-promo-code-savings')[0].href.replace(/\:term/,$('input[name=term]:checked').val()||"yearly").replace(/\:promocode/,$('input#promo-code').val());},errors:function(response){return $.map($(response).filter(".errors").find("li"),function(val){return val.innerHTML;});},valid:function(response){$promo.addClass('valid').siblings('label.valid').show();$(document).trigger({type:'promoChange',content:response});}}}},messages:{"credit_card[type]":{required:"Select the type of your credit card"},"credit_card[number]":{required:"Fill in the your credit card number"},"credit_card[verification_value]":{required:"Fill in the CSC",digits:"CSC is a 3 digit value",minlength:"CSC is a 3 digit value"},"credit_card[first_name]":{required:"Fill in the your credit card owner's first name"},"credit_card[last_name]":{required:"Fill in the your credit card owner's last name"},"promo_code":{minlength:"Promotion code must be at least six characters long"},"billing_address[first_name]":{required:"Fill in your first name"},"billing_address[last_name]":{required:"Fill in your last name"},"billing_address[address_first_line]":{required:"Fill in your adress"},"billing_address[zip_code]":{required:"Fill in your zip code"},"billing_address[city]":{required:"Fill in your city"},"billing_address[country_code]":{required:"Fill choose your country"},"billing_address[state_code]":{required:"Fill select your state"},"billing_address[vat_no]":{required:"Fill in your VAT number"}},showErrors:function(errorMap,errorList){if(!$promo.val()||(errorList.length&&errorList[0].element.id==='promo-code')){$promo.siblings('label.valid').hide();$(document).trigger({type:'promoChange',content:''});}
this.defaultShowErrors();},success:function(label){if($(label).attr('for')==='promo-code'){$promo.addClass('valid').siblings('label.valid').show();}}});$form.bind('invalid-form',function(ev){Helpers.removeGuiBlock();});$('div.payment-selector input:radio, input.pm-switch:radio').click(function(ev){var monthly=$('#term_monthly').is(':checked');if(monthly&&$('#credit_card_type_paypal').is(':checked')){$('#credit_card_type_paypal').select(false).enable(false);$('#credit_card_type_visa').select(true).click();}
$(ev.target).parents('.radiobutton').addClass('active').siblings('.radiobutton').removeClass('active');$form.find('.radiobutton.pp:first').toggleClass('disabled',monthly).find('input:radio').enable(!monthly).end().find('.expl').removeClass('hidden').toggle(monthly).end().end().find('.payment-info:first p:first').find('.monthly').toggle(monthly).end().find('.yearly').toggle(!monthly).end().end().find('.head:first').find('.monthly:first').toggleClass('hidden',!monthly).end().find('.yearly:first').toggleClass('hidden',monthly).end();$promo.each(function(index){$.data($promo[0],'previousValue',{old:null,valid:true,message:""});$("#promo-code-savings-placeholder").hide();$promo.attr('style','');$form.validate().element($promo);});$(document).trigger('paymentTypeChange');}).filter(':checked').click();var enableAllowed=function(){return $(this).filter(function(){return $(this).parents('.disabled').length===0;}).enable(true);};$form.find('#credit-card-fields input:radio').click(function(ev){var $item=$(ev.target).parents('div:first').addClass('active').siblings().removeClass('active').end();var $container=$('#payment-data-container');$container.css({height:$container.height()});if($item.is('.pp')){$('#credit-card-info').hide().find('input').enable(false);$container.slideUp(SC.FX_MEDIUM,function(){$('#pp-express-info').fadeIn(SC.FX_FAST);});}else{$('#pp-express-info').hide();$container.slideDown(SC.FX_MEDIUM,function(){$('#credit-card-info').fadeIn(SC.FX_FAST).find('input:visible').each(enableAllowed);$container.css({height:'auto'});});}
if($('#credit_card_number').is(':filled')){$form.validate().element("#credit_card_number");}}).filter(':checked').click();$('input.pm-switch:radio').click(function(ev){$(ev.target).parents('.pm').removeClass('inactive').find('.pm-info').each(function(index){$('input, select',this).each(enableAllowed);}).end().siblings('.pm').addClass('inactive').find('.pm-info').each(function(index){$('input, select',this).enable(false);});}).filter(':checked').click();$('a.reveal').click(function(ev){$(ev.target).hide();$('#'+ev.target.href.split('#')[1]).slideDown(SC.FAST);$('p.cc-info').hide();return false;});$promo.keyup(function(ev){clearTimeout(checkPromoTimeout);checkPromoTimeout=setTimeout(function(){$promo.validateField();},1300);});$('#billing_address_country_code').bind('change',function(){var isUS=$(this).val()==="US";$('#billing_address_state_code').enable(isUS).parent().toggleClass('inactive',!isUS);$(document).trigger('countryChange');});$('#is-business').bind('click',function(){var isBusiness=$(this).is(':checked');$('#business-fields').toggleClass('inactive',!isBusiness).find('input').enable(isBusiness);$(document).trigger('bussinesClientChange');});$('#billing_address_vat_no').bind('blur',function(event){$(document).trigger('vatChange');});$('#credit-card-owner-different').bind('click',function(event){var isDifferent=$(this).is(':checked');$('#credit-card-owner').toggle(isDifferent).toggleClass('disabled').find('input').enable(isDifferent);});$('#savings').each(function(index){var $savingsNotice=$(this),$bussinesNotice=$('#business-price-notification'),$promoNotice=$("#promo-code-savings-placeholder"),$price=$('#final-price').find('.price'),vatFreeCheck=function(){var vatFreeCountries=['BE','BG','CZ','DK','EE','IE','EL','ES','FR','IT','CY','LV','LT','LU','HU','MT','NL','AT','PL','PT','RO','SI','SK','FI','SE','UK'];var hasVatNumber=$('#is-business').is(':checked')&&$('#billing_address_vat_no').is(':not(:blank)');var isVatFree=$.inArray($('#billing_address_country_code').val(),vatFreeCountries)>=0;return hasVatNumber&&isVatFree;},updatePromocodeNotice=function(event){if(event&&event.content){$promoNotice.html(event.content).fadeIn();}else{$promoNotice.hide().empty();}},updateFinalPrice=function(bussinesPrice){var visiblePrice=function(){var priceData=$('#promo-savings').add('input[name=term]:checked,input[name=term]:hidden').eq(0).metadata().price;return priceData/100;}();var parsedPrice=(parseFloat(visiblePrice)*(bussinesPrice?0.81:1)).toFixed(2);$price.text(parsedPrice);},checkState=function(event){var showBusinessPrice=vatFreeCheck();updateFinalPrice(showBusinessPrice);$bussinesNotice.toggle(showBusinessPrice);$promoNotice.toggle($('#promo-savings').exists());$savingsNotice.toggle(showBusinessPrice||$('#promo-savings').exists());};$(document).bind('promoChange',updatePromocodeNotice);$(document).bind('bussinesClientChange countryChange promoChange vatChange',checkState);updateFinalPrice();checkState();});}).end().filter('.show').each(function(){$('#payment-cancel a.user-action').zoomable({src:$.zoomable.content.id,callback:function($container){$container.find('form:first').throbberform();}});}).end().filter('.index').each(function(){var selection=location.hash.replace('#','');if(selection.length>0){$('#row-'+location.hash.replace('#','')).addClass('highlighted');}
$('a[href=#premium-accounts]').scrollLink();$('#client-list').each(function(index){var $clients=$('li',this);var current;var hilite=function(classId){if(classId&&classId!==current){var rx=new RegExp($.trim(classId));$clients.each(function(){this.className=this.className.replace(/\s*(dimmed|highlighted)\s*|^/,rx.test(this.className)?'highlighted ':'dimmed ');});current=classId;}else{$clients.removeClass('dimmed highlighted');current=undefined;}};$('#client-types a').live('click',function(event){hilite(this.className.replace(/\s*active\s*/,''));$(this).siblings('a').removeClass('active').end().addClass('active');return false;});});}).end();});$(function(){var blockedUser=function(){var list=["the-observer","genericmeds"];return $.inArray(SC.CURRENT_USER.permalink,list)>=0;}();$("body#topics").filter(".show").each(function(){$('#monitoring').click(function(){var $element=$(this).throb(true),method="create",label="Stop following this topic";if($element.hasClass("monitoring-delete")){method="destroy";label="Follow this topic";}
$.scAjax({url:$element.attr("href"),type:method,callback:function(response){$element.throb(false).toggleClass("monitoring-delete").find('span').text(label);Helpers.notice(response);}});return false;});$('#posts-list li').actionIntent();$("#reply form").bind("onItemFormLoad",function(){$("#monitoring").addClass("monitoring-delete").text("Stop following this topic");$('#posts-list li').actionIntent();}).find('textarea').autogrow();if(blockedUser){$("#reply form").submit(function(){$('input:submit',this).throb(false);return false;});}else{Helpers.insertItemForm($("#reply form"),$("#posts-list"),function(){return($("#post_body").val().trim()!=="");},$("#topic-post-count"));}}).end().filter('.new').each(function(){$('#topic_title').focus();if(blockedUser){$('#new_topic form').submit(function(){$('input:submit',this).throb(false);return false;});}}).end().find('#main-content-inner form:first textarea:first').autogrow();});$(function(){$("body#tracks").filter(".show").each(function(){var trackPath=$('#main-content-inner div.player:first').metadata().trackUri;$("#public-track-login #username").focus();$('h1 em.editable').editableField({path:trackPath,name:'track[title]',title:'Click to change the track title'});$("#track-description-value.editable").editableDescription({path:trackPath,name:'track[description]'});$('div.key-bpm').tapper(function(bpm){$.scAjax({url:trackPath,type:'update',data:{'track[bpm]':bpm}});});$('div.genre-privacy span.editable').editableField({path:trackPath,maxLength:40,name:'track[genre]',title:'Click to change the track genre'});$('div.description h4.editable').editableField({path:trackPath,name:'track[tag_list]',title:'Click to change the track tags'});$("#add-non-timestamp-comment-link").click(function(){$.scrollTo('h3.comment-add-header',{easing:'easeOutExpo',speed:SC.FX_SLOW,axis:'y',onAfter:function(){$("#no-timestamp-comment-form textarea").focus();}});return false;});$("#add-timed-comment-link").click(function(){$.scrollTo('#main-content',{easing:'easeOutExpo',speed:SC.FX_SLOW,axis:'y',onAfter:function(){setTimeout(function(){$('.player .comment-area-click-proxy').hide().css('background-image','url(/images/player-comment-area-highlight.png)').fadeIn(SC.FX_SLOW,function(){$(this).fadeOut(SC.FX_SLOW,function(){$(this).css('background','transparent').show();});});},0);}});return false;});var actionIntent=function(){var items=$('ul#comments-list li').actionIntent();};actionIntent();}).end().filter('.new, .edit').each(function(){}).end();$('a.all-actions').live('click',function(){$(this).hide().siblings().show();return false;});$('div.player a.delete').live('click',function(ev){var link=this;$.dialog(link,{headline:"Do you really want to delete this track?",cancelLabel:"Cancel",throb:true,center:true,ok:function(){if($(link).parents("div.large:first").exists()){Helpers.linkToForm(link.href,'delete').submit();}else{Helpers.removePlayer(link);$.dialogRemove();$.scAjax({url:link.href,type:'destroy',callback:function(responseBody){Helpers.notice(Helpers.json(responseBody).flash.notice);}});}}});return false;});$("#more-privacy-toggler").live('click',function(){$("#more-privacy").slideToggle(SC.FAST);$(this).text(($(this).text().match(/hide/i)?"Show":"Hide")+" extra options");return false;});});$(function(){$("body#users").filter('.search').each(function(){$("#q").focus();}).end().filter('.edit').each(function(){$("#settings-form").ajaxForm({beforeSend:SC.xhr.json,type:'PUT',url:this.href,success:function(response){var data=Helpers.json(response);for(var key in data){$("#user_"+key).val(data[key]);}
Helpers.notice("Your settings were updated!");}});}).end().filter('.accept_terms').each(function(){$('#accept-terms-form').SCValidate({"user[terms_of_use]":"terms"});}).end().filter('.tracks, .comments, .favorites, .sets').each(function(){$("#description.editable").editableDescription({path:"/"+SC.USER,name:'user[description]'});}).end();});$(function(){$("body#signup, body#basic_profile").each(function(){var google=window.google;if(google&&google.loader.ClientLocation){var address=google.loader.ClientLocation.address;$('#user_city').filter(':blank').val(address.city||address.region);$('#user_country_code').filter(':blank').val(address.country_code);}else{console.log('Geo location service is not available');}}).filter(".new").each(function(){$("#user_email").focus();$('#signup-form').SCValidate({"user[email]":"email","user[password]":"password","user[password_confirmation]":"passwordConfirmation","user[terms_of_use]":"terms"});$("#user_password, #user_password_confirmation, #password").capslock();}).end().filter('.details, .edit').each(function(){$("#user_username").focus();$('#basic-profile-form').SCValidate({"user[username]":"username","user[permalink]":"userPermalink"});$('#user_username').filter(':filled').validateField();$('#user-name-edit').each(function(){var $edit=$('#edit-url');var $field=$('#user_permalink');var $form=$field.parents('form');var initial=$edit.text();$edit.editableSC({maxLength:25}).bind('onEditStart',function(ev){$field.enable(true);Helpers.setCaretPosition($edit,1);$edit.unbind('keyup.permalink').bind('keyup.permalink',Helpers.throttle(1000,function(){$field.val($edit.text().trim());$form.validate().element($field);$edit.addClass('edited');}));}).bind('onEditBlur',function(event){$form.validate().element($field);}).bind('keyup',function(){$('#permalink-change-hint')[$edit.text()===initial?'slideUp':'slideDown']();});var $name=$('input.title',this);var updateURL=function(){$edit.not('.edited').each(function(){$.scAjax({type:'show',url:'/users/suggested_permalink?user[username]='+$name.val(),callback:function(response){$field.val(response);$edit.text(response);}});});};$name.filter(function(){return this.value===""||(/user\d+/).test(this.value);}).bind('keyup.permalink',Helpers.throttle(1000,function(){updateURL();}));});var $checkboxes=$('#describe-yourself input:checkbox');$checkboxes.click(function(ev){if($checkboxes.filter(':checked').size()>2){$checkboxes.filter(':not(:checked)').attr('disabled','disabled').siblings('label').addClass('disabled');}else{$checkboxes.removeAttr('disabled').siblings('label').removeClass('disabled');}});var $current=$("#pictures-container div.current-picture");$current.find('a').bind('click',function(ev){$.cropper(ev,function(){$('#crop-box form').ajaxForm({beforeSend:SC.xhr.partial,success:function(partial,status){if($.trim(partial)){var $large=$(partial).find('span.avatar-large');Helpers.waitForBgImage($large,function(){$large.replaceAll($current.find('span')).removeClass('hidden').show();});}},complete:function(){$.closeZoomScreen();}});});});var $uploadButton=$('#upload-image-btn');$uploadButton.uploader({multiple:false,typeFilter:$.uploader.fileFilters.images,maxFileSize:1024*1024*5}).bind('onAllSelect',function(e,f,u){f.upload({url:"/users/"+SC.CURRENT_USER.permalink+"/avatars?security_token="+security_token});}).bind('onComplete',function(e,f,u){$uploadButton.throb(true);if($.trim(u[1])){var $large=$(u[1]).find('span.avatar-large');Helpers.waitForBgImage($large,function(){$large.replaceAll($current.find('span')).show();$current.find('a').removeClass('hidden').show();$uploadButton.throb(false);});}});}).end();});$(function(){$("body#users, body#dashboard").each(function(){$('a.customize-link').live('click',function(ev){$.pulldown(this,{node:$(this).parents('div.customize:first').find('.options:first'),align:'right'});});$('div.customize li a').click(function(ev){var $link=$(ev.target);$link.parent().throb(true).siblings('li').removeClass("current");$.scAjax({url:$link.attr('href'),type:'update',callback:function(body){$link.parent().throb(false).addClass("current");$link.parents('ul:first').siblings('p').find('> a').removeClass('active');Helpers.notice("Saved. The "+$link.text().trim()+" tab is now default on your profile page");$.pulldownHide();}});return false;});});});$(function(){$('#basic_profile.edit').each(function(){var $current=$('#pictures-container .current-picture');var update=function($large){$current.find('span').replaceWith($large).end().find('a').removeClass('hidden')[($('#pictures-container li:visible').exists()?'show':'hide')]().end();};var activate=function($badge){var $large=$badge.parents('li:first').addClass('avatar-active').siblings().removeClass('avatar-active').end().end().siblings('span.avatar-large').clone().show();update($large);};$current.find('a').bind('click',function(ev){$.cropper(ev,function(){$('#crop-box form').ajaxForm({beforeSend:function(){$('span.avatar-large, #previous-pictures-list .avatar-badge:first').addClass('loading');return SC.xhr.partial;},success:function(partial,status){var $li=$(partial),$preview=$li.find('span.avatar-badge'),$large=$li.find('span.avatar-large'),id=$preview.attr('id');if(id){Helpers.waitForBgImage($preview,function(){Helpers.waitForBgImage($large,function(){$('#'+id).parents('li').replaceWith($li);$preview.click();});});}},complete:function(){$.closeZoomScreen();}});});});$('span.avatar-badge').live('click',function(ev){var $avatar=$(ev.target);activate($avatar);$.scAjax({type:'update',url:'/'+SC.CURRENT_USER.permalink,data:{'user[avatar_id]':+Helpers.getId($avatar)}});});$('a.avatar-remove').live('click',function(ev){var $target=$(ev.target);if(!$target.is('.loading')){$target.addClass('loading');$.scAjax({url:$target.attr('href'),type:'destroy',accept:'text/html+partial',callback:function(response){if($.trim(response)){var $next=$(response).find('span.avatar-badge');activate($('#'+$next.attr('id')));}else{$current.find('span').hide().end().find('a').hide().end();}
$target.parents('li').fadeOut();}});}});var $uploadButton=$('#upload-image-btn');$uploadButton.uploader({multiple:false,typeFilter:$.uploader.fileFilters.images,maxFileSize:5*1024*1024}).bind('onAllSelect',function(e,f,u){f.upload({url:"/users/"+SC.CURRENT_USER.permalink+"/avatars?security_token="+security_token});}).bind('onOpen',function(){$("#previous-pictures").removeClass('hidden').show();$("<li id='avatar-loader' class='picture-preview'><div><span class='loading'></span></div><a href='#'>X</a></li>").prependTo("#previous-pictures-list");}).bind('onComplete',function(e,f,u){var $preview=$(u[1]);var $badge=$preview.find('span.avatar-badge');$uploadButton.throb(true);Helpers.waitForBgImage($badge,function(){Helpers.waitForBgImage($badge.siblings('span.avatar-large'),function(){$preview.replaceAll($('#avatar-loader')).show();$badge.click();$uploadButton.throb(false);});});}).bind('onError',function(ev,flash,upload){Helpers.notice("Could not upload the avatar, please try again");});});});$(function(){var initUploadForm=function(){var $form=$('form.upload:first, #playlist-form, #track-edit-form').eq(0);var isOldSchool=$form.parents('.basic-upload').exists();var isUploading=function(){return $('#upload-progress-amount').is(':visible')&&$('#upload-progress-amount').find('.loaded:first').length>0;};var $submit=$('input:submit',$form);$submit.data('buttonLabel',$submit.val());if(isOldSchool){$form.addClass('basic-upload');$('#track_uid').remove();$submit.removeClass('in-progress');}else{}
$form.find('input:file').enable(isOldSchool).toggle(isOldSchool);var trackId=$form.find("#track_id").val();var playlistId=$form.find("#playlist_id").val();var validation=$('#set-upload-submit').is(':visible')?SC.metaInfoValidationRules('playlist','set'):SC.metaInfoValidationRules('track');function fileSelectOk(){return $('input:file:visible',$form).not(':blank').filter(function(){return!$form.validate().element(this);}).size()===0;}
$('#edit-url:not(.inited)').each(function(){var $editUrl=$(this),originalValue=$editUrl.text(),$input=$editUrl.siblings('input:first');$editUrl.editableSC().bind('keyup',function(event){$input.val($editUrl.text().trim());$form.validate().element($input);}).bind('onEditBlur',function(){var newValue=$editUrl.text().trim();if(!newValue){$editUrl.text(originalValue);newValue=originalValue;}
$input.val(newValue);$('#edit-url-hint').remove();$form.validate().element($input);if($('body:not(.new)').exists()&&$editUrl.siblings('.error:visible').length===0&&newValue!==originalValue){$('<div id="edit-url-hint" class="hint">The new URL will be activated after you save this form.</div>').insertAfter($editUrl.parent());}
$editUrl.addClass('edited');$editUrl.trigger('onUrlChange');});$('#track_title, #playlist_title',$('form.upload, body.new')).each(function(index){var $title=$(this);var updateUrl=function(){if(!$title.val()){return;}
$('#edit-url:not(.edited)').each(function(){var $url=$(this),titleStr=$title.val(),suggestUrl=(($title.attr('id')==='playlist_title')?'/sets/suggested_permalink?playlist':'/tracks/suggested_permalink?track')+'[title]='+encodeURIComponent(titleStr);$.scAjax({type:'show',url:suggestUrl,callback:function(response){var newPermalink=response?response:Helpers.permalize(titleStr);$('#track_permalink, #playlist_permalink').val(newPermalink);$url.text(newPermalink).trigger('onUrlChange');}});});};$title.blur(updateUrl);$(document).bind('uploadTitleUpdate',updateUrl);updateUrl();});}).addClass('inited');$('textarea',$form).autogrow().blur(function(){$(this).trigger('onFormSizeChanged');});$form.throbberform().submit(function(){if($form.valid()){if(isOldSchool){if(fileSelectOk()){$form.find('input:file:visible').each(function(){var $file=$(this).addClass('aural');if($file.is(':blank')){$file.parents('li:first').remove();}else{$('<span class="loading">'+$file.val()+'</span>').insertAfter($file);}}).end().find('span.remove-set').hide();return true;}else{return false;}}else{if(isUploading()){$('<div class="hint auto-submit notification">Your upload will be saved automatically.<br><a href="#edit">Add some changes</a></div>').prependTo($form).siblings('#reorder, .content-item, #sharing-mode').hide().end();$submit.addClass('submited').throb(true);$.scrollTo($('body:first'));return false;}else{$submit.enable(false);$.leaveMsg(null);return true;}}}else{$(this).trigger('invalid');return false;}}).validate({success:"",onsubmit:false,rules:$.extend(validation.rules,{"track[asset_data]":{required:"#track_asset_data:visible",accept:'mp(3|4(a)?)|aif(f)?|wav(e)?|fla(c)?|m4a|aac|og(g|v|a|x)'},"tracks[][asset_data]":{required:"#tracks_asset_data:visible",accept:'mp(3|4(a)?)|aif(f)?|wav(e)?|fla(c)?|m4a|aac|og(g|v|a|x)'},"email":{required:"#email:visible",email:true,rangelength:[3,100]},"user[terms_of_use]":{required:"#user_terms_of_use:visible"},"track[permalink]":{required:true,rangelength:[1,100],validpermalink:true,remote:"/tracks/unique_permalink?track[id]="+trackId},"playlist[permalink]":{required:true,rangelength:[1,100],validpermalink:true,remote:"/sets/unique_permalink?playlist[id]="+playlistId},"track[title]":{required:true,rangelength:[1,100]},"playlist[title]":{required:true,rangelength:[1,100]},"track[genre]":{rangelength:[0,40]},"playlist[genre]":{rangelength:[0,40]}}),messages:$.extend(validation.messages,{"track[asset_data]":{required:"Please select a file to upload",accept:"We support .mp3, .aiff, .wav, .flac, .aac, and .ogg files. Please select a different file."},"tracks[][asset_data]":{required:"Please select a file to upload",accept:"We support .mp3, .aiff, .wav, .flac, .aac, and .ogg files. Please select a different file."},"email":{required:"Please enter an e-mail address",email:"Please enter a valid e-mail address",rangelength:$.format("Your e-mail should have between {0} and {1} characters")},"playlist[title]":{required:"Please enter a set title",rangelength:$.format("The set title should have between {0} and {1} characters")},"track[permalink]":{remote:"The url is taken, please try another"},"playlist[permalink]":{remote:"The url is taken, please try another"},"tracks[genre]":{rangelength:$.format("The track genre should have between {0} and {1} characters")},"playlist[genre]":{rangelength:$.format("The set genre should have between {0} and {1} characters")},"user[terms_of_use]":{required:"Please read and accept the terms first"}})});if(!isOldSchool){$form.find("input.title").delay(10,function(){this.focus();});}
$('#track_label_id, #playlist_label_id').change(function(ev){var selected=this.options[this.selectedIndex];if(selected.value===""){$('#track_label_name, #playlist_label_name').removeClass('disabled').enable(true).focus().get(0).select();}else{$('#track_label_name, #playlist_label_name').addClass('disabled').enable(false).val(selected.text);}}).each(function(){var $field=$(this);if($field.val()===""){$field.removeAttr("disabled").removeClass("disabled");}});$('#upload-information').appendTo($('#track-asset-data-wrapper'));$('#track-asset-data-wrapper').find('.preparing-form:first').hide();};$('div.auto-submit a').live('click',function(){$('input:submit').removeClass('submited').throb(false);$(this).parents('div.auto-submit:first').siblings(':not(.hidden)').show().end().remove();$('#reorder').show();});$(document).bind('uploadFormReady',initUploadForm);});$(function(){var activeKey,activeFile,uploadFinished=false;var editMode=$('body:first').is('.edit:not(.branded)')||$('#playlists').hasClass('new');var quota=SC.CURRENT_USER&&SC.CURRENT_USER.quota.playlists>0?SC.CURRENT_USER.quota.uploads:1;var $formContainer=$("div.upload-form:first");var $progressHeader=$('#upload-progress-header'),$progressAmount=$('#upload-progress-amount'),$progressBar=$('#upload-progress-bar');var $submit=$formContainer.find('input:submit');var flashVersion=$.flashVersion().major;var unsupported=flashVersion<9||($.browser.opera&&parseFloat($.browser.version)<10)||(flashVersion<11&&(/linux/i).test(navigator.platform));$(document).bind('uploadFormReady',function(){$submit=$formContainer.find('input:submit');});var parseFileName=function(filename){var result;result=filename.replace(/\\/,'').split(/\/|\n/).reverse()[0];result=result.replace(/\.\w{1,4}$/,"").replace(/_/g," ");result=result.replace(/^./,result.match(/^./)[0].toUpperCase());return result;};var fileDomId=function(file){return"uploading-"+Helpers.hash32(file.name)+file.modificationDate;};var startUpload=function(flash){var myflash=flash;$.getJSON('/upload/policy.json',function(policyData){myflash.upload({url:"http://"+policyData.bucket+".s3.amazonaws.com/",fieldName:'file',data:Helpers.objToUrl(policyData)});activeKey=policyData.key;});};var setupPreloaders=function(files,flash){$progressAmount.hide();$('#upload-form-file-container').fadeOut(SC.FX_FAST);$('#upload-progress-info, #upload-progress, div.upload-form').fadeIn(SC.FX_FAST);$progressHeader.html("Preparing to upload...");$submit.addClass('in-progress');if(files.length<2&&!(editMode||uploadFinished)){return;}
var $orderList=$('#reorder ol.positions:first').hide();var $failList=$orderList.siblings('ol.restricted:first');var $template=$('#template ol:first li.uploading:first');var $failTemplate=$template.siblings('li.waiting:first');$.each(files,function(index,file){(index<quota?$template:$failTemplate).clone().addClass('uploading').attr('id',fileDomId(file)).data('file',file).find('input:text:first').val(parseFileName(file.name)).end().find('span.total:first').text(Helpers.toMB(file.size)+"MB").end().appendTo(index<quota?$orderList:$failList);});$orderList.show().sortable('destroy').sortable({axis:'y',cursor:'move'});$('#reorder').show().unbind('onRemoveTrack').bind('onRemoveTrack',function(ev){var $item=$(ev.target).closest('li.uploading');$item.each(function(){flash.removeFile($item.data('file'));if($item.hasClass('active')){startUpload(flash);}
quota=quota+1;});});if(quota-files.length<0){$('#reorder div.violated:first').parent().show();}};var updateProgress=function(file,fileData,uploadData){document.title=uploadData.percentLoaded+"% uploaded - SoundCloud";$progressBar.width(uploadData.percentLoaded+"%");var approxSec=(uploadData.timeLeft>60)?Math.floor(uploadData.timeLeft/60)*60:uploadData.timeLeft;var wordsLeft=(uploadData.percentLoaded>97||approxSec<1?'finishing...':Helpers.sToWords(approxSec)+' left');$progressHeader.html("Uploading... "+wordsLeft);$progressAmount.show().find('span.total:first').html(Helpers.toMB(uploadData.bytesTotal)+"MB").end().find('span.loaded:first').html(Helpers.toMB(uploadData.bytesLoaded)+"MB").end();$('#'+fileDomId(file)).addClass('active').find('div.upload-progress-bar-inner:first').css('width',fileData.percentLoaded+"%").end().find('span.loaded:first').text(Helpers.toMB(fileData.bytesLoaded)+"MB");if($submit.exists()){$submit.val(wordsLeft);}else{$submit=$('input:submit:first');}};var finishFile=function(file,flash){if($('#reorder').exists()){$('#'+fileDomId(file)).removeClass('active').addClass('finished').removeAttr('id').find("input[name='tracks[][uid]']").val(activeKey).end().find("input[name='tracks[][original_filename]']").val(file.name).end().find('div.upload-progress-bar-inner:first').css('width','100%').end().find('span.loaded:first, span.total:first').text(Helpers.toMB(file.size)+"MB").end();$('#reorder ol.positions:first li.uploading:not(.finished)').eq(0).each(function(){startUpload(flash);});}else{$("#track_uid").val(activeKey);$("#track_original_filename").val(file.name);}};var finishQueue=function(){var isPlaylist=$('#reorder').is(':visible');document.title="100% uploaded - SoundCloud";$progressHeader.html('Complete');$progressAmount.html('<a href="#'+$submit.attr('id')+'">Don\'t forget to save</a>').show().find('a').scrollLink({target:$submit,speed:SC.FX_SLOW});$progressBar.width("100%");$submit.val($submit.data('buttonLabel')).enable(true).removeClass('in-progress');if(isPlaylist&&quota>0){$('#reorder').append($('#upload-form-file #upload-btn').addClass('user-action').text('Add more tracks'));}
$('#upload-btn.disabled').removeClass('disabled');$.leaveMsg("Your upload will be lost if you don't save your upload.");$submit.parents('form:first').addClass('uploaded').end().filter('.submited').each(function(){$.leaveMsg(null);$submit.parents('form:first').submit();});};$('#upload-btn').click(function(){$('#basic-uploader-link').click();return false;}).toggleClass('unsupported',unsupported).not('.disabled, .unsupported').uploader({typeFilter:$.uploader.fileFilters.audio,multiple:quota>1&&$('#reorder').exists()}).bind('onAllSelect',function(ev,flash,upload){var files=upload[0];var fileCount=files.length;if(!editMode&&!uploadFinished){if(fileCount>1){var formPartialUrl=$formContainer.find('a.playlist').attr('href');$formContainer.find('form:first').hide();setTimeout(function(){$.scAjax({url:formPartialUrl,type:'show',callback:function(response){if($.browser.msie){$formContainer.prepend(response);}else{$formContainer.html(response);}
$('form.upload:first input:submit').addClass('in-progress');$('#reorder').prependTo($("form.upload:first"));$(document).trigger('uploadFormReady');if(uploadFinished){finishQueue();}}});},100);}else{$('#playlist-form').addClass('upload');$('#upload-btn').addClass('disabled');$('#track_title').val(parseFileName(files[0].name));$(document).trigger('uploadTitleUpdate');$('#reorder').remove();$(document).trigger('uploadFormReady');}}
setupPreloaders(files,flash);if(fileCount>quota){for(var i=quota,l=fileCount;i<l;i=i+1){flash.removeFile(files[i]);}
quota=Math.max(0,quota-files.length);}
startUpload(flash);$.leaveMsg('Your upload will be cancelled if you leave this page.');}).bind('onComplete',function(ev,flash,upload){finishFile(upload[0],flash);}).bind('onError',function(ev,flash,upload){var file=upload[0],errorType=upload[1],errorStatus=upload[2];if(errorType==="httpStatus"&&(errorStatus>200&&errorStatus<300)){finishFile(file,flash);}else{if(errorType==='ioError'||errorType==='securityError'){Helpers.notice("Oops, the upload was interrupted, trying again in 30 seconds.");$progressHeader.html('There was an error while uploading. Waiting to retry...');setTimeout(function(){startUpload(flash);},30000);}
$.post('/errors/swfupload',$.extend(file,$.flashVersion(),{uid:activeKey,resource:$('#reorder').exists()?'playlist':'track',user:SC.USER,current:SC.CURRENT_USER.permalink,quota:quota,error:errorType,message:errorStatus}));}}).bind('onProgress',function(ev,flash,upload){updateProgress(upload[0],upload[1],upload[2]);}).bind('onAllComplete',function(ev,flash,upload){uploadFinished=true;finishQueue();});$('#basic-uploader-link').click(function(){if($(this).hasClass("disabled")){return false;}
var playlistFormlUrl=$formContainer.find('a.playlist').attr('href');var isTrack=true;$('#upload-form-file').add('#upload-information span.old-school:first').hide();$('#upload-btn').hide();$(document).trigger('onUploaderUpdate');$formContainer.removeClass("hidden").addClass('basic-upload');$('form.upload:first').find('input:submit').end().slideDown('slow');$('#track_asset_data, #track-asset-data-wrapper').show().find('input:file:first').change(function(ev){if($(ev.target).parents('form:first').validate().element(ev.target)){$('#track_title').val(parseFileName($(ev.target).val()));$(document).trigger('uploadTitleUpdate');}}).end().find('a.add-file').click(function(ev){var $link=$(ev.target),$list=$link.siblings('ol:first'),$files=$list.find('input:file');if($files.size()<quota){if(isTrack){$files.attr('name','tracks[][asset_data]').addClass('disabled').enable(false);$.scAjax({url:playlistFormlUrl,type:'show',callback:function(response){$formContainer.prepend($(response).prepend($('#track-asset-data-wrapper')));$('#new_track').hide();$(document).trigger('uploadFormReady');$list.find('input:file').removeClass('disabled').enable(true);}});}
isTrack=false;$list.find('li:first').find('span.remove-set').show().end().clone().find('input:file:first').val('').attr('id','track_asset_data'+$files.size()).end().appendTo($list);}else{Helpers.notice("If you want to upload more files, you'll have to upgrade to a PRO account.");}
return false;});$(document).trigger('uploadFormReady');$('span.remove-set').live('click',function(ev){var $item=$(ev.target).parents('li:first');if($item.siblings('li').size()===1){$item.siblings('li:first').find('span.remove-set:first').hide();}
$item.remove();return false;});});$("#track-edit-form, #playlist-form").trigger('uploadFormReady');if(/old-skool/.test(window.location.hash)){$('#basic-uploader-link').click();}else{$('#upload-form-file-container').show();$(document).trigger('onUploaderUpdate');}});$(function(){var saveSettings=function(){$('form#user-notification').ajaxSubmit({success:function(response){Helpers.notice('Your notification settings were updated');}});};var selectField=function($cells){$cells.find('input').selected(true).end().addClass('selected').siblings('td:not(.label)').removeClass('selected');if($cells.parents('table').find('input:checked[value=digest]').length){$('#digest-frequency').slideDown('slow','easeOutQuad');}else{$('#digest-frequency').slideUp('slow','easeOutQuad');}
$cells.parents('tbody').find('tr th').removeClass('selected');saveSettings();return $cells;};$('form#user-notification').each(function(){$(this).click(function(e){var $target=$(e.target);if($target.is('td:has(input)')){selectField($target);}else if($target.is('th')){var col=$target.prevAll().length;selectField($target.parents('tbody').find('td:has(input):nth-child('+(col+1)+')'));$target.addClass('selected');}else if($target.is('select')){}});$('#user-notification select').live('change',function(){saveSettings();});});});$(function(){$('a.add-to-set').live('click',function(ev){var $link=$(ev.target).parent();var $panel=$link.siblings(".sets-list:first");$.pulldown($link,{node:$panel,callback:function($pulldown){$pulldown.find('div.new-set > a.create-set').unbind('click').bind('click',function(ev){if($(ev.target).parents(".new-set").hasClass("disabled")){return false;}
$.pulldownHide();$.zoomable(ev,{callback:function($container){function successFunction(response){var resp=Helpers.json(response);Helpers.notice("Your track has been added to the set '"+resp.playlist.title+"'");$link.removeClass('active');var $currentList=$panel.find('ul:first');$("<li><a class='update-set remove-set' href='"+resp.url+"'>Remove from set '"+resp.playlist.title+"'</a></li>").appendTo($currentList);$('#tracks ul.tracks-list div.sets-list > ul').not($currentList).append("<li><a class='update-set' href='"+resp.url.replace(/listings.*/,'listings')+"'>Add to set '"+resp.playlist.title+"'</a></li>");if($('#tracks ul.tracks-list .new-set .restriction').length!==0&&$("#tracks ul.tracks-list li:first div.sets-list li").length>=3){$('#tracks ul.tracks-list .new-set').addClass("disabled");}
$.closeZoomScreen();}
$container.find('.set-form:first').removeClass('hidden');var $form=$container.find('form:first');$form.ajaxForm({type:'POST',resetForm:true,success:successFunction,beforeSend:SC.xhr.json,beforeSubmit:function(){return $form.valid();}}).validate({success:'',rules:{"playlist[title]":{required:true,rangelength:[1,100]}}});$form.find('input:visible:first').focus();}});return false;}).end().find('a.update-set').unbind('click').bind('click',function(ev){var $element=$(ev.target).throb(true),track_id=Helpers.getId($panel),method="create",text="Remove from set ':title'";if($element.hasClass("remove-set")){method="destroy";text="Add to set ':title'";}
$.scAjax({url:$element.attr("href"),type:method,accept:"application/json",data:{"listing[track_id]":track_id},callback:function(response){var resp=Helpers.json(response);$element.throb(false);$link.removeClass('active');$panel.find('a[href='+$element.attr("href")+']').toggleClass("remove-set").attr("href",resp.url).text(text.replace(/:title/,resp.playlist.title));Helpers.notice("Your track has been "+
($element.hasClass("remove-set")?"added to":"removed from")+" the set '"+
resp.playlist.title+"'");$.pulldownHide();}});return false;}).end();}});return false;});var activateTrack=function($itemPlayer){var id=$itemPlayer[0].id.replace(/players/,'listing');$itemPlayer.parents('.set:first').find('ol.tracks:first li').each(function(){this.className=this.className.replace(/playing|paused/,'');if(this.id===id){$(this).addClass('playing');}});};$('.set a.delete').live('click',function(){var $link=$(this);$.dialog($link,{headline:"Do you really want to delete this set?",throb:true,center:true,ok:function(){if($link.parents('li.set:first').exists()){$link.parents("li.set").slideUp(SC.FX_SLOW,'easeOutExpo');$("#nav span.playlists-count:first, #main-content-inner h1:first").increment(-1);$.dialogRemove();$.scAjax({url:$link.attr('href'),type:'destroy',accept:'soundcloud/json',callback:function(responseBody){Helpers.notice(Helpers.json(responseBody).flash.notice);}});}else{Helpers.linkToForm($link.attr('href'),'delete').submit();}}});return false;});$('ol.tracks li').live('click',function(ev){if(Helpers.isNormalClick(ev)){if(/download|gothere/.test(ev.target.className)){return true;}else{Helpers.getPlayer(this)[(new RegExp("paused|playing")).test(this.className)?'playPause':'play'](1);return false;}}});$('ol.players li').live('onPlay',function(ev){var $item=$(this);$item.find('div.loading-track:first').remove().end().fadeIn(1000).siblings().hide();activateTrack($item);}).live('onStop onFinish',function(ev){$('ol.tracks:first .playing').removeClass('playing').addClass('paused');}).live('onPlayerLoadStart',function(ev){var $item=$(this);$item.find('div.loading-track:first').remove().end().append('<div class="loading loading-track"><span>Loading Track</div></span>').show().siblings().hide();activateTrack($item);});$("body#playlists").filter(".edit, .new").each(function(){var checkForPrivate=function(){$('#playlist-form span.playlist-share:first').toggle($('span.private',$('#reorder ol:first')).exists());};$(document).bind('onRemoveTrack',checkForPrivate);var $positions=$("ol.positions:first").sortable({axis:'y',cursor:'move',cancel:'div.editable'});$('a#add-existing-track').tracksSelector({beforeDisplay:function($list){return $list.filter('li:not(.dropped)');},onConfirm:function($selection){$selection.appendTo($('#reorder ol:first'));if($('#available-tracks li').size()===0){$('#add-existing-track').parents('.add-to-set:first').addClass('no-add');}
$positions.sortable("refresh");checkForPrivate();$(document).trigger('onUploaderUpdate').trigger("onTrackListChange");$.closeZoomScreen();}});if($("#playlist_label_id").val().trim()===""){$("#playlist_label_name").removeAttr("disabled").removeClass("disabled");}
$("#playlist_label_id").change(function(){var selected=this.options[this.selectedIndex];if(selected.value===""){$("#playlist_label_name").removeAttr("disabled").removeClass("disabled").focus().get(0).select();}else{$("#playlist_label_name").attr("disabled",true).addClass("disabled").val(selected.text);}});$("#playlist-form").validate({success:"",rules:SC.metaInfoValidationRules("playlist","set").rules});}).end().filter(".show").each(function(){$("#side-content li.action-cancel:first a").dialog({headline:"Do you really want to delete this set?",throb:true,ok:function(){Helpers.linkToForm(this.attr('href'),'delete').submit();}});var playlistPath=$('#main-content-inner a.delete').attr('href');$("#set-description-value.editable").editableDescription({path:playlistPath,name:'playlist[description]',minHeight:150});$('h1 em.editable').editableField({path:playlistPath,name:'playlist[title]',title:'Click to change the set title'});$('div.genre-privacy span.editable').editableField({path:playlistPath,maxLength:40,name:'playlist[genre]',title:'Click to change the set genre'});$('div.description h4.editable').editableField({path:playlistPath,name:'playlist[tag_list]',title:'Click to change the set tags'});});$('#reorder').each(function(){$('a.remove-set').live('click',function(ev){$(ev.target).parents('li:first').slideUp(SC.FX_MEDIUM,function(){$(this).filter('.uploading').each(function(){$('#add-existing-track').parents('.no-add:first').removeClass('no-add');}).end().trigger('onRemoveTrack').remove();$(document).trigger('onUploaderUpdate').trigger('onTrackListChange');});return false;});$('#reorder li div.title:not(.editable)').live('mouseover',function(){var $node=$(this);$node.addClass('editable').editableField({path:$node.siblings('a.path:first').attr('href'),name:'track[title]',maxLength:200,title:'Click to change the track title'});});});var initialize_tristate_check_boxes=function(){$('body#playlists input.tristate-check-box:not(.initialized)').each(function(){var that=this;(function(){var $visible_check_box=$(that);$visible_check_box.addClass('initialized');var id=$visible_check_box.attr('id');var $check_box_false=$('#'+id+'_false');var privacy_attribute_key=id.split('playlist_')[1];var true_value=$visible_check_box.attr('value');var false_value=$check_box_false.attr('value');var update_check_box;var $indeterminate_hack;var $check_boxes;var aggregated_value_for_check_boxes=function($check_boxes){var aggregated_value=($check_boxes[0].value===true_value?true:false);$check_boxes.each(function(){if(aggregated_value!==(this.value===true_value?true:false)){aggregated_value=null;}});return aggregated_value;};var set_visible_check_box=function(value){if(value===null){$visible_check_box[0].indeterminate=true;$visible_check_box[0].was_indeterminate=true;$indeterminate_hack.css("display",null);$visible_check_box.attr('checked',false);$check_box_false.attr('checked',false);}else{$visible_check_box[0].indeterminate=false;$visible_check_box[0].was_indeterminate=false;$indeterminate_hack.hide();$visible_check_box.attr('checked',value);$check_box_false.attr('checked',!value);}};var visible_check_box_on_click=function(){if($visible_check_box.attr('disabled')){return;}
if($visible_check_box[0].was_indeterminate){$('<div class="hint hidden tristate-checkbox-warning">All tracks of this set will be changed. <a href="#" class="tiny link-button">Revert to original state</a></div>').insertAfter($visible_check_box.parent().parent()).slideDown().find('a').click(function(){$("input[name='tracks[]["+privacy_attribute_key+"]']").each(function(){this.value=this.defaultValue;});update_check_box();$(this).parent().slideUp(function(){$(this).remove();});return false;});set_visible_check_box(true);}
var is_checked=$visible_check_box.is(':checked');$check_box_false.attr('checked',!is_checked);$check_boxes=$("form#playlist-form input[name='tracks[]["+privacy_attribute_key+"]']");$check_boxes.attr("value",(is_checked?true_value:false_value));};update_check_box=function(){$check_boxes=$("form#playlist-form input[name='tracks[]["+privacy_attribute_key+"]']");if($check_boxes.length!==0){var aggregated_value=aggregated_value_for_check_boxes($check_boxes);set_visible_check_box(aggregated_value);}else{}};$visible_check_box.click(visible_check_box_on_click);if($.browser.mozilla&&parseInt($.browser.version.replace(/\./g,'').substr(0,3),10)<=191){$indeterminate_hack=$('<span id="'+id+'_indeterminate_hack" style="display: none;" class="tristate-checkbox-indeterminate-hack">&ndash;</span>').insertAfter($visible_check_box);$indeterminate_hack.click(visible_check_box_on_click);}else{$indeterminate_hack=$([]);}
$(document).bind("onTrackListChange",update_check_box);update_check_box();})();});};initialize_tristate_check_boxes();$(document).bind('onContentLoaded',initialize_tristate_check_boxes);});$(function(){$('#license a.icon-button').live('click',function(){var $link=$(this);var active=$link.hasClass('active');if(active){$('#license-chooser').slideUp(SC.FX_MEDIUM);$link.removeClass('active').text('Change License');}else{$('#license-chooser').slideDown(SC.FX_MEDIUM);$link.addClass('active').text('Hide this');}
return false;});$('#license input:radio').live('click',function(){$(this).parents('li').addClass('active').siblings('.active').removeClass();$('#creative-commons .cc-options:first')[(this.id==="license-cc")?"slideDown":"slideUp"](SC.FX_MEDIUM);});$('#license input:checkbox').live('click',function(){var $selector=$(this);var isChecked=$selector.is(':checked');$selector.siblings('label').toggleClass('active',isChecked);if(isChecked){if(this.id==="license-no-derivatives"){$('#license-share-alike:checked').selected(false).siblings('label').removeClass('active');}
if(this.id==="license-share-alike"){$('#license-no-derivatives:checked').selected(false).siblings('label').removeClass('active');}}
var ccClassName="cc-by";$('#creative-commons input:checkbox:checked').each(function(){ccClassName=ccClassName+"-"+$(this).parents('li:first').attr('class');});$('#creative-commons div.status:first a:first').each(function(){$(this).removeClass().addClass("cc").addClass(ccClassName).attr('href',this.href.replace(/by.*\/3/,ccClassName.replace('cc-','')+'/3'));});});$('#license input').live('click',function(){var $title=$('#license span.license-name:first strong').empty();if(/-rights/.test(this.id)){$title.text($.trim($(this).siblings('label').text()));}else{$('#creative-commons div.status:first a:first').clone().appendTo($title);}}).filter(':checked').click();$('#license form:first').ajaxForm({type:'PUT',success:function(response){Helpers.notice("Your default license was changed!");}});});$(function(){$("body#dropbox, body#upload").filter(".done, .resend").each(function(){$("#dropbox-change-address").validate({success:"",rules:{"email":{required:true,email:true,rangelength:[3,100]}},messages:{"email":{required:"Please enter an e-mail address",rangelength:$.format("Your e-mail should have between {0} and {1} characters"),email:"Please enter a valid e-mail address"}}});$("div.main-information input").click(function(){$(this).blur();$("ul.bullet").slideToggle();return false;});}).end().filter(".confirm").each(function(){$('#settings-form').SCValidate({"user[email]":"email","user[password]":"password","user[password_confirmation]":"passwordConfirmation","user[username]":"username"});$("#user_username").focus();}).end().filter('.edit').each(function(){function initUploadButton(){var $btn=$(this),uploadUrl='/upload/background',maxSize=1024*1024*5;$btn.parents('div:first').bind('upload',function(ev,data){var $kind=$(ev.target);if($kind.is('.db-image-headerbg')){$('div.branded-header-background-image').css('background-image','url('+data.url+')');}else if($kind.is('.db-image-bodybg')){$('body').css('background-image','url('+data.url+')');}else if($kind.is('.db-image-logo')){$('div.branded-header-image').css('background-image','url('+data.logo_url+')');}
$kind.find('span.placeholder').css('background-image','url('+data.preview_url+')').end().find('input:first').val(data.id).end();if(data.id){$kind.find('a.remove').removeClass('hidden').fadeIn().end();}
$(document).trigger('onUploaderUpdate');}).find('a.remove').click(function(ev){$(ev.target).fadeOut(function(){$(this).addClass('hidden');}).parents('div:first').trigger('upload',{id:'',url:'',logo_url:'',preview_url:''});return false;});$btn.uploader({multiple:false,typeFilter:$.uploader.fileFilters.images}).bind('onAllSelect',function(ev,flash,upload){if(upload[1].bytesTotal>maxSize){Helpers.notice('The file is too big, it has to be less than '+Helpers.toMB(maxSize)+'MB');}else{flash.upload({url:uploadUrl});}}).bind('onComplete',function(ev,flash,upload){var res=Helpers.json(upload[1]);Helpers.waitForImage(res.url,function(){Helpers.waitForImage(res.logo_url,function(){Helpers.waitForImage(res.preview_url,function(){$btn.parents('div:first').trigger('upload',res);});});});}).bind('onError',function(ev,flash,upload){Helpers.notice("Could not upload the image, please try again with a different image");});$btn.wrap('<span style="position:relative; display: block; float: left"></span>').click(function(){return false;});}
$('a.bd-customize-link:first').click(function(ev){$(this).fadeOut();$('#content').children().hide();$('#branded-dropbox-edit-form').slideDown(SC.FX_MEDIUM,function(){$('div.branded-header-image').slideDown(SC.FX_MEDIUM);$('a.background-upload').each(initUploadButton);});});if(/edit/.test(window.location.hash)){$('a.bd-customize-link:first').click();}
var initCustomizationGui=function(){var $form=$('#branded-dropbox-edit-form');var $picker=$('div.db-color-picker:first',$form).farbtastic(function(color){$form.find('div.db-color-inputs:first div.active:first input').css({backgroundColor:color}).val(color).trigger('change');},{radius:84,square:100,width:194});$form.find('div.db-color-headerbg input:text').change(function(ev){$('div.branded-header-background-image:first').css({backgroundColor:$(ev.target).val()});}).end().find('div.db-color-font input:text').change(function(ev){$('div.branded-header:first').find('*[class!=user-action]').css({color:$(ev.target).val()});}).end().find('div.db-color-bodybg input:text').change(function(ev){$('body:first').css({backgroundColor:$(ev.target).val()});}).end().find('div.db-font-family:first select:first').change(function(ev){$('div.branded-header:first div.branded-header-intro *').css({fontFamily:$(ev.target).val()||'"Interstate",interstate-regular,"Lucida Grande",Helvetica,Arial,sans-serif'});}).end().find('div.db-headline:first input:text:first').keyup(function(ev){$('div.branded-header:first h1:first').text($(ev.target).val());}).end().find('div.db-text:first textarea:first').keyup(function(ev){$('div.branded-header:first div.branded-header-intro div:first').html($(ev.target).val().replace(/\n/g,'<br/>'));}).end().find('div.db-color-inputs:first input:text').focus(function(ev){var $bar=$(ev.target).parent().addClass('active').siblings().removeClass('active').end();$.farbtastic($picker.removeClass('first last')).setColor($(ev.target).val());if($bar.is(':first-child')){$picker.addClass('first');}else if($bar.is(':last-child')){$picker.addClass('last');}}).keyup(function(ev){$.farbtastic($picker).setColor($(ev.target).val());}).eq(0).focus().end().end();};Helpers.require(SC.asset_url('/javascripts/vendor/farbtastic.js'),function(){return!!$.fn.farbtastic;},function(){initCustomizationGui();});});$('body#dropbox, body#groups, body#users').each(function(){var addSelectionToForm=function($selection){var showPath=$selection.find("a.show-track").attr('href');$('form#new_track').attr('action',$('a#existing-track-action').attr('href'));$.scAjax({url:showPath,callback:function(partial){$('#track-asset-data-wrapper').siblings('.content-item').hide().find('input, textarea, select').enable(false).end().end().after(partial).parents('div.upload-form:first').show();$('#upload-form-file-container').hide();SC.playerManager.add($('#track-asset-data-wrapper div.player'));$(document).trigger('onAllSelect');$(document).trigger('onUploaderUpdate');}});};$(document).bind('onAllSelect',function(){$('#contribute-title').show();});$('#add-existing-track').tracksSelector({beforeDisplay:function($selection){$selection.filter('li.dropped').attr('title','This track is already sent.');return $selection;},onSelect:function($selection,ev){if($selection.hasClass('dropped')){Helpers.notice('You\'ve already send this track. Please select another one!');return;}
$.closeZoomScreen();addSelectionToForm($selection);}});$('#edit-track-info').live('click',function(){var $link=$(this).throb(true);$.scAjax({url:this.href,callback:function(partial){$('#track-asset-data-wrapper').siblings('.content-item').remove();$link.after(partial);$link.hide();$(document).trigger('uploadFormReady');}});return false;});$('form.upload a.cancel').live('click',function(){window.location.reload();});});});$(function(){var username=function(id){return id?id.substring(id.indexOf('-')+1).trim():'';};var updateCounts=function(){var woacc,wacc;$('#without-access ul.permission-user-list').each(function(){woacc=$('li',this).not('.selected').length;$(this).siblings('div.access-status:first').find('abbr:first').text(woacc);});wacc=$('#with-access li').length;$('#with-access div.access-status').find('abbr:first').text(wacc).end();$(document).trigger('onListUpdated');};var shareToUser=function($original){var shareQuota=SC.CURRENT_USER.quota.sharings_per_track;var total=$original.length;if($('#with-access li').length+total<=shareQuota){var $shared=$original.clone().find('input:checkbox').selected(true).end().each(function(){this.id=this.id.replace(/[a-z]*-/,'shared-');if($.browser.msie&&($.browser.version<8)){this.innerHTML=this.innerHTML;}})
[total===1?'hide':'show']().prependTo('#with-access ul');if(total===1){$shared.fadeIn('fast');}
$original.each(function(){var usr=username(this.id);$('#contact-'+usr+', #fan-'+usr+', #group-'+usr).addClass('selected hidden');});updateCounts();return $shared;}else{Helpers.notice('With a free account, you\'re able to share a track to a maximum of '+shareQuota+' contacts');return null;}};$('#without-access ul.permission-user-list').live('click',function(ev){var $badge=$(ev.target).closest('li');$badge.each(function(){shareToUser($badge);});return false;});$('#with-access ul.permission-user-list').live('click',function(ev){var $badge=$(ev.target).closest('li');$badge.each(function(){var usr=username(this.id);var shouldBeVisible=$('#type-ahead-search').is('.blank')||new RegExp('^'+$('#type-ahead-search').val().trim().toLowerCase()).test(usr);$(this).remove();$('#contact-'+usr+', #fan-'+usr+', #group-'+usr).removeClass('selected')
[shouldBeVisible?'removeClass':'addClass']('hidden');setTimeout(updateCounts,10);});return false;});$('input.select-all').live('click',function(){shareToUser($(this).parents('div.pane:first').find('ul:first > li:visible'));return false;});$('#remove-all').live('click',function(){$('#with-access ul.permission-user-list').empty();$('#without-access li.selected').removeClass('selected hidden');updateCounts();return false;});$('ul.permission-user-list').lazyAvatars({badgesPerPage:38,badgeHeight:21,cols:2});$('#type-ahead-search').typeahead({collection:'#without-access ul.permission-user-list, #with-access ul.permission-user-list',filterPrefixString:'^(contact|fan|group)-',update:function($lists){$(document).trigger('onListUpdated');}});$('#contacts-tab a, #fans-tab a').live('click',function(event){$($(this).attr('href').replace(/.*#/,'#')).prepend($('#type-ahead-search'));});$('#add-emails').live('click',function(){var $badge;var $badgeTemplate=$('#email-badge-template li:first');$.each($('#emails').val().trim().split(/[,; ]+/),function(i,email){email=email.toLowerCase();if(Helpers.validateEmail(email)){$badge=$badgeTemplate.clone().removeClass('hidden').addClass('unknown').attr('id','contact-'+email.replace(/\W/g,'_')).find('p').html(email).end().find('input:checkbox').val(email).attr('checked',false).end().addClass('shared');shareToUser($badge);}});updateCounts();$('#emails').val('');return false;}).siblings('a').live('click',function(){$('#emails').val('');return false;});$('div.privacy-level-button').live('click',function(ev){var $btn=$(this);var $privatePane=$('div.private-sharing:first');$btn.addClass('selected').find('input:radio').selected(true).end().siblings('.privacy-level-button').removeClass('selected');if(/private/.test(this.className)){$.replaceLink($privatePane.find('a.placeholder:first'),{target:$privatePane,callback:function(){$('div.private-sharing:first').hide().removeClass('hidden').slideDown(SC.FX_MEDIUM);}});$privatePane.fadeIn(SC.FX_MEDIUM);}else{$privatePane.slideUp(SC.FX_MEDIUM);}}).find('input:radio:checked').click();$('#public-info-link, #private-info-link').live('click',function(){var self=$(this);if(!self.data('sc.last')){self.data('sc.last','(Hide explanation text)');}
self.parents('div.privacy-level-button').find('> p').slideToggle('fast');var saveText=self.text();self.text(self.data('sc.last'));self.data('sc.last',saveText);return false;});$("p.explain-download-options:first a").live('click',function(){this.blur();$("div.modal-fade:first").show();return false;});var updateSecretUrl=function(){$('#secret-url-container').each(function(index){var $field=$("#secret-url-container input:text"),original=$field.metadata().original,fieldVal=$field.val(),streamToken=$("input#track_secret_token").val(),mediaPermalink=$('#track_permalink, #playlist_permalink').val();if(!mediaPermalink){mediaPermalink=Helpers.permalize($('#track_title, #playlist_title').val());$('#edit-url').text(mediaPermalink);$('#track_permalink, #playlist_permalink').each(function(){var $title=$(this);$title.val(mediaPermalink);$title.closest('form').validate().element($title);});}
var SECRET_PREFIX="s:";var secretUrl=$('#permalink-path').text().trim()+$('#track_permalink, #playlist_permalink').val()+"/"+SECRET_PREFIX+streamToken;$field.val(secretUrl);$("#secret-url-changed")[original===$field.val()?'hide':'slideDown']();});};$("#secret_url_display").liveautoselect();var resetSecretUrl=function(){var $token=$("#track_secret_token");$token.val(Helpers.randomString(5,$token.val()));updateSecretUrl();};$("#reset_secret_url").live("click",function(){var $link=$(this);if($link.hasClass('reseted')||$("#secret-url-container input:text").metadata().original===""){resetSecretUrl();}else{$.dialog($link,{headline:"Updating the Secret URL will deactivate the existing one",cancelLabel:"Cancel",center:true,ok:function(){resetSecretUrl();$.dialogRemove();}});}
$link.addClass('reseted');return false;});$("input#secret_url").live("click",function(){var enabled=$(this).is(":checked"),$urlContainer=$("#secret-url-container");if(enabled){updateSecretUrl();$urlContainer.slideDown();}else{$urlContainer.slideUp();}});$(document).bind('onUrlChange',function(event){updateSecretUrl();});$(document).bind('submit',function(){$("#with-access    ul").find("input:checkbox").selected(true);$("#without-access input:checkbox").selected(false);$('#add-emails').click();});});$(function(){$('.inline-help, .inline-hint').live('click',function(event){var $scope=$(this);$.dialog($scope,{headline:$scope.find('strong.headline').text().trim(),copy:$scope.find('span.content:first').clone(true).removeClass('hidden'),specialClass:'help',center:true,buttons:false},event);return false;});});$(function(){$('body.groups:first #contact-groups-list').each(function(){var $groupsList=$('> ul:visible:first',this);if(!$groupsList.exists()){$groupsList=$('<ul></ul>').insertAfter($('h3',this)).hide();}
var $contactsList=$('#contacts-list > ul:first');var $newGroupForm=$('form:first',this).hide();var $groupBadgeTemplate=$groupsList.siblings('.template').find('> li:first');var defaultTitle=$newGroupForm.find('input:first').val();var resetGroupForm=function(){$newGroupForm.find('input:submit').throb(false).end().find('input:text').val(defaultTitle).end().hide().siblings('button').throb(false).fadeIn('fast');};var updateGroupContactCount=function(){$groupsList.find('li.active').find('abbr').text($contactsList.find('li.active:first ul:first li').not('.removed').size());};var switchGroup=function(group){$(group).siblings('li.active').removeClass('active').end().addClass('active').trigger('onSwitchGroup');};$('#add-contact-group').click(function(ev){$newGroupForm.show('fast',function(){$(this).find('input:text').trigger('select');});$(ev.target).hide();});$('#contact-groups-list li').live('click',function(ev){switchGroup($(this));return false;});$('#contact-groups-list a.remove').live('click',function(ev){var $groupBadge=$(ev.target).parents('li:first');$.dialog(ev.target,{headline:"Do you really want to delete the contact list '"+$groupBadge.find('a.group-link:first').text()+"'?",copy:"This will only remove the list, it won't affect who you follow or who's following you",center:true,ok:function(){$.dialogRemove();$groupBadge.addClass('removed').trigger('onRemoveGroup').hide('fast',function(){$(this).remove();}).filter('.active').each(function(){switchGroup($groupBadge.siblings().eq(0));});$.scAjax({url:ev.target.href,type:'destroy'});}},ev);return false;});$newGroupForm.submit(function(){var newTitle=Helpers.cleanScripts($newGroupForm.find('input:text').val());$.scAjax({url:'/api/contact_groups',type:'create',data:{'contact_group[name]':newTitle},accept:'application/json',callback:function(response,xhr,message){var responseData=Helpers.json(response);$groupsList.trigger('onCreateGroup',{title:responseData.name,location:responseData.uri});},error:function(response,xhr,message){if(newTitle.trim()===""){Helpers.notice("The list needs a name.");$newGroupForm.find('input:text').get(0).select();}else{Helpers.notice("There is already a list with the name "+newTitle+".");}
return;}});return false;}).keydown(function(ev){if(ev.keyCode===27){resetGroupForm();}}).find('a.cancel').click(function(ev){resetGroupForm();return false;});$groupsList.bind('onCreateGroup',function(ev,data){$groupsList.show();var $newBadge=$groupBadgeTemplate.clone().appendTo($groupsList).hide();$newBadge.find('a.group-link:first').text(data.title);var location=data.location.replace(/api\.([^\/]+)\//,"$1/api/");$newBadge.find('a.group-link:first, a.remove').attr('href',location);resetGroupForm();$newBadge.fadeIn("fast");switchGroup($groupsList.find('li:last'));if(data.useSuggested){updateGroupContactCount();}});$('#contacts-list').bind('onRemoveContact',function(ev){updateGroupContactCount();}).bind('onAddContact',function(ev){updateGroupContactCount();});});$('body.groups:first #contacts-list').each(function(){var $contactsList=$(this);var maxContacts=parseInt($("#restriction span.count:first").text(),10);var updateGroupReferences=function(target){var $targetGroup=$(target);var groupContacts=$.map($('ul li[class!=removed] a.user-link',$targetGroup),function(el){return $(el).attr('href').split('/').reverse()[0];});$targetGroup.data('contacts',groupContacts);};var updateContactPicker=function(){var contactRefference=$contactsList.find('ul:first > li.active').data('contacts')||[];var currentFilter=$('#type-ahead-search-contacts').hasClass('blank')?'':$('#type-ahead-search-contacts').val().trim().toLowerCase();var filterRx=new RegExp('^(contact|fan)-'+currentFilter);$('#contacts-add div.pane li').each(function(){$(this).toggleClass('selected',$.inArray($('input:first',this).val(),contactRefference)>=0).toggleClass('hidden',!filterRx.test(this.id));});if($("#restriction").exists()){if($contactsList.find('ul:first li li[class!=removed]').size()>=maxContacts){$('#contacts-add, #restriction').addClass('disabled');}else{$('#contacts-add, #restriction').removeClass('disabled');}}
$(document).trigger('onListUpdated');};var updateContactCount=function(){$('li.active h3 abbr',$contactsList).text($contactsList.find('li.active:first ul:first li').not('.removed').size());updateGroupReferences($('li.active',$contactsList));updateContactPicker();};var groupMemberUri=function($selection){return $("#contact-groups-list li.active div.contact-group-info a").attr("href")+"/members/"+$selection.find("input:first").val();};var removeContact=function(selection){var $selection=$(selection);var url=groupMemberUri($selection);$selection.remove();$contactsList.trigger('onRemoveContact');$.scAjax({url:url,type:'destroy'});};var addContact=function(selection){var $selection=$(selection);var url=groupMemberUri($selection);var $added=$selection.clone().hide().prependTo($contactsList.find('li.active:first ul:first')).fadeIn('fast');$selection.addClass('selected');$.scAjax({url:url,type:'update',accept:'soundcloud/json',error:function(response,xhr,message){if(xhr.status===403){$("#contacts-add, #restriction").addClass("disabled");}else if(xhr.status===422){Helpers.notice($selection.find('a.user-link').text().trim()+" is already in the list "+$('#contact-groups-list li.active a.group-link').text().trim());}
$added.remove();}});$contactsList.trigger('onAddContact');};$('ul.contacts-column li:not(.suggested)').live('mousedown',function(ev){removeContact(this);return false;});$contactsList.bind('onRemoveContact',function(){updateContactCount();}).bind('onAddContact',function(){updateContactCount();});var $getTheList=function(badge){return $('a[href='+$('a.remove',badge).attr('href')+']',$contactsList).parents('li:first');};$('#contact-groups-list ul:first').bind('onSwitchGroup',function(ev){$getTheList(ev.target).addClass('active').each(function(){$(this).siblings('li').removeClass('active').end().find('h3:first').hide().fadeIn('fast');updateContactPicker();});}).bind('onRemoveGroup',function(ev){$getTheList(ev.target).remove();$('ul.tabs a.contacts-count').increment(-1);updateContactPicker();}).bind('onCreateGroup',function(ev,data){var $newList;if(data.useSuggested){$('#create-suggested').remove();$newList=$contactsList.find('li.suggested').removeClass('suggested');}else{$contactsList.find('li.suggested').remove();$newList=$contactsList.find('ul.template li:first').clone().appendTo($contactsList.find('ul:first'));}
$newList.siblings('li').removeClass('active').end().addClass('active').find('h3:first').html(data.title+' (<abbr class="contacts-count"></abbr>)');$('ul.tabs a.contacts-count').increment(1);updateContactCount();$('#contacts-add').show();});$('#contacts-add div.pane li').click(function(){if($('#contacts-add').hasClass("disabled")){Helpers.notice($('#restriction').text().trim());}else{addContact(this);}
return false;});$contactsList.find('ul:first > li').each(function(){updateGroupReferences(this);});updateContactPicker();$('#contacts-add ul').lazyAvatars({badgesPerPage:46,badgeHeight:21,cols:2});$("#create-suggested").submit(function(){$(this).find("input[type=submit]").throb(true);$.scAjax({url:$(this).attr('action'),type:'create',data:$('input',this).serializeArray(),accept:'application/json',callback:function(response,xhr,message){var responseData=Helpers.json(response);$('#contact-groups-list ul:first').trigger('onCreateGroup',{title:responseData.name,location:responseData.uri,useSuggested:true});$('div.hint').remove();}});return false;}).keydown(function(ev){if(ev.keyCode===SC.ENTER_KEY){$(this).submit();return false;}});$("#create-suggested button").click(function(){$("#suggested-group-name").show().find('input:text')[0].select();$(this).hide();return false;});$("#create-suggested a.cancel").click(function(){$("#suggested-group-name").hide();$('#create-suggested button').show();});$('#type-ahead-search-contacts').typeahead({collection:'#contacts-pane ul:first, #fans-pane ul:first',filterPrefixString:'^(contact|fan)-'});});});$(function(){function initArtworkUploader(){$('#artwork-upload').each(function(){var $upload=$(this);var $mainSubmit=$upload.parents('form').find('input:submit');var $uploadButton=$('#artwork-upload-btn');var maxSize=1024*1024*5;var uploadUrl='/artworks';$uploadButton.uploader({multiple:false,typeFilter:$.uploader.fileFilters.images,maxFileSize:1024*1024*5}).bind('onAllSelect',function(ev,flash,upload){flash.upload({url:uploadUrl});$mainSubmit.enable(false);}).bind('onComplete',function(ev,flash,upload){var result=Helpers.json(upload[1]);var $container=$upload.find('span.artwork-container').removeClass('hidden').addClass('loading artwork');Helpers.waitForImage(result.badge_url,function(){$('#artwork-uid').val(result.uid);$container.css({background:'url('+result.badge_url+')'}).removeClass('loading').end().find('.artwork-shown').show().end().find('.artwork-hidden').hide().end();});$mainSubmit.enable(true);}).bind('onError',function(ev,flash,upload){Helpers.notice("Could not upload the artwork, please try again");$mainSubmit.enable(true);});$('a.remove',$upload).click(function(){$('#artwork-uid').val("--removed--");$upload.find('.artwork-container, .artwork-shown').hide().end().find('.artwork-hidden').show().end();$(document).trigger('onUploaderUpdate');return false;});});}
initArtworkUploader();$(document).bind('uploadFormReady',initArtworkUploader);});$(function(){$('#tour').each(function(){var $screenWrapper=$('#tour-screen-wrapper-inner:first',this),$currentSlide,$sliderNavigation=$('#tour-navigation:first',this),$sliderNext=$('<div class="slide-skip" id="tour-navigation-next">Next</div>').hide().insertAfter($sliderNavigation),$sliderPrev=$('<div class="slide-skip" id="tour-navigation-prev">Previous</div>').hide().insertAfter($sliderNavigation);function scrollToSlide($targetSlide){$screenWrapper.animate({left:-$targetSlide.position().left},400,'easeInOutExpo',function(){var parentContainer=$(this).parent('div').get(0);parentContainer.scrollLeft=parentContainer.scrollTop=0;});$currentSlide=$targetSlide;$sliderNavigation.find('li').removeClass('current before-current');$sliderNavigation.find('li a[href~=#'+$currentSlide.attr('id')+']').parent('li').addClass('current').prev().addClass('before-current');if($currentSlide.prev().exists()){$sliderPrev.fadeIn('slow');}else{$sliderPrev.fadeOut('slow');}
if($currentSlide.next().exists()){$sliderNext.fadeIn('slow');}else{$sliderNext.fadeOut('slow');}}
if($.browser.msie&&$.browser.version<7){$("div.tour-screen img.tour-image-a, div.tour-screen img.tour-image-b, div.tour-screen > img",$screenWrapper).each(function(){this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.src+"', sizingMethod='scale')";this.src='/images/ie/transparent.png';});}
$('#main-wrapper a[href^=#]').click(function(evt){var $targetSlide=$screenWrapper.find($(this).attr('href'));scrollToSlide($targetSlide);evt.preventDefault();});$sliderNext.click(function(){scrollToSlide($currentSlide.next());});$sliderPrev.click(function(){scrollToSlide($currentSlide.prev());});scrollToSlide($screenWrapper.find((window.location.hash||'.tour-screen:first')));});});$(function(){$("body#pages.api-console").each(function(){var uriToId=function(uri){return uri.replace(/[\/\?&=]/g,"_");};$("#uris>option:first").remove();$("ul#resources").find(">li").each(function(i,n){var $this=$(this);$this.attr("id",uriToId($this.find("code.example").text()));$("<option>").attr("value",$this.find("code.example").text()).text($this.find("h3").text()).addClass($this.hasClass("sub")?"sub":"").appendTo($("#uris"));}).end();$("#uris").change(function(){var $this=$(this);$("ul.documentation>li").animate({height:'hide',opacity:'hide'},SC.FX_MEDIUM,'easeInOutExpo');if($this.val()===""){$("ul#resources>li.introduction").animate({height:'show',opacity:'show'},SC.FX_MEDIUM,'easeInOutExpo');}else{$("#uri").val($this.val());var $resource=$("ul#resources>li#"+uriToId($this.val())).animate({height:'show',opacity:'show'},SC.FX_MEDIUM,'easeInOutExpo');var collectionType='';$.each(["users","tracks","comments","playlists","events"],function(){if($resource.hasClass(this)){collectionType=this;}});if(collectionType!==""){$("ul#collections>li#"+collectionType).animate({height:'show',opacity:'show'},SC.FX_MEDIUM,'easeInOutExpo');}}
$this.blur();});$("ul.documentation>li a").click(function(){var $this=$(this);$("#uri").val($this.attr('href'));return false;});$("#call").click(function(ev){var $link=$(ev.target).throb(true);var uri=$("#console input#uri").val();if(uri.substr(0,1)!=="/"){uri="/"+uri;$("#console input#uri").val(uri);}
$.scAjax({url:"/api"+uri+"",type:'show',accept:$("#format").val(),callback:function(responseBody,xhr){responseBody=xhr.responseText;var headers="";$.each(['Date','Status','Content-Type','Content-Length'],function(i){headers+=this+": "+xhr.getResponseHeader(this)+"\n";});$("#console textarea#response-headers").val(headers);$("#console textarea#response-body").val(responseBody.replace(/([,\[\]\{\}])/g,"$1\n"));$link.throb(false);}});});$("#console").submit(function(){$("#call").click();return false;});});});if(window.fluid){$(function(){var inboxCountText=$("#logged-in-badge div.info span.menu a:nth-child(2)").text();if(inboxCountText!==""){var inboxCount=inboxCountText.match(/\((.)\)/)[1];window.fluid.dockBadge=(parseInt(inboxCount,10)===0?"":inboxCount);}
$(document).bind('onTimedComment',function(ev,id){var $currentCommentObj=$('#timestamped-comment-'+id);var $user=$("a.user-image-tiny:first",$currentCommentObj);window.fluid.showGrowlNotification({title:$user.text()+" says",icon:$user.css('background-image').replace(/url\(|\)/g,"").replace(/tiny/,"large"),description:$("div.comment-info:first",$currentCommentObj).text(),priority:1,sticky:false,identifier:"comment",onclick:function(){}});});});}
$(function(){var oldIE=false;var oldSafari=$.browser.safari&&$.browser.version<420;var oldOpera=$.browser.opera&&$.browser.version<9;if(oldIE||oldSafari||oldOpera){$("body:first").prepend("<div id='browser-warning'>Hey, SoundCloud currently works best in <a href='http://firefox.com'>Firefox 3+</a>, <a href='http://www.apple.com/safari/'>Safari 3+</a>, <a href='http://www.opera.com/download'>Opera 9.5+</a> and <a href='http://windowsupdate.microsoft.com'>Internet Explorer 7+</a>. If you can, please take a moment to upgrade to your browser. Thanks for your understanding!</div>");}
if($.flashVersion().major<8){$("body:first").prepend("<div id='browser-warning' class='flash'>Hey, SoundCloud currently needs at least Flash Player 8 to be installed. If you can, please take a moment to upgrade your <a href='http://get.adobe.com/flashplayer/'>Flash Player plugin</a>. Thanks for your understanding!</div>");}});$(function(){$('#volume-control').each(function(){var $slider=$('#volume-control').appendTo('body:first'),$scale=$('#volume-control-scale'),$handle=$('#volume-control-handle'),$button=$('#header a.volume-control-button'),$sliderButton=$slider.find('a.volume-control-button'),scaleHeight=$scale.height()-$handle.height(),scaleY=$scale.position().top;var updateIcon=function(value){$button.add($sliderButton).removeClass('level0 level1 level2 level3').addClass('level'+Math.ceil(value/49));};var updateVolume=function(value){Helpers.setVolume(value);if(SC.playerManager.activePlayer){SC.playerManager.soundManager.setVolume(SC.playerManager.activePlayer.sound.sID,value);}
updateIcon(value);};var updateHandle=function(increment,absolute){var currentVolume=Helpers.getVolume();var newVolume=Math.max(0,Math.min(100,absolute?increment:currentVolume+increment));$handle.css({top:Math.round((scaleY+scaleHeight)-((scaleHeight/100)*newVolume))});if(newVolume!==currentVolume||increment===0){updateVolume(newVolume);}};$handle.draggable({containment:$scale,axis:'y',cursor:'pointer',drag:function(evt,ui){var newVolume=100-Math.round(((ui.position.top-scaleY)/scaleHeight)*100);updateVolume(newVolume);}}).siblings('.volume-plus:first').click(function(ev){updateHandle(10);}).end().siblings('.volume-minus:first').click(function(ev){updateHandle(-10);}).end();$scale.click(function(ev){var value=100-Math.max(0,((ev.pageY-$(ev.target).offset().top)/scaleHeight)*100);updateHandle(value,true);});$button.click(function(evt){var eventType='click.volume';$slider.css({left:'auto',right:20,top:$button.offset().top+2});$(document).unbind(eventType).bind(eventType,function(ev){if(ev.target!==$button[0]&&!$(ev.target).closest('#volume-control').exists()){$(document).unbind(eventType);$sliderButton.click();}});});$sliderButton.click(function(evt){$slider.css({right:'auto',left:'-9000px'});return false;});updateIcon(Helpers.getVolume());updateHandle(0);});});$(function(){var initPrettyDate=function(){$("abbr").filter(".pretty-date").prettyDate().addClass("rendered");};$(document).bind('onContentLoaded',initPrettyDate);initPrettyDate();});(function($){$('#contacts, #contacts-add, #with-access, #without-access, #group-members').live('click',function(ev){$(ev.target).closest('ul.tabs a').filter(function(){return(/#/).test(this.href);}).each(function(){var $link=$(this).blur();var $content=$(this.href.match('#.*')[0]).removeClass('hidden').show().siblings('.pane').hide().end();$link.parent("li").addClass("current").siblings('li').removeClass("current");$.replaceLink($content.find('a.lazy:first'));return false;});}).each(function(){var $container=$(this);var afterReplace=function(){$container.fadeIn(SC.FX_FAST);};var $link=$('a.lazy',$container).filter(function(){return!$(this).parent().is('.hidden');});$.replaceLink($link,{delay:3000,callback:afterReplace});});})(jQuery);$(function(){$("a.share").live('click',function(ev){var $link=$(ev.target).closest('a');var $panel=$link.siblings(".share-code:first");$.pulldown($link,{node:$panel,callback:function($pulldown){$pulldown.find("div.secret-url.enabled input[type=text]").autoselect();$pulldown.find("div.secret-url.enable a").click(function(){$.scAjax({url:this.href,type:'update',callback:function(){$pulldown.find("div.secret-url.enable").slideUp();$pulldown.find("div.secret-url.enabled").slideDown();var $sharing=$link.parents("div.player").find("div.meta-data a.private");var text=$sharing.text($sharing.text()+" and with a secret url");}});});$pulldown.find("div.share-enable").each(function(){$(this).find("a:first").zoomable({callback:function($container){$container.find('.share-enable-warning:first').removeClass('hidden').find('a.user-action').click(function(ev){$.scAjax({url:this.href,type:'update',data:{"track[sharing]":"public","track[streamable]":"true"},callback:function(){$pulldown.find("div.status, div.secret-url").remove();$link.parents("div.player").find("div.meta-data a.private").remove();$("div.share-enable",$panel).remove();$panel.find("div.share-options, div.share-icons").show().end().parents(".player:first").find("a.private").hide();$.closeZoomScreen();$.pulldownHide();Helpers.notice('The track can be shared now.');}});}).focus();}});}).end().find('input.url').autoselect().end();}});return false;});$('div.share-icons a').live('click',function(ev){var $shareLink=$(ev.target);if($shareLink.hasClass('twitter')){window.open('/twitter_proxy.html?url='+encodeURIComponent($shareLink.attr('href')),'_blank');}else if($shareLink.hasClass('blogger')){var showBloggerDialog=function(){Helpers.require(SC.asset_url('/javascripts/classes/blogger.js'),function(){return!!$.blogger;},function(){if($.blogger.authorized){var $form=$('#blogger-form');$.zoomable(ev,{height:parseInt($form.css('height'),10),width:parseInt($form.css('width'),10),src:function(display){var url=$shareLink.attr('href');$form.addClass('return-to-dom').blogger({title:Helpers.getParamInQuery(url,'title').replace(/\+/g,' '),content:$shareLink.parents('.share-code').find('input.url').val(),onReady:function($form){display($form);},onPost:function($form,entryTitle,blogTitle){$.closeZoomScreen();Helpers.notice('The \''+entryTitle+'\' was successfully posted to \''+blogTitle+'\'');}}).unbind('onBloggerError').bind('onBloggerError',function(ev){Helpers.notice("Oops, something went wrong, we couldn't post it.");});},callback:function($zoom){Helpers.setCaretPosition($zoom.find('textarea'),0);}});}else{$.zoomable(ev,{height:150,width:350,src:function(display){var $notification=$('<div style="padding: 15px;"></div>');$notification.append('<h2>Authorization needed</h2>').append('<p>You\'ll need to connect your SoundCloud account with Blogger before you can publish tracks to it.</p>').append('<div class="form-buttons"><input type="button" class="default" value="Go to Authorization" /><a class="cancel">Cancel</a></div>');$notification.find('input:button').click(function(ev){Helpers.setCookie('_share_to_blogger',$shareLink.attr('href'),{expires:1,path:'/'});$.blogger.login();$(this).throb(true);return false;});display($notification);}});}});};showBloggerDialog();}else if($shareLink.hasClass('wordpress')){$.zoomable(ev,{height:parseInt($('#wordpress-form').height(),10),src:function(display){var $form=$('#wordpress-form');$form.find('input').val($shareLink.attr('href')).autoselect().end().find('a.customize-link').click(function(){$shareLink.parents('div.share-code').find('a.customize-player-link:first').click();return false;});$.zoomable.content.dom($form,display);},callback:function($container){$('#short-code').selectNow();}});}else if($shareLink.hasClass('facebook')){FB_RequireFeatures(["XFBML","Connect"],function(){FB.init(window.settings.facebook.app_key,window.settings.facebook.xd_receiver);FB.Connect.showShareDialog(decodeURIComponent(Helpers.getParamInQuery($shareLink.attr('href'),'u')));});}else{window.open($shareLink.attr('href'),"_blank");}
$.pulldownHide();return false;});$('a.customize-player-link').live('click',function(ev){var isPlaylist=/playlist|group/.test(ev.target.href);$(ev.target).throb(true);Helpers.require(SC.asset_url('/javascripts/classes/customize_widget.js'),function(){return!!$.fn.customizeWidget;},function(){$(ev.target).throb(false);$.pulldownHide();$.zoomable(ev,{width:570,height:460,src:$.zoomable.content.loadHtml,callback:function($container){$('.customize-settings:first',$container).each(function(){$(ev.target).customizeWidget($container,isPlaylist);});}});});return false;});var bloggerLink=Helpers.getCookie('_share_to_blogger');if(!window.location.hash&&bloggerLink){var $btn=$('a[href='+bloggerLink+']').click();Helpers.removeCookie('_share_to_blogger');}});$(function(){$("#new_report").live('submit',function(){var $form=$(this);if($form.valid()){$.scAjax({url:$form.attr('action'),type:'create',data:$form.find('select, textarea').serializeArray(),callback:function(response,xhr,message){Helpers.notice("Track reported");$.closeZoomScreen();}});}
return false;}).validate({success:'',rules:{'report[message]':{required:true}},messages:{'report[message]':{required:'Please enter a message'}}});});$(function(){$('body.settings:first').filter('#account').each(function(){$("#password-reset-form").submit(function(){$.scAjax({url:this.action,type:'create',accept:'text/javascript',data:{'username_or_email':SC.CURRENT_USER.permalink},callback:function(response){Helpers.notice(response);$("#password-reset-form input:submit").throb(false);}});return false;});$("#extra-form input").live('click',function(event){$(this).parents('form').ajaxSubmit({success:function(response){Helpers.notice('Your settings were updated!');}});});$("#mute-all-channels").click(function(){$("#mute-all-channels-form").ajaxForm({url:this.href,type:'PUT',success:function(response){Helpers.notice("All email notifications have been turned off, you can turn them back on any time under the 'Email notifications' section");$("#mute-all-channels").throb(false);}}).submit();return false;});$('#delete-user-button').zoomable();}).end().filter('#email').each(function(){$('#additional-options input').live('click',function(event){$(this).parents('form').ajaxSubmit({success:function(response){Helpers.notice('Your newsletter settings were updated');}});});}).end().filter('#extra').each(function(){$("#dropbox-description-form").ajaxForm({type:'PUT',url:this.href,success:function(response){Helpers.notice("Your DropBox description was updated!");}});$('#license input').live('click',function(event){$(this).parents('form').ajaxSubmit({success:function(response){Helpers.notice('Your default license was updated');}});});}).end().filter('#tokens').each(function(){$('#share-via-networks').each(function(){$('form.settings').each(function(){var $form=$(this);var $container=$form.parents('tr');$container.bind('onSettingChanged',function(event){$.each(['tracks','favorites'],function(i,val){$('input:checkbox[name*=post_'+val+']',$container).selected($('td.'+val+' .off',$container).length===0);});$form.ajaxSubmit({beforeSend:SC.xhr.scJson,success:function(response){Helpers.notice("Your network sharing settings were updated");}});event.stopPropagation();});});$('tr:not(.inactive) a.toggle').live('click',function(event){$(this).parent().toggleClass('off').trigger('onSettingChanged');return false;});$('a.edit-text').live('click',function(event){var type=this.className.match(/track|favorite/)[0],$scope=$(this).parents('tr'),$input=$scope.find('input:text[name*=post_'+type+'_message]'),screenName=$scope.find('span.screen-name').text(),staticText=$(this).siblings("div.static-text").html(),network=$input[0].name.replace(/\[.*/,'');$.zoomable(event,{beforeDisplay:function(data){var txt=$input.val();var $form=$(data);$form.find('input:text').val(txt);$form.find('.preview-dynamic-text').text(txt);$form.find('.preview-static-text').html(staticText);$form.find('.preview').attr('class','preview '+network);$form.find('.user-name').text(screenName);return data;},callback:function($container){var $editing=$container.find('input:text').focus();$container.find('form').unbind('submit.edit').bind('submit.edit',function(event){if(!$(this).valid()){return false;}
$input.val($editing.val());$input.trigger('onSettingChanged');$.closeZoomScreen();return false;});}});});$('form.edit').validate({success:'',rules:{'edited-text':{rangelength:[0,65]}}});$('#edited-text').live('keyup',function(event){$(this).parents('form:first').find('.preview-dynamic-text:first').text(this.value);});});$("#facebook_activate_submit").click(function(){var $btn=$(this);FB_RequireFeatures(["XFBML","Connect"],function(){FB.init(window.settings.facebook.app_key,window.settings.facebook.xd_receiver);FB.Connect.showPermissionDialog("publish_stream, offline_access",function(given_permissions){$btn.parents('form').submit();},true);});return false;});}).end();});(function($){$.cropper=function(ev,onLoad){Helpers.require(SC.asset_url('/javascripts/vendor/jquery.Jcrop.js'),function(){return!!$.Jcrop;},function(){$.zoomable(ev,{width:450,height:500,src:$.zoomable.content.loadHtml,callback:function(){var i=parseInt,$extent=$('#extent'),$img=$('#crop-img'),width=i($('#original-width').val(),10),height=i($('#original-height').val(),10);function setExtent(dim){$extent.val(dim.w+'x'+dim.h+'+'+dim.x+'+'+dim.y);}
function getSelect(){var w=$img.width(),h=$img.height(),dx=w/width,dy=h/height,m=$extent.val().match(/(\d+)x(\d+)\+(\d+)\+(\d+)/);if(m){var x1=i(m[3],10)*dx,y1=i(m[4],10)*dy;var x2=x1+i(m[1],10)*dx,y2=y1+i(m[2],10)*dy;return[x1,y1,x2,y2];}else{return[w/10,h/10,w/10+w/2,h/10+h/2];}}
$img.Jcrop({aspectRatio:1,onChange:setExtent,onSelect:setExtent,setSelect:getSelect(),trueSize:[width,height]});if($.isFunction(onLoad)){onLoad();}}});});};})(jQuery);$(function(){$('body.restricted:first').each(function(){var foldTheZoom=function(foldingText,callback){$('#zoom-screen').find('h2').text(foldingText).addClass('loading').siblings().hide().end().end().animate({height:80,top:"+=100px"},'slow',function(){$(document).trigger('ajaxStart');if($.isFunction(callback)){callback();}});};var showAuthDialog=function(ev){var formWidth=330;var formHeight=270;$.zoomable(ev,{height:formHeight,width:formWidth,src:function(callback){callback($('#unlock-form').addClass('return-to-dom'),formWidth,formHeight);},uri:'#unlock-form',showCloseButton:false,beforeDisplay:function($form){return $form.removeClass('aural');},callback:function($container){$container.find('input:text').autoselect().filter(':first').focus();}});ev.stopPropagation();};var authClickEvent='click.authorization';var $clickedOnThis;var addAuthRequest=function(){$('a.send-message, a.message.button, a.remove, a.delete, a.send-track.group, a.utility, a.report-this-track, a.contact-link, a.favorite, input.small, input.tiny, a.comment-reply, a.membership, #add-non-timestamp-comment-link').unbind(authClickEvent).bind(authClickEvent,function(ev){console.log('wtf',this.className);$clickedOnThis=$(this);showAuthDialog(ev);return false;});};$('a.sign-in, #activate-account').live(authClickEvent,function(ev){showAuthDialog(ev);return false;});$('#zoom-login-form, #track-login-form, #static-login-form').validate({success:'',rules:{"username":{required:true},"password":{required:true}},messages:{"username":{required:"Please enter your username or email"},"password":{required:"Please enter your password"}}});$('#zoom-login-form').bind('submit',function(ev){var $form=$(this);if($form.parents('#zoom-content-wrapper').length>0&&$form.valid()){$.scAjax({url:$form.attr('action'),type:'create',data:$form.find('input').serializeArray(),accept:'application/json',callback:function(response,xhr,message){var responseObj=Helpers.json(response);if(responseObj.message==="ok"){foldTheZoom('Logging in...',function(){if(/\/signup/.test(window.location.toString())){window.location.replace("/");}else{if(responseObj.redirect_to===""){window.location.reload();}else{window.location=responseObj.redirect_to;}}});if($clickedOnThis&&$clickedOnThis.size()>0){$clickedOnThis.filter('.favorite, .membership').unbind(authClickEvent).click();}}else{Helpers.notice(responseObj.notice);$form.find('input:text:first').focus();}
$form.find('input:submit').throb(false);}});var iframeid="saveframe"+Math.floor(Math.random()*5000000);$('<iframe src="" id="'+iframeid+'" name="'+iframeid+'" class="aural"></iframe>').insertAfter($form);$form.attr('target',iframeid);ev.stopPropagation();}}).find('input:password').keydown(function(ev){if(ev.keyCode===13){$(this).parents('form').submit();return false;}});$('#zoom-activate-form').live('submit',function(){var $form=$(this);$form.ajaxSubmit({type:'POST',beforeSend:SC.xhr.json,beforeSubmit:function(){return $form.valid();},success:function(responseText){var responseObj=Helpers.json(responseText);if(responseObj.activated_at){foldTheZoom('Activating...',function(){if((new RegExp(SC.CURRENT_USER.permalink)).test(window.location.toString())){window.location.replace("/");}else{window.location.reload(true);}});}}});return false;}).SCValidate({"user[username]":"username","user[password]":"password"});$('a.forgot-link').live('click',function(event){var $wrapper=$(this).parents('div.site-login-form-wrapper');var forgotActive=$(this).data('active')||false;if(forgotActive){$(this).text('Forgot password?');$('div.forgot-password-container:first',$wrapper).hide();$('#zoom-login-form, #static-login-form',$wrapper).slideDown();}else{$(this).text('Oh, I remember it!');$('#zoom-login-form, #static-login-form',$wrapper).hide();$('div.forgot-password-container:first',$wrapper).each(function(){var $input=$('input:text',this);$input.val($('input[name=username]').val());$(this).slideDown(function(){$input.selectNow();});});}
$(this).data('active',!forgotActive);return false;});$(document).bind('onContentLoaded',addAuthRequest);addAuthRequest();if((/return_to/).test(window.location.search)&&!(/\/(signup|login)/).test(window.location.toString())){$('#login-link').click();}
$(document).bind('onActionPrevented',function(){$('#login-link').click();});});$('a.resend-email-button').live('click',function(e){$.scAjax({url:e.target.href,type:'update',callback:function(res){Helpers.notice(res);}});return false;});});$(function(){var outboundLink=function(link,subcategory){return'/outgoing/'+subcategory+'/'+$(link).closest('a').attr('href').replace('http://','');};$('a.shop').live('click',function(ev){$.trackPageview(outboundLink(ev.target,'shop'));});$('div.share-icons a').live('click',function(ev){$.trackPageview(outboundLink(ev.target,'share'));});var getUserPlanName=function(){return(SC.CURRENT_USER?['Free','Pro Light','Pro Standard','','Pro Max'][SC.CURRENT_USER.plan]:'Anonymous');};$(document).bind('onSoundManagerFail',function(){$.trackPageview('/error/front-end/sm2fail/'+window.location);});$.trackPage('UA-2519404-1',{visitor_type:getUserPlanName()});});