function FSM(){var machine=this;this.builder=null;var globalEnterActions=[];var globalExitActions=[];var stateBuilders={};var allEventNames={};this.Version='0.2.2';function delegateTo(obj,delegateName){var funcs=[];for(var i=2;i<arguments.length;i++){var f=arguments[i];if(f&&f.constructor===Array){funcs=funcs.concat(f);}else if(typeof f=='object'){for(var p in f){funcs.push(p);}}else{funcs.push(f);}}
for(var i=0;i<funcs.length;i++){var func=funcs[i];obj[func]=function(f){return function(){var delegate=this[delegateName];return delegate[f].apply(this,arguments);}}(func);}}
function mapArray(arr,f){var result=[];var l=arr.length;for(var i=0;i<l;i++){result.push(f(arr[i]));}
return result;}
function predicateName(name){return'is'+name.charAt(0).toUpperCase()+name.substring(1);}
function predicateFunc(context,name){return function(){return(typeof context.currentState[name]=='function');}}
function runActions(context,actions,args,check){var result=true;var l=actions.length;for(var i=0;i<l;i++){var a=actions[i];var func;switch(typeof a){case'function':func=a;break;case'string':func=context[a];break;default:if(a&&a.constructor===Array){func=context[a[0]];args=a.slice(1);}
break}
result=func.apply(context,args);if(check&&!result)return false;}
return result;}
function initialState(states){for(var n in states){var s=states[n];if(s.isInitial()){return s;}}
return null;}
function finalStates(states){var finalStates=[];for(var n in states){var s=states[n];if(s.isFinal()){finalStates.push(s);}}
return finalStates;}
var globalUnexpectedEventHandler=function(state,event){if(console){console.log('STATE: ',state,'UNEXPECTED EVENT: ',event);}}
function StateBuilder(stateName,kind){var stateBuilder=this;this.transitionBuilder=null;var events={};var toState;var isInitial=kind=='initial';var isFinal=kind=='final';var enterActions=[];var exitActions=[];var unexpectedEventHandler=globalUnexpectedEventHandler
function addTransition(name,transition){events[name]=events[name]||[];events[name].push(transition);allEventNames[name]=true;}
function TransitionBuilder(eventName){var guards=[];var actions=[];var isLoopback=false;var toStateName,guard,action;this.toString=function(){return'#<TransitionBuilder: '+stateName+'--'+eventName+'-->'+toStateName+'>';};this.goesTo=function(toState){toStateName=toState;isLoopback=(stateName==toStateName);return stateBuilder;};this.onlyIf=function(condition){guards.push(condition);return stateBuilder;};this.doing=function(doit){if(arguments.length==1){actions.push(doit);}else{actions.push(Array.prototype.slice.call(arguments,0));}
return stateBuilder;};this.buildTransition=function(){var toState=toStateName||stateName;return{event:function(){return eventName;},appliesTo:function(){return runActions(this,guards,arguments,true);},execute:function(){var enteredState;try{runActions(this,actions,arguments);if(!isLoopback){runActions(this,this.currentState.exitActions(),arguments);}
enteredState=this.transitionTo(toState);return true;}finally{if(!isLoopback&&enteredState){runActions(this,enteredState.enterActions(),arguments);}}},goesTo:function(){return toState;}};}}
this.toString=function(){return'StateBuilder: "'+stateName+'"';};this.event=function(name){this.transitionBuilder=new TransitionBuilder(name,this);addTransition(name,this.transitionBuilder);return stateBuilder;};this.onEntering=function(func){enterActions.push(func);return stateBuilder;};this.onExiting=function(func){exitActions.push(func);return stateBuilder;};this.onUnexpectedEvent=function(func){unexpectedEventHandler=func;return stateBuilder;}
delegateTo(stateBuilder,'transitionBuilder','goesTo','doing','onlyIf');this.buildState=function(){var transitions=buildTransitions();var state={name:function(){return stateName;},isInitial:function(){return isInitial;},isFinal:function(){return isFinal;},enterActions:function(){return globalEnterActions.concat(enterActions);},exitActions:function(){return exitActions.concat(globalExitActions);},successorStates:function(context){return mapArray(allApplicableTransitions(context,transitions),function(t){return t.goesTo();});},expectedEvents:function(context){return mapArray(allApplicableTransitions(context,transitions),function(t){return t.event();});},inspect:function(){return'#<State: '+stateName+'>';},toString:function(){return stateName;}};state[predicateName(stateName)]=function(){return true;};for(var e in events){state[e]=buildEventHandler(transitions[e]);}
for(var e in allEventNames){if(!state[e]){state[e]=buildUnexpectedEventHandler(e);}}
return state;};function buildTransitions(){var transitions={};for(var e in events){transitions[e]=mapArray(events[e],function(transitionBuilder){return transitionBuilder.buildTransition();});}
return transitions;}
function buildEventHandler(transitions){return function(arguments){var t=firstApplicableTransition(this,transitions,arguments);if(t){return t.execute.apply(this,arguments);}
return false;}}
function buildUnexpectedEventHandler(event){return function(){unexpectedEventHandler(stateName,event);}}
function firstApplicableTransition(context,transitions,args){var len=transitions.length;for(var i=0;i<len;i++){var t=transitions[i];if(t.appliesTo.apply(context,args)){return t;}}
return null;}}
function allApplicableTransitions(context,transitions){context=context||this;var applTrans=[];for(var e in transitions){var ts=transitions[e];var len=ts.length;for(var i=0;i<len;i++){var t=ts[i];if(t.appliesTo.apply(context)){applTrans.push(t);}}}
return applTrans;}
this.state=function(name,kind){var stateBuilder=new StateBuilder(name,kind);stateBuilders[name]=stateBuilder;builder=stateBuilder;return stateBuilder;};this.onEnteringAnyState=function(handler){globalEnterActions.push(handler);},this.onExitingAnyState=function(handler){globalExitActions.push(handler);},this.onUnexpectedEvent=function(handler){globalUnexpectedEventHandler=handler;}
var embedInto=function(context){context.states={};for(var n in stateBuilders){context.states[n]=stateBuilders[n].buildState(context);var pn=predicateName(n);context[pn]=predicateFunc(context,pn);}
var initial=initialState(context.states);var finals=finalStates(context.states);context.initialState=function(){return initial;};context.finalStates=function(){return finals;};context.currentState=initial;context.transitionTo=function(stateName){this.currentState=context.states[stateName];return this.currentState;};context.expectedEvents=function(){return this.currentState.expectedEvents(this);};context.successorStates=function(){return this.currentState.successorStates(this);};delegateTo(context,'currentState',allEventNames);return context;}
this.buildMachine=function(){return function(proto){function Machine(){}
Machine.prototype=proto;return embedInto(new Machine());}}
this.toString=function(){var desc="States:\n";for(var s in stateBuilders){desc+='  '+stateBuilders[s]+"\n";}
return desc;}
delegateTo(machine,'builder','event','goesTo','doing','onlyIf');}
FSM.build=function(definitionBlock){var fsm=new FSM;definitionBlock(fsm);return fsm.buildMachine();};(function(){if(window.jQuery)var _jQuery=window.jQuery;var jQuery=window.jQuery=function(selector,context){return new jQuery.prototype.init(selector,context);};if(window.$)var _$=window.$;window.$=jQuery;var quickExpr=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;var isSimple=/^.[^:#\[\.]*$/;jQuery.fn=jQuery.prototype={init:function(selector,context){selector=selector||document;if(selector.nodeType){this[0]=selector;this.length=1;return this;}else if(typeof selector=="string"){var match=quickExpr.exec(selector);if(match&&(match[1]||!context)){if(match[1])selector=jQuery.clean([match[1]],context);else{var elem=document.getElementById(match[3]);if(elem)if(elem.id!=match[3])return jQuery().find(selector);else{this[0]=elem;this.length=1;return this;}else
selector=[];}}else
return new jQuery(context).find(selector);}else if(jQuery.isFunction(selector))return new jQuery(document)[jQuery.fn.ready?"ready":"load"](selector);return this.setArray(selector.constructor==Array&&selector||(selector.jquery||selector.length&&selector!=window&&!selector.nodeType&&selector[0]!=undefined&&selector[0].nodeType)&&jQuery.makeArray(selector)||[selector]);},jquery:"1.2.2",size:function(){return this.length;},length:0,get:function(num){return num==undefined?jQuery.makeArray(this):this[num];},pushStack:function(elems){var ret=jQuery(elems);ret.prevObject=this;return ret;},setArray:function(elems){this.length=0;Array.prototype.push.apply(this,elems);return this;},each:function(callback,args){return jQuery.each(this,callback,args);},index:function(elem){var ret=-1;this.each(function(i){if(this==elem)ret=i;});return ret;},attr:function(name,value,type){var options=name;if(name.constructor==String)if(value==undefined)return this.length&&jQuery[type||"attr"](this[0],name)||undefined;else{options={};options[name]=value;}return this.each(function(i){for(name in options)jQuery.attr(type?this.style:this,name,jQuery.prop(this,options[name],type,i,name));});},css:function(key,value){if((key=='width'||key=='height')&&parseFloat(value)<0)value=undefined;return this.attr(key,value,"curCSS");},text:function(text){if(typeof text!="object"&&text!=null)return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(text));var ret="";jQuery.each(text||this,function(){jQuery.each(this.childNodes,function(){if(this.nodeType!=8)ret+=this.nodeType!=1?this.nodeValue:jQuery.fn.text([this]);});});return ret;},wrapAll:function(html){if(this[0])jQuery(html,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){var elem=this;while(elem.firstChild)elem=elem.firstChild;return elem;}).append(this);return this;},wrapInner:function(html){return this.each(function(){jQuery(this).contents().wrapAll(html);});},wrap:function(html){return this.each(function(){jQuery(this).wrapAll(html);});},append:function(){return this.domManip(arguments,true,false,function(elem){if(this.nodeType==1)this.appendChild(elem);});},prepend:function(){return this.domManip(arguments,true,true,function(elem){if(this.nodeType==1)this.insertBefore(elem,this.firstChild);});},before:function(){return this.domManip(arguments,false,false,function(elem){this.parentNode.insertBefore(elem,this);});},after:function(){return this.domManip(arguments,false,true,function(elem){this.parentNode.insertBefore(elem,this.nextSibling);});},end:function(){return this.prevObject||jQuery([]);},find:function(selector){var elems=jQuery.map(this,function(elem){return jQuery.find(selector,elem);});return this.pushStack(/[^+>] [^+>]/.test(selector)||selector.indexOf("..")>-1?jQuery.unique(elems):elems);},clone:function(events){var ret=this.map(function(){if(jQuery.browser.msie&&!jQuery.isXMLDoc(this)){var clone=this.cloneNode(true),container=document.createElement("div"),container2=document.createElement("div");container.appendChild(clone);container2.innerHTML=container.innerHTML;return container2.firstChild;}else
return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function(){if(this[expando]!=undefined)this[expando]=null;});if(events===true)this.find("*").andSelf().each(function(i){if(this.nodeType==3)return;var events=jQuery.data(this,"events");for(var type in events)for(var handler in events[type])jQuery.event.add(clone[i],type,events[type][handler],events[type][handler].data);});return ret;},filter:function(selector){return this.pushStack(jQuery.isFunction(selector)&&jQuery.grep(this,function(elem,i){return selector.call(elem,i);})||jQuery.multiFilter(selector,this));},not:function(selector){if(selector.constructor==String)if(isSimple.test(selector))return this.pushStack(jQuery.multiFilter(selector,this,true));else
selector=jQuery.multiFilter(selector,this);var isArrayLike=selector.length&&selector[selector.length-1]!==undefined&&!selector.nodeType;return this.filter(function(){return isArrayLike?jQuery.inArray(this,selector)<0:this!=selector;});},add:function(selector){return!selector?this:this.pushStack(jQuery.merge(this.get(),selector.constructor==String?jQuery(selector).get():selector.length!=undefined&&(!selector.nodeName||jQuery.nodeName(selector,"form"))?selector:[selector]));},is:function(selector){return selector?jQuery.multiFilter(selector,this).length>0:false;},hasClass:function(selector){return this.is("."+selector);},val:function(value){if(value==undefined){if(this.length){var elem=this[0];if(jQuery.nodeName(elem,"select")){var index=elem.selectedIndex,values=[],options=elem.options,one=elem.type=="select-one";if(index<0)return null;for(var i=one?index:0,max=one?index+1:options.length;i<max;i++){var option=options[i];if(option.selected){value=jQuery.browser.msie&&!option.attributes.value.specified?option.text:option.value;if(one)return value;values.push(value);}}return values;}else
return(this[0].value||"").replace(/\r/g,"");}return undefined;}return this.each(function(){if(this.nodeType!=1)return;if(value.constructor==Array&&/radio|checkbox/.test(this.type))this.checked=(jQuery.inArray(this.value,value)>=0||jQuery.inArray(this.name,value)>=0);else if(jQuery.nodeName(this,"select")){var values=value.constructor==Array?value:[value];jQuery("option",this).each(function(){this.selected=(jQuery.inArray(this.value,values)>=0||jQuery.inArray(this.text,values)>=0);});if(!values.length)this.selectedIndex=-1;}else
this.value=value;});},html:function(value){return value==undefined?(this.length?this[0].innerHTML:null):this.empty().append(value);},replaceWith:function(value){return this.after(value).remove();},eq:function(i){return this.slice(i,i+1);},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments));},map:function(callback){return this.pushStack(jQuery.map(this,function(elem,i){return callback.call(elem,i,elem);}));},andSelf:function(){return this.add(this.prevObject);},domManip:function(args,table,reverse,callback){var clone=this.length>1,elems;return this.each(function(){if(!elems){elems=jQuery.clean(args,this.ownerDocument);if(reverse)elems.reverse();}var obj=this;if(table&&jQuery.nodeName(this,"table")&&jQuery.nodeName(elems[0],"tr"))obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));var scripts=jQuery([]);jQuery.each(elems,function(){var elem=clone?jQuery(this).clone(true)[0]:this;if(jQuery.nodeName(elem,"script")){scripts=scripts.add(elem);}else{if(elem.nodeType==1)scripts=scripts.add(jQuery("script",elem).remove());callback.call(obj,elem);}});scripts.each(evalScript);});}};jQuery.prototype.init.prototype=jQuery.prototype;function evalScript(i,elem){if(elem.src)jQuery.ajax({url:elem.src,async:false,dataType:"script"});else
jQuery.globalEval(elem.text||elem.textContent||elem.innerHTML||"");if(elem.parentNode)elem.parentNode.removeChild(elem);}jQuery.extend=jQuery.fn.extend=function(){var target=arguments[0]||{},i=1,length=arguments.length,deep=false,options;if(target.constructor==Boolean){deep=target;target=arguments[1]||{};i=2;}if(typeof target!="object"&&typeof target!="function")target={};if(length==1){target=this;i=0;}for(;i<length;i++)if((options=arguments[i])!=null)for(var name in options){if(target===options[name])continue;if(deep&&options[name]&&typeof options[name]=="object"&&target[name]&&!options[name].nodeType)target[name]=jQuery.extend(target[name],options[name]);else if(options[name]!=undefined)target[name]=options[name];}return target;};var expando="jQuery"+(new Date()).getTime(),uuid=0,windowData={};var exclude=/z-?index|font-?weight|opacity|zoom|line-?height/i;jQuery.extend({noConflict:function(deep){window.$=_$;if(deep)window.jQuery=_jQuery;return jQuery;},isFunction:function(fn){return!!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/function/i.test(fn+"");},isXMLDoc:function(elem){return elem.documentElement&&!elem.body||elem.tagName&&elem.ownerDocument&&!elem.ownerDocument.body;},globalEval:function(data){data=jQuery.trim(data);if(data){var head=document.getElementsByTagName("head")[0]||document.documentElement,script=document.createElement("script");script.type="text/javascript";if(jQuery.browser.msie)script.text=data;else
script.appendChild(document.createTextNode(data));head.appendChild(script);head.removeChild(script);}},nodeName:function(elem,name){return elem.nodeName&&elem.nodeName.toUpperCase()==name.toUpperCase();},cache:{},data:function(elem,name,data){elem=elem==window?windowData:elem;var id=elem[expando];if(!id)id=elem[expando]=++uuid;if(name&&!jQuery.cache[id])jQuery.cache[id]={};if(data!=undefined)jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])break;if(!name)jQuery.removeData(elem);}}else{try{delete elem[expando];}catch(e){if(elem.removeAttribute)elem.removeAttribute(expando);}delete jQuery.cache[id];}},each:function(object,callback,args){if(args){if(object.length==undefined){for(var name in object)if(callback.apply(object[name],args)===false)break;}else
for(var i=0,length=object.length;i<length;i++)if(callback.apply(object[i],args)===false)break;}else{if(object.length==undefined){for(var name in object)if(callback.call(object[name],name,object[name])===false)break;}else
for(var i=0,length=object.length,value=object[0];i<length&&callback.call(value,i,value)!==false;value=object[++i]){}}return object;},prop:function(elem,value,type,i,name){if(jQuery.isFunction(value))value=value.call(elem,i);return value&&value.constructor==Number&&type=="curCSS"&&!exclude.test(name)?value+"px":value;},className:{add:function(elem,classNames){jQuery.each((classNames||"").split(/\s+/),function(i,className){if(elem.nodeType==1&&!jQuery.className.has(elem.className,className))elem.className+=(elem.className?" ":"")+className;});},remove:function(elem,classNames){if(elem.nodeType==1)elem.className=classNames!=undefined?jQuery.grep(elem.className.split(/\s+/),function(className){return!jQuery.className.has(classNames,className);}).join(" "):"";},has:function(elem,className){return jQuery.inArray(className,(elem.className||elem).toString().split(/\s+/))>-1;}},swap:function(elem,options,callback){var old={};for(var name in options){old[name]=elem.style[name];elem.style[name]=options[name];}callback.call(elem);for(var name in options)elem.style[name]=old[name];},css:function(elem,name,force){if(name=="width"||name=="height"){var val,props={position:"absolute",visibility:"hidden",display:"block"},which=name=="width"?["Left","Right"]:["Top","Bottom"];function getWH(){val=name=="width"?elem.offsetWidth:elem.offsetHeight;var padding=0,border=0;jQuery.each(which,function(){padding+=parseFloat(jQuery.curCSS(elem,"padding"+this,true))||0;border+=parseFloat(jQuery.curCSS(elem,"border"+this+"Width",true))||0;});val-=Math.round(padding+border);}if(jQuery(elem).is(":visible"))getWH();else
jQuery.swap(elem,props,getWH);return Math.max(0,val);}return jQuery.curCSS(elem,name,force);},curCSS:function(elem,name,force){var ret;function color(elem){if(!jQuery.browser.safari)return false;var ret=document.defaultView.getComputedStyle(elem,null);return!ret||ret.getPropertyValue("color")=="";}if(name=="opacity"&&jQuery.browser.msie){ret=jQuery.attr(elem.style,"opacity");return ret==""?"1":ret;}if(jQuery.browser.opera&&name=="display"){var save=elem.style.display;elem.style.display="block";elem.style.display=save;}if(name.match(/float/i))name=styleFloat;if(!force&&elem.style&&elem.style[name])ret=elem.style[name];else if(document.defaultView&&document.defaultView.getComputedStyle){if(name.match(/float/i))name="float";name=name.replace(/([A-Z])/g,"-$1").toLowerCase();var getComputedStyle=document.defaultView.getComputedStyle(elem,null);if(getComputedStyle&&!color(elem))ret=getComputedStyle.getPropertyValue(name);else{var swap=[],stack=[];for(var a=elem;a&&color(a);a=a.parentNode)stack.unshift(a);for(var i=0;i<stack.length;i++)if(color(stack[i])){swap[i]=stack[i].style.display;stack[i].style.display="block";}ret=name=="display"&&swap[stack.length-1]!=null?"none":(getComputedStyle&&getComputedStyle.getPropertyValue(name))||"";for(var i=0;i<swap.length;i++)if(swap[i]!=null)stack[i].style.display=swap[i];}if(name=="opacity"&&ret=="")ret="1";}else if(elem.currentStyle){var camelCase=name.replace(/\-(\w)/g,function(all,letter){return letter.toUpperCase();});ret=elem.currentStyle[name]||elem.currentStyle[camelCase];if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){var style=elem.style.left,runtimeStyle=elem.runtimeStyle.left;elem.runtimeStyle.left=elem.currentStyle.left;elem.style.left=ret||0;ret=elem.style.pixelLeft+"px";elem.style.left=style;elem.runtimeStyle.left=runtimeStyle;}}return ret;},clean:function(elems,context){var ret=[];context=context||document;if(typeof context.createElement=='undefined')context=context.ownerDocument||context[0]&&context[0].ownerDocument||document;jQuery.each(elems,function(i,elem){if(!elem)return;if(elem.constructor==Number)elem=elem.toString();if(typeof elem=="string"){elem=elem.replace(/(<(\w+)[^>]*?)\/>/g,function(all,front,tag){return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:front+"></"+tag+">";});var tags=jQuery.trim(elem).toLowerCase(),div=context.createElement("div");var wrap=!tags.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!tags.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||tags.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!tags.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!tags.indexOf("<td")||!tags.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!tags.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||jQuery.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];div.innerHTML=wrap[1]+elem+wrap[2];while(wrap[0]--)div=div.lastChild;if(jQuery.browser.msie){var tbody=!tags.indexOf("<table")&&tags.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:wrap[1]=="<table>"&&tags.indexOf("<tbody")<0?div.childNodes:[];for(var j=tbody.length-1;j>=0;--j)if(jQuery.nodeName(tbody[j],"tbody")&&!tbody[j].childNodes.length)tbody[j].parentNode.removeChild(tbody[j]);if(/^\s/.test(elem))div.insertBefore(context.createTextNode(elem.match(/^\s*/)[0]),div.firstChild);}elem=jQuery.makeArray(div.childNodes);}if(elem.length===0&&(!jQuery.nodeName(elem,"form")&&!jQuery.nodeName(elem,"select")))return;if(elem[0]==undefined||jQuery.nodeName(elem,"form")||elem.options)ret.push(elem);else
ret=jQuery.merge(ret,elem);});return ret;},attr:function(elem,name,value){if(!elem||elem.nodeType==3||elem.nodeType==8)return undefined;var fix=jQuery.isXMLDoc(elem)?{}:jQuery.props;if(name=="selected"&&jQuery.browser.safari)elem.parentNode.selectedIndex;if(fix[name]){if(value!=undefined)elem[fix[name]]=value;return elem[fix[name]];}else if(jQuery.browser.msie&&name=="style")return jQuery.attr(elem.style,"cssText",value);else if(value==undefined&&jQuery.browser.msie&&jQuery.nodeName(elem,"form")&&(name=="action"||name=="method"))return elem.getAttributeNode(name).nodeValue;else if(elem.tagName){if(value!=undefined){if(name=="type"&&jQuery.nodeName(elem,"input")&&elem.parentNode)throw"type property can't be changed";elem.setAttribute(name,""+value);}if(jQuery.browser.msie&&/href|src/.test(name)&&!jQuery.isXMLDoc(elem))return elem.getAttribute(name,2);return elem.getAttribute(name);}else{if(name=="opacity"&&jQuery.browser.msie){if(value!=undefined){elem.zoom=1;elem.filter=(elem.filter||"").replace(/alpha\([^)]*\)/,"")+(parseFloat(value).toString()=="NaN"?"":"alpha(opacity="+value*100+")");}return elem.filter&&elem.filter.indexOf("opacity=")>=0?(parseFloat(elem.filter.match(/opacity=([^)]*)/)[1])/100).toString():"";}name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});if(value!=undefined)elem[name]=value;return elem[name];}},trim:function(text){return(text||"").replace(/^\s+|\s+$/g,"");},makeArray:function(array){var ret=[];if(typeof array!="array")for(var i=0,length=array.length;i<length;i++)ret.push(array[i]);else
ret=array.slice(0);return ret;},inArray:function(elem,array){for(var i=0,length=array.length;i<length;i++)if(array[i]==elem)return i;return-1;},merge:function(first,second){if(jQuery.browser.msie){for(var i=0;second[i];i++)if(second[i].nodeType!=8)first.push(second[i]);}else
for(var i=0;second[i];i++)first.push(second[i]);return first;},unique:function(array){var ret=[],done={};try{for(var i=0,length=array.length;i<length;i++){var id=jQuery.data(array[i]);if(!done[id]){done[id]=true;ret.push(array[i]);}}}catch(e){ret=array;}return ret;},grep:function(elems,callback,inv){if(typeof callback=="string")callback=eval("false||function(a,i){return "+callback+"}");var ret=[];for(var i=0,length=elems.length;i<length;i++)if(!inv&&callback(elems[i],i)||inv&&!callback(elems[i],i))ret.push(elems[i]);return ret;},map:function(elems,callback){var ret=[];for(var i=0,length=elems.length;i<length;i++){var value=callback(elems[i],i);if(value!==null&&value!=undefined){if(value.constructor!=Array)value=[value];ret=ret.concat(value);}}return ret;}});var userAgent=navigator.userAgent.toLowerCase();jQuery.browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(userAgent),opera:/opera/.test(userAgent),msie:/msie/.test(userAgent)&&!/opera/.test(userAgent),mozilla:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)};var styleFloat=jQuery.browser.msie?"styleFloat":"cssFloat";jQuery.extend({boxModel:!jQuery.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":styleFloat,cssFloat:styleFloat,styleFloat:styleFloat,innerHTML:"innerHTML",className:"className",value:"value",disabled:"disabled",checked:"checked",readonly:"readOnly",selected:"selected",maxlength:"maxLength",selectedIndex:"selectedIndex",defaultValue:"defaultValue",tagName:"tagName",nodeName:"nodeName"}});jQuery.each({parent:"elem.parentNode",parents:"jQuery.dir(elem,'parentNode')",next:"jQuery.nth(elem,2,'nextSibling')",prev:"jQuery.nth(elem,2,'previousSibling')",nextAll:"jQuery.dir(elem,'nextSibling')",prevAll:"jQuery.dir(elem,'previousSibling')",siblings:"jQuery.sibling(elem.parentNode.firstChild,elem)",children:"jQuery.sibling(elem.firstChild)",contents:"jQuery.nodeName(elem,'iframe')?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes)"},function(name,fn){fn=eval("false||function(elem){return "+fn+"}");jQuery.fn[name]=function(selector){var ret=jQuery.map(this,fn);if(selector&&typeof selector=="string")ret=jQuery.multiFilter(selector,ret);return this.pushStack(jQuery.unique(ret));};});jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(){var args=arguments;return this.each(function(){for(var i=0,length=args.length;i<length;i++)jQuery(args[i])[original](this);});};});jQuery.each({removeAttr:function(name){jQuery.attr(this,name,"");if(this.nodeType==1)this.removeAttribute(name);},addClass:function(classNames){jQuery.className.add(this,classNames);},removeClass:function(classNames){jQuery.className.remove(this,classNames);},toggleClass:function(classNames){jQuery.className[jQuery.className.has(this,classNames)?"remove":"add"](this,classNames);},remove:function(selector){if(!selector||jQuery.filter(selector,[this]).r.length){jQuery("*",this).add(this).each(function(){jQuery.event.remove(this);jQuery.removeData(this);});if(this.parentNode)this.parentNode.removeChild(this);}},empty:function(){jQuery(">*",this).remove();while(this.firstChild)this.removeChild(this.firstChild);}},function(name,fn){jQuery.fn[name]=function(){return this.each(fn,arguments);};});jQuery.each(["Height","Width"],function(i,name){var type=name.toLowerCase();jQuery.fn[type]=function(size){return this[0]==window?jQuery.browser.opera&&document.body["client"+name]||jQuery.browser.safari&&window["inner"+name]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+name]||document.body["client"+name]:this[0]==document?Math.max(Math.max(document.body["scroll"+name],document.documentElement["scroll"+name]),Math.max(document.body["offset"+name],document.documentElement["offset"+name])):size==undefined?(this.length?jQuery.css(this[0],type):null):this.css(type,size.constructor==String?size:size+"px");};});var chars=jQuery.browser.safari&&parseInt(jQuery.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",quickChild=new RegExp("^>\\s*("+chars+"+)"),quickID=new RegExp("^("+chars+"+)(#)("+chars+"+)"),quickClass=new RegExp("^([#.]?)("+chars+"*)");jQuery.extend({expr:{"":"m[2]=='*'||jQuery.nodeName(a,m[2])","#":"a.getAttribute('id')==m[2]",":":{lt:"i<m[3]-0",gt:"i>m[3]-0",nth:"m[3]-0==i",eq:"m[3]-0==i",first:"i==0",last:"i==r.length-1",even:"i%2==0",odd:"i%2","first-child":"a.parentNode.getElementsByTagName('*')[0]==a","last-child":"jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a","only-child":"!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')",parent:"a.firstChild",empty:"!a.firstChild",contains:"(a.textContent||a.innerText||jQuery(a).text()||'').indexOf(m[3])>=0",visible:'"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',hidden:'"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',enabled:"!a.disabled",disabled:"a.disabled",checked:"a.checked",selected:"a.selected||jQuery.attr(a,'selected')",text:"'text'==a.type",radio:"'radio'==a.type",checkbox:"'checkbox'==a.type",file:"'file'==a.type",password:"'password'==a.type",submit:"'submit'==a.type",image:"'image'==a.type",reset:"'reset'==a.type",button:'"button"==a.type||jQuery.nodeName(a,"button")',input:"/input|select|textarea|button/i.test(a.nodeName)",has:"jQuery.find(m[3],a).length",header:"/h\\d/i.test(a.nodeName)",animated:"jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length"}},parse:[/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,new RegExp("^([:.#]*)("+chars+"+)")],multiFilter:function(expr,elems,not){var old,cur=[];while(expr&&expr!=old){old=expr;var f=jQuery.filter(expr,elems,not);expr=f.t.replace(/^\s*,\s*/,"");cur=not?elems=f.r:jQuery.merge(cur,f.r);}return cur;},find:function(t,context){if(typeof t!="string")return[t];if(context&&context.nodeType!=1&&context.nodeType!=9)return[];context=context||document;var ret=[context],done=[],last,nodeName;while(t&&last!=t){var r=[];last=t;t=jQuery.trim(t);var foundToken=false;var re=quickChild;var m=re.exec(t);if(m){nodeName=m[1].toUpperCase();for(var i=0;ret[i];i++)for(var c=ret[i].firstChild;c;c=c.nextSibling)if(c.nodeType==1&&(nodeName=="*"||c.nodeName.toUpperCase()==nodeName))r.push(c);ret=r;t=t.replace(re,"");if(t.indexOf(" ")==0)continue;foundToken=true;}else{re=/^([>+~])\s*(\w*)/i;if((m=re.exec(t))!=null){r=[];var merge={};nodeName=m[2].toUpperCase();m=m[1];for(var j=0,rl=ret.length;j<rl;j++){var n=m=="~"||m=="+"?ret[j].nextSibling:ret[j].firstChild;for(;n;n=n.nextSibling)if(n.nodeType==1){var id=jQuery.data(n);if(m=="~"&&merge[id])break;if(!nodeName||n.nodeName.toUpperCase()==nodeName){if(m=="~")merge[id]=true;r.push(n);}if(m=="+")break;}}ret=r;t=jQuery.trim(t.replace(re,""));foundToken=true;}}if(t&&!foundToken){if(!t.indexOf(",")){if(context==ret[0])ret.shift();done=jQuery.merge(done,ret);r=ret=[context];t=" "+t.substr(1,t.length);}else{var re2=quickID;var m=re2.exec(t);if(m){m=[0,m[2],m[3],m[1]];}else{re2=quickClass;m=re2.exec(t);}m[2]=m[2].replace(/\\/g,"");var elem=ret[ret.length-1];if(m[1]=="#"&&elem&&elem.getElementById&&!jQuery.isXMLDoc(elem)){var oid=elem.getElementById(m[2]);if((jQuery.browser.msie||jQuery.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2])oid=jQuery('[@id="'+m[2]+'"]',elem)[0];ret=r=oid&&(!m[3]||jQuery.nodeName(oid,m[3]))?[oid]:[];}else{for(var i=0;ret[i];i++){var tag=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];if(tag=="*"&&ret[i].nodeName.toLowerCase()=="object")tag="param";r=jQuery.merge(r,ret[i].getElementsByTagName(tag));}if(m[1]==".")r=jQuery.classFilter(r,m[2]);if(m[1]=="#"){var tmp=[];for(var i=0;r[i];i++)if(r[i].getAttribute("id")==m[2]){tmp=[r[i]];break;}r=tmp;}ret=r;}t=t.replace(re2,"");}}if(t){var val=jQuery.filter(t,r);ret=r=val.r;t=jQuery.trim(val.t);}}if(t)ret=[];if(ret&&context==ret[0])ret.shift();done=jQuery.merge(done,ret);return done;},classFilter:function(r,m,not){m=" "+m+" ";var tmp=[];for(var i=0;r[i];i++){var pass=(" "+r[i].className+" ").indexOf(m)>=0;if(!not&&pass||not&&!pass)tmp.push(r[i]);}return tmp;},filter:function(t,r,not){var last;while(t&&t!=last){last=t;var p=jQuery.parse,m;for(var i=0;p[i];i++){m=p[i].exec(t);if(m){t=t.substring(m[0].length);m[2]=m[2].replace(/\\/g,"");break;}}if(!m)break;if(m[1]==":"&&m[2]=="not")r=isSimple.test(m[3])?jQuery.filter(m[3],r,true).r:jQuery(r).not(m[3]);else if(m[1]==".")r=jQuery.classFilter(r,m[2],not);else if(m[1]=="["){var tmp=[],type=m[3];for(var i=0,rl=r.length;i<rl;i++){var a=r[i],z=a[jQuery.props[m[2]]||m[2]];if(z==null||/href|src|selected/.test(m[2]))z=jQuery.attr(a,m[2])||'';if((type==""&&!!z||type=="="&&z==m[5]||type=="!="&&z!=m[5]||type=="^="&&z&&!z.indexOf(m[5])||type=="$="&&z.substr(z.length-m[5].length)==m[5]||(type=="*="||type=="~=")&&z.indexOf(m[5])>=0)^not)tmp.push(a);}r=tmp;}else if(m[1]==":"&&m[2]=="nth-child"){var merge={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),first=(test[1]+(test[2]||1))-0,last=test[3]-0;for(var i=0,rl=r.length;i<rl;i++){var node=r[i],parentNode=node.parentNode,id=jQuery.data(parentNode);if(!merge[id]){var c=1;for(var n=parentNode.firstChild;n;n=n.nextSibling)if(n.nodeType==1)n.nodeIndex=c++;merge[id]=true;}var add=false;if(first==0){if(node.nodeIndex==last)add=true;}else if((node.nodeIndex-last)%first==0&&(node.nodeIndex-last)/first>=0)add=true;if(add^not)tmp.push(node);}r=tmp;}else{var f=jQuery.expr[m[1]];if(typeof f!="string")f=jQuery.expr[m[1]][m[2]];f=eval("false||function(a,i){return "+f+"}");r=jQuery.grep(r,f,not);}}return{r:r,t:t};},dir:function(elem,dir){var matched=[];var cur=elem[dir];while(cur&&cur!=document){if(cur.nodeType==1)matched.push(cur);cur=cur[dir];}return matched;},nth:function(cur,result,dir,elem){result=result||1;var num=0;for(;cur;cur=cur[dir])if(cur.nodeType==1&&++num==result)break;return cur;},sibling:function(n,elem){var r=[];for(;n;n=n.nextSibling){if(n.nodeType==1&&(!elem||n!=elem))r.push(n);}return r;}});jQuery.event={add:function(elem,types,handler,data){if(elem.nodeType==3||elem.nodeType==8)return;if(jQuery.browser.msie&&elem.setInterval!=undefined)elem=window;if(!handler.guid)handler.guid=this.guid++;if(data!=undefined){var fn=handler;handler=function(){return fn.apply(this,arguments);};handler.data=data;handler.guid=fn.guid;}var events=jQuery.data(elem,"events")||jQuery.data(elem,"events",{}),handle=jQuery.data(elem,"handle")||jQuery.data(elem,"handle",function(){var val;if(typeof jQuery=="undefined"||jQuery.event.triggered)return val;val=jQuery.event.handle.apply(arguments.callee.elem,arguments);return val;});handle.elem=elem;jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];handler.type=parts[1];var handlers=events[type];if(!handlers){handlers=events[type]={};if(!jQuery.event.special[type]||jQuery.event.special[type].setup.call(elem)===false){if(elem.addEventListener)elem.addEventListener(type,handle,false);else if(elem.attachEvent)elem.attachEvent("on"+type,handle);}}handlers[handler.guid]=handler;jQuery.event.global[type]=true;});elem=null;},guid:1,global:{},remove:function(elem,types,handler){if(elem.nodeType==3||elem.nodeType==8)return;var events=jQuery.data(elem,"events"),ret,index;if(events){if(types==undefined)for(var type in events)this.remove(elem,type);else{if(types.type){handler=types.handler;types=types.type;}jQuery.each(types.split(/\s+/),function(index,type){var parts=type.split(".");type=parts[0];if(events[type]){if(handler)delete events[type][handler.guid];else
for(handler in events[type])if(!parts[1]||events[type][handler].type==parts[1])delete events[type][handler];for(ret in events[type])break;if(!ret){if(!jQuery.event.special[type]||jQuery.event.special[type].teardown.call(elem)===false){if(elem.removeEventListener)elem.removeEventListener(type,jQuery.data(elem,"handle"),false);else if(elem.detachEvent)elem.detachEvent("on"+type,jQuery.data(elem,"handle"));}ret=null;delete events[type];}}});}for(ret in events)break;if(!ret){var handle=jQuery.data(elem,"handle");if(handle)handle.elem=null;jQuery.removeData(elem,"events");jQuery.removeData(elem,"handle");}}},trigger:function(type,data,elem,donative,extra){data=jQuery.makeArray(data||[]);if(!elem){if(this.global[type])jQuery("*").add([window,document]).trigger(type,data);}else{if(elem.nodeType==3||elem.nodeType==8)return undefined;var val,ret,fn=jQuery.isFunction(elem[type]||null),event=!data[0]||!data[0].preventDefault;if(event)data.unshift(this.fix({type:type,target:elem}));data[0].type=type;if(jQuery.isFunction(jQuery.data(elem,"handle")))val=jQuery.data(elem,"handle").apply(elem,data);if(!fn&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false)val=false;if(event)data.shift();if(extra&&jQuery.isFunction(extra)){ret=extra.apply(elem,val==null?data:data.concat(val));if(ret!==undefined)val=ret;}if(fn&&donative!==false&&val!==false&&!(jQuery.nodeName(elem,'a')&&type=="click")){this.triggered=true;try{elem[type]();}catch(e){}}this.triggered=false;}return val;},handle:function(event){var val;event=jQuery.event.fix(event||window.event||{});var parts=event.type.split(".");event.type=parts[0];var handlers=jQuery.data(this,"events")&&jQuery.data(this,"events")[event.type],args=Array.prototype.slice.call(arguments,1);args.unshift(event);for(var j in handlers){var handler=handlers[j];args[0].handler=handler;args[0].data=handler.data;if(!parts[1]||handler.type==parts[1]){var ret=handler.apply(this,args);if(val!==false)val=ret;if(ret===false){event.preventDefault();event.stopPropagation();}}}if(jQuery.browser.msie)event.target=event.preventDefault=event.stopPropagation=event.handler=event.data=null;return val;},fix:function(event){var originalEvent=event;event=jQuery.extend({},originalEvent);event.preventDefault=function(){if(originalEvent.preventDefault)originalEvent.preventDefault();originalEvent.returnValue=false;};event.stopPropagation=function(){if(originalEvent.stopPropagation)originalEvent.stopPropagation();originalEvent.cancelBubble=true;};if(!event.target)event.target=event.srcElement||document;if(event.target.nodeType==3)event.target=originalEvent.target.parentNode;if(!event.relatedTarget&&event.fromElement)event.relatedTarget=event.fromElement==event.target?event.toElement:event.fromElement;if(event.pageX==null&&event.clientX!=null){var doc=document.documentElement,body=document.body;event.pageX=event.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);event.pageY=event.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);}if(!event.which&&((event.charCode||event.charCode===0)?event.charCode:event.keyCode))event.which=event.charCode||event.keyCode;if(!event.metaKey&&event.ctrlKey)event.metaKey=event.ctrlKey;if(!event.which&&event.button)event.which=(event.button&1?1:(event.button&2?3:(event.button&4?2:0)));return event;},special:{ready:{setup:function(){bindReady();return;},teardown:function(){return;}},mouseenter:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseover",jQuery.event.special.mouseenter.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseover",jQuery.event.special.mouseenter.handler);return true;},handler:function(event){if(withinElement(event,this))return true;arguments[0].type="mouseenter";return jQuery.event.handle.apply(this,arguments);}},mouseleave:{setup:function(){if(jQuery.browser.msie)return false;jQuery(this).bind("mouseout",jQuery.event.special.mouseleave.handler);return true;},teardown:function(){if(jQuery.browser.msie)return false;jQuery(this).unbind("mouseout",jQuery.event.special.mouseleave.handler);return true;},handler:function(event){if(withinElement(event,this))return true;arguments[0].type="mouseleave";return jQuery.event.handle.apply(this,arguments);}}}};jQuery.fn.extend({bind:function(type,data,fn){return type=="unload"?this.one(type,data,fn):this.each(function(){jQuery.event.add(this,type,fn||data,fn&&data);});},one:function(type,data,fn){return this.each(function(){jQuery.event.add(this,type,function(event){jQuery(this).unbind(event);return(fn||data).apply(this,arguments);},fn&&data);});},unbind:function(type,fn){return this.each(function(){jQuery.event.remove(this,type,fn);});},trigger:function(type,data,fn){return this.each(function(){jQuery.event.trigger(type,data,this,true,fn);});},triggerHandler:function(type,data,fn){if(this[0])return jQuery.event.trigger(type,data,this[0],false,fn);return undefined;},toggle:function(){var args=arguments;return this.click(function(event){this.lastToggle=0==this.lastToggle?1:0;event.preventDefault();return args[this.lastToggle].apply(this,arguments)||false;});},hover:function(fnOver,fnOut){return this.bind('mouseenter',fnOver).bind('mouseleave',fnOut);},ready:function(fn){bindReady();if(jQuery.isReady)fn.call(document,jQuery);else
jQuery.readyList.push(function(){return fn.call(this,jQuery);});return this;}});jQuery.extend({isReady:false,readyList:[],ready:function(){if(!jQuery.isReady){jQuery.isReady=true;if(jQuery.readyList){jQuery.each(jQuery.readyList,function(){this.apply(document);});jQuery.readyList=null;}jQuery(document).triggerHandler("ready");}}});var readyBound=false;function bindReady(){if(readyBound)return;readyBound=true;if(document.addEventListener&&!jQuery.browser.opera)document.addEventListener("DOMContentLoaded",jQuery.ready,false);if(jQuery.browser.msie&&window==top)(function(){if(jQuery.isReady)return;try{document.documentElement.doScroll("left");}catch(error){setTimeout(arguments.callee,0);return;}jQuery.ready();})();if(jQuery.browser.opera)document.addEventListener("DOMContentLoaded",function(){if(jQuery.isReady)return;for(var i=0;i<document.styleSheets.length;i++)if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return;}jQuery.ready();},false);if(jQuery.browser.safari){var numStyles;(function(){if(jQuery.isReady)return;if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return;}if(numStyles===undefined)numStyles=jQuery("style, link[rel=stylesheet]").length;if(document.styleSheets.length!=numStyles){setTimeout(arguments.callee,0);return;}jQuery.ready();})();}jQuery.event.add(window,"load",jQuery.ready);}jQuery.each(("blur,focus,load,resize,scroll,unload,click,dblclick,"+"mousedown,mouseup,mousemove,mouseover,mouseout,change,select,"+"submit,keydown,keypress,keyup,error").split(","),function(i,name){jQuery.fn[name]=function(fn){return fn?this.bind(name,fn):this.trigger(name);};});var withinElement=function(event,elem){var parent=event.relatedTarget;while(parent&&parent!=elem)try{parent=parent.parentNode;}catch(error){parent=elem;}return parent==elem;};jQuery(window).bind("unload",function(){jQuery("*").add(document).unbind();});jQuery.fn.extend({load:function(url,params,callback){if(jQuery.isFunction(url))return this.bind("load",url);var off=url.indexOf(" ");if(off>=0){var selector=url.slice(off,url.length);url=url.slice(0,off);}callback=callback||function(){};var type="GET";if(params)if(jQuery.isFunction(params)){callback=params;params=null;}else{params=jQuery.param(params);type="POST";}var self=this;jQuery.ajax({url:url,type:type,dataType:"html",data:params,complete:function(res,status){if(status=="success"||status=="notmodified")self.html(selector?jQuery("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(selector):res.responseText);self.each(callback,[res.responseText,status,res]);}});return this;},serialize:function(){return jQuery.param(this.serializeArray());},serializeArray:function(){return this.map(function(){return jQuery.nodeName(this,"form")?jQuery.makeArray(this.elements):this;}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password/i.test(this.type));}).map(function(i,elem){var val=jQuery(this).val();return val==null?null:val.constructor==Array?jQuery.map(val,function(val,i){return{name:elem.name,value:val};}):{name:elem.name,value:val};}).get();}});jQuery.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){jQuery.fn[o]=function(f){return this.bind(o,f);};});var jsc=(new Date).getTime();jQuery.extend({get:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data=null;}return jQuery.ajax({type:"GET",url:url,data:data,success:callback,dataType:type});},getScript:function(url,callback){return jQuery.get(url,null,callback,"script");},getJSON:function(url,data,callback){return jQuery.get(url,data,callback,"json");},post:function(url,data,callback,type){if(jQuery.isFunction(data)){callback=data;data={};}return jQuery.ajax({type:"POST",url:url,data:data,success:callback,dataType:type});},ajaxSetup:function(settings){jQuery.extend(jQuery.ajaxSettings,settings);},ajaxSettings:{global:true,type:"GET",timeout:0,contentType:"application/x-www-form-urlencoded",processData:true,async:true,data:null,username:null,password:null,accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(s){var jsonp,jsre=/=\?(&|$)/g,status,data;s=jQuery.extend(true,s,jQuery.extend(true,{},jQuery.ajaxSettings,s));if(s.data&&s.processData&&typeof s.data!="string")s.data=jQuery.param(s.data);if(s.dataType=="jsonp"){if(s.type.toLowerCase()=="get"){if(!s.url.match(jsre))s.url+=(s.url.match(/\?/)?"&":"?")+(s.jsonp||"callback")+"=?";}else if(!s.data||!s.data.match(jsre))s.data=(s.data?s.data+"&":"")+(s.jsonp||"callback")+"=?";s.dataType="json";}if(s.dataType=="json"&&(s.data&&s.data.match(jsre)||s.url.match(jsre))){jsonp="jsonp"+jsc++;if(s.data)s.data=(s.data+"").replace(jsre,"="+jsonp+"$1");s.url=s.url.replace(jsre,"="+jsonp+"$1");s.dataType="script";window[jsonp]=function(tmp){data=tmp;success();complete();window[jsonp]=undefined;try{delete window[jsonp];}catch(e){}if(head)head.removeChild(script);};}if(s.dataType=="script"&&s.cache==null)s.cache=false;if(s.cache===false&&s.type.toLowerCase()=="get"){var ts=(new Date()).getTime();var ret=s.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+ts+"$2");s.url=ret+((ret==s.url)?(s.url.match(/\?/)?"&":"?")+"_="+ts:"");}if(s.data&&s.type.toLowerCase()=="get"){s.url+=(s.url.match(/\?/)?"&":"?")+s.data;s.data=null;}if(s.global&&!jQuery.active++)jQuery.event.trigger("ajaxStart");if((!s.url.indexOf("http")||!s.url.indexOf("//"))&&(s.dataType=="script"||s.dataType=="json")&&s.type.toLowerCase()=="get"){var head=document.getElementsByTagName("head")[0];var script=document.createElement("script");script.src=s.url;if(s.scriptCharset)script.charset=s.scriptCharset;if(!jsonp){var done=false;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){done=true;success();complete();head.removeChild(script);}};}head.appendChild(script);return undefined;}var requestDone=false;var xml=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();xml.open(s.type,s.url,s.async,s.username,s.password);try{if(s.data)xml.setRequestHeader("Content-Type",s.contentType);if(s.ifModified)xml.setRequestHeader("If-Modified-Since",jQuery.lastModified[s.url]||"Thu, 01 Jan 1970 00:00:00 GMT");xml.setRequestHeader("X-Requested-With","XMLHttpRequest");xml.setRequestHeader("Accept",s.dataType&&s.accepts[s.dataType]?s.accepts[s.dataType]+", */*":s.accepts._default);}catch(e){}if(s.beforeSend)s.beforeSend(xml);if(s.global)jQuery.event.trigger("ajaxSend",[xml,s]);var onreadystatechange=function(isTimeout){if(!requestDone&&xml&&(xml.readyState==4||isTimeout=="timeout")){requestDone=true;if(ival){clearInterval(ival);ival=null;}status=isTimeout=="timeout"&&"timeout"||!jQuery.httpSuccess(xml)&&"error"||s.ifModified&&jQuery.httpNotModified(xml,s.url)&&"notmodified"||"success";if(status=="success"){try{data=jQuery.httpData(xml,s.dataType);}catch(e){status="parsererror";}}if(status=="success"){var modRes;try{modRes=xml.getResponseHeader("Last-Modified");}catch(e){}if(s.ifModified&&modRes)jQuery.lastModified[s.url]=modRes;if(!jsonp)success();}else
jQuery.handleError(s,xml,status);complete();if(s.async)xml=null;}};if(s.async){var ival=setInterval(onreadystatechange,13);if(s.timeout>0)setTimeout(function(){if(xml){xml.abort();if(!requestDone)onreadystatechange("timeout");}},s.timeout);}try{xml.send(s.data);}catch(e){jQuery.handleError(s,xml,null,e);}if(!s.async)onreadystatechange();function success(){if(s.success)s.success(data,status);if(s.global)jQuery.event.trigger("ajaxSuccess",[xml,s]);}function complete(){if(s.complete)s.complete(xml,status);if(s.global)jQuery.event.trigger("ajaxComplete",[xml,s]);if(s.global&&!--jQuery.active)jQuery.event.trigger("ajaxStop");}return xml;},handleError:function(s,xml,status,e){if(s.error)s.error(xml,status,e);if(s.global)jQuery.event.trigger("ajaxError",[xml,s,e]);},active:0,httpSuccess:function(r){try{return!r.status&&location.protocol=="file:"||(r.status>=200&&r.status<300)||r.status==304||r.status==1223||jQuery.browser.safari&&r.status==undefined;}catch(e){}return false;},httpNotModified:function(xml,url){try{var xmlRes=xml.getResponseHeader("Last-Modified");return xml.status==304||xmlRes==jQuery.lastModified[url]||jQuery.browser.safari&&xml.status==undefined;}catch(e){}return false;},httpData:function(r,type){var ct=r.getResponseHeader("content-type");var xml=type=="xml"||!type&&ct&&ct.indexOf("xml")>=0;var data=xml?r.responseXML:r.responseText;if(xml&&data.documentElement.tagName=="parsererror")throw"parsererror";if(type=="script")jQuery.globalEval(data);if(type=="json")data=eval("("+data+")");return data;},param:function(a){var s=[];if(a.constructor==Array||a.jquery)jQuery.each(a,function(){s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));});else
for(var j in a)if(a[j]&&a[j].constructor==Array)jQuery.each(a[j],function(){s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));});else
s.push(encodeURIComponent(j)+"="+encodeURIComponent(a[j]));return s.join("&").replace(/%20/g,"+");}});jQuery.fn.extend({show:function(speed,callback){return speed?this.animate({height:"show",width:"show",opacity:"show"},speed,callback):this.filter(":hidden").each(function(){this.style.display=this.oldblock||"";if(jQuery.css(this,"display")=="none"){var elem=jQuery("<"+this.tagName+" />").appendTo("body");this.style.display=elem.css("display");if(this.style.display=="none")this.style.display="block";elem.remove();}}).end();},hide:function(speed,callback){return speed?this.animate({height:"hide",width:"hide",opacity:"hide"},speed,callback):this.filter(":visible").each(function(){this.oldblock=this.oldblock||jQuery.css(this,"display");this.style.display="none";}).end();},_toggle:jQuery.fn.toggle,toggle:function(fn,fn2){return jQuery.isFunction(fn)&&jQuery.isFunction(fn2)?this._toggle(fn,fn2):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){jQuery(this)[jQuery(this).is(":hidden")?"show":"hide"]();});},slideDown:function(speed,callback){return this.animate({height:"show"},speed,callback);},slideUp:function(speed,callback){return this.animate({height:"hide"},speed,callback);},slideToggle:function(speed,callback){return this.animate({height:"toggle"},speed,callback);},fadeIn:function(speed,callback){return this.animate({opacity:"show"},speed,callback);},fadeOut:function(speed,callback){return this.animate({opacity:"hide"},speed,callback);},fadeTo:function(speed,to,callback){return this.animate({opacity:to},speed,callback);},animate:function(prop,speed,easing,callback){var optall=jQuery.speed(speed,easing,callback);return this[optall.queue===false?"each":"queue"](function(){if(this.nodeType!=1)return false;var opt=jQuery.extend({},optall);var hidden=jQuery(this).is(":hidden"),self=this;for(var p in prop){if(prop[p]=="hide"&&hidden||prop[p]=="show"&&!hidden)return jQuery.isFunction(opt.complete)&&opt.complete.apply(this);if(p=="height"||p=="width"){opt.display=jQuery.css(this,"display");opt.overflow=this.style.overflow;}}if(opt.overflow!=null)this.style.overflow="hidden";opt.curAnim=jQuery.extend({},prop);jQuery.each(prop,function(name,val){var e=new jQuery.fx(self,opt,name);if(/toggle|show|hide/.test(val))e[val=="toggle"?hidden?"show":"hide":val](prop);else{var parts=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),start=e.cur(true)||0;if(parts){var end=parseFloat(parts[2]),unit=parts[3]||"px";if(unit!="px"){self.style[name]=(end||1)+unit;start=((end||1)/e.cur(true))*start;self.style[name]=start+unit;}if(parts[1])end=((parts[1]=="-="?-1:1)*end)+start;e.custom(start,end,unit);}else
e.custom(start,val,"");}});return true;});},queue:function(type,fn){if(jQuery.isFunction(type)||(type&&type.constructor==Array)){fn=type;type="fx";}if(!type||(typeof type=="string"&&!fn))return queue(this[0],type);return this.each(function(){if(fn.constructor==Array)queue(this,type,fn);else{queue(this,type).push(fn);if(queue(this,type).length==1)fn.apply(this);}});},stop:function(clearQueue,gotoEnd){var timers=jQuery.timers;if(clearQueue)this.queue([]);this.each(function(){for(var i=timers.length-1;i>=0;i--)if(timers[i].elem==this){if(gotoEnd)timers[i](true);timers.splice(i,1);}});if(!gotoEnd)this.dequeue();return this;}});var queue=function(elem,type,array){if(!elem)return undefined;type=type||"fx";var q=jQuery.data(elem,type+"queue");if(!q||array)q=jQuery.data(elem,type+"queue",array?jQuery.makeArray(array):[]);return q;};jQuery.fn.dequeue=function(type){type=type||"fx";return this.each(function(){var q=queue(this,type);q.shift();if(q.length)q[0].apply(this);});};jQuery.extend({speed:function(speed,easing,fn){var opt=speed&&speed.constructor==Object?speed:{complete:fn||!fn&&easing||jQuery.isFunction(speed)&&speed,duration:speed,easing:fn&&easing||easing&&easing.constructor!=Function&&easing};opt.duration=(opt.duration&&opt.duration.constructor==Number?opt.duration:{slow:600,fast:200}[opt.duration])||400;opt.old=opt.complete;opt.complete=function(){if(opt.queue!==false)jQuery(this).dequeue();if(jQuery.isFunction(opt.old))opt.old.apply(this);};return opt;},easing:{linear:function(p,n,firstNum,diff){return firstNum+diff*p;},swing:function(p,n,firstNum,diff){return((-Math.cos(p*Math.PI)/2)+0.5)*diff+firstNum;}},timers:[],timerId:null,fx:function(elem,options,prop){this.options=options;this.elem=elem;this.prop=prop;if(!options.orig)options.orig={};}});jQuery.fx.prototype={update:function(){if(this.options.step)this.options.step.apply(this.elem,[this.now,this]);(jQuery.fx.step[this.prop]||jQuery.fx.step._default)(this);if(this.prop=="height"||this.prop=="width")this.elem.style.display="block";},cur:function(force){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null)return this.elem[this.prop];var r=parseFloat(jQuery.css(this.elem,this.prop,force));return r&&r>-10000?r:parseFloat(jQuery.curCSS(this.elem,this.prop))||0;},custom:function(from,to,unit){this.startTime=(new Date()).getTime();this.start=from;this.end=to;this.unit=unit||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var self=this;function t(gotoEnd){return self.step(gotoEnd);}t.elem=this.elem;jQuery.timers.push(t);if(jQuery.timerId==null){jQuery.timerId=setInterval(function(){var timers=jQuery.timers;for(var i=0;i<timers.length;i++)if(!timers[i]())timers.splice(i--,1);if(!timers.length){clearInterval(jQuery.timerId);jQuery.timerId=null;}},13);}},show:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.show=true;this.custom(0,this.cur());if(this.prop=="width"||this.prop=="height")this.elem.style[this.prop]="1px";jQuery(this.elem).show();},hide:function(){this.options.orig[this.prop]=jQuery.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0);},step:function(gotoEnd){var t=(new Date()).getTime();if(gotoEnd||t>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var done=true;for(var i in this.options.curAnim)if(this.options.curAnim[i]!==true)done=false;if(done){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(jQuery.css(this.elem,"display")=="none")this.elem.style.display="block";}if(this.options.hide)this.elem.style.display="none";if(this.options.hide||this.options.show)for(var p in this.options.curAnim)jQuery.attr(this.elem.style,p,this.options.orig[p]);}if(done&&jQuery.isFunction(this.options.complete))this.options.complete.apply(this.elem);return false;}else{var n=t-this.startTime;this.state=n/this.options.duration;this.pos=jQuery.easing[this.options.easing||(jQuery.easing.swing?"swing":"linear")](this.state,n,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update();}return true;}};jQuery.fx.step={scrollLeft:function(fx){fx.elem.scrollLeft=fx.now;},scrollTop:function(fx){fx.elem.scrollTop=fx.now;},opacity:function(fx){jQuery.attr(fx.elem.style,"opacity",fx.now);},_default:function(fx){fx.elem.style[fx.prop]=fx.now+fx.unit;}};jQuery.fn.offset=function(){var left=0,top=0,elem=this[0],results;if(elem)with(jQuery.browser){var parent=elem.parentNode,offsetChild=elem,offsetParent=elem.offsetParent,doc=elem.ownerDocument,safari2=safari&&parseInt(version)<522,fixed=jQuery.css(elem,"position")=="fixed";if(elem.getBoundingClientRect){var box=elem.getBoundingClientRect();add(box.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),box.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));add(-doc.documentElement.clientLeft,-doc.documentElement.clientTop);}else{add(elem.offsetLeft,elem.offsetTop);while(offsetParent){add(offsetParent.offsetLeft,offsetParent.offsetTop);if(mozilla&&!/^t(able|d|h)$/i.test(offsetParent.tagName)||safari&&!safari2)border(offsetParent);if(!fixed&&jQuery.css(offsetParent,"position")=="fixed")fixed=true;offsetChild=/^body$/i.test(offsetParent.tagName)?offsetChild:offsetParent;offsetParent=offsetParent.offsetParent;}while(parent&&parent.tagName&&!/^body|html$/i.test(parent.tagName)){if(!/^inline|table.*$/i.test(jQuery.css(parent,"display")))add(-parent.scrollLeft,-parent.scrollTop);if(mozilla&&jQuery.css(parent,"overflow")!="visible")border(parent);parent=parent.parentNode;}if((safari2&&(fixed||jQuery.css(offsetChild,"position")=="absolute"))||(mozilla&&jQuery.css(offsetChild,"position")!="absolute"))add(-doc.body.offsetLeft,-doc.body.offsetTop);if(fixed)add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));}results={top:top,left:left};}function border(elem){add(jQuery.curCSS(elem,"borderLeftWidth",true),jQuery.curCSS(elem,"borderTopWidth",true));}function add(l,t){left+=parseInt(l)||0;top+=parseInt(t)||0;}return results;};})();;function SoundManager(smURL,smID){var self=this;this.version='V2.0b.20070415';this.url=(smURL||'soundmanager2.swf');this.debugMode=true;this.useConsole=true;this.consoleOnly=false;this.nullURL='data/null.mp3';this.defaultOptions={'autoLoad':false,'stream':true,'autoPlay':false,'onid3':null,'onload':null,'whileloading':null,'onplay':null,'whileplaying':null,'onstop':null,'onfinish':null,'onbeforefinish':null,'onbeforefinishtime':5000,'onbeforefinishcomplete':null,'onjustbeforefinish':null,'onjustbeforefinishtime':200,'multiShot':true,'pan':0,'volume':100}
this.allowPolling=true;this.enabled=false;this.o=null;this.id=(smID||'sm2movie');this.oMC=null;this.sounds=[];this.soundIDs=[];this.isIE=(navigator.userAgent.match(/MSIE/));this.isSafari=(navigator.userAgent.match(/safari/i));this.debugID='soundmanager-debug';this._debugOpen=true;this._didAppend=false;this._appendSuccess=false;this._didInit=false;this._disabled=false;this._hasConsole=(typeof console!='undefined'&&typeof console.log!='undefined');this._debugLevels=!self.isSafari?['debug','info','warn','error']:['log','log','log','log'];this.getMovie=function(smID){return self.isIE?window[smID]:(self.isSafari?document[smID+'-embed']:document.getElementById(smID+'-embed'));}
this.loadFromXML=function(sXmlUrl){try{self.o._loadFromXML(sXmlUrl);}catch(e){self._failSafely();return true;}}
this.createSound=function(oOptions){if(!self._didInit)throw new Error('soundManager.createSound(): Not loaded yet - wait for soundManager.onload() before calling sound-related methods');if(arguments.length==2){oOptions={'id':arguments[0],'url':arguments[1]}}
var thisOptions=self._mergeObjects(oOptions);self._writeDebug('soundManager.createSound(): "<a href="#" onclick="soundManager.play(\''+thisOptions.id+'\');return false" title="play this sound">'+thisOptions.id+'</a>" ('+thisOptions.url+')',1);if(self._idCheck(thisOptions.id,true)){self._writeDebug('sound '+thisOptions.id+' already defined - exiting',2);return false;}
self.sounds[thisOptions.id]=new SMSound(self,thisOptions);self.soundIDs[self.soundIDs.length]=thisOptions.id;try{self.o._createSound(thisOptions.id,thisOptions.onjustbeforefinishtime);}catch(e){self._failSafely();return true;}
if(thisOptions.autoLoad||thisOptions.autoPlay)self.sounds[thisOptions.id].load(thisOptions);if(thisOptions.autoPlay)self.sounds[thisOptions.id].playState=1;}
this.destroySound=function(sID){if(!self._idCheck(sID))return false;for(var i=self.soundIDs.length;i--;){if(self.soundIDs[i]==sID){delete self.soundIDs[i];continue;}}
self.sounds[sID].unload();delete self.sounds[sID];}
this.load=function(sID,oOptions){if(!self._idCheck(sID))return false;self.sounds[sID].load(oOptions);}
this.unload=function(sID){if(!self._idCheck(sID))return false;self.sounds[sID].unload();}
this.play=function(sID,oOptions){if(!self._idCheck(sID)){if(typeof oOptions!='Object')oOptions={url:oOptions};if(oOptions&&oOptions.url){self._writeDebug('soundController.play(): attempting to create "'+sID+'"',1);oOptions.id=sID;self.createSound(oOptions);}else{return false;}}
self.sounds[sID].play(oOptions);}
this.start=this.play;this.setPosition=function(sID,nMsecOffset){if(!self._idCheck(sID))return false;self.sounds[sID].setPosition(nMsecOffset);}
this.stop=function(sID){if(!self._idCheck(sID))return false;self._writeDebug('soundManager.stop('+sID+')',1);self.sounds[sID].stop();}
this.stopAll=function(){self._writeDebug('soundManager.stopAll()',1);for(var oSound in self.sounds){if(self.sounds[oSound]instanceof SMSound)self.sounds[oSound].stop();}}
this.pause=function(sID){if(!self._idCheck(sID))return false;self.sounds[sID].pause();}
this.resume=function(sID){if(!self._idCheck(sID))return false;self.sounds[sID].resume();}
this.togglePause=function(sID){if(!self._idCheck(sID))return false;self.sounds[sID].togglePause();}
this.setPan=function(sID,nPan){if(!self._idCheck(sID))return false;self.sounds[sID].setPan(nPan);}
this.setVolume=function(sID,nVol){if(!self._idCheck(sID))return false;self.sounds[sID].setVolume(nVol);}
this.setPolling=function(bPolling){if(!self.o||!self.allowPolling)return false;self._writeDebug('soundManager.setPolling('+bPolling+')');self.o._setPolling(bPolling);}
this.disable=function(){if(self._disabled)return false;self._disabled=true;self._writeDebug('soundManager.disable(): Disabling all functions - future calls will return false.',1);for(var i=self.soundIDs.length;i--;){self._disableObject(self.sounds[self.soundIDs[i]]);}
self.initComplete();self._disableObject(self);}
this.getSoundById=function(sID,suppressDebug){if(!sID)throw new Error('SoundManager.getSoundById(): sID is null/undefined');var result=self.sounds[sID];if(!result&&!suppressDebug){self._writeDebug('"'+sID+'" is an invalid sound ID.',2);}
return result;}
this.onload=function(){soundManager._writeDebug('<em>Warning</em>: soundManager.onload() is undefined.',2);}
this.onerror=function(){}
this._idCheck=this.getSoundById;this._disableObject=function(o){for(var oProp in o){if(typeof o[oProp]=='function'&&typeof o[oProp]._protected=='undefined')o[oProp]=function(){return false;}}
oProp=null;}
this._failSafely=function(){var flashCPLink='http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html';var fpgssTitle='You may need to whitelist this location/domain eg. file:///C:/ or C:/ or mysite.com, or set ALWAYS ALLOW under the Flash Player Global Security Settings page. Note that this seems to apply only to file system viewing.';var flashCPL='<a href="'+flashCPLink+'" title="'+fpgssTitle+'">view/edit</a>';var FPGSS='<a href="'+flashCPLink+'" title="Flash Player Global Security Settings">FPGSS</a>';if(!self._disabled){self._writeDebug('soundManager: JS-&gt;Flash communication failed. Possible causes: flash/browser security restrictions ('+flashCPL+'), insufficient browser/plugin support, or .swf not found',2);self._writeDebug('Verify that the movie path of <em>'+self.url+'</em> is correct (<a href="'+self.url+'" title="If you get a 404/not found, fix it!">test link</a>)',1);if(self._didAppend){if(!document.domain){self._writeDebug('Loading from local file system? (document.domain appears to be null, this URL path may need to be added to \'trusted locations\' in '+FPGSS+')',1);self._writeDebug('Possible security/domain restrictions ('+flashCPL+'), should work when served by http on same domain',1);}}
self.disable();}}
this._createMovie=function(smID,smURL){if(self._didAppend&&self._appendSuccess)return false;if(window.location.href.indexOf('debug=1')+1)self.debugMode=true;self._didAppend=true;var html=['<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="16" height="16" id="'+smID+'"><param name="movie" value="'+smURL+'"><param name="quality" value="high"><param name="allowScriptAccess" value="always" /></object>','<embed name="'+smID+'-embed" id="'+smID+'-embed" src="'+smURL+'" width="1" height="1" quality="high" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>'];var toggleElement='<div id="'+self.debugID+'-toggle" style="position:fixed;_position:absolute;right:0px;bottom:0px;_top:0px;width:1.2em;height:1.2em;line-height:1.2em;margin:2px;padding:0px;text-align:center;border:1px solid #999;cursor:pointer;background:#fff;color:#333;z-index:706" title="Toggle SM2 debug console" onclick="soundManager._toggleDebug()">-</div>';var debugHTML='<div id="'+self.debugID+'" style="display:'+(self.debugMode&&((!self._hasConsole||!self.useConsole)||(self.useConsole&&self._hasConsole&&!self.consoleOnly))?'block':'none')+';opacity:0.85"></div>';var appXHTML='soundManager._createMovie(): appendChild/innerHTML set failed. Serving application/xhtml+xml MIME type? Browser may be enforcing strict rules, not allowing write to innerHTML. (PS: If so, this means your commitment to XML validation is going to break stuff now, because this part isn\'t finished yet. ;))';var sHTML='<div style="position:absolute;left:-256px;top:-256px;width:1px;height:1px" class="movieContainer">'+html[self.isIE?0:1]+'</div>'+(self.debugMode&&((!self._hasConsole||!self.useConsole)||(self.useConsole&&self._hasConsole&&!self.consoleOnly))&&!document.getElementById(self.debugID)?'x'+debugHTML+toggleElement:'');var oTarget=(document.body?document.body:document.getElementsByTagName('div')[0]);if(oTarget){self.oMC=document.createElement('div');self.oMC.className='movieContainer';self.oMC.style.position='absolute';self.oMC.style.left='-256px';self.oMC.style.width='1px';self.oMC.style.height='1px';try{oTarget.appendChild(self.oMC);self.oMC.innerHTML=html[self.isIE?0:1];self._appendSuccess=true;}catch(e){throw new Error(appXHTML);}
if(!document.getElementById(self.debugID)&&((!self._hasConsole||!self.useConsole)||(self.useConsole&&self._hasConsole&&!self.consoleOnly))){var oDebug=document.createElement('div');oDebug.id=self.debugID;oDebug.style.display=(self.debugMode?'block':'none');if(self.debugMode){try{var oD=document.createElement('div');oTarget.appendChild(oD);oD.innerHTML=toggleElement;}catch(e){throw new Error(appXHTML);}}
oTarget.appendChild(oDebug);}
oTarget=null;}
self._writeDebug('-- SoundManager 2 Version '+self.version.substr(1)+' --',1);self._writeDebug('soundManager._createMovie(): trying to load <a href="'+smURL+'" title="Test this link (404=bad)">'+smURL+'</a>',1);}
this._writeDebug=function(sText,sType){if(!self.debugMode)return false;if(self._hasConsole&&self.useConsole){console[self._debugLevels[sType]||'log'](sText);if(self.useConsoleOnly)return true;}
var sDID='soundmanager-debug';try{var o=document.getElementById(sDID);if(!o)return false;var p=document.createElement('div');p.innerHTML=sText;o.insertBefore(p,o.firstChild);}catch(e){}
o=null;}
this._writeDebug._protected=true;this._writeDebugAlert=function(sText){alert(sText);}
if(window.location.href.indexOf('debug=alert')+1){self.debugMode=true;self._writeDebug=self._writeDebugAlert;}
this._toggleDebug=function(){var o=document.getElementById(self.debugID);var oT=document.getElementById(self.debugID+'-toggle');if(!o)return false;if(self._debugOpen){oT.innerHTML='+';o.style.display='none';}else{oT.innerHTML='-';o.style.display='block';}
self._debugOpen=!self._debugOpen;}
this._toggleDebug._protected=true;this._debug=function(){self._writeDebug('soundManager._debug(): sounds by id/url:',0);for(var i=0,j=self.soundIDs.length;i<j;i++){self._writeDebug(self.sounds[self.soundIDs[i]].sID+' | '+self.sounds[self.soundIDs[i]].url,0);}}
this._mergeObjects=function(oMain,oAdd){var o1=oMain;var o2=(typeof oAdd=='undefined'?self.defaultOptions:oAdd);for(var o in o2){if(typeof o1[o]=='undefined')o1[o]=o2[o];}
return o1;}
this.createMovie=function(sURL){if(sURL)self.url=sURL;self._initMovie();}
this._initMovie=function(){if(self.o)return false;self.o=self.getMovie(self.id);if(!self.o){self._createMovie(self.id,self.url);self.o=self.getMovie(self.id);}
if(self.o){self._writeDebug('soundManager._initMovie(): Got '+self.o.nodeName+' element ('+(self._didAppend?'created via JS':'static HTML')+')',1);}}
this.initComplete=function(){if(self._didInit)return false;self._didInit=true;self._writeDebug('-- SoundManager 2 '+(self._disabled?'failed to load':'loaded')+' ('+(self._disabled?'security/load error':'OK')+') --',1);if(self._disabled){self._writeDebug('soundManager.initComplete(): calling soundManager.onerror()',1);self.onerror.apply(window);return false;}
self._writeDebug('soundManager.initComplete(): calling soundManager.onload()',1);try{self.onload.apply(window);}catch(e){self._writeDebug('soundManager.onload() threw an exception: '+e.message,2);throw e;}
self._writeDebug('soundManager.onload() complete',1);}
this.init=function(){if(window.removeEventListener){window.removeEventListener('load',self.beginInit,false);}else if(window.detachEvent){window.detachEvent('onload',self.beginInit);}
try{self.o._externalInterfaceTest();self._writeDebug('Flash ExternalInterface call (JS -&gt; Flash) succeeded.',1);if(!self.allowPolling)self._writeDebug('Polling (whileloading/whileplaying support) is disabled.',1);self.setPolling(true);self.enabled=true;}catch(e){self._failSafely();self.initComplete();return false;}
self.initComplete();}
this.beginDelayedInit=function(){setTimeout(self.beginInit,200);}
this.beginInit=function(){self.createMovie();self._initMovie();setTimeout(self.init,1000);}
this.destruct=function(){if(self.isSafari){for(var i=self.soundIDs.length;i--;){if(self.sounds[self.soundIDs[i]].readyState==1)self.sounds[self.soundIDs[i]].unload();}}
self.disable();}}
function SMSound(oSM,oOptions){var self=this;var sm=oSM;this.sID=oOptions.id;this.url=oOptions.url;this.options=sm._mergeObjects(oOptions);this.id3={}
self.resetProperties=function(bLoaded){self.bytesLoaded=null;self.bytesTotal=null;self.position=null;self.duration=null;self.durationEstimate=null;self.loaded=false;self.loadSuccess=null;self.playState=0;self.paused=false;self.readyState=0;self.didBeforeFinish=false;self.didJustBeforeFinish=false;}
self.resetProperties();this.load=function(oOptions){self.loaded=false;self.loadSuccess=null;self.readyState=1;self.playState=(oOptions.autoPlay||false);var thisOptions=sm._mergeObjects(oOptions);if(typeof thisOptions.url=='undefined')thisOptions.url=self.url;try{sm._writeDebug('loading '+thisOptions.url,1);sm.o._load(self.sID,thisOptions.url,thisOptions.stream,thisOptions.autoPlay,thisOptions.whileloading?1:0);}catch(e){sm._writeDebug('SMSound().load(): JS-&gt;Flash communication failed.',2);}}
this.unload=function(){sm._writeDebug('SMSound().unload(): "'+self.sID+'"');self.setPosition(0);sm.o._unload(self.sID,sm.nullURL);self.resetProperties();}
this.play=function(oOptions){if(!oOptions)oOptions={};if(oOptions.onfinish)self.options.onfinish=oOptions.onfinish;if(oOptions.onbeforefinish)self.options.onbeforefinish=oOptions.onbeforefinish;if(oOptions.onjustbeforefinish)self.options.onjustbeforefinish=oOptions.onjustbeforefinish;var thisOptions=sm._mergeObjects(oOptions);if(self.playState==1){var allowMulti=thisOptions.multiShot;if(!allowMulti){sm._writeDebug('SMSound.play(): "'+self.sID+'" already playing? (one-shot)',1);return false;}else{sm._writeDebug('SMSound.play(): "'+self.sID+'" already playing (multi-shot)',1);}}
if(!self.loaded){if(self.readyState==0){sm._writeDebug('SMSound.play(): .play() before load request. Attempting to load "'+self.sID+'"',1);thisOptions.stream=true;thisOptions.autoPlay=true;self.load(thisOptions);}else if(self.readyState==2){sm._writeDebug('SMSound.play(): Could not load "'+self.sID+'" - exiting',2);return false;}else{sm._writeDebug('SMSound.play(): "'+self.sID+'" is loading - attempting to play..',1);}}else{sm._writeDebug('SMSound.play(): "'+self.sID+'"');}
if(self.paused){self.resume();}else{self.playState=1;self.position=(thisOptions.offset||0);if(thisOptions.onplay)thisOptions.onplay.apply(self);self.setVolume(thisOptions.volume);self.setPan(thisOptions.pan);if(!thisOptions.autoPlay){sm.o._start(self.sID,thisOptions.loop||1,self.position);}}}
this.start=this.play;this.stop=function(bAll){if(self.playState==1){self.playState=0;self.paused=false;if(sm.defaultOptions.onstop)sm.defaultOptions.onstop.apply(self);sm.o._stop(self.sID);}}
this.setPosition=function(nMsecOffset){sm.o._setPosition(self.sID,nMsecOffset/1000,self.paused||!self.playState);}
this.pause=function(){if(self.paused)return false;sm._writeDebug('SMSound.pause()');self.paused=true;sm.o._pause(self.sID);}
this.resume=function(){if(!self.paused)return false;sm._writeDebug('SMSound.resume()');self.paused=false;sm.o._pause(self.sID);}
this.togglePause=function(){sm._writeDebug('SMSound.togglePause()');if(!self.playState){self.play({offset:self.position/1000});return false;}
if(self.paused){sm._writeDebug('SMSound.togglePause(): resuming..');self.resume();}else{sm._writeDebug('SMSound.togglePause(): pausing..');self.pause();}}
this.setPan=function(nPan){if(typeof nPan=='undefined')nPan=0;sm.o._setPan(self.sID,nPan);self.options.pan=nPan;}
this.setVolume=function(nVol){if(typeof nVol=='undefined')nVol=100;sm.o._setVolume(self.sID,nVol);self.options.volume=nVol;}
this._whileloading=function(nBytesLoaded,nBytesTotal,nDuration){self.bytesLoaded=nBytesLoaded;self.bytesTotal=nBytesTotal;self.duration=nDuration;self.durationEstimate=parseInt((self.bytesTotal/self.bytesLoaded)*self.duration);if(self.readyState!=3&&self.options.whileloading)self.options.whileloading.apply(self);}
this._onid3=function(oID3PropNames,oID3Data){sm._writeDebug('SMSound()._onid3(): "'+this.sID+'" ID3 data received.');var oData=[];for(var i=0,j=oID3PropNames.length;i<j;i++){oData[oID3PropNames[i]]=oID3Data[i];}
self.id3=sm._mergeObjects(self.id3,oData);if(self.options.onid3)self.options.onid3.apply(self);}
this._whileplaying=function(nPosition){if(isNaN(nPosition)||nPosition==null)return false;self.position=nPosition;if(self.playState==1){if(self.options.whileplaying)self.options.whileplaying.apply(self);if(self.loaded&&self.options.onbeforefinish&&self.options.onbeforefinishtime&&!self.didBeforeFinish&&self.duration-self.position<=self.options.onbeforefinishtime){sm._writeDebug('duration-position &lt;= onbeforefinishtime: '+self.duration+' - '+self.position+' &lt= '+self.options.onbeforefinishtime+' ('+(self.duration-self.position)+')');self._onbeforefinish();}}}
this._onload=function(bSuccess){bSuccess=(bSuccess==1?true:false);sm._writeDebug('SMSound._onload(): "'+self.sID+'"'+(bSuccess?' loaded.':' failed to load (or loaded from cache - weird bug) - [<a href="'+self.url+'">test URL</a>]'));self.loaded=bSuccess;self.loadSuccess=bSuccess;self.readyState=bSuccess?3:2;if(self.options.onload)self.options.onload.apply(self);}
this._onbeforefinish=function(){if(!self.didBeforeFinish){self.didBeforeFinish=true;if(self.options.onbeforefinish)self.options.onbeforefinish.apply(self);}}
this._onjustbeforefinish=function(msOffset){if(!self.didJustBeforeFinish){self.didJustBeforeFinish=true;if(self.options.onjustbeforefinish)self.options.onjustbeforefinish.apply(self);;}}
this._onfinish=function(){sm._writeDebug('SMSound._onfinish(): "'+self.sID+'"');self.playState=0;self.paused=false;if(self.options.onfinish)self.options.onfinish.apply(self);if(self.options.onbeforefinishcomplete)self.options.onbeforefinishcomplete.apply(self);self.setPosition(0);self.didBeforeFinish=false;self.didJustBeforeFinish=false;}}
var soundManager=new SoundManager();if(window.addEventListener){window.addEventListener('load',soundManager.beginDelayedInit,false);window.addEventListener('beforeunload',soundManager.destruct,false);}else if(window.attachEvent){window.attachEvent('onload',soundManager.beginInit);window.attachEvent('beforeunload',soundManager.destruct);}else{soundManager.onerror();soundManager.disable();};var PHI=1.61803398874989484820458683;var PHI_INV=1/PHI;function mult(m1,m2){var result=new Array(4);for(var i=0;i<4;i++){result[i]=new Array(4);}
for(var i=0;i<3;i++){result[i][0]=m1[i][0]*m2[0][0]+m1[i][1]*m2[1][0]+m1[i][2]*m2[2][0]+m1[i][3]*m2[3][0];result[i][1]=m1[i][0]*m2[0][1]+m1[i][1]*m2[1][1]+m1[i][2]*m2[2][1]+m1[i][3]*m2[3][1];result[i][2]=m1[i][0]*m2[0][2]+m1[i][1]*m2[1][2]+m1[i][2]*m2[2][2]+m1[i][3]*m2[3][2];result[i][3]=m1[i][0]*m2[0][3]+m1[i][1]*m2[1][3]+m1[i][2]*m2[2][3]+m1[i][3]*m2[3][3];}
return result;}
function multV(m,v0,v1,v2,v3){var result=new Array(4);result[0]=m[0][0]*v0+m[0][1]*v1+m[0][2]*v2+m[0][3]*v3;result[1]=m[1][0]*v0+m[1][1]*v1+m[1][2]*v2+m[1][3]*v3;result[2]=m[2][0]*v0+m[2][1]*v1+m[2][2]*v2+m[2][3]*v3;result[3]=m[3][0]*v0+m[3][1]*v1+m[3][2]*v2+m[3][3]*v3;return result;}
function identity(){return[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];}
function JS3D(renderDiv,maxZ){this.rField=document.getElementById(renderDiv);if(maxZ)this.maxZ=maxZ;else this.maxZ=0;this.initCoordinates();this.points=new Array();}
JS3D.prototype={initCoordinates:function(){this.xPos=this.rField.style.left.substring(0,this.rField.style.left.indexOf("px"));this.yPos=this.rField.style.top.substring(0,this.rField.style.left.indexOf("px"));this.width=this.rField.style.width.substring(0,this.rField.style.width.indexOf("px"));this.height=this.rField.style.height.substring(0,this.rField.style.height.indexOf("px"));this.resetMatrix();},resetMatrix:function(){this.matrix=identity();this.matrix=this.translate(this.width/2,this.height/2,0);},rotateX:function(angle,m){if(!m)m=this.matrix;var c=Math.cos(angle);var s=Math.sin(angle);return mult(m,[[1,0,0,0],[0,c,-s,0],[0,s,c,0],[0,0,0,1]]);},rotateY:function(angle,m){if(!m)m=this.matrix;var c=Math.cos(angle);var s=Math.sin(angle);return mult(m,[[c,0,s,0],[0,1,0,0],[-s,0,c,0],[0,0,0,1]]);},rotateZ:function(angle,m){if(!m)m=this.matrix;var c=Math.cos(angle);var s=Math.sin(angle);return mult(m,[[c,-s,0,0],[s,c,0,0],[0,0,1,0],[0,0,0,1]]);},scale:function(scaleX,scaleY,scaleZ,m){if(!m)m=this.matrix;return mult(m,[[scaleX,0,0,0],[0,scaleY,0,0],[0,0,scaleZ,0],[0,0,0,1]]);},translate:function(dX,dY,dZ,m){if(!m)m=this.matrix;return mult(m,[[1,0,0,dX],[0,1,0,dY],[0,0,1,dZ],[0,0,0,1]]);},addPoint:function(x,y,z,text,m,size){if(!m)m=identity();var v=multV(m,x,y,z,1);var l=this.points.length;this.points[l]=new Point(v[0],v[1],v[2],text,size);this.rField.appendChild(this.points[l].div);return this.points[l];},addPointV:function(v,text){this.addPoint(v[0],v[1],v[2],text);},addLine:function(x1,y1,z1,x2,y2,z2,num,text,m,size){if(!text)text="*";if(!m)m=identity();var dx=x2-x1;var dy=y2-y1;var dz=z2-z1;var length=Math.sqrt(dx*dx+dy*dy+dz*dz);for(var i=0;i<=num;i++){var px=x1+dx*i/num;var py=y1+dy*i/num;var pz=z1+dz*i/num;this.addPoint(px,py,pz,text,m,size);}},removePoint:function(p){var point=(typeof(p)=='number'?this.points[p]:p);for(var i=0;i<this.points.length;i++){if(this.points[i]==point)
this.points.splice(i,1);}
if(this.rField&&point.div)
try{this.rField.removeChild(point.div);}catch(e){ }},clearPoints:function(){for(var i=0;i<this.points.length;i++){this.rField.removeChild(this.points[i].div);}
this.points.length=0;},nPoints:function(){return this.points.length;},drawPoint:function(index){var point=this.points[index];var div=point.div;var tPoint=multV(this.matrix,point.x,point.y,point.z,point.W);if(tPoint[0]<0||tPoint[0]>this.width||tPoint[1]<0||tPoint[1]>this.height||tPoint[2]>=this.maxZ){div.style.visibility="hidden";return;}
div.style.visibility="visible";div.style.left=tPoint[0]+"px";div.style.top=tPoint[1]+"px";div.style.fontSize=500*point.size/(-tPoint[2])+"px";},paint:function(){for(var i=0;i<this.points.length;i++){this.drawPoint(i);}}}
function Point(x,y,z,text,size){this.x=x;this.y=y;this.z=z;this.W=1;this.size=size||10;this.div=document.createElement("div");if(text)this.div.innerHTML=text;else this.div.innerHTML="*";this.div.style.position="absolute";this.div.style.fontSize=size+"px";};function JS3DEngine(js3d,minZ,dt){this.init(js3d,minZ,dt);}
JS3DEngine.prototype={canvas:null,minZ:100,dt:100,time:0,timer:null,stopped:false,actions:null,init:function(canvas,minZ,dt){if(this.timer)
this.timer.stop();this.time=0;this.canvas=canvas;this.minZ=minZ;this.dt=dt;this.stop();this.reset();this.actions=new Array();this.paint();var self=this;this.timer=timer(self.dt,function(timer){if(!self.stopped){self.canvas.matrix=self.initMatrix();self.time+=dt;for(var i=0;i<self.actions.length;){if(self.actions[i].action.step()){if(self.actions){self.actions.splice(i,1);}}else{i++;}}
self.paint();}});},initMatrix:function(){this.canvas.resetMatrix();return this.canvas.translate(0,0,this.minZ);},stop:function(){this.stopped=true;},start:function(){this.stopped=false;},reset:function(){this.time=0;},getEngineTime:function(){return this.time;},isStopped:function(){return this.stopped;},getTimeStep:function(){return this.dt;},addAction:function(fn,id){fn.setEngine(this);this.actions.push({id:id,action:fn});},getAction:function(id){for(var i=0;i<this.actions.length;i++){if(this.actions[i].id==id)
return this.actions[i].action;}
return false;},paint:function(){this.canvas.paint();},destroy:function(){if(this.actions)
this.actions.splice(0,this.actions.length);this.actions=new Array();this.canvas.clearPoints();this.timer.stop();}};const ERROR=3;const WARNING=2;const NOTICE=1;const NO_DEBUG=4;const DEBUGGING_LEVEL=NO_DEBUG;;$j=jQuery.noConflict();var translations=new Array();const LOCALE_ID_PREFIX='locale-';var currentLanguage;const SUPPORTED_LANGUAGES=['en','fr'];const DEFAULT_LANGUAGE='fr';if(typeof(navigator.language)!='undefined'){currentLanguage=DEFAULT_LANGUAGE;}
function t(stringId,changeable,lang){if(typeof(changeable)=='undefined')
changeable=true;if(changeable)
return'<div class="translated" style="display: inline" id="'+LOCALE_ID_PREFIX+stringId+'">'+getTranslation(stringId,lang)+'</div>';else
return getTranslation(stringId,lang);}
function getTranslation(stringId,lang){lang=lang||currentLanguage;if(translations[lang])
{var value=translations[lang][stringId];if(value)
return value;else{log("Translation does not exist for stringId = '"+stringId+"' and language = '"+lang+"'.",WARNING);return"";}}else{log("No translations exist for language = '"+lang+"'.",WARNING);return"";}}
function setTranslation(lang,stringId,value){translations[lang][stringId]=value;}
function addLanguage(lang){if(!translations[lang])
translations[lang]=new Array();}
function setLocale(lang){log("Set locale to "+lang);currentLanguage=lang;$j('.translated').each(function(){$j(this).html(getTranslation(this.id.substring(LOCALE_ID_PREFIX.length)));});};addLanguage('fr');setTranslation('fr','page-back',"Retour");setTranslation('fr','home-button-intro','Tutoriel interactif');setTranslation('fr','home-button-new','Créer un nouveau vévé');setTranslation('fr','home-button-load','Ouvrir un vévé');setTranslation('fr','home-button-info','Infos');setTranslation('fr','home-button-credits','Crédits');setTranslation('fr','game-button-quit','Quitter');setTranslation('fr','game-button-new','Nouveau vévé');setTranslation('fr','game-button-load','Ouvrir un vévé');setTranslation('fr','tutorial-0',"Vévé est un jeu d'association de mots");setTranslation('fr','tutorial-1',"Vévé apprend");setTranslation('fr','tutorial-2',"Votre vévé apprend à partir des mots que vous écrivez");setTranslation('fr','tutorial-3',"Le jeu va commencer");setTranslation('fr','tutorial-4',"Vévé va vous parler");setTranslation('fr','tutorial-5',"Écrivez le premier mot qui vous vient à l'esprit");setTranslation('fr','tutorial-6',"Puis un autre mot");setTranslation('fr','tutorial-7',"Et ainsi de suite");setTranslation('fr','tutorial-8',"Vous pouvez répéter plusieurs fois le même mot");setTranslation('fr','tutorial-9',"Afin de créer des associations plus fortes");setTranslation('fr','load-name-input-invitation',"Écrivez le nom du vévé:");setTranslation('fr','load-nonexistent-entity',"Ce vévé n'existe pas");setTranslation('fr','game-cursor-invitation',"À quel mot pensez-vous?");setTranslation('fr','game-name-input-invitation',"Nommez votre vévé:");setTranslation('fr','game-already-existing-entity',"Un autre vévé porte déjà ce nom");setTranslation('fr','info-text',"<h1>À propos de VÉVÉ</h1><p>Les mots ne sont qu'amalgames de lettres. C'est la relation qui associe les mots entre eux qui leur donne vie et sens. Dans ce projet, les visiteurs contribuent à la création d'entités dialogiques, des <em>vévés</em>, en tenant une conversation basée sur le simple échange de mots. À partir de ce dialogue, les <em>vévés</em> apprennent, se complexifient, évoluent. Ils semblent animés d'une volonté propre.</p><p>&copy; 2008 Sofian Audry<br /><small>Le code source du projet est disponible sous la <a target=\"_blank\" href=\"http://www.gnu.org/licenses/gpl-3.0.html\">license libre Gnu GPL</a>.</small></p>");setTranslation('fr','credits-text',"<h1>Crédits</h1><p><strong>VÉVÉ</strong><br />Version 1.0</p><p>Une oeuvre web de<br /><strong>Sofian Audry</strong><br /><a target=\"_blank\" href=\"http://sofianaudry.com\">http://sofianaudry.com</a></p><p><strong>Réalisation sonore</strong><br />Alexandre Quessy<br /><a target=\"_blank\" href=\"http://alexandre.quessy.net\">http://alexandre.quessy.net</a></p><p><strong>Production</strong><br />Sofian Audry<br />Agence TOPO<br /><a target=\"_blank\" href=\"http://www.agencetopo.qc.ca/\">http://www.agencetopo.qc.ca/</a></p><p><strong>Soutien à la réalisation</strong><br />Guy Asselin<br />Véronique Briand<br />Michel Lefebvre<br />Esther Bourdages</p><p><strong>Logiciels open-source utilisés<br /></strong>JQuery<br />JS3D<br />SoundManager2<br />JSFSM</p>");;addLanguage('en');setTranslation('en','page-back',"Back");setTranslation('en','home-button-intro','Interactive tutorial');setTranslation('en','home-button-new','Create a new vévé');setTranslation('en','home-button-load','Open a vévé');setTranslation('en','home-button-info','Infos');setTranslation('en','home-button-credits','Credits');setTranslation('en','game-button-quit','Quit');setTranslation('en','game-button-new','New vévé');setTranslation('en','game-button-load','Open a vévé');setTranslation('en','tutorial-0',"Vévé is a word association game");setTranslation('en','tutorial-1',"Vévé learns");setTranslation('en','tutorial-2',"Your vévé learns with the words you write");setTranslation('en','tutorial-3',"The game will start soon");setTranslation('en','tutorial-4',"Vévé will speak to you");setTranslation('en','tutorial-5',"Write the first word that comes to your mind");setTranslation('en','tutorial-6',"Then another word");setTranslation('en','tutorial-7',"And so on");setTranslation('en','tutorial-8',"You can repeat the same word many times");setTranslation('en','tutorial-9',"In order to create stronger associations");setTranslation('en','load-name-input-invitation',"Write the vévé's name:");setTranslation('en','load-nonexistent-entity',"This vévé does not exist");setTranslation('en','game-cursor-invitation',"What is the word in your mind?");setTranslation('en','game-name-input-invitation',"Give your vévé a name:");setTranslation('en','game-already-existing-entity',"A vévé with that name already exists");setTranslation('en','info-text',"<h1>About VÉVÉ</h1><p>Words are but amalgams of letters. It is the relationship between words that gives them life and meaning. In this project, visitors contribute to the creation of dialogical entities called <em>vévés</em>, taking a conversation based on the simple exchange of words. From this dialogue, the <em>vévés</em> learn, become more complex and evolve. They seem to be animated by their own will.</p><p>&copy; 2008 Sofian Audry<br /><small>The project's source code is available under the free software license <a target=\"_blank\" href=\"http://www.gnu.org/licenses/gpl-3.0.html\">Gnu GPL</a>.</small></p>");setTranslation('en','credits-text',"<h1>Credits</h1><p><strong>VÉVÉ</strong><br />Version 1.0</p><p>A web art project by<br /><strong>Sofian Audry</strong><br /><a target=\"_blank\" href=\"http://sofianaudry.com\">http://sofianaudry.com</a></p><p><strong>Audio conception</strong><br />Alexandre Quessy<br /><a target=\"_blank\" href=\"http://alexandre.quessy.net\">http://alexandre.quessy.net</a></p><p><strong>Production</strong><br />Sofian Audry<br />Agence TOPO<br /><a target=\"_blank\" href=\"http://www.agencetopo.qc.ca/\">http://www.agencetopo.qc.ca/</a></p><p><strong>Support to the production</strong><br />Guy Asselin<br />Véronique Briand<br />Michel Lefebvre<br />Esther Bourdages</p><p><strong>Open source softwares used in the work<br /></strong>JQuery<br />JS3D<br />SoundManager2<br />JSFSM</p>");;(function(){var initializing=false,fnTest=/xyz/.test(function(){xyz;})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(prop){var _super=this.prototype;initializing=true;var prototype=new this();initializing=false;for(var name in prop){prototype[name]=typeof prop[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(prop[name])?(function(name,fn){return function(){var tmp=this._super;this._super=_super[name];var ret=fn.apply(this,arguments);this._super=tmp;return ret;};})(name,prop[name]):prop[name];}
function Class(){if(!initializing&&this.init)
this.init.apply(this,arguments);}
Class.prototype=prototype;Class.constructor=Class;Class.extend=arguments.callee;return Class;};})();;(function($){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},s={'array':function(x){var a=['['],b,f,i,l=x.length,v;for(i=0;i<l;i+=1){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}
a[a.length]=v;b=true;}}}
a[a.length]=']';return a.join('');},'boolean':function(x){return String(x);},'null':function(x){return"null";},'number':function(x){return isFinite(x)?String(x):'null';},'object':function(x){if(x){if(x instanceof Array){return s.array(x);}
var a=['{'],b,f,i,v;for(i in x){v=x[i];f=s[typeof v];if(f){v=f(v);if(typeof v=='string'){if(b){a[a.length]=',';}
a.push(s.string(i),':',v);b=true;}}}
a[a.length]='}';return a.join('');}
return'null';},'string':function(x){if(/["\\\x00-\x1f]/.test(x)){x=x.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}
c=b.charCodeAt();return'\\u00'+
Math.floor(c/16).toString(16)+
(c%16).toString(16);});}
return'"'+x+'"';}};$.toJSON=function(v){var f=isNaN(v)?s[typeof v]:s['number'];if(f)return f(v);};$.parseJSON=function(v,safe){if(safe===undefined)safe=$.parseJSON.safe;if(safe&&!/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(v))
return undefined;return eval('('+v+')');};$.parseJSON.safe=false;})(jQuery);;timer=function(interval,callback)
{var interval=interval||100;if(!callback)
return false;_timer=function(interval,callback){this.stop=function(){clearInterval(self.id);};this.internalCallback=function(){callback(self);};this.reset=function(val){if(self.id)
clearInterval(self.id);var val=val||100;this.id=setInterval(this.internalCallback,val);};this.interval=interval;this.id=setInterval(this.internalCallback,this.interval);var self=this;};return new _timer(interval,callback);};;Easing={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;},easeNone:function(x,t,b,c,d){return c*t/d+b;}};;function log(aMessage,level)
{if(typeof(level)=='undefined')
level=NOTICE;if(level>=DEBUGGING_LEVEL)
console.log(aMessage);};function clamp(value,min,max){return Math.min(max,Math.max(min,value))}
function random(min,max,rand){min=min||0.0;max=max||1.0;if(max<min)alert('In function random(), min should be < max');rand=rand||Math.random();return min+rand*(max-min);}
function random_integer(min,max,rand){if(max<min)alert('In function random_integer(), min should be < max');rand=rand||Math.random();return Math.floor(rand*(max-min+1)+min);}
function random_boolean(){return(Math.random()<0.5);}
var normal_is_valid=false;function random_normal(mean,stdv){if(isUndefined(mean))
mean=0.0;if(isUndefined(stdv))
stdv=1.0;if(!normal_is_valid){normal_x=random();normal_y=random();normal_rho=Math.sqrt(-2.*Math.log(1.0-normal_y));normal_is_valid=true;}
else
normal_is_valid=false;if(normal_is_valid)
return normal_rho*Math.cos(2.*Math.PI*normal_x)*stdv+mean;else
return normal_rho*Math.sin(2.*Math.PI*normal_x)*stdv+mean;}
function rescale(v,min,max,newMin,newMax){return(v-min)/(max-min)*(newMax-newMin)+newMin;}
function isUndefined(obj){return(typeof(obj)=='undefined');}
function dump(arr,level){var dumped_text="";if(!level)level=0;var level_padding="";for(var j=0;j<level+1;j++)level_padding+="    ";if(typeof(arr)=='object'){for(var item in arr){var value=arr[item];if(typeof(value)=='object'){dumped_text+=level_padding+"'"+item+"' ...\n";alert(level);dumped_text+=dump(value,level-1);}else{dumped_text+=level_padding+"'"+item+"' => \""+value+"\"\n";}}}else{dumped_text="===>"+arr+"<===("+typeof(arr)+")";}
return dumped_text;}
function mydump(arr,level){var str=""
for(var item in arr){str+=item+"="+arr[item]+"\n";}
return str}
function print_r(input,_indent)
{if(typeof(_indent)=='string'){var indent=_indent+'    ';var paren_indent=_indent+'  ';}else{var indent='    ';var paren_indent='';}
switch(typeof(input)){case'boolean':var output=(input?'true':'false')+"\n";break;case'object':if(input===null){var output="null\n";break;}
var output=((input.reverse)?'Array':'Object')+" (\n";for(var i in input){output+=indent+"["+i+"] => "+print_r(input[i],indent);}
output+=paren_indent+")\n";break;case'number':case'string':default:var output=""+input+"\n";}
return output;};$j=jQuery.noConflict();function runAjaxAction(action,q,callback){var args={action:action,q:$j.toJSON(q),format:"json"};var url=BASE_URL+"/ajax.php";if(!isUndefined(callback))
$j.get(url,args,function(data){callback($j.parseJSON(data))});else
$j.get(url,args);};$j=jQuery.noConflict();function TypeWriter(element,text,speed,variation,callback){var counter=0;var element=element;var speed=speed||1000;var variation=variation||100;var text=text;var callback=callback;var stopped=true;this.reset=function(){counter=0;}
this.stop=function(){stopped=true;}
this.isStopped=function(){return stopped;}
this.start=function(){stopped=false;timer(0,function(timer){if(stopped){timer.stop();}else{if(counter>text.length){stopped=true;timer.stop();if(callback)
callback(element);}else{var substr=text.substr(0,counter++);element.val(substr);element.text(substr);timer.reset(random_normal(speed,variation));}}});}};function HistoryQueue(size){var _queue;var _size;this.init(size);}
HistoryQueue.prototype={init:function(size){_queue=new Array();_size=size;},push:function(word){if(_queue.length>=_size){_queue.shift();}
_queue.push(word);},getData:function(){return _queue;}};Action=Class.extend({engine:null,time:0,stopped:true,init:function(){this.reset();this.start();},setEngine:function(engine){this.engine=engine;this._initEngine();},step:function(){if(!this.stopped){this.time+=this.engine.getTimeStep();return this._doStep();}
return false;},stop:function(){this.stopped=true;},start:function(){this.stopped=false;},reset:function(){this.time=0;},_initEngine:function(){}});CameraRotationAction=Action.extend({angle:null,velocity:null,init:function(angle,velocity){this._super();this.angle=angle||{x:0,y:0,z:0};this.velocity=velocity||{x:0,y:0,z:0};},_doStep:function(){var dt=this.engine.getTimeStep();this.angle.x+=this.velocity.x*dt/1000.0;this.angle.y+=this.velocity.y*dt/1000.0;this.angle.z+=this.velocity.z*dt/1000.0;canvas.matrix=canvas.rotateX(this.angle.x);canvas.matrix=canvas.rotateY(this.angle.y);canvas.matrix=canvas.rotateZ(this.angle.z);}});CameraRotationChangeAction=Action.extend({cameraRotationAction:null,startVelocity:null,deltaVelocity:null,startTime:0,duration:0,easing:null,callback:null,init:function(cameraRotationAction,targetVelocity,duration,easing,callback){this._super();this.cameraRotationAction=cameraRotationAction;var velocity=cameraRotationAction.velocity;this.startVelocity={x:velocity.x,y:velocity.y,z:velocity.z};this.targetVelocity={x:targetVelocity.x,y:targetVelocity.y,z:targetVelocity.z};this.duration=duration||0;this.easing=easing||Easing.easeNone;this.callback=callback||function(){};},_doStep:function(){var finished=false;var velocity=this.cameraRotationAction.velocity;if(this.targetVelocity.x!=velocity.x||this.targetVelocity.y!=velocity.y||this.targetVelocity.z!=velocity.z){if(this.time>=this.duration){finished=true;velocity.x=this.targetVelocity.x;velocity.y=this.targetVelocity.y;velocity.z=this.targetVelocity.z;}else{velocity.x=this.easing(velocity.x,this.time,this.startVelocity.x,this.targetVelocity.x-this.startVelocity.x,this.duration);velocity.y=this.easing(velocity.y,this.time,this.startVelocity.y,this.targetVelocity.y-this.startVelocity.y,this.duration);velocity.z=this.easing(velocity.z,this.time,this.startVelocity.z,this.targetVelocity.z-this.startVelocity.z,this.duration);}}else{finished=true;}
if(finished){this.callback();return true;}else{return false;}}});PropertyAction=Action.extend({object:null,getFunction:null,setFunction:null,startValue:0,deltaValue:0,easing:null,startTime:0,callback:null,init:function(object,getFunction,setFunction,targetValue,duration,easing,callback){this._super();this.object=object;this.getFunction=getFunction;this.setFunction=setFunction;this.startValue=parseFloat(this.getFunction(this.object));this.deltaValue=targetValue-this.startValue;this.duration=duration||1000;this.easing=easing||Easing.easingNone;this.callback=callback||function(){};},_doStep:function(){var value;var finished;if(this.time>this.duration){finished=true;value=this.deltaValue+this.startValue;}else{finished=false;value=this.easing(parseFloat(this.getFunction(this.object)),this.time,this.startValue,this.deltaValue,this.duration);}
this.setFunction(value,this.object);if(finished){this.callback();}
return finished;}});RecenterAction=Action.extend({startTime:0,startPoints:null,duration:0,easing:null,origin:null,callback:null,init:function(origin,duration,easing,callback){this._super();this.duration=duration||3000;this.easing=easing||Easing.easeNone;this.callback=callback||function(){};this.origin={x:origin.x,y:origin.y,z:origin.z};this.startPoints=new Array();},_initEngine:function(){for(i in this.engine.canvas.points){var point=this.engine.canvas.points[i];this.startPoints[i]={x:point.x,y:point.y,z:point.z,point:point};};},_doStep:function(){var x0=this.origin.x;var y0=this.origin.y;var z0=this.origin.z;for(i in this.startPoints){var start=this.startPoints[i];var point=start.point;if(this.time>=this.duration){point.x=start.x-x0;point.y=start.y-y0;point.z=start.z-z0;}else{point.x=this.easing(point.x,this.time,start.x,-x0,this.duration);point.y=this.easing(point.y,this.time,start.y,-y0,this.duration);point.z=this.easing(point.z,this.time,start.z,-z0,this.duration);}}
if(this.time>=this.duration){this.callback();return true;}else{return false;}}});;MusicInstrument=function(minNote,maxNote,directory,prefix,suffix){this.init(minNote,maxNote,directory,prefix,suffix);}
MusicInstrument.prototype={init:function(minNote,maxNote,directory,prefix,suffix){this.minNote=minNote||0;this.maxNote=maxNote||0;this.directory=directory||'./';this.prefix=prefix||'';this.suffix=suffix||'.mp3';this.chord=new Array();},volume:1.0,soundFileName:"note",debugPrefix:"DEBUG: ",loadNotes:function(){for(var note=this.minNote;note<=this.maxNote;note++){var noteFileName=this.getNoteFileName(note);soundManager.createSound(noteFileName,noteFileName);}},nSounds:function(){return(this.maxNote-this.minNote);},playNote:function(note,volume,pan){volume=volume||1.0;pan=pan||0.5;if(this.getNoteState(note)!=1){soundManager.play(this.getNoteFileName(note),{volume:this.volume*volume*100,pan:(100*(pan*2-1))});return true;}else{return false;}},getNoteFileName:function(note){note=clamp(note,this.minNote,this.maxNote);return this.directory+this.prefix+this.indexToString(note)+this.suffix;},setVolume:function(volume){this.volume=volume||1.0;},getNoteState:function(note){return soundManager.getSoundById(this.getNoteFileName(note)).playState;},debug:function(str){console.log(this.debugPrefix+str);},indexToString:function(i){var str=(i<10?'0':'');str=str+i;return str;}}
MusicManager=function(){}
MusicManager.prototype={instruments:new Array(),players:new Array(),volume:1.0,bpm:120,addInstrument:function(sId,instrument){this.instruments[sId]=instrument;},getInstrument:function(sId){return this.instruments[sId];},addPlayer:function(sId,player){this.players[sId]=player;},getPlayer:function(sId){return this.players[sId];},play:function(playerId,instrumentId,options){options=options||{};var volume=options.volume||1.0;options.volume=volume*this.volume;this.players[playerId].play(this.instruments[instrumentId],options,60000/this.bpm);},setBpm:function(bpm){this.bpm=bpm;},setVolume:function(volume){this.volume=volume;},setup:function(soundManagerUrl,debugMode){var self=this;soundManager.url=soundManagerUrl;soundManager.debugMode=debugMode||false;soundManager.consoleOnly=false;soundManager.onload=function(){for(sId in self.instruments){self.instruments[sId].loadNotes();}}}}
musicManager=new MusicManager();;function chordToNotes(chord,minNote,maxNote){var notes=new Array();for(var i=minNote;i<=maxNote;i++){for(var j=0;j<chord.length;j++){if(chord[j]==(i%12)){notes.push(i);}}}
return notes;}
MusicRandomChordPlayer=function(chord){this.init(chord);}
MusicRandomChordPlayer.prototype={init:function(chord){this.chord=chord;},play:function(instrument,options,noteDuration){var volume=options.volume||1.0;var pan=options.pan||0.5;var length=options.length||1;var density=options.density||1;var notes=chordToNotes(this.chord,instrument.minNote,instrument.maxNote);var self=this;timer(0,function(timer){if(length>0&&density>0){var index=null;instrument.playNote(notes[random_integer(0,notes.length-1)],volume,pan);for(var i=1;i<density;i++){instrument.playNote(notes[(++index)%notes.length],volume,pan);}
length--;timer.reset(noteDuration);}else{timer.stop();}});}}
MusicDrunkPlayer=function(chord){var _drunk;this.init(chord);}
MusicDrunkPlayer.prototype={init:function(chord){this.chord=chord;_drunk=new Drunk({stepMin:0,stepMax:0.01,rangeMin:0.0,rangeMax:1.0,currentVal:0.5});},play:function(instrument,options,noteDuration){var volume=options.volume||1.0;var pan=options.pan||0.5;var length=options.length||1;var randomizeVolume=options.randomizeVolume;if(typeof(randomizeVolume)=='undefined')randomizeVolume=true;var notes=chordToNotes(this.chord,instrument.minNote,instrument.maxNote);_drunk.stepMax=1.0/notes.length;if(randomizeVolume)
volume*=Math.random();var self=this;timer(0,function(t){if(length>0){timer(0,function(t){if(!instrument.playNote(notes[random_integer(0,notes.length-1,_drunk.nextValue())],volume,pan))
t.reset(100);else
t.stop();});length--;t.reset(noteDuration);}else{t.stop();}});}}
Drunk=function(args){this.init(args);}
Drunk.prototype={rangeMin:0,rangeMax:100,stepMin:0,stepMax:10,currentVal:0,lastVal:0,lastVariation:0,init:function(args){this.stepMin=args.stepMin||0;this.stepMax=args.stepMax||10;this.rangeMin=args.rangeMin||0;this.rangeMax=args.rangeMax||100;this.currentVal=args.currentVal||0;},nextValue:function(){var dir=random_integer(0,1);dir=(dir==0)?-1:1;var step=random(this.stepMin,this.stepMax)*dir;if((this.currentVal+step)<this.rangeMin){step*=-1;}else if((this.currentVal+step)>this.rangeMax){step*=-1;}
this.currentVal+=step;return this.currentVal;},setValue:function(newVal){this.currentVal=newVal;}};var VeveModel=Class.extend({_beginner:false,_needsHelpWithCursor:false,_hasRegisteredName:false,_nameInputMode:false,_conversationId:-1,_entity:null,_fsm:null,init:function(){this._beginner=false;this._needsHelpWithCursor=false;this.reset();},getFsm:function(){return this._fsm;},setFsm:function(fsm){this._fsm=fsm;},isBeginner:function(){return this._beginner;},setIsBeginner:function(beginner){this._beginner=beginner;},needsHelpWithCursor:function(){return this._needsHelpWithCursor;},setNeedsHelpWithCursor:function(needsHelpWithCursor) {this._needsHelpWithCursor=needsHelpWithCursor;},hasRegisteredName:function(){return this._hasRegisteredName;},setHasRegisteredName:function(hasRegisteredName) {this._hasRegisteredName=hasRegisteredName;},nameInputMode:function(){return this._nameInputMode;},setNameInputMode:function(nameInputMode){this._nameInputMode=nameInputMode;},getEntity:function(){return this._entity;},setEntity:function(entity) {this._entity=entity;},getConversationId:function(){return this._conversationId;},setConversationId:function(conversationId){this._conversationId=conversationId;},reset:function(){this._hasRegisteredName=false;this._nameInputMode=false;this._entity=null;this._conversationId=-1;}});;$j=jQuery.noConflict();const WORD_FADE_OUT_TIME=10000;const N_WORDS_PER_MEASURE=4;var CHORDS=['Cm69','C69','G79','Db79','Bb79'];var CHORDS_PROBABILITIES=[0.45,0.25,0.15,0.1,0.05];function initAudio(){musicManager.addPlayer('Cm69',new MusicRandomChordPlayer([0,3,7,9,2]));musicManager.addPlayer('C69',new MusicRandomChordPlayer([0,4,7,9,2]));musicManager.addPlayer('G79',new MusicRandomChordPlayer([7,11,2,5,9]));musicManager.addPlayer('Db79',new MusicRandomChordPlayer([1,5,8,11,3]));musicManager.addPlayer('Bb79',new MusicRandomChordPlayer([10,2,5,8,0]));musicManager.addPlayer('Cm69-drunk',new MusicDrunkPlayer([0,3,7,9,2]));musicManager.addPlayer('C69-drunk',new MusicDrunkPlayer([0,4,7,9,2]));musicManager.addPlayer('G79-drunk',new MusicDrunkPlayer([7,11,2,5,9]));musicManager.addPlayer('Db79-drunk',new MusicDrunkPlayer([1,5,8,11,3]));musicManager.addPlayer('Bb79-drunk',new MusicDrunkPlayer([10,2,5,8,0]));musicManager.addInstrument('cello_archet',new MusicInstrument(36,67,'audio/cello_archet/','cello_archet_'));musicManager.addInstrument('cello_pizz',new MusicInstrument(42,60,'audio/cello_pizz/','cello_pizz_'));musicManager.addInstrument('flute_staccato',new MusicInstrument(59,84,'audio/flute_staccato/','flute_staccato_'));musicManager.addPlayer('Cm6-quinte',new MusicRandomChordPlayer([0,2,3,7,9]));musicManager.setup('js/soundmanager2/soundmanager2.swf',false);}
var nWordsPlayed=0;var currentChord=-1;function getRandomChord(isWord){if(isWord||currentChord==-1){log("nwords :"+nWordsPlayed);if(currentChord==-1||nWordsPlayed>=N_WORDS_PER_MEASURE){var prob=Math.random();for(currentChord=0;currentChord<CHORDS.length;currentChord++){prob-=CHORDS_PROBABILITIES[currentChord];if(prob<=0)break;}
nWordsPlayed=0;log("Change chord to "+CHORDS[currentChord]);}else{nWordsPlayed++;}}
return CHORDS[currentChord];}
function playRandomWord(instrumentName,elem){var currentPlayer=getRandomChord(true);log("Chord = "+currentPlayer);var pan=$j(elem).offset().left/$j('#main').width();var fontSize=parseFloat($j(elem).css('font-size').slice(0,-2));var volume=rescale(clamp(fontSize,7,30),7,30,0.,1.);var density=(random_integer(1,3));musicManager.play(currentPlayer,instrumentName,{density:density,volume:volume,pan:pan});}
VeveView=Class.extend({_model:null,_main:null,init:function(model){this._model=model;this._main=$j('#main');},clear:function(){log("clear main");this._main.empty();},addButton:function(buttonId,buttonName,leftOffset,bulletIsLeft,topOffset){if(typeof(bulletIsLeft)=='undefined')
bulletIsLeft=true;leftOffset=leftOffset||0;topOffset=topOffset||0;$j('#menu').append('<div class="menuitem" style="margin-left: '+
leftOffset+'px; margin-top: '+topOffset+'px" id="div_'+buttonId+'" />');var bullet='<a href="#" class="bullet"><img src="images/puce.gif" /></a>';var button='<a href="#" class="button" id="'+buttonId+'">'+buttonName+'</a> ';if(bulletIsLeft){$j('#div_'+buttonId).append(bullet).append(button);}else{$j('#div_'+buttonId).append(button).append(bullet);}
$j('.bullet').click(function(event){$j(this).siblings('.button').click()})},resize:function(){},getButton:function(action){return $j('#'+action);},getmodel:function(){return this._model;},getMain:function(){return this._main;},destroy:function(){this.clear();}});var tw=new Array();PageView=VeveView.extend({init:function(model){this._super(model);this._main.append('<div id="content"></div>').append('<div id="menu"></div>')
this.addButton('back',t('page-back'),200,true);this.addButton('fr','Français',-400,false);this.addButton('en','English',-400,false);},setText:function(text){$j('#content').html(text);},addButton:function(buttonId,buttonName,leftOffset,bulletIsLeft,topOffset){this._super(buttonId,buttonName,leftOffset,bulletIsLeft,topOffset);$j('.button').hover(function(event){$j(this).fadeTo(100,0.3,function(){$j(this).fadeTo(100,1.0);});},function(event){$j(this).fadeTo(100,1.0);});}});HomePageView=VeveView.extend({init:function(model){this._super(model);this._main.append('<div id="title"><img src="images/logoveve.gif" title="VÉVÉ" alt="VÉVÉ" /></div>').append('<div id="menu"></div>');this.addButton('intro',t('home-button-intro'),-150,false);this.addButton('new',t('home-button-new'),-300,true,20);this.addButton('load',t('home-button-load'),-300,true);this.addButton('info',t('home-button-info'),300,true);this.addButton('credits',t('home-button-credits'),350,true);this.addButton('fr','Français',-400,false);this.addButton('en','English',-400,false);},addButton:function(buttonId,buttonName,leftOffset,bulletIsLeft,topOffset){this._super(buttonId,buttonName,leftOffset,bulletIsLeft,topOffset);$j('.button').hover(function(event){$j(this).fadeTo(100,0.3,function(){$j(this).fadeTo(100,1.0);});},function(event){$j(this).fadeTo(100,1.0);});}});GameView=VeveView.extend({maxQueueLength:10,minFontSize:10,maxFontSize:60,cursorFontSize:20,maxWordLength:15,border:100,engine:null,init:function(model){this._super(model);preventFocusOnCursor=false;wordIndex=0;this._main.append('<div id="canvas" />');$j('#canvas').css('width',this._main.width()).css('height',this._main.height()).css('position','absolute').css('overflow','hidden');canvas=new JS3D("canvas");cursorPoint=canvas.addPoint(0,0,0,'<input type="text" id="cursor" name="cursor"></input>',identity(),this.cursorFontSize);cursor=$j('#cursor').eq(0);cursor.hide();minZ=-Math.max(this._main.width(),this._main.height())/3;this.engine=new JS3DEngine(canvas,minZ,100);this.resize();this._main.append('<input type="text" id="entity_name" name="entity_name"></input>');nameInput=$j('#entity_name').eq(0);this._main.append('<div id="menu"></div>');},resize:function(){$j('#canvas').css('width',this._main.width()).css('height',this._main.height())
minZ=-Math.max(this._main.width(),this._main.height())/3;this.engine.minZ=minZ;this.engine.canvas.initCoordinates();},addButton:function(buttonId,buttonName,leftOffset,bulletIsLeft,topOffset){this._super(buttonId,buttonName,leftOffset,bulletIsLeft,topOffset);$j('.button').hide();$j('.menuitem').hover(function(event){$j(this).children('.button').fadeIn(1000);},function(event){var self=this;timer(1000,function(timer){$j(self).children('.button').fadeOut(500);timer.stop();});});$j('.menuitem').css('position','absolute');},clear:function(){canvas.clearPoints();this.engine.destroy();this._super();},getCursor:function(){return cursor;},getNameInput:function(){return nameInput;},setCursor:function(params,duration,easing){params=this.rescaleParams(params,cursor);cursorPoint.x=params.x;cursorPoint.y=params.y;cursorPoint.z=params.z;cursor.hide();var self=this;cursor.show();this.focusOnCursor();this.engine.addAction(new RecenterAction(params,duration,easing,function(){cursor.show();self.focusOnCursor();}));},focusOnCursor:function(){if(!preventFocusOnCursor)
cursor.focus();},focusOnNameInput:function(){nameInput.focus();},setEnableCursor:function(enable){if(enable){cursor.show();}else{cursor.hide();}
cursor.attr('disabled',!enable);},setPreventFocusOnCursor:function(prevent){preventFocusOnCursor=prevent;},clearCursor:function(){cursor.empty();cursor.val("");},clearNameInput:function(){nameInput.empty();nameInput.val("");},addWord:function(word,params,rescale,divId,fadeOutTime,callback){if(typeof(rescale)=='undefined')
rescale=true;divId=divId||'word_'+wordIndex;fadeOutTime=fadeOutTime||WORD_FADE_OUT_TIME;var rescaledParams=(rescale?this.rescaleParams(params):params);var point=canvas.addPoint(rescaledParams.x,rescaledParams.y,rescaledParams.z,'<div class="word" id="'+divId+'">'+word+'</div>',identity(),rescaledParams.size);canvas.paint();this.engine.addAction(new PropertyAction(point.div,function(object){return $j(object).css('opacity');},function(value,object){$j(object).css('opacity',value);},0.0,fadeOutTime,Easing.easeNone,function(){if(typeof(canvas.removePoint)!='undefined'){canvas.removePoint(point);}
if(callback)
callback();}),divId);wordIndex++;return $j(point.div).eq(0);},nWords:function(){return canvas.nPoints();},removeWord:function(i){},cursorToWord:function(){cursor.hide();return this.addWord(this.getCursorText(),cursorPoint,false);},getCursorText:function(){return cursor.val();},getNameInputText:function(){return nameInput.val();},setCursorText:function(text){cursor.val(text);},setNameInputText:function(text){nameInput.val(text);},setNameInputError:function(errorMessage){var copy=this.getNameInputText();this.setNameInputText(errorMessage);this.getNameInput().attr('disabled',true);var self=this;timer(1500,function(timer){self.setNameInputText(copy);self.getNameInput().attr('disabled',false);timer.stop();});},cursorIsFull:function(){return(this.getCursorText().length>=this.maxWordLength);},nameInputIsFull:function(){return(this.getNameInputText().length>=this.maxWordLength);},rescaleParams:function(params,element){if(typeof element!='undefined'){elementWidth=element.width();elementHeight=element.height();}else{elementWidth=elementHeight=0;}
var xMax=this._main.width()/2-elementWidth-this.border;var yMax=this._main.height()/2-elementHeight-this.border;var newParams=new Object();newParams.size=rescale(params.size,0.0,1.0,this.minFontSize,this.maxFontSize);newParams.x=rescale(params.x,0.0,1.0,-xMax,xMax);newParams.y=rescale(params.y,0.0,1.0,-yMax,yMax);newParams.z=rescale(params.z,0.0,1.0,minZ,0);return newParams;},setWordElementParams:function(element,params){var size=rescale(params.size,0.0,1.0,this.minFontSize,this.maxFontSize);element.css('fontSize',size).css('display','inline').css({position:'absolute',left:rescale(params.x,0.0,1.0,this.border,Math.max(this.border,this._main.width()-element.width()-this.border-5)),top:rescale(params.y,0.0,1.0,this.border,Math.max(this.border,this._main.height()-element.height()-this.border-5))});}});TutorialView=GameView.extend({init:function(model){this._super(model);var fsm=this._model.getFsm();var self=this;function runTextSequence(seq,i){i=i||0;if(sequence.length>0){var callback=(sequence.length==1?function(){fsm.stop();}:null);var item=seq.shift();var elem=self.addWord("",item[0],true,null,10000,callback);var tw=new TypeWriter(elem,item[1],75,10,function(){timer(1000,function(timer){musicManager.play('Cm6-quinte','cello_pizz',{length:3},1000);timer.stop();runTextSequence(seq,i+1);});});tw.start();}}
var sequence=new Array();var textIndex=0;function addText(params,text){sequence[textIndex++]=[params,text];}
addText({size:0.3,z:0.2,x:0.1,y:0.4},t('tutorial-0',false));addText({size:0.3,z:0.3,x:0.7,y:0.6},t('tutorial-1',false));addText({size:0.3,z:0.2,x:0.2,y:0.8},t('tutorial-2',false));addText({size:0.3,z:0.3,x:0.6,y:0.2},t('tutorial-3',false));addText({size:0.3,z:0.5,x:0.5,y:0.4},t('tutorial-4',false));addText({size:0.3,z:0.2,x:0.2,y:0.6},t('tutorial-5',false));addText({size:0.3,z:0.7,x:0.7,y:0.8},t('tutorial-6',false));addText({size:0.3,z:0.3,x:0.6,y:0.2},t('tutorial-7',false));addText({size:0.3,z:0.2,x:0.2,y:0.4},t('tutorial-8',false));addText({size:0.1,z:0.3,x:0.3,y:0.6},t('tutorial-9',false));runTextSequence(sequence);this.engine.start();}});LoadView=GameView.extend({init:function(model){this._super(model);}});;const TIMER_MEAN_TICK=4000;const TIMER_WAIT_TICK=1000;const CAMERA_ROTATION_VELOCITY=Math.PI/10;const MAX_N_WORDS=10;const HISTORY_SIZE=3;const NAME_INPUT_INVITATION_MIN_N_INPUT_WORDS=5;$j=jQuery.noConflict();VeveController=Class.extend({_view:null,_model:null,init:function(model,view){this._model=model;this._view=view;var self=this;window.onresize=function(){self.getView().resize();};},getModel:function(){return this._model;},getView:function(){return this._view;},setButtonAction:function(buttonId,action){var model=this._model;this._view.getButton(buttonId).click(function(event){action(model,event)});},destroy:function(){this.getView().getMain().unbind();}});HomePageController=VeveController.extend({init:function(model,view){if(!(view instanceof HomePageView)){log("View has wrong class",ERROR);}else{this._super(model,view);}}});PageController=VeveController.extend({init:function(model,view){if(!(view instanceof PageView)){log("View has wrong class",ERROR);}else{this._super(model,view);}}});TutorialController=VeveController.extend({init:function(model,view){if(!(view instanceof TutorialView)){log("View has wrong class",ERROR);}else{this._super(model,view);}}});LoadController=VeveController.extend({_nameInputInvitation:null,_timer:null,_nameInputInvitationTimer:null,init:function(model,view){if(!(view instanceof LoadView)){log("View has wrong class",ERROR);}else{this._super(model,view);}
var fsm=model.getFsm();view.setCursor({x:0.5,y:0.5,z:0.5},0);view.getCursor().hide();view.engine.start();view.getMain().addClass("load_entity");view.setPreventFocusOnCursor(true);view.focusOnNameInput();this._nameInputInvitation=null;log("Create name input invitation timer "+model.hasRegisteredName());this._nameInputInvitationTimer=timer(5000,function(timer){if(!model.hasRegisteredName()){this._nameInputInvitation=new TypeWriter(view.getNameInput(),t('load-name-input-invitation',false),100,20,function(){view.setPreventFocusOnCursor(true);view.getNameInput().focus()});this._nameInputInvitation.start();timer.stop();}})
var preventSampleEntities=false;function accessEntity(name){preventSampleEntities=true;runAjaxAction('get_entity',name,function(entity){if(entity){model.setHasRegisteredName(true);view.getMain().removeClass("load_entity");model.setEntity({id:entity.id,name:name});view.setPreventFocusOnCursor(false);view.focusOnCursor();fsm.play();return true;}else{view.setNameInputError(t('load-nonexistent-entity',false));preventSampleEntities=false;return false;}});}
$j(document).click(function(event){view.focusOnNameInput();})
view.getNameInput().keypress(function(e){if(!model.hasRegisteredName()){if(this._nameInputInvitation)
this._nameInputInvitation.stop();view.clearNameInput();model.setHasRegisteredName(true);}
var keyCode=(e.keyCode?e.keyCode:e.which);var name=view.getNameInputText();if(keyCode==13){if(name.length>0){accessEntity(name);}
return false;}
else if(keyCode!=8&&view.nameInputIsFull()){return false;}
else{musicManager.play(getRandomChord(false)+'-drunk','flute_staccato');if(name.length==0&&keyCode!=8){view.setNameInputText(String.fromCharCode(e.which).toUpperCase());return false;}}
if(view.getNameInputText().length==0){}})
const LOAD_ENTITY_TIMER_MEAN_TICK=1000;const LOAD_ENTITY_TIME_FADEOUT=5000;this._timer=timer(3000,function(timer){if(view.nWords()>=MAX_N_WORDS){timer.reset(LOAD_ENTITY_TIMER_MEAN_TICK);}else{var prefix=(model.hasRegisteredName()?view.getNameInputText():'');runAjaxAction('sample_entities',[prefix,10],function(entities){log("Prevent sample? "+preventSampleEntities);if(!preventSampleEntities){if(entities.length>0){var suffix;if(entities.length==1)
suffix="!";else if(entities.length>3)
suffix="?";else
suffix="?";var entity=entities[0];var name=view.addWord(entity.name+suffix,{x:Math.random(),y:Math.random(),z:Math.random(),size:1.0},true,null,LOAD_ENTITY_TIME_FADEOUT);playRandomWord('cello_pizz',name);$j(name).click(function(event){var text=$j(this).text();text=text.substring(0,text.length-1);view.setNameInputText(text);accessEntity(text);});}}});}
timer.reset(LOAD_ENTITY_TIMER_MEAN_TICK+random_normal(1000,300));});},destroy:function(){this._super();this._timer.stop();this._nameInputInvitationTimer.stop();}});GameController=VeveController.extend({rotationActionY:null,currentRotationDirectionY:1,freezeAction:false,_nameInputInvitation:null,_timer:null,init:function(model,view){this._super(model,view);var self=this;if(model.getEntity()){view.getNameInput().val(model.getEntity().name);model.setHasRegisteredName(true);log("Entity = "+print_r(model.getEntity()));runAjaxAction('create_conversation',[model.getEntity().id],function(conversationId){model.setConversationId(conversationId);log("Conversation id "+conversationId);});}else{runAjaxAction('create_entity',null,function(entityId){model.setEntity({id:entityId,name:""});log("Entity = "+print_r(model.getEntity()));runAjaxAction('create_conversation',[entityId],function(conversationId){model.setConversationId(conversationId);log("Conversation id "+conversationId);});});}
this.currentRotationDirectionY=1;this.rotationActionY=new CameraRotationAction({x:0,y:0,z:0},{x:0,y:this.currentRotationDirectionY*CAMERA_ROTATION_VELOCITY,z:0});view.engine.addAction(this.rotationActionY);view.engine.start();this.freezeAction=false;model.setNeedsHelpWithCursor(model.isBeginner());queue=new HistoryQueue(HISTORY_SIZE);view.setCursor({x:0.5,y:0.5,z:0.5},0);var helpWithCursorTypeWriter;if(model.needsHelpWithCursor()){helpWithCursorTypeWriter=new TypeWriter(view.getCursor(),t('game-cursor-invitation',false),100,20);timer(5000,function(timer){if(model.needsHelpWithCursor()){helpWithCursorTypeWriter.start();}
timer.stop();})}
this._nameInputInvitation=null;var nWordsEntered=0;$j(document).click(function(event){if(model.nameInputMode()){view.focusOnNameInput();}else{view.focusOnCursor();}})
view.getNameInput().click(function(event){self.enterNameInputMode();event.stopPropagation();}).keypress(function(e){if(!model.hasRegisteredName()){if(this._nameInputInvitation)
self._nameInputInvitation.stop();view.clearNameInput();model.setHasRegisteredName(true);}
var keyCode=(e.keyCode?e.keyCode:e.which);var name=view.getNameInputText();if(keyCode==13){return self.changeName(name);}else if(keyCode!=8&&view.nameInputIsFull()){return false;}else{musicManager.play(getRandomChord(false)+'-drunk','cello_pizz');if(name.length==0&&keyCode!=8){view.setNameInputText(String.fromCharCode(e.which).toUpperCase());return false;}}})
view.getCursor().keypress(function(e){if(model.needsHelpWithCursor()){helpWithCursorTypeWriter.stop();stopTypeWriter=true;view.clearCursor();model.setNeedsHelpWithCursor(false);}
var keyCode=(e.keyCode?e.keyCode:e.which);if(keyCode==13){var word=view.getCursorText();if(word.length>0){var elem=view.cursorToWord();self.randomSetCursor();log("Before logging: "+queue.getData());runAjaxAction('log',[word,'human',model.getEntity().id,model.getConversationId(),queue.getData()]);model.setIsBeginner(false);nWordsEntered++;if(nWordsEntered>=NAME_INPUT_INVITATION_MIN_N_INPUT_WORDS&&!model.hasRegisteredName()){if(!self._nameInputInvitation){self._nameInputInvitation=new TypeWriter(view.getNameInput(),t('game-name-input-invitation',false),100,20,function(){self.enterNameInputMode();});self._nameInputInvitation.start();}}
queue.push(word);playRandomWord('cello_archet',elem);}
self.currentRotationDirectionY=(random_boolean()?-1:1);self.setFreezeAction(false);return false;}
else if((keyCode!=8&&view.cursorIsFull())||keyCode==32){return false;}
else{musicManager.play(getRandomChord(false)+'-drunk','flute_staccato');log("entity: "+model.getEntity().name+" "+model.getEntity().id);var cursor=view.getCursor();cursor.show();if(keyCode==8&&view.getCursorText().length<=1){self.setFreezeAction(false);}
else if(view.getCursorText().length==0){self.setFreezeAction(true);}}
if(view.getCursorText().length==0){}})
this._timer=timer(TIMER_MEAN_TICK,function(timer){if(self.freezeAction||view.nWords()>=MAX_N_WORDS){timer.reset(TIMER_WAIT_TICK);}else{var entityId=model.getEntity().id;log("Entity: "+print_r(model.getEntity()));if(typeof(entityId)!='undefined'){runAjaxAction('sample',[model.getEntity().id,queue.getData()],function(word){if(self.getModel().getFsm().currentState.name!='play'){if(word){runAjaxAction('log',[word,'entity']);var elem=self.randomAddWord(word);queue.push(word);playRandomWord('cello_pizz',elem);}}});}
timer.reset(random_normal(TIMER_MEAN_TICK,TIMER_MEAN_TICK/2));}});},randomSetCursor:function(){var view=this.getView();view.setEnableCursor(false);view.clearCursor();view.setCursor({x:Math.random(),y:Math.random(),z:Math.random()});timer(0,function(timer){if(view.nWords()<MAX_N_WORDS||view.getCursorText().length!=0){view.setEnableCursor(true);view.focusOnCursor();timer.stop();}else{view.setEnableCursor(false);timer.reset(1000);}});},randomAddWord:function(word){var params={x:Math.random(),y:Math.random(),z:Math.random(),size:Math.random()};return this._view.addWord(word,params);},setFreezeAction:function(freeze){this.freezeAction=freeze;var self=this;$j('.word').each(function(i){var action=self.getView().engine.getAction(this.id);if(freeze)action.stop();else action.start();});log("Rotation direction: "+this.currentRotationDirectionY);this.getView().engine.addAction(new CameraRotationChangeAction(this.rotationActionY,{x:0,y:(freeze?0:this.currentRotationDirectionY*CAMERA_ROTATION_VELOCITY),z:0},1000));},enterNameInputMode:function(){this.setFreezeAction(true);var model=this.getModel();var view=this.getView();model.setNameInputMode(true);view.setPreventFocusOnCursor(true);view.focusOnNameInput();},changeName:function(name){var view=this.getView();var model=this.getModel();var self=this;if(name.length==0){return false;}else{var entityId=model.getEntity().id;runAjaxAction('change_entity_name',[entityId,name],function(success){if(!success){view.setNameInputError(t('game-already-existing-entity',false));return false;}else{self.setFreezeAction(false);model.getEntity().name=name;model.setNameInputMode(false);view.setPreventFocusOnCursor(false);view.setEnableCursor(true);view.focusOnCursor();model.setHasRegisteredName(true);return true;}});}},destroy:function(){this._super();this._timer.stop();this.getModel().setEntity(null);this.getView().engine.stop();}});function preventSubmitOnReturn(){if(typeof window.event=='undefined'){document.onkeypress=function(e){var test_var=e.target.nodeName.toUpperCase();if(e.target.type)var test_type=e.target.type.toUpperCase();if(e.keyCode==13){e.preventDefault();}}}else{document.onkeydown=function(){var test_var=event.srcElement.tagName.toUpperCase();if(event.srcElement.type)var test_type=event.srcElement.type.toUpperCase();if(e.keyCode==13){e.preventDefault();}}}};var Machine=FSM.build(function(fsm){with(fsm){var model=new VeveModel(this);var view;var controller;onEnteringAnyState(function(){model.setFsm(this);log('Entering: '+this.currentState.name())});onExitingAnyState(function(){if(view){view.destroy();}
if(controller){controller.destroy();}
log('Exiting: '+this.currentState.name())});state('init','initial').event('run').goesTo('home')
state('home').onEntering(function(){view=new HomePageView(model);controller=new HomePageController(model,view);controller.setButtonAction('new',function(model,event){model.getFsm().play()})
controller.setButtonAction('load',function(model,event){model.getFsm().load()})
controller.setButtonAction('intro',function(model,event){model.setIsBeginner(true);model.getFsm().intro()})
controller.setButtonAction('info',function(model,event){model.getFsm().info()})
controller.setButtonAction('credits',function(model,event){model.getFsm().credits()})
controller.setButtonAction('fr',function(model,event){setLocale('fr');});controller.setButtonAction('en',function(model,event){setLocale('en');});}).event('intro').goesTo('intro').event('play').goesTo('game').event('load').goesTo('load').event('info').goesTo('info').event('credits').goesTo('credits');state('info').onEntering(function(){view=new PageView(model);controller=new PageController(model,view);view.setText(t('info-text'));controller.setButtonAction('back',function(model,event){model.getFsm().home()});controller.setButtonAction('fr',function(model,event){setLocale('fr');});controller.setButtonAction('en',function(model,event){setLocale('en');});}).event('home').goesTo('home')
state('credits').onEntering(function(){view=new PageView(model);controller=new PageController(model,view);view.setText(t('credits-text'));controller.setButtonAction('back',function(model,event){model.getFsm().home()});controller.setButtonAction('fr',function(model,event){setLocale('fr');});controller.setButtonAction('en',function(model,event){setLocale('en');});}).event('home').goesTo('home')
state('intro').onEntering(function(){view=new TutorialView(model);controller=new TutorialController(model,view);}).event('stop').goesTo('game')
var loadedEntity=null;state('load').onEntering(function(){log("load it!");view=new LoadView(model);controller=new LoadController(model,view);}).event('play').goesTo('game')
state('new-game').onEntering(function(){model.getFsm().play()}).event('play').goesTo('game').doing(function(){model.reset();})
state('game').onEntering(function(){view=new GameView(model);controller=new GameController(model,view);view.addButton('quit',t('game-button-quit'),80,true,110);view.addButton('new',t('game-button-new'),40,true,150);view.addButton('load',t('game-button-load'),50,true,170);controller.setButtonAction('quit',function(model,event){model.getFsm().quit()});controller.setButtonAction('new',function(model,event){log("new game");model.getFsm().play()});controller.setButtonAction('load',function(model,event){model.getFsm().load()});}).event('quit').goesTo('home').event('play').goesTo('new-game').event('load').goesTo('load')}});function VeveMachine(){}
VeveMachine.prototype=new Machine(VeveMachine.prototype);;$j=jQuery.noConflict();function validateBrowser(){return($j.browser.mozilla&&parseFloat($j.browser.version)>1.5);}
if(!validateBrowser()){alert('Sorry but this project contains scripts that are not supported by your browser.\n\rDésolé, ce projet contient des scripts qui ne sont pas supportés par votre navigateur.')
document.location.href='browser.html'};$j(function(){initAudio();var machine=new VeveMachine();machine.run();preventSubmitOnReturn();})