﻿function whenEvent(tdItem, className){
	tdItem.className = className;
}

function changeImage(tdItem, imageName){
	tdItem.src = imageName;
}
		
function whenClick(imgItem, trChildID){
	var trChild = getElement(trChildID, 'id');
	if (trChild){
		trChild.style.display = "block";
	}
}

var date = new Date();
date.setFullYear(date.getFullYear() + 1);

function getBrowserSize(){
	try{
		/*document.cookie = "width=" + escape(window.screen.availWidth) + "; expires=" + date.toGMTString();
		document.cookie = "height=" + escape(window.screen.availHeight) + "; expires=" + date.toGMTString();
		*/
		document.cookie = "width=800; expires=" + date.toGMTString();
		document.cookie = "height=600; expires=" + date.toGMTString();
	}catch(e){}
}
function OpenWin(obj){
	try{
		if(obj.options[obj.selectedIndex].value !=""){
			window.open(obj.options[obj.selectedIndex].value);
		}
	}catch(e){}	
}
getBrowserSize();


function ChangeSize(index){
	try{
		window.parent.frames.TopLevelFrame.rows = (22 + index*53) + ",*";
		RowAtt[0].style.display = ((index == 0) ? "none" : "block");
		RowAtt[1].style.display = ((index == 0) ? "none" : "block");
		tdClose.style.display = ((index == 0) ? "none" : "block");
		tdOpen.style.display = ((index == 0) ? "block" : "none");
	}catch(e){}
	return false;
}
function ViewFolder(close){
	try{
		if (close){
			window.parent.LeftMenu.cols = "200,*";
			window.parent.LeftMenu2.rows = "23,*";
			Folder.style.display = "block";
		}
	}catch(e){}
}

var cols = "150,*";

function preloadImages() {
	try{
		if (document.images) {
			newImage("images/buttonLeftClose2.gif");
			newImage("images/buttonLeftOpen2.gif");
			preloadFlag = true;
		}
	}catch(e){
		preloadFlag = false;
	}
}

function ViewFolder(close){
	try{
		if (close){
			window.parent.LeftMenu.cols = cols;
			window.parent.LeftMenu2.rows = "23,*";
			Folder.style.display = "block";
		}else{
			cols = window.parent.LeftMenu.cols;
			window.parent.LeftMenu.cols = "15,*";
			window.parent.LeftMenu2.rows = "*,0";
			Folder.style.display = "none";
		}
	}catch(e){}
}
function OpenWindow4(windowURL, height, width, target){
try{
	var windowConfig = 'toolbar=no, ';
    //Menu
	windowConfig += 'menubar=no, ';
    //Scrollbars
	windowConfig += 'scrollbars=yes, ';
    //Resizable
	windowConfig += 'resizable=no, ';
    //Address Bar
	windowConfig += 'location=no, ';
	//Favorites
	windowConfig += 'directories=no, ';
	//Statusbar
	windowConfig += 'status=no, ';
	if(width != null){
	windowConfig += 'width='+ width +', ';		
	}else{windowConfig += 'width=400, ';}
	
	if(target == null){
	target="towWin";}	

	if(height != null){
	windowConfig += 'height='+ height +', ';		
	}else{windowConfig += 'height=700, ';}		
	var leftWin = (window.screen.availWidth - width)/2
	var topWin = (window.screen.availHeight - height)/2
	windowConfig += 'left=' + leftWin + ', ';
	windowConfig += 'top='+ topWin + ', ';
	//windowConfig += 'height=' + window.screen.height + ', ';
	//windowConfig += 'width=' + window.screen.width;
	var newWindow = window.open(windowURL, target, config = windowConfig);
	newWindow.opener = window;
}catch(e){}
}
function OpenWindow(windowURL, height, width, target){
try{
	var windowConfig = 'toolbar=no, ';
    //Menu
	windowConfig += 'menubar=no, ';
    //Scrollbars
	windowConfig += 'scrollbars=yes, ';
    //Resizable
	windowConfig += 'resizable=no, ';
    //Address Bar
	windowConfig += 'location=no, ';
	//Favorites
	windowConfig += 'directories=no, ';
	//Statusbar
	windowConfig += 'status=no, ';
	if(width != null){
	windowConfig += 'width='+ width +', ';		
	}else{windowConfig += 'width=400, ';}
	
	if(target == null){
	target="towWin";}	

	if(height != null){
	windowConfig += 'height='+ height +', ';		
	}else{windowConfig += 'height=700, ';}		
	var leftWin = (window.screen.availWidth - width)/2
	var topWin = (window.screen.availHeight - height)/2
	windowConfig += 'left=' + leftWin + ', ';
	windowConfig += 'top='+ topWin + ', ';
	//windowConfig += 'height=' + window.screen.height + ', ';
	//windowConfig += 'width=' + window.screen.width;
	var newWindow = window.open(windowURL, target, config = windowConfig);
	newWindow.opener = window;
}catch(e){}
}


