function enterEmail() {
	if (document.forms[0].Email.value == 'E-mail Address') {
		document.forms[0].Email.value = '';
	}
}

function loadMenu() {
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	if (winW < 821) {
		winW = 821;
	}
	document.getElementById('id_menu').style.left = winW/2+15;
}

function showMenu() {
	document.getElementById('id_menu').style.visibility="visible";
}
function hideMenu() {
	document.getElementById('id_menu').style.visibility="hidden";
}

function save_cart(str) {
	if (str == 1) {
		document.getElementById('div_cartUtil').className = 'hideGrp';
		document.getElementById('div_loadCart').className = 'hideGrp';
		document.getElementById('div_saveCart').className = 'showGrp';
	}
	else if (str == 2) {
		document.getElementById('div_cartUtil').className = 'hideGrp';
		document.getElementById('div_loadCart').className = 'showGrp';
		document.getElementById('div_saveCart').className = 'hideGrp';
	}
	else {
		document.getElementById('div_cartUtil').className = 'showGrp';
		document.getElementById('div_loadCart').className = 'hideGrp';
		document.getElementById('div_saveCart').className = 'hideGrp';
	}
}
function paymentType(str) {
	if (str == 1) {
		document.getElementById('div_paymentType_1').className = 'showGrp';
		document.getElementById('div_paymentType_2').className = 'hideGrp';
	}
	else {
		document.getElementById('div_paymentType_1').className = 'hideGrp';
		document.getElementById('div_paymentType_2').className = 'showGrp';	
	}
}

function acc_view(str) {
	if (str == 0) {
	document.getElementById('div_acc_0').className = 'showGrp';
	document.getElementById('div_acc_1').className = 'hideGrp';
	document.getElementById('div_acc_2').className = 'hideGrp';
	document.getElementById('div_acc_3').className = 'hideGrp';

	document.getElementById('div_acc_tbl_0').className = 'showGrp';
	document.getElementById('div_acc_tbl_1').className = 'hideGrp';
	document.getElementById('div_acc_tbl_2').className = 'hideGrp';
	document.getElementById('div_acc_tbl_3').className = 'hideGrp';
	}
	else if (str == 1) {
	document.getElementById('div_acc_0').className = 'hideGrp';
	document.getElementById('div_acc_1').className = 'showGrp';
	document.getElementById('div_acc_2').className = 'hideGrp';
	document.getElementById('div_acc_3').className = 'hideGrp';
	document.getElementById('div_acc_tbl_0').className = 'hideGrp';
	document.getElementById('div_acc_tbl_1').className = 'showGrp';
	document.getElementById('div_acc_tbl_2').className = 'hideGrp';
	document.getElementById('div_acc_tbl_3').className = 'hideGrp';
	}
	else if (str == 2) {
	document.getElementById('div_acc_0').className = 'hideGrp';
	document.getElementById('div_acc_1').className = 'hideGrp';
	document.getElementById('div_acc_2').className = 'showGrp';
	document.getElementById('div_acc_3').className = 'hideGrp';
	document.getElementById('div_acc_tbl_0').className = 'hideGrp';
	document.getElementById('div_acc_tbl_1').className = 'hideGrp';
	document.getElementById('div_acc_tbl_2').className = 'showGrp';
	document.getElementById('div_acc_tbl_3').className = 'hideGrp';
	}
	else if (str == 3) {
	document.getElementById('div_acc_0').className = 'hideGrp';
	document.getElementById('div_acc_1').className = 'hideGrp';
	document.getElementById('div_acc_2').className = 'hideGrp';
	document.getElementById('div_acc_3').className = 'showGrp';
	document.getElementById('div_acc_tbl_0').className = 'hideGrp';
	document.getElementById('div_acc_tbl_1').className = 'hideGrp';
	document.getElementById('div_acc_tbl_2').className = 'hideGrp';
	document.getElementById('div_acc_tbl_3').className = 'showGrp';
	}
}

function repeat (str) { //v2.0
	warnAction('Are you sure you want to place repeat order?\nAll items in your cart will be replaced.','/repeat.asp?ordernumber=' + str);
}

