function setcookie ( name,value,toalert,alertmessage,redirecturl )
{
  var cookie_string = name + "=" + escape ( value );  
  document.cookie = cookie_string;
  var result = getcookie(name,toalert,alertmessage,redirecturl);
 
}

function getcookie ( cookie_name, toalert, alertmessage, redirecturl )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
  {
     if(toalert == "true")
     {
       alert(alertmessage);  
     }
     if(redirecturl)
     {
       window.location = redirecturl;
     }
    return null;
  }
}
