// {0} id
// {1} type
function getLikeCode() {
	/*return '<iframe src="http://www.facebook.com/plugins/like.php?app_id=100144803417702&amp;href=http%3A%2F%2Funo.mycosme.com.tw%2F%23%2Fgame%3Fid%3D{0}%26type%3D{1}%26usite%3Dfb_02&amp;send=false&amp;layout=button_count&amp;width=170&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:170px; height:21px;" allowTransparency="true"></iframe>';*/
	
	return '<iframe src="http://www.facebook.com/plugins/like.php?app_id=100144803417702&amp;href=http://uno.mycosme.com.tw/game.aspx?id={0}%26type={1}%26usite=fb_02&amp;send=false&amp;layout=button_count&amp;width=170&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:170px; height:21px;" allowTransparency="true"></iframe>';
}

function showLike(id, type) {
	var likeCode = getLikeCode();
	var obj = new Array(2);
	obj[0] = id;
	obj[1] = type;
	
	var likeHtml = messageFormat(likeCode, obj);
	
	_onResize();
	$('#likeBox').css('display', 'none').html(likeHtml).show();
}

function closeLike() {
	$('#likeBox').hide();
}

function _onResize() {
	var setOffX = 101;
	var setOffY = -209;
			
	var center = $("#content").width() >> 1;
	var middle = $("#content").height() >> 1;
			
	$("#alignment").width($("#content").width()).css("{ 'top': 0, 'left': 0 }");
	
	$("#likeBox").css("left", (center + setOffX) + "px");
	
	$("#likeBox").css("left", (center + setOffX) + "px");
	$("#likeBox").css("top", (middle + setOffY) + "px");
	
	/*if ($("#content").width() <= 1000) {
		$("#likeBox").css("left", (500 + setOffX) + "px");
	} else {
		$("#likeBox").css("left", (center + setOffX) + "px");
	}
			
	if ($("#content").height() <= 600) {
		$("#likeBox").css("top", (300 + setOffY) + "px");
	} else {
		$("#likeBox").css("top", (middle + setOffY) + "px");
	}*/
}

function messageFormat( _tmp , obj) {
	var text = _tmp;
	for(var i = 0 ; i < obj.length ; i ++){
		var oldstr = "{" + i + "}";
		while( text.indexOf(oldstr) != -1 ) {
			text = text.replace(oldstr ,  obj[i]);
		}
	}
	return text;
}

