function setCookie(cookie_name, cookie_val) { 
     var nextyear = new Date(); 
     //create the cookie expiry date 
     nextyear.setFullYear(nextyear.getFullYear() +1); 
     //set the cookie 
     document.cookie = cookie_name +"="+ escape(cookie_val) + "; expires="+nextyear.toGMTString(); 
}//end setCookie function 

function getCookie( cookie_name ) { 
     //Retrieve all of the cookies into a variable called all cookies 
     var allcookies = document.cookie; 

     //Locate the position of the cookie label 
     var pos = allcookies.indexOf( cookie_name ); 

     //if pos = -1 then cookie label wasn't found 
     if (pos != -1) { 

          //Locate the beginning and end of the value of our cookie label 
          //Locate the start of the cookie var add the # characters found plus one 
          var start = pos + cookie_name.length + 1; 

          //find the end of the value 
          var end = allcookies.indexOf(";",start); 

          //if end is equal to negative one then set it to the length of allcookies 
          if (end == -1) end = allcookies.length; 

      //convert the sub string or value of the parameter and store it in answer. 
          answer = unescape( allcookies.substring(start,end) ); 
           
          //return the value of the cookie 
          return answer; 
     } // end if 
} //end function getCookie