﻿//Cac function xu ly Main, MainFull
function Main_GhiChu_Click(XKH,CNDK){
	Main_AddVar("ActiveIBound:" + XKH + "|PageLevel:TrangCon|Activecontrol:" + CNDK); 
	Main_DelVar("ActiveBound");
	Main_Submit();
}
//Cac function xu ly IBound
function IB_Click(CNDK,TuKhoa,TuKhoa_Customize){
	Main_AddVar("ActiveIBound:" + TuKhoa + "|PageLevel:TrangCon|ActiveControl:" + CNDK);
	Main_DelVar("ActiveBound|ASPNAME|CustomizeMaCNDK|CustomizeKey|" + TuKhoa_Customize);
	Main_Submit();
}
function IB_FR_Click(ModuleId){
		args = "width=600px,height=300px,top=80px,left=80px,titlebar=1,menubar=1,toolbar=1,resizable=1,status=1,scrollbars=1";		
		url = "Common/ViewLink.aspx?ModuleId=" + ModuleId;
		window.open(url,"ViewLink",args);
		window.event.returnValue = false;
}
function IBEx_Click(strAddVar,strDelVar,CNDK,aspName){
	var strAddVarEx = "";
	var strDelVarEx = "";
	if(CNDK!= null&&aspName!= null&&CNDK!=""&&aspName!=""){
		strAddVarEx = "PageLevel:TrangCon|ActiveIBound:GROUPEX|ActiveControl:" + CNDK + "|ASPNAME:" + aspName;
		strDelVarEx = "ActiveBound|CustomizeMaCNDK|CustomizeKey";
		strAddVar = (strAddVar!= "")?(strAddVarEx + "|" + strAddVar):(strAddVarEx);
		strDelVar = (strDelVar!= "")?(strDelVarEx + "|" + strDelVar):(strDelVarEx);
	}	
	Main_AddVar(strAddVar);
	Main_DelVar(strDelVar);
	Main_Submit();
}
function SubMenu_Click(CNDK,TuKhoa,TuKhoa_Customize,strAddVar,strDelVar){
	Main_AddVar("ActiveIBound:" + TuKhoa + "|PageLevel:TrangCon|Activecontrol:" + CNDK + "|" + strAddVar);
	var strDelVarEx = "ActiveBound|ASPNAME|CustomizeMaCNDK|CustomizeKey|" + TuKhoa_Customize;
	if(strDelVar!= "") strDelVarEx += "|" + strDelVar;
	Main_DelVar(strDelVarEx);
	Main_Submit();
}
function IB_Over(src){
	src.className = "IB_Text_Hover";
	span = src.getElementsByTagName("span");
	if(span.length>0){
	 span[0].className = src.className;
	}
	//alert("");
}
function IB_Out(src){
	src.className = "IB_Text";
	span = src.getElementsByTagName("span");
	if(span.length>0){
	 span[0].className = src.className;
	}
}
function IBoundRight_Title_Over(src){
	src.className = "IB_Right_Text_Hover";
}
function IBoundRight_Title_Out(src){
	src.className = "IB_Right_Text";
}
function SubIB_Over(src){
	src.className = "SubIB_Text_Hover";
}
function SubIB_Out(src){
	src.className = "SubIB_Text";
}
//Cac function xu ly Bound
function Bound_Xuly(Index,OldVal,TuKhoa,KieuLoai){
	if(Index==1 && OldVal=="1") Index=2;
	if(Index==3 && OldVal=="3") Index=2;
	if (Index==5){
		Main_AddVar(TuKhoa + ":" + Index.toString() + "|CustomizeKey:" + TuKhoa);
		if (KieuLoai=="C"){
			Main_DelVar("ActiveControl|ActiveTab");
		}
	}else{
		Main_AddVar(TuKhoa + ":" + Index.toString());
	}
}
function Bound_Frame_Click(KieuLoai,DuongDan){
	//Bound một Frame//Frame có liên kết
	if (KieuLoai=="F"){
		sFeature="";
		window.open (DuongDan,"_blank", sFeature, true);
		return true;
	}
	return false;
}
function Bound_Click(CNDK,TuKhoa,KieuLoai,DuongDan){
	//Xử lý Frame_Title_Click nếu có
	if (Bound_Frame_Click(KieuLoai,DuongDan)){
		return;
	}
	Main_AddVar("PageLevel:TrangCon|ActiveBound:" + TuKhoa + "|ActiveControl:" + CNDK);
	Main_Submit();
}
function Bound_Over(src){
	src.className = "Caption_Text_Hover";
}
function Bound_Out(src){
	src.className = "Caption_Text"; 
}
function Bound_XuLyHelp(HeplFile,ModuleID){
	OpenWin("Help/Index.aspx?Help="+HeplFile+"&ID="+ModuleID);
}
//Các function phục vụ xử lý Status
function Status_Item_Over(src){
	if (src.id.toUpperCase()!=Status_SelectedID.toUpperCase()){
		src.className = "Status_Text_Hover";
	}
}
function Status_Item_Out(src){
	if (src.id.toUpperCase()!=Status_SelectedID.toUpperCase()){
		src.className = "Status_Text_Normal";
	}
}
//Các function phục vụ xử lý Footer
function Footer_Item_Over(src,_class){
	if (src.id.toUpperCase()!=Footer_SelectedID.toUpperCase()){
		src.className = _class;//"Footer_Text_Hover";
	}
}
function Footer_Item_Out(src,_class){
	if (src.id.toUpperCase()!=Footer_SelectedID.toUpperCase()){
		src.className = _class;//"Footer_Text_Normal";
	}
}
//Các function phục vụ xử lý Tab
function Tab_Item_Over(src){
	if (src.id.toUpperCase()!=SelectedTab_ID.toUpperCase()){
		src.className = "Tab_Text_Hover";
	}
}
function Tab_Item_Out(src){
	if (src.id.toUpperCase()!=SelectedTab_ID.toUpperCase()){
		src.className = "Tab_Text_Normal";
	}
}
//Liên kết nội dung
function Insert_Link(strAddVar,FunctionId){
	if(strAddVar!=""){
		var strVar = strAddVar.split("|");
		if(strVar[0]!="LKNDN"){
			Main_AddVar(strAddVar + "|PageLevel:TrangCon|ActiveIBound:LINK|ActiveControl:" + FunctionId);
			Main_DelVar("ASPNAME|CustomizeMaCNDK|CustomizeKey");
			Main_Submit();
		}else{
			Path = "Common/TextEditor/LKNDN.aspx?" + strVar[1];			
			Link_File(Path);
		}
	}
}
function Link_File(strPath){
	var w1 = 716, h1=480;
	var strTop = parseInt((screen.height - h1)/2)-20;
	var strLeft = parseInt((screen.width - w1)/2);
	args="width="+w1+"px,height="+h1+"px,top="+strTop+"px,left="+strLeft+"px,resizable=0,scrollbars=1,status=1";	
	window.open(strPath,"mainwindow",args);		
}
function Main_PageSize(VarPageSize){
	CancelBubble();
	Main_AddVar(VarPageSize);		
	Main_Submit();
} 
///////////////
function Main_AddVar(strValue){
	var oldVal = document.getElementById(Index_hidAddVVS_ClientID).value;
	if(oldVal!="") strValue = oldVal + "|" + strValue;
	document.getElementById(Index_hidAddVVS_ClientID).value = strValue;
	document.getElementById(Index_hidActived_ClientID).value = "TRUE";
}
function Main_DelVar(strValue){
	var oldVal = document.getElementById(Index_hidDelVVS_ClientID).value;
	if(oldVal!="") strValue = oldVal + "|" + strValue;
	document.getElementById(Index_hidDelVVS_ClientID).value = strValue;
	document.getElementById(Index_hidActived_ClientID).value = "TRUE";
}
function Main_Submit(){
	document.getElementById("frmIndex").submit();
}
function CancelBubble(){
	if(document.all) window.event.cancelBubble = true;
}
function EventElement(mEvent){
	var nav = navigator.userAgent.toLowerCase();	
	if (nav.indexOf('msie') > -1)	return window.event.srcElement; //IE
	else if (mEvent.target)			return mEvent.target;//Netscape and Firefox		
	return null;
}
function Event(mEvent){	
	var nav = navigator.userAgent.toLowerCase();	
	if (nav.indexOf('msie') > -1)	return window.event; //IE
	else if (mEvent.target)			return mEvent;//Netscape and Firefox		
	return null;
}
function CancelEvent(e){	
	var nav = navigator.userAgent.toLowerCase();	
	if (nav.indexOf('msie') > -1) window.event.returnValue = false; //IE
	else if (e.stopPropagation){//Netscape and Firefox 
		e.preventDefault();
		e.stopPropagation();
	}	
}
function OpenWin(Path) {
	var w1 = 778, h1=480;
	var strTop = parseInt((screen.height - h1)/2)-20;
	var strLeft = parseInt((screen.width - w1)/2);
	args="width="+w1+"px,height="+h1+"px,top="+strTop+"px,left="+strLeft+"px,resizable=0,scrollbars=1,status=1";	
	window.open(Path,"mainwindow",args);
	window.event.returnValue = false;
}
function Trim(str){
    var strT='';
    for (u=0;u<str.length;u++){
        if (str.charAt(u)!=' ')
        strT=strT + str.charAt(u);  
    }
    return strT;
}
//---------
function showDateVN(strDate){
	var dt = new Date(strDate);			
	var strarrDay = new Array("Chủ nhật", "Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy"); 
	var strarrMonth = new Array("01","02","03","04","05","06","07","08","09","10","11","12"); 
	var strThu = dt.getDay();
	strThu = strarrDay[strThu] + ", ";
	var strDay = dt.getDate();
	if (strDay<10) strDay="0" + strDay;
	var strMonth = dt.getMonth();
	strMonth= strarrMonth[strMonth];
	var strYears = dt.getYear();
	if (strYears<1900) strYears += 1900;
	
	var strdate = "&nbsp;" + strThu + " " + strDay + "/" + strMonth + "/" + strYears;
	document.getElementById("spnDate").innerHTML = strdate;
}
//--- Lời chào mừng của CTT
function LCM_CTTTTH(strAddVar,strDelVar,CNDK,aspName)
{
		var strAddVarEx = "";
	var strDelVarEx = "";
	if(CNDK!= null&&aspName!= null&&CNDK!=""&&aspName!=""){
		strAddVarEx = "PageLevel:TrangCon|ActiveIBound:GROUPEX|ActiveControl:" + CNDK + "|ASPNAME:" + aspName;
		strDelVarEx = "CustomizeMaCNDK|CustomizeKey";
		strAddVar = (strAddVar!= "")?(strAddVarEx + "|" + strAddVar):(strAddVarEx);
		strDelVar = (strDelVar!= "")?(strDelVarEx + "|" + strDelVar):(strDelVarEx);
	}	
	Main_AddVar(strAddVar);
	Main_DelVar(strDelVar);
	Main_Submit();

}
function LCM_Over(src,index){
	if (index==1) {//over		
		src.className = 'LCM_Text_Hover';
	}else{	
		src.className = 'LCM_Text';			
	}
}
function OpenURL(url){
	if (url!="")
		window.open(url,"_blank","resizable=1,scrollbars=1,status=1,menubar=1,toolbar=1");
}
function Index_Resize(e){
	try{
		var tdLBR = document.getElementById("tdLBR");
		var tblLBR = document.getElementById("tblMain");
		ClientHeight = (document.body.clientHeight);
		ClientTop = (document.getElementById("tdBody").clientHeight-tblLBR.clientHeight);		
		tdLBR.style.height = (ClientHeight-ClientTop);
		var tblMainTab = document.getElementById("tblMainTab");
		var tblContent = document.getElementById("tblContent");
		var tblContent_Sub = document.getElementById("tblContent_Sub");
		if(tblMainTab!=null){
			tblMainTab.style.height = (ClientHeight-ClientTop);
		}
		if(tblContent!=null){					
			tblContent.style.height = (ClientHeight-ClientTop);
		}				
		if(tblContent_Sub!=null){					
			tblContent_Sub.style.height = (ClientHeight-ClientTop);
		}				
	}
	catch(ex){}
	eType = (ie4)?(window.event.type):(e.type);
	if(eType=='load') setActiveTab();
}
function setActiveTab(){
	document.getElementById(Index_hidAddVVS_ClientID).value = Active_Tab;
}
//Xu ly TTSK
function TTSK_Item_Hover(arg1,arg2){
	window.onerror = null;
	browserName = navigator.appName;
	browserVer = parseInt(navigator.appVersion);
	if (browserVer >= 3) ver = "yes";
	else ver = "no";
	if (ver == "yes"){
		var e = document.getElementById("spn_TTSK_" + arg1);
		if (arg2=="TL1")
			e.className = 'TTSK_Type_Khac';
		else if (arg2=="TL2")
			e.className = 'TTSK_Type_Hover';
		else if (arg2=="TT1")
			e.className = 'TTSK_News_Khac';
		else
			e.className = 'TTSK_News_Hover';
	}
}
function TTSK_View(){
	Main_DelVar("TTSK_SPEC:1|TTSK_Command|TTSK_MaTTSKTL|TTSK_MaTTSK|TTSK_Ngay");
	Main_Submit();
}
function TTSK_View_Type(MaTLT){
	Main_AddVar("TTSK_SPEC:1|TTSK_Command:TINTUCTYPE|TTSK_Ngay|TTSK_MaTTSKTL:" + MaTLT);
	Main_Submit();
}
function TTSK_View_News(MaTLT,MaTT){
	Main_AddVar("TTSK_SPEC:1|TTSK_Command:TINTUCDETAIL|TTSK_Ngay|TTSK_MaTTSKTL:" + MaTLT + "|TTSK_MaTTSK:" + MaTT);
	Main_Submit();
}

