﻿function button_over(eButton)	{
	eButton.style.backgroundColor = "#B5BDD6";
	eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
	eButton.style.borderWidth = '1px';
	eButton.style.borderStyle = 'solid'; 
}

function button_out(eButton) {
	eButton.style.backgroundColor = "#efedde";
	eButton.style.borderColor = "#efedde";
}

function button_down(eButton) {
	eButton.style.backgroundColor = "#8494B5";
	eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
}

function button_up(eButton) {
	eButton.style.backgroundColor = "#B5BDD6";
	eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
	eButton = null; 
}
function search(){
    var newwindow;
	window.returnValue=1;
    newwindow=window.open('admin/editor/colorselect.htm');window.close();
}
/*
 
 Cac ham dung cho duyet phan thong tin kem them

*/
function link_over(elink)	{
	elink.style.backgroundColor = "#336699";
	elink.style.borderColor = "#000000";
	elink.style.borderWidth = '1px';
	elink.style.borderStyle = 'inset'; 
  }

function link_out(elink) {
	elink.style.backgroundColor = "#003366";
	elink.style.borderColor = "#808080";
}

function link_down(elink) {
	elink.style.backgroundColor = "#003366";
	elink.style.borderColor = "#808080";
}

function link_up(elink) {
	elink.style.backgroundColor = "#336699";
	elink.style.borderColor = "#808080";
	elink = null; 
}
/*
 
 Cac ham dung cho duyet phan thong tin kem them

*/
function link_over2(elink)	{
	elink.className='clsComTDOver';
}

function link_out2(elink) {
	elink.className='clsComTD';
}

function link_down2(elink) {
	elink.className='clsComTD';
}

function link_up2(elink) {
	elink.className='clsComTDOver';
}
/*
 
 Cac ham dung cho phan hien thi thong tin

*/
function ShowDetailNewslink_over(elink)	{
	elink.style.backgroundColor = "#6699cc";
  }

function ShowDetailNewslink_out(elink) {
	elink.style.backgroundColor = "#FFFFFF";
}

function ShowDetailNewslink_down(elink) {
	elink.style.backgroundColor = "#FFFFFF";
}

function ShowDetailNewslink_up(elink) {
	elink.style.backgroundColor = "#6699cc";
	elink = null; 
}
/*
 
 Cac ham dung cho duyet phan thong tin kem them cua trang newsLists

*/
function NewsListsOver(elink)	{
	elink.style.backgroundColor = "#336699";
}
function NewsListsDown(elink) {
	elink.style.backgroundColor = "#003366";
}
function NewsListsOut(elink) {
	elink.style.backgroundColor = "#003366";
}

function NewsListsUp(elink) {
	elink.style.backgroundColor = "#336699";
	elink = null; 
}
/*
 
 Cac ham dung cho phan website

*/
function ShowWebSite_over(elink)	{
	elink.style.backgroundColor = "#336699";
	elink.style.borderColor = "#336699";
	elink.style.borderWidth = '1px';
	elink.style.borderStyle = 'solid'; 
  }

function ShowWebSite_out(elink) {
	elink.style.backgroundColor = "#F0FFF4";
	elink.style.borderTopColor = "#F0FFF4";
	elink.style.borderLeftColor = "#F0FFF4";
	elink.style.borderRightColor = "#F0FFF4";
	elink.style.borderBottomColor = "#336699";
	elink.style.backgroundColor = "#F0FFF4";
	elink.style.borderTopColor = "#F0FFF4";
	elink.style.borderLeftColor = "#F0FFF4";
	elink.style.borderRightColor = "#F0FFF4";
	elink.style.borderWidth = '1px';
    elink.style.borderWidth = 'solid';
}

function ShowWebSite_down(elink) {
    elink.style.backgroundColor = "#F0FFF4";
	elink.style.borderTopColor = "#F0FFF4";
	elink.style.borderLeftColor = "#F0FFF4";
	elink.style.borderRightColor = "#F0FFF4";
	elink.style.borderBottomColor = "#336699";
	elink.style.backgroundColor = "#F0FFF4";
	elink.style.borderTopColor = "#F0FFF4";
	elink.style.borderLeftColor = "#F0FFF4";
	elink.style.borderRightColor = "#F0FFF4";
	elink.style.borderWidth = '1px';
    elink.style.borderWidth = 'solid';
}

