function igoorooPlayGame(GameURL) 
{ 
    w = 1204;
    h = 768;
    	
	if(screen.width) 
	{ 
		x = (screen.width-w)/2 - 10;
		y = (screen.height-h)/2 - 20;
	} 
   	else 
   	{ 
		x = 150;
		y = 100;
	} 
	win = window.open(GameURL,'play','location=no, menubar=no, toolbar=no, resizable=yes, status=no, scrollbars=yes,width='+w+',height='+h+',top='+y+',left='+x); 
}

var wd = parent.screen.availWidth;
var hg = parent.screen.availHeight;
function MM_openBrWindow(theURL) { 
	window.open(theURL,'','left=0,top=0,width='+wd+',height='+hg+',toolbar=no,location=yes,menubar=no,status=no,resizble=1,scrollbars=1')
}

function CopyGameURL( input ) 
{
	copied = input.createTextRange();
	input.focus();
	input.select();
	copied.execCommand("Copy");
}

//星星評分
function igooroo_swapImage(a,b,c) { //v3.0
	for(i=1;i<=c;i++) {
		document.getElementById("start"+i).src = b;
	}
	for(i=(c+1);i<=5;i++) {
		document.getElementById("start"+i).src = "/img/ico_startB.png";
	}
}
function igooroo_swapImgRestore(a) { //v3.0
	for(i=1;i<=a;i++) {
		document.getElementById("start"+i).src = "/img/ico_start.png";
	}
	for(i=(a+1);i<=5;i++) {
		document.getElementById("start"+i).src = "/img/ico_startB.png";
	}
}

function MM_preloadImages() { //v3.0預先載入圖片
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function AJAX_Like(likethe,GameID) {
	document.getElementById("DoYouLike").innerHTML = '<img src="/img/ajax-loading.gif"/>';	
	XMLHttpRequestObject.open("GET", "/likegameXML.php?yesorno=" + likethe + "&gameid=" + GameID);
	XMLHttpRequestObject.send(null);
	XMLHttpRequestObject.onreadystatechange = function() {
   		if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
			s_Yes = XMLHttpRequestObject.responseXML.getElementsByTagName("Yes");
			s_No = XMLHttpRequestObject.responseXML.getElementsByTagName("No");	
			document.getElementById("DoYouLike").innerHTML = "謝謝你的投票。";	
			
        	document.getElementById("YesLike").width = s_Yes[1].firstChild.nodeValue;
			document.getElementById("YesLikeNo").innerHTML = s_Yes[0].firstChild.nodeValue;	
			document.getElementById("YesLikeP").innerHTML = s_Yes[2].firstChild.nodeValue;			

			document.getElementById("NoLike").width = s_No[1].firstChild.nodeValue;
			document.getElementById("NoLikeNo").innerHTML = s_No[0].firstChild.nodeValue;	
			document.getElementById("NoLikeP").innerHTML = s_No[2].firstChild.nodeValue;		
    	}
	}
}
function AJAX_GameMarkerAdd(GameID) {
	document.getElementById("gamemarker").innerHTML = '<img src="/img/ajax-loading.gif"/>';	
	XMLHttpRequestObject.open("GET", "/marker/add/" + GameID);
	XMLHttpRequestObject.send(null);
	XMLHttpRequestObject.onreadystatechange = function() {
   		if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
			document.getElementById("gamemarker").innerHTML = XMLHttpRequestObject.responseText;
    	}
	}
}
function AJAX_GameMarkerDel(GameID) {
	document.getElementById("gamemarker").innerHTML = '<img src="/img/ajax-loading.gif"/>';	
	XMLHttpRequestObject.open("GET", "/marker/del/" + GameID);
	XMLHttpRequestObject.send(null);
	XMLHttpRequestObject.onreadystatechange = function() {
   		if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
			document.getElementById("gamemarker").innerHTML = XMLHttpRequestObject.responseText;
    	}
	}
}

function postsocial(cate,GameID){ //分享到社群網站
	var _global_basehref='http://www.igooroo.net/';
	var url=(_global_basehref)?_global_basehref:location.href;
	url+='info/' + GameID + '.html';
	var tit=document.title;
	if(cate == 'f'){
		window.open('http://www.facebook.com/share.php?u='.concat(encodeURIComponent(url)));
	}
	if(cate == 'p'){
		window.open('http://www.plurk.com/?qualifier=shares&status='.concat(encodeURIComponent(url)).concat(' ').concat('(').concat(encodeURIComponent(tit)).concat(')'));
	}
	if(cate == 't')	{
		window.open('http://twitter.com/home/?status='.concat(encodeURIComponent(tit)).concat(' ').concat(encodeURIComponent(url)));
	}
}

function UpHowStart(a,GameID) {
	document.getElementById("StartImg").innerHTML = '<img src="/img/ajax-loading.gif"/>';	
	XMLHttpRequestObject.open("GET", "/startgameXML.php?start=" + a + "&gameid=" + GameID);
	XMLHttpRequestObject.send(null);
	XMLHttpRequestObject.onreadystatechange = function() {
   		if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
        	document.getElementById("StartImg").innerHTML = XMLHttpRequestObject.responseText;
    	}
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
