var ControllerAction=null;
var GamesJSON={};
var Promote=null;
var UC=null;
var GRA={};
var Users={};
var Facebook=null;
var iphoneMode=false;
var Gane_id=null;
var chatRef=null;
var GameLoadDelay=0;
var doc_href=null;
(function(){
if(window.jQuery){
var _1=window.jQuery;
}
var _2=window.jQuery=function(_3,_4){
return new _2.prototype.init(_3,_4);
};
if(window.$){
var _$=window.$;
}
window.$=_2;
var _6=/^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;
var _7=/^.[^:#\[\.]*$/;
_2.fn=_2.prototype={init:function(_8,_9){
_8=_8||document;
if(_8.nodeType){
this[0]=_8;
this.length=1;
return this;
}else{
if(typeof _8=="string"){
var _a=_6.exec(_8);
if(_a&&(_a[1]||!_9)){
if(_a[1]){
_8=_2.clean([_a[1]],_9);
}else{
var _b=document.getElementById(_a[3]);
if(_b){
if(_b.id!=_a[3]){
return _2().find(_8);
}else{
this[0]=_b;
this.length=1;
return this;
}
}else{
_8=[];
}
}
}else{
return new _2(_9).find(_8);
}
}else{
if(_2.isFunction(_8)){
return new _2(document)[_2.fn.ready?"ready":"load"](_8);
}
}
}
return this.setArray(_8.constructor==Array&&_8||(_8.jquery||_8.length&&_8!=window&&!_8.nodeType&&_8[0]!=undefined&&_8[0].nodeType)&&_2.makeArray(_8)||[_8]);
},jquery:"1.2.2",size:function(){
return this.length;
},length:0,get:function(_c){
return _c==undefined?_2.makeArray(this):this[_c];
},pushStack:function(_d){
var _e=_2(_d);
_e.prevObject=this;
return _e;
},setArray:function(_f){
this.length=0;
Array.prototype.push.apply(this,_f);
return this;
},each:function(_10,_11){
return _2.each(this,_10,_11);
},index:function(_12){
var ret=-1;
this.each(function(i){
if(this==_12){
ret=i;
}
});
return ret;
},attr:function(_15,_16,_17){
var _18=_15;
if(_15.constructor==String){
if(_16==undefined){
return this.length&&_2[_17||"attr"](this[0],_15)||undefined;
}else{
_18={};
_18[_15]=_16;
}
}
return this.each(function(i){
for(_15 in _18){
_2.attr(_17?this.style:this,_15,_2.prop(this,_18[_15],_17,i,_15));
}
});
},css:function(key,_1b){
if((key=="width"||key=="height")&&parseFloat(_1b)<0){
_1b=undefined;
}
return this.attr(key,_1b,"curCSS");
},text:function(_1c){
if(typeof _1c!="object"&&_1c!=null){
return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(_1c));
}
var ret="";
_2.each(_1c||this,function(){
_2.each(this.childNodes,function(){
if(this.nodeType!=8){
ret+=this.nodeType!=1?this.nodeValue:_2.fn.text([this]);
}
});
});
return ret;
},wrapAll:function(_1e){
if(this[0]){
_2(_1e,this[0].ownerDocument).clone().insertBefore(this[0]).map(function(){
var _1f=this;
while(_1f.firstChild){
_1f=_1f.firstChild;
}
return _1f;
}).append(this);
}
return this;
},wrapInner:function(_20){
return this.each(function(){
_2(this).contents().wrapAll(_20);
});
},wrap:function(_21){
return this.each(function(){
_2(this).wrapAll(_21);
});
},append:function(){
return this.domManip(arguments,true,false,function(_22){
if(this.nodeType==1){
this.appendChild(_22);
}
});
},prepend:function(){
return this.domManip(arguments,true,true,function(_23){
if(this.nodeType==1){
this.insertBefore(_23,this.firstChild);
}
});
},before:function(){
return this.domManip(arguments,false,false,function(_24){
this.parentNode.insertBefore(_24,this);
});
},after:function(){
return this.domManip(arguments,false,true,function(_25){
this.parentNode.insertBefore(_25,this.nextSibling);
});
},end:function(){
return this.prevObject||_2([]);
},find:function(_26){
var _27=_2.map(this,function(_28){
return _2.find(_26,_28);
});
return this.pushStack(/[^+>] [^+>]/.test(_26)||_26.indexOf("..")>-1?_2.unique(_27):_27);
},clone:function(_29){
var ret=this.map(function(){
if(_2.browser.msie&&!_2.isXMLDoc(this)){
var _2b=this.cloneNode(true),_2c=document.createElement("div"),_2d=document.createElement("div");
_2c.appendChild(_2b);
_2d.innerHTML=_2c.innerHTML;
return _2d.firstChild;
}else{
return this.cloneNode(true);
}
});
var _2e=ret.find("*").andSelf().each(function(){
if(this[expando]!=undefined){
this[expando]=null;
}
});
if(_29===true){
this.find("*").andSelf().each(function(i){
if(this.nodeType==3){
return;
}
var _30=_2.data(this,"events");
for(var _31 in _30){
for(var _32 in _30[_31]){
_2.event.add(_2e[i],_31,_30[_31][_32],_30[_31][_32].data);
}
}
});
}
return ret;
},filter:function(_33){
return this.pushStack(_2.isFunction(_33)&&_2.grep(this,function(_34,i){
return _33.call(_34,i);
})||_2.multiFilter(_33,this));
},not:function(_36){
if(_36.constructor==String){
if(_7.test(_36)){
return this.pushStack(_2.multiFilter(_36,this,true));
}else{
_36=_2.multiFilter(_36,this);
}
}
var _37=_36.length&&_36[_36.length-1]!==undefined&&!_36.nodeType;
return this.filter(function(){
return _37?_2.inArray(this,_36)<0:this!=_36;
});
},add:function(_38){
return !_38?this:this.pushStack(_2.merge(this.get(),_38.constructor==String?_2(_38).get():_38.length!=undefined&&(!_38.nodeName||_2.nodeName(_38,"form"))?_38:[_38]));
},is:function(_39){
return _39?_2.multiFilter(_39,this).length>0:false;
},hasClass:function(_3a){
return this.is("."+_3a);
},val:function(_3b){
if(_3b==undefined){
if(this.length){
var _3c=this[0];
if(_2.nodeName(_3c,"select")){
var _3d=_3c.selectedIndex,_3e=[],_3f=_3c.options,one=_3c.type=="select-one";
if(_3d<0){
return null;
}
for(var i=one?_3d:0,max=one?_3d+1:_3f.length;i<max;i++){
var _43=_3f[i];
if(_43.selected){
_3b=_2.browser.msie&&!_43.attributes.value.specified?_43.text:_43.value;
if(one){
return _3b;
}
_3e.push(_3b);
}
}
return _3e;
}else{
return (this[0].value||"").replace(/\r/g,"");
}
}
return undefined;
}
return this.each(function(){
if(this.nodeType!=1){
return;
}
if(_3b.constructor==Array&&/radio|checkbox/.test(this.type)){
this.checked=(_2.inArray(this.value,_3b)>=0||_2.inArray(this.name,_3b)>=0);
}else{
if(_2.nodeName(this,"select")){
var _44=_3b.constructor==Array?_3b:[_3b];
_2("option",this).each(function(){
this.selected=(_2.inArray(this.value,_44)>=0||_2.inArray(this.text,_44)>=0);
});
if(!_44.length){
this.selectedIndex=-1;
}
}else{
this.value=_3b;
}
}
});
},html:function(_45){
return _45==undefined?(this.length?this[0].innerHTML:null):this.empty().append(_45);
},replaceWith:function(_46){
return this.after(_46).remove();
},eq:function(i){
return this.slice(i,i+1);
},slice:function(){
return this.pushStack(Array.prototype.slice.apply(this,arguments));
},map:function(_48){
return this.pushStack(_2.map(this,function(_49,i){
return _48.call(_49,i,_49);
}));
},andSelf:function(){
return this.add(this.prevObject);
},domManip:function(_4b,_4c,_4d,_4e){
var _4f=this.length>1,_50;
return this.each(function(){
if(!_50){
_50=_2.clean(_4b,this.ownerDocument);
if(_4d){
_50.reverse();
}
}
var obj=this;
if(_4c&&_2.nodeName(this,"table")&&_2.nodeName(_50[0],"tr")){
obj=this.getElementsByTagName("tbody")[0]||this.appendChild(this.ownerDocument.createElement("tbody"));
}
var _52=_2([]);
_2.each(_50,function(){
var _53=_4f?_2(this).clone(true)[0]:this;
if(_2.nodeName(_53,"script")){
_52=_52.add(_53);
}else{
if(_53.nodeType==1){
_52=_52.add(_2("script",_53).remove());
}
_4e.call(obj,_53);
}
});
_52.each(evalScript);
});
}};
_2.prototype.init.prototype=_2.prototype;
function evalScript(i,_55){
if(_55.src){
_2.ajax({url:_55.src,async:false,dataType:"script"});
}else{
_2.globalEval(_55.text||_55.textContent||_55.innerHTML||"");
}
if(_55.parentNode){
_55.parentNode.removeChild(_55);
}
}
_2.extend=_2.fn.extend=function(){
var _56=arguments[0]||{},i=1,_58=arguments.length,_59=false,_5a;
if(_56.constructor==Boolean){
_59=_56;
_56=arguments[1]||{};
i=2;
}
if(typeof _56!="object"&&typeof _56!="function"){
_56={};
}
if(_58==1){
_56=this;
i=0;
}
for(;i<_58;i++){
if((_5a=arguments[i])!=null){
for(var _5b in _5a){
if(_56===_5a[_5b]){
continue;
}
if(_59&&_5a[_5b]&&typeof _5a[_5b]=="object"&&_56[_5b]&&!_5a[_5b].nodeType){
_56[_5b]=_2.extend(_56[_5b],_5a[_5b]);
}else{
if(_5a[_5b]!=undefined){
_56[_5b]=_5a[_5b];
}
}
}
}
}
return _56;
};
var _5c="jQuery"+(new Date()).getTime(),_5d=0,_5e={};
var _5f=/z-?index|font-?weight|opacity|zoom|line-?height/i;
_2.extend({noConflict:function(_60){
window.$=_$;
if(_60){
window.jQuery=_1;
}
return _2;
},isFunction:function(fn){
return !!fn&&typeof fn!="string"&&!fn.nodeName&&fn.constructor!=Array&&/function/i.test(fn+"");
},isXMLDoc:function(_62){
return _62.documentElement&&!_62.body||_62.tagName&&_62.ownerDocument&&!_62.ownerDocument.body;
},globalEval:function(_63){
_63=_2.trim(_63);
if(_63){
var _64=document.getElementsByTagName("head")[0]||document.documentElement,_65=document.createElement("script");
_65.type="text/javascript";
if(_2.browser.msie){
_65.text=_63;
}else{
_65.appendChild(document.createTextNode(_63));
}
_64.appendChild(_65);
_64.removeChild(_65);
}
},nodeName:function(_66,_67){
return _66.nodeName&&_66.nodeName.toUpperCase()==_67.toUpperCase();
},cache:{},data:function(_68,_69,_6a){
_68=_68==window?_5e:_68;
var id=_68[_5c];
if(!id){
id=_68[_5c]=++_5d;
}
if(_69&&!_2.cache[id]){
_2.cache[id]={};
}
if(_6a!=undefined){
_2.cache[id][_69]=_6a;
}
return _69?_2.cache[id][_69]:id;
},removeData:function(_6c,_6d){
_6c=_6c==window?_5e:_6c;
var id=_6c[_5c];
if(_6d){
if(_2.cache[id]){
delete _2.cache[id][_6d];
_6d="";
for(_6d in _2.cache[id]){
break;
}
if(!_6d){
_2.removeData(_6c);
}
}
}else{
try{
delete _6c[_5c];
}
catch(e){
if(_6c.removeAttribute){
_6c.removeAttribute(_5c);
}
}
delete _2.cache[id];
}
},each:function(_6f,_70,_71){
if(_71){
if(_6f.length==undefined){
for(var _72 in _6f){
if(_70.apply(_6f[_72],_71)===false){
break;
}
}
}else{
for(var i=0,_74=_6f.length;i<_74;i++){
if(_70.apply(_6f[i],_71)===false){
break;
}
}
}
}else{
if(_6f.length==undefined){
for(var _72 in _6f){
if(_70.call(_6f[_72],_72,_6f[_72])===false){
break;
}
}
}else{
for(var i=0,_74=_6f.length,_75=_6f[0];i<_74&&_70.call(_75,i,_75)!==false;_75=_6f[++i]){
}
}
}
return _6f;
},prop:function(_76,_77,_78,i,_7a){
if(_2.isFunction(_77)){
_77=_77.call(_76,i);
}
return _77&&_77.constructor==Number&&_78=="curCSS"&&!_5f.test(_7a)?_77+"px":_77;
},className:{add:function(_7b,_7c){
_2.each((_7c||"").split(/\s+/),function(i,_7e){
if(_7b.nodeType==1&&!_2.className.has(_7b.className,_7e)){
_7b.className+=(_7b.className?" ":"")+_7e;
}
});
},remove:function(_7f,_80){
if(_7f.nodeType==1){
_7f.className=_80!=undefined?_2.grep(_7f.className.split(/\s+/),function(_81){
return !_2.className.has(_80,_81);
}).join(" "):"";
}
},has:function(_82,_83){
return _2.inArray(_83,(_82.className||_82).toString().split(/\s+/))>-1;
}},swap:function(_84,_85,_86){
var old={};
for(var _88 in _85){
old[_88]=_84.style[_88];
_84.style[_88]=_85[_88];
}
_86.call(_84);
for(var _88 in _85){
_84.style[_88]=old[_88];
}
},css:function(_89,_8a,_8b){
if(_8a=="width"||_8a=="height"){
var val,_8d={position:"absolute",visibility:"hidden",display:"block"},_8e=_8a=="width"?["Left","Right"]:["Top","Bottom"];
function getWH(){
val=_8a=="width"?_89.offsetWidth:_89.offsetHeight;
var _8f=0,_90=0;
_2.each(_8e,function(){
_8f+=parseFloat(_2.curCSS(_89,"padding"+this,true))||0;
_90+=parseFloat(_2.curCSS(_89,"border"+this+"Width",true))||0;
});
val-=Math.round(_8f+_90);
}
if(_2(_89).is(":visible")){
getWH();
}else{
_2.swap(_89,_8d,getWH);
}
return Math.max(0,val);
}
return _2.curCSS(_89,_8a,_8b);
},curCSS:function(_91,_92,_93){
var ret;
function color(_95){
if(!_2.browser.safari){
return false;
}
var ret=document.defaultView.getComputedStyle(_95,null);
return !ret||ret.getPropertyValue("color")=="";
}
if(_92=="opacity"&&_2.browser.msie){
ret=_2.attr(_91.style,"opacity");
return ret==""?"1":ret;
}
if(_2.browser.opera&&_92=="display"){
var _97=_91.style.display;
_91.style.display="block";
_91.style.display=_97;
}
if(_92.match(/float/i)){
_92=styleFloat;
}
if(!_93&&_91.style&&_91.style[_92]){
ret=_91.style[_92];
}else{
if(document.defaultView&&document.defaultView.getComputedStyle){
if(_92.match(/float/i)){
_92="float";
}
_92=_92.replace(/([A-Z])/g,"-$1").toLowerCase();
var _98=document.defaultView.getComputedStyle(_91,null);
if(_98&&!color(_91)){
ret=_98.getPropertyValue(_92);
}else{
var _99=[],_9a=[];
for(var a=_91;a&&color(a);a=a.parentNode){
_9a.unshift(a);
}
for(var i=0;i<_9a.length;i++){
if(color(_9a[i])){
_99[i]=_9a[i].style.display;
_9a[i].style.display="block";
}
}
ret=_92=="display"&&_99[_9a.length-1]!=null?"none":(_98&&_98.getPropertyValue(_92))||"";
for(var i=0;i<_99.length;i++){
if(_99[i]!=null){
_9a[i].style.display=_99[i];
}
}
}
if(_92=="opacity"&&ret==""){
ret="1";
}
}else{
if(_91.currentStyle){
var _9d=_92.replace(/\-(\w)/g,function(all,_9f){
return _9f.toUpperCase();
});
ret=_91.currentStyle[_92]||_91.currentStyle[_9d];
if(!/^\d+(px)?$/i.test(ret)&&/^\d/.test(ret)){
var _a0=_91.style.left,_a1=_91.runtimeStyle.left;
_91.runtimeStyle.left=_91.currentStyle.left;
_91.style.left=ret||0;
ret=_91.style.pixelLeft+"px";
_91.style.left=_a0;
_91.runtimeStyle.left=_a1;
}
}
}
}
return ret;
},clean:function(_a2,_a3){
var ret=[];
_a3=_a3||document;
if(typeof _a3.createElement=="undefined"){
_a3=_a3.ownerDocument||_a3[0]&&_a3[0].ownerDocument||document;
}
_2.each(_a2,function(i,_a6){
if(!_a6){
return;
}
if(_a6.constructor==Number){
_a6=_a6.toString();
}
if(typeof _a6=="string"){
_a6=_a6.replace(/(<(\w+)[^>]*?)\/>/g,function(all,_a8,tag){
return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?all:_a8+"></"+tag+">";
});
var _aa=_2.trim(_a6).toLowerCase(),div=_a3.createElement("div");
var _ac=!_aa.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!_aa.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||_aa.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!_aa.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!_aa.indexOf("<td")||!_aa.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!_aa.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||_2.browser.msie&&[1,"div<div>","</div>"]||[0,"",""];
div.innerHTML=_ac[1]+_a6+_ac[2];
while(_ac[0]--){
div=div.lastChild;
}
if(_2.browser.msie){
var _ad=!_aa.indexOf("<table")&&_aa.indexOf("<tbody")<0?div.firstChild&&div.firstChild.childNodes:_ac[1]=="<table>"&&_aa.indexOf("<tbody")<0?div.childNodes:[];
for(var j=_ad.length-1;j>=0;--j){
if(_2.nodeName(_ad[j],"tbody")&&!_ad[j].childNodes.length){
_ad[j].parentNode.removeChild(_ad[j]);
}
}
if(/^\s/.test(_a6)){
div.insertBefore(_a3.createTextNode(_a6.match(/^\s*/)[0]),div.firstChild);
}
}
_a6=_2.makeArray(div.childNodes);
}
if(_a6.length===0&&(!_2.nodeName(_a6,"form")&&!_2.nodeName(_a6,"select"))){
return;
}
if(_a6[0]==undefined||_2.nodeName(_a6,"form")||_a6.options){
ret.push(_a6);
}else{
ret=_2.merge(ret,_a6);
}
});
return ret;
},attr:function(_af,_b0,_b1){
if(!_af||_af.nodeType==3||_af.nodeType==8){
return undefined;
}
var fix=_2.isXMLDoc(_af)?{}:_2.props;
if(_b0=="selected"&&_2.browser.safari){
_af.parentNode.selectedIndex;
}
if(fix[_b0]){
if(_b1!=undefined){
_af[fix[_b0]]=_b1;
}
return _af[fix[_b0]];
}else{
if(_2.browser.msie&&_b0=="style"){
return _2.attr(_af.style,"cssText",_b1);
}else{
if(_b1==undefined&&_2.browser.msie&&_2.nodeName(_af,"form")&&(_b0=="action"||_b0=="method")){
return _af.getAttributeNode(_b0).nodeValue;
}else{
if(_af.tagName){
if(_b1!=undefined){
if(_b0=="type"&&_2.nodeName(_af,"input")&&_af.parentNode){
throw "type property can't be changed";
}
_af.setAttribute(_b0,""+_b1);
}
if(_2.browser.msie&&/href|src/.test(_b0)&&!_2.isXMLDoc(_af)){
return _af.getAttribute(_b0,2);
}
return _af.getAttribute(_b0);
}else{
if(_b0=="opacity"&&_2.browser.msie){
if(_b1!=undefined){
_af.zoom=1;
_af.filter=(_af.filter||"").replace(/alpha\([^)]*\)/,"")+(parseFloat(_b1).toString()=="NaN"?"":"alpha(opacity="+_b1*100+")");
}
return _af.filter&&_af.filter.indexOf("opacity=")>=0?(parseFloat(_af.filter.match(/opacity=([^)]*)/)[1])/100).toString():"";
}
_b0=_b0.replace(/-([a-z])/ig,function(all,_b4){
return _b4.toUpperCase();
});
if(_b1!=undefined){
_af[_b0]=_b1;
}
return _af[_b0];
}
}
}
}
},trim:function(_b5){
return (_b5||"").replace(/^\s+|\s+$/g,"");
},makeArray:function(_b6){
var ret=[];
if(typeof _b6!="array"){
for(var i=0,_b9=_b6.length;i<_b9;i++){
ret.push(_b6[i]);
}
}else{
ret=_b6.slice(0);
}
return ret;
},inArray:function(_ba,_bb){
for(var i=0,_bd=_bb.length;i<_bd;i++){
if(_bb[i]==_ba){
return i;
}
}
return -1;
},merge:function(_be,_bf){
if(_2.browser.msie){
for(var i=0;_bf[i];i++){
if(_bf[i].nodeType!=8){
_be.push(_bf[i]);
}
}
}else{
for(var i=0;_bf[i];i++){
_be.push(_bf[i]);
}
}
return _be;
},unique:function(_c1){
var ret=[],_c3={};
try{
for(var i=0,_c5=_c1.length;i<_c5;i++){
var id=_2.data(_c1[i]);
if(!_c3[id]){
_c3[id]=true;
ret.push(_c1[i]);
}
}
}
catch(e){
ret=_c1;
}
return ret;
},grep:function(_c7,_c8,inv){
if(typeof _c8=="string"){
_c8=eval("false||function(a,i){return "+_c8+"}");
}
var ret=[];
for(var i=0,_cc=_c7.length;i<_cc;i++){
if(!inv&&_c8(_c7[i],i)||inv&&!_c8(_c7[i],i)){
ret.push(_c7[i]);
}
}
return ret;
},map:function(_cd,_ce){
var ret=[];
for(var i=0,_d1=_cd.length;i<_d1;i++){
var _d2=_ce(_cd[i],i);
if(_d2!==null&&_d2!=undefined){
if(_d2.constructor!=Array){
_d2=[_d2];
}
ret=ret.concat(_d2);
}
}
return ret;
}});
var _d3=navigator.userAgent.toLowerCase();
_2.browser={version:(_d3.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(_d3),opera:/opera/.test(_d3),msie:/msie/.test(_d3)&&!/opera/.test(_d3),mozilla:/mozilla/.test(_d3)&&!/(compatible|webkit)/.test(_d3)};
var _d4=_2.browser.msie?"styleFloat":"cssFloat";
_2.extend({boxModel:!_2.browser.msie||document.compatMode=="CSS1Compat",props:{"for":"htmlFor","class":"className","float":_d4,cssFloat:_d4,styleFloat:_d4,innerHTML:"innerHTML",className:"className",value:"value",disabled:"disabled",checked:"checked",readonly:"readOnly",selected:"selected",maxlength:"maxLength",selectedIndex:"selectedIndex",defaultValue:"defaultValue",tagName:"tagName",nodeName:"nodeName"}});
_2.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(_d5,fn){
fn=eval("false||function(elem){return "+fn+"}");
_2.fn[_d5]=function(_d7){
var ret=_2.map(this,fn);
if(_d7&&typeof _d7=="string"){
ret=_2.multiFilter(_d7,ret);
}
return this.pushStack(_2.unique(ret));
};
});
_2.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(_d9,_da){
_2.fn[_d9]=function(){
var _db=arguments;
return this.each(function(){
for(var i=0,_dd=_db.length;i<_dd;i++){
_2(_db[i])[_da](this);
}
});
};
});
_2.each({removeAttr:function(_de){
_2.attr(this,_de,"");
if(this.nodeType==1){
this.removeAttribute(_de);
}
},addClass:function(_df){
_2.className.add(this,_df);
},removeClass:function(_e0){
_2.className.remove(this,_e0);
},toggleClass:function(_e1){
_2.className[_2.className.has(this,_e1)?"remove":"add"](this,_e1);
},remove:function(_e2){
if(!_e2||_2.filter(_e2,[this]).r.length){
_2("*",this).add(this).each(function(){
_2.event.remove(this);
_2.removeData(this);
});
if(this.parentNode){
this.parentNode.removeChild(this);
}
}
},empty:function(){
_2(">*",this).remove();
while(this.firstChild){
this.removeChild(this.firstChild);
}
}},function(_e3,fn){
_2.fn[_e3]=function(){
return this.each(fn,arguments);
};
});
_2.each(["Height","Width"],function(i,_e6){
var _e7=_e6.toLowerCase();
_2.fn[_e7]=function(_e8){
return this[0]==window?_2.browser.opera&&document.body["client"+_e6]||_2.browser.safari&&window["inner"+_e6]||document.compatMode=="CSS1Compat"&&document.documentElement["client"+_e6]||document.body["client"+_e6]:this[0]==document?Math.max(Math.max(document.body["scroll"+_e6],document.documentElement["scroll"+_e6]),Math.max(document.body["offset"+_e6],document.documentElement["offset"+_e6])):_e8==undefined?(this.length?_2.css(this[0],_e7):null):this.css(_e7,_e8.constructor==String?_e8:_e8+"px");
};
});
var _e9=_2.browser.safari&&parseInt(_2.browser.version)<417?"(?:[\\w*_-]|\\\\.)":"(?:[\\w\u0128-\uffff*_-]|\\\\.)",_ea=new RegExp("^>\\s*("+_e9+"+)"),_eb=new RegExp("^("+_e9+"+)(#)("+_e9+"+)"),_ec=new RegExp("^([#.]?)("+_e9+"*)");
_2.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("^([:.#]*)("+_e9+"+)")],multiFilter:function(_ed,_ee,not){
var old,cur=[];
while(_ed&&_ed!=old){
old=_ed;
var f=_2.filter(_ed,_ee,not);
_ed=f.t.replace(/^\s*,\s*/,"");
cur=not?_ee=f.r:_2.merge(cur,f.r);
}
return cur;
},find:function(t,_f4){
if(typeof t!="string"){
return [t];
}
if(_f4&&_f4.nodeType!=1&&_f4.nodeType!=9){
return [];
}
_f4=_f4||document;
var ret=[_f4],_f6=[],_f7,_f8;
while(t&&_f7!=t){
var r=[];
_f7=t;
t=_2.trim(t);
var _fa=false;
var re=_ea;
var m=re.exec(t);
if(m){
_f8=m[1].toUpperCase();
for(var i=0;ret[i];i++){
for(var c=ret[i].firstChild;c;c=c.nextSibling){
if(c.nodeType==1&&(_f8=="*"||c.nodeName.toUpperCase()==_f8)){
r.push(c);
}
}
}
ret=r;
t=t.replace(re,"");
if(t.indexOf(" ")==0){
continue;
}
_fa=true;
}else{
re=/^([>+~])\s*(\w*)/i;
if((m=re.exec(t))!=null){
r=[];
var _ff={};
_f8=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=_2.data(n);
if(m=="~"&&_ff[id]){
break;
}
if(!_f8||n.nodeName.toUpperCase()==_f8){
if(m=="~"){
_ff[id]=true;
}
r.push(n);
}
if(m=="+"){
break;
}
}
}
}
ret=r;
t=_2.trim(t.replace(re,""));
_fa=true;
}
}
if(t&&!_fa){
if(!t.indexOf(",")){
if(_f4==ret[0]){
ret.shift();
}
_f6=_2.merge(_f6,ret);
r=ret=[_f4];
t=" "+t.substr(1,t.length);
}else{
var re2=_eb;
var m=re2.exec(t);
if(m){
m=[0,m[2],m[3],m[1]];
}else{
re2=_ec;
m=re2.exec(t);
}
m[2]=m[2].replace(/\\/g,"");
var elem=ret[ret.length-1];
if(m[1]=="#"&&elem&&elem.getElementById&&!_2.isXMLDoc(elem)){
var oid=elem.getElementById(m[2]);
if((_2.browser.msie||_2.browser.opera)&&oid&&typeof oid.id=="string"&&oid.id!=m[2]){
oid=_2("[@id=\""+m[2]+"\"]",elem)[0];
}
ret=r=oid&&(!m[3]||_2.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=_2.merge(r,ret[i].getElementsByTagName(tag));
}
if(m[1]=="."){
r=_2.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=_2.filter(t,r);
ret=r=val.r;
t=_2.trim(val.t);
}
}
if(t){
ret=[];
}
if(ret&&_f4==ret[0]){
ret.shift();
}
_f6=_2.merge(_f6,ret);
return _f6;
},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=_2.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=_7.test(m[3])?_2.filter(m[3],r,true).r:_2(r).not(m[3]);
}else{
if(m[1]=="."){
r=_2.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[_2.props[m[2]]||m[2]];
if(z==null||/href|src|selected/.test(m[2])){
z=_2.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 _11c={},tmp=[],test=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(m[3]=="even"&&"2n"||m[3]=="odd"&&"2n+1"||!/\D/.test(m[3])&&"0n+"+m[3]||m[3]),_11e=(test[1]+(test[2]||1))-0,last=test[3]-0;
for(var i=0,rl=r.length;i<rl;i++){
var node=r[i],_120=node.parentNode,id=_2.data(_120);
if(!_11c[id]){
var c=1;
for(var n=_120.firstChild;n;n=n.nextSibling){
if(n.nodeType==1){
n.nodeIndex=c++;
}
}
_11c[id]=true;
}
var add=false;
if(_11e==0){
if(node.nodeIndex==last){
add=true;
}
}else{
if((node.nodeIndex-last)%_11e==0&&(node.nodeIndex-last)/_11e>=0){
add=true;
}
}
if(add^not){
tmp.push(node);
}
}
r=tmp;
}else{
var f=_2.expr[m[1]];
if(typeof f!="string"){
f=_2.expr[m[1]][m[2]];
}
f=eval("false||function(a,i){return "+f+"}");
r=_2.grep(r,f,not);
}
}
}
}
}
return {r:r,t:t};
},dir:function(elem,dir){
var _128=[];
var cur=elem[dir];
while(cur&&cur!=document){
if(cur.nodeType==1){
_128.push(cur);
}
cur=cur[dir];
}
return _128;
},nth:function(cur,_12b,dir,elem){
_12b=_12b||1;
var num=0;
for(;cur;cur=cur[dir]){
if(cur.nodeType==1&&++num==_12b){
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;
}});
_2.event={add:function(elem,_133,_134,data){
if(elem.nodeType==3||elem.nodeType==8){
return;
}
if(_2.browser.msie&&elem.setInterval!=undefined){
elem=window;
}
if(!_134.guid){
_134.guid=this.guid++;
}
if(data!=undefined){
var fn=_134;
_134=function(){
return fn.apply(this,arguments);
};
_134.data=data;
_134.guid=fn.guid;
}
var _137=_2.data(elem,"events")||_2.data(elem,"events",{}),_138=_2.data(elem,"handle")||_2.data(elem,"handle",function(){
var val;
if(typeof _2=="undefined"||_2.event.triggered){
return val;
}
val=_2.event.handle.apply(arguments.callee.elem,arguments);
return val;
});
_138.elem=elem;
_2.each(_133.split(/\s+/),function(_13a,type){
var _13c=type.split(".");
type=_13c[0];
_134.type=_13c[1];
var _13d=_137[type];
if(!_13d){
_13d=_137[type]={};
if(!_2.event.special[type]||_2.event.special[type].setup.call(elem)===false){
if(elem.addEventListener){
elem.addEventListener(type,_138,false);
}else{
if(elem.attachEvent){
elem.attachEvent("on"+type,_138);
}
}
}
}
_13d[_134.guid]=_134;
_2.event.global[type]=true;
});
elem=null;
},guid:1,global:{},remove:function(elem,_13f,_140){
if(elem.nodeType==3||elem.nodeType==8){
return;
}
var _141=_2.data(elem,"events"),ret,_143;
if(_141){
if(_13f==undefined){
for(var type in _141){
this.remove(elem,type);
}
}else{
if(_13f.type){
_140=_13f.handler;
_13f=_13f.type;
}
_2.each(_13f.split(/\s+/),function(_145,type){
var _147=type.split(".");
type=_147[0];
if(_141[type]){
if(_140){
delete _141[type][_140.guid];
}else{
for(_140 in _141[type]){
if(!_147[1]||_141[type][_140].type==_147[1]){
delete _141[type][_140];
}
}
}
for(ret in _141[type]){
break;
}
if(!ret){
if(!_2.event.special[type]||_2.event.special[type].teardown.call(elem)===false){
if(elem.removeEventListener){
elem.removeEventListener(type,_2.data(elem,"handle"),false);
}else{
if(elem.detachEvent){
elem.detachEvent("on"+type,_2.data(elem,"handle"));
}
}
}
ret=null;
delete _141[type];
}
}
});
}
for(ret in _141){
break;
}
if(!ret){
var _148=_2.data(elem,"handle");
if(_148){
_148.elem=null;
}
_2.removeData(elem,"events");
_2.removeData(elem,"handle");
}
}
},trigger:function(type,data,elem,_14c,_14d){
data=_2.makeArray(data||[]);
if(!elem){
if(this.global[type]){
_2("*").add([window,document]).trigger(type,data);
}
}else{
if(elem.nodeType==3||elem.nodeType==8){
return undefined;
}
var val,ret,fn=_2.isFunction(elem[type]||null),_151=!data[0]||!data[0].preventDefault;
if(_151){
data.unshift(this.fix({type:type,target:elem}));
}
data[0].type=type;
if(_2.isFunction(_2.data(elem,"handle"))){
val=_2.data(elem,"handle").apply(elem,data);
}
if(!fn&&elem["on"+type]&&elem["on"+type].apply(elem,data)===false){
val=false;
}
if(_151){
data.shift();
}
if(_14d&&_2.isFunction(_14d)){
ret=_14d.apply(elem,val==null?data:data.concat(val));
if(ret!==undefined){
val=ret;
}
}
if(fn&&_14c!==false&&val!==false&&!(_2.nodeName(elem,"a")&&type=="click")){
this.triggered=true;
try{
elem[type]();
}
catch(e){
}
}
this.triggered=false;
}
return val;
},handle:function(_152){
var val;
_152=_2.event.fix(_152||window.event||{});
var _154=_152.type.split(".");
_152.type=_154[0];
var _155=_2.data(this,"events")&&_2.data(this,"events")[_152.type],args=Array.prototype.slice.call(arguments,1);
args.unshift(_152);
for(var j in _155){
var _158=_155[j];
args[0].handler=_158;
args[0].data=_158.data;
if(!_154[1]||_158.type==_154[1]){
var ret=_158.apply(this,args);
if(val!==false){
val=ret;
}
if(ret===false){
_152.preventDefault();
_152.stopPropagation();
}
}
}
if(_2.browser.msie){
_152.target=_152.preventDefault=_152.stopPropagation=_152.handler=_152.data=null;
}
return val;
},fix:function(_15a){
var _15b=_15a;
_15a=_2.extend({},_15b);
_15a.preventDefault=function(){
if(_15b.preventDefault){
_15b.preventDefault();
}
_15b.returnValue=false;
};
_15a.stopPropagation=function(){
if(_15b.stopPropagation){
_15b.stopPropagation();
}
_15b.cancelBubble=true;
};
if(!_15a.target){
_15a.target=_15a.srcElement||document;
}
if(_15a.target.nodeType==3){
_15a.target=_15b.target.parentNode;
}
if(!_15a.relatedTarget&&_15a.fromElement){
_15a.relatedTarget=_15a.fromElement==_15a.target?_15a.toElement:_15a.fromElement;
}
if(_15a.pageX==null&&_15a.clientX!=null){
var doc=document.documentElement,body=document.body;
_15a.pageX=_15a.clientX+(doc&&doc.scrollLeft||body&&body.scrollLeft||0)-(doc.clientLeft||0);
_15a.pageY=_15a.clientY+(doc&&doc.scrollTop||body&&body.scrollTop||0)-(doc.clientTop||0);
}
if(!_15a.which&&((_15a.charCode||_15a.charCode===0)?_15a.charCode:_15a.keyCode)){
_15a.which=_15a.charCode||_15a.keyCode;
}
if(!_15a.metaKey&&_15a.ctrlKey){
_15a.metaKey=_15a.ctrlKey;
}
if(!_15a.which&&_15a.button){
_15a.which=(_15a.button&1?1:(_15a.button&2?3:(_15a.button&4?2:0)));
}
return _15a;
},special:{ready:{setup:function(){
bindReady();
return;
},teardown:function(){
return;
}},mouseenter:{setup:function(){
if(_2.browser.msie){
return false;
}
_2(this).bind("mouseover",_2.event.special.mouseenter.handler);
return true;
},teardown:function(){
if(_2.browser.msie){
return false;
}
_2(this).unbind("mouseover",_2.event.special.mouseenter.handler);
return true;
},handler:function(_15e){
if(_15f(_15e,this)){
return true;
}
arguments[0].type="mouseenter";
return _2.event.handle.apply(this,arguments);
}},mouseleave:{setup:function(){
if(_2.browser.msie){
return false;
}
_2(this).bind("mouseout",_2.event.special.mouseleave.handler);
return true;
},teardown:function(){
if(_2.browser.msie){
return false;
}
_2(this).unbind("mouseout",_2.event.special.mouseleave.handler);
return true;
},handler:function(_160){
if(_15f(_160,this)){
return true;
}
arguments[0].type="mouseleave";
return _2.event.handle.apply(this,arguments);
}}}};
_2.fn.extend({bind:function(type,data,fn){
return type=="unload"?this.one(type,data,fn):this.each(function(){
_2.event.add(this,type,fn||data,fn&&data);
});
},one:function(type,data,fn){
return this.each(function(){
_2.event.add(this,type,function(_167){
_2(this).unbind(_167);
return (fn||data).apply(this,arguments);
},fn&&data);
});
},unbind:function(type,fn){
return this.each(function(){
_2.event.remove(this,type,fn);
});
},trigger:function(type,data,fn){
return this.each(function(){
_2.event.trigger(type,data,this,true,fn);
});
},triggerHandler:function(type,data,fn){
if(this[0]){
return _2.event.trigger(type,data,this[0],false,fn);
}
return undefined;
},toggle:function(){
var args=arguments;
return this.click(function(_171){
this.lastToggle=0==this.lastToggle?1:0;
_171.preventDefault();
return args[this.lastToggle].apply(this,arguments)||false;
});
},hover:function(_172,_173){
return this.bind("mouseenter",_172).bind("mouseleave",_173);
},ready:function(fn){
bindReady();
if(_2.isReady){
fn.call(document,_2);
}else{
_2.readyList.push(function(){
return fn.call(this,_2);
});
}
return this;
}});
_2.extend({isReady:false,readyList:[],ready:function(){
if(!_2.isReady){
_2.isReady=true;
if(_2.readyList){
_2.each(_2.readyList,function(){
this.apply(document);
});
_2.readyList=null;
}
_2(document).triggerHandler("ready");
}
}});
var _175=false;
function bindReady(){
if(_175){
return;
}
_175=true;
if(document.addEventListener&&!_2.browser.opera){
document.addEventListener("DOMContentLoaded",_2.ready,false);
}
if(_2.browser.msie&&window==top){
(function(){
if(_2.isReady){
return;
}
try{
document.documentElement.doScroll("left");
}
catch(error){
setTimeout(arguments.callee,0);
return;
}
_2.ready();
})();
}
if(_2.browser.opera){
document.addEventListener("DOMContentLoaded",function(){
if(_2.isReady){
return;
}
for(var i=0;i<document.styleSheets.length;i++){
if(document.styleSheets[i].disabled){
setTimeout(arguments.callee,0);
return;
}
}
_2.ready();
},false);
}
if(_2.browser.safari){
var _177;
(function(){
if(_2.isReady){
return;
}
if(document.readyState!="loaded"&&document.readyState!="complete"){
setTimeout(arguments.callee,0);
return;
}
if(_177===undefined){
_177=_2("style, link[rel=stylesheet]").length;
}
if(document.styleSheets.length!=_177){
setTimeout(arguments.callee,0);
return;
}
_2.ready();
})();
}
_2.event.add(window,"load",_2.ready);
}
_2.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){
_2.fn[name]=function(fn){
return fn?this.bind(name,fn):this.trigger(name);
};
});
var _15f=function(_17b,elem){
var _17d=_17b.relatedTarget;
while(_17d&&_17d!=elem){
try{
_17d=_17d.parentNode;
}
catch(error){
_17d=elem;
}
}
return _17d==elem;
};
_2(window).bind("unload",function(){
_2("*").add(document).unbind();
});
_2.fn.extend({load:function(url,_17f,_180){
if(_2.isFunction(url)){
return this.bind("load",url);
}
var off=url.indexOf(" ");
if(off>=0){
var _182=url.slice(off,url.length);
url=url.slice(0,off);
}
_180=_180||function(){
};
var type="GET";
if(_17f){
if(_2.isFunction(_17f)){
_180=_17f;
_17f=null;
}else{
_17f=_2.param(_17f);
type="POST";
}
}
var self=this;
_2.ajax({url:url,type:type,dataType:"html",data:_17f,complete:function(res,_186){
if(_186=="success"||_186=="notmodified"){
self.html(_182?_2("<div/>").append(res.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(_182):res.responseText);
}
self.each(_180,[res.responseText,_186,res]);
}});
return this;
},serialize:function(){
return _2.param(this.serializeArray());
},serializeArray:function(){
return this.map(function(){
return _2.nodeName(this,"form")?_2.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=_2(this).val();
return val==null?null:val.constructor==Array?_2.map(val,function(val,i){
return {name:elem.name,value:val};
}):{name:elem.name,value:val};
}).get();
}});
_2.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(i,o){
_2.fn[o]=function(f){
return this.bind(o,f);
};
});
var jsc=(new Date).getTime();
_2.extend({get:function(url,data,_192,type){
if(_2.isFunction(data)){
_192=data;
data=null;
}
return _2.ajax({type:"GET",url:url,data:data,success:_192,dataType:type});
},getScript:function(url,_195){
return _2.get(url,null,_195,"script");
},getJSON:function(url,data,_198){
return _2.get(url,data,_198,"json");
},post:function(url,data,_19b,type){
if(_2.isFunction(data)){
_19b=data;
data={};
}
return _2.ajax({type:"POST",url:url,data:data,success:_19b,dataType:type});
},ajaxSetup:function(_19d){
_2.extend(_2.ajaxSettings,_19d);
},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 _19f,jsre=/=\?(&|$)/g,_1a1,data;
s=_2.extend(true,s,_2.extend(true,{},_2.ajaxSettings,s));
if(s.data&&s.processData&&typeof s.data!="string"){
s.data=_2.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))){
_19f="jsonp"+jsc++;
if(s.data){
s.data=(s.data+"").replace(jsre,"="+_19f+"$1");
}
s.url=s.url.replace(jsre,"="+_19f+"$1");
s.dataType="script";
window[_19f]=function(tmp){
data=tmp;
success();
complete();
window[_19f]=undefined;
try{
delete window[_19f];
}
catch(e){
}
if(head){
head.removeChild(_1a5);
}
};
}
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&&!_2.active++){
_2.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 _1a5=document.createElement("script");
_1a5.src=s.url;
if(s.scriptCharset){
_1a5.charset=s.scriptCharset;
}
if(!_19f){
var done=false;
_1a5.onload=_1a5.onreadystatechange=function(){
if(!done&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){
done=true;
success();
complete();
head.removeChild(_1a5);
}
};
}
head.appendChild(_1a5);
return undefined;
}
var _1a9=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",_2.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){
_2.event.trigger("ajaxSend",[xml,s]);
}
var _1ab=function(_1ac){
if(!_1a9&&xml&&(xml.readyState==4||_1ac=="timeout")){
_1a9=true;
if(ival){
clearInterval(ival);
ival=null;
}
_1a1=_1ac=="timeout"&&"timeout"||!_2.httpSuccess(xml)&&"error"||s.ifModified&&_2.httpNotModified(xml,s.url)&&"notmodified"||"success";
if(_1a1=="success"){
try{
data=_2.httpData(xml,s.dataType);
}
catch(e){
_1a1="parsererror";
}
}
if(_1a1=="success"){
var _1ae;
try{
_1ae=xml.getResponseHeader("Last-Modified");
}
catch(e){
}
if(s.ifModified&&_1ae){
_2.lastModified[s.url]=_1ae;
}
if(!_19f){
success();
}
}else{
_2.handleError(s,xml,_1a1);
}
complete();
if(s.async){
xml=null;
}
}
};
if(s.async){
var ival=setInterval(_1ab,13);
if(s.timeout>0){
setTimeout(function(){
if(xml){
xml.abort();
if(!_1a9){
_1ab("timeout");
}
}
},s.timeout);
}
}
try{
xml.send(s.data);
}
catch(e){
_2.handleError(s,xml,null,e);
}
if(!s.async){
_1ab();
}
function success(){
if(s.success){
s.success(data,_1a1);
}
if(s.global){
_2.event.trigger("ajaxSuccess",[xml,s]);
}
}
function complete(){
if(s.complete){
s.complete(xml,_1a1);
}
if(s.global){
_2.event.trigger("ajaxComplete",[xml,s]);
}
if(s.global&&!--_2.active){
_2.event.trigger("ajaxStop");
}
}
return xml;
},handleError:function(s,xml,_1b1,e){
if(s.error){
s.error(xml,_1b1,e);
}
if(s.global){
_2.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||_2.browser.safari&&r.status==undefined;
}
catch(e){
}
return false;
},httpNotModified:function(xml,url){
try{
var _1b6=xml.getResponseHeader("Last-Modified");
return xml.status==304||_1b6==_2.lastModified[url]||_2.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"){
_2.globalEval(data);
}
if(type=="json"){
data=eval("("+data+")");
}
return data;
},param:function(a){
var s=[];
if(a.constructor==Array||a.jquery){
_2.each(a,function(){
s.push(encodeURIComponent(this.name)+"="+encodeURIComponent(this.value));
});
}else{
for(var j in a){
if(a[j]&&a[j].constructor==Array){
_2.each(a[j],function(){
s.push(encodeURIComponent(j)+"="+encodeURIComponent(this));
});
}else{
s.push(encodeURIComponent(j)+"="+encodeURIComponent(a[j]));
}
}
}
return s.join("&").replace(/%20/g,"+");
}});
_2.fn.extend({show:function(_1bf,_1c0){
return _1bf?this.animate({height:"show",width:"show",opacity:"show"},_1bf,_1c0):this.filter(":hidden").each(function(){
this.style.display=this.oldblock||"";
if(_2.css(this,"display")=="none"){
var elem=_2("<"+this.tagName+" />").appendTo("body");
this.style.display=elem.css("display");
if(this.style.display=="none"){
this.style.display="block";
}
elem.remove();
}
}).end();
},hide:function(_1c2,_1c3){
return _1c2?this.animate({height:"hide",width:"hide",opacity:"hide"},_1c2,_1c3):this.filter(":visible").each(function(){
this.oldblock=this.oldblock||_2.css(this,"display");
this.style.display="none";
}).end();
},_toggle:_2.fn.toggle,toggle:function(fn,fn2){
return _2.isFunction(fn)&&_2.isFunction(fn2)?this._toggle(fn,fn2):fn?this.animate({height:"toggle",width:"toggle",opacity:"toggle"},fn,fn2):this.each(function(){
_2(this)[_2(this).is(":hidden")?"show":"hide"]();
});
},slideDown:function(_1c6,_1c7){
return this.animate({height:"show"},_1c6,_1c7);
},slideUp:function(_1c8,_1c9){
return this.animate({height:"hide"},_1c8,_1c9);
},slideToggle:function(_1ca,_1cb){
return this.animate({height:"toggle"},_1ca,_1cb);
},fadeIn:function(_1cc,_1cd){
return this.animate({opacity:"show"},_1cc,_1cd);
},fadeOut:function(_1ce,_1cf){
return this.animate({opacity:"hide"},_1ce,_1cf);
},fadeTo:function(_1d0,to,_1d2){
return this.animate({opacity:to},_1d0,_1d2);
},animate:function(prop,_1d4,_1d5,_1d6){
var _1d7=_2.speed(_1d4,_1d5,_1d6);
return this[_1d7.queue===false?"each":"queue"](function(){
if(this.nodeType!=1){
return false;
}
var opt=_2.extend({},_1d7);
var _1d9=_2(this).is(":hidden"),self=this;
for(var p in prop){
if(prop[p]=="hide"&&_1d9||prop[p]=="show"&&!_1d9){
return _2.isFunction(opt.complete)&&opt.complete.apply(this);
}
if(p=="height"||p=="width"){
opt.display=_2.css(this,"display");
opt.overflow=this.style.overflow;
}
}
if(opt.overflow!=null){
this.style.overflow="hidden";
}
opt.curAnim=_2.extend({},prop);
_2.each(prop,function(name,val){
var e=new _2.fx(self,opt,name);
if(/toggle|show|hide/.test(val)){
e[val=="toggle"?_1d9?"show":"hide":val](prop);
}else{
var _1df=val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),_1e0=e.cur(true)||0;
if(_1df){
var end=parseFloat(_1df[2]),unit=_1df[3]||"px";
if(unit!="px"){
self.style[name]=(end||1)+unit;
_1e0=((end||1)/e.cur(true))*_1e0;
self.style[name]=_1e0+unit;
}
if(_1df[1]){
end=((_1df[1]=="-="?-1:1)*end)+_1e0;
}
e.custom(_1e0,end,unit);
}else{
e.custom(_1e0,val,"");
}
}
});
return true;
});
},queue:function(type,fn){
if(_2.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){
_1e5(this,type,fn);
}else{
_1e5(this,type).push(fn);
if(_1e5(this,type).length==1){
fn.apply(this);
}
}
});
},stop:function(_1e6,_1e7){
var _1e8=_2.timers;
if(_1e6){
this.queue([]);
}
this.each(function(){
for(var i=_1e8.length-1;i>=0;i--){
if(_1e8[i].elem==this){
if(_1e7){
_1e8[i](true);
}
_1e8.splice(i,1);
}
}
});
if(!_1e7){
this.dequeue();
}
return this;
}});
var _1e5=function(elem,type,_1ec){
if(!elem){
return undefined;
}
type=type||"fx";
var q=_2.data(elem,type+"queue");
if(!q||_1ec){
q=_2.data(elem,type+"queue",_1ec?_2.makeArray(_1ec):[]);
}
return q;
};
_2.fn.dequeue=function(type){
type=type||"fx";
return this.each(function(){
var q=_1e5(this,type);
q.shift();
if(q.length){
q[0].apply(this);
}
});
};
_2.extend({speed:function(_1f0,_1f1,fn){
var opt=_1f0&&_1f0.constructor==Object?_1f0:{complete:fn||!fn&&_1f1||_2.isFunction(_1f0)&&_1f0,duration:_1f0,easing:fn&&_1f1||_1f1&&_1f1.constructor!=Function&&_1f1};
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){
_2(this).dequeue();
}
if(_2.isFunction(opt.old)){
opt.old.apply(this);
}
};
return opt;
},easing:{linear:function(p,n,_1f6,diff){
return _1f6+diff*p;
},swing:function(p,n,_1fa,diff){
return ((-Math.cos(p*Math.PI)/2)+0.5)*diff+_1fa;
}},timers:[],timerId:null,fx:function(elem,_1fd,prop){
this.options=_1fd;
this.elem=elem;
this.prop=prop;
if(!_1fd.orig){
_1fd.orig={};
}
}});
_2.fx.prototype={update:function(){
if(this.options.step){
this.options.step.apply(this.elem,[this.now,this]);
}
(_2.fx.step[this.prop]||_2.fx.step._default)(this);
if(this.prop=="height"||this.prop=="width"){
this.elem.style.display="block";
}
},cur:function(_1ff){
if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null){
return this.elem[this.prop];
}
var r=parseFloat(_2.css(this.elem,this.prop,_1ff));
return r&&r>-10000?r:parseFloat(_2.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(_205){
return self.step(_205);
}
t.elem=this.elem;
_2.timers.push(t);
if(_2.timerId==null){
_2.timerId=setInterval(function(){
var _206=_2.timers;
for(var i=0;i<_206.length;i++){
if(!_206[i]()){
_206.splice(i--,1);
}
}
if(!_206.length){
clearInterval(_2.timerId);
_2.timerId=null;
}
},13);
}
},show:function(){
this.options.orig[this.prop]=_2.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";
}
_2(this.elem).show();
},hide:function(){
this.options.orig[this.prop]=_2.attr(this.elem.style,this.prop);
this.options.hide=true;
this.custom(this.cur(),0);
},step:function(_208){
var t=(new Date()).getTime();
if(_208||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(_2.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){
_2.attr(this.elem.style,p,this.options.orig[p]);
}
}
}
if(done&&_2.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=_2.easing[this.options.easing||(_2.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;
}};
_2.fx.step={scrollLeft:function(fx){
fx.elem.scrollLeft=fx.now;
},scrollTop:function(fx){
fx.elem.scrollTop=fx.now;
},opacity:function(fx){
_2.attr(fx.elem.style,"opacity",fx.now);
},_default:function(fx){
fx.elem.style[fx.prop]=fx.now+fx.unit;
}};
_2.fn.offset=function(){
var left=0,top=0,elem=this[0],_215;
if(elem){
with(_2.browser){
var _216=elem.parentNode,_217=elem,_218=elem.offsetParent,doc=elem.ownerDocument,_21a=safari&&parseInt(version)<522,_21b=_2.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(_218){
add(_218.offsetLeft,_218.offsetTop);
if(mozilla&&!/^t(able|d|h)$/i.test(_218.tagName)||safari&&!_21a){
border(_218);
}
if(!_21b&&_2.css(_218,"position")=="fixed"){
_21b=true;
}
_217=/^body$/i.test(_218.tagName)?_217:_218;
_218=_218.offsetParent;
}
while(_216&&_216.tagName&&!/^body|html$/i.test(_216.tagName)){
if(!/^inline|table.*$/i.test(_2.css(_216,"display"))){
add(-_216.scrollLeft,-_216.scrollTop);
}
if(mozilla&&_2.css(_216,"overflow")!="visible"){
border(_216);
}
_216=_216.parentNode;
}
if((_21a&&(_21b||_2.css(_217,"position")=="absolute"))||(mozilla&&_2.css(_217,"position")!="absolute")){
add(-doc.body.offsetLeft,-doc.body.offsetTop);
}
if(_21b){
add(Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft),Math.max(doc.documentElement.scrollTop,doc.body.scrollTop));
}
}
_215={top:top,left:left};
}
}
function border(elem){
add(_2.curCSS(elem,"borderLeftWidth",true),_2.curCSS(elem,"borderTopWidth",true));
}
function add(l,t){
left+=parseInt(l)||0;
top+=parseInt(t)||0;
}
return _215;
};
})();
(function($){
$.fn.hoverIntent=function(f,g){
var cfg={sensitivity:7,interval:100,timeout:0};
cfg=$.extend(cfg,g?{over:f,out:g}:f);
var cX,cY,pX,pY;
var _228=function(ev){
cX=ev.pageX;
cY=ev.pageY;
};
var _22a=function(ev,ob){
ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);
if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){
$(ob).unbind("mousemove",_228);
ob.hoverIntent_s=1;
return cfg.over.apply(ob,[ev]);
}else{
pX=cX;
pY=cY;
ob.hoverIntent_t=setTimeout(function(){
_22a(ev,ob);
},cfg.interval);
}
};
var _22d=function(ev,ob){
ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);
ob.hoverIntent_s=0;
return cfg.out.apply(ob,[ev]);
};
var _230=function(e){
var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;
while(p&&p!=this){
try{
p=p.parentNode;
}
catch(e){
p=this;
}
}
if(p==this){
return false;
}
var ev=jQuery.extend({},e);
var ob=this;
if(ob.hoverIntent_t){
ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);
}
if(e.type=="mouseover"){
pX=ev.pageX;
pY=ev.pageY;
$(ob).bind("mousemove",_228);
if(ob.hoverIntent_s!=1){
ob.hoverIntent_t=setTimeout(function(){
_22a(ev,ob);
},cfg.interval);
}
}else{
$(ob).unbind("mousemove",_228);
if(ob.hoverIntent_s==1){
ob.hoverIntent_t=setTimeout(function(){
_22d(ev,ob);
},cfg.timeout);
}
}
};
return this.mouseover(_230).mouseout(_230);
};
})(jQuery);
(function($){
var _236=false;
var _237=null;
var _238={};
var _239={};
var _23a={};
var _23b={};
var _23c;
var _23d;
var _23e;
var _23f;
var _240={};
$.getMousePosition=function(e){
var posx=0;
var posy=0;
if(!e){
var e=window.event;
}
if(e.pageX||e.pageY){
posx=e.pageX;
posy=e.pageY;
}else{
if(e.clientX||e.clientY){
posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
posy=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
}
}
return {"x":posx,"y":posy};
};
$.updatePosition=function(e){
var pos=$.getMousePosition(e);
var _246=(pos.x-_23c);
var _247=(pos.y-_23d);
$(_237).css("top",(_23e+_247));
$(_237).css("left",(_23f+_246));
};
$(document).mousemove(function(e){
if(_236&&_240[_237.id]=="on"){
$.updatePosition(e);
if(_239[_237.id]!=undefined){
_239[_237.id](e,_237);
}
return false;
}
});
$(document).mouseup(function(e){
if(_236&&_240[_237.id]=="on"){
_236=false;
if(_238[_237.id]!=undefined){
_238[_237.id](e,_237);
}
return false;
}
});
$.fn.ondrag=function(_24a){
return this.each(function(){
_239[this.id]=_24a;
});
};
$.fn.ondrop=function(_24b){
return this.each(function(){
_238[this.id]=_24b;
});
};
$.fn.ondragstart=function(_24c){
return this.each(function(){
_23a[this.id]=_24c;
});
};
$.fn.dragOff=function(){
return this.each(function(){
_240[this.id]="off";
$(this).css("cursor","default");
});
};
$.fn.dragOn=function(){
return this.each(function(){
_240[this.id]="on";
$(this).css("cursor","pointer");
});
};
$.fn.easydrag=function(_24d){
return this.each(function(){
if(undefined==this.id||!this.id.length){
this.id="easydrag"+(new Date().getTime());
}
_240[this.id]="on";
$(this).css("cursor","pointer");
$(this).mousedown(function(e){
if(_240[this.id]!="on"){
return false;
}
$(this).css("position","absolute");
$(this).css("z-index","10000");
if(_23a[this.id]!=undefined){
_23a[this.id](e,this);
}
_236=true;
_237=this;
var pos=$.getMousePosition(e);
_23c=pos.x;
_23d=pos.y;
_23e=this.offsetTop;
_23f=this.offsetLeft;
$.updatePosition(e);
return _24d?true:false;
});
});
};
})(jQuery);
jQuery.fn.farbtastic=function(_250){
$.farbtastic(this,_250);
return this;
};
jQuery.farbtastic=function(_251,_252){
var _251=$(_251).get(0);
return _251.farbtastic||(_251.farbtastic=new jQuery._farbtastic(_251,_252));
};
jQuery._farbtastic=function(_253,_254){
var fb=this;
$(_253).html("<div class=\"farbtastic\"><div class=\"color\"></div><div class=\"wheel\"></div><div class=\"overlay\"></div><div class=\"h-marker marker\"></div><div class=\"sl-marker marker\"></div></div>");
var e=$(".farbtastic",_253);
fb.wheel=$(".wheel",_253).get(0);
fb.radius=42;
fb.square=50;
fb.width=97;
if(navigator.appVersion.match(/MSIE [0-6]\./)){
$("*",e).each(function(){
if(this.currentStyle.backgroundImage!="none"){
var _257=this.currentStyle.backgroundImage;
_257=this.currentStyle.backgroundImage.substring(5,_257.length-2);
$(this).css({"backgroundImage":"none","filter":"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+_257+"')"});
}
});
}
fb.linkTo=function(_258){
if(typeof fb.callback=="object"){
$(fb.callback).unbind("keyup",fb.updateValue);
}
fb.color=null;
if(typeof _258=="function"){
fb.callback=_258;
}else{
if(typeof _258=="object"||typeof _258=="string"){
fb.callback=$(_258);
fb.callback.bind("keyup",fb.updateValue);
if(fb.callback.get(0).value){
fb.setColor(fb.callback.get(0).value);
}
}
}
return this;
};
fb.updateValue=function(_259){
if(this.value&&this.value!=fb.color){
fb.setColor(this.value);
}
};
fb.setColor=function(_25a){
var _25b=fb.unpack(_25a);
if(fb.color!=_25a&&_25b){
fb.color=_25a;
fb.rgb=_25b;
fb.hsl=fb.RGBToHSL(fb.rgb);
fb.updateDisplay();
}
return this;
};
fb.setHSL=function(hsl){
fb.hsl=hsl;
fb.rgb=fb.HSLToRGB(hsl);
fb.color=fb.pack(fb.rgb);
fb.updateDisplay();
return this;
};
fb.widgetCoords=function(_25d){
var x,y;
var el=_25d.target||_25d.srcElement;
var _261=fb.wheel;
if(typeof _25d.offsetX!="undefined"){
var pos={x:_25d.offsetX,y:_25d.offsetY};
var e=el;
while(e){
e.mouseX=pos.x;
e.mouseY=pos.y;
pos.x+=e.offsetLeft;
pos.y+=e.offsetTop;
e=e.offsetParent;
}
var e=_261;
var _264={x:0,y:0};
while(e){
if(typeof e.mouseX!="undefined"){
x=e.mouseX-_264.x;
y=e.mouseY-_264.y;
break;
}
_264.x+=e.offsetLeft;
_264.y+=e.offsetTop;
e=e.offsetParent;
}
e=el;
while(e){
e.mouseX=undefined;
e.mouseY=undefined;
e=e.offsetParent;
}
}else{
var pos=fb.absolutePosition(_261);
x=(_25d.pageX||0*(_25d.clientX+$("html").get(0).scrollLeft))-pos.x;
y=(_25d.pageY||0*(_25d.clientY+$("html").get(0).scrollTop))-pos.y;
}
return {x:x-fb.width/2,y:y-fb.width/2};
};
fb.mousedown=function(_265){
if(!document.dragging){
$(document).bind("mousemove",fb.mousemove).bind("mouseup",fb.mouseup);
document.dragging=true;
}
var pos=fb.widgetCoords(_265);
fb.circleDrag=Math.max(Math.abs(pos.x),Math.abs(pos.y))*2>fb.square;
fb.mousemove(_265);
return false;
};
fb.mousemove=function(_267){
var pos=fb.widgetCoords(_267);
if(fb.circleDrag){
var hue=Math.atan2(pos.x,-pos.y)/6.28;
if(hue<0){
hue+=1;
}
fb.setHSL([hue,fb.hsl[1],fb.hsl[2]]);
}else{
var sat=Math.max(0,Math.min(1,-(pos.x/fb.square)+0.5));
var lum=Math.max(0,Math.min(1,-(pos.y/fb.square)+0.5));
fb.setHSL([fb.hsl[0],sat,lum]);
}
return false;
};
fb.mouseup=function(){
$(document).unbind("mousemove",fb.mousemove);
$(document).unbind("mouseup",fb.mouseup);
document.dragging=false;
};
fb.updateDisplay=function(){
var _26c=fb.hsl[0]*6.28;
$(".h-marker",e).css({left:Math.round(Math.sin(_26c)*fb.radius+fb.width/2)+"px",top:Math.round(-Math.cos(_26c)*fb.radius+fb.width/2)+"px"});
$(".sl-marker",e).css({left:Math.round(fb.square*(0.5-fb.hsl[1])+fb.width/2)+"px",top:Math.round(fb.square*(0.5-fb.hsl[2])+fb.width/2)+"px"});
$(".color",e).css("backgroundColor",fb.pack(fb.HSLToRGB([fb.hsl[0],1,0.5])));
if(typeof fb.callback=="object"){
$(fb.callback).css({backgroundColor:fb.color,color:fb.hsl[2]>0.5?"#000":"#fff"});
$(fb.callback).each(function(){
if(this.value&&this.value!=fb.color){
this.value=fb.color;
}
});
}else{
if(typeof fb.callback=="function"){
fb.callback.call(fb,fb.color);
}
}
};
fb.absolutePosition=function(el){
var r={x:el.offsetLeft,y:el.offsetTop};
if(el.offsetParent){
var tmp=fb.absolutePosition(el.offsetParent);
r.x+=tmp.x;
r.y+=tmp.y;
}
return r;
};
fb.pack=function(rgb){
var r=Math.round(rgb[0]*255);
var g=Math.round(rgb[1]*255);
var b=Math.round(rgb[2]*255);
return "#"+(r<16?"0":"")+r.toString(16)+(g<16?"0":"")+g.toString(16)+(b<16?"0":"")+b.toString(16);
};
fb.unpack=function(_274){
if(_274.length==7){
return [parseInt("0x"+_274.substring(1,3))/255,parseInt("0x"+_274.substring(3,5))/255,parseInt("0x"+_274.substring(5,7))/255];
}else{
if(_274.length==4){
return [parseInt("0x"+_274.substring(1,2))/15,parseInt("0x"+_274.substring(2,3))/15,parseInt("0x"+_274.substring(3,4))/15];
}
}
};
fb.HSLToRGB=function(hsl){
var m1,m2,r,g,b;
var h=hsl[0],s=hsl[1],l=hsl[2];
m2=(l<=0.5)?l*(s+1):l+s-l*s;
m1=l*2-m2;
return [this.hueToRGB(m1,m2,h+0.33333),this.hueToRGB(m1,m2,h),this.hueToRGB(m1,m2,h-0.33333)];
};
fb.hueToRGB=function(m1,m2,h){
h=(h<0)?h+1:((h>1)?h-1:h);
if(h*6<1){
return m1+(m2-m1)*h*6;
}
if(h*2<1){
return m2;
}
if(h*3<2){
return m1+(m2-m1)*(0.66666-h)*6;
}
return m1;
};
fb.RGBToHSL=function(rgb){
var min,max,_284,h,s,l;
var r=rgb[0],g=rgb[1],b=rgb[2];
min=Math.min(r,Math.min(g,b));
max=Math.max(r,Math.max(g,b));
_284=max-min;
l=(min+max)/2;
s=0;
if(l>0&&l<1){
s=_284/(l<0.5?(2*l):(2-2*l));
}
h=0;
if(_284>0){
if(max==r&&max!=g){
h+=(g-b)/_284;
}
if(max==g&&max!=b){
h+=(2+(b-r)/_284);
}
if(max==b&&max!=r){
h+=(4+(r-g)/_284);
}
h/=6;
}
return [h,s,l];
};
$("*",e).mousedown(fb.mousedown);
fb.setColor("#000000");
if(_254){
fb.linkTo(_254);
}
};
var Juggernaut={debug:true,verbose_debug:false,isIE:/Microsoft/i.test(navigator.appName),hasFirebug:"console" in window&&"firebug" in window.console&&window.console.firebug.indexOf("1.0")>-1,logFunc:function(msg){
Juggernaut.hasFirebug?console.log("Juggernaut: "+msg):window.alert("Juggernaut: "+msg);
},listenToChannels:function(_28c){
Juggernaut._setupOptions(_28c);
Event.observe(window,"load",function(){
Juggernaut._appendFlashObject();
});
},receiveData:function(data){
if(Juggernaut.base64){
var _28e=Juggernaut._decode64(data);
Juggernaut._verbose_log("Received data:\n"+_28e);
eval(Juggernaut._utf8to16(_28e));
}else{
Juggernaut._verbose_log("Received data:\n"+data);
eval(data);
}
},connected:function(){
Juggernaut._verbose_log("You have been connected");
},errorConnecting:function(){
Juggernaut._log("There has been an error connection, please check the push server and make sure your firewall has the correct ports open");
},disconnected:function(){
Juggernaut._log("Connection has been lost. Please log out and log back in for chat and collaborative functionality.");
},_setupOptions:function(_28f){
Juggernaut.host=_28f["host"]||"localhost";
Juggernaut.port=_28f["port"]||443;
Juggernaut.ses_id=_28f["ses_id"];
Juggernaut.num_tries=_28f["num_tries"];
Juggernaut.num_secs=_28f["num_secs"];
Juggernaut.unique_id=_28f["unique_id"]||null;
Juggernaut.base64=_28f["base64"]||false;
var data="";
if(_28f["channel"]){
data="\""+_28f["channel"]+"\"";
}else{
if(_28f["channels"]){
data=_28f["channels"].map(function(c){
return "\""+c+"\"";
}).join(",");
}
}
Juggernaut.channels=encodeURIComponent(data);
},_appendFlashObject:function(){
var so=new SWFObject("/juggernaut.swf","juggernaut_flash","1","1","8","#ffffff");
so.useExpressInstall("/expressinstall.swf");
so.addVariable("host",Juggernaut.host);
so.addVariable("port",Juggernaut.port);
so.addVariable("channels",Juggernaut.channels);
so.addVariable("ses_id",Juggernaut.ses_id);
so.addVariable("num_tries",Juggernaut.num_tries);
so.addVariable("num_secs",Juggernaut.num_secs);
so.addVariable("unique_id",Juggernaut.unique_id);
so.write("flashcontent");
},_log:function(msg){
if(Juggernaut.debug){
Juggernaut.logFunc(msg);
}
},_verbose_log:function(msg){
if(Juggernaut.verbose_debug){
Juggernaut.logFunc(msg);
}
},_decode64:function(_295){
var _296="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var _297="";
var chr1,chr2,chr3;
var enc1,enc2,enc3,enc4;
var i=0;
_295=_295.replace(/[^A-Za-z0-9\+\/\=]/g,"");
do{
enc1=_296.indexOf(_295.charAt(i++));
enc2=_296.indexOf(_295.charAt(i++));
enc3=_296.indexOf(_295.charAt(i++));
enc4=_296.indexOf(_295.charAt(i++));
chr1=(enc1<<2)|(enc2>>4);
chr2=((enc2&15)<<4)|(enc3>>2);
chr3=((enc3&3)<<6)|enc4;
_297=_297+String.fromCharCode(chr1);
if(enc3!=64){
_297=_297+String.fromCharCode(chr2);
}
if(enc4!=64){
_297=_297+String.fromCharCode(chr3);
}
}while(i<_295.length);
return _297;
},_utf8to16:function(str){
var out,i,len,c;
var _2a5,_2a6;
out="";
len=str.length;
i=0;
while(i<len){
c=str.charCodeAt(i++);
switch(c>>4){
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
out+=str.charAt(i-1);
break;
case 12:
case 13:
_2a5=str.charCodeAt(i++);
out+=String.fromCharCode(((c&31)<<6)|(_2a5&63));
break;
case 14:
_2a5=str.charCodeAt(i++);
_2a6=str.charCodeAt(i++);
out+=String.fromCharCode(((c&15)<<12)|((_2a5&63)<<6)|((_2a6&63)<<0));
break;
}
}
return out;
}};
function receiveData(d){
Juggernaut.receiveData(d);
}
(function(){
var $$;
$$=jQuery.fn.flash=function(_2a9,_2aa,_2ab,_2ac){
var _2ad=_2ab||$$.replace;
_2aa=$$.copy($$.pluginOptions,_2aa);
if(!$$.hasFlash(_2aa.version)){
if(_2aa.expressInstall&&$$.hasFlash(6,0,65)){
var _2ae={flashvars:{MMredirectURL:location,MMplayerType:"PlugIn",MMdoctitle:jQuery("title").text()}};
}else{
if(_2aa.update){
_2ad=_2ac||$$.update;
}else{
return this;
}
}
}
_2a9=$$.copy($$.htmlOptions,_2ae,_2a9);
return this.each(function(){
_2ad.call(this,$$.copy(_2a9));
});
};
$$.copy=function(){
var _2af={},_2b0={};
for(var i=0;i<arguments.length;i++){
var arg=arguments[i];
if(arg==undefined){
continue;
}
jQuery.extend(_2af,arg);
if(arg.flashvars==undefined){
continue;
}
jQuery.extend(_2b0,arg.flashvars);
}
_2af.flashvars=_2b0;
return _2af;
};
$$.hasFlash=function(){
if(/hasFlash\=true/.test(location)){
return true;
}
if(/hasFlash\=false/.test(location)){
return false;
}
var pv=$$.hasFlash.playerVersion().match(/\d+/g);
var rv=String([arguments[0],arguments[1],arguments[2]]).match(/\d+/g)||String($$.pluginOptions.version).match(/\d+/g);
for(var i=0;i<3;i++){
pv[i]=parseInt(pv[i]||0);
rv[i]=parseInt(rv[i]||0);
if(pv[i]<rv[i]){
return false;
}
if(pv[i]>rv[i]){
return true;
}
}
return true;
};
$$.hasFlash.playerVersion=function(){
try{
try{
var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
try{
axo.AllowScriptAccess="always";
}
catch(e){
return "6,0,0";
}
}
catch(e){
}
return new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").replace(/\D+/g,",").match(/^,?(.+),?$/)[1];
}
catch(e){
try{
if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
return (navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g,",").match(/^,?(.+),?$/)[1];
}
}
catch(e){
}
}
return "0,0,0";
};
$$.htmlOptions={height:240,flashvars:{},pluginspage:"http://www.adobe.com/go/getflashplayer",src:"#",type:"application/x-shockwave-flash",width:320};
$$.pluginOptions={expressInstall:false,update:true,version:"6.0.65"};
$$.replace=function(_2b7){
this.innerHTML="<div class=\"alt\">"+this.innerHTML+"</div>";
jQuery(this).addClass("flash-replaced").prepend($$.transform(_2b7));
};
$$.update=function(_2b8){
var url=String(location).split("?");
url.splice(1,0,"?hasFlash=true&");
url=url.join("");
var msg="<p>This content requires the Flash Player 8 or above. <a href=\"http://www.adobe.com/go/getflashplayer\">Download Flash Player</a>. Already have Flash Player? <a href=\""+url+"\">Click here.</a></p>";
this.innerHTML="<span class=\"alt\">"+this.innerHTML+"</span>";
jQuery(this).addClass("flash-update").prepend(msg);
};
function toAttributeString(){
var s="";
for(var key in this){
if(typeof this[key]!="function"){
s+=key+"=\""+this[key]+"\" ";
}
}
return s;
}
function toFlashvarsString(){
var s="";
for(var key in this){
if(typeof this[key]!="function"){
s+=key+"="+encodeURIComponent(this[key])+"&";
}
}
return s.replace(/&$/,"");
}
$$.transform=function(_2bf){
_2bf.toString=toAttributeString;
if(_2bf.flashvars){
_2bf.flashvars.toString=toFlashvarsString;
}
return "<embed "+String(_2bf)+"/>";
};
if(window.attachEvent){
window.attachEvent("onbeforeunload",function(){
__flash_unloadHandler=function(){
};
__flash_savedUnloadHandler=function(){
};
});
}
})();
(function($){
var hack={ltie7:$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),pixel:"/images/pixel.gif",filter:function(src){
return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+src+"')";
}};
$.fn.pngfix=hack.ltie7?function(){
return this.each(function(){
var $$=$(this);
if($$.is("img")){
$$.css({filter:hack.filter($$.attr("src")),width:$$.width(),height:$$.height()}).attr({src:hack.pixel}).positionFix();
}else{
var _2c4=$$.css("backgroundImage");
if(_2c4.match(/^url\(["']*(.*\.png)["']*\)$/i)){
_2c4=RegExp.$1;
$$.css({backgroundImage:"none",filter:hack.filter(_2c4)}).positionFix();
}
}
});
}:function(){
return this;
};
$.fn.pngunfix=hack.ltie7?function(){
return this.each(function(){
var $$=$(this);
var src=$$.css("filter");
if(src.match(/src=["'](.*\.png)["']/i)){
src=RegExp.$1;
if($$.is("img")){
$$.attr({src:src}).css({filter:""});
}else{
$$.css({filter:"",background:"url("+src+")"});
}
}
});
}:function(){
return this;
};
$.fn.positionFix=function(){
return this.each(function(){
var $$=$(this);
var _2c8=$$.css("position");
if(_2c8!="absolute"&&_2c8!="relative"){
$$.css({position:"relative"});
}
});
};
})(jQuery);
(function($){
$.fn.cornerz=function(_2ca){
function canvasCorner(t,l,r,bw,bc,bg){
var sa,ea,cw,sx,sy,x,y,p=1.57,css="position:absolute;";
if(t){
sa=-p;
sy=r;
y=0;
css+="top:-"+bw+"px;";
}else{
sa=p;
sy=0;
y=r;
css+="bottom:-"+bw+"px;";
}
if(l){
ea=p*2;
sx=r;
x=0;
css+="left:-"+bw+"px;";
}else{
ea=0;
sx=0;
x=r;
css+="right:-"+bw+"px;";
}
var _2da=$("<canvas width="+r+"px height="+r+"px style='"+css+"' ></canvas>");
var ctx=_2da[0].getContext("2d");
ctx.beginPath();
ctx.lineWidth=bw*2;
ctx.arc(sx,sy,r,sa,ea,!(t^l));
ctx.strokeStyle=bc;
ctx.stroke();
ctx.lineWidth=0;
ctx.lineTo(x,y);
ctx.fillStyle=bg;
ctx.fill();
return _2da;
}
function canvasCorners(_2dc,r,bw,bc,bg){
var hh=$("<div style='display: inherit' />");
$.each(_2dc.split(" "),function(){
hh.append(canvasCorner(this[0]=="t",this[1]=="l",r,bw,bc,bg));
});
return hh;
}
function vmlCurve(r,b,c,m,ml,mt,_2e8){
var l=m-ml-_2e8;
var t=m-mt;
return "<v:arc filled='False' strokeweight='"+b+"px' strokecolor='"+c+"' startangle='0' endangle='361' style=' top:"+t+"px;left: "+l+";width:"+r+"px; height:"+r+"px' />";
}
var _2eb={};
function vmlCorners(_2ec,r,bw,bc,bg){
var key=_2ec+r+"_"+bw+bc+bg;
_2eb[key]=_2eb[key]||_vmlCorners(_2ec,r,bw,bc,bg);
return _2eb[key];
}
function vmlCorners(_2f2,r,bw,bc,bg,w){
var h="<div style='text-align:left; '>";
$.each($.trim(_2f2).split(" "),function(){
var css,ml=1,mt=1,_2fc=0;
if(this.charAt(0)=="t"){
css="top:-"+bw+"px;";
}else{
css="bottom:-"+bw+"px;";
mt=r+1;
}
if(this.charAt(1)=="l"){
css+="left:-"+bw+"px;";
}else{
css+="right:-"+(bw)+"px; ";
ml=r;
_2fc=1;
}
h+="<div style='"+css+"; position: absolute; overflow:hidden; width:"+r+"px; height: "+r+"px;'>";
h+="<v:group  style='width:1000px;height:1000px;position:absolute;' coordsize='1000,1000' >";
h+=vmlCurve(r*3,r+bw,bg,-r/2,ml,mt,_2fc);
if(bw>0){
h+=vmlCurve(r*2-bw,bw,bc,bw/2,ml,mt,_2fc);
}
h+="</v:group>";
h+="</div>";
});
h+="</div>";
return h;
}
var _2fd={corners:"tl tr bl br",radius:10,background:"white",borderWidth:0};
$.extend(_2fd,_2ca||{});
return this.each(function(){
var $$=$(this);
var r=_2fd.radius*1;
var bw=(_2fd.borderWidth||parseInt($$.css("borderTopWidth"))||0)*1;
var bg=_2fd.background;
var bc=_2fd.borderColor;
bc=bc||(bw>0?$$.css("borderTopColor"):bg);
var cs=_2fd.corners;
if($.browser.msie){
this.innerHTML+=vmlCorners(cs,r,bw,bc,bg,$(this).width());
}else{
$(this).append(canvasCorners(cs,r,bw,bc,bg));
}
if(this.style.position!="absolute"){
this.style.position="relative";
}
this.style.zoom=1;
});
};
})(jQuery);
function insertPlayer(_304,_305){
var _306="/flash/singlemp3player.swf";
var _307="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
_307+="width=\"1\" height=\"1\" ";
_307+="codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab\">";
_307+="<param name=\"movie\" value=\""+_306+"?";
_307+="showDownload=false&file="+_304+"&autoStart=true";
_307+="&backColor=ffffff&frontColor=ffffff";
_307+="&repeatPlay=false&songVolume="+_305+"\" />";
_307+="<param name=\"wmode\" value=\"transparent\" />";
_307+="<embed wmode=\"transparent\" width=\"1\" height=\"1\" ";
_307+="src=\""+_306+"?";
_307+="showDownload=false&file="+_304+"&autoStart=true";
_307+="&backColor=ffffff&frontColor=ffffff";
_307+="&repeatPlay=false&songVolume="+_305+"\" ";
_307+="type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
_307+="</object>";
return _307;
}
function playSound(_308){
volume=UC?UC.volume:50;
$("#player_div").empty();
$("#player_div").prepend(insertPlayer(_308,volume));
}
(function($){
var _30a=null;
$.closeDropdownz=function(){
if(_30a){
$(_30a).hide().prev().removeClass("open");
}
_30a=null;
};
$.fn.dropdownz=function(){
$("html").click(function(){
$.closeDropdownz();
});
return this.each(function(){
$(this).find("a, .triangle").click(function(){
if($(this).attr("href")!=null){
return true;
}
o=$(this).parent().next();
$.closeDropdownz();
if(_30a&&o[0]==_30a[0]){
return;
}
$(this).parent().addClass("open");
pos=$(this).parent().find("a").offset();
o.css({top:pos.top+($(this).parent().find("a").height()),left:pos.left}).show();
_30a=o;
return false;
}).hover(function(){
$(this).addClass("hover");
},function(){
$(this).removeClass("hover");
});
});
};
})(jQuery);
(function($){
$.tabs=function(id,_30d){
var _30e="on";
var i=(typeof _30d=="number")?_30d-1:0;
$(id+">div:lt("+i+")").add(id+">div:gt("+i+")").hide();
$(id+">ul>li:nth-child("+i+")").addClass(_30e);
$(id+">ul>li>a").click(function(){
if(!$(this.parentNode).is("."+_30e)){
var re=/([_\-\w]+$)/i;
var _311=$("#"+re.exec(this.href)[1]);
if(_311.size()>0){
$(id+">div:visible").hide();
_311.show();
$(id+">ul>li").removeClass(_30e);
$(this.parentNode).addClass(_30e);
}else{
alert("There is no such container.");
}
}
return false;
}).focus(function(){
$(this).blur();
});
};
})(jQuery);
String.prototype.capitalize=function(){
return this.replace(/\w+/g,function(a){
return a.charAt(0).toUpperCase()+a.substr(1).toLowerCase();
});
};
String.prototype.titlize=function(){
return this.replace(/^\w+/,function(a){
return a.charAt(0).toUpperCase()+a.substr(1).toLowerCase();
});
};
parse_json=function(text){
try{
return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g,"")))&&eval("("+text+")");
}
catch(e){
return false;
}
};
navigateTo=function(url){
if(window.top==window.parent.top){
document.location.href=url;
}else{
window.parent.location.href=url;
}
};
link_to_game=function(game){
return "<a href='"+url_for_game(game)+"'>"+game.name.replace(/\+/g," ").capitalize()+"</a>";
};
url_for_game=function(game){
return "/games/show/"+game.id;
};
var TurnBullet="<span class=tbullet style='color:black'>\u25b6</span>";
link_to_user=function(user,turn){
if(typeof (user)=="string"){
return "<a href='/users/show_user/"+user+"' class=user>"+user.capitalize()+"</a>";
}else{
clss="";
clss=(user.online==1||user.id<0)?"logged_in":"logged_out";
href=(user.id>0)?"/users/show/"+user.id+"-"+user.name:"#";
return "<a user_id="+user.id+" href='"+href+"' class='user "+(clss)+"'>"+""+(turn?TurnBullet:"")+""+user.name.capitalize()+"</a>";
}
};
setGRA=function(){
if(UC&&GRA[0]){
html="";
count=0;
$.each(GRA,function(i,game){
clss=(game.attention_id==UC)?"active":"inactive";
html+="<li class='"+clss+"'>"+link_to_game(game)+"</li>";
if(game.attention_id==UC){
count+=1;
}
});
$("#in_play ul.dropdown").html(html);
$("#in_play_link").html("In Play ("+count+")").attr("href","/games/show/"+GRA[0].id);
}
};
gotoNextGame=function(){
games=$.grep(GRA,function(game){
return (game.attention_id==UC);
});
document.location.href=url_for_game(games[0]);
};
function isFunc(s){
try{
return (typeof (eval(s))=="function");
}
catch(e){
return false;
}
}
function delete_challenge(id){
$.ajax({type:"POST",url:"/challenges/destroy/"+id});
$("#challenge_"+id).fadeOut("slow");
}
function oppositeColor(_31f){
if(_31f=="w"){
return "b";
}else{
if(_31f=="b"){
return "w";
}else{
if(_31f=="white"){
return "black";
}else{
if(_31f=="black"){
return "white";
}else{
return _31f;
}
}
}
}
}
function convert2Challenge(id){
h="<table>";
h+="<tr><td class=tl></td><td class=tr></td></tr>";
h+="<tr><td class=bl></td><td class=br></td></tr>";
h+="</table>";
$(id).html(h);
setChallengeAppearence(id);
}
function setChallengeAppearence(id,_322){
$_id=$(id);
_322=jQuery.extend({challenger:$_id.attr("challenger"),black_square:$_id.attr("black_square"),playing_as:$_id.attr("playing_as"),piece_set:$_id.attr("piece_set")||"classic",size:$_id.attr("size")||"40"},_322||{});
$_id.attr("challenger",_322.challenger);
$_id.attr("black_square",_322.black_square);
$_id.attr("playing_as",_322.playing_as);
$_id.attr("piece_set",_322.piece_set);
$_id.attr("size",_322.size);
br_piece=_322.challenger=="true"?"q":"k";
tl_piece=_322.challenger=="true"?"k":"q";
br_color=_322.playing_as;
tl_color=oppositeColor(_322.playing_as);
$("#"+$_id[0].id+" td").css({width:(_322.size+"px"),height:(_322.size+"px")});
tl=new Piece(tl_piece,tl_color[0],"a1",false);
br=new Piece(br_piece,br_color[0],"a1",false);
$("#"+$_id[0].id+" .tl").html(tl.html(1,{size:_322.size,piece_set:_322.piece_set,css:"position: relative;"})).css({backgroundColor:_322.black_square});
$("#"+$_id[0].id+" .br").html(br.html(1,{size:_322.size,piece_set:_322.piece_set,css:"position: relative;"})).css({backgroundColor:_322.black_square});
}
if(!Array.prototype.map){
Array.prototype.map=function(fun){
var len=this.length;
if(typeof fun!="function"){
throw new TypeError();
}
var res=new Array(len);
var _326=arguments[1];
for(var i=0;i<len;i++){
if(i in this){
res[i]=fun.call(_326,this[i],i,this);
}
}
return res;
};
}
Juggernaut._appendFlashObject=function(){
$("#jug_flash").flash({src:"/juggernaut.swf",height:1,width:1},{version:8,expressInstall:true},function(_328){
$this=$(this);
_328.flashvars.host=Juggernaut.host;
_328.flashvars.port=Juggernaut.port;
_328.flashvars.channels=Juggernaut.channels;
_328.flashvars.ses_id=Juggernaut.ses_id;
_328.flashvars.num_tries=Juggernaut.num_tries;
_328.flashvars.num_secs=Juggernaut.num_secs;
_328.flashvars.unique_id=Juggernaut.unique_id;
_328.flashvars.crossdomain_url=Juggernaut.crossdomain_url;
$this.before($.fn.flash.transform(_328));
});
};
Juggernaut.listenToChannels=function(_329){
Juggernaut._setupOptions(_329);
window.onload=function(){
Juggernaut._appendFlashObject();
window_onload();
};
};
Juggernaut.errorConnecting=function(){
$("#connectivity").html("<a href=# onclick=\"javascript:location.href=location.href\">Refresh</a> to Update").fadeIn();
};
Juggernaut.disconnected=function(){
Juggernaut.errorConnecting();
};
Juggernaut.setFlashRunning=function(){
};
function sendMessage(txt){
txt=txt||$("#message_content").val();
if(txt==null||txt==""){
return false;
}
message={};
$.getScript("/conversations/send_message?comm_id="+chatRef+"&message="+txt);
$("#message_content").val("");
scroll2bottom();
return false;
}
function scroll2bottom(){
if($("#outer_box")){
obj=$("#outer_box")[0];
}
if(obj){
obj.scrollTop=obj.scrollHeight;
}
}
function receiveMessage(_32b){
$("#outer_box").append(_32b);
scroll2bottom();
}
function retrieveMessages(comm){
$.ajax({type:"GET",url:"/conversations/retrieve_messages?comm_id="+chatRef,dataType:"script",success:function(json){
x=parse_json(json);
receiveMessages(x);
}});
}
var last_chat_user=null;
function receiveMessages(_32e){
$.each(_32e,function(i){
message=_32e[i];
tit=message.t?get_local_time_for_date(message.t):"";
for(usr in message){
mess=message[usr];
if(usr!="t"){
s="style='color: "+word2color(usr)+"'";
html="<p "+s+" title='"+tit+"'>";
if(last_chat_user!=usr){
html+="<a "+s+" href='/users/show_user/"+usr+"' title='"+tit+"'><b>"+usr.capitalize()+":</b></a> ";
last_chat_user=usr;
html+=mess+"</p>";
}else{
html+="&nbsp;&nbsp;"+mess+"</p>";
}
$("#outer_box").append(html);
}
}
});
scroll2bottom();
}
function word2color(s){
col=parseInt(s.replace(/[\s_-]/g,""),26).toString(16).slice(0,6);
if(col.length<6){
col=col.charAt(0)+col.charAt(0)+col.charAt(1)+col.charAt(1)+col.charAt(2)+col.charAt(2);
}
i=parseInt(col.charAt(0)+col.charAt(1),16)+parseInt(col.charAt(2)+col.charAt(3),16)+parseInt(col.charAt(4)+col.charAt(5),16);
mid=parseInt("88",16)*3;
fff=parseInt("ffffff",16);
if(i>mid){
col=(fff-parseInt(col,16)).toString(16);
}
return "#"+col;
}
var FlashingTitle={hearbeat:null,title:null,orginal:document.title,period:7000,start:function(s){
if(s){
FlashingTitle["original"]=document.title;
FlashingTitle["title"]=s;
document.title=FlashingTitle["title"];
if(FlashingTitle["heartbeat"]){
clearInterval(FlashingTitle["heartbeat"]);
}
FlashingTitle["heartbeat"]=setInterval("FlashingTitle.toggle()",FlashingTitle["period"]);
}else{
FlashingTitle.stop();
}
},stop:function(){
document.title=FlashingTitle["original"]||document.title;
clearInterval(FlashingTitle["heartbeat"]);
},toggle:function(){
if(FlashingTitle["title"]==document.title){
document.title=FlashingTitle["original"];
}else{
document.title=FlashingTitle["title"];
}
}};
function show_dates_as_local_time(){
$("span.local_time").each(function(){
this.innerHTML=get_local_time_for_date(this.innerHTML);
});
}
function get_local_time_for_date(time,del){
del=(del==null)?0:del;
system_date=new Date(time);
user_date=new Date();
delta_minutes=Math.floor((user_date-system_date-(del*1000))/(60*1000));
if(Math.abs(delta_minutes)<=(8*7*24*60)){
distance=distance_of_time_in_words(delta_minutes);
if(!del){
return (delta_minutes<0)?"Just a moment ago":(distance+" ago");
}else{
return (delta_minutes<0)?(distance+" from now"):(distance+" ago");
}
}else{
date_string=system_date.toLocaleDateString();
if(date_string=="Invalid Date"){
return "";
}
return "on "+date_string;
}
}
function distance_of_time_in_words(_334){
if(_334.isNaN){
return "";
}
_334=Math.abs(_334);
if(_334<1){
return ("< 1 minute");
}
if(_334<50){
return (_334+" minute"+(_334==1?"":"s"));
}
if(_334<90){
return ("one hour");
}
if(_334<1080){
return (Math.round(_334/60)+" hours");
}
if(_334<1440){
return ("one day");
}
if(_334<2880){
return ("one day");
}else{
return (Math.round(_334/1440)+" days");
}
}
var notify_user=function(text){
img="<img id=notify_close src='/images/icons/cross.png' />";
$("#notify").html(img+text).fadeIn();
$("#notify_close").click(function(){
$("#notify").fadeOut();
});
};
var process_nudge=function(hash){
if(hash.from!=UC){
playSound("/mp3/beep.mp3");
}
user_link="<a href='/users/show/"+hash.from+"'>"+hash.from_name+"</a>";
game_link=link_to_game({id:hash.game_id,name:hash.game_name});
notify_user("reminder: "+game_link);
};
var process_challenge=function(hash){
if(hash.from!=UC){
playSound("/mp3/beep.mp3");
}
user_link="<a href='/users/show/"+hash.from+"'>"+hash.from_name+"</a>";
game_link=link_to_game({id:hash.game_id,name:hash.game_name});
if(hash.challenge_type=="create"){
notify_user("challenge from: "+user_link);
}else{
if(hash.challenge_type=="accept"){
notify_user("challenge accepted: "+game_link);
}
}
};
var process_chatroom=function(hash){
m={};
if(hash.action=="enter"){
m[hash.from_name]="enters "+hash.chat_room;
}else{
if(hash.action=="leave"){
m[hash.from_name]="leaves "+hash.chat_room;
}
}
receiveMessages([m]);
};
var update_gra=function(){
$.ajax({type:"GET",url:"/users/reload_gra/",dataType:"script",success:function(){
setGRA();
}});
};
var process_game_move=function(hash){
if(Game_id==hash.game_id){
$.ajax({type:"GET",url:"/games/json/"+Game_id,dataType:"script",success:function(){
e=$(".game_"+Game_id)[0];
updateGame(e,GamesJSON[e.data.id]);
if(hash.from!=UC){
playSound("/mp3/beep.mp3");
}
update_gra();
setAjaxActive(false);
}});
setAjaxActive();
}else{
user_link="<a href='/users/show/"+hash.from+"'>"+hash.from_name+"</a>";
game_link=link_to_game({id:hash.game_id,name:hash.game_name});
notify_user("Activity in: "+game_link);
update_gra();
if(hash.from!=UC){
playSound("/mp3/beep.mp3");
}
}
};
var process_login=function(hash){
if(hash.logged_in){
$(".user_"+hash.from).addClass("online").removeClass("offline");
$(".user_"+hash.from+" online_state").html("Online");
}else{
$(".user_"+hash.from).addClass("offline").removeClass("online");
$(".user_"+hash.from+" online_state").html("Offline");
}
};
var process_message=function(hash){
if(hash.comm_id=="lobby"){
receiveMessages([hash.message]);
}else{
if(Game_id==hash.comm_id){
receiveMessages([hash.message]);
}else{
if(BoardView!="micro"){
user_link="<a href='/users/show/"+hash.from+"'>"+hash.from_name+"</a>";
game_link=link_to_game({id:hash.comm_id,name:hash.game_name});
notify_user("message from: "+game_link);
}
}
}
};
var receiveComm=function(hash){
eval("process_"+hash.type+"(hash)");
};
var setUserLoggedIn=function(x){
update_gra();
UserLoggedIn=x;
if(UserLoggedIn){
$("#"+UserLoggedIn+"_user a").css({color:"#0b0"});
if(UserTurn){
setButton("nudge",false);
}else{
if($("#nudge").html()!="Reminded"){
setButton("nudge",true);
}
}
}else{
$("#"+UserLoggedIn+"_user a").css({color:"#555"});
}
};
var setOpponentLoggedIn=function(x){
OpponentLoggedIn=x;
if(OpponentLoggedIn){
$("#opponent_not_online").css({display:"none"});
$("#"+OpponentLoggedIn+"_user a").css({color:"#0b0"});
}else{
$("#opponent_not_online").css({display:"block"});
if(UserLoggedIn=="white"){
$("#black_user a").css({color:"#555"});
}else{
if(UserLoggedIn=="black"){
$("#white_user a").css({color:"#555"});
}else{
$("#white_user a").css({color:"#555"});
$("#black_user a").css({color:"#555"});
}
}
}
};
var ViewMode={init:function(e){
},step:function(e){
},exit:function(e){
e.$e.find("#playing_controls").hide();
},update:function(e){
e.$e.find("#mode #inner").html(e.game.state_text());
e.game.setMoveHistory(e.data.moves);
e.game.advanceToMovenum(e.options.move_num||"end");
e.board.render();
e.game.highlightLastMove();
if(e.game.userTurn(UC)){
e.$e.find("#mode").addClass("yourmove");
}
if(!e.options.hide.move_list&&!e.options.hide.info){
MoveHistory.draw(e,e.data.moves,true);
MoveHistory.highlight(e,e.game.curMoveNum);
MoveHistory.scrollTo(e,e.game.curMoveNum);
MoveHistory.hover(e,true);
}
e.options.move_num=null;
}};
var PlayingMode={step:function(e){
},exit:function(e){
e.$e.find("#playing_controls").hide();
e.$e.find("#move").fadeOut();
},init:function(e){
e.game.advanceToMovenum("end");
setButton("move",true);
var _346=$.browser.msie6?".gif":".png";
e.$e.find("#move").css({backgroundPosition:"0px 0px",width:e.options.size*36/60,height:e.options.size*36/60,backgroundImage:"url('/images/icons/tick/"+e.options.size+_346+"')",backgroundColor:"transparent"}).hover(function(){
$(this).css({backgroundPosition:(Math.floor(e.options.size*36/60))+"px 0px"});
},function(){
$(this).css({backgroundPosition:"0px 0px"});
});
},update:function(e){
e.$e.find("#playing_controls").show();
e.$e.find("#mode #inner").html(e.game.state_text());
if(e.game.userTurn(UC)){
e.$e.find("#mode").addClass("yourmove");
}else{
e.$e.find("#mode").removeClass("yourmove");
}
e.$e.find("#last_action").show();
e.game.moveCallback=PlayingMode.moveCallback;
e.game.setMoveHistory(e.data.moves,e.data.moves.length);
e.game.advanceToMovenum(e.options.move_num||"end");
e.board.render();
e.options.move_num=null;
e.game.highlightLastMove();
if(!e.options.hide.move_list&&!e.options.hide.info){
MoveHistory.draw(e,e.data.moves,true);
MoveHistory.scrollTo(e,e.game.curMoveNum);
MoveHistory.highlight(e,e.game.curMoveNum);
MoveHistory.hover(e,true);
}
setButton("view_pgn",true);
setButton("step",true);
setButton("analysis",true);
if(UC){
var _348=e.game.userColor(UC);
var _349=e.game.userTurn(UC);
var ef=e.data.game_state!="request";
setButton("draw",ef);
setButton("takeback",ef);
setButton("resign",(e.data.win==null));
if(UC==e.data.turn_user_id&&e.data.win==null){
FlashingTitle.start(">> Your Move");
}else{
FlashingTitle.stop();
}
if(e.data.time&&_348){
var _34b=e.game.abandonable()&&!_349;
var text=_349?"Opponent":"You";
text+=" can Abandon";
if(!e.game.abandonable()){
text+="<br/>"+get_local_time_for_date(e.data.time.last_move_date,e.data.time.abandonable_time);
}
setButton("abandon",_34b,text);
}
if(UC!=e.data.turn_user_id&&e.data.game_state!="abandoned"){
setButton("nudge",true,null,true);
}else{
setButton("nudge",false,null,false);
}
if(e.data.game_state=="request"&&_348){
var html="";
if(e.data.request_id==UC){
html=" - <a href='#' id='cancel' onclick='clicked_decline()'>Cancel</a>";
}else{
html=" - <a href='#' id='accept' onclick='clicked_accept()'>Accept</a>/<a id='decline' href='#' onclick='clicked_decline()'>Decline</a> ";
}
e.$e.find("#last_action").append(html);
}
if(UC==e.data.turn_user_id){
e.game.setAllowedMoves(e.data.allowed_moves);
}else{
e.game.setAllowedMoves([]);
}
}
},moveCallback:function(_34e,_34f){
var e=this.elem;
newstate=this.transist(cloneState(this.curState),_34f);
e.board.render(newstate);
if(_34e.piece=="p"&&newstate[_34e.id].piece!="p"){
_34f.promote=newstate[_34e.id];
}
var obj=this;
window.setTimeout(function(){
obj.setAllowedMoves([]);
},400);
e.board.highlightSquares([_34f.t,_34f.f]);
e.curSelectedMove=_34f;
sq=Square.fromLocation(_34f.t);
coords=Board.getCoords(sq.i,sq.j,e.board.settings);
ss=e.options.size;
coords.x+=coords.x==0?ss:0;
coords.y+=coords.y==0?ss:0;
button_size=(ss*36/60);
p=e.$e.find("#game").unbind("click").offset();
e.$e.find("#move").css({left:p.left+coords.x-button_size/2,top:p.top+coords.y-button_size/2});
window.setTimeout(function(){
e.$e.find("#move, #undo").fadeIn();
e.$e.find("#game").css("cursor","pointer").click(function(){
clicked_undo(e);
$(this).css("cursor","default");
return false;
});
obj.setAllowedMoves([]);
},100);
}};
var StepMode={step:function(e){
},init:function(e){
var $e=$(e);
$e.find("#step_forward").click(function(){
MoveHistory.click(e,e.game.curMoveNum);
MoveHistory.scrollTo(e,e.game.curMoveNum);
});
$e.find("#step_start").click(function(){
MoveHistory.click(e,0);
MoveHistory.scrollTo(e,0);
});
$e.find("#step_end").click(function(){
MoveHistory.click(e,e.game.moveHistory.length-1);
MoveHistory.scrollTo(e,e.game.moveHistory.length-1);
});
$e.find("#step_back").click(function(){
MoveHistory.click(e,e.game.curMoveNum-2);
MoveHistory.scrollTo(e,e.game.curMoveNum-2);
});
$e.find("#step_analysis").click(function(){
update_mode("analysis",e);
});
$e.find("#step_exit").click(function(){
$e.find("#step_end").click();
update_mode(e.options.mode,e);
});
$e.find("#step_controls li, #analysis_controls li").hover(function(){
$(this).addClass("hover");
},function(){
$(this).removeClass("hover");
});
},update:function(e){
e.$e.find("#mode #inner").html("STEP THROUGH").parent().addClass("green");
e.$e.find("#game").unbind("click").css("cursor","default");
e.$e.find("#step_controls").show();
e.game.advanceToMovenum(e.game.curMoveNum);
e.board.render();
MoveHistory.highlight(e);
e.$e.find("#m"+(e.game.curMoveNum-1)).addClass("highlight");
e.game.setAllowedMoves([]);
MoveHistory.hover(e,true);
},exit:function(e){
e.$e.find("#mode").removeClass("green");
e.$e.find("#step_controls").hide();
}};
var ReplayMode={init:function(e){
},step:function(e){
},exit:function(e){
},update:function(e){
e.game.advanceToMovenum(e.options.move_num||0);
e.board.render();
e.$e.find("#mode #inner").html("REPLAY").parent().removeClass("green");
MoveHistory.hover(e,false);
window.setTimeout(function(){
ReplayMode.loop(e.options.id.replace(".","_"));
},e.board.settings.speed*2);
},x:1,loop:function(id){
e=$("."+id)[0];
e.game.advance(1);
e.board.render();
if(!e.options.hide.info&&e.options.hide.move_list){
MoveHistory.highlight(e,e.game.curMoveNum);
MoveHistory.scrollTo(e,e.game.curMoveNum);
}
window.setTimeout(function(){
ReplayMode.loop(id);
},e.board.settings.speed*4);
}};
var AnalysisMode={step:function(e){
},moveCallback:function(_35d,_35e){
pt=this.findPiece(this.curState,_35e.t);
pf=this.findPiece(this.curState,_35e.f);
var e=this.elem;
var $e=$(e);
if(pf&&pt&&pf.color==pt.color){
this.board.render();
}else{
this.curState=this.transist(this.curState,_35e);
e.analysis_transitions=e.analysis_transitions||[];
_35e["a"]=true;
e.analysis_transitions[e.analysis_transitions.length]=_35e;
AnalysisMode.render(e);
}
e.board.setAllowedMoves("all");
},render:function(e){
var _362=e.data.moves.slice(0,e.game.curMoveNum).concat(e.analysis_transitions);
e.game.curState=e.game.transist_to_move_num(e.game.curMoveNum);
for(j=0;j<e.analysis_transitions.length;j++){
e.game.curState=e.game.transist(e.game.curState,e.analysis_transitions[j]);
}
e.game.board.render();
MoveHistory.draw(e,_362);
e.board.highlightTransition(e.analysis_transitions[e.analysis_transitions.length-1]);
MoveHistory.scrollTo(e,e.game.curMoveNum);
},init:function(e){
e.$e.find("#analysis_start").click(function(){
var e=$(this).parents(".embed")[0];
e.analysis_transitions=[];
AnalysisMode.render(e);
});
e.$e.find("#analysis_back").click(function(){
var e=$(this).parents(".embed")[0];
e.analysis_transitions=e.analysis_transitions.slice(0,-1);
AnalysisMode.render(e);
});
e.$e.find("#analysis_exit").click(function(){
var e=$(this).parents(".embed")[0];
e.$e.find("#analysis_start").click();
window.setTimeout(function(){
update_mode(e.options.mode,e);
},50);
});
},update:function(e){
e.$e.find("#mode #inner").html("ANALYSIS MODE").parent().addClass("green");
e.analysis_transitions=[];
e.game.moveCallback=AnalysisMode.moveCallback;
e.board.render();
e.board.setAllowedMoves("all");
MoveHistory.hover(e,false);
MoveHistory.draw(e,e.data.moves.slice(0,e.game.curMoveNum),true);
MoveHistory.highlight(e,e.game.curMoveNum);
e.$e.find("#analysis_controls").show();
e.$e.find("#game").css({backgroundColor:"#aea"});
},exit:function(e){
var $e=$(e);
e.$e.find("#analysis_controls").hide();
e.$e.find("#mode").removeClass("green");
e.$e.find("#game").css({backgroundColor:e.options.black_sq});
}};
var params_as_hash=function(p){
if(p==null){
return {};
}
var h={};
$.each(p.split(/,/),function(i,kv){
var x=kv.split("=");
h[$.trim(x[0])]=$.trim(x[1]);
});
return h;
};
var convertEmbeddedGames=function(_36f){
var _370=$("#template")[0];
$(".embed").each(function(){
if(_370){
$(this).html(_370.innerHTML);
}
var p=get_params(this);
$(this).find("#preview").css(boardCSSHash(p.size,"#eee")).show();
if(!_36f){
do_embed(this,p);
}else{
$(this).click(function(){
$(this).unbind("click");
do_embed(this);
}).css("cursor","pointer").find("#middle").html("Click to Load");
}
});
};
var get_params=function(x){
var _373=x.attributes["chess"]?x.attributes["chess"].value:document.location.search.substring(1);
_373=params_as_hash(_373);
_373.size=_373.size||2;
_373.size=parseInt(_373.size)*5+10;
if(_373.move_num){
_373.move_num=parseInt(_373.move_num);
}
_373.mode=_373.mode||"view";
if(_373.hide){
var h={};
$.each(_373.hide.split(/;/),function(){
h[this+""]=true;
});
_373.hide=h;
}else{
_373.hide={};
}
return _373;
};
var do_embed=function(_375){
var $$=$(_375);
var _377=get_params(_375);
if(_377.background){
$("body").css("background",_377.background.replace(/^x/,"#"));
}
$$.addClass("embed_"+_377.size).addClass(_377.id.replace(".","_"));
var y=_377.id.split(".");
_375.id_num=y[1];
_375.id_type=y[0];
embed(_375,_377);
};
var embed=function(e,opts){
opts.elem=e;
var d=GamesJSON[opts.id];
$(e).find("#middle").html("Loading <img src='/icons/small_ajax.gif'/>");
if(d){
initGame(e,d,opts);
updateGame(e,d);
$(e).find("#preview").hide();
}else{
var y=opts.id.split(".");
var gid=parseInt(y[1]);
var type=y[0];
$.ajax({url:"/"+type+"s/json_only/"+opts.id,dataType:"json",success:function(d){
$(e).find("#preview").hide();
GamesJSON[opts.id]=d;
initGame(e,d,opts);
updateGame(e,d);
}});
}
};
Piece=function(_380,_381,_382,_383){
this.location=_382;
this.taken=_383||false;
this.moved=false;
this.piece=_380;
this.color=_381;
this.moveToSq=function(sq,m){
m=(m==false)?false:true;
this.i=sq.i;
this.j=sq.j;
this.location=sq.location;
this.moved=m;
};
this.moveToSq(Square.fromLocation(this.location),false);
this.html=function(_386,_387){
var h="<div class='piece'";
if(!_387.taken_piece){
h+=" id='p"+this.id+"' ";
}
h+="style='";
if(_387.css){
h+=_387.css;
}
if(this.id!=null){
var _389=Board.getCoords(this.i,this.j,_387);
var _38a=_387.taken_piece?"inline":(this.taken?"none":"block");
var pos=_387.taken_piece?"position: relative; ":"left:"+(_389.x+1)+"px; display:"+_38a+";top:"+(_389.y+1)+"px;";
h+=pos;
}
h+="overflow: hidden; width:"+(_387.size-1)+"px; height: "+(_387.size-1)+"px;' board_id='"+_386+"'>";
h+=this.pieceImage(_387);
h+="</div>";
return h;
};
this.pieceImage=function(_38c){
var ml="bwc".indexOf(this.color)*(-_38c.size);
var mt="pnbrqk".indexOf(this.piece)*(-_38c.size);
var css="width:"+_38c.size*3+"px; height: "+_38c.size*6+"px; margin-left: "+(ml-1)+"px; margin-top: "+(mt-1)+"px;background-color: transparent; ";
var img="/images/pieces/"+_38c.piece_set+"/"+_38c.size+".png";
if($.browser.msie6){
css+="background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src="+img+"); position: relative; ";
}else{
css+="background-image:url("+img+"); ";
}
return "<div style='"+css+"' ></div>";
};
this.equals=function(p){
return p.i==this.i&&p.j==this.j&&p.taken==this.taken&&p.piece==this.piece&&this.dragging==this.dragging;
};
};
cloneState=function(_392){
var _393=[];
for(i=0;i<_392.length;i++){
var o=_392[i];
var _395={};
for(k in o){
_395[k]=o[k];
}
_393[i]=_395;
}
return _393;
};
Game=function(){
this.findPiece=function(_396,_397){
for(var i=0;i<32;i++){
if(_396[i].location==_397){
return _396[i];
}
}
return null;
};
this.state_text=function(){
if(this.elem.data.type=="opening"){
return "OPENING";
}
if(this.elem.data.game_state=="abandoned"){
return "ABANDONED";
}
if(this.elem.data.win==null){
if(this.userColor(UC)){
if(this.elem.data.turn_user_id==UC){
return "YOUR MOVE";
}
}
return this.turnColor().toUpperCase()+"'S MOVE";
}else{
if(this.elem.data.win=="draw"){
return "DRAW";
}else{
return this.elem.data.win.toUpperCase()+" WINS";
}
}
};
this.abandonable=function(){
var t=this.elem.data.time.abandonable_time;
return ((new Date()-new Date(this.elem.data.time.last_move_date))>(t*1000))&&this.elem.data.win==null;
};
this.setBoard=function(_39a){
this.board=_39a;
this.board.game=this;
};
this.userColor=function(user){
if(user==null||this.elem.data.type!="game"){
return null;
}
if(this.elem.data.user_white.id==user){
return "white";
}else{
if(this.elem.data.user_black.id==user){
return "black";
}
}
return null;
};
this.userTurn=function(user){
return (this.userColor(user)&&this.userColor(user)==this.turnColor());
};
this.opponent_id=function(_39d){
if(this.elem.data.user_white.id==_39d){
return this.elem.data.user_black.id;
}else{
if(this.elem.data.user_black.id==_39d){
return this.elem.data.user_white.id;
}
}
return null;
};
this.turnColor=function(){
if(this.elem.data.user_white.id==this.elem.data.turn_user_id){
return "white";
}else{
if(this.elem.data.user_black.id==this.elem.data.turn_user_id){
return "black";
}
}
return null;
};
this.initialize=function(_39e){
this.backrow=_39e||"rnbqkbnr";
this.enpassant=true;
this.moveHistory=[];
this.startState=this.initState(this.backrow);
this.curState=cloneState(this.startState);
this.curMoveNum=0;
};
this.setMoveHistory=function(_39f,_3a0){
_3a0=_3a0||0;
this.moveHistory=_39f;
this.curMoveNum=(_3a0=="end")?this.moveHistory.length:_3a0;
};
this.advance=function(x){
this.curMoveNum+=(x=="end")?this.moveHistory.length:((x==null)?this.moveHistory.length:x);
if(this.curMoveNum>this.moveHistory.length){
this.curMoveNum=this.moveHistory.length;
}
if(this.curMoveNum<0){
this.curMoveNum=0;
}
this.curState=this.transist_to_move_num(this.curMoveNum);
};
this.advanceToMovenum=function(x){
this.curMoveNum=(x=="end")?this.moveHistory.length:((x==null)?this.moveHistory.length:x);
if(this.curMoveNum>this.moveHistory.length){
this.curMoveNum=this.moveHistory.length;
}
if(this.curMoveNum<0){
this.curMoveNum=0;
}
this.curState=this.transist_to_move_num(this.curMoveNum);
};
this.initState=function(b){
var s=[];
var rows="abcdefgh";
for(var i=0;i<8;i++){
var r=rows.charAt(i);
s[i]=new Piece(b.charAt(i),"w",r+1);
s[i+8]=new Piece("p","w",r+2);
s[i+16]=new Piece(b.charAt(i),"b",r+8);
s[i+24]=new Piece("p","b",r+7);
}
for(var i=0;i<32;i++){
s[i].id=i;
}
return s;
};
this.setAllowedMoves=function(ms){
this.elem.board.setAllowedMoves(ms);
};
this.transist=function(_3a9,_3aa){
var _3ab=this.findPiece(_3a9,_3aa.f);
if(_3ab){
var _3ac=this.findPiece(_3a9,_3aa.t);
if(_3ac&&_3ac.color==_3ab.color){
_3ac=null;
}
moved_already=_3ab.moved;
_3a9[_3ab.id].moveToSq(Square.fromLocation(_3aa.t));
var toSq=Square.fromLocation(_3aa.t);
var _3ae=Square.fromLocation(_3aa.f);
if(_3ab.piece=="k"&&(_3aa.t.charAt(1)=="1"||_3aa.t.charAt(1)=="8")&&!moved_already&&(Math.abs(toSq.i-_3ae.i)==2||(_3aa.t.charAt(0)=="a"||_3aa.t.charAt(0)=="h"))){
var dr=(toSq.i>_3ae.i)?1:-1;
var rook=null;
for(var i=0;i<32;i++){
n=_3a9[i];
if(n.piece=="r"&&n.moved==false&&n.color==_3ab.color&&(n.i-_3ae.i)*dr>0){
rook=n;
break;
}
}
if(rook){
if(Math.abs(toSq.i-_3ae.i)==2){
rook.moveToSq(new Square(_3ae.i+dr,_3ae.j));
}else{
rook.moveToSq(new Square(_3ae.i,_3ae.j));
}
}
}
if(this.enpassant&&_3ab.piece=="p"&&toSq.i!=_3ae.i&&!_3ac){
epSq=new Square(toSq.i,_3ae.j);
ep=this.findPiece(_3a9,epSq.location);
if(_3ab.color=="w"){
if(ep&&ep.piece=="p"&&ep.color=="b"&&toSq.j==5&&_3ae.j==4){
_3ac=ep;
}
}else{
if(ep&&ep.piece=="p"&&ep.color=="w"&&toSq.j==2&&_3ae.j==3){
_3ac=ep;
}
}
}
if(_3ab.piece=="p"&&(toSq.j==(7-(_3ab.color=="w"?0:7)))){
_3a9[_3ab.id].piece="q";
_3a9[_3ab.id].promote="q";
}
if(_3ac){
_3a9[_3ac.id].taken=true;
_3a9[_3ac.id].moveToSq(new Square(-1,-1));
}
}else{
document.title+=("no piece at: "+_3aa.f);
}
return _3a9;
};
this.transist_to_move_num=function(_3b2){
if(_3b2>this.moveHistory.length){
_3b2=this.moveHistory.length;
}
if(_3b2<0){
_3b2=1;
}
var _3b3=cloneState(this.startState);
for(var i=0;i<_3b2;i++){
var _3b5=this.moveHistory[i];
_3b3=this.transist(_3b3,_3b5);
}
return _3b3;
};
this.highlightLastMove=function(){
this.board.highlightTransition(this.moveHistory[this.curMoveNum-1]);
};
this.takenPieces=function(_3b6){
_3b6=_3b6||this.curState;
var _3b7={w:[],b:[]};
for(var i in _3b6){
var _3b9=_3b6[i];
if(_3b9.taken){
_3b7[_3b9.color][_3b7[_3b9.color].length]=_3b9;
}
}
return _3b7;
};
this.moveCallback=function(_3ba,_3bb){
alert("no logic specified");
};
};
if(!Array.indexOf){
Array.prototype.indexOf=function(obj){
for(var i=0;i<this.length;i++){
if(this[i]==obj){
return i;
}
}
return -1;
};
}
cloneSettings=function(_3be){
var _3bf={};
for(k in _3be){
_3bf[k]=_3be[k];
}
return _3bf;
};
var movePiece=null;
var dragging_piece=null;
Board=function(){
this.settings={piece_set:"classic",black_sq:"#ddf",size:20,view_color:"white",highlight_sq:"yellow",speed:600,allow_user_moves:true};
this.initialize=function(id,_3c1){
this.id=id;
this.settings=jQuery.extend(this.settings,_3c1);
this.settings.speed=parseInt(this.settings.speed);
if(iphoneMode){
this.settings.speed=0;
}
this.curState=null;
this.elem=this.settings.elem;
this.$game=this.elem.$e.find("#game");
};
this.render=function(_3c2){
_3c2=_3c2||this.game.curState;
if(!this.renderedHTML){
this.renderHTML(_3c2);
}else{
this.renderUpdate(_3c2);
}
this.curState=cloneState(_3c2);
};
this.renderUpdate=function(_3c3){
this.updateSprites(_3c3);
if(iphoneMode){
if(!this.settings.linkToGame){
this.$game.unbind("click");
}
$(".piece").unbind("click",dealWithSquaresUnderPieces);
$(".square").unbind("click");
}
if(this.curState){
this.unHighlightSquares();
}
};
this.renderHTML=function(_3c4){
this.$game[0].innerHTML="<div id=highlightSquares>&nbsp;</div>"+this.spritesHTML(_3c4);
this.$game[0].style.cssText=this.boardStyleCSS(this.settings.linkToGame);
if(this.settings.linkToGame){
var url="/"+(this.settings.linkToGame=="opening"?"openings":"games")+"/show/"+this.id;
this.elem.setAttribute("url",url);
this.$game.click(function(){
document.location.href=this.getAttribute("url");
});
}
this.renderedHTML=true;
};
this.updateSprites=function(_3c6){
var _3c7=_3c6;
for(var i=0;i<32;i++){
var _3c9=_3c7[i];
var c=null;
if(this.curState&&this.curState[i].equals(_3c9)&&!this.curState[i].dragging){
}else{
if(this.curState&&this.curState[i].taken!=_3c9.taken){
var p=this.$game.find("#p"+i);
if(this.curState[i].taken){
if($.browser.msie6){
p.show();
}else{
if($.browser.msie){
p.css({backgroundColor:this.sqCol(_3c9)}).fadeIn(300,function(){
$(this).css({backgroundColor:"transparent"});
});
}else{
p.fadeIn(400);
}
}
this.setPiecePos(_3c9,0);
}else{
if($.browser.msie6){
p.hide();
}else{
if($.browser.msie){
p.css({backgroundColor:this.sqCol(_3c9)}).fadeOut(300,function(){
$(this).css({backgroundColor:"transparent"});
});
}else{
p.fadeOut(300);
}
}
}
}else{
if(this.curState){
this.setPiecePos(_3c9);
}
}
if(this.curState&&this.curState[i].piece!=_3c9.piece){
this.setPieceImage(_3c9);
}
}
}
return;
};
this.sqCol=function(p){
return (p.i+p.j)%2?"#fff":this.settings.black_sq;
};
this.setPiecePos=function(_3cd,_3ce){
pos=Board.getCoords(_3cd.i,_3cd.j,this.settings);
if(_3ce==0||iphoneMode){
var p=this.$game.find("#p"+_3cd.id)[0].style;
p.left=pos.x+1+"px";
p.top=pos.y+1+"px";
}else{
this.$game.find("#p"+_3cd.id).animate({left:pos.x,top:pos.y},_3ce||this.settings.speed);
}
};
this.setPieceImage=function(_3d0){
this.$game.find("#p"+_3d0.id)[0].innerHTML=_3d0.pieceImage(this.settings);
};
this.setAllowedMoves=function(_3d1){
if(_3d1!=[]){
this.initDragNDrop();
}
this.allowedMoves=_3d1;
movePiece=null;
if(this.settings.allow_user_moves){
for(i=0;i<32;i++){
var _3d2=this.curState[i];
if(_3d2.taken){
continue;
}
var _3d3=(this.allowedMoves=="all")||(this.allowedMoves&&this.allowedMoves[_3d2.location]!=null);
obj=this.$game.find(" #p"+i);
var _3d4=this.elem;
var _3d5=this;
if(iphoneMode){
if(_3d3){
obj.unbind("click").click(function(){
dragging_piece=_3d5.curState[parseInt(this.attributes["id"].value.substring(1))];
_3d5.onDragStart(dragging_piece);
$(".square").click(function(){
_3d5.over_sq=this.attributes["id"].value.substring(2);
_3d5.onDragEnd(dragging_piece);
return false;
});
$(".piece").click(dealWithSquaresUnderPieces);
return false;
});
}
}else{
if(_3d3){
obj.dragOn();
}else{
obj.dragOff();
}
}
}
}
};
this.scr2sq=function(x,y){
var i=Math.floor(x/this.settings.size);
var j=Math.floor(y/this.settings.size);
(this.settings.view_color=="white")?j=7-j:i=7-i;
return new Square(i,j);
};
this.initDragNDrop=function(){
if(!this.inited_dragndrop){
this.elem.$e.find(".piece").each(function(){
$(this).easydrag(false).dragOff();
$(this).ondrag(function(e,elem){
DragCallback(e,elem,"onDrag");
});
$(this).ondrop(function(e,elem){
DragCallback(e,elem,"onDrop");
});
$(this).ondragstart(function(e,elem){
DragCallback(e,elem,"onDragStart");
});
});
this.inited_dragndrop=true;
}
};
this.spritesHTML=function(ps){
html="";
for(var i=0;i<32;i++){
html+=ps[i].html(this.id,this.settings);
}
return html;
};
this.boardStyleCSS=function(_3e2){
return boardCSS(this.settings.size,this.settings.black_sq)+(_3e2?"; cursor: pointer":"");
};
this.highlightSquares=function(sqs,clss){
clss=clss||"highlight";
html="";
for(var k in sqs){
if(typeof (sqs[k])!="string"){
continue;
}
var sq=Square.fromLocation(sqs[k]);
var _3e7=Board.getCoords(sq.i,sq.j,this.settings);
html+="<div id='sq"+sq.location+"' class='square "+clss+"' style='margin-top:1px; margin-left:1px; position: absolute; left:"+_3e7.x+"px;top:"+_3e7.y+"px;width:"+(this.settings.size-1)+"px;height: "+(this.settings.size-1)+"px'>&nbsp;</div>";
}
this.$h=this.$h||this.$game.find("#highlightSquares");
this.$h[0].innerHTML=html;
this.$h[0].style.display="block";
};
this.highlightTransition=function(_3e8){
if(!_3e8){
return;
}
this.highlightSquares([_3e8.t,_3e8.f]);
};
this.unHighlightSquares=function(_3e9){
if(!this.$h){
return;
}
if(_3e9==null){
this.$h.find(".square").hide();
}else{
this.$h.find("div:not(."+_3e9+") ").fadeOut();
}
};
this.onDragStart=function(_3ea,ev){
if(!this.allowedMoves[_3ea.location]&&this.allowedMoves!="all"){
return true;
}
this.curState[_3ea.id].dragging=true;
this.unHighlightSquares();
this.move_from=_3ea.location;
this.over_sq=_3ea.location;
this.offset={x:ev.layerX,y:ev.layerY};
this.$game_offset=this.$game.offset();
if(this.allowedMoves!=null&&this.allowedMoves!="all"){
this.highlightSquares(this.allowedMoves[_3ea.location].concat([this.move_from]));
}
this.$game.find(" #sq"+this.move_from).addClass("over_sq");
};
this.onDrag=function(_3ec,ev){
if(!this.$game_offset){
return;
}
var x=-this.offset.x+ev.pageX-this.$game_offset.left;
var y=-this.offset.y+ev.pageY-this.$game_offset.top;
sq=this.scr2sq(x+this.settings.size/2,y+this.settings.size/2).location;
if(this.over_sq!=sq){
if(this.over_sq!=this.move_from){
this.$game.find(" #sq"+this.over_sq).removeClass("over_sq");
}
this.over_sq=sq;
if(this.allowedMoves&&(this.allowedMoves=="all"||(this.allowedMoves[_3ec.location]&&this.allowedMoves[_3ec.location].indexOf(this.over_sq)>-1))){
this.$game.find(" #sq"+this.over_sq).addClass("over_sq");
}
}
};
this.onDrop=function(_3f0,ev){
this.move_to=this.over_sq;
this.over_sq=null;
if((this.allowedMoves=="all"||(this.allowedMoves[this.move_from].indexOf(this.move_to)>=0))&&this.move_to!=this.move_from){
if(this.game.moveCallback){
this.game.moveCallback(_3f0,{t:this.move_to,f:this.move_from});
}
}else{
this.render(this.curState);
}
_3f0.dragging=false;
};
this.renderTakenPieces=function(_3f2){
_3f2=_3f2||this.game.takenPieces();
var _3f3=cloneSettings(this.settings);
_3f3.size=20;
_3f3.taken_piece=true;
var html="";
var cols=["w","b"];
for(var col=0;col<2;col++){
html+="<ul>";
var _3f7=_3f2[cols[col]];
for(var i in _3f7){
if(typeof (_3f7[i])!="object"){
continue;
}
html+="<li>"+_3f7[i].html("",_3f3)+"</li>";
}
html+="</ul>";
}
html+="<div class=clear></div>";
return html;
};
};
Board.getCoords=function(i,j,_3fb){
var ii=0,jj=0;
if(_3fb.view_color=="white"){
ii=i;
jj=7-j;
}else{
ii=7-i;
jj=j;
}
return {x:(ii*_3fb.size),y:(jj*_3fb.size)};
};
var DragCallback=function(ev,elem,t){
var b=$(elem).parents(".embed")[0].board;
var p=b.curState[parseInt(elem.id.substring(1))];
if(ev.offsetX&&t=="onDragStart"){
ev.layerX=ev.offsetX;
ev.layerY=ev.offsetY;
if(ev.offsetX>b.settings.size||ev.offsetY>b.settings.size){
var _403=$(elem).find("div");
ev.layerX+=parseInt(_403.css("margin-left"));
ev.layerY+=parseInt(_403.css("margin-top"));
}
}
switch(t){
case "onDrag":
b.onDrag(p,ev);
break;
case "onDrop":
b.onDrop(p,ev);
break;
case "onDragStart":
b.onDragStart(p,ev);
}
};
function boardCSS(size,_405){
return "background-color: "+_405+";background-image: url(/images/boards/board"+size+".gif)"+";width: "+size*8+"px"+";height: "+size*8+"px"+";border-right: 1px solid #888;border-bottom: 1px solid #888";
}
function boardCSSHash(size,_407){
return {"background-color":_407,"background-image":"url(/images/boards/board"+size+".gif)","width":size*8+"px","height":size*8+"px","border-right":"1px solid #888","border-bottom":"1px solid #888"};
}
Square=function(i,j){
this.i=i;
this.j=j;
this.location="abcdefgh".charAt(this.i)+(this.j+1);
this.equals=function(b){
if(b==null){
return false;
}
return (this.i==b.i&&this.j==b.j);
};
};
Square.fromLocation=function(n){
var i="abcdefgh".indexOf(n.charAt(0));
var j=parseInt(n.charAt(1))-1;
return new Square(i,j);
};
MoveHistory={render:function(e,_40f,n){
var h="";
for(var i=0;i<_40f.length;i++){
h+=MoveHistory.add_move(_40f,i,n);
}
return h;
},add_move:function(_413,i,n){
var h="";
n=n?n:0;
if(i%2==0){
var clss=_413[i].a?"'analysis move_num'":"move_num";
h+="<div class="+clss+" >"+((i/2)+1+n)+"</div>";
if((i+n)>0){
h="<br/>"+h;
}
}
return h+MoveHistory.move_html(_413,i);
},move_html:function(_418,i){
var move=_418[i];
if(!move){
return "";
}
var clss=(i%2==0)?"move_w":"move_b";
clss+=move.a?" analysis":"";
var note=move.n?move.n.replace("=","").replace("x","&times;"):(move.f+"."+move.t);
return "<div id=m"+i+" class='"+clss+" ' onclick=\"MoveHistory.click_td(this, "+i+")\" >"+note+"</span></div>";
},click_td:function(e_td,i){
return MoveHistory.click($(e_td).parents(".embed")[0],i);
},click:function(e,i){
if(i<0||i>e.data.moves.length-1||e.curMode=="analysis"||e.curMode=="replay"){
return;
}
MoveHistory.highlight(e,i+1);
MoveHistory.scrollTo(e,i+1);
e.game.curState=e.game.transist_to_move_num(i+1);
e.game.curMoveNum=i+1;
update_mode("step",e);
},scrollTo:function(e,i){
if(e.$e.find("#m0")[0]){
e.$e.find("#move_list")[0].scrollTop=Math.floor((i-1)/2)*e.$e.find("#m0").height();
}
},highlight:function(e,_i){
_i=_i||e.game.curMoveNum;
e.$e.find("#move_list .highlight").removeClass("highlight");
e.$e.find("#move_list #m"+(_i-1)).addClass("highlight");
},hover:function(e,on){
if(on){
e.$e.find(".move_w, .move_b").hover(function(){
$(this).addClass("hover");
},function(){
$(this).removeClass("hover");
});
}else{
e.$e.find(".move_w, .move_b").unbind("hover").removeClass("hover");
}
},draw:function(e,_428){
e.$e.find("#move_list").html(MoveHistory.render(e,_428));
}};
setButton=function(n,ok,text,vis){
var x=$("#"+n);
if(text){
x.find("a").html(text);
}
if(vis==true){
x.show();
}else{
if(vis==false){
x.hide();
}
}
if(ok==false){
x.removeClass("inactive").removeClass("hover").removeClass("active").unbind().click(function(){
return false;
}).find("a").removeAttr("href");
return;
}
x.addClass("active").removeClass("inactive").hover(function(){
$(this).addClass("hover");
},function(){
$(this).removeClass("hover");
}).unbind("click").click(function(){
$.closeDropdownz();
var e=$(this).parents(".embed")[0];
eval("clicked_"+$(this).attr("id")+"(e)");
return false;
}).find("a").attr("href","#");
};
setAjaxActive=function(p){
if(p==false){
$("#ajax").removeClass("active");
}else{
$("#ajax").addClass("active");
}
};
clicked_move=function(e){
move_params="to_state=move&from="+e.curSelectedMove.f+"&to="+e.curSelectedMove.t;
move_params+=e.curSelectedMove.promote?"&promote="+e.curSelectedMove.promote.piece:"";
ajaxRespond(e,"/games/transist/"+e.id_num,move_params,function(){
update_gra();
});
$(e).find("#game").unbind("click").css("cursor","default");
$(e).find("#move, #undo").fadeOut();
};
clicked_undo=function(e){
if(e.mode=="analysis"){
return;
}
e.game.board.render();
e.curSelectedMove=null;
window.setTimeout(function(){
if(UC&&UC==e.data.turn_user_id){
e.game.setAllowedMoves(e.data.allowed_moves);
}else{
e.game.setAllowedMoves([]);
}
},400);
e.$e.find("#move, #undo").fadeOut();
};
clicked_nudge=function(e){
ajaxRespond(e,"/games/nudge/"+e.id_num,"",function(){
setButton("nudge",false,"Remind Opponent",false);
});
};
clicked_resign=function(e){
if(confirm("Are you sure you want to resign?")){
ajaxRespond(e,"/games/transist/"+e.id_num,"to_state=resign");
}
};
clicked_decline=function(){
$.closeDropdownz();
e=$(".embed")[0];
ajaxRespond(e,"/games/transist/"+e.id_num,"to_state=answer&type="+e.data.request_type);
return false;
};
clicked_accept=function(){
$.closeDropdownz();
e=$(".embed")[0];
ajaxRespond(e,"/games/transist/"+e.id_num,"to_state=answer&accept=true&type="+e.data.request_type);
return false;
};
request=function(e,req){
if(confirm("Are you sure you want to request a "+req+"?")){
ajaxRespond(e,"/games/transist/"+e.id_num,"to_state=request&type="+req);
}
};
clicked_draw=function(e){
request(e,"draw");
};
clicked_takeback=function(e){
request(e,"takeback");
};
clicked_abandon=function(e){
if(confirm("Are you sure you want to set this game as abandoned? \n The game will be finished.")){
ajaxRespond(e,"/games/transist/"+e.id_num,"to_state=abandon");
}
};
clicked_view_pgn=function(e){
p=window.open("about:blank","_64squares_pgn","height=400,width=400,status=no,toolbar=no,menubar=no,location=no");
p.document.write("<body style='margin:0px; padding: 0px'>"+e.$e.find("#pgn").html()+"</body>");
p.document.close();
};
clicked_step=function(e){
update_mode("step",e);
};
clicked_analysis=function(e){
update_mode("analysis",e);
};
answer_request=function(e,x){
ans=ajaxRespond(e,"/games/transist/"+e.id_num,("to_state=answer&"+x?"accept=true":""));
};
ajaxRespond=function(e,url,data,s){
$.ajax({type:"POST",url:url,data:data,dataType:"script",success:function(){
setAjaxActive(false);
updateGame(e,GamesJSON[e.data.id]);
if(s){
s.call();
}
}});
setAjaxActive(true);
};
GameElems=["top","info","move_list","mode","last_action"];
var unhideElems=function(e){
$.each(GameElems,function(k,v){
if(!e.options.hide[v]){
e.$e.find("#"+v).show();
}
});
};
var updateInfo=function(e){
unhideElems(e);
if(e.data.time){
e.$e.find("#last_action").html(e.data.last_action+" "+get_local_time_for_date(e.data.time.updated_at));
}
if(!e.options.hide.move_list&&!e.options.hide.info){
var fs=parseInt(e.$e.find("#move_list").css("font-size"));
var ml=e.$e.find("#move_list");
MoveHistory.draw(e,e.data.moves,true);
x=e.$e.find("#mode").width();
x=x?x:"20pt";
ml.css({width:x-(parseInt(ml.css("margin-left")))});
var h=8*fs+(e.options.size/5-5)*4;
ml.css({height:h});
MoveHistory.scrollTo(e,e.game.curMoveNum);
}
};
var postUpdate=function(e){
var url="/"+e.data.type+"s/show/"+e.data.id;
if(e.data.name){
e.$e.find("#title")[0].innerHTML="<a href='"+url+"'>"+e.data.name.titlize()+"</a>";
}
if(!e.options.no_link&&e.options.mode!="playing"){
e.$e.find("#game").attr("href",url).click(function(){
navigateTo($(this).attr("href"));
}).css("cursor","pointer");
}
var t=e.$e.find("#taken_pieces");
if(t[0]){
t[0].innerHTML=e.board.renderTakenPieces();
}
e.$e.find("#mode").cornerz({radius:7});
};
var updateVersus=function(e){
if(e.data.user_white){
e.$e.find("#vs #user_white").html(link_to_user(e.data.user_white,e.game.userTurn(e.data.user_white.id)));
e.$e.find("#vs #user_black").html(link_to_user(e.data.user_black,e.game.userTurn(e.data.user_black.id)));
}
};
var initGame=function(e,data,_44f){
e.game=new Game();
e.$e=$(e);
e.board=new Board();
e.game.initialize(data.backrow);
var b_s=_44f;
b_s.piece_set=b_s.piece_set||data.piece_set;
b_s.black_sq=b_s.black_sq?b_s.black_sq.replace(/^x/,"#"):data.black_sq;
if(UC&&data.user_black&&data.user_black.id==UC){
b_s.view_color="black";
}
e.board.initialize(data.id,b_s);
e.game.setBoard(e.board);
e.game.setMoveHistory(data.moves);
e.game.elem=e;
e.options=_44f;
postInit(e);
var _451=e.$e.find("#codes");
if(_451[0]){
_451[0].innerHTML=row_col_HTML((b_s.view_color=="black"),e.options.size);
}
};
var row_col_HTML=function(rev,size){
var cols=["a","b","c","d","e","f","g","h"];
var rows=["8","7","6","5","4","3","2","1"];
if(rev){
rows=rows.reverse();
cols=cols.reverse();
}
var h="<div id=rows>";
var m=size/2;
$.each(rows,function(){
h+="<div style='top: "+m+"px'>"+this+"</div>";
m+=size;
});
h+="</div>";
h+="<div id=cols>";
m=size/2;
$.each(cols,function(){
h+="<div style='left: "+m+"px; top: "+size*8+"px'>"+this+"</div>";
m+=size;
});
h+="</div>";
return h;
};
var postInit=function(e){
};
var updateGame=function(e,data){
e.data=data;
updateInfo(e);
updateVersus(e);
update_mode(e.options.mode,e);
postUpdate(e);
};
var Modes={"playing":PlayingMode,"step":StepMode,"replay":ReplayMode,"analysis":AnalysisMode,"view":ViewMode};
var update_mode=function(mode,e){
if(e.curMode&&e.curMode!=mode){
Modes[e.curMode].exit(e);
}
if(!e["inited_"+mode]){
Modes[mode].init(e);
e["inited_"+mode]=true;
}
Modes[mode].update(e);
e.curMode=mode;
};
function javascript_all_pages(){
$(".dropdown_control").dropdownz();
$(".round").cornerz();
if(!$.browser.msie){
$(".round5").cornerz({radius:5});
$("#tabs_container .tabs li a").cornerz({corners:"tl tr"});
}
$("input[@type=text], input[@type=password], textarea").addClass("black_border");
if($.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent)){
$("img[@src$=.png], #move").pngfix();
}
setGRA();
show_dates_as_local_time();
window.onfocus=function(){
FlashingTitle.stop();
};
window.setTimeout(function(){
convertEmbeddedGames(ControllerAction=="users_blog"||ControllerAction=="articles_index");
$(".user").hoverIntent({over:function(){
showToolTip(this);
},interval:350,timeout:350,out:hideToolTip}).click(function(){
$("#tooltip").remove();
});
},GameLoadDelay);
$(".stripeMe tr:even").addClass("alt");
}
function showToolTip(elem){
var $$=$(elem);
var id=$$.attr("user_id");
if(id==null||id<0){
return;
}
id=parseInt(id);
user=Users[id];
if(user==null){
$("#tooltip").html("<img src='/images/icons/small_ajax.gif' />");
$.ajax({url:"/users/json/"+id,dataType:"json",success:function(d){
Users[parseInt(id)]=d;
setTooltipText(Users[parseInt(id)]);
}});
}else{
setTooltipText(user);
}
t=$$.offset();
$("#tooltip").css({left:(t.left+50),top:(t.top+20)}).fadeIn();
}
function setTooltipText(user,tt){
var _463=""+user.rating+" ("+user.rank+")<br>";
_463+="Won:"+user.profile.wins+" ";
_463+="Drawn:"+user.profile.draws+" ";
_463+="Lost:"+user.profile.losses+" ";
_463+="<b>Abandoned:"+user.profile.abandoned+"";
$("#tooltip").html(_463);
}
function hideToolTip(){
$("#tooltip").hide();
}
function javascript_challenges_create(){
$("#open_anyone").click(function(){
$("#name_or_email").addClass("not_vis")[0].disabled=true;
$("#spec").show();
});
$("#open_specific").click(function(){
$("#name_or_email").removeClass("not_vis")[0].disabled=false;
$("#spec").hide();
if($("#name_or_email").val()==""){
$("#name_or_email").val("Enter Username/Email Address");
}
});
$("#name_or_email").click(function(){
$(this).select();
});
v=$("#name_or_email").val();
if(v!=""){
$("#open_specific").click();
}else{
$("#open_anyone").click();
}
}
function javascript_challenges_new(){
$(".challenge").each(function(){
convert2Challenge(this);
});
javascript_challenges_create();
}
function javascript_challenges_show_open(){
$(".challenge").each(function(){
convert2Challenge(this);
});
}
function javascript_conversations_lobby(){
outer_box_el=$("#outer_box");
$("#conversation #outer_box").css({overflow:"auto"});
}
function javascript_games_show(){
window.setTimeout(function(){
if($(".embed")[0].game.userColor(UC)){
$("#conversation").show().find("#outer_box").css({overflow:"auto"});
}
},50);
}
function javascript_page_index(){
GameLoadDelay=100;
}
function convert_rte(){
$(".rte-zone").rte("/stylesheets/rte.css");
$(".rte-toolbar a").spritez({src:"/rte/rte.gif",layout:{"nav":{size:[16,16],states:["bold","italic","underline","superscript","subscript","orderedlist","unorderedlist","leftjustify","rightjustify","fulljustify","color","background","source","link","image","strikethrough","embed_game"]}}});
}
function javascript_users_show(){
$.tabs("#tabs_container");
$("#profile_wins").html(""+User_on_page.profile.wins);
$("#profile_completed").html(""+User_on_page.profile.completed);
$("#profile_losses").html(""+User_on_page.profile.losses);
$("#profile_draws").html(""+User_on_page.profile.draws);
$("#profile_current").html(""+User_on_page.profile.current);
$("#profile_abandoned").html(""+User_on_page.profile.abandoned);
$("#rating").html(User_on_page.rating+" ("+User_on_page.rank+")");
GameLoadDelay=100;
$(".challenge").each(function(){
convert2Challenge(this);
});
}
$(document).ready(function(){
if($.browser.msie){
$.browser.msie6=/MSIE\s(5\.5|6\.)/.test(navigator.userAgent);
}
ControllerAction=document.body.id;
javascript_all_pages();
switch(ControllerAction){
case "articles_new":
javascript_articles_new();
break;
case "challenges_create":
javascript_challenges_create();
break;
case "challenges_new":
javascript_challenges_new();
break;
case "challenges_show_open":
javascript_challenges_show_open();
break;
case "conversations_lobby":
javascript_conversations_lobby();
break;
case "games_show":
javascript_games_show();
break;
case "page_index":
javascript_page_index();
break;
case "users_show":
javascript_users_show();
break;
}
});
var window_onload=function(){
if(ControllerAction=="games_show"&&!Facebook&&$(".embed")[0].game.userColor(UC)){
setTimeout(function(){
retrieveMessages();
},100);
}
$.getScript("http://www.google-analytics.com/urchin.js",function(){
_uacct="UA-2222289-1";
if(typeof (urchinTracker)=="function"){
urchinTracker();
}
});
};