function GetCookieOpenClose(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }

  //window.alert('does not exist : ' + sName);
  // a cookie with the requested name does not exist
  return null;
}

function SetCookieOpenClose(sName, sValue)
{
  date = new Date();
  document.cookie = sName + "=" + escape(sValue) + "; expires=Mon, 01-Jan-2018 00:00:00 GMT";
  
  //window.alert('SetCookieOpenClose(' + sName + ',' + sValue + ')');
    
}

function toggle(t) {

        var para=document.getElementById(t);
        var tb = document.getElementById('t' + t);
        var htb = document.getElementById('h' + t);

        var v = GetCookieOpenClose('l');
        
        if(para.style.display!='none') {
                
                para.style.display = 'none';
                tb.style.display = 'block';
                htb.style.display = 'none';
                
        	if (v!=null) {
        		v += "|" + t;
        	} else {
        		
        		v = "|" + t;
        	}
                
                SetCookieOpenClose('l',v);
                
        }
        else {

                para.style.display = 'block';
                tb.style.display = 'none';
                htb.style.display = 'block';
        
        	if (v!=null) {
                  v = v.replace("|" + t,"");
        	}        
                
                SetCookieOpenClose('l',v);

        }
        
        v = GetCookieOpenClose('l');
        
        return true;
}
function setpageblocks(ckname) {
        
        var v = GetCookieOpenClose('l');
        
        if(v!=null) {
        
        	t = ckname;
        
        	var para = document.getElementById(t);
        	var tb = document.getElementById('t' + t);
        	var htb = document.getElementById('h' + t);

        	list = v.split("|");

                para.style.display = 'block';
                tb.style.display = 'none';
                htb.style.display = 'block';        			
        			
        	
        	for (var i=0; i<list.length; i++) {
        	
        		if (list[i]==ckname) {
        			
		                para.style.display = 'none';
		                tb.style.display = 'block';
		                htb.style.display = 'none';
                        

        		}
        	
        	}
        
        }
}