﻿function kat (category) { 

   whichpost = document.getElementById(category); 
   
   if (whichpost.className=="visible") { 
      whichpost.className="hidden"; 
   } 
   else { 
      whichpost.className="visible"; 
   } 
} 

function pil (navn) { 

   whichpost = document.getElementById(navn); 
   
   if (whichpost.className=="visible") { 
      whichpost.className="hidden"; 
   } 
   else { 
      whichpost.className="visible"; 
   } 
}

function toggle (divID) {

     var container = document.getElementById( 'container' );
     
     var newClass = divID + "Visible";
     
     if ( container.className == newClass )
       container.className = '';
       
     else
       container.className = newClass;
}

function hideAll() {
	document.getElementById( 'container' ).className = '';
}

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 readCookie(name)
{
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var j=0;j < ca.length;j++)
        {
                var c = ca[j];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
}

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

function kat (category)
{ 
   whichpost = document.getElementById(category); 
   
   if (whichpost.className=="visible") { 
      whichpost.className="hidden";
   } 
   else { 
      whichpost.className="visible"; 
   }
   if (readCookie(category)) {
      eraseCookie(category);
   }
   createCookie(category,whichpost.className,1);

}
function openCategories()
{
    var cats = new Array("illustrasjon", "typografi", "fotografi", "tegning", "design", "video", "posters", "annet", "dongery", "web", "tegneserier", "linker");
    for(j = 0; j < cats.length; j++) {
        if (readCookie(cats[j]) == "visible") {
            kat(cats[j]);
        }
    }   
}
