<!--
//------------------------------------------------------------------------------
// Copyright (C) NGUYEN NHU TUAN, JunzeNNT, 11/2006
// E-mail: junzennt@yahoo.com OR junzennt@gmail.com
// JunzeCOM
// Nghiem cam sao luu duoi moi hinh thuc, neu trich dan hay de ro suat xu tu JunzeNNT, JunzeCOM
//------------------------------------------------------------------------------
var mau="#FFE6E7";
 function ngonngu_set(obj){
    for(i=0; i<2;i++)
    	if(document.chonngonngu.ngonngu(i).checked==true)
    	document.getElementById(obj).ngonngu.value=document.chonngonngu.ngonngu(i).value;
 }
//----------------------------
 function frmlienket(obj){
 	temp=true;
 	if((Trim(document.getElementById(obj).weblink.value)=="")||(Trim(document.getElementById(obj).weblink.value)=="http://")){
 	   document.getElementById(obj).weblink.style.backgroundColor=mau;
 	   document.getElementById(obj).weblink.focus();
 	   temp=false;
 	}
 	if(checkURL(Trim(document.getElementById(obj).weblink.value))){
 	   document.getElementById(obj).weblink.style.backgroundColor=mau;
 	   document.getElementById(obj).weblink.focus();
 	   temp=false;
 	}
 	if(Trim(document.getElementById(obj).webnote.value)==""){
 	   document.getElementById(obj).webnote.style.backgroundColor=mau;
 	   document.getElementById(obj).webnote.focus();
 	   temp=false;
 	}
 	if(Trim(document.getElementById(obj).en_webnote.value)==""){
 	   document.getElementById(obj).en_webnote.style.backgroundColor=mau;
 	   document.getElementById(obj).en_webnote.focus();
 	   temp=false;
 	}
 	return temp;
 }
//----------------------------
 function frmfaq(obj){
 	temp=true;
 	if(Trim(document.getElementById(obj).question.value)==""){
 	   document.getElementById(obj).question.style.backgroundColor=mau;
 	   document.getElementById(obj).question.focus();
 	   temp=false;
 	}
 	if(Trim(document.getElementById(obj).en_question.value)==""){
 	   document.getElementById(obj).en_question.style.backgroundColor=mau;
 	   document.getElementById(obj).en_question.focus();
 	   temp=false;
 	}
 	if(Trim(document.getElementById(obj).answer.value)==""){
 	   document.getElementById(obj).answer.style.backgroundColor=mau;
 	   document.getElementById(obj).answer.focus();
 	   temp=false;
 	}
 	if(Trim(document.getElementById(obj).en_answer.value)==""){
 	   document.getElementById(obj).en_answer.style.backgroundColor=mau;
 	   document.getElementById(obj).en_answer.focus();
 	   temp=false;
 	}
 	return temp;
 }
 //----------------------------
 function frmdanhmuctin(obj){
 	temp=true;
 	if(Trim(document.getElementById(obj).title.value)==""){
 	   document.getElementById(obj).title.style.backgroundColor=mau;
 	   document.getElementById(obj).title.focus();
 	   temp=false;
 	}
 	if(Trim(document.getElementById(obj).en_title.value)==""){
 	   document.getElementById(obj).en_title.style.backgroundColor=mau;
 	   document.getElementById(obj).en_title.focus();
 	   temp=false;
 	}
 	if(Trim(document.getElementById(obj).comment.value)==""){
 	   document.getElementById(obj).comment.style.backgroundColor=mau;
 	   document.getElementById(obj).comment.focus();
 	   temp=false;
 	}
 	if(Trim(document.getElementById(obj).en_comment.value)==""){
 	   document.getElementById(obj).en_comment.style.backgroundColor=mau;
 	   document.getElementById(obj).en_comment.focus();
 	   temp=false;
 	}
 	return temp;
 }
