function bookmark(url, title)
{
	if(window.sidebar)
	{ // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	}
	else if(window.external)
	{ // IE Favorite
		window.external.AddFavorite(url, title);
	}
}
function homepage(me)
{
	var url = 'http://kongfumonkey.com/';
	if(window.sidebar)
	{ // Mozilla Firefox Bookmark
		alert("Your browser doesn't support this function. Please set your homepage manually. Thank you.");
	}
	else if(window.external)
	{ // IE Favorite
		me.style.behavior='url(#default#homepage)';
		me.setHomePage(url)
	}
}
function check_english(input)
{
	for(var i=0;i<input.value.length;++i)
	{
		var c = input.value.charAt(i);
		if(	(c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') )
			continue;
		if( c=='_' )
			continue;
		return false;
	}
	return true;
}
function checkEmail(input)
{
	var at_rindex = input.value.lastIndexOf("@");
	var at_index = input.value.indexOf("@");
	var c_index = input.value.indexOf(".",at_rindex);
	var c_rindex = input.value.lastIndexOf(".",at_rindex);
	var ret = (at_rindex==at_index && at_index>0 && c_index>2 && (at_index+1)<c_index && c_rindex<input.value.length-1);
	return ret;
}
function report_bad_link(gameIndex)
{
	if(confirm("Do you want to report a dead-link or game broken for this page?"))
		top.location.href="http://kongfumonkey.com/report_bad_link.php?game_index="+gameIndex;
}
function back_site(gameIndex)
{
	var url = "http://kongfumonkey.com/game_detail.php?game_index="+gameIndex;
	if(top.opener!=null && !top.opener.closed)
	{
		top.opener.location.href = url;
		top.opener.focus();
		top.close();
	}
	else
	{
		top.location.href=url;
	}
	
	return false;
}
function on_rate(theform, gameIndex)
{
	var rate = parseInt(theform.score[theform.score.selectedIndex].value);
	if(rate >= 1 && rate <= 5)
	{
		var win = open("http://kongfumonkey.com/rate_game.php?game_index="+gameIndex+"&rate="+rate,"gpsrategame","width=325,height=120,scrollbars=0,toolbar=0,resizable=1");
		win.focus();
	}
	else
	{
		alert("½Ð¿ï¾Üµû¤À");
	}
}
function goplay(gameIndex, ageconfirm)
{
	if(ageconfirm && !confirm("This game may contain violence or nudity.\nYou need to be 18+ to play this game!"))
		return false;
	var win = open("http://kongfumonkey.com/game_play.php?game_index="+gameIndex,"playgame", "width=810,height=700,scrollbars=1,toolbar=0,resizable=1");
	if(win && !win.closed)
		return false;
	return true;
}
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_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;
}

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 email_user(uid)
{
	var win = open("http://kongfumonkey.com/email_user.php?uid="+uid,"email_user","width=325,height=160,scrollbars=0,toolbar=0,resizable=1");
	win.focus();
	return false;
}
function contact_us()
{
	var win = open("http://kongfumonkey.com/contact_us.php","contactus","width=325,height=350,scrollbars=0,toolbar=0,resizable=1");
	win.focus();
	return false;
}

function del_cmt(index)
{
	if(confirm("Are you sure that you want to delete this article?"))
	{
		var win = open("http://kongfumonkey.com/update_comment.php?op=del&index="+index,"update_comment","width=325,height=120,scrollbars=0,toolbar=0,resizable=1");
	}
	return false;
}
function edit_cmt(index)
{
	var win = open("http://kongfumonkey.com/update_comment.php?op=edit&index="+index,"update_comment","width=325,height=120,scrollbars=0,toolbar=0,resizable=1");
	win.focus();
	return false;
}
function reply_cmt(index)
{
	var win = open("http://kongfumonkey.com/read_comment.php?index="+index+"#reply","read_comment","width=500,height=400,scrollbars=1,toolbar=0,resizable=1");
	win.focus();
	return false;
}
function read_cmt(index)
{
	var win = open("http://kongfumonkey.com/read_comment.php?index="+index,"read_comment","width=500,height=400,scrollbars=1,toolbar=0,resizable=1");
	win.focus();
	return false;
}