function ShowWebSite_up(elink) {
	elink.style.backgroundColor = "#336699";
	elink.style.borderColor = "#336699";
	elink.style.borderWidth = '1px';
    elink.style.borderStyle = 'solid';
	elink = null; 
}
/*

Ham collapse and expand

*/
function ShowHide_Element(element) {
    var  IdIndex =element.sourceIndex;
	var object = document.all[IdIndex+3]
    if (object.style.display=="none") 
       object.style.display="inline"; 
	else
		object.style.display="none"; 
}
/*

Ham hien thi min cua bang

*/
function FuncShowTableMinMax(element) {
   var  IdIndex =element.sourceIndex;
	var object = document.all[IdIndex+3]
    if (object.style.display=="none"){
	  object.style.display="inline"; 	
	}  
	else{
		object.style.display="none"; 	
	}
}
/*



*/
function FuncInforLink_Over(button) {
  button.style.backgroundColor = "#c6c6c6";
}
function FuncInforLink_Up(button) {
  button.style.backgroundColor = "#c6c6c6";
  button=null;
}
function FuncInforLink_Out(button) {
  button.style.backgroundColor = "#F5F5F5";
}
function FuncInforLink_Down(button) {
  button.style.backgroundColor = "#F5F5F5";
}
/*



*/
function InforLinkVNNEG_over(elink)	{
	elink.style.backgroundColor = "#c6c6c6";
}

function InforLinkVNNEG_out(elink) {
	elink.style.backgroundColor = "#f5f5f5";
}
function InforLinkVNNEG_down(elink) {
	elink.style.backgroundColor = "#f5f5f5";
}
function InforLinkVNNEG_up(elink) {
	elink.style.backgroundColor = "#c6c6c6";
	elink = null; 
}
/*
 
 Cac ham dung cho duyet phan thong tin kem them cua trang newsLists

*/
function ForumVNNVNOver(elink)	{
	elink.className='clsComTDOver';
}

function ForumVNNVNDown(elink) {
	elink.className='clsComTD';
}
function ForumVNNVNOut(elink) {
	elink.className='clsComTD';
}

function ForumVNNVNUp(elink) {
	elink.className='clsComTDOver';
}
/*
 
 Cac ham dung cho duyet phan thong tin kem them cua trang newsLists

*/
function ShowNewsListsOver(elink)	{
	elink.style.backgroundColor = "#003366";
}
function ShowNewsListsDown(elink) {
	elink.style.backgroundColor = "#336699";
}
function ShowNewsListsOut(elink) {
	elink.style.backgroundColor = "#336699";
}

function ShowNewsListsUp(elink) {
	elink.style.backgroundColor = "#003366";
	elink = null; 
}
/*


*/
function NewsCateListsOver(elink)	{
	elink.style.backgroundColor = "#E8E8E8";
}
function NewsCateListsDown(elink) {
	elink.style.backgroundColor = "#fcfcfc";
}
function NewsCateListsOut(elink) {
	elink.style.backgroundColor = "#fcfcfc";
}

function NewsCateListsUp(elink) {
	elink.style.backgroundColor = "#E8E8E8";
	elink = null; 
}
/*

Phan danh cho trang newsimg1

*/
function ShowTDImg1_over(elink)	{
	elink.style.backgroundColor = "#f5f5f5";
  }
function ShowTDImg1_out(elink) {
	elink.style.backgroundColor = "#FFFFFF";
}

function ShowTDImg1_down(elink) {
	elink.style.backgroundColor = "#FFFFFF";
}

function ShowTDImg1_up(elink) {
	elink.style.backgroundColor = "#f5f5f5";
	elink = null; 
}
/*

Phan danh cho menu

*/
function FShowNodeOver(node) {
  node.className='clssubmenu';
}
function FShowNodeOut(node) {
  node.className='clssubmenu';
}
function FShowNodeUp(node) {
  node.className='clssubmenu';
}
function FShowNodeDown(node) {
 node.className='clssubmenu'; 
}
function FShowSubNodeOver(node) {
 node.className='clssubmenu';
}
function FShowSubNodeOut(node) {
 node.className='clsSubNode';
}
function FShowSubNodeUp(node) {
 node.className='clsSubNodeOver';
}
function FShowSubNodeDown(node) {
 node.className='clssubmenu';
}
//

