url = location.href;
if (url.indexOf("/wumbus.com") > -1) {
	location.href = url.replace("wumbus.com","www.wumbus.com");
}

var form = "";
var submitted = false;
var error = false;
var error_message = "";

function check_select(field_name, field_default, message) {
	if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
		var field_value = form.elements[field_name].value;
		if (field_value == field_default) { error_message = error_message + "* " + message + "\n"; error = true; }
	}
}

function refresh_form(form_name) {
   form_name.action.value = 'refresh';
   form_name.state.value = '';
   form_name.submit();
   return true;
}

function pageCartBox() {
	var val = '', ita = '', qta = '', s = '', ss = '', itmAr = null, qtyAr = null, tot = 0.0;
	var aC = document.cookie.split("; ");
	for (var i=0; i < aC.length; i++) { var aB = aC[i].split("="); if (aB[0] == 'ionCart') { val = aB[1]; } }
	if (val != null && val != '') {
		if (val.indexOf("|") >= 0) {
			var aR = val.split("|");
			for (var i=0; i < aR.length; i++) { var aa = aR[i].split("."); if (i > 0) { ita+='|'; qta+='|'; } ita+=aa[0]; qta+=aa[1]; }
			itmAr = ita.split("|"); qtyAr = qta.split("|");
		}
		if (val.indexOf("|") < 0 && val.indexOf(".") >= 0) { var aa = val.split("."); itmAr = [aa[0]]; qtyAr = [aa[1]]; }
		if (itmAr.length == 1) {
			s = "<b style='color:#225588'>There is (1) item in the cart<b>";
			ss = "1";
		} else {
			s = "<b style='color:#225588'>There are ("+itmAr.length+") items in the cart</b>";
			ss = itmAr.length;
		}
		document.getElementById('topItemCnt').innerHTML = ss;
		s += "<br />\n";
		if (itmAr.length > 0) {
			s+="<table border='0' cellspacing='0' cellpadding='0'><tr><td style='font:normal 4px arial; border-bottom:2px solid #336699;'>&nbsp;</td></tr>\n";
			for (var i=0; i < itmAr.length; i++) {
				s+="<tr><td WRAP class='ionPageCartItem' style='padding-top:3px; padding-bottom:3px;'> <b>&#183;</b> "+itemDesc[itmAr[i]][0]+"</td></tr>\n";
			}
			s+="</table>\n";
		}
		document.getElementById('box-shoppingcart').innerHTML = "<div class='cartempty'>"+s+"</div>";
	} else {
		document.getElementById('box-shoppingcart').innerHTML = "<div class='cartempty'>Your cart is empty</div>";
		document.getElementById('topItemCnt').innerHTML = "0";
	}
}

function movr0(x) { x.src='imagesx/playArrow.png'; }
function mout0(x) { x.src='imagesx/blank200.png'; }

function movr1(x) { x.style.color='#FFFF99'; }
function mout1(x) { x.style.color='#FFFFFF'; }

function addSelection(rid){
	var select = document.addForm.addSelect.value;
	if (select =="1"){go1DayPass(rid);}
	else if (select =="7"){go7DayPass(rid);}
	else if (select =="30"){go30DayPass(rid);}
	else if (select =="year"){goYearPass(rid);}
	else if (select =="life"){goUnlimited(rid);}
	else if (select =="buy"){addToCart(rid);}
	else if (select =="buysp"){addToCartSP(rid);}
	cartFlash();
}

function cartFlash(){
	showCart('on');
}

function addToCart(rid) {
	var val = '';
	var aC = document.cookie.split("; ");
	for (var i=0; i < aC.length; i++) { var aB = aC[i].split("="); if (aB[0] == 'ionCart') { val = aB[1]; } }
	if (val == null || val == '') { val = rid+'.1.DVD Shipped'; } else { val = val+'|'+rid+'.1.DVD Shipped'; }
	document.cookie = 'ionCart=' + val;
	pageCartBox();
	cartFlash();
}

function addToCartSP(rid) {
	var val = '';
	var aC = document.cookie.split("; ");
	for (var i=0; i < aC.length; i++) { var aB = aC[i].split("="); if (aB[0] == 'ionCart') { val = aB[1]; } }
	if (val == null || val == '') { val = rid+'.1.DVD-SP Shipped'; } else { val = val+'|'+rid+'.1.DVD-SP Shipped'; }
	document.cookie = 'ionCart=' + val;
	pageCartBox();
	cartFlash();
}

function go1DayPass(rid) {
	var val = '';
	var aC = document.cookie.split("; ");
	for (var i=0; i < aC.length; i++) { var aB = aC[i].split("="); if (aB[0] == 'ionCart') { val = aB[1]; } }
	if (val == null || val == '') { val = rid+'.1.1-Day Pass'; } else { val = val+'|'+rid+'.1.1-Day Pass'; }
	document.cookie = 'ionCart=' + val;
	pageCartBox();
	cartFlash();
}

function go7DayPass(rid) {
	var val = '';
	var aC = document.cookie.split("; ");
	for (var i=0; i < aC.length; i++) { var aB = aC[i].split("="); if (aB[0] == 'ionCart') { val = aB[1]; } }
	if (val == null || val == '') { val = rid+'.1.7-Day Pass'; } else { val = val+'|'+rid+'.1.7-Day Pass'; }
	document.cookie = 'ionCart=' + val;
	pageCartBox();
}