//------------------------------
//-----------------------------------------------
function tomau(item){
  item.style.backgroundColor="#FFC1C2";
}
function untomau(item){
  item.style.backgroundColor="";
}
function junzedirect(link){
location.href=link;
}
//Process ITEM
function processitem(strLink,strAlert){
if(confirm(strAlert)){
    junzedirect(strLink);
}
}
function anhien(msg_id) {
	msg_id.style.display = msg_id.style.display == 'none' ? 'block' : 'none';
}
//Xem anh
function xemanhnao(id,anhlinkabc){
document.getElementById(id).src=anhlinkabc;
dichuyen(viewanhabc,0,-100);
anhien(viewanhabc);
}
//Di chuyen den vi tri chuot
function dichuyen(divid,x,y){
ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
if (ns4) {var mouseX=e.pageX; var mouseY=e.pageY}//Neu trinh duyet la Nescaep
if (ie4) {var mouseX=event.x; var mouseY=event.y}//Neu trinh duyet la IE
divid.style.left=mouseX+x;
divid.style.top=mouseY+y;
}
function demkytu(maxchart,obj,display){
	if(obj.value.length>maxchart){
	obj.value=obj.value.substring(0, maxchart);
	}else{
	display.value=maxchart-obj.value.length;
	}
	}

//Chuyen nhanh giua cac Link
function chuyenlink(id){
if(document.getElementById(id).switchlink.value!="none"){
//location.href=document.getElementById(id).switchlink.value;
url=document.getElementById(id).switchlink.value;
window.open(url,"","");
}
}

// Effect IMGAGES
function noeffect(obj) {
    obj.style.filter="alpha(opacity=20)";
    obj.filters.alpha.enabled='false';
}
function effect(obj) {
    obj.style.filter="alpha(opacity=50)";
    obj.filters.alpha.enabled='true';
}
// Cac ham xu ly co ich khac---------------------
//-----------------------------------------------
function setHome()
{
   document.body.style.behavior='url(#default#homepage)';
   document.body.setHomePage(window.location.href);
}
function addfavo(){
window.external.AddFavorite(location.href, document.title);
}
//------------------------------------------------
function Trim(STRING){
STRING = LTrim(STRING);
return RTrim(STRING);
}
function RTrim(STRING){
while(STRING.charAt((STRING.length -1))==" "){
STRING = STRING.substring(0,STRING.length-1);
}
return STRING;
}
function LTrim(STRING){
while(STRING.charAt(0)==" "){
STRING = STRING.replace(STRING.charAt(0),"");
}
return STRING;
}
//-----------------------------------------------
function checkEmail(str){
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
return true
else
return false
}

function checkURL(str) {
 var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
 if (tomatch.test(str)){
 return false
 } else {
 return true
}
}

function checknumber(str){
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(str))
testresult=false
else{
testresult=true
}
return testresult
}

function checkcardid(str){
var filter=/^\d{4}-\d{4}-\d{4}$/
if (filter.test(str))
return true
else
return false
}
//-----------------------------------------------
  function choncheck(trangthai,tu)
		   {
		   		var alen=document.soanthao.elements.length;
				alen=(alen>1)?document.soanthao.chk.length:0;
				if (alen>0)
				{
			   		for(var i=0;i<alen;i++)
						document.soanthao.chk[i].checked=trangthai;
				}else
				{
						document.soanthao.chk.checked=trangthai;
				}
				if(tu>0)
					document.soanthao.chkall.checked=trangthai;
		   }

	function choncheckone()
		   {
		   		var alen=document.soanthao.elements.length;
				var isChecked=true;
				alen=(alen>1)?document.soanthao.chk.length:0;
				if (alen>0)
				{
			   		for(var i=0;i<alen;i++)
						if(document.soanthao.chk[i].checked==false)
							isChecked=false;
				}else
				{
					if(document.soanthao.chk.checked==false)
						isChecked=false;
				}
				document.soanthao.chkall.checked=isChecked;
		   }

	function laygiatri(){
	        var strchon="";
    		var alen=document.soanthao.elements.length;
			alen=(alen>1)?document.soanthao.chk.length:0;
        if(alen>0)
				{
				for(var i=0;i<alen;i++)
				if(document.soanthao.chk[i].checked==true)
				strchon+=document.soanthao.chk[i].value+",";
				}else{
				if(document.soanthao.chk.checked==true)
	  			strchon+=document.soanthao.chk.value;
				}
		document.soanthao.chon.value=strchon;
	}

	function checkInput(strAlert)
		   {
				var alen=document.soanthao.elements.length;
				var isChecked=false;
				alen=(alen>1)?document.soanthao.chk.length:0;
				if (alen>0)
				{
			   		for(var i=0;i<alen;i++)
						if(document.soanthao.chk[i].checked==true)
							isChecked=true;
				}else
				{
					if(document.soanthao.chk.checked==true)
						isChecked=true;
				}
				if (!isChecked)
				alert("Hay chon mot cai di cung");
				else
if(confirm(strAlert)){
				  laygiatri();
}else{
isChecked=false;
}
			return isChecked;
		  }
