function LoadTab()
{
    var valueCat = document.getElementById("hidCatID").value;
    var objCatID= valueCat.split(",");    
    var objTab=document.getElementById("div_"+objCatID[1]);
    if (objTab)
    {
        objTab.className="active";
    }
    if(objCatID[0]=="8" || objCatID[0]=="143")
        document.getElementById('subMenu').innerHTML = "<li><a href='/home/game-online/cong-dong.chn' style='margin-left:120px;' id='li_143'>Cộng đồng</a></li>";    
    else if(objCatID[0]=="109" || objCatID[0]=="146")
        document.getElementById('subMenu').innerHTML = "<li><a href='/home/esport/kinh-nghiem.chn' style='margin-left:295px;' id='li_146'>Kinh nghiệm - Replay</a></li>";     
    else if(objCatID[0]=="103" || objCatID[0]=="134")
        document.getElementById('subMenu').innerHTML = "<li><a href='/home/hi-tech/thu-thuat.chn' style='margin-left:610px;' id='li_134'>Thủ thuật</a></li>"; 
    else if(objCatID[0]=="141" || objCatID[0]=="164" || objCatID[0] == "165")
        document.getElementById('subMenu').innerHTML = "<li><a href='/home/photo-video/photo.chn' style='margin-left:610px;' id='li_141'>Photo</a></li><li style=\"padding-left:10px\"><a href='/home/photo-video/video.chn' id='li_165'> Video</a></li>";
    else if(objCatID[0]=="166" || objCatID[0]=="167" || objCatID[0] == "168")
    document.getElementById('subMenu').innerHTML = "<li><a href='/home/game-societini/game-society.chn' style='margin-left:200px;' id='li_167'>Game Society</a></li><li style=\"padding-left:10px\"><a href='/home/game-societini/mini-game.chn' id='li_168'>Mini Game</a></li>";
    else if(objCatID[0]=="170" || objCatID[0]=="171" || objCatID[0] == "182")
    document.getElementById('subMenu').innerHTML = "<li><a href='/home/pre-review/review.chn' style='margin-left:455px;' id='li_171'>Review</a></li><li style=\"padding-left:10px\"><a href='/home/pre-review/preview.chn' id='li_182'>Preview</a></li>";
    
    var objChild=document.getElementById("li_"+objCatID[0]);
    if (objChild)
    {
        objChild.className="active";
    }
}
/*Danh cho header-Tim kiem*/
function HideTextSearch(textSearch)
{       
    textSearch.value = "";
}
function ShowTextSearch(textSearch)
{
    if (textSearch != null && textSearch.value.length == 0)
    {
        textSearch.value = "Tìm kiếm trang Gamek";
    }
}
function DoSearch(id)
{        
    var keySearch=id.value;
    if (document.all)
        window.location = "/Search.aspx?key=" + keySearch;
    else
        document.location = "/Search.aspx?key=" + keySearch;
}
function doClickTimTin(buttonName,event,strKey)
{
    var keySearch=strKey.value;
    var key;
    var url="/Search.aspx?key="+keySearch;
    if(window.event)
    {
        /*IE*/
        key = window.event.keyCode; 
        if (key == 13)
        {
            if(keySearch!="")
            {   
                document.location.href = url;
                /*event.keyCode = 0;*/                      
                return false;
            }
            else
            {
                alert("Bạn chưa nhập từ khóa tìm kiếm !");
                return false;
            }
        }    
    }
    else
    {
        /*FF*/
        key =event.which;
        if (key == 13)
        {
            if(keySearch!="")
            {
                document.location.href = url;
                /*event.keyCode = 0;*/
                return false;
            }
            else
            {
                alert("Bạn chưa nhập từ khóa tìm kiếm !");
                return false;
            }
        }    
    }
}
function writeBoxReplyCommentGameK(userReply){
var str='';
str+='    <div class="f_l b_s_1_w bg_ccc w_425" id="divCommentReply">';
str+='    <div style="overflow:hidden"><img onmouseout="LoadImagesTraLoi(this,\'\/Images\/gui\/Comment_r2_c4.jpg\');" onmouseover="LoadImagesTraLoi(this,\'\/Images\/gui\/Comment_r2_c2.jpg\');" src="\/Images\/gui\/Comment_r2_c4.jpg" width="15px" style="float:right;cursor:pointer" onclick="ClosePopupReply();"></div>  ';
str+='        <div class="f_l p_l_10 p_t_10 w_414" style="font-family: Times New Roman; font-size: 20px; font-weight: bold;';
str+='            color: Black;">';
str+='            <div class="f_l">Trả lời bình luận<\/div>';
str+='        <\/div>';
str+='        <div class="w_370 f_l p_t_16">';
str+='            <div class="w_97 f_l" style="font-family: Times New Roman; color: #333333; font-size: 15px;">';
str+='                Tên của bạn:';
str+='            <\/div>';
str+='            <div class="f_l">';
str+='                <input onkeyup="telexingVietUC(this,event);" id="txtNameReply" type="text" style="width: 200px;border:solid 1px #666666" \/><font color="red">  *<\/font>';
str+='            <\/div>';
str+='        <\/div>';
str+='        <div class="w_370 f_l p_t_16">';
str+='            <div class="w_97 f_l" style="font-family: Times New Roman; color: #333333; font-size: 15px;">';
str+='                Mail của bạn:';
str+='            <\/div>';
str+='            <div class="f_l">';
str+='                <input id="txtMailReply" type="text" style="width: 200px; border:solid 1px #666666" \/><font color="red">  *<\/font>';
str+='            <\/div>';
str+='        <\/div>';
str+='        <div class="w_370 f_l p_l_10 p_t_20">';
str+='            <div class="f_l"><input id="telex" type="radio" checked="CHECKED" title="Telex" onfocus="setTypingMode(1);" name="TV" \/>Telex  ';
str+='            <input id="vni" type="radio" title="VNI" onfocus="setTypingMode(1);" name="TV" \/>VNI   ';
str+='            <input id="none" type="radio" title="None" name="TV" onfocus="setTypingMode(0);" \/>None  ';
str+='            <img style="cursor: pointer" src="/images/gui/emoticon.png" border="0" onclick="EMOTICONReply.show(\'txtContentReply\')"\/><\/div>';
str+='        <\/div>';
str+='        <div class="f_l p_l_10 p_t_8">';
str+='            <textarea rows="5" cols="61" id="txtContentReply" onkeyup="telexingVietUC(this,event);" style="width:405px;border: solid 1px #666666; height: 85px; font-family: Arial; font-size: 12px;float:left" >';
str+='@'+userReply+': ';
str+='<\/textarea>';
str+='        <\/div>';
str+='        <div class="w_400 p_t_8 f_r p_b_14 p_r_9">';
str+='            <div class="f_r">';
str+='                <img onmouseout="LoadImagesTraLoi(this,\'/images/gui/traloi.png\');" onmouseover="LoadImagesTraLoi(this,\'/images/gui/btn_send_hover.png\');" src="\/images\/gui\/traloi.png" style="cursor:pointer" onclick="return ValidateSendCommentReply();"  \/>';
str+='            <\/div>';
str+='        <\/div>';
str+='</div>';
return str;
}

