function Set_Cookie( name, value, expires_Seconds, path, domain, secure )
{
  var today = new Date();
  var expires = 3600*1000; //default 1 hour
  if ( expires_Seconds ) {
    if (expires_Seconds == 'Session')
      expires = false;
    else
      expires = expires_Seconds * 1000;
  }
  var expires_date = new Date( today.getTime() + expires );
  document.cookie = name + "=" + encodeURIComponent( value ) +
  ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
  ( ( path ) ? ";path=" + path : "" ) +
  ( ( domain ) ? ";domain=" + domain : "" ) +
  ( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) {
var a_all_cookies = document.cookie.split( ';' ); // split all cookies into arr we can interate over
var a_temp_cookie = new Array();
var cookie_name = '';
for ( i = 0; i < a_all_cookies.length; i++ )
{
  a_temp_cookie = a_all_cookies[i].split( '=' );
  cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); // trim ws from name
  if ( cookie_name == check_name ) {
    if ( a_temp_cookie.length > 1 ) // cookie has value {
      return decodeURIComponent( a_temp_cookie[1]).replace(/^\s+|\s+$/g, ''); //trim spaces
    return "NO_VALUE"; //cookie is set but no value
  }
}
return null;
}