var gameHandler=Class.create();
gameHandler.prototype={initialize:function(){
this.img_id="";
this.type="";
this.cid=0;
this.parent=null;
this.left_index=-2;
this.right_index=-1;
this.pictures=new Array();
this.img_win="/style/images/won.jpg";
this.img_pow="/style/images/pow.jpg";
},addPictures:function(_1){
eval("this.pictures = ("+_1+")");
this.showPictures();
},showPictures:function(){
if(this.left_index+2>this.pictures.length){
this.left_index=0;
this.right_index=1;
}else{
this.left_index=this.left_index+2;
}
if(this.right_index+2>this.pictures.length){
this.left_index=0;
this.right_index=1;
}else{
this.right_index=this.right_index+2;
}
$("img-main-left").src=this.pictures[this.left_index]["image"];
$("img-main-left").alt=this.pictures[this.left_index]["title"];
$("img-main-left").title=this.pictures[this.left_index]["title"];
$("href-main-left").href="/media/"+this.pictures[this.left_index]["url_title"];
$("img-main-right").src=this.pictures[this.right_index]["image"];
$("img-main-right").alt=this.pictures[this.right_index]["title"];
$("img-main-right").title=this.pictures[this.right_index]["title"];
$("href-main-right").href="/media/"+this.pictures[this.right_index]["url_title"];
$("a-main-left").onclick=function(){
this.votePicture(this.pictures[this.left_index]["id"],this.pictures[this.right_index]["id"],"left");
return false;
}.bind(this);
$("a-main-right").onclick=function(){
this.votePicture(this.pictures[this.right_index]["id"],this.pictures[this.left_index]["id"],"right");
return false;
}.bind(this);
},votePicture:function(_2,_3,_4){
this.win_id=_2;
this.pow_id=_3;
switch(_4){
case "left":
$("img-main-left").src=this.img_win;
$("img-main-right").src=this.img_pow;
break;
case "right":
$("img-main-right").src=this.img_win;
$("img-main-left").src=this.img_pow;
break;
}
$("a-main-left").onclick=function(){
};
$("a-main-right").onclick=function(){
};
this.ajaxVotePicture();
},ajaxVotePicture:function(){
var _5="/ajax";
var _6="game=1&win_id="+this.win_id+"&pow_id="+this.pow_id;
var _7=new Ajax.Request(_5,{method:"post",parameters:_6,onComplete:this.ajaxVotePictureComplete.bindAsEventListener(this)});
},ajaxVotePictureComplete:function(o){
this.showPictures();
},cookieAddAllVotes:function(){
var _9=this.getCookie(this.cookie_all_votes_name);
var _a=_9.split(",");
if(_9.length==0){
_9+=this.img_id;
}else{
if(_9.indexOf(this.img_thumb)==-1){
_9+=","+this.img_id;
}else{
return false;
}
}
this.setCookie(this.cookie_all_votes_name,_9,this.getExpireDate(1),"",this.domain,"");
return true;
},cookieAddVote:function(){
this.cookieAddAllVotes();
var _b=this.getCookie(this.cookie_name);
var _c=_b.split(",");
if(_b.length==0){
_b+=this.img_thumb;
}else{
if(_b.indexOf(this.img_thumb)==-1){
if(_c.length<this.cookie_limit){
_b+=","+this.img_thumb;
}else{
_c.shift();
_c.push(this.img_thumb);
_b=_c.toString();
this.removeFirstVote();
}
}else{
return false;
}
}
this.setCookie(this.cookie_name,_b,this.getExpireDate(365),"",this.domain,"");
if(!$("wrn-no-votes").hasClassName("hidden")){
$("wrn-no-votes").addClassName("hidden");
}
if($("votes-del-all").hasClassName("hidden")){
$("votes-del-all").removeClassName("hidden");
}
return true;
},cookieRemoveVote:function(id,_e){
var _f=new Array();
var _10=this.getCookie(this.cookie_name).split(",");
_10.each(function(_11){
if(_11!=_e){
if(_f==""){
_f+=_11;
}else{
_f+=","+_11;
}
}
});
this.deleteCookie(this.cookie_name,"",this.domain);
if(_f!=""&&_f!="/"){
this.setCookie(this.cookie_name,_f,this.getExpireDate(365),"",this.domain,"");
if(!$("wrn-no-votes").hasClassName("hidden")){
$("wrn-no-votes").addClassName("hidden");
}
if($("votes-del-all").hasClassName("hidden")){
$("votes-del-all").removeClassName("hidden");
}
}else{
$("wrn-no-votes").removeClassName("hidden");
$("votes-del-all").addClassName("hidden");
}
},setCookie:function(_12,_13,_14,_15,_16,_17){
var _18=_12+"="+escape(_13)+((_14)?"; expires="+_14:"")+((_15)?"; path="+_15:"/")+((_16)?"; domain="+_16:"")+((_17)?"; secure":"");
document.cookie=_18;
},getCookie:function(_19){
var _1a=_19+"=";
var c=document.cookie;
var _1c="";
var _1d=c.indexOf(_1a);
if(_1d==-1){
return _1c;
}
var _1e=c.indexOf(";",_1d+_1a.length);
if(_1e==-1){
_1e=c.length;
}
return unescape(c.substring(_1d+_1a.length,_1e));
},deleteCookie:function(_1f,_20,_21){
if(this.getCookie(_1f)){
document.cookie=_1f+"="+((_20)?"; path="+_20:"/")+((_21)?"; domain="+_21:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
},getExpireDate:function(day){
var _23;
Today=new Date();
nomilli=Date.parse(Today);
Today.setTime(nomilli+day*24*60*60*1000);
_23=Today.toUTCString();
return _23;
}};

