﻿// JScript File
var highlightbehavior="TR"

var ns6=document.getElementById&&!document.all
var ie=document.all
var pop;
function changeto(e,highlightcolor)
{
	source=ie? event.srcElement : e.target
	if (source.tagName=="TABLE")
	return
	while(source.tagName!=highlightbehavior && source.tagName!="HTML")
	source=ns6? source.parentNode : source.parentElement
		
	if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore"){
		source.style.backgroundColor=highlightcolor;
	}
}
//===============================================
function changeback(e,originalcolor){
	if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
	return
	else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
	return
	if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
	source.style.backgroundColor=originalcolor;
}
function openwindow1(url,width,height)
{
	var top=(screen.height - height)/2;
	var left=(screen.width - width)/2;
	
	window.open(url,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no,left=" + left + ", top=" + top + ", width=" + width + ", height=" + height)
}
/*Chon ngon ngu cho danh muc tin tuc*/
function changeLanguage(Language_ID,Cat_ID){	
	
	var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	var szURL = "EDITOR_XML_Cat_List.aspx";
	var szHttpMethod = "POST";	
	var szRequest = Language_ID + "," + Cat_ID;
	objHTTP.Open(szHttpMethod, szURL, false);
	objHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	objHTTP.Send(szRequest);
	var szReply = objHTTP.ResponseText;	
	if (szReply!=''){
	    var obj = document.getElementById('pEditorCats');
	    obj.innerHTML = szReply;
	}	
	objHTTP = null;
	szRequest = null;
	szReply	= null;
	return true;
}
/*Hien thi danh muc tin de chon tin lien quan*/
function changeEditorCatNews(EditorCat_ID){	
	var obj = document.getElementById("pEditorCatToRelate");
	var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	var szURL = "EDITOR_XML_Relate_News.aspx";
	var szHttpMethod = "POST";
	var szRequest = EditorCat_ID;
	objHTTP.Open(szHttpMethod, szURL, false);
	objHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	objHTTP.Send(szRequest);
	var szReply = objHTTP.ResponseText;
	if (szReply!=''){
		obj.innerHTML = szReply;
	}
	objHTTP = null;
	szRequest = null;
	szReply	= null;
	return true;
}
/*Them moi tin lien quan*/
function AddNews(){
	var obj = document.getElementById("SRelateNewsSource");
	var obj1 = document.getElementById("SRelateNews");
	var optionCounter;
	var strText = "";
	var intID = "";
	var blAdd = true;
		
	if(obj!=null){
		for (optionCounter = 0; optionCounter < obj.length; optionCounter++){
			if(obj.options[optionCounter].value == obj.value){
				strText = obj.options[optionCounter].text;
				intID = obj.options[optionCounter].value;
			}
		}
		if(strText!="" && !isNaN(intID)){
			if(obj1!=null){
				for (optionCounter = 0; optionCounter < obj1.length; optionCounter++){
					if(obj1.options[optionCounter].value == intID){
						blAdd = false;
					}
				}
				if(blAdd){
					var myNewOption = new Option(strText,intID);
					obj1.options[obj1.length] = myNewOption;
				}
				else{
					alert("Bạn đã thêm tin này rồi.");
				}
			}
		}
	}
}
/*Xoa bo tin lien quan*/
function RemoveNews(){
	var obj = document.getElementById("SRelateNews");
	var blRemove = true;
		
	if(obj!=null){
		if(!isNaN(obj.value) && obj.value!=""){
			for (optionCounter = 0; optionCounter < obj.length; optionCounter++){
				if(obj.options[optionCounter].value == obj.value){
					obj.options[optionCounter] = null;
				}
			}
			
		}
	}
}
function checkSubmitToSearch(aspnetForm){
    //Từ cần tìm
    if (aspnetForm.ctl00$ContentPlaceHolder1$txtSearch.value=='')
    {
        alert('Nhập từ khóa cần tìm kiếm');
        aspnetForm.ctl00$ContentPlaceHolder1$txtSearch.focus();
        return false;
    }
    if (aspnetForm.ctl00$ContentPlaceHolder1$DDLanguage.value=='0')
    {
        alert('Bạn phải chọn ngôn ngữ hiển thị');
        aspnetForm.ctl00$ContentPlaceHolder1$DDLanguage.focus();
        return false;
    }
    if (aspnetForm.ctl00$ContentPlaceHolder1$DDLCategoryNews.value=='0')
    {
        alert('Bạn phải chọn danh mục tin tức');
        aspnetForm.ctl00$ContentPlaceHolder1$DDLCategoryNews.focus();
        return false;
    }
	return true;
}

//DatDN
function ClickFormSearch(){
    var idThis = document.getElementById('idList');
    if(idThis.style.display = 'none'){            
        idThis.style.display = 'block';
    }
    else
    {
        idThis.style.display = 'none';        
    }
}
//===============================================
function gen_Image(w,Thumb_W,Photo){
var szHTML, tf, it;
	it = '<img src="'+ Photo + '_T.jpg' +'" border="0">';
	szHTML='';
	szHTML+='<table cellSpacing=0 cellPadding=3 width=1 border=0>';
	szHTML+='<tr><td>';
	szHTML+= it;
	szHTML+='</td></tr>';
	szHTML+='</table>';
	
	return szHTML;
}
//===============================================
function removeLeadImage(){
		divImg.innerHTML = '';		
		document.aspnetForm.LeadImage.value = '';
		spanDeleteIcon.innerHTML = '';
}
//===============================================
function do_InsertImgEditor(w,Thumb_W,Photo, imageID)
{
	divImg.innerHTML = gen_Image(w,Thumb_W,Photo);
	document.aspnetForm.LeadImage.value = imageID;
	spanDeleteIcon.innerHTML = '<img style="cursor:hand" onclick=\"JavaScript:removeLeadImage()\" src=\"/Images/Admin/delete.gif\" border=\"0\" alt="Xóa ảnh">';
}	//===============================================
function removeLeadImageColor(){
		divImgColor.innerHTML = '';		
		document.aspnetForm.LeadImageColor.value = '';
		spanDeleteIconColor.innerHTML = '';
}
//===============================================
function do_InsertImgEditorColor(w,Thumb_W,Photo, imageID)
{
	divImgColor.innerHTML = gen_Image(w,Thumb_W,Photo);
	document.aspnetForm.LeadImageColor.value = imageID;
	spanDeleteIconColor.innerHTML = '<img style="cursor:hand" onclick=\"JavaScript:removeLeadImageColor()\" src=\"/Images/Admin/delete.gif\" border=\"0\" alt="Xóa ảnh">';
}	
//Lampn Add Vote Question
function Add_New_Answer(element){
	document.aspnetForm.hiddenNo.value = parseInt(document.aspnetForm.hiddenNo.value) + 1;
	var Editor_Num = document.aspnetForm.hiddenNo.value
	var obj = document.getElementById(element);
	var objHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	var szURL = "Add_Question_XML.aspx";
	var szHttpMethod = "POST";
	var szRequest = Editor_Num;
	objHTTP.Open(szHttpMethod, szURL, false);
	objHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	objHTTP.Send(szRequest);
	var szReply = objHTTP.ResponseText;
	//alert(szReply);
	//alert(obj);
	if (szReply!=''){
		obj.innerHTML = obj.innerHTML + szReply;
	}
	objHTTP = null;
	szRequest = null;
	szReply	= null;
	return true;
}
function Delete_answer_New(sub_Answer){
	var obj = document.getElementById(sub_Answer);
	alert(obj);
	obj.innerHTML='';
	obj.outnerHTML='';
	return true;
}
function OpenQuestiontbl()
{
    if(document.all.tblquestionFaqs.style.display == "none")
    {
		document.all.tblquestionFaqs.style.display = "block";
    }
    else
    {        
        document.getElementById('tblquestionFaqs').style.display = "none";
	}
}
function Playfile(sfile) {	
	document.getElementById('mediaplayer').src.value=sfile;
}
function MChange(Url){
	document.getElementById('MPlayer').innerHTML= '<embed width="352px" hspace="0" height="355px" align="middle" showdisplay="0" showstatusbar="1" showcontrols="1" autostart="-1" autohref="true" correction="full" wmode="transparent" type="application/x-mplayer2" src="'+ Url +'"/>';
}
function checkRegMail()
{
    if (aspnetForm.ctl00$Left$txtNewsletter.value=='')
    {
        alert('Nhập địa chỉ Email của bạn');
        aspnetForm.ctl00$Left$txtNewsletter.focus();
        return false;
    }
    return true;
}
/*=======================================================*/
function PopImage(id, cid, proid){
	window.open("Product_Popup.aspx?proid=" + proid + "&id=" + id +"&cid=" + cid,"image","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=1,height=1,left = 0,top = 0");
}
/*=======================================================*/
function PopImage_1(id, cid, proid){
	window.open("eProduct_Popup.aspx?proid=" + proid + "&id=" + id +"&cid=" + cid,"image","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=1,height=1,left = 0,top = 0");
}
/*=======================================================*/
function displayStatus(strStatus){
	window.status = strStatus;
}
/*=======================================================*/
function BlockLeftMenu(tbName,session_com)
{   
    document.getElementById("tbAbout").style.display="none";
    document.getElementById("tbCIntroduce").style.display="none";
    document.getElementById("tbNews").style.display="none";    
    //if(session_com != 3 && session_com != 5 && session_com != 2)
    if(session_com != 3)
    {
       document.getElementById("tbProduct").style.display="none"; 
    }else if(session_com == 3)
    {
        document.getElementById("tbPhonoi").style.display="none";
    }
    document.getElementById(tbName).style.display="block";
}
function BlockAllLeftMenu(session_com)
{
    document.getElementById("tbAbout").style.display="none";
    document.getElementById("tbCIntroduce").style.display="none";
    document.getElementById("tbNews").style.display="none";    
    //if(session_com != 3 && session_com != 5 && session_com != 2)
    if(session_com != 3)
    {
       document.getElementById("tbProduct").style.display="none"; 
    }else if(session_com == 3)
    {
        document.getElementById("tbPhonoi").style.display="none";        
    }        
}
/*============================EN===========================*/
function eBlockLeftMenu(tbName,session_com)
{   
    document.getElementById("etbAbout").style.display="none";
    document.getElementById("etbCIntroduce").style.display="none";
    document.getElementById("etbNews").style.display="none";    
    //if(session_com != 3 && session_com != 5 && session_com != 2)
    if(session_com != 15)
    {
       document.getElementById("etbProduct").style.display="none"; 
    }else if(session_com == 15)
    {
        document.getElementById("etbPhonoi").style.display="none";
    }
    document.getElementById(tbName).style.display="block";
}
function eBlockAllLeftMenu(session_com)
{
    document.getElementById("etbAbout").style.display="none";
    document.getElementById("etbCIntroduce").style.display="none";
    document.getElementById("etbNews").style.display="none";    
    //if(session_com != 3 && session_com != 5 && session_com != 2)
    if(session_com != 15)
    {
       document.getElementById("etbProduct").style.display="none"; 
    }else if(session_com == 15)
    {
        document.getElementById("etbPhonoi").style.display="none";        
    }        
}
/*============================EN===========================*/

function PopupVote(strOpen)
    {
        window.open(strOpen, "Info", "status=1, width=500,height=250,toolbar=no,menubar=no,location=no");
    }
function EmailToFriend(strOpen)
    {
        window.open(strOpen, "Info", "status=1, width=660,height=550,toolbar=no,menubar=no,location=no");
    }
function OpenPopubPro(strOpen)
    {
        window.open(strOpen, "Info", "status=1, width=800,height=450,toolbar=no,menubar=no,location=yes");
    }   
/*=====================Menu========================*/
function swap(td_name,image)
{
	document.getElementById(td_name).style.background=image;
}

function bgoff(td_name,image)
{
	document.getElementById(td_name).style.background=image;
}
/*=================================================*/    