function writeBoxReplyCommentGameKChild(userReply){
var str='';
str+='    <div class="f_l b_s_1_w bg_ccc" id="divCommentReply" style="width:392px" >';
str+='    <div style="overflow:hidden"><img onmouseout="LoadImagesTraLoi(this,\'\/Images\/gui\/Comment_r2_c4.jpg\');" onmouseover="LoadImagesTraLoi(this,\'\/Images\/gui\/Comment_r2_c2.jpg\');" src="\/Images\/gui\/Comment_r2_c4.jpg" width="15px" style="float:right;cursor:pointer" onclick="ClosePopupReply();"></div>  ';
str+='        <div class="f_l w_345 p_l_10 p_t_10" style="font-family: Times New Roman; font-size: 20px; font-weight: bold;';
str+='            color: Black;">';
str+='            <div class="f_l">Trả lời bình luận<\/div>';
str+='        <\/div>';
str+='        <div class="w_345 f_l p_t_16">';
str+='            <div class="w_97 f_l" style="font-family: Times New Roman; color: #333333; font-size: 15px;">';
str+='                Tên của bạn:';
str+='            <\/div>';
str+='            <div class="f_l">';
str+='                <input onkeyup="telexingVietUC(this,event);" id="txtNameReply" type="text" style="width: 200px;border:solid 1px #666666" \/><font color="red">  *<\/font>';
str+='            <\/div>';
str+='        <\/div>';
str+='        <div class="w_345 f_l p_t_16">';
str+='            <div class="w_97 f_l" style="font-family: Times New Roman; color: #333333; font-size: 15px;">';
str+='                Mail của bạn:';
str+='            <\/div>';
str+='            <div class="f_l">';
str+='                <input id="txtMailReply" type="text" style="width: 200px; border:solid 1px #666666" \/><font color="red">  *<\/font>';
str+='            <\/div>';
str+='        <\/div>';
str+='        <div class="w_345 f_l p_l_10 p_t_20">';
str+='            <div class="f_l"><input id="telex" type="radio" checked="CHECKED" title="Telex" onfocus="setTypingMode(1);" name="TV" \/>Telex  ';
str+='            <input id="vni" type="radio" title="VNI" onfocus="setTypingMode(1);" name="TV" \/>VNI   ';
str+='            <input id="none" type="radio" title="None" name="TV" onfocus="setTypingMode(0);" \/>None  ';
str+='            <img style="cursor: pointer" src="/images/gui/emoticon.png" border="0" onclick="EMOTICONReply.show(\'txtContentReply\')"\/><\/div>';
str+='        <\/div>';
str+='        <div class="f_l p_l_10 p_t_8">';
str+='            <textarea rows="5" cols="61" id="txtContentReply" onkeyup="telexingVietUC(this,event);" style="width:370px;border: solid 1px #666666; height: 85px; font-family: Arial; font-size: 12px;float:left" >';
str+='@'+userReply+': ';
str+='<\/textarea>';
str+='        <\/div>';
str+='        <div class="w_400 p_t_8 f_r p_b_14 p_r_9">';
str+='            <div class="f_r">';
str+='                <img onmouseout="LoadImagesTraLoi(this,\'/images/gui/traloi.png\');" onmouseover="LoadImagesTraLoi(this,\'/images/gui/btn_send_hover.png\');" src="\/images\/gui\/traloi.png" style="cursor:pointer" onclick="return ValidateSendCommentReply();"  \/>';
str+='            <\/div>';
str+='        <\/div>';
str+='</div>';
return str;
}

   
function showtextReply(ctr)
{
    if(ctr.value == "")
    ctr.value=temp;
}
function hiddentextReply(ctr)
{
    if(ctr.value==temp)
    ctr.value="";
}

