/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Public Domain (Thanks to Dustin Diaz) :: http://www.dustindiaz.com/top-ten-javascript/ */

//alert("document.location = " + document.location + "\n" + "document.top = " + document.top + "\n" + "  document.URL = " + document.URL + "\n" + "  document.referrer = " + document.referrer + "\n" + "  document.domain = " + document.domain + "\n" + "  document.cookie = " + document.cookie + "\n" + "  document.lastModified = " + document.lastModified + "\n" + "  document.top = " + document.top + "\n" + "  document.pathname = " + document.pathname + "\n");
//alert("window.location = " + window.location + "\n" + "window.location.href = " + window.location.href + "\n" + "  window.opener = " + window.opener + "\n" + "  window.document = " + window.document + "\n" + "  window.name = " + window.name + "\n" + "  window.parent = " + window.parent + "\n" + "  window.top = " + window.top + "\n" + "  document.location.pathname = " + document.location.pathname + "\n");

if (!pagecheck()) {setTimeout("checkLog()",250)};     //Let page load first

function logOut () {
  setCookie('excorp', 'logout', .5, '/');
}

function logIn () {
  setCookie('excorp', 'login', .5, '/');
}

function checkLog () {
  if(getCookie('excorp') == 'login') {if(document.getElementById('log')) {document.getElementById("log").style.visibility = 'visible'}};
}

function pagecheck () {
  if ((document.URL.indexOf('login') > 0) || (document.URL.indexOf('logout') > 0)) {return(true)};
  return(false);
}

function getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
  var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) {
//    expires = expires * 1000 * 60 * 60 * 24;
//    expires = expires * 3600000;
    expires = new Date((new Date()).getTime() + expires * 3600000);
  }
  var expires_date = new Date( today.getTime() + (expires) );
  document.cookie = name+"="+escape( value ) + 
    ( ( expires ) ? ";expires=" + expires.toGMTString() : "") + //expires.toGMTString()
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}

function deleteCookie( name, path, domain ) {
  if ( getCookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