//
function FShowMenuNodeOver(clsName,node) {
 node.className=clsName+'Over';
}
function FShowMenuNodeOut(clsName,node) {
 node.className=clsName;
}
function FShowMenuNodeUp(clsName,node) {
 node.className=clsName+'Over';
}
function FShowMenuNodeDown(clsName,node) {
 node.className=clsName;
}

/*

Fix anh

*/
function FixSizeImg(sImg,vwidth,vheight)
 {
   var vHeight,vLength;
   //var sImg=document.getElementById("fixsizeimg")
   var i
   vHeight=sImg.height;
   vLength=sImg.width;
   //alert(vLength);
   if (vLength>vwidth) {
     sImg.width=vwidth;
     sImg.height=vwidth;
   }
   
}
function FVoteAction(vPath) {
  var vWindow;
  alert(vPath);
  showModalDialog(vPath+"common/polls/defaultUBND.asp","","font-family:Verdana; font-size:12; dialogWidth:45em; dialogHeight:35em;Center:Yes;Help:No;Resizable:No;Status:No;" );
  window.frmVote.submit();
}
function ReverseFolderByDate(vCateId)
{
	var vCurrentPage=document.location.href;
	//vCurrentPage=vCurrentPage.concat('?nCateId=').concat(vCateId)
	Ryear = document.frmExchangeDate.slcnamyear.options[document.frmExchangeDate.slcnamyear.selectedIndex].value;
	Rmonth = document.frmExchangeDate.slcthangmonth.options[document.frmExchangeDate.slcthangmonth.selectedIndex].value;
	Rday = document.frmExchangeDate.slcngaydate.options[document.frmExchangeDate.slcngaydate.selectedIndex].value;
    
	for (; Rday > 0; Rday--)
	{
		Rdate = new Date(Ryear, Rmonth - 1, Rday);
		if (Rdate.getDate() == Rday)
		{
			break;
		}
	}
    //.concat(' 23:59:59')
	LastDate = Rmonth.concat('/').concat(Rday).concat('/').concat(Ryear);
	//alert(vCurrentPage.concat('&d=').concat(escape(LastDate)));
	location.replace(vCurrentPage.concat('&d=').concat(escape(LastDate)));
}
/*

Phan danh cho xu ly ngay thang

*/
function FuncSubmitExchangeDate() 
{
	var vPageCurrent = document.location.href;
	var PosId;
	Ryear = document.frmExchangeDate.slcYear.options[document.frmExchangeDate.slcYear.selectedIndex].value;
	Rmonth = document.frmExchangeDate.slcMonth.options[document.frmExchangeDate.slcMonth.selectedIndex].value;
	Rday = document.frmExchangeDate.slcDay.options[document.frmExchangeDate.slcDay.selectedIndex].value;
    PosId = vPageCurrent.indexOf("/?d");
    if (PosId!=-1)
    {
      vPageCurrent = vPageCurrent.substring(0,PosId + 1);
    }
	alert(vPageCurrent)
	for (; Rday > 0; Rday--)
	{
		Rdate = new Date(Ryear, Rmonth - 1, Rday);
		if (Rdate.getDate() == Rday)
		{
			break;
		}
	}
    LastDate = Rday.concat('|').concat(Rmonth).concat('|').concat(Ryear);
	location.replace(vPageCurrent.concat('?d=').concat(escape(LastDate)));
}
function PopUpExLangNews(sPath)
{
    var vPath=sPath.value;
    //alert(vPath)
    window.open(vPath,"_blank","menubar = no,titlebar = no,toolbar = no,status = no,fullscreen = no,resizable = yes,height=400,width=600");
    //alert(vPath);.concat('?pop=1')
}
function PopUpExLangNewsDiv(sPath)
{
    var vPath=sPath;
    //alert(vPath)
    window.open(vPath,"_blank","menubar = no,titlebar = no,toolbar = no,status = no,fullscreen = no,resizable = yes,height=400,width=600");
    //alert(vPath);.concat('?pop=1')
}
function PopUpPrintNews(sPath,nNewsId)
{
   var vPath=sPath.concat('?print=1');
   window.open(vPath,"window","scrollbars = yes,menubar = no,titlebar = yes,toolbar = yes,status = no,fullscreen = no,resizable = yes,height=400,width=600");
   //alert(vPath);
}
function PopUpExLangCate(sPath)
{
    var vPath=sPath.value;
    location.href=vPath;
    //alert(vPath);.concat('?pop=1')
}
function ReplaceChar(iStr)
{
	var	r1=/&/g;
	var	r2=/ /g;
	var	r3=/"/g;

	iStr	=iStr.replace(r1, '%26');
	iStr	=iStr.replace(r2, '%20');
	iStr	=iStr.replace(r3, '%22');

	return iStr;
}

