/* compact [
	squelettes/js/nicetitle.js
	prive/javascript/jquery.js
	prive/javascript/jquery.form.js
	prive/javascript/ajaxCallback.js
	page=chess.js
	plugins/auto/couteau_suisse/lib/jcorner/distant_jquery.corner.js
	plugins/auto/fancybox/spip20/javascript/jquery.fancybox-1.2.6.js
	plugins/auto/fancybox/javascript/fancybox.js
	page=socialtags.js
] 63.1% */

/* squelettes/js/nicetitle.js */
;
var XHTMLNS="http://www.w3.org/1999/xhtml";
var CURRENT_NICE_TITLE=false;
var browser=new Browser();
addEvent(window,"load",makeNiceTitles);
function makeNiceTitles(){
if(!document.createElement||!document.getElementsByTagName)return;
if(!document.createElementNS)
{
document.createElementNS=function(ns,elt){
return document.createElement(elt)}
}
if(!document.links)
{
document.links=document.getElementsByTagName("a")}
for(var ti=0;ti<document.links.length;ti++){
var lnk=document.links[ti];
if(lnk.title){
lnk.setAttribute("nicetitle",lnk.title);
lnk.removeAttribute("title");
addEvent(lnk,"mouseover",showNiceTitle);
addEvent(lnk,"mouseout",hideNiceTitle);
addEvent(lnk,"focus",showNiceTitle);
addEvent(lnk,"blur",hideNiceTitle)}
}
var instags=document.getElementsByTagName("ins");
if(instags){
for(var ti=0;ti<instags.length;ti++){
var instag=instags[ti];
if(instag.dateTime){
var strDate=instag.dateTime;
var dtIns=new Date(strDate.substring(0,4),parseInt(strDate.substring(4,6)-1),strDate.substring(6,8),strDate.substring(9,11),strDate.substring(11,13),strDate.substring(13,15));
instag.setAttribute("nicetitle","Added on "+dtIns.toString());
addEvent(instag,"mouseover",showNiceTitle);
addEvent(instag,"mouseout",hideNiceTitle);
addEvent(instag,"focus",showNiceTitle);
addEvent(instag,"blur",hideNiceTitle)}
}
}
}
function findPosition(oLink){
if(oLink.offsetParent){
for(var posX=0,posY=0;oLink.offsetParent;oLink=oLink.offsetParent){
posX+=oLink.offsetLeft;
posY+=oLink.offsetTop}
return[posX,posY]}else{
return[oLink.x,oLink.y]}
}
function showNiceTitle(e){
if(CURRENT_NICE_TITLE)hideNiceTitle(CURRENT_NICE_TITLE);
if(!document.getElementsByTagName)return;
if(window.event&&window.event.srcElement){
lnk=window.event.srcElement
}else if(e&&e.target){
lnk=e.target
}
if(!lnk)return;
if(lnk.nodeType==3){
lnk=getParent(lnk,"A")}
if(!lnk)return;
nicetitle=lnk.getAttribute("nicetitle");
if(!nicetitle)return;
var d=document.createElementNS(XHTMLNS,"div");
d.className="nicetitle";
tnt=document.createTextNode(nicetitle);
pat=document.createElementNS(XHTMLNS,"p");
pat.className="titletext";
pat.appendChild(tnt);
d.appendChild(pat);
STD_WIDTH=300;
if(nicetitle.toString().length){
h=nicetitle.toString().length;
t=nicetitle.toString().length}else{
h=1;
t=1}
h_pixels=h*6;t_pixels=t*10;
if(h_pixels>STD_WIDTH){
w=h_pixels}else if((STD_WIDTH>t_pixels)&&(t_pixels>h_pixels)){
w=t_pixels}else if((STD_WIDTH>t_pixels)&&(h_pixels>t_pixels)){
w=h_pixels}else{
w=STD_WIDTH}
d.style.width=w+'px';
mpos=findPosition(lnk);
mx=mpos[0];
my=mpos[1];
d.style.left=(mx+15)+'px';
d.style.top=(my+35)+'px';
if(window.innerWidth&&((mx+w)>window.innerWidth)){
d.style.left=(window.innerWidth-w-25)+"px"}
if(document.body.scrollWidth&&((mx+w)>document.body.scrollWidth)){
d.style.left=(document.body.scrollWidth-w-25)+"px"}
document.getElementsByTagName("body")[0].appendChild(d);
CURRENT_NICE_TITLE=d}
function hideNiceTitle(e){
if(!document.getElementsByTagName)return;
if(CURRENT_NICE_TITLE){
document.getElementsByTagName("body")[0].removeChild(CURRENT_NICE_TITLE);
CURRENT_NICE_TITLE=null}
}
function addEvent(obj,evType,fn){
if(obj.addEventListener){
obj.addEventListener(evType,fn,false);
return true}else if(obj.attachEvent){
var r=obj.attachEvent("on"+evType,fn);
return r}else{
return false}
}
function getParent(el,pTagName){
if(el==null)return null;
else if(el.nodeType==1&&el.tagName.toLowerCase()==pTagName.toLowerCase())return el;
else
return getParent(el.parentNode,pTagName)}
function getMousePosition(event){
if(browser.isIE){
x=window.event.clientX+document.documentElement.scrollLeft
+document.body.scrollLeft;
y=window.event.clientY+document.documentElement.scrollTop
+document.body.scrollTop}
if(browser.isNS){
x=event.clientX+window.scrollX;
y=event.clientY+window.scrollY}
return[x,y]}
function Browser(){
var ua,s,i;
this.isIE=false;
this.isNS=false;
this.version=null;
ua=navigator.userAgent;
s="MSIE";
if((i=ua.indexOf(s))>=0){
this.isIE=true;
this.version=parseFloat(ua.substr(i+s.length));
return}
s="Netscape6/";
if((i=ua.indexOf(s))>=0){
this.isNS=true;
this.version=parseFloat(ua.substr(i+s.length));
return}
s="Gecko";
if((i=ua.indexOf(s))>=0){
this.isNS=true;
this.version=6.1;
return}
}


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


/* prive/javascript/jquery.form.js */
;

