function geniuscart_checkops() {
	return check_ops();
}


function check_ops() {

	// See if any options are not chosen tha start with choose
	rv = true;
	dbg = "";
	var upsells_chosen = 0;
	var res = document.getElementById("upsell_restrictions");

	for (i = 0; i < document.geniuscart_addform.elements.length; i++) {

		e = document.geniuscart_addform.elements[i];

		if (e.name.match(/^special/) && e.value.toUpperCase().match(/^CHOOSE/)) {
			rv = false;
			alert("Please first select an option for '" + e.value
					+ "' to add this item to your cart.");
		}

		// Add checks to permit only one UPSELL per product
		if (res && e.name.match(/^upsell\[\d+\]\[Quantity\]/) && e.value > 0
				&& res.value.indexOf(e.name) >= 0 && upsells_chosen++ > 0) {
			rv = false;
			alert("Sorry, we only permit one add-on from the product group specified since our tags will only have room for one feature on the back. ");
		}

	}

	return rv;
}


// This controls the css menu for non css2 compliant browsers like ie5/6

function doMenuFallback() {
	if (navigator.appVersion.indexOf("MSIE") == -1) {
		return;
	}
	var i, k, g, lg, r = /\s*hvr/, nn = '', c, cs = 'hvr', bv = 'mb';
	for (i = 0; i < 10; i++) {
		try {
			g = document.getElementById(bv + nn);
			if (g) {
				lg = g.getElementsByTagName("LI");
				if (lg) {
					for (k = 0; k < lg.length; k++) {
						lg[k].onmouseover = function() {
							c = this.className;
							cl = (c) ? c + ' ' + cs : cs;
							this.className = cl;
						};
						lg[k].onmouseout = function() {
							c = this.className;
							this.className = (c) ? c.replace(r, '') : '';
						};
					}
				}
			}
		} catch (e) {
		}
		nn = i + 1;
	}
}


function loadahah(url,target){
	  document.getElementById(target).innerHTML = ' Fetching data...';
	  if (window.XMLHttpRequest) {
	    req = new XMLHttpRequest();
	  } else if (window.ActiveXObject) {
	    req = new ActiveXObject("Microsoft.XMLHTTP");
	  }
	  if (req != undefined) {
	    req.onreadystatechange = function() {
	    	if (req.status == 200)
	    		document.getElementById(target).innerHTML = req.responseText;
	    };
	    req.open("GET", url, true);
	    req.send("");
	  }
}

loadahah('/promo.txt','onsale');


var has_loaded = 0;
go_URL = new Array();
imgID = new Array();
// *****************  CONFIGURE THINGS HERE ***************** //

var pause = 5000

// Add new elements here, indexed as in the examples:
if (document.images) {

	imgID[0] = "images/frontpage/rotating/rt_combo.png"
	go_URL[0] = "/product.gc?ID=220";

	imgID[1] = "images/frontpage/rotating/rt_reflective_collars.png"
	go_URL[1] = "/product.gc?ID=178";

	imgID[2] = "images/frontpage/rotating/rt_rivet_collars.png"
	go_URL[2] = "/pet_tags_by_id/54";

	imgID[3] = "images/frontpage/rotating/rt_plate_frames.png"
	go_URL[3] = "/pet_tags_by_id/204";
	
	has_loaded = 1;
}

//*****************  END CONFIGURE THINGS HERE ***************** //

var a = 0;
var b = (go_URL.length - 1);
var to=false;

function rotate(imgN) {

	if (has_loaded == 1) {

		if (a == b) {
			a = 0;
		} else {
			a++;
		}

		el = document.getElementById(imgN);
		el.src = imgID[a];
		to=setTimeout('rotate("rotational")', pause);
		

	} // end of if has_loaded

} // end of function rotate

function goto_url() {
	clearTimeout(to);
	document.location = (go_URL[a]);
	return false;
}

if(document.getElementById('rotational'))
	rotate('rotational');



// Analytics code
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-12957191-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();


