//id is receiving the value of parent id and subid of menus from lef_nav.html
//url is receiving the value of path to open the target page from lef_nav.html
//openid is receiving the value to control the menu to open two times after click 

function HideShowMenus(id,url,openid){
    
	var pid=id;
	var urlocation=url;
    var openidinc;
	var strid=id+"";
    var urltransfer=-1;
    
   	if(strid.length==3){
		parentid=strid.substr(0,1);
		childid=strid.substr(1,2);
		navparent = document.getElementById('sm'+parentid);
		navchild = document.getElementById('sm'+childid);

	 }else if (strid.length==2 && id<=18){
		parentid=strid.substr(0,2);
		childid=0;
		navparent = document.getElementById('sm'+parentid);
	 }else if (strid.length==2 && id<90){
		parentid=strid.substr(0,1)
		childid=strid.substr(1,1);
		navparent = document.getElementById('sm'+parentid);
		navchild = document.getElementById('sm'+childid);
	 }else{
		parentid=strid.substr(0,1)
		childid=0;
		navparent = document.getElementById('sm'+parentid);
	 }
	
    if(openid>0){
	for(i=1;i<=17;i++){
		if(i==parentid){
		 navparent.style.display='block';
		 }else if (i==childid){
		  navchild.style.display='block';
		 }else{
			nav1=document.getElementById('sm'+i);
			nav1.style.display='none';
		}
	  }
     }else{
	 urltransfer=openid;
	 openid+=1;
	 }

    openidinc=openid;
	createCookie ( 'nav_val', pid, 0 );
    createCookie ( 'url_loc', urlocation, 0);
    createCookie ( 'openid', openidinc, 0);
    
	if (urltransfer==0){
	    location.href=url;
	}
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


function eraseCookie(name) {
	createCookie(name,"",-1);
}

