<!--
/*
#################################################
# Copyright (c) 2004 - Symbolic Productions
# Author: Woody Phillips - woody@SymbolicProductions.com
#################################################
*/

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
// An adaptation of Dorcht's function for setting a cookie.

function setCookie(name, value, expires, path, domain, secure) {

//alert(name+' , '+value+' , '+expires);

  document.cookie = name + "=" + escape(value) +
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
 
//alert(getCookie(name));
}


// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
// Heinle's function for retrieving a cookie.

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


// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds

// An adaptation of Dorcht's function for deleting a cookie.

function deleteCookie (name,path,domain) {

  path = '/';
  //  domain = 'www.StarwoodHawaii.com';

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

  }
}

//set expiration date 1 Hour ahead
var expires = new Date();
expires.setTime(expires.getTime() + (60 * 60 * 1000));

function CheckCookie(myName) {

var clicks = '2';

var count  = getCookie(myName);
var popped = getCookie('SHpopped');

//alert('Popped value='+popped);
//alert('Count value='+count);

if (popped != null)
	{
	return;
	} else {
	if (count != clicks)
		{
		if (count == null)
			{
			count = 1;
			setCookie(myName, count, expires, '/');
			} else {
			count++;
			setCookie(myName, count, expires, '/');
			}
		} else {
		if (count == clicks)
			{
			//set expiration date 180 days ahead
			expires.setTime(expires.getTime() + (180 * 24 * 60 * 60 * 1000));
			count++;
			setCookie(myName, count, expires, '/');
			setCookie('SHpopped', '1', expires, '/');
newWin=window.open("http://www.InteractiveMarketingSystem.com/ecm/StarwoodHawaii/form.html","form_window","resizable=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,copyhistory=0,width=580,height=470,top=5,left=50");
newWin.focus();
			}
		}
	}
}

// after loading above code, run it once. (Simulates "onLoad" condition).

CheckCookie('SHcounter');

// -->