function OpenWindow2(windowURL, height, width, target){
try{
	var windowConfig = 'toolbar=no, ';
    //Menu
	windowConfig += 'menubar=no, ';
	//Title
	windowConfig += 'title=, ';
    //Scrollbars
	windowConfig += 'scrollbars=yes, ';
    //Resizable
	windowConfig += 'resizable=no, ';
    //Address Bar
	windowConfig += 'location=no, ';
	//Favorites
	windowConfig += 'directories=no, ';
	//Statusbar
	windowConfig += 'status=no, ';
	if(width != null){
	windowConfig += 'width='+ width +', ';		
	}else{windowConfig += 'width=400, ';}
	
	if(target == null){
	target="towWin";}	

	if(height != null){
	windowConfig += 'height='+ height +', ';		
	}else{windowConfig += 'height=700, ';}		

	var leftWin = (window.screen.availWidth - width)/2
	var topWin = (window.screen.availHeight - height)/2
	windowConfig += 'left=' + leftWin + ', ';
	windowConfig += 'top='+ topWin + ', ';
	//windowConfig += 'height=' + window.screen.height + ', ';
	//windowConfig += 'width=' + window.screen.width;
	var newWindow2 = window.open(windowURL, target, config = windowConfig);
	newWindow2.opener = window;
}catch(e){}
}

function OpenWindow1(windowURL, height, width, target){
try{
	var windowConfig = 'toolbar=no, ';
    //Menu
	windowConfig += 'menubar=no, ';
    //Scrollbars
	windowConfig += 'scrollbars=no, ';
    //Resizable
	windowConfig += 'resizable=no, ';
    //Address Bar
	windowConfig += 'location=no, ';
	//Favorites
	windowConfig += 'directories=no, ';
	//Statusbar
	windowConfig += 'status=no, ';
	if(width != null){
	windowConfig += 'width='+ width +', ';		
	}else{windowConfig += 'width=400, ';}
	
	if(target == null){
	target="towWin";}	

	if(height != null){
	windowConfig += 'height='+ height +', ';		
	}else{windowConfig += 'height=700, ';}		

	var leftWin = (window.screen.availWidth - width)/2
	var topWin = (window.screen.availHeight - height)/2
	windowConfig += 'left=' + leftWin + ', ';
	windowConfig += 'top='+ topWin + ', ';
	//windowConfig += 'height=' + window.screen.height + ', ';
	//windowConfig += 'width=' + window.screen.width;
	var newWindow = window.open(windowURL, target, config = windowConfig);
	newWindow.opener = window;
}catch(e){}
}	

