function killErrors(){return true;}
//window.onerror=killErrors;
  /*  function $(id){
	   return document.getElementById(id);
	 }*/
	
	 var blnDragging;
var vminLimit= 5; 
var vmaxLimit= 100; 

var zoomstate=50;

var playfjd;
var blnDragging=false;
var mPosX;
var mousepositionX;
function readyDragV(){
	
 if(document.layers){return false;}
 var evt=getEvent();
 mPosX=evt.clientX;
 playfjd=zoomstate.style.width;
 blnDragging=true;
 document.onmousemove=volTrackingV;
} 
    var startGameWidth = 32;
    var startGameHeight = 1024;
    function zoomObject(pos){
		if(_gamemode==1)
		{
        var newWidth = Math.ceil( pos*startGameWidth/100 );
        var newHeight = Math.ceil( pos*startGameHeight/100 );
		newWidth=Math.ceil(pos*startGameWidth/10 * _gamewidth)
		newHeight=Math.ceil(pos*startGameWidth/10 * _gameheight)
        $("#swfobj").css("width", newWidth+"px");
		$("#swfobj").css("height",newHeight+"px");
		$("#play").css("width",newWidth+"px");
		$("#play").css("height", newHeight+"px");
		$("#w1").css("width", (newWidth+10)+"px");
		$("#w2").css("width", (newWidth+10)+"px");
		$("#w3").css("width", newWidth+"px");
		$("#w4").css("width", (newWidth+30)+"px");
		}

    }
function volTrackingV(){

	var evt=getEvent();
	mousepositionX=evt.clientX;
	
	if (blnDragging ){
		
		var sliderLength= vmaxLimit;
		var mov =  parseInt(playfjd) + mousepositionX - mPosX;
		
		if(mov <= vminLimit){
			zoomstate.style.width=vminLimit+"px";
			zoomObject(10);
		}
		if(mov > vmaxLimit){
			zoomstate.style.width=vmaxLimit+"px";
			zoomObject(100);
		}
		if ((mov <= vmaxLimit) &&  (mov > vminLimit )){
			zoomstate.style.width=parseInt(playfjd) + mousepositionX - mPosX+"px";
			zoomObject(mov);
		}
	}return false;
}
function overDrag()
{
	blnDragging=false;
	return false;
}
document.write("<script language='JavaScript' src='/stat/?GameId="+_gameid+"'></script>");

function picxh(comid)
{
	$.post("/vote.asp",{ id:_gameid,act:comid,'rand':Math.random() },
		   function(data){
		//	eval('var dataobj='+data);
		//	document.write(dataobj);
			if (data=="ok") {alert("Thanks for your vote!");ChangeVoteState(2);} else {alert("You've already rated this game");}
		   } 
		); 

}
function zoom_out(){
	zoomstate =  zoomstate + 10;
	if (zoomstate<10) { zoomstate=10;}

	zoomObject(zoomstate);
	
}
function normal()
{
	zoomstate = 50;
	
	zoomObject(zoomstate);
}
function zoom_in(){
	zoomstate =  zoomstate - 10;
	if (zoomstate > 100){  zoomstate=100;}
	
	zoomObject(zoomstate);
}
function CreateBookmarkLink(url,title){
	if(window.sidebar&&!document.all){window.sidebar.addPanel(title,url,"");}
	else
	if(window.external){window.external.AddFavorite(url,title);}
	else
	if(window.opera&&window.print){return false;}
}
function getEvent(){ //
   if(document.all) return window.event; 
   func=getEvent.caller; 
   while(func!=null){ 
   var arg0=func.arguments[0]; 
   if(arg0){ 
       if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){ 
          return arg0; 
       } 
   } 
   func=func.caller; 
  } 
  return null; 
}
function CopyCode(c)
{
  c.select()
  text = c.value;
  window.clipboardData.setData("text", text);
  alert("Copy this code to your page");
}

function ChangeVoteState(act){
	if(act==1)
	{
		
		$.post("/svote.asp",{ id:_gameid,'rand':Math.random() },
		   function(data){
		//	eval('var sText='+data);
			if (data){cmtini(data,act);}
		   } 
		); 
		
	}
	else
	{
		$.post("/svote.asp",{ id:_gameid,'rand':Math.random() },
		   function(data){
			//eval('var sText='+data);
			if (data.indexOf(":")>0){cmtini(data,act);} else {alert(data);}
		   } 
		); 
		
	}
}
function cmtini(tempv,act)
{
	tempvalue=tempv.split(':');
	if (act==2)
	{
	//    $("sgood").disabled="disabled";
	//    $("sbad").disabled="disabled";
	}
	$("#good").html(tempvalue[0]+" votes");
	$("#bad").html(tempvalue[1]+" votes");
        var temptotal;
        temptotal=Math.floor(tempvalue[0])+Math.floor(tempvalue[1]);
        if (temptotal==0)
            temptotal=1;
	$("#goodw").css("width",Math.round(Math.floor(tempvalue[0])*100/(temptotal)*10)/10+"%");
	$("#pro").html(Math.round(Math.floor(tempvalue[0])*100/(temptotal)*10)/10+"%");
}
function addPlaylist(){
	var playListID = $.cookie('hasplaylistID');
	var playID = [_gameid,fdirnum,_gamename,picurl];
	if(playListID!=null){
		if(playListID.indexOf(_gameid+'|')==-1){
			$.cookie('hasplaylistID',playID.join('|') + '$' + playListID,{path:'/',expires:7});
			if($.cookie('hasplaylistID').split('$').length>20){
				$.cookie('hasplaylistID',$.cookie('hasplaylistID').split('$').slice(0,20).join('$'),{path:'/',expires:7});
			}
		}
		else{
			if($.cookie('hasplaylistID').split('$').length==1){
				$.cookie('hasplaylistID',playID.join('|'),{path:'/',expires:7});
			}
			else{
				var aryPlist = $.cookie('hasplaylistID').split('$');
				var p = 0;
				for(var i=0;i<aryPlist.length;i++){
					if(aryPlist[i].indexOf(_gameid+'|')==0) break;
					p++;
				}
				aryPlist.splice(p,1);
				$.cookie('hasplaylistID',playID.join('|') + '$' + aryPlist.join('$'),{path:'/',expires:7});
			}
		}
	}else{
		$.cookie('hasplaylistID',playID.join('|'),{path:'/',expires:7});
	}
}
ChangeVoteState(1);
addPlaylist();

