/*
   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
*/

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}


function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

/* This is where you must define the images you want to use later.
   Put the document.write line where you want it in the document */

images = new Array(3);
images[0] = "<img src='Images/ropescourse.gif' alt='Austin Sunshine Camps 2' width='575' height='250' border='0'>";
images[1] = "<img src='Images/main_group.gif' alt='Austin Sunshine Camps 3' width='575' height='250' border='0'>";
images[2] = "<img src='Images/main_canoe.gif' alt='Austin Sunshine Camps 4' width='575' height='250' border='0'>";
images[3] = "<img src='Images/main_line.gif'alt='Austin Sunshine Camps 5' width='575' height='250' border='0'>";
/*
use this to display the rotating image from the list above.
you can add images to the list above without having to change the code.
document.write("<DT>" + "" + images[ascimage] + "\n");
*/



/* Start code to rotate images.
 */

// create an instance of the Date object
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);

/*Start cookie 1*/
var ascimage = getCookie("ascimage");
// if the cookie wasn't found, this is your first visit
if (!ascimage) {
  ascimage = 0; // the value for the new cookie
} else {
  // increment the counter
  ascimage = parseInt(ascimage) + 1;
  if(ascimage == images.length) {
    ascimage = 0;
  }
}
// set the new cookie
setCookie("ascimage", ascimage, now);
/* End cookie 1 */

/* Start cookie 2 */
var ascimage2 = getCookie("ascimage2");
// if the cookie wasn't found, this is your first visit
if (!ascimage2) {
  ascimage2 = 0; // the value for the new cookie
} else {
  // increment the counter
  ascimage2 = parseInt(ascimage2) + 1;
  if(ascimage2 == 1) {
    ascimage2 =0;
  }
}
setCookie("ascimage2", ascimage2, now);
/* end cookie 2

/* Start cookie 3 */
var ascimage3 = getCookie("ascimage3");
// if the cookie wasn't found, this is your first visit
if (!ascimage3) {
  ascimage3 = 0; // the value for the new cookie
} else {
  // increment the counter
  ascimage3 = parseInt(ascimage3) + 1;
  if(ascimage3 == 1) {
    ascimage3 =0;
  }
}
setCookie("ascimage3", ascimage3, now);
/* end cookie 3
You can cut and paste the cookie 2 code for as many images as you need. */