function sg() { //v2.0
  window.open('/secure/sg.asp','sg','width=400,height=300,scrollbars=no,menubar=no');
}

function cal() { //v2.0
  window.open('/pricecalculator.asp ','cal','width=300,height=600,scrollbars=no,menubar=no');
}
function upc() { //v2.0
  window.open('/upcoming.asp ','upc','width=260,height=520,scrollbars=no,menubar=no');
}

function ccid() { //v2.0
  window.open('/ccid.asp','ccid','width=600,height=340,scrollbars=yes,menubar=no');
}

function goTo(pagename) {
	if (pagename.options[pagename.selectedIndex].value != 'null') {
		location.href=pagename.options[pagename.selectedIndex].value;
	}
	else {
		alert('Please make a selection ...');
	}
	return true;
}

function goToForm(pagename) {
	if (pagename.options[pagename.selectedIndex].value != 'null') {
		crossreference.action=pagename.options[pagename.selectedIndex].value;
		crossreference.submit();
	}
	else {
		alert('Please make a selection ...');
	}
	return true;
}

function sendpass() { //v2.0
  window.open('/sendpass.asp','sendpass','width=400,height=150,scrollbars=no,menubar=no');
}

function warnAction(q,p) { //df
	if (confirm(q)) {
		location.href = p;
	}
}
function updateTotal (obj, amount) {
	var newtotal;
	newtotal = 1*obj.txtSubtotal.value + 1*amount;
	newtotal = newtotal.toFixed(2);
	
	var s_newtotal = "";
	j = newtotal.length;
	for	(var i=0; i < j; i++) {
		if ((j-i == 6 && i != 0) || (j-i == 9 && i != 0))
			s_newtotal += ',';
		s_newtotal += newtotal.charAt(i);
	}
	document.getElementById('div_total').innerHTML = '$' + s_newtotal;
	//obj.txtTotal.value = '$' + s_newtotal;
}

function completeShipping(obj) {
  if (obj.billandship.checked) {
		Firstname = obj.Firstname.value;
		MiddleInitial = obj.MiddleInitial.value;
		Lastname = obj.Lastname.value;
		Company = obj.Company.value;
		Address = obj.Address.value;
		Suite = obj.Suite.value;
		City = obj.City.value;
		State = obj.State.value;
		Zip = obj.Zip.value;
		Phone = obj.Phone.value; 
	
		obj.Firstname.value = obj.ShipFirstname.value;
		obj.MiddleInitial.value = obj.ShipMiddleInitial.value;
		obj.Lastname.value = obj.ShipLastname.value;
		obj.Company.value = obj.ShipCompany.value;
		obj.Address.value = obj.ShipAddress.value;
		obj.Suite.value = obj.ShipSuite.value;
		obj.City.value = obj.ShipCity.value;
		obj.State.value = obj.ShipState.value;
		obj.Zip.value = obj.ShipZip.value;
		obj.Phone.value = obj.ShipPhone.value;
	}
	else {
		obj.Firstname.value = Firstname;
		obj.MiddleInitial.value = MiddleInitial;
		obj.Lastname.value = Lastname;
		obj.Company.value = Company;
		obj.Address.value = Address;
		obj.Suite.value = Suite;
		obj.City.value = City;
		obj.State.value = State;
		obj.Zip.value = Zip;
		obj.Phone.value  = Phone;
	}
  return true;
}

function checkRef() {
	var i = document.checkout3.CheckoutRefererID.selectedIndex;
	var j = document.checkout3.CheckoutRefererID.length;
	i = i + 1;
	if (i == j) {
		document.getElementById('div_referer').className = 'showGrp';
	}
	else {
		document.getElementById('div_referer').className = 'hideGrp';				
	}
}


function EL(id) {
    return document.getElementById(id);
}

var http_request = false;
var responseData = '';
/*get functions */