function CharReplace(iStr)
{
	var	r1=/%26/g;
	var	r2=/%20/g;
	var	r3=/%22/g;

	iStr	=iStr.replace(r1, '&');
	iStr	=iStr.replace(r2, ' ');
	iStr	=iStr.replace(r3, '"');

	return iStr;
}
function FuncProcessVote(vPollId,sAction) 
{
       width=540; height=390;
       LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
       TopPosition = (screen.height) ? (screen.height-height)/2 : 0;				
       var  sWindowFeatures='top='+TopPosition+',left='+LeftPosition+',height='+height+',width='+width+',status=no,toolbar=no,menubar=no,location=no,scrollbars=1,edge: Raised,center: Yes';	
       var vRadio=document.frmVote.rdVoteId;
       var vLenRD=vRadio.length;
       var i=0
	while ((i<vLenRD)&&(!vRadio[i].checked))
	{
       i++;
	}
	if (i<vLenRD)
	{
		if (vRadio[i].checked)
		{
          vVoteId = vRadio[i].value;
		}
		else {vVoteId='undefine';}

	}
	else {vVoteId='undefine';}
	//var vVoteId = document.frmVote.rdVoteId.value;
	var vPathVote = '/Libaries/common/polls/defaultUBND.asp';//vPath+
	var vAction = '&action='+sAction;
        var vStrVote = '&vid='+vPollId;
    //LastDate = Rmonth.concat('/').concat(Rday).concat('/').concat(Ryear);
	window.open(vPathVote.concat('?id=').concat(vVoteId).concat(vAction).concat(vStrVote),"window",sWindowFeatures);
}
/*

Xu ly search

*/
function FuncProcessSearch(vPath,intRoot,sCountry) 
{
	var vRadio=document.frmSearch.rdsearch;
	var vSearch=document.frmSearch.txtsearch.value;
	var sPath=vPath.split("/");
	var vLength=sPath.length;
	var vCount=0;
	var vSysPath='';
	for(vCount=0;vCount<vLength-2;vCount++)
	 {vSysPath=vSysPath+sPath[vCount]+'/';}
	var i=0;
    vCateId =intRoot;
	var s=vSearch;
	while (s.length > 0 && s.charAt(0) <= ' ')
	{s = s.substr(1);}
	while ((i=s.length) > 0 && s.charAt(i - 1) <= ' ')
	{s = s.substr(0, i - 1);}
	if (s=='')
	{	document.frmSearch.txtsearch.value = s;
		alert("B?n hãy nh?p d? ki?n");
		return false;
	}
	var vPathSearch = '/Libaries/search/default'+sCountry+'.asp';//vSysPath+
	var vAction = '&s='+s;
	var r=vPathSearch.concat('?c=').concat(vCateId ).concat(vAction)
    if (document.location.pathname.toLowerCase()=='/search/')
	{document.location.replace(r);}
	else{document.location.href=r;}
	return false;
}
/*

Ham xu ly tim kiem WebSite

*/
function FuncProcessSearchWebSite(vPath,intRoot) 
{
	var vRadio=document.frmSearchWebSite.rdsearch;
	var vSearch=document.frmSearchWebSite.txtsearch.value;
	var vLenRD=vRadio.length;
	var i=0
    while ((i<vLenRD)&&(!vRadio[i].checked))
	{
       i++;
	}
	if (i<vLenRD)
	{
		if (vRadio[i].checked)
		{
          vCateId = vRadio[i].value;
		}
		else {vCateId =intRoot;}

	}
	else {vCateId =intRoot;}
	//----------------------------------------
	// Xu ly chuoi tim kiem
	var s=vSearch;
	while (s.length > 0 && s.charAt(0) <= ' ')
	{
		s = s.substr(1);
	}

	while ((i=s.length) > 0 && s.charAt(i - 1) <= ' ')
	{
		s = s.substr(0, i - 1);
	}

	if (s=='')
	{
		document.frmSearch.txtsearch.value = s;
		alert("B?n hãy nh?p d? ki?n");
		return false;
	}
	s = escape(UnicodeSet(s));

	//-----------------------------------------
	var vPathSearch = vPath+'common/sitevietnam/';
	var vAction = '&s='+s;
	var r=vPathSearch.concat('?k=').concat(vCateId ).concat(vAction)
    if (location.pathname.toLowerCase()=='/common/sitevietnam/')
	{
	   location.replace(r);
	}
	else
	{
	  location.href=r;
	}
	return false;
}

