﻿// JScript File
menu_status = new Array();


function SetOnMenuLoad()
{
    var CurrentMenuItem = GetCookie ("ActiveMenuItem");
    if(CurrentMenuItem != null)
    {
        document.getElementById(CurrentMenuItem).className = 'show';
    }
}

function SetCookie (name, value) 
{
        //creating expiration date

        var ExpireyDate = new Date();
//        1000 - The number of milliseconds in a second.
//        60 (first one) - The number of seconds in a minute.
//        60 (second one) - The number of minutes in an hour.
//        24 - The number of hours in a day.
//        365 - The number of days in a year.
        ExpireyDate.setTime(ExpireyDate.getTime() + 1000 * 60 * 30 )
        
        
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        //var expires = (argc > 2) ? argv[2] : null;
        var expires = ExpireyDate;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
                ((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
                ((path == null) ? "" : ("; path=" + path)) +
                ((domain == null) ? "" : ("; domain=" + domain)) +
                ((secure == true) ? "; secure" : "");
}

function GetCookie (name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                        if (i == 0)
                                break;
                }
   return null;
}

function showHide(theid){
    if (document.getElementById) 
	{// close all other menu sections
	    SetCookie("ActiveMenuItem", theid);

	    if (theid != 'mymenu16') document.getElementById("mymenu16").className = 'hide';	
	    if (theid != 'mymenu15') document.getElementById("mymenu15").className = 'hide';	         
		if(theid != 'mymenu14')document.getElementById("mymenu14").className = 'hide';	        
		if(theid != 'mymenu13')document.getElementById("mymenu13").className = 'hide';		
		if(theid != 'mymenu12')document.getElementById("mymenu12").className = 'hide';		        
		if(theid != 'mymenu12')document.getElementById("mymenu12").className = 'hide';		
		if(theid != 'mymenu11')document.getElementById("mymenu11").className = 'hide';
		if(theid != 'mymenu10')document.getElementById("mymenu10").className = 'hide';			
		if(theid != 'mymenu9')document.getElementById("mymenu9").className = 'hide';			
		if(theid != 'mymenu8')document.getElementById("mymenu8").className = 'hide';		
		if(theid != 'mymenu7')document.getElementById("mymenu7").className = 'hide';
		if(theid != 'mymenu6')document.getElementById("mymenu6").className = 'hide';
		if(theid != 'mymenu5')document.getElementById("mymenu5").className = 'hide';
		if(theid != 'mymenu4')document.getElementById("mymenu4").className = 'hide';
		if(theid != 'mymenu3')document.getElementById("mymenu3").className = 'hide';
		if(theid != 'mymenu2')document.getElementById("mymenu2").className = 'hide';
		if(theid != 'mymenu1')document.getElementById("mymenu1").className = 'hide';	
		
		
		var switch_id = document.getElementById(theid);
	    switch_id.className = 'show';
       // if(menu_status[theid] != 'show') {
       //    switch_id.className = 'show';
       //    menu_status[theid] = 'show';
      //  }else{
      //     switch_id.className = 'hide';
       //    menu_status[theid] = 'hide';
       // }
    }
}

function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}