function ClickHereReply()
{
    document.getElementById('tblMessageReply').style.display = "none";
    document.getElementById('tblPostReply').style.display = "";
    return false;
}var opened = false;
var EMOTICON = 
{
	
	show: function(ctrId)
	{
	    path='/Images/Emoticon/';
	    numberoficons= 52;
	    opened = false;
		var html = '', index = '';
		for(var i=0;i<numberoficons;i++)
		{
			index = (i<10) ? ('0' + i) : (i + '');
			html += '<div style="float:left; width:40px; height:40px; padding:10px; overflow:hidden;"><div align="center" style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+ path + index +'.gif\'); width:30px; height:30px; cursor:pointer" onclick="EMOTICON.insert(' + index + ', this, \'' + ctrId + '\');return false;"><a href="javascript:void(0);" title="' + index + '" ><img src="' + path + index + '.gif" style="filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0));" /></a></div></div>';
		}

showPopup('popupbox');
		document.getElementById('popupbox_content').innerHTML = html;
		window.setTimeout("GanLaiOpened()",500);
	},
	showAvatar: function(ctrId)
	{
	    path= '/Images/AvatarComment/';
	    numberoficons= 45;
	    opened = false;
		var html = '', index = '';
		for(var i=0;i<numberoficons;i++)
		{
			index = (i<10) ? ('0' + i) : (i + '');
			html += '<div style="float:left; width:55px; height:55px; overflow:hidden;padding:5px"><div align="center" style="width:55px; height:55px; cursor:pointer" ><a href="javascript:void(0);" title="' + index + '" ><img onclick="EMOTICON.insertAvatar(\'' + path + index + '.jpg\', this, \'' + ctrId + '\');return false;" src="' + path + index + '.jpg" style="width:55px; height:55px;" /></a></div></div>';
		}
		
		showPopup('popupbox');
		
		document.getElementById('popupbox_content').innerHTML = html;
		window.setTimeout("GanLaiOpened()",500);
	},
	hide: function()
	{
	    if(opened != false && document.getElementById('popupbox')!=null)
	    {
	        document.getElementById('popupbox').style.display="none";
	    }
	},
	insert: function(index, a, ctrId)
	{
		index = '<' + index + '>';
			try
    		{
				var ctr = document.getElementById(ctrId);	            
				if (ctr != null && ctr.createTextRange && ctr.caretPos) 
				{
					var caretPos = ctr.caretPos;
					caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? index + ' ' : index;	
				}
				else 
				{
					ctr.value += index;
				}
			}
			catch(e)
			{
        		alert(e.message);
			}
		
		EMOTICON.hide();
			
			
	},
	insertEmoticon:function doInsert(smilieface, ctrID)
    {
    	try
    	{
            var ctr = document.getElementById(ctrId)            
	        if (ctr != null && ctr.createTextRange && ctr.caretPos)
	        {
		        var caretPos = ctr.caretPos;
		        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? smilieface + ' ' : smilieface;	
	        }
	        else 
	        {
		        ctr.value += smilieface
	        }        
	        
        }
        catch(e)
        {
        	alert(e.message);
        }
        EMOTICONReply.hide();	
    },
	insertAvatar: function(index, a, ctrId)
	{
		try
    		{
				var ctr = document.getElementById(ctrId);	
				           
				var URLAvatar = document.getElementById("hidenURLAvatar");
			   
				if (ctr != null && URLAvatar !=null) 
				{
				   
					ctr.src = index;
					URLAvatar.value  = index;
					
				}
				
			}
			catch(e)
			{
        		alert(e.message);
			}
		
		EMOTICON.hide();
	}
}
function GanLaiOpened()
{
    opened = true;
}