function OpenWindowResgister(windowURL, height, width, target){
try{
	var windowConfig = 'toolbar=no, ';
    //Menu
	windowConfig += 'menubar=no, ';
    //Scrollbars
	windowConfig += 'scrollbars=yes, ';
    //Resizable
	windowConfig += 'resizable=no, ';
    //Address Bar
	windowConfig += 'location=no, ';
	//Favorites
	windowConfig += 'directories=no, ';
	//Statusbar
	windowConfig += 'status=no, ';
	if(width != null){
	windowConfig += 'width='+ width +', ';		
	}else{windowConfig += 'width=600, ';}
	
	if(target == null){
	target="towWin";}	

	if(height != null){
	windowConfig += 'height='+ height +', ';		
	}else{windowConfig += 'height=500, ';}		

	windowConfig += 'left=185, ';
	windowConfig += 'top=125, ';
	//windowConfig += 'height=' + window.screen.height + ', ';
	//windowConfig += 'width=' + window.screen.width;
	var newWindow = window.open(windowURL, target, config = windowConfig);
	newWindow.opener = window;
}catch(e){}
}

function JSFX_FloatTopDiv()
{
	var verticalpos="fromtop"
	var startX = 0;
		startY = 0;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;					
	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;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function()
	{
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : document.body.scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("demo");
	stayTopLeft();
}
				
function confirmDelete() {
 var agree=confirm("Canh bao: Ban dang thuc hien xoa item nay!\n+ Item se bi xoa khoi he thong\nBan co chac khong?");
 if (agree) {
 return true ;
 }
 else {
  return false ;
  }
}

function confirmDelete1() {
 var agree=confirm("Canh bao: Ban dang thuc hien xoa item nay!\nBan co chac khong?");
 if (agree) {
 return true ;
 }
 else {
  return false ;
  }
}


function jumpPage(url, s) {
	var urltemplate = url;
	//if (s.selectedIndex != 0) 
		top.location.href = url + s.options[s.selectedIndex].value;
	return 1;
}

	function FloatTopDiv()
	{
		startX = document.body.clientWidth - 129, startY = 71;
		var ns = (navigator.appName.indexOf("Netscape") != -1);
		var d = document;
			
		if (document.body.clientWidth < 1024) startX = -129;

		
		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 > 71){startY = 3} else {startY = 71};

			if (document.body.clientWidth >= 1024)
			{
				ftlObj.x = document.body.clientWidth - 129;ftlObj.y += (pY + startY - ftlObj.y)/32;ftlObj.sP(ftlObj.x, ftlObj.y);
			}
			else
			{
			
			
			ftlObj.x  = startX;
			ftlObj.y += (pY + startY - ftlObj.y)/32;
			ftlObj.sP(ftlObj.x, ftlObj.y);
			}
			}
			setTimeout("stayTopLeft()", 1);
		}
		
		ftlObj = ml("divAdRight");
		stayTopLeft();
		
	}
function FloatTopDiv2()
	{
		startX2 = document.body.clientWidth - 1004, startY2 = 71;
		var ns2 = (navigator.appName.indexOf("Netscape") != -1);
		var d2 = document;
			
		if (document.body.clientWidth < 980) startX2 = -129;

		
		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 > 71){startY2 = 3} else {startY2 = 71};

			if (document.body.clientWidth >= 1024)
			{
				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();
		
	}


	function ShowAdDivLeft()
	{
	
		var objAdDivLeft  = document.getElementById("divAdLeft");
	    if(document.body.clientWidth <= 1024)
	    {
	        objAdDivLeft.style.display = 'none';
	        return false;
	    }

		if (document.body.clientWidth < 980)
		{
			objAdDivLeft.style.left  = - 129;
		}
		
		else
		{
			objAdDivLeft.style.left  = 0;
		}
		FloatTopDiv2();
	}

	function ShowAdDivRight()
	{
		var objAdDivRight = document.getElementById("divAdRight");
	    if(document.body.clientWidth <= 1024)
	    {
	        objAdDivRight.style.display = 'none';
	        return false;
	    }

		if (document.body.clientWidth < 980)
		{
			objAdDivRight.style.left = - 129;
		}
		
		else
		{
			objAdDivRight.style.left = document.body.clientWidth - 110;
		}
		FloatTopDiv();
	}

				