;(function($){
$.fn.ajaxSubmit=function(options){
if(!this.length){
log('ajaxSubmit: skipping submit process - no element selected');
return this}
if(typeof options=='function')
options={success:options};
var url=this.attr('action')||window.location.href;
url=(url.match(/^([^#]+)/)||[])[1];
url=url||window.location.href;
url=(url.match(/^([^#]+)/)||[])[1];
url=url||'';
options=$.extend({
url:url,
type:this.attr('method')||'GET'
},options||{});
var veto={};
this.trigger('form-pre-serialize',[this,options,veto]);
if(veto.veto){
log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
return this}
if(options.beforeSerialize&&options.beforeSerialize(this,options)===false){
log('ajaxSubmit: submit aborted via beforeSerialize callback');
return this}
var a=this.formToArray(options.semantic);
if(options.data){
options.extraData=options.data;
for(var n in options.data){
if(options.data[n]instanceof Array){
for(var k in options.data[n])
a.push({name:n,value:options.data[n][k]})}
else
a.push({name:n,value:options.data[n]})}
}
if(options.beforeSubmit&&options.beforeSubmit(a,this,options)===false){
log('ajaxSubmit: submit aborted via beforeSubmit callback');
return this}
this.trigger('form-submit-validate',[a,this,options,veto]);
if(veto.veto){
log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
return this}
var q=$.param(a);
if(options.type.toUpperCase()=='GET'){
options.url+=(options.url.indexOf('?')>=0?'&':'?')+q;
options.data=null}
else
options.data=q;
var $form=this,callbacks=[];
if(options.resetForm)callbacks.push(function(){$form.resetForm()});
if(options.clearForm)callbacks.push(function(){$form.clearForm()});
if(!options.dataType&&options.target){
var oldSuccess=options.success||function(){};
callbacks.push(function(data){
$(options.target).html(data).each(oldSuccess,arguments)})}
else if(options.success)
callbacks.push(options.success);
options.success=function(data,status){
for(var i=0,max=callbacks.length;i<max;i++)
callbacks[i].apply(options,[data,status,$form])};
var files=$('input:file',this).fieldValue();
var found=false;
for(var j=0;j<files.length;j++)
if(files[j])
found=true;
if(options.iframe||found){
if(options.closeKeepAlive)
$.get(options.closeKeepAlive,fileUpload);
else
fileUpload()}
else
$.ajax(options);
this.trigger('form-submit-notify',[this,options]);
return this;
function fileUpload(){
var form=$form[0];
if($(':input[name=submit]',form).length){
alert('Error: Form elements must not be named "submit".');
return}
var opts=$.extend({},$.ajaxSettings,options);
var s=$.extend(true,{},$.extend(true,{},$.ajaxSettings),opts);
var id='jqFormIO'+(new Date().getTime());
var $io=$('<iframe id="'+id+'" name="'+id+'" src="about:blank" />');
var io=$io[0];
$io.css({position:'absolute',top:'-1000px',left:'-1000px'});
var xhr={
aborted:0,
responseText:null,
responseXML:null,
status:0,
statusText:'n/a',
getAllResponseHeaders:function(){},
getResponseHeader:function(){},
setRequestHeader:function(){},
abort:function(){
this.aborted=1;
$io.attr('src','about:blank')}
};
var g=opts.global;
if(g&&!$.active++)$.event.trigger("ajaxStart");
if(g)$.event.trigger("ajaxSend",[xhr,opts]);
if(s.beforeSend&&s.beforeSend(xhr,s)===false){
s.global&&$.active--;
return}
if(xhr.aborted)
return;
var cbInvoked=0;
var timedOut=0;
var sub=form.clk;
if(sub){
var n=sub.name;
if(n&&!sub.disabled){
options.extraData=options.extraData||{};
options.extraData[n]=sub.value;
if(sub.type=="image"){
options.extraData[name+'.x']=form.clk_x;
options.extraData[name+'.y']=form.clk_y}
}
}
setTimeout(function(){
var t=$form.attr('target'),a=$form.attr('action');
form.setAttribute('target',id);
if(form.getAttribute('method')!='POST')
form.setAttribute('method','POST');
if(form.getAttribute('action')!=opts.url)
form.setAttribute('action',opts.url);
if(!options.skipEncodingOverride){
$form.attr({
encoding:'multipart/form-data',
enctype:'multipart/form-data'
})}
if(opts.timeout)
setTimeout(function(){timedOut=true;cb()},opts.timeout);
var extraInputs=[];
try{
if(options.extraData)
for(var n in options.extraData)
extraInputs.push(
$('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')
.appendTo(form)[0]);
$io.appendTo('body');
io.attachEvent?io.attachEvent('onload',cb):io.addEventListener('load',cb,false);
form.submit()}
finally{
form.setAttribute('action',a);
t?form.setAttribute('target',t):$form.removeAttr('target');
$(extraInputs).remove()}
},10);
var nullCheckFlag=0;
function cb(){
if(cbInvoked++)return;
io.detachEvent?io.detachEvent('onload',cb):io.removeEventListener('load',cb,false);
var ok=true;
try{
if(timedOut)throw'timeout';
var data,doc;
doc=io.contentWindow?io.contentWindow.document:io.contentDocument?io.contentDocument:io.document;
if((doc.body==null||doc.body.innerHTML=='')&&!nullCheckFlag){
nullCheckFlag=1;
cbInvoked--;
setTimeout(cb,100);
return}
xhr.responseText=doc.body?doc.body.innerHTML:null;
xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc;
xhr.getResponseHeader=function(header){
var headers={'content-type':opts.dataType};
return headers[header]};
if(opts.dataType=='json'||opts.dataType=='script'){
var ta=doc.getElementsByTagName('textarea')[0];
xhr.responseText=ta?ta.value:xhr.responseText}
else if(opts.dataType=='xml'&&!xhr.responseXML&&xhr.responseText!=null){
xhr.responseXML=toXml(xhr.responseText)}
data=$.httpData(xhr,opts.dataType)}
catch(e){
ok=false;
$.handleError(opts,xhr,'error',e)}
if(ok){
opts.success(data,'success');
if(g)$.event.trigger("ajaxSuccess",[xhr,opts])}
if(g)$.event.trigger("ajaxComplete",[xhr,opts]);
if(g&&!--$.active)$.event.trigger("ajaxStop");
if(opts.complete)opts.complete(xhr,ok?'success':'error');
setTimeout(function(){
$io.remove();
xhr.responseXML=null},100)};
function toXml(s,doc){
if(window.ActiveXObject){
doc=new ActiveXObject('Microsoft.XMLDOM');
doc.async='false';
doc.loadXML(s)}
else
doc=(new DOMParser()).parseFromString(s,'text/xml');
return(doc&&doc.documentElement&&doc.documentElement.tagName!='parsererror')?doc:null}}};
$.fn.ajaxForm=function(options){
return this.ajaxFormUnbind().bind('submit.form-plugin',function(){
$(this).ajaxSubmit(options);
return false}).each(function(){
$(":submit,input:image",this).bind('click.form-plugin',function(e){
var form=this.form;
form.clk=this;
if(this.type=='image'){
if(e.offsetX!=undefined){
form.clk_x=e.offsetX;
form.clk_y=e.offsetY}else if(typeof $.fn.offset=='function'){
var offset=$(this).offset();
form.clk_x=e.pageX-offset.left;
form.clk_y=e.pageY-offset.top}else{
form.clk_x=e.pageX-this.offsetLeft;
form.clk_y=e.pageY-this.offsetTop}
}
setTimeout(function(){form.clk=form.clk_x=form.clk_y=null},10)})})};
$.fn.ajaxFormUnbind=function(){
this.unbind('submit.form-plugin');
return this.each(function(){
$(":submit,input:image",this).unbind('click.form-plugin')})};
$.fn.formToArray=function(semantic){
var a=[];
if(this.length==0)return a;
var form=this[0];
var els=semantic?form.getElementsByTagName('*'):form.elements;
if(!els)return a;
for(var i=0,max=els.length;i<max;i++){
var el=els[i];
var n=el.name;
if(!n)continue;
if(semantic&&form.clk&&el.type=="image"){
if(!el.disabled&&form.clk==el)
a.push({name:n+'.x',value:form.clk_x},{name:n+'.y',value:form.clk_y});
continue}
var v=$.fieldValue(el,true);
if(v&&v.constructor==Array){
for(var j=0,jmax=v.length;j<jmax;j++)
a.push({name:n,value:v[j]})}
else if(v!==null&&typeof v!='undefined')
a.push({name:n,value:v})}
if(!semantic&&form.clk){
var inputs=form.getElementsByTagName("input");
for(var i=0,max=inputs.length;i<max;i++){
var input=inputs[i];
var n=input.name;
if(n&&!input.disabled&&input.type=="image"&&form.clk==input)
a.push({name:n+'.x',value:form.clk_x},{name:n+'.y',value:form.clk_y})}
}
return a};
$.fn.formSerialize=function(semantic){
return $.param(this.formToArray(semantic))};
$.fn.fieldSerialize=function(successful){
var a=[];
this.each(function(){
var n=this.name;
if(!n)return;
var v=$.fieldValue(this,successful);
if(v&&v.constructor==Array){
for(var i=0,max=v.length;i<max;i++)
a.push({name:n,value:v[i]})}
else if(v!==null&&typeof v!='undefined')
a.push({name:this.name,value:v})});
return $.param(a)};
$.fn.fieldValue=function(successful){
for(var val=[],i=0,max=this.length;i<max;i++){
var el=this[i];
var v=$.fieldValue(el,successful);
if(v===null||typeof v=='undefined'||(v.constructor==Array&&!v.length))
continue;
v.constructor==Array?$.merge(val,v):val.push(v)}
return val};
$.fieldValue=function(el,successful){
var n=el.name,t=el.type,tag=el.tagName.toLowerCase();
if(typeof successful=='undefined')successful=true;
if(successful&&(!n||el.disabled||t=='reset'||t=='button'||
(t=='checkbox'||t=='radio')&&!el.checked||
(t=='submit'||t=='image')&&el.form&&el.form.clk!=el||
tag=='select'&&el.selectedIndex==-1))
return null;
if(tag=='select'){
var index=el.selectedIndex;
if(index<0)return null;
var a=[],ops=el.options;
var one=(t=='select-one');
var max=(one?index+1:ops.length);
for(var i=(one?index:0);i<max;i++){
var op=ops[i];
if(op.selected){
var v=op.value;
if(!v)
v=(op.attributes&&op.attributes['value']&&!(op.attributes['value'].specified))?op.text:op.value;
if(one)return v;
a.push(v)}
}
return a}
return el.value};
$.fn.clearForm=function(){
return this.each(function(){
$('input,select,textarea',this).clearFields()})};
$.fn.clearFields=$.fn.clearInputs=function(){
return this.each(function(){
var t=this.type,tag=this.tagName.toLowerCase();
if(t=='text'||t=='password'||tag=='textarea')
this.value='';
else if(t=='checkbox'||t=='radio')
this.checked=false;
else if(tag=='select')
this.selectedIndex=-1})};
$.fn.resetForm=function(){
return this.each(function(){
if(typeof this.reset=='function'||(typeof this.reset=='object'&&!this.reset.nodeType))
this.reset()})};
$.fn.enable=function(b){
if(b==undefined)b=true;
return this.each(function(){
this.disabled=!b})};
$.fn.selected=function(select){
if(select==undefined)select=true;
return this.each(function(){
var t=this.type;
if(t=='checkbox'||t=='radio')
this.checked=select;
else if(this.tagName.toLowerCase()=='option'){
var $sel=$(this).parent('select');
if(select&&$sel[0]&&$sel[0].type=='select-one'){
$sel.find('option').selected(false)}
this.selected=select}
})};
function log(){
if($.fn.ajaxSubmit.debug&&window.console&&window.console.log)
window.console.log('[jquery.form] '+Array.prototype.join.call(arguments,''))}})(jQuery);


/* prive/javascript/ajaxCallback.js */
;
if(!jQuery.load_handlers){
jQuery.load_handlers=new Array();
function onAjaxLoad(f){
jQuery.load_handlers.push(f)};
function triggerAjaxLoad(root){
for(var i=0;i<jQuery.load_handlers.length;i++)
jQuery.load_handlers[i].apply(root)};
jQuery.fn._ACBload=jQuery.fn.load;
jQuery.fn.load=function(url,params,callback){
callback=callback||function(){};
if(params){
if(params.constructor==Function){
callback=params;
params=null}
}
var callback2=function(res,status){triggerAjaxLoad(this);callback.call(this,res,status)};
return this._ACBload(url,params,callback2)};
jQuery._ACBajax=jQuery.ajax;
jQuery.ajax=function(type){
var s=jQuery.extend(true,{},jQuery.ajaxSettings,type);
var callbackContext=s.context||s;
if(jQuery.ajax.caller==jQuery.fn._load)return jQuery._ACBajax(type);
var orig_complete=s.complete||function(){};
type.complete=function(res,status){
var dataType=type.dataType;
var ct=(res&&(typeof res.getResponseHeader=='function'))
?res.getResponseHeader("content-type"):'';
var xml=!dataType&&ct&&ct.indexOf("xml")>=0;
orig_complete.call(callbackContext,res,status);
if(!dataType&&!xml||dataType=="html")triggerAjaxLoad(document)};
return jQuery._ACBajax(type)}}
jQuery.fn.animeajax=function(end){
this.children().css('opacity',0.5);
if(typeof ajax_image_searching!='undefined'){
var i=(this).find('.image_loading');
if(i.length)i.eq(0).html(ajax_image_searching);
else this.prepend('<span class="image_loading">'+ajax_image_searching+'</span>')}
return this}
jQuery.fn.positionner=function(force){
var offset=jQuery(this).offset({'scroll':false});
var hauteur=parseInt(jQuery(this).css('height'));
var scrolltop=self['pageYOffset']||
jQuery.boxModel&&document.documentElement['scrollTop']||
document.body['scrollTop'];
var h=jQuery(window).height();
var scroll=0;
if(force||offset['top']-5<=scrolltop)
scroll=offset['top']-5;
else if(offset['top']+hauteur-h+5>scrolltop)
scroll=Math.min(offset['top']-5,offset['top']+hauteur-h+15);
if(scroll)
jQuery('html,body')
.animate({scrollTop:scroll},300);
jQuery(jQuery('*',this).filter('input[type=text],textarea')[0]).focus();
return this}
var virtualbuffer_id='spip_virtualbufferupdate';
function initReaderBuffer(){
if(jQuery('#'+virtualbuffer_id).length)return;
jQuery('body').append('<p style="float:left;width:0;height:0;position:absolute;left:-5000;top:-5000;"><input type="hidden" name="'+virtualbuffer_id+'" id="'+virtualbuffer_id+'" value="0" /></p>')}
function updateReaderBuffer(){
var i=jQuery('#'+virtualbuffer_id);
if(!i.length)return;
i.attr('value',parseInt(i.attr('value'))+1)}
jQuery.fn.formulaire_dyn_ajax=function(target){
if(this.length)
initReaderBuffer();
return this.each(function(){
var cible=target||this;
jQuery('form:not(.noajax,.bouton_action_post)',this).each(function(){
var leform=this;
var leclk,leclk_x,leclk_y;
jQuery(this).prepend("<input type='hidden' name='var_ajax' value='form' />")
.ajaxForm({
beforeSubmit:function(){
leclk=leform.clk;
if(leclk){
var n=leclk.name;
if(n&&!leclk.disabled&&leclk.type=="image"){
leclk_x=leform.clk_x;
leclk_y=leform.clk_y}
}
jQuery(cible).addClass('loading').animeajax()},
success:function(c){
if(c=='noajax'){
jQuery("input[name=var_ajax]",leform).remove();
if(leclk){
var n=leclk.name;
if(n&&!leclk.disabled){
jQuery(leform).prepend("<input type='hidden' name='"+n+"' value='"+leclk.value+"' />");
if(leclk.type=="image"){
jQuery(leform).prepend("<input type='hidden' name='"+n+".x' value='"+leform.clk_x+"' />");
jQuery(leform).prepend("<input type='hidden' name='"+n+".y' value='"+leform.clk_y+"' />")}
}
}
jQuery(leform).ajaxFormUnbind().submit()}
else{
var recu=jQuery('<div><\/div>').html(c);
var d=jQuery('div.ajax',recu);
if(d.length)
c=d.html();
jQuery(cible)
.removeClass('loading')
.html(c);
var a=jQuery('a:first',recu).eq(0);
if(a.length&&a.is('a[name=ajax_ancre]')){
a=a.attr('href');
setTimeout(function(){
jQuery(a,cible).positionner(true)},10)}
else{
jQuery(cible).positionner(false);
if(a.length&&a.is('a[name=ajax_redirect]')){
a=a.attr('href');
jQuery(cible).addClass('loading').animeajax();
setTimeout(function(){
document.location.replace(a)},10)}
}
triggerAjaxLoad(cible);
updateReaderBuffer()}
},
iframe:jQuery.browser.msie
})
.addClass('noajax')})})}
var ajax_confirm=true;
var ajax_confirm_date=0;
var spip_confirm=window.confirm;
function _confirm(message){
ajax_confirm=spip_confirm(message);
if(!ajax_confirm){
var d=new Date();
ajax_confirm_date=d.getTime()}
return ajax_confirm}
window.confirm=_confirm;
var preloaded_urls={};
var ajaxbloc_selecteur;
jQuery.fn.ajaxbloc=function(){
if(this.length)
initReaderBuffer();
return this.each(function(){
jQuery('div.ajaxbloc',this).ajaxbloc();var blocfrag=jQuery(this);
var on_pagination=function(c){
jQuery(blocfrag)
.html(c)
.removeClass('loading');
var a=jQuery('a:first',jQuery(blocfrag)).eq(0);
if(a.length&&a.is('a[name=ajax_ancre]')
){
a=a.attr('href');
setTimeout(function(){
jQuery(a,blocfrag).positionner(true)},10)}
else{
jQuery(blocfrag).positionner(false)}
updateReaderBuffer()}
var ajax_env=(""+blocfrag.attr('class')).match(/env-([^ ]+)/);
if(!ajax_env||ajax_env==undefined)return;
ajax_env=ajax_env[1];
if(ajaxbloc_selecteur==undefined)
ajaxbloc_selecteur='.pagination a,a.ajax';
jQuery(ajaxbloc_selecteur,this).not('.noajax').each(function(){
var url=this.href.split('#');
url[0]+=(url[0].indexOf("?")>0?'&':'?')+'var_ajax=1&var_ajax_env='+encodeURIComponent(ajax_env);
if(url[1])
url[0]+="&var_ajax_ancre="+url[1];
if(jQuery(this).is('.preload')&&!preloaded_urls[url[0]]){
jQuery.ajax({"url":url[0],"success":function(r){preloaded_urls[url[0]]=r}})}
jQuery(this).click(function(){
if(!ajax_confirm){
ajax_confirm=true;
var d=new Date();
if((d.getTime()-ajax_confirm_date)<=2)
return false}
jQuery(blocfrag)
.animeajax()
.addClass('loading');
if(preloaded_urls[url[0]]){
on_pagination(preloaded_urls[url[0]]);
triggerAjaxLoad(document)}else{
jQuery.ajax({
url:url[0],
success:function(c){
on_pagination(c);
preloaded_urls[url[0]]=c}
})}
return false})}).addClass('noajax');jQuery('form.bouton_action_post.ajax:not(.noajax)',this).each(function(){
var leform=this;
var url=jQuery(this).attr('action').split('#');
jQuery(this)
.prepend("<input type='hidden' name='var_ajax' value='1' /><input type='hidden' name='var_ajax_env' value='"+(ajax_env)+"' />"+(url[1]?"<input type='hidden' name='var_ajax_ancre' value='"+url[1]+"' />":""))
.ajaxForm({
beforeSubmit:function(){
jQuery(blocfrag).addClass('loading').animeajax()},
success:function(c){
on_pagination(c);
preloaded_urls={};jQuery(blocfrag)
.ajaxbloc()},
iframe:jQuery.browser.msie
})
.addClass('noajax')})})};
jQuery(function(){
jQuery('form:not(.bouton_action_post)').parents('div.ajax')
.formulaire_dyn_ajax();
jQuery('div.ajaxbloc').ajaxbloc()});
onAjaxLoad(function(){
if(jQuery){
jQuery('form:not(.bouton_action_post)',this).parents('div.ajax')
.formulaire_dyn_ajax();
jQuery('div.ajaxbloc',this)
.ajaxbloc()}
});


/* page=chess.js */
;
var chess_queryStringSeparator='&';
var chess_cssPath='http://www.lmpe.org/spip.php?page=chess.css';
var chess_imageFolder='http://www.lmpe.org/plugins/auto/chess/images/';
var DHTMLGoodies=new Object();
if(!String.trim)String.prototype.trim=function(){return this.replace(/^\s+|\s+$/,'')};
var D_chessObjects=new Array();
var ChessWidgetEventFuncs=new Object();
DHTMLGoodies.ChessPgn=function(props)
{
var pgnFile;
var gameList;
var ajaxObjects;
var serverFile;
var gameDetails;
var cachedGameList;
var numberOfGames;
var pgnTimeStamps;
this.pgnTimeStamps=new Object();
this.gameDetails=new Array();
this.cachedGameList=new Object();
this.numberOfGames=new Object();
this.serverFile='chess.php';
this.ajaxObjects=new Array();
if(props)this.__setInitialProperties(props);
this.objectIndex=D_chessObjects.length;
D_chessObjects[this.objectIndex]=this}
DHTMLGoodies.ChessPgn.prototype={
__setInitialProperties:function(props)
{
if(props.pgnFile)this.pgnFile=props.pgnFile;
if(props.serverFile)this.serverFile=props.serverFile}
,
__getGameDetails:function(gameIndex,jsOnComplete,liveUpdateMode)
{
if(this.gameDetails[gameIndex]&&!liveUpdateMode){
this.__returnGameDetailsFromCache(gameIndex,jsOnComplete);
return}
var objIndex=this.objectIndex;
var index=this.ajaxObjects.length;
this.ajaxObjects[index]=new sack();
this.ajaxObjects[index].method='GET';
this.ajaxObjects[index].requestFile=this.serverFile;
this.ajaxObjects[index].setVar('getGameDetails','1');
this.ajaxObjects[index].setVar('pgnFile',this.pgnFile);
this.ajaxObjects[index].setVar('gameIndex',gameIndex);
this.ajaxObjects[index].setVar('liveUpdateMode',liveUpdateMode?'1':'0');
if(!this.pgnTimeStamps[this.pgnFile+'_'+gameIndex]||!this.gameDetails[gameIndex])this.pgnTimeStamps[this.pgnFile+'_'+gameIndex]=0;
this.ajaxObjects[index].setVar('timestamp',this.pgnTimeStamps[this.pgnFile+'_'+gameIndex]);
this.ajaxObjects[index].onCompletion=function(){D_chessObjects[objIndex].__returnGameDetails(gameIndex,index,jsOnComplete)}
this.ajaxObjects[index].onError=function(){D_chessObjects[objIndex].__ajaxError()}
this.ajaxObjects[index].runAJAX()}
,
__isNumberOfGamesSet:function()
{
return(this.numberOfGames[this.pgnFile]?true:false)}
,
__getNumberOfGames:function()
{
return this.numberOfGames[this.pgnFile]}
,
__getNumberOfGamesFromServer:function(jsOnComplete)
{
if(this.numberOfGames[this.pgnFile]){
this.__returnNumberOfGamesFromCache(jsOnComplete);
return}
var objIndex=this.objectIndex;
var index=this.ajaxObjects.length;
this.ajaxObjects[index]=new sack();
this.ajaxObjects[index].method='GET';
this.ajaxObjects[index].requestFile=this.serverFile;
this.ajaxObjects[index].setVar('getNumberOfGames','1');
this.ajaxObjects[index].setVar('pgnFile',this.pgnFile);
this.ajaxObjects[index].onCompletion=function(){D_chessObjects[objIndex].__returnNumberOfGames(index,jsOnComplete)}
this.ajaxObjects[index].onError=function(){this.__ajaxError()}
this.ajaxObjects[index].runAJAX()}
,
__returnNumberOfGames:function(ajaxIndex,jsOnComplete)
{
this.numberOfGames[this.pgnFile]=this.ajaxObjects[ajaxIndex].response;
eval(jsOnComplete+'('+this.ajaxObjects[ajaxIndex].response+')')}
,
__returnNumberOfGamesFromCache:function(jsOnComplete)
{
eval(jsOnComplete+'('+this.numberOfGames[this.pgnFile]+')')}
,
__returnGameDetails:function(gameIndex,index,jsOnComplete)
{
try{
var obj=eval('('+this.ajaxObjects[index].response+')');
if(!obj.result)obj.result='*'}catch(e){
self.status='Error in returned JSON string';
return}
if(!obj){
eval(jsOnComplete+'(false)');
return}
this.gameDetails[gameIndex]=obj;
this.__setPgnTimestamp(gameIndex);
if(jsOnComplete.indexOf('(')>=0){
jsOnComplete=jsOnComplete.replace(')','');
eval(jsOnComplete+',this.gameDetails['+gameIndex+'])')}else{
eval(jsOnComplete+'(this.gameDetails['+gameIndex+'])')}
}
,
__setPgnTimestamp:function(gameIndex)
{
var d=new Date();
this.pgnTimeStamps[this.pgnFile+'_'+gameIndex]=Math.floor(d.getTime()/1000)}
,
__returnGameDetailsFromCache:function(gameIndex,jsOnComplete)
{
if(jsOnComplete.indexOf('(')>=0){
jsOnComplete=jsOnComplete.replace(')','');
eval(jsOnComplete+',this.gameDetails['+gameIndex+'])')}else{
eval(jsOnComplete+'(this.gameDetails['+gameIndex+'])')}
}
,
__getGameList:function(jsOnComplete)
{
if(this.cachedGameList[this.pgnFile]){
this.__returnGameListFromCache(jsOnComplete);
return}
var objIndex=this.objectIndex;
var index=this.ajaxObjects.length;
this.ajaxObjects[index]=new sack();
this.ajaxObjects[index].method='GET';
this.ajaxObjects[index].requestFile=this.serverFile;
this.ajaxObjects[index].setVar('getGameList','1');
this.ajaxObjects[index].setVar('pgnFile',this.pgnFile);
this.ajaxObjects[index].onCompletion=function(){D_chessObjects[objIndex].__returnGameList(index,jsOnComplete)}
this.ajaxObjects[index].onError=function(){D_chessObjects[objIndex].__ajaxError()}
this.ajaxObjects[index].runAJAX()}
,
__returnGameList:function(index,jsOnComplete)
{
this.cachedGameList[this.pgnFile]=this.ajaxObjects[index].response;
if(jsOnComplete.indexOf('(')>=0){
jsOnComplete=jsOnComplete.replace(')','');
eval(jsOnComplete+',this.ajaxObjects['+index+'].response)')}else{
eval(jsOnComplete+'(this.ajaxObjects['+index+'].response)')}
}
,
__returnGameListFromCache:function(jsOnComplete)
{
if(jsOnComplete.indexOf('(')>=0){
jsOnComplete=jsOnComplete.replace(')','');
eval(jsOnComplete+',this.cachedGameList[this.pgnFile])')}else{
eval(jsOnComplete+'(this.cachedGameList[this.pgnFile])')}
}
,
__ajaxError:function()
{
alert('Could not complete ajax request for '+this.pgnFile)}
,
__setPgnFile:function(pgnFile)
{
this.gameList=new Array();
this.gameDetails=new Array();
this.pgnFile=pgnFile}
}
DHTMLGoodies.Chess=function(props)
{
var divBoard;
var divBoardOuter;
var cssPath;
var parentRef;
var squareSize;
var imageFolder;
var isOldMSIE;
var boardLabels;
var flipBoardWhenBlackToStart;
var flipBoardWhenBlackWins;
var flipBoard;
var divIndicators;
var indicateLastMove;
var coordLastMove;
var animate;
var animationSpeed;
var autoplayDelayBeforeComments;
var stopAutoplayBeforeComments;
var soundEmbed;
var liveUpdateInterval;
var dataForLiveUpdate;
var isBusyWithLiveUpdate;
var languageCode;
var chessSet;
var pgnObject;
var colorLightSquares;
var colorDarkSquares;
var pieces;
var objectIndex;
var currentGameIndex;
var currentMove;
var currentColor;
var currentMoveNumber;
var currentVariationMove;
var currentVariationColor;
var currentVariationMoveNumber;
var dragProperties;
var animateNextMove;
var isBusy;
var currentZIndex;
var lastMoveEnPassant;
var currentHighlightInlineMove;
var currentHighlightTableMove;
var currentHihglightInlineVariationMove;
var currentHighlightedGame;
var previousClassHighlighedGame;
var elPlayerNames;
var elMovesInline;
var elMovesInTable;
var elMovesInTableMaxMovesPerTable;
var keyboardSupport;
var elActiveMove;
var elActivePgnFile;
var elActiveComment;
var elGameAttributes;
var insideVariation;
var displayPrefaceCommentWithInlineMoves;
var slideCoordinates;
var eventElements;
var dragAndDropColor;
var sound;
var officers;
this.dataForLiveUpdate=new Object();
this.dragAndDropColor=false;
this.eventElements=new Array();
this.slideCoordinates=new Array();
this.dragProperties=new Object();
this.animationSpeed=1;
this.liveUpdateInterval=0;
this.elMovesInTable=new Array();
this.languageCode=chess_languageCode;
this.officers=new Object();
this.officers.en=['B','R','Q','N','K'];
this.officers.no=['L','T','D','S','K'];
this.officers.fr=['F','T','D','C','R'];
this.officers.it=['A','T','D','C','R'];
this.officers.es=['A','T','D','C','R'];
this.officers.de=['L','T','D','S','K'];
this.currentMoveNumber=1;
this.divIndicators=new Object();
this.chessSet='alpha';
this.squareSize=60;
this.elMovesInTableMaxMovesPerTable=900;
this.keyboardSupport=true;
this.isOldMSIE=(navigator.userAgent.toLowerCase().match(/msie\s[0-6]/gi))?true:false;
this.isMSIE=(navigator.userAgent.toLowerCase().indexOf('msie')>=0)?true:false;
this.isOpera=(navigator.userAgent.toLowerCase().indexOf('opera')>=0)?true:false;
this.isFirefox=(navigator.userAgent.toLowerCase().indexOf('firefox')>=0)?true:false;
this.elGameAttributes=new Object();
this.stopAutoplayBeforeComments=false;
this.displayPrefaceCommentWithInlineMoves=true;
this.currentGameIndex=false;
this.animationSetTimeout=13;
this.insideVariation=false;
this.indicateLastMove=true;
this.coordLastMove=new Object();
this.coordLastMove.from=new Object();
this.coordLastMove.to=new Object();
this.animate=true;
this.cssPath=chess_cssPath;
this.parentRef=document.body;
this.imageFolder=chess_imageFolder;
this.boardLabels=true;
this.flipBoardWhenBlackToStart=true;
this.flipBoardWhenBlackWins=true;
this.flipBoard=false;
this.animateNextMove=false;
this.isBusy=false;
this.currentZIndex=20000;
this.lastMoveEnPassant=false;
this.autoPlayDelayBetweenMoves=0.5;
this.autoPlayActive=false;
this.gameListProperties=new Object();
this.objectIndex=D_chessObjects.length;
this.sound=false;
D_chessObjects[this.objectIndex]=this;
if(props)this.__setInitProps(props);
this.pgnObject=new DHTMLGoodies.ChessPgn(props);
this.__init()}
DHTMLGoodies.Chess.prototype={
setAutoPlayDelayBetweenMoves:function(autoPlayDelayBetweenMoves){
if(autoPlayDelayBetweenMoves<0.1)autoPlayDelayBetweenMoves=0.1;
this.autoPlayDelayBetweenMoves=autoPlayDelayBetweenMoves}
,
setDragAndDropColor:function(dragAndDropColor){
this.dragAndDropColor=dragAndDropColor}
,
setPgn:function(pgnFile)
{
if(this.isBusy||this.autoPlayActive)return;
this.currentGameIndex=false;
this.__clearGameDetails();
this.__clearCurrentVariationVariables();
this.pgnObject.__setPgnFile(pgnFile);
this.__handleCallback('switchPgn')}
,
__displayActivePgnFileProperty:function(){
if(this.elActivePgnFile){
try{
this.elActivePgnFile.innerHTML=this.pgnObject.pgnFile.replace(/^.*\/(.*)$/g,'$1')}catch(e){
}
}
}
,
setSquareSize:function(squareSize)
{
if(this.isBusy||this.autoPlayActive)return;
var toMove=this.currentMove;
var toColor=this.currentColor;
this.squareSize=squareSize;
this.__clearBoard();
if(this.currentGameIndex===false){
this.__createDefaultPieces();
return}
this.parentRef.className='ChessBoardParentContainer'+squareSize;
try{
this.parentRef.parentNode.className=' ChessBoardParentOfParentContainer'+squareSize}catch(e){
}
if(this.pgnObject.gameDetails[this.currentGameIndex].fen){
this.displayBoardByFen(this.pgnObject.gameDetails[this.currentGameIndex].fen,this.parentRef)}else{
this.__createDefaultPieces()}
if(this.insideVariation){
this.goToVariationMove(this.currentVariationMove,this.currentVariationColor,this.insideVariation.move,this.insideVariation.color,this.insideVariation.variationIndex)}else{
if(toMove==0)this.currentMove=0;
if(toMove>0)this.goToMove(toMove,toColor)}
this.__createIndicators();
this.__indicateLastMove()}
,
setChessSet:function(chessSet)
{
if(this.isBusy||this.autoPlayActive)return;
this.chessSet=chessSet;
var toMove=this.currentMove;
var toColor=this.currentColor;
this.__clearBoard();
if(this.currentGameIndex===false){
this.__createDefaultPieces();
return}
if(this.pgnObject.gameDetails[this.currentGameIndex].fen){
this.displayBoardByFen(this.pgnObject.gameDetails[this.currentGameIndex].fen,this.parentRef)}else{
this.__createDefaultPieces()}
if(this.insideVariation){
this.goToVariationMove(this.currentVariationMove,this.currentVariationColor,this.insideVariation.move,this.insideVariation.color,this.insideVariation.variationIndex)}else{
if(toMove==0)this.currentMove=0;
if(toMove>0)this.goToMove(toMove,toColor)}
}
,
flip:function()
{
if(this.isBusy||this.autoPlayActive)return;
if(this.flipBoard){
this.flipBoard=false}else{
this.flipBoard=true}
var toMove=this.currentMove;
var toColor=this.currentColor;
this.__clearBoard();
if(this.currentGameIndex===false){
this.__createDefaultPieces();
return}
if(this.pgnObject.gameDetails[this.currentGameIndex].fen){
this.displayBoardByFen(this.pgnObject.gameDetails[this.currentGameIndex].fen,this.parentRef)}else{
this.__createDefaultPieces()}
if(this.insideVariation){
this.goToVariationMove(this.currentVariationMove,this.currentVariationColor,this.insideVariation.move,this.insideVariation.color,this.insideVariation.variationIndex)}else{
if(toMove==0)this.currentMove=0;
if(toMove>0)this.goToMove(toMove,toColor)}
}
,
getNextMove:function()
{
var move=this.__getNextMove();
return move.notation}
,
getResult:function()
{
if(this.currentGameIndex===false)return false;
if(!this.pgnObject.gameDetails[this.currentGameIndex].result)return false;
return this.pgnObject.gameDetails[this.currentGameIndex].result.trim()}
,
getPgnFile:function()
{
return this.pgnObject.pgnFile}
,
getStartColor:function()
{
return this.whoToStartMove=='w'?'white':'black'}
,
__init:function()
{
this.__loadCss(this.cssPath);
this.__addSoundEffects();
this.__addGeneralEvents();
this.__createLiveUpdateHandler();
this.__addKeyboardSupport()}
,
setFlipBoardWhenBlackToStart:function(flipBoardWhenBlackToStart)
{
this.flipBoardWhenBlackToStart=flipBoardWhenBlackToStart}
,
setFlipBoardWhenBlackWins:function(flipBoardWhenBlackWins)
{
this.flipBoardWhenBlackWins=flipBoardWhenBlackWins}
,
getCurrentFen:function()
{
}
,
getCurrentGameIndex:function()
{
return this.currentGameIndex}
,
showRandomGame:function()
{
if(this.pgnObject.__isNumberOfGamesSet()){
var numGames=this.pgnObject.__getNumberOfGames();
var gameIndex=Math.floor(Math.random()*numGames);
return this.showGame(gameIndex)}else{
var ind=this.objectIndex;
this.pgnObject.__getNumberOfGamesFromServer('D_chessObjects['+ind+'].__showRandomGame')}
}
,
__showRandomGame:function(numberOfGames)
{
if(numberOfGames)this.showRandomGame()}
,
showGame:function(gameIndex)
{
this.__handleCallback('beforeGameLoad');
this.currentGameIndex=gameIndex;
this.__clearCurrentVariationVariables();
this.__clearDragProperties();
var ind=this.objectIndex;
this.dataForLiveUpdate.liveUpdateGameIndexBefore=this.currentGameIndex;
this.pgnObject.__getGameDetails(gameIndex,'D_chessObjects['+ind+'].__showGame',false);
return gameIndex}
,
__addKeyboardSupport:function()
{
if(!this.keyboardSupport)return;
var ind=this.objectIndex;
document.documentElement.onkeydown=function(e){return D_chessObjects[ind].__handleKeyboard(e)}}
,
__handleKeyboard:function(e)
{
if(document.all)e=event;
if(e.keyCode==39||e.keyCode==102){
this.move(1);
return false}
if(e.keyCode==37||e.keyCode==100){
this.move(-1);
return false}
if(e.ctrlKey&&e.shiftKey&&e.keyCode==70){
this.flip()}
}
,
__getNewGameData:function()
{
if(this.isBusy||this.autoPlayActive||this.isBusyWithLiveUpdate)return;
if(this.currentGameIndex===false)return;
this.isBusyWithLiveUpdate=true;
var lastMove=this.__getLastMove();
this.dataForLiveUpdate.moveAfterLiveUpdate=false;
this.dataForLiveUpdate.moveAfterLiveUpdate=false;
this.dataForLiveUpdate.lastMoveBeforeUpdate=this.__getLastPlayedMove();
this.dataForLiveUpdate.liveUpdateGameIndexBefore=this.currentGameIndex;
if(this.currentMove==lastMove.move&&this.currentColor==lastMove.color)this.dataForLiveUpdate.moveAfterLiveUpdate=true;
if(lastMove.move==0)this.dataForLiveUpdate.moveAfterLiveUpdate=true;
var ind=this.objectIndex;
this.pgnObject.__getGameDetails(this.currentGameIndex,'D_chessObjects['+ind+'].__receiveLiveGameUpdate',true)}
,
__receiveLiveGameUpdate:function(details)
{
this.isBusyWithLiveUpdate=false;
if(!details)return;
if(this.dataForLiveUpdate.liveUpdateGameIndexBefore!=this.currentGameIndex)return;
var lastMove=this.__getLastMove();
var lastPlayedMove=this.__getLastPlayedMove();
this.__displayGameDetails();
if(lastPlayedMove.move!=this.dataForLiveUpdate.lastMoveBeforeUpdate.move||lastPlayedMove.color!=this.dataForLiveUpdate.lastMoveBeforeUpdate.color)this.dataForLiveUpdate.moveAfterLiveUpdate=false;
if(lastPlayedMove.move>lastMove.move||(lastPlayedMove.move==lastMove.move&&lastMove.color=='white'&&lastPlayedMove.color=='black')){
this.__clearBoard();
this.__createDefaultPieces();
this.goToMove(lastMove.move,lastMove.color)}else{
this.goToMove(this.dataForLiveUpdate.lastMoveBeforeUpdate.move,this.dataForLiveUpdate.lastMoveBeforeUpdate.color)}
this.__highlightActiveMove(this.currentMove,this.currentColor);
if(this.dataForLiveUpdate.moveAfterLiveUpdate)this.autoPlay()}
,
displayGameListInSelect:function(selectRef)
{
if(this.isBusy||this.autoPlayActive)return;
var ind=this.objectIndex;
this.pgnObject.__getGameList('D_chessObjects['+ind+'].__displayGameListInSelect("'+selectRef+'")');
this.__displayActivePgnFileProperty()}
,
__displayGameListInSelect:function(selectRef,json)
{
selectRef=this.__getEl(selectRef);
var ind=this.objectIndex;
selectRef.setAttribute('objectIndex',ind);
selectRef.onchange=this.__showGameFromSelect;
this.__addEventEl(selectRef);
selectRef.options.length=0;
var ind=this.objectIndex;
try{
var gameList=eval('('+json+')')}catch(e){
alert(json)}
for(var no in gameList){
selectRef.options[selectRef.options.length]=new Option(gameList[no].white+' vs. '+gameList[no].black,no)}
}
,
__showGameFromSelect:function()
{
var objectIndex=this.getAttribute('objectIndex');
D_chessObjects[objectIndex].showGame(this.options[this.selectedIndex].value)}
,
displayGameListInTable:function(tableRef,props,viewProperties)
{
if(this.isBusy||this.autoPlayActive)return;
if(props&&!this.__isArray(props)){
props=props.split(/,/g)}
tableRef=this.__getEl(tableRef);
this.__clearTBodyRows(tableRef);
var ind=this.objectIndex;
var arrayString='';
if(!props){
props=['view','white','black','result']}
for(var no=0;no<props.length;no++){
if(no==0)arrayString='[';else arrayString=arrayString+',';
arrayString=arrayString+'"'+props[no]+'"'}
if(arrayString)arrayString=arrayString+']';
if(viewProperties)this.gameListProperties=viewProperties;
this.pgnObject.__getGameList('D_chessObjects['+ind+'].__displayGameListInTable("'+tableRef.id+'",'+arrayString+')');
this.__displayActivePgnFileProperty()}
,
__displayGameListInTable:function(tableRef,props,json)
{
tableRef=this.__getEl(tableRef);
var ind=this.objectIndex;
try{
var gameList=eval('('+json+')')}catch(e){
alert(json)}
this.__clearTBodyRows(tableRef);
var tbody=tableRef.getElementsByTagName('tbody')[0];
if(!tbody){
alert('Your game list table is missing a <tbody> element. Please insert it');
return}
var counter=0;
var d=new Date();
var start=d.getTime();
var currentRowClassName='GameListOddRow';
var tableContent='';
var rowTemplate='<tr id="ChessGameList<ID>" class="<CLASSNAME>">';
for(var no2=0;no2<props.length;no2++){
for(var no2=0;no2<props.length;no2++){
if(props[no2]=='view'){
rowTemplate=rowTemplate+'<td><a href="#" id="game<ID>" onclick="D_chessObjects['+ind+'].showGame(<ID>);return false" title="<PROPERTY_title>"><PROPERTY_view></a></td>'}else{
rowTemplate=rowTemplate+'<td><PROPERTY_'+props[no2]+'></td>'}
}
}
rowTemplate+='</TR>';
for(var no in gameList){
currentRowClassName=(currentRowClassName=='GameListOddRow'?'GameListEvenRow':'GameListOddRow');
var thisRow=rowTemplate;
thisRow=rowTemplate.replace(/<ID>/g,no);
thisRow=thisRow.replace(/<CLASSNAME>/g,currentRowClassName);
var txt=this.gameListProperties.viewGameLink;
if(txt=='gameNumber')txt=(no/1+1)+'';
thisRow=thisRow.replace('<PROPERTY_title>',this.gameListProperties.viewGameTitle);
thisRow=thisRow.replace('<PROPERTY_view>',txt);
for(var no2=0;no2<props.length;no2++){
thisRow=thisRow.replace('<PROPERTY_'+props[no2]+'>',gameList[no][props[no2]])}
tableContent=tableContent+thisRow}
this.__replaceTbody(tableContent,tableRef);
var d2=new Date();
var end=d2.getTime();
return}
,
__showGame:function(details)
{
if(this.dataForLiveUpdate.liveUpdateGameIndexBefore!=this.currentGameIndex)return;
this.flipBoard=false;
this.stopAutoPlay();
if(details.fen){
this.__setWhoToMoveFromFen(details.fen);
if(this.whoToStartMove=='b'&&this.flipBoardWhenBlackToStart)this.flipBoard=true;
this.__clearBoard();
this.displayBoardByFen(details.fen,this.parentRef)}else{
this.__setWhoToMoveFromResult(details.fen);
if(this.whoToStartMove=='b'&&this.flipBoardWhenBlackWins)this.flipBoard=true;
this.__clearBoard();
this.__createDefaultPieces()}
this.currentMove=0;
this.currentColor=this.whoToStartMove=='w';
this.__clearDisplayedActiveMove();
this.__highlightActiveGame();
this.__displayGameDetails();
this.__handleCallback('startGame')}
,
__clearGameDetails:function()
{
this.__clearMoveDetails();
for(var prop in this.elGameAttributes){
try{
this.__getEl(this.elGameAttributes[prop]).innerHTML=''}catch(e){
}
}
if(this.elPlayerNames)this.elPlayerNames.innerHTML=''}
,
__displayGameDetails:function()
{
this.__clearGameDetails();
this.__displayMoveDetails();
var gameDetails=this.pgnObject.gameDetails[this.currentGameIndex];
for(var prop in this.elGameAttributes){
if(gameDetails[prop.toLowerCase()]){
try{
var el=this.__getEl(this.elGameAttributes[prop]);
el.innerHTML=gameDetails[prop.toLowerCase()]}catch(e){
}
}
}
if(this.elPlayerNames){
this.elPlayerNames.innerHTML=this.pgnObject.gameDetails[this.currentGameIndex].white+' vs. '+this.pgnObject.gameDetails[this.currentGameIndex].black}
}
,
__highlightActiveGame:function()
{
if(this.currentHighlightedGame){
this.currentHighlightedGame.className=this.previousClassHighlighedGame}
if(document.getElementById('ChessGameList'+this.currentGameIndex)){
this.currentHighlightedGame=document.getElementById('ChessGameList'+this.currentGameIndex);
if(this.currentHighlightedGame.className!='ActiveGameInTable')this.previousClassHighlighedGame=this.currentHighlightedGame.className;
this.currentHighlightedGame.className='ActiveGameInTable'}
}
,
__clearMoveDetails:function()
{
if(this.elMovesInline)this.elMovesInline.innerHTML='';
if(this.elMovesInTable){
for(var no=0;no<this.elMovesInTable.length;no++){
this.__clearTBodyRows(this.elMovesInTable[no])}
}
}
,
__clearCurrentVariationVariables:function()
{
this.insideVariation=false;
this.currentVariationMove=0;
this.currentVariationColor='white';
this.currentVariationMoveNumber=false}
,
__setStartVariationVariables:function(moveRoot,moveRootColor,variationIndex)
{
this.insideVariation={move:moveRoot,color:moveRootColor,variationIndex:variationIndex};
var variations=this.pgnObject.gameDetails[this.currentGameIndex].moves[moveRoot][moveRootColor].variation[variationIndex];
for(var prop in variations){
this.currentVariationMoveNumber=prop*2;
this.currentVariationMove=prop/1;
this.currentVariationColor='white';
if(!variations[prop].white){
this.currentVariationMoveNumber++;
this.currentVariationColor='black'}
break}
if(this.currentVariationColor=='black'){
this.currentVariationColor='white'}else{
this.currentVariationColor='black';
this.currentVariationMove--}
}
,
goToVariationMove:function(move,color,moveRoot,moveRootColor,variationIndex)
{
var goToMove=moveRoot;
var goToColor=moveRootColor;
var goToMoveNumber=(move*2)+(color=='black'?1:0);
if(goToColor=='black'){
goToColor='white'}else{
goToColor='black';
goToMove--}
var animateNext=this.animateNextMove;
this.animateNextMove=false;
if(this.insideVariation&&(this.insideVariation.move!=moveRoot||this.insideVariation.color!=moveRootColor||this.insideVariation.variationIndex!=variationIndex)){
this.goToMove(goToMove,goToColor);
this.__clearCurrentVariationVariables();
this.__setStartVariationVariables(moveRoot,moveRootColor,variationIndex)}
if(!this.insideVariation){
this.goToMove(goToMove,goToColor);
this.__setStartVariationVariables(moveRoot,moveRootColor,variationIndex)}
if(this.insideVariation&&goToMoveNumber<this.currentVariationMoveNumber){
this.goToMove(goToMove,goToColor);
this.__setStartVariationVariables(moveRoot,moveRootColor,variationIndex)}
this.animateNextMove=animateNext;
var variations=this.pgnObject.gameDetails[this.currentGameIndex].moves[moveRoot][moveRootColor].variation[variationIndex];
var pieceMoved=false;
for(var no=this.currentVariationMoveNumber;no<=goToMoveNumber;no++){
pieceMoved=true;
var moveNumber=Math.floor(no/2);
var moveToColor=no%2==1?'black':'white';
if(variations[moveNumber][moveToColor]){
this.__parseAMove(variations[moveNumber][moveToColor],moveToColor);
this.currentVariationMove=moveNumber;
this.currentVariationColor=moveToColor;
this.currentVariationMoveNumber=no}
}
this.currentVariationMoveNumber++;
this.__indicateLastMove();
this.__highlightActiveVariationMove(move,color,moveRoot,moveRootColor)}
,
__getMoveDetailsForVariation:function(variationObj,move,color)
{
var ind=this.objectIndex;
var retValue='';
for(var variationIndex in variationObj){
var aVariation=variationObj[variationIndex]
var ret='';
for(var prop in aVariation){
if(ret)ret=ret+' ';else ret='[';
if(aVariation[prop].white){
ret=ret+prop+'. <a class="InlineVariationMove" href="#" id="InlineVariationMove_'+move+'_'+color+'_'+variationIndex+'_'+prop+'_'+'white" onclick="D_chessObjects['+ind+'].goToVariationMove(\''+prop+'\',\'white\',\''+move+'\',\''+color+'\',\''+variationIndex+'\');return false">'+this.__getAMoveInLanguage(aVariation[prop].white)+'</a>';
if(aVariation[prop].black){
ret=ret+' <a class="InlineVariationMove" href="#" id="InlineVariationMove_'+move+'_'+color+'_'+variationIndex+'_'+prop+'_'+'black" onclick="D_chessObjects['+ind+'].goToVariationMove(\''+prop+'\',\'black\',\''+move+'\',\''+color+'\',\''+variationIndex+'\');return false">'+this.__getAMoveInLanguage(aVariation[prop].black)+'</a>'}
}else{
ret=ret+prop+'... <a class="InlineVariationMove" href="#" id="InlineVariationMove_'+move+'_'+color+'_'+variationIndex+'_'+prop+'_'+'black" onclick="D_chessObjects['+ind+'].goToVariationMove(\''+prop+'\',\'black\',\''+move+'\',\''+color+'\',\''+variationIndex+'\');return false">'+this.__getAMoveInLanguage(aVariation[prop].black)+'</a>'}
}
ret=ret+'] ';
ret=' <span class="InlineChessVariationBlock">'+ret+'</span>';
retValue=retValue+ret}
return retValue}
,
__getClassNameOfInlineMove:function(move)
{
var ret='InlineChessMove_plainMove';
if(move.indexOf('!')>=0)ret='InlineChessMove_goodMove';
if(move.indexOf('!!')>=0)ret='InlineChessMove_veryGoodMove';
if(move.indexOf('?')>=0)ret='InlineChessMove_badMove';
if(move.indexOf('??')>=0)ret='InlineChessMove_veryBadMove';
if(move.indexOf('!?')>=0)ret='InlineChessMove_supriseMove';
if(move.indexOf('?!')>=0)ret='InlineChessMove_questionableMove';
return ret}
,
__getAMoveInLanguage:function(move)
{
if(this.languageCode=='en')return move;
for(var no=0;no<this.officers.en.length;no++){
move=move.replace(this.officers.en[no],this.officers[this.languageCode][no])}
return move}
,
__displayMoveDetails:function()
{
this.__clearGameDetails();
var moves=this.pgnObject.gameDetails[this.currentGameIndex].moves;
var ind=this.objectIndex;
if(this.elMovesInline){
var moveStr='';
if(this.pgnObject.gameDetails[this.currentGameIndex].prefaceComment&&this.displayPrefaceCommentWithInlineMoves){
moveStr=moveStr+'<span class="InlineChessComment">'+this.pgnObject.gameDetails[this.currentGameIndex].prefaceComment+'</span> '}
for(var prop in moves){
if(moveStr)moveStr=moveStr+' ';
if(moves[prop].white){
var className=this.__getClassNameOfInlineMove(moves[prop].white.move);
moveStr=moveStr+prop+'.'+'<a class="'+className+'" id="InlineChessMove'+prop+'white" href="#" onclick="D_chessObjects['+ind+'].goToMove(\''+prop+'\',\'white\');return false">'+this.__getAMoveInLanguage(moves[prop].white.move)+'</a>';
if(moves[prop].white.comment){
moveStr=moveStr+' <span class="InlineChessComment">'+moves[prop].white.comment+'</span> '}
if(moves[prop].white.variation){
moveStr=moveStr+this.__getMoveDetailsForVariation(moves[prop].white.variation,prop,'white')}
if(moves[prop].black){
var className=this.__getClassNameOfInlineMove(moves[prop].black.move);
moveStr=moveStr+' '+'<a class="'+className+'" id="InlineChessMove'+prop+'black" href="#" onclick="D_chessObjects['+ind+'].goToMove(\''+prop+'\',\'black\');return false">'+this.__getAMoveInLanguage(moves[prop].black.move)+'</a>';
if(moves[prop].black.comment){
moveStr=moveStr+' <span class="InlineChessComment">'+moves[prop].black.comment+'</span> '}
if(moves[prop].black.variation){
moveStr=moveStr+this.__getMoveDetailsForVariation(moves[prop].black.variation,prop,'black')}
}
}else{
var className=this.__getClassNameOfInlineMove(moves[prop].black.move);
moveStr=moveStr+prop+' ...'+'<a class="'+className+'" id="InlineChessMove'+prop+'black" href="#" onclick="D_chessObjects['+ind+'].goToMove(\''+prop+'\',\'black\');return false">'+this.__getAMoveInLanguage(moves[prop].black.move)+'</a>';
if(moves[prop].black.comment){
moveStr=moveStr+' <span class="InlineChessComment">'+moves[prop].black.comment+'</span> '}
if(moves[prop].black.variation){
moveStr=moveStr+this.__getMoveDetailsForVariation(moves[prop].black.variation,prop,'black')}
}
}
moveStr=moveStr+' '+this.pgnObject.gameDetails[this.currentGameIndex].result;
this.elMovesInline.innerHTML=moveStr}
if(this.elMovesInTable[0]){
var tbody=this.elMovesInTable[0].getElementsByTagName('TBODY')[0];
if(!tbody){
alert('Cannot display moves inside a table because it is missing a <tbody> element');
return}
var tableCounter=0;
var moveCounter=1;
for(var prop in moves){
if(moveCounter>this.elMovesInTableMaxMovesPerTable){
tableCounter++;
moveCounter=1;
var tbody=this.elMovesInTable[tableCounter].getElementsByTagName('TBODY')[0]}
var row=document.createElement('TR');
tbody.appendChild(row);
var cell=document.createElement('TD');
cell.innerHTML=prop;
row.appendChild(cell);
if(moves[prop].white){
var cell=document.createElement('TD');
cell.innerHTML='<a id="TableChessMove'+prop+'white" href="#" onclick="D_chessObjects['+ind+'].goToMove(\''+prop+'\',\'white\');return false">'+this.__getAMoveInLanguage(moves[prop].white.move)+'</a>';
row.appendChild(cell);
if(moves[prop].black){
var cell=document.createElement('TD');
cell.innerHTML='<a id="TableChessMove'+prop+'black" href="#" onclick="D_chessObjects['+ind+'].goToMove(\''+prop+'\',\'black\');return false">'+this.__getAMoveInLanguage(moves[prop].black.move)+'</a>';
row.appendChild(cell)}
}else{
var cell=document.createElement('TD');
cell.innerHTML='...';
row.appendChild(cell);
if(moves[prop].black){
var cell=document.createElement('TD');
cell.innerHTML='<a id="TableChessMove'+prop+'black" href="#" onclick="D_chessObjects['+ind+'].goToMove(\''+prop+'\',\'black\');return false">'+this.__getAMoveInLanguage(moves[prop].black.move)+'</a>';
row.appendChild(cell)}
}
moveCounter++}
}
}
,
__showGameLink:function()
{
var ind=this.getAttribute('objectIndex');
D_chessObjects[ind].showGame(this.id.replace(/[^0-9]/g,''))}
,
moveToStart:function()
{
if(this.currentGameIndex===false||this.isBusy)return;
if(!this.pgnObject.gameDetails[this.currentGameIndex].moves[1])return;
if(this.pgnObject.gameDetails[this.currentGameIndex].fen){
this.displayBoardByFen(this.pgnObject.gameDetails[this.currentGameIndex].fen,this.parentRef)}else{
this.__createDefaultPieces()}
if(this.insideVariation){
var firstMove=this.__getFirstVariationMove(this.insideVariation.move,this.insideVariation.color,this.insideVariation.variationIndex);
this.goToVariationMove(firstMove.move,firstMove.color,this.insideVariation.move,this.insideVariation.color,this.insideVariation.variationIndex)
}else{
this.currentMove=0;
this.currentColor=0;
this.currentMoveNumber=1;
var tmpColor='white';
if(!this.pgnObject.gameDetails[this.currentGameIndex].moves[1].white)tmpColor='black';
this.__highlightActiveMove(0,tmpColor);
this.__displayActiveMove(1,tmpColor);
this.__playSound('startGame')}
}
,
moveToEnd:function()
{
if(this.currentGameIndex===false||this.isBusy)return;
if(!this.pgnObject.gameDetails[this.currentGameIndex].moves[1])return;
var moveObj=this.pgnObject.gameDetails[this.currentGameIndex].moves;
if(this.insideVariation){
var lastMove=this.__getLastVariationMove(this.insideVariation.move,this.insideVariation.color,this.insideVariation.variationIndex);
this.goToVariationMove(lastMove.move,lastMove.color,this.insideVariation.move,this.insideVariation.color,this.insideVariation.variationIndex)}else{
var lastMove=this.__getLastMove();
this.goToMove(lastMove.move,lastMove.color)}
}
,
__getLastMove:function()
{
var moveObj=this.pgnObject.gameDetails[this.currentGameIndex].moves;
var lastMove=false;
for(var prop in moveObj){
lastMove=prop}
if(lastMove===false)return{move:0,color:'white'}
var ret=new Object();
ret.move=lastMove;
if(moveObj[lastMove].black)ret.color='black';else ret.color='white';
return ret}
,
__getFirstVariationMove:function(moveRoot,moveRootColor,variationIndex)
{
var moveObj=this.pgnObject.gameDetails[this.currentGameIndex].moves[moveRoot][moveRootColor].variation[variationIndex];
for(var prop in moveObj){
lastMove=prop;
break}
var ret=new Object();
ret.move=lastMove;
if(!lastMove)return'white';
if(moveObj[lastMove].black)ret.color='black';else ret.color='white';
return ret}
,
__getLastVariationMove:function(moveRoot,moveRootColor,variationIndex)
{
var moveObj=this.pgnObject.gameDetails[this.currentGameIndex].moves[moveRoot][moveRootColor].variation[variationIndex];
for(var prop in moveObj){
lastMove=prop}
var ret=new Object();
ret.move=lastMove;
if(!lastMove)return'white';
if(moveObj[lastMove].black)ret.color='black';else ret.color='white';
return ret}
,
move:function(moves)
{
if(this.currentGameIndex===false||this.isBusy)return;
if(!this.pgnObject.gameDetails[this.currentGameIndex].moves[1])return;
var fullMoves=Math.floor(Math.abs(moves)/2);
var halfMoves=Math.abs(moves)%2;
if(this.insideVariation){
var color=this.currentVariationColor;
var move=this.currentVariationMove}else{
var color=this.currentColor;
var move=this.currentMove}
if(moves>0){
if(halfMoves==1){
if(color=='white'){
color='black'}else{
color='white';
move++}
}
}
if(moves<0){
fullMoves*=-1;
if(halfMoves==1){
if(color=='black'){
color='white'}else{
color='black';
move--}
}
}
move+=fullMoves;
if(this.insideVariation){
if(move<=this.insideVariation.move){
if(color=='white'&&this.insideVariation.color=='black')return;
if(move<this.insideVariation.move)return}
if(moves>0){
var lastMove=this.__getLastVariationMove(this.insideVariation.move,this.insideVariation.color,this.insideVariation.variationIndex)}
}else{
if(move<=0){
this.moveToStart();
this.__hideIndicators();
return}
if(moves>0){
var lastMove=this.__getLastMove()}
}
this.animateNextMove=false;
if(this.animate&&moves==1)this.animateNextMove=true;
if(moves>0){
if(move>=lastMove.move){
if(move>lastMove.move){
move=lastMove.move/1;
color=lastMove.color;
this.animateNextMove=false;
if(moves==1)return}else{
move=lastMove.move/1;
if(color=='black'&&lastMove.color=='white'){
color='white';
this.animateNextMove=false}
}
}
}
if(this.insideVariation){
if(moves!=0){
this.goToVariationMove(move,color,this.insideVariation.move,this.insideVariation.color,this.insideVariation.variationIndex)}
}else{
if(moves!=0){
if(moves>0&&move==1&&color=='white'&&!this.pgnObject.gameDetails[this.currentGameIndex].moves[1]['white'])color='black';
this.goToMove(move,color,moves)}
}
}
,
autoPlay:function()
{
if(this.autoPlayActive||this.currentGameIndex===false)return;
if(!this.pgnObject.gameDetails[this.currentGameIndex].moves[1])return;
this.autoPlayActive=true;
var moveDetails=this.__getNextMove();
var move=moveDetails.move;
var color=moveDetails.color;
this.__autoPlayStep(move,color)}
,
__autoPlayStep:function(move,color)
{
if(this.insideVariation){
var moveObj=this.pgnObject.gameDetails[this.currentGameIndex].moves[this.insideVariation.move][this.insideVariation.color].variation[this.insideVariation.variationIndex];
if(moveObj[move]&&moveObj[move][color]){
this.move(1)}else{
this.stopAutoPlay();
this.__handleCallback('stopAutoPlay')}
}else{
if(this.pgnObject.gameDetails[this.currentGameIndex]&&this.pgnObject.gameDetails[this.currentGameIndex].moves[move]&&this.pgnObject.gameDetails[this.currentGameIndex].moves[move][color]){
this.move(1)}else{
this.stopAutoPlay();
this.__handleCallback('stopAutoPlay')}
}
}
,
stopAutoPlay:function()
{
this.autoPlayActive=false}
,
goToMove:function(moveNumber,color,direction)
{
if(this.currentGameIndex===false||this.isBusy||!moveNumber){
this.__hideIndicators();
return}
if(!this.pgnObject.gameDetails[this.currentGameIndex].moves[1])return;
var tmpNo=(moveNumber*2)+(color=='black'?1:0);
if(tmpNo<this.currentMoveNumber||this.insideVariation){
this.__clearBoard();
if(this.pgnObject.gameDetails[this.currentGameIndex].fen){
this.displayBoardByFen(this.pgnObject.gameDetails[this.currentGameIndex].fen,this.parentRef)}else{
this.__createDefaultPieces()}
this.currentColor=this.whoToStartMove}
if(tmpNo==this.currentMoveNumber-1)return;
var tmpColor;
if(this.currentColor=='w')tmpColor='white';else tmpColor='black';
for(var no=this.currentMoveNumber;no<tmpNo;no++){
var tmpColor=(no%2==1?'white':'black');
var moveIndex=Math.ceil(no/2);
if(no==tmpNo-1){
this.__highlightActiveMove(moveIndex,tmpColor);
this.__displayActiveMove(moveIndex,tmpColor)}
if(this.pgnObject.gameDetails[this.currentGameIndex].moves[moveIndex]&&this.pgnObject.gameDetails[this.currentGameIndex].moves[moveIndex][tmpColor])this.__parseAMove(this.pgnObject.gameDetails[this.currentGameIndex].moves[moveIndex][tmpColor].move,tmpColor)}
var indicate=true;
if(direction<0&&moveNumber==1){
if(color=='white')indicate=false;
if(color=='black'&&!this.pgnObject.gameDetails[this.currentGameIndex].moves[1].white)indicate=false}
if(indicate)this.__indicateLastMove();
this.currentMoveNumber=moveNumber*2+(color=='black'?1:0);
this.currentMove=moveNumber/1;
this.currentColor=color;
this.__clearCurrentVariationVariables();
if(this.autoPlayActive&&!this.animate){
var moveDetails=this.__getNextMove();
var autoplayDelay=this.__getAutoPlayDelayBeforeNextMove();
if(this.stopAutoplayBeforeComments&&this.pgnObject.gameDetails[this.currentGameIndex].moves[this.currentMove][this.currentColor].comment){
this.stopAutoPlay();
return}
var ind=this.objectIndex;
setTimeout('D_chessObjects['+ind+'].move(1)',autoplayDelay)}
}
,
__getAutoPlayDelayBeforeNextMove:function()
{
if(this.autoplayDelayBeforeComments&&this.pgnObject.gameDetails[this.currentGameIndex].moves[this.currentMove][this.currentColor].comment){
var autoplayDelay=(this.autoplayDelayBeforeComments*1000)}else{
var autoplayDelay=(this.autoPlayDelayBetweenMoves*1000)}
return autoplayDelay}
,
__highlightActiveMove:function(moveIndex,color)
{
if(this.currentHighlightInlineMove){
try{
var className=this.currentHighlightInlineMove.className.replace(' ActiveInlineChessMove','');
var className=className.replace(' ActiveInlineVariationChessMove','');
className=className.trim();
this.currentHighlightInlineMove.className=className}catch(e){
}
}
if(this.currentHighlightTableMove){
try{
this.currentHighlightTableMove.className=''}catch(e){
}
}
if(document.getElementById('InlineChessMove'+moveIndex+color)){
this.currentHighlightInlineMove=document.getElementById('InlineChessMove'+moveIndex+color);
var newClass=this.currentHighlightInlineMove.className+' ActiveInlineChessMove';
this.currentHighlightInlineMove.className=newClass;
this.__autoScrollContainerInlineMove(this.currentHighlightInlineMove)}
if(document.getElementById('TableChessMove'+moveIndex+color)){
this.currentHighlightTableMove=document.getElementById('TableChessMove'+moveIndex+color);
this.currentHighlightTableMove.className='ActiveTableChessMove';
this.__autoScrollContainerTableMove(this.currentHighlightTableMove)}
}
,
__highlightActiveVariationMove:function(moveIndex,color,moveRoot,colorRoot)
{
this.__highlightActiveMove(0,'white');
var idOfEl='InlineVariationMove_'+this.insideVariation.move+'_'+this.insideVariation.color+'_'+this.insideVariation.variationIndex+'_'+moveIndex+'_'+color;
if(document.getElementById(idOfEl)){
this.currentHighlightInlineMove=document.getElementById(idOfEl);
this.currentHighlightInlineMove.className=this.currentHighlightInlineMove.className+' ActiveInlineVariationChessMove';
this.__autoScrollContainerInlineMove(this.currentHighlightInlineMove)}
}
,
__autoScrollContainerTableMove:function(el)
{
try{
var parent=el.parentNode.parentNode;
el=el.parentNode;
while(parent!=this.elMovesInTable[0]&&parent.tagName.toLowerCase()!='body')parent=parent.parentNode;
var overflow=this.__getStyle(parent,'overflow');
if(overflow&&(overflow!='auto'||overflow!='scroll')){
parent=parent.parentNode;
var overflow=this.__getStyle(parent,'overflow')}
if(el.offsetTop>(parent.clientHeight+parent.scrollTop-el.offsetHeight-2)){
parent.scrollTop=(el.offsetTop-parent.clientHeight+el.offsetHeight+2)}
}catch(e){
}
}
,
__autoScrollContainerInlineMove:function(el)
{
var parent=el.parentNode;
while(parent!=this.elMovesInline)parent=parent.parentNode;
if(el.offsetTop>(parent.clientHeight+parent.scrollTop-el.offsetHeight-2)){
parent.scrollTop=(el.offsetTop-parent.clientHeight+el.offsetHeight+2)}
}
,
__clearDisplayedActiveMove:function()
{
if(this.elActiveMove){
this.elActiveMove.innerHTML=''}
if(this.elActiveComment){
this.elActiveComment.innerHTML=''}
}
,
__displayActiveMove:function(moveIndex,color)
{
if(this.elActiveMove){
var move=this.__getAMoveInLanguage(this.pgnObject.gameDetails[this.currentGameIndex].moves[moveIndex][color].move);
if(color=='black')move='... '+move;else move='. '+move;
move=moveIndex+move;
this.elActiveMove.innerHTML=move}
if(this.elActiveComment){
var move=this.pgnObject.gameDetails[this.currentGameIndex].moves[moveIndex][color];
if(move.comment){
this.elActiveComment.innerHTML=move.comment}else{
this.elActiveComment.innerHTML=''}
}
}
,
__getInfoByMoveString:function(move,color)
{
var write=false;
if(move=='hxg8Q+')write=true;
move=move.replace(/[\#\+]/gi,'');
if(move.length==3&&move.match(/^[a-h][18][BRNQ]$/)){
move=move.substr(0,2)+'='+move.substr(2,1)}
var capture=(move.indexOf('x')>=0)?true:false;
var castle=(move.indexOf('0')>=0)?true:false;
if(!castle){
castle=(move.indexOf('O')>=0)?true:false}
var pawnMove=move.substr(0,1).match(/[abcdefgh]/);
var officer=move.substr(0,1).match(/[BKQNR]/g);
var promote=move.match(/=/);
if(pawnMove&&move.substr(move.length-1,1).match(/[BKQNR]/)){
promote=true;
officer=false}
var fromRank=false;
var rankMatches=move.match(/[0-9]/g);
if(rankMatches&&rankMatches.length>1){
fromRank=rankMatches[0]}
if(promote){
pawnMove=true;
officer=false}
if(officer)pawnMove=false;
var fromFile=false;
var fileMatches=move.match(/[a-h]/g);
if(fileMatches&&fileMatches.length>1){
fromFile=fileMatches[0]}
if(pawnMove){
if(move.indexOf('x')>=0){
fromFile=move.replace(/^([a-h]).*$/,'$1')}else{
fromFile=move.replace(/[^a-h]/g,'')}
fromRank=move.replace(/[^0-9]/g,'');
if(color=='black')fromRank=fromRank/1+1;else fromRank=fromRank/1-1}
var ret=new Object();
ret.fromFile=fromFile;
ret.fromRank=fromRank;
ret.castle=castle;
ret.officer=officer;
ret.pawnMove=pawnMove;
ret.capture=capture;
ret.promote=promote;
return ret}
,
__parseAMove:function(move,color)
{
this.lastMoveEnPassant=false;
this.lastMovePawnPromote=false;
this.currentlyParsedMove=move;
var opositeColor=(color=='white')?'black':'white';
if(move.substr(move.length-1,1)=='='){
move=move.substr(0,move.length-1)}
move=move.replace(/\-\/?\+/g,'')
move=move.replace(/\+\/?\-/g,'')
var moveInfo=this.__getInfoByMoveString(move);
move=move.replace(/[\#\+!\?]/gi,'');
if(!moveInfo.castle){
var toSquare=move.replace(/=[BKQNR][+\#]?/g,'');
toSquare=toSquare.replace(/[\#+]/g,'');
toSquare=toSquare.substr(toSquare.length-2,2)}
if(moveInfo.pawnMove){
var numericPos=move.replace(/[^0-9]/g,'');
if(!moveInfo.capture){
var pieceIndex=this.__movePawnForward(move,color);
if(pieceIndex||pieceIndex==0)this.__movePieceToLocation(color,pieceIndex,move)}else{
var pieceIndex=this.__movePawnCapture(move,moveInfo.fromFile,color,true)}
if(moveInfo.promote){
var obj=this.pieces[color][pieceIndex];
var promoteTo=move.replace(/[^NBRQ]/g,'').toLowerCase();
this.__removePieceFromBoard(pieceIndex,color);
var ind=this.__createPieceByPromotion(obj.file,obj.rank,color,promoteTo);
this.lastMovePawnPromote=true}
}
if(moveInfo.officer){
var pieceType=move.substr(0,1).toLowerCase();
if(moveInfo.capture){
var el=this.__getPieceOnSquare(toSquare,opositeColor);
this.__removePieceFromBoard(el,opositeColor)}
this.__moveOfficer(toSquare,color,moveInfo.fromFile,moveInfo.fromRank,pieceType)}
if(moveInfo.castle){
var matches=move.match(/\-/g);
var rank=(color=='white')?1:8;
if(matches.length>1){
this.__moveOfficer('d'+rank,color,'a',false,'r');
this.__moveOfficer('c'+rank,color,false,false,'k')}else{
this.__moveOfficer('f'+rank,color,'h',false,'r');
this.__moveOfficer('g'+rank,color,false,false,'k')}
}
}
,
__createPieceByPromotion:function(file,rank,color,promoteTo)
{
if(color=='white')color='w';else color='b';
col=this.__getColFromFile(file)+((8-rank)*8);
col--;
var el=document.createElement('div');
el.style.width=this.squareSize+'px';
el.style.height=this.squareSize+'px';
el.style.position='absolute';
this.divBoard.appendChild(el);
var img=document.createElement('img');
img.src=this.imageFolder+this.chessSet+this.squareSize+color+promoteTo.toLowerCase()+'.png';
el.appendChild(img);
var pos=this.__getBoardPosByCol(col);
if(this.isOldMSIE&&!this.isOpera)this.correctPng(img);
el.style.left=pos.x+'px';
el.style.top=pos.y+'px';
if(this.animateNextMove)el.style.display='none';
var index=this.__addPieceToArray(color,promoteTo,col,el);
this.__addEventToChessPiece(el,color,index);
return index}
,
__moveOfficer:function(toSquare,color,fromFile,fromRank,pieceType)
{
for(counter=0;counter<this.pieces[color].length;counter++){
var obj=this.pieces[color][counter];
if(fromFile&&obj.file!=fromFile)continue;
if(fromRank&&obj.rank!=fromRank)continue;
if(obj.pieceType==pieceType){
if(this.__canPieceMoveToSquare(color,counter/1,toSquare)){
this.__movePieceToLocation(color,counter,toSquare);
return}
}
}
}
,
__canPieceMoveToSquare:function(color,index,toSquare,recursive)
{
var opositeColor=color=='white'?'black':'white';
var obj=this.pieces[color][index];
if(!obj.onBoard)return false;
var toPos=this.__getColAndRowFromSquare(toSquare);
var currCol=this.__getColFromFile(obj.file);
var currRow=obj.rank;
var diffTo=Math.max(toPos.col,currCol)-Math.min(toPos.col,currCol);
var diffFrom=Math.max(toPos.row,currRow)-Math.min(toPos.row,currRow);
if(obj.pieceType=='b'||obj.pieceType=='q'){
if(diffTo==diffFrom){
if(!this.__occupiedSquaresBetween({'col':toPos.col,'row':toPos.row},{'col':currCol,'row':currRow})){
if(recursive)return true;
if(!this.__isMovingIntoCheckByMovingThisPiece(obj,color,toSquare))return true}
}
}
if(obj.pieceType=='r'||obj.pieceType=='q'){
if(diffTo==0||diffFrom==0){
if(!this.__occupiedSquaresBetween({'col':toPos.col,'row':toPos.row},{'col':currCol,'row':currRow})){
if(recursive)return true;
if(!this.__isMovingIntoCheckByMovingThisPiece(obj,color,toSquare))return true}
}
}
if(obj.pieceType=='k'){
return true}
if(obj.pieceType=='n'){
if(diffFrom==2&&diffTo==1){
if(recursive)return true;
if(!this.__isMovingIntoCheckByMovingThisPiece(obj,color,toSquare))return true}
if(diffTo==2&&diffFrom==1){
if(recursive)return true;
if(!this.__isMovingIntoCheckByMovingThisPiece(obj,color,toSquare))return true}
}
return false}
,
__isMovingIntoCheckByMovingThisPiece:function(pieceObj,color,toSquare)
{
var checkBefore=this.__isKingInCheck(color);
if(checkBefore)return false;
pieceObj.onBoard=false;
var opositeColor=color=='white'?'black':'white';
var elOnDestSquare=this.__getPieceOnSquare(toSquare,opositeColor);
if(elOnDestSquare||elOnDestSquare===0){
this.pieces[opositeColor][elOnDestSquare].onBoard=false}
var checkAfter=this.__isKingInCheck(color);
pieceObj.onBoard=true;
if(checkAfter){
var savedFile=pieceObj.file;
var savedRank=pieceObj.rank;
pieceObj.file=toSquare.substr(0,1);
pieceObj.rank=toSquare.substr(1,1);
var checkAfter=this.__isKingInCheck(color);
pieceObj.file=savedFile;
pieceObj.rank=savedRank}
if(elOnDestSquare||elOnDestSquare===0){
this.pieces[opositeColor][elOnDestSquare].onBoard=true}
return checkAfter}
,
__isKingInCheck:function(color)
{
var kingObj;
for(var no=0;no<this.pieces[color].length;no++){
if(this.pieces[color][no].pieceType=='k'){
kingObj=this.pieces[color][no];
break}
}
var kingRow=kingObj.rank;
var kingCol=this.__getColFromFile(kingObj.file);
var opositeColor=color=='white'?'black':'white';
for(var no=0;no<this.pieces[opositeColor].length;no++){
var piece=this.pieces[opositeColor][no];
if(!piece.onBoard)continue;
if(piece.pieceType=='b'||piece.pieceType=='q'||piece.pieceType=='r'){
var ret=this.__canPieceMoveToSquare(opositeColor,no,kingObj.file+kingObj.rank,true);
if(ret){
return true}
}
}
return false}
,
__occupiedSquaresBetween:function(from,to)
{
var squares=this.__getSquaresBetween(from,to);
for(var squareCounter=0;squareCounter<squares.length;squareCounter++){
var el=this.__getPieceOnSquare(squares[squareCounter],'white');
if(el||el===0)return true;
var el=this.__getPieceOnSquare(squares[squareCounter],'black');
if(el||el===0)return true}
return false}
,
__getSquaresBetween:function(from,to)
{
var retArray=new Array();
if(from.row==to.row){
var min=Math.min(from.col,to.col)+1;
var max=Math.max(from.col,to.col)-1;
if(max<min==1)return false;
for(var counter=min;counter<=max;counter++){
retArray[retArray.length]=this.__getFileByCol(counter)+''+to.row}
return retArray}else if(from.col==to.col){
var file=this.__getFileByCol(from.col);
var min=Math.min(from.row,to.row)+1;
var max=Math.max(from.row,to.row)-1;
if(max<min==1)return false;
for(var counter=min;counter<=max;counter++){
retArray[retArray.length]=file+''+counter}
return retArray}else{
var moveX=1;
var moveY=1;
if(from.col>to.col)moveX=-1;
if(from.row>to.row)moveY=-1;
var min=Math.min(from.col,to.col);
var max=Math.max(from.col,to.col);
var diff=max-min;
for(var counter=1;counter<diff;counter++){
var file=from.col+(counter*moveX);
var rank=from.row+(counter*moveY);
file=this.__getFileByCol(file);
retArray[retArray.length]=file+''+rank}
return retArray}
}
,
__movePawnForward:function(move,color)
{
move=move.replace(/[^0-9a-h]/g,'');
var file=move.replace(/[0-9]/g,'');
var rank=move.replace(/[^0-9]/g,'');
for(var no=0;no<this.pieces[color].length;no++){
var obj=this.pieces[color][no];
if(!obj.onBoard)continue;
var rankMatch=false;
if(color=='white'&&obj.rank<rank)rankMatch=true;
if(color=='black'&&obj.rank>rank)rankMatch=true;
var maxRankDiff=1;
if(color=='white'){
if(rank==4)maxRankDiff=2;
if(rank-obj.rank>maxRankDiff)rankMatch=false}
if(color=='black'){
if(rank==5)maxRankDiff=2;
if(obj.rank-rank>maxRankDiff)rankMatch=false}
if(rankMatch){
var colFrom=this.__getColFromFile(file);
var colTo=this.__getColFromFile(obj.file);
if(this.__occupiedSquaresBetween({'col':colFrom,'row':rank},{'col':colTo,'row':obj.rank})){
rankMatch=false}
}
if(obj.pieceType=='p'&&obj.file==file&&rankMatch){
return no}
}
return false}
,
__movePawnCapture:function(move,fromFile,color,removePiece)
{
var opositeColor=(color=='white')?'black':'white';
var capturedSquare=move.replace(/.*?x([a-z][1-8]).*/g,'$1');
var el=this.__getPieceOnSquare(capturedSquare,opositeColor);
var retVal=this.__movePawn(fromFile,capturedSquare,color,removePiece);
if(el||el===0){
if(removePiece)this.__removePieceFromBoard(el,opositeColor)}else{
this.lastMoveEnPassant=true;
var file=capturedSquare.substr(0,1);
var rank=capturedSquare.substr(1,1);
if(color=='white')rank--;else rank++;
capturedSquare=file+''+rank;
var el=this.__getPieceOnSquare(capturedSquare,opositeColor);
if(el&&removePiece)this.__removePieceFromBoard(el,opositeColor)}
return retVal}
,
__movePawn:function(fromFile,toSquare,color,removePiece)
{
var rank=toSquare.substr(1,1)/1;
if(color=='white')rank--;else rank++;
var index=this.__getPieceOnSquare(fromFile+rank,color);
if(removePiece)this.__movePieceToLocation(color,index,toSquare);
return index}
,
__getPieceOnSquare:function(square,color)
{
var file=square.substr(0,1);
var rank=square.substr(1,1);
for(no=0;no<this.pieces[color].length;no++){
var obj=this.pieces[color][no];
if(!obj.onBoard)continue;
if(obj.file==file&&obj.rank==rank&&obj.onBoard)return no}
return false}
,
__getSlideCoordinates:function(from,to)
{
var diffX=Math.max(from.x,to.x)-Math.min(from.x,to.x);
var diffY=Math.max(from.y,to.y)-Math.min(from.y,to.y);
var aniSpeed=22.5*this.animationSpeed;
if(diffX>diffY){
if(diffX==0)diffX=1;
moveX=diffX/aniSpeed;
moveY=moveX*(diffY/diffX)}else{
if(diffY==0)diffY=1;
moveY=Math.ceil(diffY/aniSpeed);
moveX=moveY*(diffX/diffY)}
var directionX=1;
if(to.x<from.x)directionX=-1;
var directionY=1;
if(to.y<from.y)directionY=-1;
var retArray=new Array();
moveX=moveX*directionX;
moveY=moveY*directionY;
var counter=0;
while(Math.abs(moveX)<1&&Math.abs(moveY)<1&&counter<10){
moveX*=2;
moveY*=2;
counter++}
retArray[retArray.length]={x:from.x,y:from.y};
var finished=false;
var finishedX=false;
var finishedY=false;
if(directionY==0)finishedY=true;
if(directionX==0)finishedX=true;
var counter=0;
while(!finished){
if(moveX==0&&moveY==0)finished=true;
counter++;
if(counter>400){
alert('Infinite loop ('+moveX+','+moveY+')');
return}
from.x=from.x+moveX;
from.y=from.y+moveY;
if(directionY>0&&from.y>=to.y&&moveY!=0){
finishedY=true;
from.y=to.y;
from.x=to.x}else if(directionY<0&&from.y<=to.y&&moveY!=0){
finishedY=true;
from.y=to.y;
from.x=to.x}else if(directionX>0&&from.x>=to.x&&moveX!=0){
finishedX=true;
from.x=to.x;
from.y=to.y}else if(directionX<0&&from.x<=to.x&&moveX!=0){
finishedX=true;
from.x=to.x;
from.y=to.y}
retArray[retArray.length]={x:Math.round(from.x),y:Math.round(from.y)};
if(finishedX||finishedY)finished=true}
if(retArray.length<=2)retArray[retArray.length]={x:Math.round(from.x),y:Math.round(from.y)};
if(retArray.length<=2)alert('Length of array: '+retArray.length);
return retArray}
,
__onAnimatedMoveComplete:function()
{
this.__handleCallback('moveComplete');
var lastMove=this.__getLastMove();
var lastPlayedMove=this.__getLastPlayedMove();
this.__playSound();
if(lastMove.color==lastPlayedMove.color&&lastMove.move==lastPlayedMove.move)this.__handleCallback('afterLastMove')}
,
__movePieceToLocation:function(color,index,toSquare)
{
var pos=this.__getBoardPosByNotation(toSquare);
var el=this.pieces[color][index].el;
this.currentZIndex++;
el.style.zIndex=this.currentZIndex;
var fromPos=this.__getBoardPosByNotation(this.pieces[color][index].file+this.pieces[color][index].rank);
this.coordLastMove.from.x=fromPos.x;
this.coordLastMove.from.y=fromPos.y;
this.coordLastMove.to.x=pos.x;
this.coordLastMove.to.y=pos.y;
if(this.animateNextMove){
this.isBusy=true;
var currLeft=el.style.left.replace('px','')/1;
var currTop=el.style.top.replace('px','')/1;
var coordIndex=this.slideCoordinates.length;
this.slideCoordinates[coordIndex]=this.__getSlideCoordinates({x:currLeft,y:currTop},{x:pos.x,y:pos.y});
this.__slideElement(
{'coordIndex':coordIndex,'coordStep':1},
{'x':pos.x,'y':pos.y}
,
index,
color
)
}else{
el.style.left=pos.x+'px';
el.style.top=pos.y+'px'}
this.__updatePieceRankFileByPosition(index,color,{'x':pos.x,'y':pos.y})}
,
__slideElement:function(coordinateRef,to,index,color,dragDropVar,end,timeVar)
{
var ind=this.objectIndex;
var repeat=true;
if(coordinateRef.coordStep==this.slideCoordinates[coordinateRef.coordIndex].length-1)repeat=false;
this.pieces[color][index].el.style.left=this.slideCoordinates[coordinateRef.coordIndex][coordinateRef.coordStep].x+'px';
this.pieces[color][index].el.style.top=this.slideCoordinates[coordinateRef.coordIndex][coordinateRef.coordStep].y+'px';
if(repeat){
var jsonStr="{ coordIndex:"+coordinateRef.coordIndex+",coordStep:"+(coordinateRef.coordStep+1)+" },"
+"{ 'x':"+to.x+",'y':"+to.y+" },"
+"'"+index+"','"+color+"'";
if(dragDropVar){
jsonStr=jsonStr+",'"+dragDropVar+"'"}else{
jsonStr=jsonStr+",false"}
setTimeout('D_chessObjects['+ind+'].__slideElement('+jsonStr+')',this.animationSetTimeout);
return}else{
if(!dragDropVar){
this.slideCoordinates[coordinateRef.coordIndex]=null;
this.animateNextMove=false;
this.__indicateLastMove();
this.isBusy=false;
var opositeColor=(color=='white')?'black':'white';
var toSquare=this.__getNotationByBoardPos(to.x,to.y);
var pieceIndex=this.__getPieceOnSquare(toSquare,opositeColor);
if(pieceIndex||pieceIndex===0){
this.__removePieceFromBoard(pieceIndex,opositeColor)}else{
if(this.lastMoveEnPassant){
if(opositeColor=='black'){
toSquare=toSquare.substr(0,1)+(toSquare.substr(1,1)/1-1)}else{
toSquare=toSquare.substr(0,1)+(toSquare.substr(1,1)/1+1)}
var pieceIndex=this.__getPieceOnSquare(toSquare,opositeColor);
this.__removePieceFromBoard(pieceIndex,opositeColor)}
}
if(this.lastMovePawnPromote){
var pieceIndex=this.__getPieceOnSquare(toSquare,color);
this.__removePieceFromBoard(pieceIndex,color);
var pieceIndex=this.__getPieceOnSquare(toSquare,color);
this.pieces[color][pieceIndex].el.style.display='block'}
var moveComplete=true;
if(this.pieces[color][index].pieceType=='k'){
var lastMove=this.__getLastPlayedMove();
if(lastMove.moveString=='O-O'||lastMove.moveString=='O-O-O'||lastMove.moveString=='0-0'||lastMove.moveString=='0-0-0')moveComplete=false}
if(moveComplete)this.__onAnimatedMoveComplete();
if(this.autoPlayActive){
var moveDetails=this.__getNextMove();
var autoplayDelay=this.__getAutoPlayDelayBeforeNextMove();
if(this.stopAutoplayBeforeComments&&this.pgnObject.gameDetails[this.currentGameIndex].moves[this.currentMove][this.currentColor].comment){
this.stopAutoPlay();
return}
setTimeout('D_chessObjects['+ind+'].__autoPlayStep('+moveDetails.move+',"'+moveDetails.color+'")',autoplayDelay)}
}else{
if(dragDropVar!='sameSquare')this.__handleCallback('wrongMove');else this.__playSound('move')}
}
}
,
__removePieceFromBoard:function(pieceIndex,color)
{
if(this.animateNextMove)return;
try{
this.pieces[color][pieceIndex].onBoard=false;
this.pieces[color][pieceIndex].el.style.display='none'}catch(e){
}
}
,
__updatePieceRankFileByPosition:function(pieceIndex,color,position)
{
var files='abcdefgh';
var file=position.x/this.squareSize;
var rank=position.y/this.squareSize;
rank=8-rank;
if(this.flipBoard){
file=7-file;
rank=9-rank}
file=files.substr(file,1);
this.pieces[color][pieceIndex].file=file;
this.pieces[color][pieceIndex].rank=rank}
,
__indicateLastMove:function()
{
if(!this.divIndicators.from.parentNode)this.__createIndicators();
var fromStyle=this.divIndicators.from.style;
var toStyle=this.divIndicators.to.style;
if(this.indicateLastMove&&!this.animateNextMove){
fromStyle.display='block';
toStyle.display='block'}else{
this.__hideIndicators()}
try{
var borderWidth=this.__getStyle(this.divIndicators.to,'borderLeftWidth').replace('px','')/1}catch(e){
var borderWidth=2}
if(!borderWidth)borderWidth=(this.divIndicators['from'].offsetWidth-this.divIndicators['from'].clientWidth)/2;
var size=this.squareSize-(borderWidth*2);
if(this.coordLastMove.x||this.coordLastMove.y||this.coordLastMove.to.x||this.coordLastMove.to.y){
fromStyle.left=this.coordLastMove.from.x+'px';
fromStyle.top=this.coordLastMove.from.y+'px';
fromStyle.width=size+'px';
fromStyle.height=size+'px';
toStyle.left=this.coordLastMove.to.x+'px';
toStyle.top=this.coordLastMove.to.y+'px';
toStyle.width=size+'px';
toStyle.height=size+'px'}else{
this.__hideIndicators()}
}
,
__hideIndicators:function()
{
this.divIndicators.from.style.display='none';
this.divIndicators.to.style.display='none'}
,
setBoardLabels:function(boardLabels)
{
this.boardLabels=boardLabels}
,
displayBoardByFen:function(fenString,element)
{
element=this.__getEl(element);
element.innerHTML='';
this.__createBoardDiv(element);
this.__loadFen(fenString,this.divBoard);
this.__hideIndicators()}
,
__setWhoToMoveFromResult:function()
{
var det=this.pgnObject.gameDetails[this.currentGameIndex].result;
det=det.trim();
if(det=='0-1')this.whoToStartMove='b';else this.whoToStartMove='w'}
,
__setWhoToMoveFromFen:function(fenString)
{
try{
var items=fenString.split(/\s/g);
this.whoToStartMove=items[1].trim()}catch(e){
alert('Unable to parse FEN string');
return'w'}
}
,
__clearBoard:function()
{
this.parentRef.innerHTML='';
this.__createBoardDiv();
this.divBoard.innerHTML='';
this.__createSquares(this.divBoard);
if(!this.whoToStartMove)this.whoToStartMove='w';
this.currentMove=1;
this.currentColor=this.whoToStartMove;
this.currentMoveNumber=1}
,
__createDefaultPieces:function()
{
this.__clearBoard();
this.pieces=new Array();
this.pieces['white']=new Array();
this.pieces['black']=new Array();
var strPieces='rnbqkbnrpppppppp';
var color='b';
for(var no=0;no<strPieces.length;no++){
var character=strPieces.substr(no,1);
var el=document.createElement('div');
el.style.width=this.squareSize+'px';
el.style.height=this.squareSize+'px';
el.style.position='absolute';
this.divBoard.appendChild(el);
if(this.isMSIE){
var img=document.createElement('img');
img.src=this.imageFolder+this.chessSet+this.squareSize+color+character.toLowerCase()+'.png';
el.appendChild(img);
if(this.isOldMSIE&&!this.isOpera)this.correctPng(img)}else{
el.style.backgroundImage='url("'+this.imageFolder+this.chessSet+this.squareSize+color+character.toLowerCase()+'.png")'
}
var pos=this.__getBoardPosByCol(no);
el.style.left=pos.x+'px';
el.style.top=pos.y+'px';
var pieceIndex=this.__addPieceToArray('b',character.toLowerCase(),no,el);
this.__addEventToChessPiece(el,color,pieceIndex)}
var strPieces='pppppppprnbqkbnr';
var color='w';
for(var no=0;no<strPieces.length;no++){
var character=strPieces.substr(no,1);
var el=document.createElement('div');
el.style.width=this.squareSize+'px';
el.style.height=this.squareSize+'px';
el.style.position='absolute';
this.divBoard.appendChild(el);
if(this.isMSIE){
var img=document.createElement('img');
img.src=this.imageFolder+this.chessSet+this.squareSize+color+character.toLowerCase()+'.png';
el.appendChild(img);
if(this.isOldMSIE&&!this.isOpera)this.correctPng(img)}else{
el.style.backgroundImage='url("'+this.imageFolder+this.chessSet+this.squareSize+color+character.toLowerCase()+'.png")'
}
var pos=this.__getBoardPosByCol(no+48);
el.style.left=pos.x+'px';
el.style.top=pos.y+'px';
var pieceIndex=this.__addPieceToArray('w',character.toLowerCase(),(no+48),el);
this.__addEventToChessPiece(el,color,pieceIndex)}
}
,
__addPieceToArray:function(color,type,col,el)
{
if(color=='w')color='white';
if(color=='b')color='black';
var ind=this.pieces[color].length;
this.pieces[color][ind]=new Object();
this.pieces[color][ind]['pieceType']=type;
var pos=this.__getRankFileByCol(63-col);
this.pieces[color][ind]['file']=pos.file;
this.pieces[color][ind]['rank']=pos.rank;
this.pieces[color][ind]['el']=el;
this.pieces[color][ind]['onBoard']=true;
return ind}
,
__createBoardDiv:function(element)
{
if(!element)element=this.parentRef;
var boardOuter=document.createElement('DIV');
boardOuter.className='ChessBoard'+this.squareSize;
boardOuter.style.position='relative';
boardOuter.id=this.__getUniqueId();
this.labelDivRef=boardOuter.id;
var board=document.createElement('DIV');
board.className='ChessBoardInner'+this.squareSize;
board.style.width=(this.squareSize*8)+'px';
board.style.height=(this.squareSize*8)+'px';
this.divBoard=board;
this.divBoard.onselectstart=function(){return false}
this.__addEventEl(this.divBoard);
this.boardFrame=document.createElement('DIV');
this.boardFrame.className='ChessBoardFrame'+this.squareSize;
this.boardFrame.appendChild(board);
boardOuter.appendChild(this.boardFrame);
board.style.position='relative';
board.style.left='0px';
board.style.top='0px';
element.appendChild(boardOuter);
if(this.boardLabels){
this.boardFrame.style.position='absolute';
this.boardFrame.style.top='0px';
this.boardFrame.style.right='0px';
this.__addBoardLabels(boardOuter)}
this.__createSquares(this.divBoard);
this.__createIndicators();
return board}
,
__getUniqueId:function(){
var ret='UID'+Math.random()+''+Math.random();
return ret.replace(/\./g,'')}
,
showBoardLabels:function(){
var el=this.__getEl(this.labelDivRef);
this.boardLabels=true;
this.__addBoardLabels(el)}
,
hideBoardLabels:function(){
this.boardLabels=false;
var el=this.__getEl(this.labelDivRef);
var subDivs=el.getElementsByTagName('DIV');
for(var i=0;i<subDivs.length;i++){
if(subDivs[i].className.indexOf('ChessBoardLabel')>=0){
el.removeChild(subDivs[i]);
i--}
}
}
,
__createSquares:function(board)
{
currentBgColor=this.colorLightSquares;
currentBgImg=this.bgImageLightSquares;
currentClass='chessBoardSquare_light';
var lightIsArray=false;
var darkIsArray=false;
if(this.__isArray(this.bgImageLightSquares))lightIsArray=true;
if(this.__isArray(this.bgImageDarkSquares))darkIsArray=true;
var countLightSquares=0;
var countDarkSquares=0;
for(no=1;no<=64;no++){
var square=document.createElement('DIV');
square.style.cssText='float:left;width:'+this.squareSize+'px;height:'+this.squareSize+'px';
square.style.styleFloat='left';
square.style.width=this.squareSize+'px';
square.style.height=this.squareSize+'px';
square.className=currentClass;
if(currentBgColor)square.style.backgroundColor=currentBgColor;
if(currentBgImg)square.style.backgroundImage='url(\''+currentBgImg+'\')';
board.appendChild(square);
val=(no+Math.floor(no/8))%2;
if(val==0){
currentBgColor=this.colorLightSquares;
currentBgImg=this.bgImageLightSquares;
if(lightIsArray)currentBgImg=this.bgImageLightSquares[Math.floor(Math.random()*this.bgImageLightSquares.length)];
else currentBgImg=this.bgImageLightSquares;
currentClass='chessBoardSquare_light';
currentClass=currentClass+' chessBoardSquare_light_no'+(no%8)}else{
currentBgColor=this.colorDarkSquares;
if(darkIsArray)currentBgImg=this.bgImageDarkSquares[Math.floor(Math.random()*this.bgImageDarkSquares.length)];
else currentBgImg=this.bgImageDarkSquares;
currentClass='chessBoardSquare_dark';
currentClass=currentClass+' chessBoardSquare_dark_no'+(no%8)}
}
}
,
__addBoardLabels:function(boardOuter)
{
var letters='ABCDEFGH';
var borderWidth=this.__getStyle(this.divBoard,'borderLeftWidth').replace('px','')/1;
var posDiff=borderWidth?borderWidth:0;
try{
var left=this.__getLeftPos(this.divBoard);
var leftOuter=this.__getLeftPos(this.boardFrame);
posDiff+=left-leftOuter}catch(e){
}
for(var no=1;no<=8;no++){
var file=document.createElement('DIV');
file.style.position='absolute';
file.style.right=(((8-no)*this.squareSize)+posDiff)+'px';
file.style.bottom='0px';
file.innerHTML=letters.substr((no-1),1);
file.style.textAlign='center';
file.style.width=this.squareSize+'px';
boardOuter.appendChild(file);
file.className='ChessBoardLabel ChessBoardLabel'+this.squareSize;
file.id='ChessBoardLabel_'+(file.innerHTML);
var rank=document.createElement('DIV');
rank.style.position='absolute';
rank.style.left='0px';
rank.style.top=(((8-no)*this.squareSize)+posDiff)+'px';
rank.innerHTML=no;
rank.style.height=this.squareSize+'px';
rank.style.lineHeight=this.squareSize+'px';
boardOuter.appendChild(rank);
rank.className='ChessBoardLabel ChessBoardLabel'+this.squareSize;
rank.id='ChessBoardLabel_'+(rank.innerHTML);
if(this.flipBoard){
rank.innerHTML=9-no;
file.innerHTML=letters.substr((8-no),1)}
}
}
,
__loadFen:function(fenString,boardEl)
{
this.__setWhoToMoveFromFen(fenString);
var items=fenString.split(/\s/g);
var pieces=items[0];
this.pieces=new Array();
this.pieces['white']=new Array();
this.pieces['black']=new Array();
var currentCol=0;
for(var no=0;no<pieces.length;no++){
var character=pieces.substr(no,1);
if(character.match(/[A-Z]/i)){
var boardPos=this.__getBoardPosByCol(currentCol);
var piece=document.createElement('DIV');
piece.style.position='absolute';
piece.style.left=boardPos.x+'px';
piece.style.top=boardPos.y+'px';
if(character.match(/[A-Z]/)){
var color='w'}
if(character.match(/[a-z]/)){
var color='b'}
var img=document.createElement('IMG');
img.src=this.imageFolder+this.chessSet+this.squareSize+color+character.toLowerCase()+'.png';
piece.appendChild(img);
piece.className='ChessPiece'+this.squareSize;
boardEl.appendChild(piece);
var pieceIndex=this.__addPieceToArray(color,character.toLowerCase(),currentCol,piece);
this.__addEventToChessPiece(piece,color,pieceIndex);
currentCol++;
if(this.isOldMSIE&&!this.isOpera)this.correctPng(img)}
if(character.match(/[0-8]/))currentCol+=character/1}
}
,
__addEventToChessPiece:function(el,color,pieceIndex)
{
var ind=this.objectIndex;
el.onmousedown=this.__moveDownOnChessPiece;
el.onselectstart=this.__cancelEvent;
el.ondragstart=this.__cancelEvent;
this.__addEventEl(el);
el.setAttribute('objectIndex',ind);
el.setAttribute('color',color);
el.setAttribute('pieceIndex',pieceIndex)}
,
__getLastPlayedMove:function()
{
var ret=new Object();
if(this.insideVariation){
ret.color=this.currentVariationColor;
ret.move=this.currentVariationMove;
try{
ret.moveString=this.pgnObject.gameDetails[this.currentGameIndex].moves[this.insideVariation.move][this.insideVariation.color].variation[this.insideVariation.variationIndex][this.currentVariationMove][this.currentVariationColor]}catch(e){
}
}else{
ret.color=this.currentColor;
ret.move=this.currentMove;
try{
ret.moveString=this.pgnObject.gameDetails[this.currentGameIndex].moves[this.currentMove][this.currentColor].move}catch(e){
}
}
return ret}
,
__getNextMove:function()
{
if(this.currentGameIndex===false)return{move:0,color:'white'};
var ret=new Object();
if(this.insideVariation){
var move=this.currentVariationMove;
var color=this.currentVariationColor}else{
var move=this.currentMove;
var color=this.currentColor}
if(move==0){
move=1;
color='white';
if(!this.pgnObject.gameDetails[this.currentGameIndex].moves[1])color='white';
else if(!this.insideVariation&&!this.pgnObject.gameDetails[this.currentGameIndex].moves[1]['white'])color='black'}else{
if(color=='black'){
color='white';
move++}else{
color='black'}
}
ret.move=move;
ret.color=color;
var notationNextMove;
try{
if(this.insideVariation){
notationNextMove=this.pgnObject.gameDetails[this.currentGameIndex].moves[this.insideVariation.move][this.insideVariation.color].variation[this.insideVariation.variationIndex][move][color]}else{
notationNextMove=this.pgnObject.gameDetails[this.currentGameIndex].moves[move][color].move}
}catch(e){
return ret}
var squareInfo=this.__getSquareAndPieceByNotation(notationNextMove,color);
var moveInfo=this.__getInfoByMoveString(notationNextMove,color);
ret=moveInfo;
ret.notation=notationNextMove;
ret.toSquare=squareInfo.square;
ret.pieceType=squareInfo.pieceType;
if(moveInfo.pawnMove)ret.pieceType='p';
ret.move=move;
ret.color=color;
return ret}
,
__getSquareAndPieceByNotation:function(notation,color)
{
var ret=new Object();
notation=notation.trim();
notation=notation.replace(/[\+#]/g,'');
if(notation=='0-0'||notation=='O-O'){
ret.pieceType='k';
if(color=='white')ret.square='g1';else ret.square='g8';
return ret}
if(notation=='0-0-0'||notation=='O-O-O'){
ret.pieceType='k';
if(color=='white')ret.square='c1';else ret.square='c8';
return ret}
var piece=notation.replace(/[^BKQNR]/g,'');
if(!piece)piece='p';
piece=piece.toLowerCase();
var toSquare=notation.replace(/=[BKQNR][+\#]?/g,'');
toSquare=toSquare.replace(/[\#+]/g,'');
ret.square=toSquare.substr(toSquare.length-2,2);
ret.pieceType=piece;
return ret}
,
__getFileByCol:function(col)
{
var files='abcdefgh';
return files.substr(col-1,1)}
,
__getColFromFile:function(file)
{
var files='abcdefgh';
return files.indexOf(file)+1}
,
__getColAndRowFromSquare:function(square)
{
var file=square.substr(0,1);
var rank=square.substr(1,1)/1;
file=this.__getColFromFile(file);
var retArray=new Object();
retArray.col=file;
retArray.row=rank;
return retArray}
,
__getRankFileByCol:function(col)
{
var files='hgfedcba';
var rank=1;
while(col>=8){
rank++;
col-=8}
var ret=new Object();
ret.file=files.substr(col,1);
ret.rank=rank;
return ret}
,
__getNotationByBoardPos:function(x,y)
{
var files='abcdefgh';
var file=x/this.squareSize;
var rank=8-(y/this.squareSize);
if(this.flipBoard){
file=7-file;
rank=9-rank}
file=files.charAt(file);
return file+rank}
,
__getBoardPosByNotation:function(notation)
{
var files='abcdefgh';
notation=notation.replace(/[^0-9a-h]/g,'');
var y=notation.replace(/[^0-9]/gi,'')/1;
var file=notation.replace(/[0-9]/gi,'');
var x=files.indexOf(file)+1;
x--;
y=8-y;
if(this.flipBoard){
x=7-x;
y=7-y}
var retArray=new Object();
retArray.x=x*this.squareSize;
retArray.y=y*this.squareSize;
return retArray}
,
__getBoardPosByCol:function(col)
{
var rank=0;
while(col>=8){
rank++;
col-=8}
var retArray=new Object();
if(this.flipBoard){
col=7-col;
rank=7-rank}
retArray.x=col*this.squareSize;
retArray.y=rank*this.squareSize;
return retArray}
,
__loadCss:function(cssFile)
{
var lt=document.createElement('LINK');
lt.href=cssFile+chess_queryStringSeparator+'rand='+Math.random();
lt.rel='stylesheet';
lt.media='screen';
lt.type='text/css';
document.getElementsByTagName('HEAD')[0].appendChild(lt)}
,
__createIndicators:function()
{
this.divIndicators.from=document.createElement('DIV');
this.divIndicators.from.style.position='absolute';
this.divIndicators.from.className='ChessMoveIndicator';
this.divBoard.appendChild(this.divIndicators.from);
this.divIndicators.from.zIndex=9000000;
this.divIndicators.to=document.createElement('DIV');
this.divIndicators.to.className='ChessMoveIndicator';
this.divIndicators.to.style.position='absolute';
this.divBoard.appendChild(this.divIndicators.to);
this.divIndicators.to.zIndex=9000000;
this.divIndicators.to.style.width='100px';
this.divIndicators.to.style.height='100px'}
,
__handleCallback:function(action)
{
var callbackString='';
switch(action){
case'beforeGameLoad':
callbackString=this.callbackOnBeforeGameLoaded;
break;
case'startGame':
callbackString=this.callbackOnGameLoaded;
break;
case'switchPgn':
callbackString=this.callbackOnSwitchPgn;
break;
case'stopAutoPlay':
callbackString=this.callbackOnStopAutoPlay;
break;
case'moveComplete':
callbackString=this.callbackOnMoveComplete;
break;
case'wrongMove':
callbackString=this.callbackOnWrongMove;
break;
case'correctMove':
callbackString=this.callbackOnCorrectMove;
break;
case'afterLastMove':
callbackString=this.callbackAfterLastMove;
break}
if(callbackString){
if(callbackString.indexOf('(')==-1){
callbackString=callbackString+'(this.pgnObject.gameDetails['+this.currentGameIndex+'])'}
eval(callbackString)}
}
,
__getEl:function(elRef)
{
if(typeof elRef=='string'){
if(document.getElementById(elRef))return document.getElementById(elRef);
if(document.forms[elRef])return document.forms[elRef];
if(document[elRef])return document[elRef];
if(window[elRef])return window[elRef]}
return elRef}
,
__setInitProps:function(props)
{
if(props.cssPath)this.cssPath=props.cssPath;
if(props.imageFolder)this.imageFolder=props.imageFolder;
if(props.squareSize)this.squareSize=props.squareSize;
if(props.callbackOnGameLoaded)this.callbackOnGameLoaded=props.callbackOnGameLoaded;
if(props.callbackBeforeComments)this.callbackBeforeComments=props.callbackBeforeComments;
if(props.callbackOnBeforeGameLoaded)this.callbackOnBeforeGameLoaded=props.callbackOnBeforeGameLoaded;
if(props.callbackOnSwitchPgn)this.callbackOnSwitchPgn=props.callbackOnSwitchPgn;
if(props.callbackOnStopAutoPlay)this.callbackOnStopAutoPlay=props.callbackOnStopAutoPlay;
if(props.callbackOnWrongMove)this.callbackOnWrongMove=props.callbackOnWrongMove;
if(props.callbackOnCorrectMove)this.callbackOnCorrectMove=props.callbackOnCorrectMove;
if(props.callbackAfterLastMove)this.callbackAfterLastMove=props.callbackAfterLastMove;
if(props.autoPlayDelayBetweenMoves)this.autoPlayDelayBetweenMoves=props.autoPlayDelayBetweenMoves;
if(props.animationSpeed)this.animationSpeed=props.animationSpeed;
if(props.autoplayDelayBeforeComments)this.autoplayDelayBeforeComments=props.autoplayDelayBeforeComments;
if(props.stopAutoplayBeforeComments||props.stopAutoplayBeforeComments===false)this.stopAutoplayBeforeComments=props.stopAutoplayBeforeComments;
if(props.parentRef){
this.parentRef=this.__getEl(props.parentRef);
this.parentRef.className='ChessBoardParentContainer'+this.squareSize;
try{
this.parentRef.parentNode.className='ChessBoardParentOfParentContainer'+this.squareSize}catch(e){
}
}
if(props.boardLabels||props.boardLabels===false)this.boardLabels=props.boardLabels;
if(props.flipBoardWhenBlackToStart||props.flipBoardWhenBlackToStart===false)this.flipBoardWhenBlackToStart=props.flipBoardWhenBlackToStart;
if(props.chessSet)this.chessSet=props.chessSet;
if(props.elMovesInline)this.elMovesInline=this.__getEl(props.elMovesInline);
if(props.elMovesInTable){
if(this.__isArray(props.elMovesInTable)){
for(var no=0;no<props.elMovesInTable.length;no++){
this.elMovesInTable[no]=this.__getEl(props.elMovesInTable[no])}
}else{
this.elMovesInTable[0]=this.__getEl(props.elMovesInTable)}
}
if(props.elPlayerNames)this.elPlayerNames=this.__getEl(props.elPlayerNames);
if(props.elActiveMove)this.elActiveMove=this.__getEl(props.elActiveMove);
if(props.elActivePgnFile)this.elActivePgnFile=this.__getEl(props.elActivePgnFile);
if(props.elActiveComment)this.elActiveComment=this.__getEl(props.elActiveComment);
if(props.colorLightSquares||props.colorLightSquares=='')this.colorLightSquares=props.colorLightSquares;
if(props.colorDarkSquares||props.colorDarkSquares=='')this.colorDarkSquares=props.colorDarkSquares;
if(props.bgImageDarkSquares||props.bgImageDarkSquares=='')this.bgImageDarkSquares=props.bgImageDarkSquares;
if(props.bgImageLightSquares||props.bgImageLightSquares=='')this.bgImageLightSquares=props.bgImageLightSquares;
if(props.animate||props.animate===false)this.animate=props.animate;
if(props.sound||props.sound===false)this.sound=props.sound;
if(props.indicateLastMove||props.indicateLastMove===false)this.indicateLastMove=props.indicateLastMove;
if(props.displayPrefaceCommentWithInlineMoves||props.displayPrefaceCommentWithInlineMoves===false)this.displayPrefaceCommentWithInlineMoves=props.displayPrefaceCommentWithInlineMoves;
if(props.elGameAttributes)this.elGameAttributes=props.elGameAttributes;
if(props.dragAndDropColor)this.dragAndDropColor=props.dragAndDropColor;
if(props.liveUpdateInterval)this.liveUpdateInterval=props.liveUpdateInterval;
if(props.elMovesInTableMaxMovesPerTable)this.elMovesInTableMaxMovesPerTable=props.elMovesInTableMaxMovesPerTable;
if(props.languageCode)this.languageCode=props.languageCode;
if(props.keyboardSupport||props.keyboardSupport===false)this.keyboardSupport=props.keyboardSupport}
,
__isDragOk:function(color,pieceIndex)
{
if(this.currentGameIndex===false||this.isBusy||this.autoPlayActive)return false;
var nextMove=this.__getNextMove();
if(color!=nextMove.color)return false;
if(color!=this.dragAndDropColor)return false;
return true}
,
__clearDragProperties:function()
{
this.dragProperties=new Object()}
,
__moveDownOnChessPiece:function(e)
{
if(document.all)e=event;
var color=this.getAttribute('color');
var pieceIndex=this.getAttribute('pieceIndex');
var objectIndex=this.getAttribute('objectIndex');
var chessObj=D_chessObjects[objectIndex];
var tmpColor='white';
if(color=='b')tmpColor='black';
if(chessObj.__isDragOk(tmpColor,pieceIndex)){
var pieceX=chessObj.pieces[tmpColor][pieceIndex].el.style.left.replace('px','')/1;
var pieceY=chessObj.pieces[tmpColor][pieceIndex].el.style.top.replace('px','')/1;
chessObj.currentZIndex++;
chessObj.pieces[tmpColor][pieceIndex].el.style.zIndex=chessObj.currentZIndex;
chessObj.dragProperties={color:tmpColor,pieceIndex:pieceIndex,mouseX:e.clientX,mouseY:e.clientY,pieceX:pieceX,pieceY:pieceY,toFile:false,toRank:false};
chessObj.dragCountDownVar=2;
document.body.style.cursor='move';
chessObj.__countDownToDragStart()}
return false}
,
__countDownToDragStart:function()
{
if(this.dragCountDownVar>=0&&this.dragCountDownVar<5){
this.dragCountDownVar++;
var ind=this.objectIndex;
setTimeout('D_chessObjects['+ind+'].__countDownToDragStart()',5)}
}
,
__moveDraggedPiece:function(e)
{
if(document.all)e=event;
if(this.dragCountDownVar==5){
this.pieces[this.dragProperties.color][this.dragProperties.pieceIndex].el.style.left=(e.clientX-this.dragProperties.mouseX+this.dragProperties.pieceX)+'px';
this.pieces[this.dragProperties.color][this.dragProperties.pieceIndex].el.style.top=(e.clientY-this.dragProperties.mouseY+this.dragProperties.pieceY)+'px'}
}
,
__getSquareFromDragXY:function(x,y)
{
x=Math.ceil(x/this.squareSize);
y=Math.ceil(8-y/this.squareSize);
if(this.flipBoard){
x=9-x;
y=9-y}
return this.__getFileByCol(x)+y}
,
__isCorrectPieceDraggedToCorrectSquare:function(toSquare)
{
if(this.currentGameIndex===false)return false;
var nextMove=this.__getNextMove();
if(nextMove.pawnMove){
if(nextMove.capture){
var index=this.__movePawnCapture(nextMove.notation,nextMove.fromFile,nextMove.color,false)}else{
var index=this.__movePawnForward(nextMove.notation,nextMove.color)}
if(index==this.dragProperties.pieceIndex&&toSquare==nextMove.toSquare)return true;
return false}
var pieceObj=this.pieces[this.dragProperties.color][this.dragProperties.pieceIndex];
var moveOk=true;
if(!this.__canPieceMoveToSquare(this.dragProperties.color,this.dragProperties.pieceIndex/1,toSquare))moveOk=false;
if(pieceObj.pieceType!=nextMove.pieceType)moveOk=false;
if(nextMove.fromFile&&nextMove.fromFile!=pieceObj.file)moveOk=false;
if(nextMove.toSquare!=toSquare)moveOk=false;
if(nextMove.fromRank&&nextMove.fromRank!=pieceObj.rank)moveOk=false;
if(moveOk){
return true}
if(!this.insideVariation){
var variations=this.__getVariationIndexes(nextMove.move,nextMove.color);
if(variations){
for(var prop in variations){
var aVariation=variations[prop];
this.__setStartVariationVariables(nextMove.move,nextMove.color,prop);
if(this.__isCorrectPieceDraggedToCorrectSquare(toSquare))return true}
this.insideVariation=false}
}
var opositeColor=this.dragProperties.color=='white'?'black':'white';
var el=this.__getPieceOnSquare(toSquare,opositeColor);
if(el===false)this.__playSound('move');else this.__playSound('capture');
return false}
,
__getVariationIndexes:function(move,color)
{
try{
return this.pgnObject.gameDetails[this.currentGameIndex].moves[move][color].variation}catch(e){
return false}
}
,
__dragAndDropAfterMoveCallback:function()
{
var lastMove=this.__getLastPlayedMove();
if(lastMove.color==this.dragProperties.color){
var ind=this.objectIndex;
setTimeout('D_chessObjects['+ind+'].move(1)',100);
this.__handleCallback('correctMove')}else{
this.callbackOnMoveComplete=false}
}
,
__releaseDraggedPiece:function(e)
{
if(this.dragCountDownVar==5){
document.body.style.cursor='';
var ind=this.objectIndex;
this.dragCountDownVar=-1;
if(document.all)e=event;
var x=e.clientX-this.__getLeftPos(this.divBoard)+Math.max(document.documentElement.scrollLeft,document.body.scrollLeft);
var y=e.clientY-this.__getTopPos(this.divBoard)+Math.max(document.documentElement.scrollTop,document.body.scrollTop);
var toSquare=this.__getSquareFromDragXY(x,y);
if(this.__isCorrectPieceDraggedToCorrectSquare(toSquare)){
this.callbackOnMoveComplete='D_chessObjects['+ind+'].__dragAndDropAfterMoveCallback';
this.move(1)}else{
var fromPos=this.__getPieceXY(this.dragProperties.color,this.dragProperties.pieceIndex);
var pieceObj=this.pieces[this.dragProperties.color][this.dragProperties.pieceIndex];
var toPos=this.__getBoardPosByNotation(pieceObj.file+pieceObj.rank);
var coordIndex=this.slideCoordinates.length;
this.slideCoordinates[coordIndex]=this.__getSlideCoordinates({x:fromPos.x,y:fromPos.y},{x:toPos.x,y:toPos.y});
var dragDropVar='differentSquare';
if(toSquare==this.pieces[this.dragProperties.color][this.dragProperties.pieceIndex].file+this.pieces[this.dragProperties.color][this.dragProperties.pieceIndex].rank){
dragDropVar='sameSquare'}
this.__slideElement(
{'coordIndex':coordIndex,'coordStep':1},
{'x':fromPos.x,'y':fromPos.y}
,
this.dragProperties.pieceIndex,
this.dragProperties.color,
dragDropVar
)
}
}
}
,
__getPieceXY:function(color,pieceIndex)
{
var ret=new Object();
ret.x=this.pieces[color][pieceIndex].el.style.left.replace('px','')/1;
ret.y=this.pieces[color][pieceIndex].el.style.top.replace('px','')/1;
return ret}
,
__cancelEvent:function()
{
return false}
,
__addGeneralEvents:function()
{
var ind=this.objectIndex;
this.addEvent(window,'unload',function(){D_chessObjects[ind].__clearMemoryGarbage()});
this.addEvent(document.documentElement,'mousemove',function(e){D_chessObjects[ind].__moveDraggedPiece(e)});
this.addEvent(document.documentElement,'mouseup',function(e){D_chessObjects[ind].__releaseDraggedPiece(e)})}
,
__createLiveUpdateHandler:function()
{
if(!this.liveUpdateInterval)return;
var ind=this.objectIndex;
setInterval('D_chessObjects['+ind+'].__getNewGameData()',(this.liveUpdateInterval*1000))}
,
__addSoundEffects:function()
{
if(!this.sound)return;
this.soundEmbed=document.createElement('bgsound');
this.soundEmbed.setAttribute('autostart',true);
this.soundEmbed.setAttribute('loop',false);
this.soundEmbed.src='';
var head=document.getElementsByTagName('HEAD')[0];
head.appendChild(this.soundEmbed)}
,
__playSound:function(whichSound)
{
if(!this.sound)return;
var lastMove=this.__getLastPlayedMove();
if(whichSound){
switch(whichSound){
case"startGame":soundFile='startgame1.wav';break;
case"move":soundFile='move1.wav';break;
case"capture":soundFile='capture1.wav';break}
}else{
var soundFile='move1.wav';
if(lastMove.moveString.indexOf('x')>=0){
soundFile='capture1.wav'}
if(lastMove.moveString.indexOf('O-O')>=0)soundFile='castle1.wav'}
if(this.soundEmbed.src.indexOf('1')>0)soundFile=soundFile.replace('1','2');
this.soundEmbed.src='sound/'+soundFile}
,
correctPng:function(el)
{
el=this.__getEl(el);
el.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"', sizingMethod='scale')";
el.src=this.imageFolder+'spacer.gif';
el.width=this.squareSize;
el.height=this.squareSize}
,
__getStyle:function(el,property)
{
el=this.__getEl(el);
if(document.defaultView&&document.defaultView.getComputedStyle){
var retVal=null;
var comp=document.defaultView.getComputedStyle(el,'');
if(comp){
retVal=comp[property];
if(!retVal){
var comp=document.defaultView.getComputedStyle(el,null);
retVal=comp.getPropertyCSSValue(property)}
}
if(retVal==null)retVal='';
return el.style[property]||retVal}
if(document.documentElement.currentStyle&&this.isMSIE){
var value=el.currentStyle?el.currentStyle[property]:null;
return(el.style[property]||value)}
return el.style[property]}
,
__clearTBodyRows:function(tbodyRef)
{
if(!tbodyRef)return;
if(tbodyRef.tagName.toLowerCase()=='table'){
var table=tbodyRef;
var tbodies=tbodyRef.getElementsByTagName('TBODY');
var tbodyRef=tbodies[0]}else{
var table=tbodyRef.parentNode}
var className=tbodyRef.className;
var css=tbodyRef.style.cssText;
this.__discardElement(tbodyRef);
var tbody=document.createElement('tbody');
if(className)tbody.className=className;
if(css)tbody.style.cssText=css;
table.appendChild(tbody)}
,
__replaceTbody:function(content,tableRef)
{
var className;
var css;
var tbodies=tableRef.getElementsByTagName('TBODY');
if(tbodies.length>0){
className=tbodies[0].className;
css=tbodies[0].style.cssText;
this.__discardElement(tbodies[0])}
content='<tbody class="'+className+'" style="'+css+'">'+content+'</tbody>';
try{
tableRef.innerHTML=tableRef.innerHTML+content}catch(e){
var outerHTML=tableRef.outerHTML;
tokens=outerHTML.split('</TABLE>');
newHTML=tokens[0]+content+'</table>';
tableRef.outerHTML=newHTML}
}
,
__discardElement:function(element){
element=this.__getEl(element);
var gBin=document.getElementById('IELeakGBin');
if(!gBin){
gBin=document.createElement('DIV');
gBin.id='IELeakGBin';
gBin.style.display='none';
var head=document.getElementsByTagName('HEAD')[0];
head.appendChild(gBin)}
gBin.appendChild(element);
gBin.innerHTML=''}
,
__isArray:function(el)
{
if(!el)return false;
if(el.constructor.toString().indexOf("Array")!=-1)return true;
return false}
,
__addEventEl:function(el)
{
this.eventElements[this.eventElements]=el}
,
__clearMemoryGarbage:function()
{
if(!this.isMSIE)return;
for(var no=0;no<this.eventElements.length;no++){
try{
var el=this.eventElements[no];
el.onclick=null;
el.onmousedown=null;
el.onmousemove=null;
el.onmouseout=null;
el.onmouseover=null;
el.onmouseup=null;
el.onfocus=null;
el.onblur=null;
el.onkeydown=null;
el.onkeypress=null;
el.onkeyup=null;
el.onselectstart=null;
el.ondragstart=null;
el.oncontextmenu=null;
el.onscroll=null;
el=null}catch(e){
}
}
window.onbeforeunload=null;
window.onunload=null}
,
addEvent:function(obj,type,fn,suffix){
if(!suffix)suffix='';
if(obj.attachEvent){
if(typeof ChessWidgetEventFuncs[type+fn+suffix]!='function'){
ChessWidgetEventFuncs[type+fn+suffix]=function(){
fn.apply(window.event.srcElement)};
obj.attachEvent('on'+type,ChessWidgetEventFuncs[type+fn+suffix])}
obj=null}else{
obj.addEventListener(type,fn,false)}
this.__addEventEl(obj)}
,
removeEvent:function(obj,type,fn,suffix)
{
if(obj.detachEvent){
obj.detachEvent('on'+type,ChessWidgetEventFuncs[type+fn+suffix]);
ChessWidgetEventFuncs[type+fn+suffix]=null;
obj=null}else{
obj.removeEventListener(type,fn,false)}
}
,
__getLeftPos:function(el)
{
if(document.getBoxObjectFor){
return document.getBoxObjectFor(el).x
}
var returnValue=el.offsetLeft;
while((el=el.offsetParent)!=null){
if(el.tagName!='HTML'){
returnValue+=el.offsetLeft;
if(document.all)returnValue+=el.clientLeft}
}
return returnValue}
,
__getTopPos:function(el)
{
if(document.getBoxObjectFor){
return document.getBoxObjectFor(el).y
}
var returnValue=el.offsetTop;
while((el=el.offsetParent)!=null){
if(el.tagName!='HTML'){
returnValue+=(el.offsetTop-el.scrollTop);
if(document.all)returnValue+=el.clientTop}
}
return returnValue}
}
function sack(file){
this.xmlhttp=null;
this.resetData=function(){
this.method="POST";
this.queryStringSeparator=chess_queryStringSeparator;
this.argumentSeparator="&";
this.URLString="";
this.encodeURIString=true;
this.execute=false;
this.element=null;
this.elementObj=null;
this.requestFile=file;
this.vars=new Object();
this.responseStatus=new Array(2)};
this.resetFunctions=function(){
this.onLoading=function(){};
this.onLoaded=function(){};
this.onInteractive=function(){};
this.onCompletion=function(){};
this.onError=function(){};
this.onFail=function(){}};
this.reset=function(){
this.resetFunctions();
this.resetData()};
this.createAJAX=function(){
try{
this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")}catch(e1){
try{
this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}catch(e2){
this.xmlhttp=null}
}
if(!this.xmlhttp){
if(typeof XMLHttpRequest!="undefined"){
this.xmlhttp=new XMLHttpRequest()}else{
this.failed=true}
}
};
this.setVar=function(name,value){
this.vars[name]=Array(value,false)};
this.encVar=function(name,value,returnvars){
if(true==returnvars){
return Array(encodeURIComponent(name),encodeURIComponent(value))}else{
this.vars[encodeURIComponent(name)]=Array(encodeURIComponent(value),true)}
}
this.processURLString=function(string,encode){
encoded=encodeURIComponent(this.argumentSeparator);
regexp=new RegExp(this.argumentSeparator+"|"+encoded);
varArray=string.split(regexp);
for(i=0;i<varArray.length;i++){
urlVars=varArray[i].split("=");
if(true==encode){
this.encVar(urlVars[0],urlVars[1])}else{
this.setVar(urlVars[0],urlVars[1])}
}
}
this.createURLString=function(urlstring){
if(this.encodeURIString&&this.URLString.length){
this.processURLString(this.URLString,true)}
if(urlstring){
if(this.URLString.length){
this.URLString+=this.argumentSeparator+urlstring}else{
this.URLString=urlstring}
}
this.setVar("rndval",new Date().getTime());
urlstringtemp=new Array();
for(key in this.vars){
if(false==this.vars[key][1]&&true==this.encodeURIString){
encoded=this.encVar(key,this.vars[key][0],true);
delete this.vars[key];
this.vars[encoded[0]]=Array(encoded[1],true);
key=encoded[0]}
urlstringtemp[urlstringtemp.length]=key+"="+this.vars[key][0]}
if(urlstring){
this.URLString+=this.argumentSeparator+urlstringtemp.join(this.argumentSeparator)}else{
this.URLString+=urlstringtemp.join(this.argumentSeparator)}
}
this.runResponse=function(){
eval(this.response)}
this.runAJAX=function(urlstring){
if(this.failed){
this.onFail()}else{
this.createURLString(urlstring);
if(this.element){
this.elementObj=document.getElementById(this.element)}
if(this.xmlhttp){
var self=this;
if(this.method=="GET"){
totalurlstring=this.requestFile+this.queryStringSeparator+this.URLString;
this.xmlhttp.open(this.method,totalurlstring,true)}else{
this.xmlhttp.open(this.method,this.requestFile,true);
try{
this.xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
}catch(e){}
}
this.xmlhttp.onreadystatechange=function(){
switch(self.xmlhttp.readyState){
case 1:
self.onLoading();
break;
case 2:
self.onLoaded();
break;
case 3:
self.onInteractive();
break;
case 4:
self.response=self.xmlhttp.responseText;
self.responseXML=self.xmlhttp.responseXML;
self.responseStatus[0]=self.xmlhttp.status;
self.responseStatus[1]=self.xmlhttp.statusText;
if(self.execute){
self.runResponse()}
if(self.elementObj){
elemNodeName=self.elementObj.nodeName;
elemNodeName=elemNodeName.toLowerCase();
if(elemNodeName=="input"
||elemNodeName=="select"
||elemNodeName=="option"
||elemNodeName=="textarea"){
self.elementObj.value=self.response}else{
self.elementObj.innerHTML=self.response}
}
if(self.responseStatus[0]=="200"){
self.onCompletion()}else{
self.onError()}
self.URLString="";
delete self.xmlhttp['onreadystatechange'];
self.xmlhttp=null;
self.responseStatus=null;
self.response=null;
self.responseXML=null;
break}
};
this.xmlhttp.send(this.URLString)}
}
};
this.reset();
this.createAJAX()}
function addEndCol(obj)
{
if(document.all)return;
var rows=obj.getElementsByTagName('TR');
for(var no=0;no<rows.length;no++){
var cell=rows[no].insertCell(-1);
cell.innerHTML=' ';
cell.style.width='13px';
cell.width='13'}
}
function cancelTableWidgetEvent()
{
return false}
function createScrollTable(objId,width,height)
{
var isMSIE=navigator.userAgent.indexOf('MSIE')>=0?true:false;
width=width+'';
height=height+'';
var obj=document.getElementById(objId);
if(obj.parentNode.className){
obj.parentNode.className=obj.parentNode.className+' widget_tableDiv'}else{
obj.parentNode.className='widget_tableDiv'}
if(isMSIE){
obj.parentNode.style.overflowY='scroll'}
if(width.indexOf('%')>=0){
obj.style.width='100%';
obj.parentNode.style.width=width}else{
obj.style.width=width+'px';
obj.parentNode.style.width=width+'px'}
if(height.indexOf('%')>=0){
obj.parentNode.style.height=height}else{
obj.parentNode.style.height=height+'px'}
if(!isMSIE){
addEndCol(obj)}else{
obj.style.cssText='width:expression(this.parentNode.clientWidth)'}
obj.cellSpacing=0;
obj.cellPadding=0;
obj.className='tableWidget';
var tHead=obj.getElementsByTagName('THEAD')[0];
var cells=tHead.getElementsByTagName('TD');
for(var no=0;no<cells.length;no++){
cells[no].className='tableWidget_headerCell';
cells[no].onselectstart=cancelTableWidgetEvent;
if(no==cells.length-1){
cells[no].style.borderRight='0px'}
cells[no].style.cursor='default'}
var tBody=obj.getElementsByTagName('TBODY')[0];
if(document.all&&navigator.userAgent.indexOf('Opera')<0){
tBody.className='scrollingContent';
tBody.style.display='block'}else{
tBody.className='scrollingContent';
tBody.style.height=(obj.parentNode.clientHeight-tHead.offsetHeight)+'px';
if(tBody.style.height=='0px')tBody.style.height=(height-20)+'px';
if(navigator.userAgent.indexOf('Opera')>=0){
obj.parentNode.style.overflow='auto'}
}
}
if(!window.$)window.$=function(e){return document.getElementById(e)};
function showDetails(gameDetails){
document.getElementById('moveTab').style.display='block';
document.getElementById('gameList').style.display='none';
document.getElementById('pgnList').style.display='none';
document.getElementById('tabDetails').className='tabActive';
document.getElementById('tabGames').className='tabInactive';
document.getElementById('tabPgns').className='tabInactive'}
function showGames(){
document.getElementById('moveTab').style.display='none';
document.getElementById('pgnList').style.display='none';
document.getElementById('gameList').style.display='block';
document.getElementById('tabGames').className='tabActive';
document.getElementById('tabDetails').className='tabInactive';
document.getElementById('tabPgns').className='tabInactive'}
function showPgns(){
document.getElementById('moveTab').style.display='none';
document.getElementById('gameList').style.display='none';
document.getElementById('pgnList').style.display='block';
document.getElementById('tabGames').className='tabInactive';
document.getElementById('tabDetails').className='tabInactive';
document.getElementById('tabPgns').className='tabActive'}
function guessedWrongMove(){
alert('sorry - that move was wrong')}
function correctMove(){
}
$(document).ready(function(){
$("#mainContainer").dblclick(function(){
return false})});
document.onkeyup=KeyCheck;
function KeyCheck(e){
var keyID=(window.event)?event.keyCode:e.keyCode;
switch(keyID){
case 37:
chessObj.move(-1);
break;
case 39:
chessObj.move(1);
break}
};


/* plugins/auto/couteau_suisse/lib/jcorner/distant_jquery.corner.js */
;

;(function($){
var ua=navigator.userAgent;
var moz=$.browser.mozilla&&/gecko/i.test(ua);
var webkit=$.browser.safari&&/Safari\/[5-9]/.test(ua);
var expr=$.browser.msie&&(function(){
var div=document.createElement('div');
try{div.style.setExpression('width','0+0');div.style.removeExpression('width')}
catch(e){return false}
return true})();
function sz(el,p){
return parseInt($.css(el,p))||0};
function hex2(s){
var s=parseInt(s).toString(16);
return(s.length<2)?'0'+s:s};
function gpc(node){
for(;node&&node.nodeName.toLowerCase()!='html';node=node.parentNode){
var v=$.css(node,'backgroundColor');
if(v=='rgba(0, 0, 0, 0)')
continue;if(v.indexOf('rgb')>=0){
var rgb=v.match(/\d+/g);
return'#'+hex2(rgb[0])+hex2(rgb[1])+hex2(rgb[2])}
if(v&&v!='transparent')
return v}
return'#ffffff'};
function getWidth(fx,i,width){
switch(fx){
case'round':return Math.round(width*(1-Math.cos(Math.asin(i/width))));
case'cool':return Math.round(width*(1+Math.cos(Math.asin(i/width))));
case'sharp':return Math.round(width*(1-Math.cos(Math.acos(i/width))));
case'bite':return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
case'slide':return Math.round(width*(Math.atan2(i,width/i)));
case'jut':return Math.round(width*(Math.atan2(width,(width-i-1))));
case'curl':return Math.round(width*(Math.atan(i)));
case'tear':return Math.round(width*(Math.cos(i)));
case'wicked':return Math.round(width*(Math.tan(i)));
case'long':return Math.round(width*(Math.sqrt(i)));
case'sculpt':return Math.round(width*(Math.log((width-i-1),width)));
case'dog':return(i&1)?(i+1):width;
case'dog2':return(i&2)?(i+1):width;
case'dog3':return(i&3)?(i+1):width;
case'fray':return(i%2)*width;
case'notch':return width;
case'bevel':return i+1}
};
$.fn.corner=function(options){
if(this.length==0){
if(!$.isReady&&this.selector){
var s=this.selector,c=this.context;
$(function(){
$(s,c).corner(options)})}
return this}
return this.each(function(index){
var $this=$(this);
var o=[options||'',$this.attr($.fn.corner.defaults.metaAttr)||''].join(' ').toLowerCase();
var keep=/keep/.test(o);var cc=((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);var sc=((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);var width=parseInt((o.match(/(\d+)px/)||[])[1])||10;var re=/round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
var fx=((o.match(re)||['round'])[0]);
var edges={T:0,B:1};
var opts={
TL:/top|tl|left/.test(o),TR:/top|tr|right/.test(o),
BL:/bottom|bl|left/.test(o),BR:/bottom|br|right/.test(o)
};
if(!opts.TL&&!opts.TR&&!opts.BL&&!opts.BR)
opts={TL:1,TR:1,BL:1,BR:1};
if($.fn.corner.defaults.useNative&&fx=='round'&&(moz||webkit)&&!cc&&!sc){
if(opts.TL)
$this.css(moz?'-moz-border-radius-topleft':'-webkit-border-top-left-radius',width+'px');
if(opts.TR)
$this.css(moz?'-moz-border-radius-topright':'-webkit-border-top-right-radius',width+'px');
if(opts.BL)
$this.css(moz?'-moz-border-radius-bottomleft':'-webkit-border-bottom-left-radius',width+'px');
if(opts.BR)
$this.css(moz?'-moz-border-radius-bottomright':'-webkit-border-bottom-right-radius',width+'px');
return}
var strip=document.createElement('div');
strip.style.overflow='hidden';
strip.style.height='1px';
strip.style.backgroundColor=sc||'transparent';
strip.style.borderStyle='solid';
var pad={
T:parseInt($.css(this,'paddingTop'))||0,R:parseInt($.css(this,'paddingRight'))||0,
B:parseInt($.css(this,'paddingBottom'))||0,L:parseInt($.css(this,'paddingLeft'))||0
};
if(typeof this.style.zoom!=undefined)this.style.zoom=1;if(!keep)this.style.border='none';
strip.style.borderColor=cc||gpc(this.parentNode);
var cssHeight=$.curCSS(this,'height');
for(var j in edges){
var bot=edges[j];
if((bot&&(opts.BL||opts.BR))||(!bot&&(opts.TL||opts.TR))){
strip.style.borderStyle='none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
var d=document.createElement('div');
$(d).addClass('jquery-corner');
var ds=d.style;
bot?this.appendChild(d):this.insertBefore(d,this.firstChild);
if(bot&&cssHeight!='auto'){
if($.css(this,'position')=='static')
this.style.position='relative';
ds.position='absolute';
ds.bottom=ds.left=ds.padding=ds.margin='0';
if(expr)
ds.setExpression('width','this.parentNode.offsetWidth');
else
ds.width='100%'}
else if(!bot&&$.browser.msie){
if($.css(this,'position')=='static')
this.style.position='relative';
ds.position='absolute';
ds.top=ds.left=ds.right=ds.padding=ds.margin='0';
if(expr){
var bw=sz(this,'borderLeftWidth')+sz(this,'borderRightWidth');
ds.setExpression('width','this.parentNode.offsetWidth - '+bw+'+ "px"')}
else
ds.width='100%'}
else{
ds.position='relative';
ds.margin=!bot?'-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px':
(pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px'}
for(var i=0;i<width;i++){
var w=Math.max(0,getWidth(fx,i,width));
var e=strip.cloneNode(false);
e.style.borderWidth='0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
bot?d.appendChild(e):d.insertBefore(e,d.firstChild)}
}
}
})};
$.fn.uncorner=function(){
if(moz||webkit)
this.css(moz?'-moz-border-radius':'-webkit-border-radius',0);
$('div.jquery-corner',this).remove();
return this};
$.fn.corner.defaults={
useNative:true,metaAttr:'data-corner'}})(jQuery);


/* plugins/auto/fancybox/spip20/javascript/jquery.fancybox-1.2.6.js */
;

;(function($){
$.fn.fixPNG=function(){
return this.each(function(){
var image=$(this).css('backgroundImage');
if(image.match(/^url\(["']?(.*\.png)["']?\)$/i)){
image=RegExp.$1;
$(this).css({
'backgroundImage':'none',
'filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod="+($(this).css('backgroundRepeat')=='no-repeat'?'crop':'scale')+", src='"+image+"')"
}).each(function(){
var position=$(this).css('position');
if(position!='absolute'&&position!='relative')
$(this).css('position','relative')})}
})};
var elem,opts,busy=false,imagePreloader=new Image,loadingTimer,loadingFrame=1,imageRegExp=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i;
var ieQuirks=null,IE6=$.browser.msie&&$.browser.version.substr(0,1)==6&&!window.XMLHttpRequest,oldIE=IE6||($.browser.msie&&$.browser.version.substr(0,1)==7);
$.fn.fancybox=function(o){
var settings=$.extend({},$.fn.fancybox.defaults,o);
var matchedGroup=this;
function _initialize(){
elem=this;
opts=$.extend({},settings);
_start();
return false};
function _start(){
if(busy)return;
if($.isFunction(opts.callbackOnStart)){
opts.callbackOnStart()}
opts.itemArray=[];
opts.itemCurrent=0;
if(settings.itemArray.length>0){
opts.itemArray=settings.itemArray}else{
var item={};
if(!elem.rel||elem.rel==''){
var item={href:elem.href,title:elem.title};
if($(elem).children("img:first").length){
item.orig=$(elem).children("img:first")}else{
item.orig=$(elem)}
if(item.title==''||typeof item.title=='undefined'){
item.title=item.orig.attr('alt')}
opts.itemArray.push(item)}else{
var subGroup=$(matchedGroup).filter("a[rel="+elem.rel+"]");
var item={};
for(var i=0;i<subGroup.length;i++){
item={href:subGroup[i].href,title:subGroup[i].title};
if($(subGroup[i]).children("img:first").length){
item.orig=$(subGroup[i]).children("img:first")}else{
item.orig=$(subGroup[i])}
if(item.title==''||typeof item.title=='undefined'){
item.title=item.orig.attr('alt')}
opts.itemArray.push(item)}
}
}
while(opts.itemArray[opts.itemCurrent].href!=elem.href){
opts.itemCurrent++}
if(opts.overlayShow){
if(IE6){
$('embed, object, select').css('visibility','hidden');
$("#fancy_overlay").css('height',$(document).height())}
$("#fancy_overlay").css({
'background-color':opts.overlayColor,
'opacity':opts.overlayOpacity
}).show()}
$(window).bind("resize.fb scroll.fb",$.fn.fancybox.scrollBox);
_change_item()};
function _change_item(){
$("#fancy_right, #fancy_left, #fancy_close, #fancy_title").hide();
var href=opts.itemArray[opts.itemCurrent].href;
if(href.match("iframe")||elem.className.indexOf("iframe")>=0){
$.fn.fancybox.showLoading();
_set_content('<iframe id="fancy_frame" onload="jQuery.fn.fancybox.showIframe()" name="fancy_iframe'+Math.round(Math.random()*1000)+'" frameborder="0" hspace="0" src="'+href+'"></iframe>',opts.frameWidth,opts.frameHeight)}else if(href.match(/#/)){
var target=window.location.href.split('#')[0];target=href.replace(target,'');target=target.substr(target.indexOf('#'));
_set_content('<div id="fancy_div">'+$(target).html()+'</div>',opts.frameWidth,opts.frameHeight)}else if(href.match(imageRegExp)){
imagePreloader=new Image;imagePreloader.src=href;
if(imagePreloader.complete){
_proceed_image()}else{
$.fn.fancybox.showLoading();
$(imagePreloader).unbind().bind('load',function(){
$("#fancy_loading").hide();
_proceed_image()})}
}else{
$.fn.fancybox.showLoading();
$.get(href,function(data){
$("#fancy_loading").hide();
_set_content('<div id="fancy_ajax">'+data+'</div>',opts.frameWidth,opts.frameHeight)})}
};
function _proceed_image(){
var width=imagePreloader.width;
var height=imagePreloader.height;
var horizontal_space=(opts.padding*2)+40;
var vertical_space=(opts.padding*2)+60;
var w=$.fn.fancybox.getViewport();
if(opts.imageScale&&(width>(w[0]-horizontal_space)||height>(w[1]-vertical_space))){
var ratio=Math.min(Math.min(w[0]-horizontal_space,width)/width,Math.min(w[1]-vertical_space,height)/height);
width=Math.round(ratio*width);
height=Math.round(ratio*height)}
_set_content('<img alt="" id="fancy_img" src="'+imagePreloader.src+'" />',width,height)};
function _preload_neighbor_images(){
if((opts.itemArray.length-1)>opts.itemCurrent){
var href=opts.itemArray[opts.itemCurrent+1].href||false;
if(href&&href.match(imageRegExp)){
objNext=new Image();
objNext.src=href}
}
if(opts.itemCurrent>0){
var href=opts.itemArray[opts.itemCurrent-1].href||false;
if(href&&href.match(imageRegExp)){
objNext=new Image();
objNext.src=href}
}
};
function _set_content(value,width,height){
busy=true;
var pad=opts.padding;
if(oldIE||ieQuirks){
$("#fancy_content")[0].style.removeExpression("height");
$("#fancy_content")[0].style.removeExpression("width")}
if(pad>0){
width+=pad*2;
height+=pad*2;
$("#fancy_content").css({
'top':pad+'px',
'right':pad+'px',
'bottom':pad+'px',
'left':pad+'px',
'width':'auto',
'height':'auto'
});
if(oldIE||ieQuirks){
$("#fancy_content")[0].style.setExpression('height','(this.parentNode.clientHeight - '+pad*2+')');
$("#fancy_content")[0].style.setExpression('width','(this.parentNode.clientWidth - '+pad*2+')')}
}else{
$("#fancy_content").css({
'top':0,
'right':0,
'bottom':0,
'left':0,
'width':'100%',
'height':'100%'
})}
if($("#fancy_outer").is(":visible")&&width==$("#fancy_outer").width()&&height==$("#fancy_outer").height()){
$("#fancy_content").fadeOut('fast',function(){
$("#fancy_content").empty().append($(value)).fadeIn("normal",function(){
_finish()})});
return}
var w=$.fn.fancybox.getViewport();
var itemTop=(height+60)>w[1]?w[3]:(w[3]+Math.round((w[1]-height-60)*0.5));
var itemLeft=(width+40)>w[0]?w[2]:(w[2]+Math.round((w[0]-width-40)*0.5));
var itemOpts={
'left':itemLeft,
'top':itemTop,
'width':width+'px',
'height':height+'px'
};
if($("#fancy_outer").is(":visible")){
$("#fancy_content").fadeOut("normal",function(){
$("#fancy_content").empty();
$("#fancy_outer").animate(itemOpts,opts.zoomSpeedChange,opts.easingChange,function(){
$("#fancy_content").append($(value)).fadeIn("normal",function(){
_finish()})})})}else{
if(opts.zoomSpeedIn>0&&opts.itemArray[opts.itemCurrent].orig!==undefined){
$("#fancy_content").empty().append($(value));
var orig_item=opts.itemArray[opts.itemCurrent].orig;
var orig_pos=$.fn.fancybox.getPosition(orig_item);
$("#fancy_outer").css({
'left':(orig_pos.left-20-opts.padding)+'px',
'top':(orig_pos.top-20-opts.padding)+'px',
'width':$(orig_item).width()+(opts.padding*2),
'height':$(orig_item).height()+(opts.padding*2)
});
if(opts.zoomOpacity){
itemOpts.opacity='show'}
$("#fancy_outer").animate(itemOpts,opts.zoomSpeedIn,opts.easingIn,function(){
_finish()})}else{
$("#fancy_content").hide().empty().append($(value)).show();
$("#fancy_outer").css(itemOpts).fadeIn("normal",function(){
_finish()})}
}
};
function _set_navigation(){
if(opts.itemCurrent!==0){
$("#fancy_left, #fancy_left_ico").unbind().bind("click",function(e){
e.stopPropagation();
opts.itemCurrent--;
_change_item();
return false});
$("#fancy_left").show()}
if(opts.itemCurrent!=(opts.itemArray.length-1)){
$("#fancy_right, #fancy_right_ico").unbind().bind("click",function(e){
e.stopPropagation();
opts.itemCurrent++;
_change_item();
return false});
$("#fancy_right").show()}
};
function _finish(){
if($.browser.msie){
$("#fancy_content")[0].style.removeAttribute('filter');
$("#fancy_outer")[0].style.removeAttribute('filter')}
_set_navigation();
_preload_neighbor_images();
$(document).bind("keydown.fb",function(e){
if(e.keyCode==27&&opts.enableEscapeButton){
$.fn.fancybox.close()}else if(e.keyCode==37&&opts.itemCurrent!==0){
$(document).unbind("keydown.fb");
opts.itemCurrent--;
_change_item()}else if(e.keyCode==39&&opts.itemCurrent!=(opts.itemArray.length-1)){
$(document).unbind("keydown.fb");
opts.itemCurrent++;
_change_item()}
});
if(opts.hideOnContentClick){
$("#fancy_content").click($.fn.fancybox.close)}
if(opts.overlayShow&&opts.hideOnOverlayClick){
$("#fancy_overlay").bind("click",$.fn.fancybox.close)}
if(opts.showCloseButton){
$("#fancy_close").bind("click",$.fn.fancybox.close).show()}
if(typeof opts.itemArray[opts.itemCurrent].title!=='undefined'&&opts.itemArray[opts.itemCurrent].title.length>0){
var pos=$("#fancy_outer").position();
$('#fancy_title div').text(opts.itemArray[opts.itemCurrent].title).html();
$('#fancy_title').css({
'top':pos.top+$("#fancy_outer").outerHeight()-32,
'left':pos.left+(($("#fancy_outer").outerWidth()*0.5)-($('#fancy_title').width()*0.5))
}).show()}
if(opts.overlayShow&&IE6){
$('embed, object, select',$('#fancy_content')).css('visibility','visible')}
if($.isFunction(opts.callbackOnShow)){
opts.callbackOnShow(opts.itemArray[opts.itemCurrent])}
if($.browser.msie){
$("#fancy_outer")[0].style.removeAttribute('filter');
$("#fancy_content")[0].style.removeAttribute('filter')}
busy=false};
return this.unbind('click.fb').bind('click.fb',_initialize)};
$.fn.fancybox.scrollBox=function(){
var w=$.fn.fancybox.getViewport();
if(opts.centerOnScroll&&$("#fancy_outer").is(':visible')){
var ow=$("#fancy_outer").outerWidth();
var oh=$("#fancy_outer").outerHeight();
var pos={
'top':(oh>w[1]?w[3]:w[3]+Math.round((w[1]-oh)*0.5)),
'left':(ow>w[0]?w[2]:w[2]+Math.round((w[0]-ow)*0.5))
};
$("#fancy_outer").css(pos);
$('#fancy_title').css({
'top':pos.top+oh-32,
'left':pos.left+((ow*0.5)-($('#fancy_title').width()*0.5))
})}
if(IE6&&$("#fancy_overlay").is(':visible')){
$("#fancy_overlay").css({
'height':$(document).height()
})}
if($("#fancy_loading").is(':visible')){
$("#fancy_loading").css({'left':((w[0]-40)*0.5+w[2]),'top':((w[1]-40)*0.5+w[3])})}
};
$.fn.fancybox.getNumeric=function(el,prop){
return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0};
$.fn.fancybox.getPosition=function(el){
var pos=el.offset();
pos.top+=$.fn.fancybox.getNumeric(el,'paddingTop');
pos.top+=$.fn.fancybox.getNumeric(el,'borderTopWidth');
pos.left+=$.fn.fancybox.getNumeric(el,'paddingLeft');
pos.left+=$.fn.fancybox.getNumeric(el,'borderLeftWidth');
return pos};
$.fn.fancybox.showIframe=function(){
$("#fancy_loading").hide();
$("#fancy_frame").show()};
$.fn.fancybox.getViewport=function(){
return[$(window).width(),$(window).height(),$(document).scrollLeft(),$(document).scrollTop()]};
$.fn.fancybox.animateLoading=function(){
if(!$("#fancy_loading").is(':visible')){
clearInterval(loadingTimer);
return}
$("#fancy_loading > div").css('top',(loadingFrame*-40)+'px');
loadingFrame=(loadingFrame+1)%12};
$.fn.fancybox.showLoading=function(){
clearInterval(loadingTimer);
var w=$.fn.fancybox.getViewport();
$("#fancy_loading").css({'left':((w[0]-40)*0.5+w[2]),'top':((w[1]-40)*0.5+w[3])}).show();
$("#fancy_loading").bind('click',$.fn.fancybox.close);
loadingTimer=setInterval($.fn.fancybox.animateLoading,66)};
$.fn.fancybox.close=function(){
busy=true;
$(imagePreloader).unbind();
$(document).unbind("keydown.fb");
$(window).unbind("resize.fb scroll.fb");
$("#fancy_overlay, #fancy_content, #fancy_close").unbind();
$("#fancy_close, #fancy_loading, #fancy_left, #fancy_right, #fancy_title").hide();
__cleanup=function(){
if($("#fancy_overlay").is(':visible')){
$("#fancy_overlay").fadeOut("fast")}
$("#fancy_content").empty();
if(opts.centerOnScroll){
$(window).unbind("resize.fb scroll.fb")}
if(IE6){
$('embed, object, select').css('visibility','visible')}
if($.isFunction(opts.callbackOnClose)){
opts.callbackOnClose()}
busy=false};
if($("#fancy_outer").is(":visible")!==false){
if(opts.zoomSpeedOut>0&&opts.itemArray[opts.itemCurrent].orig!==undefined){
var orig_item=opts.itemArray[opts.itemCurrent].orig;
var orig_pos=$.fn.fancybox.getPosition(orig_item);
var itemOpts={
'left':(orig_pos.left-20-opts.padding)+'px',
'top':(orig_pos.top-20-opts.padding)+'px',
'width':$(orig_item).width()+(opts.padding*2),
'height':$(orig_item).height()+(opts.padding*2)
};
if(opts.zoomOpacity){
itemOpts.opacity='hide'}
$("#fancy_outer").stop(false,true).animate(itemOpts,opts.zoomSpeedOut,opts.easingOut,__cleanup)}else{
$("#fancy_outer").stop(false,true).fadeOut('fast',__cleanup)}
}else{
__cleanup()}
return false};
$.fn.fancybox.build=function(){
var html='';
html+='<div id="fancy_overlay"></div>';
html+='<div id="fancy_loading"><div></div></div>';
html+='<div id="fancy_outer">';
html+='<div id="fancy_inner">';
html+='<div id="fancy_close"></div>';
html+='<div id="fancy_bg"><div class="fancy_bg" id="fancy_bg_n"></div><div class="fancy_bg" id="fancy_bg_ne"></div><div class="fancy_bg" id="fancy_bg_e"></div><div class="fancy_bg" id="fancy_bg_se"></div><div class="fancy_bg" id="fancy_bg_s"></div><div class="fancy_bg" id="fancy_bg_sw"></div><div class="fancy_bg" id="fancy_bg_w"></div><div class="fancy_bg" id="fancy_bg_nw"></div></div>';
html+='<a href="javascript:;" id="fancy_left"><span class="fancy_ico" id="fancy_left_ico"></span></a><a href="javascript:;" id="fancy_right"><span class="fancy_ico" id="fancy_right_ico"></span></a>';
html+='<div id="fancy_content"></div>';
html+='</div>';
html+='</div>';
html+='<div id="fancy_title"></div>';
$(html).appendTo("body");
$('<table cellspacing="0" cellpadding="0" border="0"><tr><td class="fancy_title" id="fancy_title_left"></td><td class="fancy_title" id="fancy_title_main"><div></div></td><td class="fancy_title" id="fancy_title_right"></td></tr></table>').appendTo('#fancy_title');
if($.browser.msie){
$(".fancy_bg").fixPNG()}
if(IE6){
$("div#fancy_overlay").css("position","absolute");
$("#fancy_loading div, #fancy_close, .fancy_title, .fancy_ico").fixPNG();
$("#fancy_inner").prepend('<iframe id="fancy_bigIframe" src="javascript:false;" scrolling="no" frameborder="0"></iframe>');
var frameDoc=$('#fancy_bigIframe')[0].contentWindow.document;
frameDoc.open();
frameDoc.close()}
};
$.fn.fancybox.defaults={
padding:10,
imageScale:true,
zoomOpacity:true,
zoomSpeedIn:0,
zoomSpeedOut:0,
zoomSpeedChange:300,
easingIn:'swing',
easingOut:'swing',
easingChange:'swing',
frameWidth:560,
frameHeight:340,
overlayShow:true,
overlayOpacity:0.3,
overlayColor:'#666',
enableEscapeButton:true,
showCloseButton:true,
hideOnOverlayClick:true,
hideOnContentClick:true,
centerOnScroll:true,
itemArray:[],
callbackOnStart:null,
callbackOnShow:null,
callbackOnClose:null
};
$(document).ready(function(){
ieQuirks=$.browser.msie&&!$.boxModel;
if($("#fancy_outer").length<1){
$.fn.fancybox.build()}
})})(jQuery);


/* plugins/auto/fancybox/javascript/fancybox.js */
;
var baselongdesc=function(url){
return $("<link \/>").attr("href",url)[0].href.replace(/^([^/]+:\/\/[^/]*\/).*/,"$1")}
var cachelongdesc={};
var displaylongdesc=function(l){
if((l=l.html())&&(l=l.replace(/^\s*$/,""))){
$("<div id=\'fancy_legend\'>")
.css({opacity:0.9})
.hide()
.html(l)
.appendTo("#fancy_content")
.slideDown("slow")
.click(function(e){cachelongdesc={};e.stopPropagation()});
$("#fancy_img")
.hover(
function(){$("#fancy_legend").slideUp()},
function(){$("#fancy_legend").slideDown()}
)}
}
var showlongdesc=function(c){
var l=c.itemArray[c.itemCurrent]
if(l&&l.orig&&l.orig[0])
l=$(l.orig[0]).attr("longdesc");
else
l=null;
if(l){
if(l.match(/^#/)){
displaylongdesc($(l))}
else{
if(baselongdesc(l)==baselongdesc(window.location)){
var url=l.replace(/#.*/,"");
var sel=l.replace(/^[^#]*/,"")||">*";
if(cachelongdesc[url])
displaylongdesc($(sel,cachelongdesc[url]));
else
$.get(url,function(e){
cachelongdesc[url]="<xml>"+e+"</xml>";
displaylongdesc($(sel,cachelongdesc[url]))})}
else{
displaylongdesc(
$("<a>afficher la l&eacute;gende</a>")
.onclick()
.wrap("<div \/>")
.attr("href",l)
.parent()
)}
}
}
}
var hideembed=function(){
if(!navigator.platform.match('Mac')){
jQuery('embed[wmode!=transparent]:visible').addClass('fancy_cache').css('visibility','hidden')
.parents('object').addClass('fancy_cache').css('visibility','hidden')}
}
var showembed=function(){
if(!navigator.platform.match('Mac')){
jQuery('.fancy_cache').removeClass('.fancy_cache').css('visibility','visible')}
}
var fancy_init=function(){
$("a[type=\'image/jpeg\'],a[type=\'image/png\'],a[type=\'image/gif\']",this)
.addClass("fancybox")
.attr("onclick","")
.fancybox();
$(fb_selecteur_galerie,this).attr("rel","galerie-portfolio");
$(fb_selecteur_commun,this)
.fancybox(fb_commun_options);
$(fb_selecteur_frame,this)
.fancybox(fb_frame_options)};


/* page=socialtags.js */
;

;var socialtags_addfavorite=function(u,t){
if(document.all)window.external.AddFavorite(u,t)};
(function($){
var socialtags_init=function(){
var selector=$('#socialtags');
if(!selector.length)return;
var socialtags=[
{a:'bookmark',n:'Ajouter aux favoris',i:'plugins/auto/socialtags/images/bookmark.png',u:'javascript:socialtags_addfavorite(\'%u\',\'%t\');'},
{a:'delicious',n:'Del.icio.us',i:'plugins/auto/socialtags/images/delicious.png',u:'http://delicious.com/save?url=%u&title=%t&notes=%d'},
{a:'facebook',n:'Facebook',i:'plugins/auto/socialtags/images/facebook.png',u:'http://www.facebook.com/sharer.php?u=%u&t=%t'},
{a:'google',n:'Google',i:'plugins/auto/socialtags/images/google.png',u:'http://www.google.com/bookmarks/mark?op=edit&bkmk=%u&title=%t'},
{a:'live',n:'Live',i:'plugins/auto/socialtags/images/live.png',u:'https://favorites.live.com/quickadd.aspx?marklet=1&add=%u&title=%t'},
{a:'netvibes',n:'Netvibes',i:'plugins/auto/socialtags/images/netvibes.png',u:'http://www.netvibes.com/subscribe.php?url=%u'},
{a:'pioche',n:'Pioche',i:'plugins/auto/socialtags/images/pioche.png',u:'http://www.pioche.fr/soumettre_nouvelle.php?url=%u'},
{a:'simpy',n:'Simpy',i:'plugins/auto/socialtags/images/simpy.png',u:'http://simpy.com/simpy/LinkAdd.do?href=%u&title=%t'},
{a:'slashdot',n:'Slashdot',i:'plugins/auto/socialtags/images/slashdot.png',u:'http://slashdot.org/bookmark.pl?url=%u&title=%t'},
{a:'technorati',n:'Technorati',i:'plugins/auto/socialtags/images/technorati.png',u:'http://technorati.com/faves?add=%u'},
{a:'tumblr',n:'Tumblr',i:'plugins/auto/socialtags/images/tumblr.png',u:'http://www.tumblr.com/share?v=3&u=%u&t=%t&s='},
{a:'twitter',n:'Twitter',i:'plugins/auto/socialtags/images/twitter.png',u:'http://twitter.com/home?status=%u'},
{a:'viadeo',n:'Viadeo',i:'plugins/auto/socialtags/images/viadeo.png',u:'http://www.viadeo.com/shareit/share/?url=%u&title=%t'},
{a:'yahoobookmarks',n:'Yahoo! Bookmarks',i:'plugins/auto/socialtags/images/yahoobookmarks.png',u:'http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&u=%u&t=%t'},
{a:'buzzyahoo',n:'Yahoo! Buzz',i:'plugins/auto/socialtags/images/buzzyahoo.png',u:'http://buzz.yahoo.com/submit?submitUrl=%u&submitHeadline=%t&submitSummary=%d'}
];
var title=$('title').text()||'';
var description=($('meta[name=description]').attr('content')||'').substr(0,250);
var cano=$('link[rel=canonical]')[0];
var url=cano?cano.href:document.location.href;
var ul=$('<ul><\/ul>');
var esc=function(x){return encodeURIComponent(x).replace(/\s/g,' ')};
var ref=document.referrer.match(/^.*\/\/([^\/]+)\//);
if(ref&&ref[1].match(/\.facebook\./))
$.cookie('social_facebook',1,{path:'/',expires:30});
$.each(socialtags,function(){if(this.u){
if(this.a=='bookmark'&&!document.all)return;
$('<a rel="nofollow"><img class="socialtags-hovers" src="'+this.i+'"\/><\/a>')
.attr('href',
this.u
.replace(/%u/g,esc(url))
.replace(/%t/g,esc(title))
.replace(/%d/g,esc(description))
)
.attr('title',this.n)
.wrap('<li><\/li>')
.parent().appendTo(ul)}});
selector.after(ul.wrap('<div class="socialtags"><\/div>').parent())};
$(function(){
$(socialtags_init)})})(jQuery);



