//------------------------------------------------------
function get_element(id) {
  if (document.all) {                   return document.all[id]; }
  else if (document.layers) {           return document.layers[id]; }
  else if (document.getElementById) {   return document.getElementById(id); }
  else {                                return document.coupon.id; }
  }

//------------------------------------------------------
var change = 1;
var delay = 5;
var counter = 0;
var next_id = -1;
var curr_id = 0;
var pic_id = 0;
var holding = 0;

function rotate() {
	counter += 0.5;  
	if ((change == 1) && ((counter % delay) == 0)) {
    if ((next_id >= 0) && (next_id <= 6)) {
      curr_id = pic_id;
      pic_id = next_id;
      change = 0;
      }
    else {
      pic_id++;
      }
		cpce_set(pic_id);
		if (pic_id == 6) {
      pic_id = -1;
      }
		}
	r = setTimeout("rotate()", 500);
	}

function set_next(id) {
  if (id == pic_id) {
    hold();
    return false;
    }
  else if (id == (pic_id + 1)) {
    pic_id++;
    }
  next_id = id;               //-- set the next pic to display
  delay = 0.5;                //-- set it to display in 0.5 seconds
  //eval('outer_' + id + '.style.cursor = "hand";');
  }

function hold() {
  change = 0;
  holding = 1;
  //cpce_trans_con.style.cursor = "hand";
  }

function reset() {
  change = 1;                 //-- set the rotation to change
  counter = 0;                //-- reset the counter to 0
  delay = 5;                  //-- set pic to change in 5 seconds
  if (holding == 0) {
    next_id = -1;             //-- ensure the next_id loop is skipped
    pic_id = curr_id;         //-- set the pic to the last pic shown
    }
  holding = 0;
  }
//------------------------------------------------------
function cpce_set(id) {
  cpce_trans_con.filters[0].Apply();

  cpce_0.style.visibility = "hidden";
  cpce_1.style.visibility = "hidden";
  cpce_2.style.visibility = "hidden";
  cpce_3.style.visibility = "hidden";
  cpce_4.style.visibility = "hidden";
  cpce_5.style.visibility = "hidden";
  cpce_6.style.visibility = "hidden";

  switch (id) {
    case 0:  cpce_0.style.visibility = "visible";  break;
    case 1:  cpce_1.style.visibility = "visible";  break;
    case 2:  cpce_2.style.visibility = "visible";  break;
    case 3:  cpce_3.style.visibility = "visible";  break;
    case 4:  cpce_4.style.visibility = "visible";  break;
    case 5:  cpce_5.style.visibility = "visible";  break;
    case 6:  cpce_6.style.visibility = "visible";  break;
    default: cpce_0.style.visibility = "visible";  break;
    }

  cpce_trans_con.filters[0].Play();
  }

//-- Main Routine --------------------------------------
if (window.attachEvent) {
  window.attachEvent("onload", rotate);
  }
else if (window.addEventListener) {
  window.addEventListener("load", rotate, false);
  }
else {
  window.onload = rotate;
  }

//------------------------------------------------------
function get_element(id) {
  if (document.all) {                   return document.all[id]; }
  else if (document.layers) {           return document.layers[id]; }
  else if (document.getElementById) {   return document.getElementById(id); }
  else {                                return document.coupon.id; }
  }

//------------------------------------------------------
function icon_results_over(icon) {
	icon.style.cursor = "pointer";
	}

function icon_results_out(icon) {
	icon.style.cursor = "auto";
	}
	
function icon_results_click(event_id) {
	var results_row = get_element(event_id + 'R');
	if (results_row.style.display == "none") {
		results_row.style.display = "";
		}
	else {
		results_row.style.display = "none";
		}
	}

function over(id) {
	var cell_a = get_element(id + 'A');
	var cell_b = get_element(id + 'B');
	var cell_c = get_element(id + 'C');
	var cell_d = get_element(id + 'D');
	var cell_e = get_element(id + 'E');
	var cell_f = get_element(id + 'F');
	var cell_g = get_element(id + 'G');
	var cell_h = get_element(id + 'H');

	if ((cell_a.getAttribute("class") != "next") && (cell_a.getAttribute("className") != "next")) {
		if (cell_a != undefined) {
			cell_a.setAttribute("class", "over");
			cell_a.setAttribute("className", "over");
			}
		if (cell_b != undefined) {
			cell_b.setAttribute("class", "over");
			cell_b.setAttribute("className", "over");
			}
		if (cell_c != undefined) {
			cell_c.setAttribute("class", "over");
			cell_c.setAttribute("className", "over");
			}
		if (cell_d != undefined) {
			cell_d.setAttribute("class", "over");
			cell_d.setAttribute("className", "over");
			}
		if (cell_e != undefined) {
			cell_e.setAttribute("class", "over");
			cell_e.setAttribute("className", "over");
			}
		if (cell_f != undefined) {
			cell_f.setAttribute("class", "over");
			cell_f.setAttribute("className", "over");
			}
		if (cell_g != undefined) {
			cell_g.setAttribute("class", "over");
			cell_g.setAttribute("className", "over");
			}
		if (cell_h != undefined) {
			cell_h.setAttribute("class", "over");
			cell_h.setAttribute("className", "over");
			}
		}
	}

function out(id) {
	var cell_a = get_element(id + 'A');
	var cell_b = get_element(id + 'B');
	var cell_c = get_element(id + 'C');
	var cell_d = get_element(id + 'D');
	var cell_e = get_element(id + 'E');
	var cell_f = get_element(id + 'F');
	var cell_g = get_element(id + 'G');
	var cell_h = get_element(id + 'H');

	if ((cell_a.getAttribute("class") != "next") && (cell_a.getAttribute("className") != "next")) {
		if (cell_a != undefined) {
			cell_a.setAttribute("class", "");
			cell_a.setAttribute("className", "");
			}
		if (cell_b != undefined) {
			cell_b.setAttribute("class", "");
			cell_b.setAttribute("className", "");
			}
		if (cell_c != undefined) {
			cell_c.setAttribute("class", "");
			cell_c.setAttribute("className", "");
			}
		if (cell_d != undefined) {
			cell_d.setAttribute("class", "");
			cell_d.setAttribute("className", "");
			}
		if (cell_e != undefined) {
			cell_e.setAttribute("class", "");
			cell_e.setAttribute("className", "");
			}
		if (cell_f != undefined) {
			cell_f.setAttribute("class", "");
			cell_f.setAttribute("className", "");
			}
		if (cell_g != undefined) {
			cell_g.setAttribute("class", "");
			cell_g.setAttribute("className", "");
			}
		if (cell_h != undefined) {
			cell_h.setAttribute("class", "");
			cell_h.setAttribute("className", "");
			}
		}
	}
