var globar_root_path = ""

var voteAllow = true;
function setVote(game_idx, vote_type){
	if (voteAllow != true) return;
	voteAllow = false;
	new Ajax.Request(globar_root_path + '/ajax/setVote.asp',{
		parameters:{
			game_idx:game_idx,
			vote_type:vote_type
		},
		onSuccess:function(res){
			new Ajax.Request(globar_root_path + '/ajax/loadVoteBar.asp',{
				parameters:{
					game_idx:game_idx
				},
				onSuccess:function(res){
					$("rate").update(res.responseText);
				},
				onFailure:function(res){
					voteAllow = true;
					alert(res.responseText);
				}
			}) ;
		},
		onFailure:function(res){
			voteAllow = true;
			alert(res.responseText);
		}
	}) ;
}


var mygameAllow = true;
function setMygame(game_idx){
	var result;
	if (mygameAllow != true) return;
	mygameAllow = false;
	new Ajax.Request(globar_root_path + '/ajax/setMygame.asp',{
		parameters:{
			game_idx:game_idx
		},
		onSuccess:function(res){
			mygameAllow = true;
			result = res.responseText;
			switch (result)
			{
			case "0" :
				alert("Please Login");
				break;
			case "-1" :
				alert("Already exist my games");
				break;
			case "1" :
				alert("Added my games");
				break;
			}
		},
		onFailure:function(res){
			mygameAllow = true;
			alert(res.responseText);
		}
	}) ;
}

function delMygame(game_idx){
	if (!confirm("Delete this game in mygames list?"))
	{
		return;
	}
	new Ajax.Request(globar_root_path + '/ajax/delMygame.asp',{
		parameters:{
			game_idx:game_idx
		},
		onSuccess:function(res){
			document.location.reload();
		},
		onFailure:function(res){
			alert(res.responseText);
		}
	}) ;
}


function setFeatured(game_idx,featured_type){
	new Ajax.Request(globar_root_path + '/ajax/setFeatured.asp',{
		parameters:{
			game_idx:game_idx,
			featured_type:featured_type
		},
		onSuccess:function(res){
			document.location.reload();
		},
		onFailure:function(res){
			alert(res.responseText);
		}
	}) ;
}

function fullOpen(_u,_name){
	var myWin = window.open(_u,_name,"toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,top=0,left=0,width=" + screen.availWidth + ",height=" + screen.availWidth + "");
	myWin.focus();
}

function searchChk(form){
	var game_q = form.game_q.value;
	if (game_q.length < 2)
	{
		return false;
	}
	return true;
}

function selectShare(_name){
	$(_name).focus();
	$(_name).select();
}