function ShowImage(Path,wimg,himg){
	var w1 = 750, h1 = 480;
	w = parseInt(wimg);
	h = parseInt(himg);
	if (w <= 750){
		w1 = w;
	}
	if (h <= 480){
		h1 = h;
	}
	w1 += 58;
	h1 += 48;
	var strTop = parseInt((screen.height - h1)/2)-20;
	var strLeft = parseInt((screen.width - w1)/2);
	args = "width=" + w1 + "px,height=" + h1 + "px,top=" + strTop + "px,left=" + strLeft + "px,resizable=0,status=0,scrollbars=";
	if ((wimg>=750)||(himg>=480)){
		args += "1";
	}else{
		args += "0";
	}
	url = "Common/ViewImg.aspx?Path=" + Path + "&Height=" + himg + "&Width=" +wimg;
	window.open(url,"ViewImages",args);
	window.event.returnValue = false;
}
function Change_ImgSrc(){
	return false;
	/*
	var ImgSet = document.getElementsByTagName("img");
	for(i=0;i<ImgSet.length;i++){
		if(ImgSet[i].src.indexOf("Module_Left.gif")>0||ImgSet[i].src.indexOf("Module_Right.gif")>0){
			td = ImgSet[i].parentNode;			
			tr = td.parentNode;			
			//if((td.clientHeight>22) && (td.clientHeight <= 28)) // 2 line (28px)
			if(td.clientHeight>22) // 2 line (28px)
			{				
				tr.className = "ModuleCaption_Text2";
				ImgSet[i].src=ImgSet[i].src.replace(".gif","2.gif");
			}
			/*
			if((td.clientHeight > 30) && (td.clientHeight <= 36)) // 3 line (36px)
			{				
				tr.className = "ModuleCaption_Text3";
				ImgSet[i].src=ImgSet[i].src.replace(".gif","3.gif");
			}
			if(td.clientHeight > 38)// 4 lines (48px)
			{				
				tr.className = "ModuleCaption_Text4";
				ImgSet[i].src=ImgSet[i].src.replace(".gif","4.gif");
			}
			//
		}
	}
	*/
}

var prevID = '';
function IBSubEx_Click(name, id, div, span){
	// xu ly cho cac doi tuong da chon lan truoc
	if (prevID != id){
		if(prevID!=''){
			var divMenu1 = document.getElementById('div'+ name + '_' + prevID);
			var spanMenu1 = document.getElementById('span' + name + '_'+prevID);	
			divMenu1.style.display = 'none';
			spanMenu1.style.fontWeight="normal";
		}
		prevID = id	
	}	
	var divMenu = document.getElementById(div);
	var spanMenu = document.getElementById(span);
	if (divMenu.style.display==''){
		divMenu.style.display = 'none';
		spanMenu.style.fontWeight="normal";
		
	}else{
		divMenu.style.display = '';
		spanMenu.style.fontWeight="bold";
	}	
}
/*----------------------------------------------------------------*/
function getTextFCK(FCKname) {
	var oEditor = FCKeditorAPI.GetInstance(FCKname);
	return oEditor.GetXHTML(true);
}
//--End code
/*----------------------------------------------------------------*/