function go30DayPass(rid) {
	var val = '';
	var aC = document.cookie.split("; ");
	for (var i=0; i < aC.length; i++) { var aB = aC[i].split("="); if (aB[0] == 'ionCart') { val = aB[1]; } }
	if (val == null || val == '') { val = rid+'.1.30-Day Pass'; } else { val = val+'|'+rid+'.1.30-Day Pass'; }
	document.cookie = 'ionCart=' + val;
	pageCartBox();
}

function goYearPass(rid) {
	var val = '';
	var aC = document.cookie.split("; ");
	for (var i=0; i < aC.length; i++) { var aB = aC[i].split("="); if (aB[0] == 'ionCart') { val = aB[1]; } }
	if (val == null || val == '') { val = rid+'.1.Annual Pass'; } else { val = val+'|'+rid+'.1.Annual Pass'; }
	document.cookie = 'ionCart=' + val;
	pageCartBox();
	cartFlash();
}

function goUnlimited(rid) {
	var val = '';
	var aC = document.cookie.split("; ");
	for (var i=0; i < aC.length; i++) { var aB = aC[i].split("="); if (aB[0] == 'ionCart') { val = aB[1]; } }
	if (val == null || val == '') { val = rid+'.1.Lifetime Pass'; } else { val = val+'|'+rid+'.1.Lifetime Pass'; }
	document.cookie = 'ionCart=' + val;
	pageCartBox();
	cartFlash();
}

function gotoBookmarks() {
	var val = '';
	var aC = document.cookie.split("; ");
	for (var i=0; i < aC.length; i++) { var aB = aC[i].split("="); if (aB[0] == 'ionBookmarks') { val = aB[1]; } }
	if (val != "undefined" && val != "" && val != null) {
		top.document.bkmrkForm.op.value='bkmrk';
		top.document.bkmrkForm.bkmrks.value=val;
		top.document.bkmrkForm.submit();
	} else {
		alert("No Bookmarks.");
	}
}

function clear_textbox(fld) {
	if (fld == "search") { document.search.keywords.value = ""; }
	else { document.emailNotify.emailAddress.value = ""; }
}

function chkEml(fld){
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([\w-]+(?:\.[\w-]+)*)$/i
  if (fld.value == 'Enter Email Address' || fld.value == '' ) {
      alert('Please enter your e-mail address in the Box');
      fld.focus();
  }
  else if (filter.test(fld.value) == false)  {
      alert('Sorry, please enter a valid e-mail address, for example, johndoe@gmail.com');
      fld.focus();
  }
  else { document.emailNotify.submit(); }
}

function submitRating(prodid,rating) { alert("ProdID="+prodid+", Rating="+rating); }

function starMOvr(prodid,rating) {
	if (rating==1) {
		document.getElementById(prodid+"1").src="imagesx/starBlue.png";
	}
	if (rating==2) {
		document.getElementById(prodid+"1").src="imagesx/starBlue.png";
		document.getElementById(prodid+"2").src="imagesx/starBlue.png";
	}
	if (rating==3) {
		document.getElementById(prodid+"1").src="imagesx/starBlue.png";
		document.getElementById(prodid+"2").src="imagesx/starBlue.png";
		document.getElementById(prodid+"3").src="imagesx/starBlue.png";
	}
	if (rating==4) {
		document.getElementById(prodid+"1").src="imagesx/starBlue.png";
		document.getElementById(prodid+"2").src="imagesx/starBlue.png";
		document.getElementById(prodid+"3").src="imagesx/starBlue.png";
		document.getElementById(prodid+"4").src="imagesx/starBlue.png";
	}
	if (rating==5) {
		document.getElementById(prodid+"1").src="imagesx/starBlue.png";
		document.getElementById(prodid+"2").src="imagesx/starBlue.png";
		document.getElementById(prodid+"3").src="imagesx/starBlue.png";
		document.getElementById(prodid+"4").src="imagesx/starBlue.png";
		document.getElementById(prodid+"5").src="imagesx/starBlue.png";
	}
}
function starMOut(prodid,rating) {
	document.getElementById(prodid+"1").src="imagesx/starGray.png";
	document.getElementById(prodid+"2").src="imagesx/starGray.png";
	document.getElementById(prodid+"3").src="imagesx/starGray.png";
	document.getElementById(prodid+"4").src="imagesx/starGray.png";
	document.getElementById(prodid+"5").src="imagesx/starGray.png";
}


function clear_textbox(fld) {
	if (fld == "searchWrapper") { document.searchWrapper.keywords.value = ""; }
	else { document.signUpForm.emailAddress.value = ""; }
}

function chkEml(fld){
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([\w-]+(?:\.[\w-]+)*)$/i
  if (fld.value == 'Enter Email Address' || fld.value == '' ) {
      alert('Please enter your e-mail address in the Box');
      fld.focus();
  }
  else if (filter.test(fld.value) == false)  {
      alert('Sorry, please enter a valid e-mail address, for example, johndoe@gmail.com');
      fld.focus();
  }
  else { document.signUpForm.submit(); }
}

function showCart(action){
	if (action=="on"){
		parent.document.getElementById("cartDiv").style.visibility = "visible";
	} else {
		parent.document.getElementById("cartDiv").style.visibility = "hidden";
	}
}