/*
Cac ham xu ly unicode
*/
function UnicodeSet(iStr)
{
	for (i=0, oStr=''; i < iStr.length; i++)
	{
		switch ((j=iStr.charCodeAt(i)))
		{
		case 34:
			oStr=oStr.concat('&quot;');
			break;
		case 38:
			oStr=oStr.concat('&amp;');
			break;
		case 39:
			oStr = oStr.concat('&#39;');
			break;
		case 60:
			oStr = oStr.concat('&lt;');
			break;
		case 62:
			oStr = oStr.concat('&gt;');
			break;
		default:
			if (j < 32 || j > 127 || j==34 || j==39)
			{
				oStr=oStr.concat('&#').concat(j).concat(';');
			}
			else
			{
				oStr=oStr.concat(iStr.charAt(i)); 
			}
			break;
		}
	}
	
	return oStr;
}

function UnicodeGet(iStr)
{
	for (i=0, oStr=''; i < iStr.length; )
	{
		if (iStr.charCodeAt(i)==38)
		{
			if (iStr.charCodeAt(i + 1)==35)
			{
				p=iStr.indexOf(';', i  + 2);
				if (p!=-1)
				{
					if (p - i <= 7)
					{
						if (isFinite(iStr.substr(i + 2, p - i - 2)))
						{
							oStr = oStr.concat(String.fromCharCode(iStr.substr(i + 2, p - i - 2)));
							i = p + 1;
							continue;
						}
					}
				}
			}
			else
			{
				p=iStr.indexOf(';', i  + 1);
				if (p!=-1)
				{
					switch (iStr.substr(i + 1, p - i - 1))
					{
					case 'amp':
						oStr = oStr.concat('&');
						i = p + 1;
						break;
					case 'quot':
						oStr = oStr.concat('"');
						i = p + 1;
						break;
					case 'lt':
						oStr = oStr.concat('<');
						i = p + 1;
						break;
					case 'gt':
						oStr = oStr.concat('>');
						i = p + 1;
						break;
					}
				}
			}
		}
	
	
		oStr=oStr.concat(iStr.charAt(i));
		i++;
	}
	
	return oStr;
}
function SearchOnFocus(field)
{
	if(field.value=='Search')
	{
		field.value = '';
	}
}

function SearchOnBlur(field)
{
	if(field.value=='')
	{
		field.value='Search';
	}
}
//Phan danh cho chuyen Trang trong Frameset
function fExchangePageOfA(sPath)
  {
      parent.document.location.href=sPath;
  }
//Phan danh cho chuyen Trang trong Frameset  
function FixTopImg(vWidth,vHeight,btn)
 {
   var vLength=btn.width;
   if (vLength>vWidth)
   {
     btn.width=vWidth;
   }
 }
//Moi sua
 function fChangeBGdown(btn)
  {
      btn.className='clsMenuH';
  }
  function fChangeBGUP(btn)
  {
      btn.className='clsMenuHOver';
  }
  function Java_EnlargeImg(sPath,sW,sH)
  {
    var width=1800; 
    var height=500;
	var LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
	window.open("ImgPreview.asp?sPath="+sPath,"window","Top="+TopPosition+"; Left="+LeftPosition+"; Height="+sH+"; Width="+sW+"; center= 1; resizable=no; status= 0");
  }
function  Java_ChangePhoto(sPath,sObj)
{
  var sValue = sObj.value;
  var sHref = sPath + "&iKindID="+sValue;
  document.location.replace(sHref);
}