//-----------------------------------------------
//Funtion for Insert Text into TestAre
// insertText(formName,textareName, testInsert)
// addText(formName,textareName, testInsert1, testInsert2)
function insertText(formname, elname, what) {
if (document.forms[formname].elements[elname].createTextRange) {
document.forms[formname].elements[elname].focus();
document.selection.createRange().duplicate().text = what;
} else if ((typeof document.forms[formname].elements[elname].selectionStart) != 'undefined') { // for Mozilla
var tarea = document.forms[formname].elements[elname];
var selEnd = tarea.selectionEnd;
var txtLen = tarea.value.length;
var txtbefore = tarea.value.substring(0,selEnd);
var txtafter = tarea.value.substring(selEnd, txtLen);
var oldScrollTop = tarea.scrollTop;
tarea.value = txtbefore + what + txtafter;
tarea.selectionStart = txtbefore.length + what.length;
tarea.selectionEnd = txtbefore.length + what.length;
tarea.scrollTop = oldScrollTop;
tarea.focus();
} else {
document.forms[formname].elements[elname].value += what;
document.forms[formname].elements[elname].focus();
}
}
function addText(formname,elname, wrap1, wrap2) {
	if (document.selection) { // for IE
		var str = document.selection.createRange().text;
		document.forms[formname].elements[elname].focus();
		var sel = document.selection.createRange();
		sel.text = wrap1 + str + wrap2;
		return;
	} else if ((typeof document.forms[formname].elements[elname].selectionStart) != 'undefined') { // for Mozilla
		var txtarea = document.forms[formname].elements[elname];
		var selLength = txtarea.textLength;
		var selStart = txtarea.selectionStart;
		var selEnd = txtarea.selectionEnd;
		var oldScrollTop = txtarea.scrollTop;
		//if (selEnd == 1 || selEnd == 2)
		//selEnd = selLength;
		var s1 = (txtarea.value).substring(0,selStart);
		var s2 = (txtarea.value).substring(selStart, selEnd)
		var s3 = (txtarea.value).substring(selEnd, selLength);
		txtarea.value = s1 + wrap1 + s2 + wrap2 + s3;
		txtarea.selectionStart = s1.length;
		txtarea.selectionEnd = s1.length + s2.length + wrap1.length + wrap2.length;
		txtarea.scrollTop = oldScrollTop;
		txtarea.focus();
		return;
	} else {
		insertText(elname, wrap1 + wrap2);
	}
}
//-----------------------------------------------
//EDITOR-----------------------------------------
	_editor_url = 'editor/htmlarea2/';          // URL to htmlarea files
	var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
	if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
	if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
	if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }

	if (win_ie_ver >= 5.5) {
		document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
		document.write(' language="Javascript1.2"></scr' + 'ipt>');
	} else {
		document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>');
	}
