// 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 -->



function select_innerHTML(objeto,innerHTML){
/******
* select_innerHTML - corrige o bug do InnerHTML em selects no IE
* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Versão: 2.1 - 04/09/2007
* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
* @objeto(tipo HTMLobject): o select a ser alterado
* @innerHTML(tipo string): o novo valor do innerHTML
*******/
    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
      
    
    for(var i=0;i<selTemp.childNodes.length;i++){
  var spantemp = selTemp.childNodes[i];
  
        if(spantemp.tagName){     
            opt = document.createElement("OPTION")
    
   if(document.all){ //IE
    objeto.add(opt)
   }else{
    objeto.appendChild(opt)
   }       
    
   //getting attributes
   for(var j=0; j<spantemp.attributes.length ; j++){
    var attrName = spantemp.attributes[j].nodeName;
    var attrVal = spantemp.attributes[j].nodeValue;
    if(attrVal){
     try{
      opt.setAttribute(attrName,attrVal);
      opt.setAttributeNode(spantemp.attributes[j].cloneNode(true));
     }catch(e){}
    }
   }
   //getting styles
   if(spantemp.style){
    for(var y in spantemp.style){
     try{opt.style[y] = spantemp.style[y];}catch(e){}
    }
   }
   //value and text
   opt.value = spantemp.getAttribute("value")
   opt.text = spantemp.innerHTML
   //IE
   opt.selected = spantemp.getAttribute('selected');
   opt.className = spantemp.className;
  } 
 }    
 document.body.removeChild(selTemp)
 selTemp = null
}



//jquery fx begin
$(document).ready(function()
{
	$("#memberAreaPostBtn").hide();
	//toggle the componenet with class msg_body
	$("#memberAreaPostLink").click(function(){
		$('#memberAreaPostBtn').slideToggle(600);
		return false;
	});
	
	
	$("input[@type=password], input[@type=text], textarea").focus(function() {
        $(this).addClass("input_focus"); 
                
    });
    
    $("input[@type=password], input[@type=text], textarea").blur(function(){
        if ($(this).find(".input_focus")) {
            $(this).removeClass("input_focus");
        }
    });

});