function updateSize() {
	http_request = false;
	var id = EL('pc_BagStyleID').value;

  try {    // Firefox, Opera 8.0+, Safari
		http_request=new XMLHttpRequest();
	}
  catch (e) {    // Internet Explorer
		try {
			http_request=new ActiveXObject("Msxml2.XMLHTTP");
		}
    catch (e) {
			try {
				http_request=new ActiveXObject("Microsoft.XMLHTTP");
			}
      catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
  http_request.onreadystatechange=function() {
  	if (http_request.readyState==4) {
			responseData = http_request.responseText;
			//alert(responseData);

			//EL('div_BagStyleID').className = 'd_form';
			//EL('div_TemplateID').className = 'd_sel';
			//EL('id_TemplateID').disabled = false;
			//EL('id_BagColorID').disabled = false;
			//if (EL('id_BagStyleID').selectedIndex == 1 || EL('id_BagStyleID').selectedIndex == 6) {
			//	EL('id_HandleColorID').selectedIndex = 0;
			//	EL('id_HandleColorID').disabled = false;
			//}
			//else {
			//	EL('id_HandleColorID').disabled = true;
			//}

			var arrData = responseData.split('//');
			var arr;
			EL('pc_BagSizeID').length = 0;
			EL('pc_BagSizeID').options[0] = new Option('- select -');
			for (var i = 0; i < arrData.length; i++) {
				arr = arrData[i].split(',');
				EL('pc_BagSizeID').options[i+1] = new Option(arr[1],arr[0]);
			}
		}
	}
  http_request.open("GET","/pc_update.asp?BagStyleID=" + id, true);
 	http_request.send(null);
}

function getPrices() {
	http_request = false;
	var id = EL('pc_BagSizeID').value;
	var NumColors = EL('pc_NumColors').value;
	var NumSides = EL('pc_NumSides').value;

  try {    // Firefox, Opera 8.0+, Safari
		http_request=new XMLHttpRequest();
	}
  catch (e) {    // Internet Explorer
		try {
			http_request=new ActiveXObject("Msxml2.XMLHTTP");
		}
    catch (e) {
			try {
				http_request=new ActiveXObject("Microsoft.XMLHTTP");
			}
      catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
if (NumSides == "2" && NumColors == "4") {
	alert("Please contact us for speacial order if you want more than 4 colors and print on 2 sides!")
	form.pc_NumSides.focus()
	return false;
}
  http_request.onreadystatechange=function() {
  	if (http_request.readyState==4) {
			responseData = http_request.responseText;
			//alert(responseData);

			//EL('div_BagStyleID').className = 'd_form';
			//EL('div_TemplateID').className = 'd_sel';
			//EL('id_TemplateID').disabled = false;
			//EL('id_BagColorID').disabled = false;
			//if (EL('id_BagStyleID').selectedIndex == 1 || EL('id_BagStyleID').selectedIndex == 6) {
			//	EL('id_HandleColorID').selectedIndex = 0;
			//	EL('id_HandleColorID').disabled = false;
			//}
			//else {
			//	EL('id_HandleColorID').disabled = true;
			//}

			var arrData = responseData.split(',');
			var arr;
			//EL('pc_BagSizeID').length = 0;
			//EL('pc_BagSizeID').options[0] = new Option('- select -');
			for (var i = 0; i < arrData.length; i++) {
				EL('pc_Price_' + i).innerHTML = arrData[i];
			}
		}
	}
	//alert("/pc_update.asp?BagID=" + id + "&NumSides=" + NumSides + "&NumColors=" + NumColors);
  http_request.open("GET","/pc_update.asp?BagID=" + id + "&NumSides=" + NumSides + "&NumColors=" + NumColors, true);
 	http_request.send(null);
}

function placeOrder() {
	var id = EL('pc_BagStyleID').value;
	if (id == '2') {
		id = '3';
	}
	else if (id == '3') {
		id = '2';
	}
	location.href = '/rbc_customize.asp?style=' + id;
}

function showSurveyOptions( str, id, num ) {
	for ( var i = 0; i <= num; i ++ ) {
		if (id == i) {
			EL(str + '' + i).className = 'showGrp';
		}
		else {
			EL(str + '' + i).className = 'hideGrp';
		}
	}
}