// Show popup Emoticon và Avatar cho phần reply riêng comment
var openedNew = false;
var ctrCommentSend;
var EMOTICONReply = 
{
	
	show: function(ctrId)
	{
	    path='/Images/Emoticon/';
	    numberoficons= 52;
	    openedNew = false;
		var popup = document.getElementById('popupboxReply');
		popup.style.display="block";
		popup.style.zIndex="100";
		showPopup('popupboxReply');
		//document.getElementById('popupbox_contentReply').innerHTML = html;
		window.setTimeout("GanLaiOpenedNew()",500);		
		ctrCommentSend = ctrId;
	},
	showAvatar: function(ctrId)
	{
	    path= '/Images/AvatarComment/';
	    numberoficons= 45;
	    openedNew = false;
		var html = '', index = '';
		for(var i=0;i<numberoficons;i++)
		{
			index = (i<10) ? ('0' + i) : (i + '');
			html += '<div style="float:left; width:55px; height:55px; overflow:hidden;padding:5px"><div align="center" style=" width:55px; height:55px; cursor:pointer" ><a href="javascript:void(0);" title="' + index + '" ><img onclick="EMOTICONReply.insertAvatar(\'' + path + index + '.jpg\', this, \'' + ctrId + '\');return false;" src="' + path + index + '.jpg" style="width:55px; height:55px;" /></a></div></div>';
		}
			var popup = document.getElementById('popupboxReply');
		
		showPopup('popupboxReply');
		document.getElementById('popupbox_contentReply').innerHTML = html;
		window.setTimeout("GanLaiOpenedNew()",500);
	},
	hide: function()
	{
	    
	    if(openedNew != false && document.getElementById('popupboxReply')!=null)
	    {	        
	        document.getElementById('popupboxReply').style.display="none";
	    }
	 
	},
	insert: function(index, a, ctrId)
	{
		
			try
    		{
				var ctr = document.getElementById(ctrId);	            
				if (ctr != null && ctr.createTextRange && ctr.caretPos) 
				{
					var caretPos = ctr.caretPos;
					caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? index + ' ' : index;	
				}
				else 
				{
					ctr.value += index;
				}
			}
			catch(e)
			{
        		alert(e.message);
			}
		
		EMOTICONReply.hide();		
	},
	insertEmoticon:function doInsert(smilieface)
    {
    	try
    	{    	    
            var ctr = document.getElementById(ctrCommentSend)            
	        if (ctr != null && ctr.createTextRange && ctr.caretPos)
	        {
		        var caretPos = ctr.caretPos;
		        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? smilieface + ' ' : smilieface;	
	        }
	        else 
	        {
		        ctr.value += smilieface
	        }        
	        
        }
        catch(e)
        {
        	alert(e.message);
        }
        EMOTICONReply.hide();	
    },
	insertAvatar: function(index, a, ctrId)
	{
		try
    		{
				var ctr = document.getElementById(ctrId);	
				           
				var URLAvatar = document.getElementById("hidenURLAvatarReply");
			   
				if (ctr != null && URLAvatar !=null) 
				{
				   
					ctr.src = index;
					URLAvatar.value  = index;
					
				}
				
			}
			catch(e)
			{
        		alert(e.message);
			}
		
		EMOTICONReply.hide();
	}
}



function GanLaiOpenedNew()
{
    openedNew = true;
}

function showPopup(controlID)
{
var control = document.getElementById(controlID);
if (control)
{
control.style.display = 'block';
control.style.zIndex = '100';
var top = (window.screen.availHeight - control.offsetHeight)/2 - 100;
        var left = (document.documentElement.offsetWidth - control.offsetWidth)/2;
        left += (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
        top += (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;

control.style.left= left + 'px';
control.style.top=  top + 'px';

return true;
}
return false;
}