// Global variables
var logURL="http://www.etherica.net/cgi-bin/loadimage.pl";
// Sample websites
var sampleAuto1 = "auto1/index.html";
var sampleAuto2 = "auto2/index.html";
var sampleLingerie = "notyetimplemented.html";
// Company variables

// Ad banner variables
var hRef= new Array();
var iMage=new Array();
var aLt=  new Array();
var tItle=new Array();

var i=0;

function testAlert(message) {
  alert(message);
}

function displayNewWindow(theWebSite) {
  win = window.open(theWebSite,"website","toolbar,menubar,scrollbars,resizable,status,location,copyhistory,directories,width=700,height=500");
  return win;
}

function showPopup(url) {
  newwindow = window.open(url,'name','height=190,width=520,top=200,left=300,resizable');
  
  if (window.focus) {newwindow.focus()}
}

// Display sample web sites
function displaySample(theWebsite) {
  var winDow = window.open(theWebsite,'samplewebsite','toolbar,status,menubar,resizable,scrollbars, height=600,width=800');
}

// For dynamic button depressons.
function changePic (oldName, newName) {
  if (document.images) {
    newSource = eval (newName + ".src");
    document [oldName].src = newSource;
  }
  if (changePic.arguments.length == 2) {
    self.status = changePic.arguments[2];
    return true;
  }
  return false;
}

// Display update date
function displayUpdate() {
  document.write('<span class="comment"><b>Updated:</b> '+document.lastModified+'</span>');
}

// Log visit - don't include any personal information
function logVisit() {
  document.write('<img src="'+logURL+'" width="1" height="1">');
}

// Cookie functions
//   cookiesEnabled()           See if cookies are enabled
//   getCookie(name)
//   deleteCookie(name)
//   setCookie(name,value,days)
function cookiesEnabled() {
  var cookieName =  "cookiesenabled";
	var cookieValue = 1;
	var cookieDays =  1;
	// Make sure there is no previous version
	deleteCookie(cookieName);
	// Try to set the cookie
  setCookie(cookieName,cookieValue,cookieDays);
	// See if the cookie got created
	if (getCookie(cookieName) == cookieValue) {
	  // document.write("Cookies enabled<br>");
		deleteCookie(cookieName);
		return 1;
	} else {
	  // document.write("Cookies NOT enabled<br>");
		return 0;
	}
}

function getCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i<ca.length;i++) {
    var c = ca[i];
    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 deleteCookie(name) {
  // Constant for 3 days (3*24*60*60*1000 = 259200000) is faster
  // document.write("Deleting cookie: ",name,"<br>");
  // document.write("Cookie Before:   ",document.cookie,"<br>");
  var today=new Date();
  var expired=new Date(today.getTime()-259200000);
  // document.write("Expired: ",expired,"<br>");
  document.cookie=name+"=null; expires="+expired.toGMTString()+"; path=/";
  // document.write("Cookie After:    ",document.cookie,"<br>");
}

// Copyright (C) 1999 Dan Steinman
// Distributed under the terms of the GNU Library General Public License
// Available at http://www.dansteinman.com/dynapi/
// thanks to: Jesee Chisholm <JCHISHOLM@SENSORMATIC-VPD.com>
function setCookie(name,value,days) {
   document.write("Cookie before: ",document.cookie,"<br>");
  if (days) {
    var date = new Date();
	  date.setTime(date.getTime()+(days*24*60*60*1000));
	  var expires = "; expires="+date.toGMTString();
  } else {
	  expires = "";
	}
  document.cookie = name+"="+value+expires+"; path=/";
   document.write("Cookie after: ",document.cookie,"<br>");
}
