// JavaScript Document
/*-------------------------------------------------------------------------*/
// Get element by id
/*-------------------------------------------------------------------------*/

function my_getbyid(id)
{
	itm = null;
	
	if (document.getElementById)
	{
		itm = document.getElementById(id);
		
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}
	
	return itm;
}

 /*-------------------------------------------------------------------------*/
// Set DIV ID to hide
/*-------------------------------------------------------------------------*/

function my_hide_div(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "none";
}

/*-------------------------------------------------------------------------*/
// Set DIV ID to show
/*-------------------------------------------------------------------------*/

function my_show_div(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "";
}

/*-------------------------------------------------------------------------*/
// Toggle category
/*-------------------------------------------------------------------------*/

function togglecategory( fid,add )
{
	//not left menu, but using this techniques
	if(fid >= 100)
	{
		if(add)
		{
			my_show_div( my_getbyid( 'fo_'+fid  ) );
			my_hide_div( my_getbyid( 'fc_'+fid  ) );
		}
		else
		{
			my_show_div( my_getbyid( 'fc_'+fid  ) );
			my_hide_div( my_getbyid( 'fo_'+fid  ) );
		}
			
		return;
	}
	
	//normal left menu
	if ( add )
	{	
		//tao cookie de luu lai sup-cat nao dang duoc mo
		//de mo lai cho lan refresh sau
		setCookie("sup_cat", fid, "", "");
		for(var i = 1; i <= 10; i++)
		{
			my_hide_div( my_getbyid( 'fo_'+i  ) );
			my_show_div( my_getbyid( 'fc_'+i  ) );

		}
		
		my_show_div( my_getbyid( 'fo_'+fid  ) );
		my_hide_div( my_getbyid( 'fc_'+fid  ) );
	}
	else
	{
		setCookie("sup_cat", 0, "", "");
		my_show_div( my_getbyid( 'fc_'+fid  ) );
		my_hide_div( my_getbyid( 'fo_'+fid  ) );
	}
	
}

//ham dung de set cookie
function setCookie(cookieName, cookieValue, cookiePath, cookieExpires)
{
	cookieValue = escape(cookieValue);
	if (cookieExpires == "")
	{
		var nowDate = new Date();
		nowDate.setMonth(nowDate.getMonth() + 6);
		cookieExpires = nowDate.toGMTString();
	}
	if (cookiePath != "")
	{
		cookiePath = ";Path=" + cookiePath;
	}
	else
	{
		cookiePath = ";Path=/";
	}
	document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires + cookiePath;
}


//Ham dung lay gia tri cua 1 cookie
function getCookieValue(cookieName)
{
	var cookieValue = document.cookie;
	var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");
	if (cookieStartsAt == -1)
	{
		cookieStartsAt = cookieValue.indexOf(cookieName + "=");
	}
	if (cookieStartsAt == -1)
	{
		cookieValue = null;
	}
	else
	{
		cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1;
		var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
		if (cookieEndsAt == -1)
		{
			cookieEndsAt = cookieValue.length;
		}
		cookieValue = unescape(cookieValue.substring(cookieStartsAt, cookieEndsAt));
	}
	return cookieValue;
}

//Ham dung de kiem tra xem se hien thi menu o che do sort theo abc hay theo category
function checkMenu()
{
	//kiem tra sup-category nao dang duoc mo, de mo cho dung
	var cat = getCookieValue("sup_cat");
	if(cat != "")	//da co 1 sup cat duoc chon truoc do
	{
		//alert( my_getbyid( 'fo_'+cat  ));
		my_show_div( my_getbyid( 'fo_'+cat  ) );
		my_hide_div( my_getbyid( 'fc_'+cat  ) );
	}
	
}



function checkall(num)

	{



		for ( i=0;i < document.manage.elements.length ; i++ ){

			if ( document.manage.all.checked==true ){

				document.manage.elements[i].checked = true;

			}

			else

			{

				document.manage.elements[i].checked  = false;

			}

		}

	}
	
	//task1: check Menu style

	

function delm(theURL)
{
if (confirm('Are you sure ?'))
{
	window.location.href=theURL;
}
		  
}



<!-- ;
var newwindow;
var wheight = 0, wwidth = 0;

function popitup5(url, title, iwidth, iheight, colour) {
var pwidth, pheight;

if ( !newwindow || newwindow.closed ) {
pwidth=iwidth+30;
pheight=iheight+30;
newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10');
wheight=iheight;
wwidth=iwidth;
}

if (wheight!=iheight || wwidth!=iwidth ) {
pwidth=iwidth+30;
pheight=iheight+90;
newwindow.resizeTo(pwidth, pheight);
wheight=iheight;
wwidth=iwidth;
}

newwindow.document.clear();
newwindow.focus();
newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >');
newwindow.document.writeln('<\/center> <\/body> <\/html>');
newwindow.document.close();
newwindow.focus();
}

// Routines to tidy up popup windows when page is left
// Call with an onUnload="tidy5()" in body tag

function tidy5() {
if (newwindow && !newwindow.closed) { newwindow.close(); }
}

// Based on JavaScript provided by Peter Curtis at www.pcurtis.com -->