//-----------------------------------------------
//Tao hai thanh quang cao chay hai ben
function thanhbenphaixy()
	{
		startX = document.body.clientWidth - 110, startY =  50;
		var ns = (navigator.appName.indexOf("Netscape") != -1);
		var d = document;

		if (document.body.clientWidth < 980) startX = -110;


		function ml(id)
		{
			var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			if(d.layers)el.style=el;
			el.sP=function(x,y){this.style.left=x;this.style.top=y;};
			el.x = startX;
			el.y = startY;
			return el;
		}

		window.stayTopLeft=function()
		{

			if (document.body.clientWidth < 980)
			{
				ftlObj.x = - 115;ftlObj.y = 0;	ftlObj.sP(ftlObj.x, ftlObj.y);
			}

			else
			{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY = ns ? pageYOffset : document.documentElement.scrollTop;
			else if (document.body)
				var pY = ns ? pageYOffset : document.body.scrollTop;

			if (document.body.scrollTop >  50){startY = 3} else {startY =  50};

			if (document.body.clientWidth >= 1024)
			{
				ftlObj.x = document.body.clientWidth - 110;ftlObj.y += (pY + startY - ftlObj.y)/32;ftlObj.sP(ftlObj.x, ftlObj.y);
			}
			else
			{


			ftlObj.x  = startX+5;
			ftlObj.y += (pY + startY - ftlObj.y)/32;
			ftlObj.sP(ftlObj.x, ftlObj.y);
			}
			}
			setTimeout("stayTopLeft()", 1);
		}

		ftlObj = ml("divAdRight");
		stayTopLeft();

	}
function thanhbentraixy()
	{
		startX2 = document.body.clientWidth - 1004, startY2 =  50;
		var ns2 = (navigator.appName.indexOf("Netscape") != -1);
		var d2 = document;

		if (document.body.clientWidth < 980) startX2 = -110;


		function ml2(id)
		{
			var el2=d2.getElementById?d2.getElementById(id):d2.all?d2.all[id]:d2.layers[id];
			if(d2.layers)el2.style=el2;
			el2.sP=function(x,y){this.style.left=x;this.style.top=y;};
			el2.x = startX2;
			el2.y = startY2;
			return el2;
		}

		window.stayTopLeft2=function()
		{
			if (document.body.clientWidth < 980)
			{
				ftlObj2.x = - 115;ftlObj2.y = 0;	ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
			else
			{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY2 = ns2 ? pageYOffset : document.documentElement.scrollTop;
			else if (document.body)
				var pY2 = ns2 ? pageYOffset : document.body.scrollTop;

			if (document.body.scrollTop >  50){startY2 = 3} else {startY2 =  50};

			if (document.body.clientWidth >= 1004)
			{
				ftlObj2.x =  0;ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/32;	ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
			else
			{



			ftlObj2.x  = startX2;
			ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/32;
			ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
			}
			setTimeout("stayTopLeft2()", 1);
		}

		ftlObj2 = ml2("divAdLeft");
		stayTopLeft2();

	}

//Hien thi ca hai thanh
	function ShowAdDiv()
	{
		var objAdDivLeft  = document.getElementById("divAdLeft");
		var objAdDivRight = document.getElementById("divAdRight");
		if (document.body.clientWidth < 980)
		{
			objAdDivLeft.style.left  = - 110;
			objAdDivRight.style.left = - 110;
		}

		else
		{
			objAdDivLeft.style.left  = 0;
			objAdDivRight.style.left = document.body.clientWidth - 110;
		}
		thanhbenphaixy();
		thanhbentraixy();
	}
//Hien thi thanh ben Trai
	function ShowAdDivleft()
	{
		var objAdDivLeft  = document.getElementById("divAdLeft");
		if (document.body.clientWidth < 980)
		{
			objAdDivLeft.style.left  = - 110;
		}

		else
		{
			objAdDivLeft.style.left  = 0;
		}
		thanhbentraixy();
	}
//Hien thi thanh ben Phai
	function ShowAdDivright()
	{
		var objAdDivRight = document.getElementById("divAdRight");
		if (document.body.clientWidth < 980)
		{
			objAdDivRight.style.left = - 110;
		}

		else
		{
			objAdDivRight.style.left = document.body.clientWidth - 110;
		}
		thanhbenphaixy();
	}

//-----------------------------------------------
//-->
