function validateOrderTotal() {
		reallyValidateOrderTotal();
	}
	function reallyValidateOrderTotal()
	{
		val = $('#discount').val();
		if (isNaN(val)) {
			window.alert('You did not enter a numeric value. Please enter a number.');
		} else if (val >= 100) {
			window.alert('Value must be less than 100.');
			return false;
		} else {
			tempPrice = $('#totalPrice').val();
			tax = $('#tax').val();
			shipping = $('#shipping').val();
			tempVal = parseFloat(tempPrice) + parseFloat(tax) + parseFloat(shipping);
			tempValSub = parseFloat(tempPrice) + parseFloat(tax) + parseFloat(shipping);
			tempVal2 = tempValSub * (val / 100);
			tempVal = tempVal - tempVal2;
			//tempVal = tempVal * 100;
			//tempVal = Math.round(tempVal);
			//tempVal = tempVal / 100;
			//if (tempVal.toString().length - tempVal.toString().lastIndexOf(".") == 2) {
				tempVal = tempVal.toFixed(2);
			}
			$('orderTotal').val(tempVal);
			//$('totalPrice').val(tempVal);
	}
	
	function gotoCheckOut()
	{
		var getThis = $('#shipping').val();
		var discount = $('#discount').val();
		window.location = '/orderform.asp?action=checkout&phish=' + parseFloat(getThis) + '&discount=' + parseFloat(discount);
	}

	function loadProductAttributes(productID,asis) {
		if (productID != "")
			$('#productAttributes').load('admin/attributes.asp?action=loadProductAttributes&id=' + productID + '&asis=' + asis, function () {
				//swapRows();
			});
		else
			$('#productAttributes').remove();
		$('#attributeRow').append('<div id=\'productAttributes\'></div>');
		incrimenter = 0;
	}

	function swapRows() {
		first = $('.first').last();
		//alert(first.html());
		last = $('.manComments');
		first.after(last.html());
		last.remove();

		embellish = $('.embellish');
		embroidered = $('.embroidered');

		if (embellish != null && embroidered != null) {
			embellish.after(embroidered.html());
			embroidered.remove();
		}
		else if(embroidered != null){ 
			last = $('.manComments');
			last.after(embroidered.html());
			embroidered.remove();
		}
	}

	function limitText(limitField, limitNum) {
		if (limitField.value.length > limitNum) {
			limitField.value = limitField.value.substring(0, limitNum);
		}
	}

	function toggleAsIs() {
		var htemel = $('#productDropDown').html();
		if ($('#asIs').is(':checked')) {
			$('#productDropDown').load('admin/attributes.asp?action=loadproducts&asis=true');
		}
		else {
			$('#productDropDown').load('admin/attributes.asp?action=loadproducts');

		}
		$('#attributeRow').html('<div id=\'productAttributes\'></div>');
		incrimenter = 0;
	}
	var incrimenter = 0;
	
	

	function getBasePrice() {
		if($('#basePrice').val() == null)
			BasePrice = $('#price').val();
		else
			BasePrice = $('#basePrice').val();
	}
	function changePrice() {
		if (incrimenter == 0) {
			getBasePrice();
		}
		incrimenter++;
		var a = $('#button :selected').text();
		var b = $('#embellish :selected').text();
		var c = $('#embroidered :selected').text();
		var d = $('#fabric :selected').text();
		var e = $('#monogram :selected').text();
		var f = $('#ribbon :selected').text();
		var g = $('#itemSize :selected').text();
		var h = $('#itemTrim :selected').text();
		var i = $('#monogram_placement :selected').text();
		if (a.indexOf('$') > -1) {
			a = a.substring(a.indexOf('$') + 1).valueOf();
		}
		else{
			a = 0;
		}
		if (b.indexOf('$') > -1) {
		b = b.substring(b.indexOf('$') + 1).valueOf();
		}
		else{
			b = 0;
		}
		if (c.indexOf('$') > -1) {
		c = c.substring(c.indexOf('$') + 1).valueOf();
		}
		else{
			c = 0;
		}
		if (d.indexOf('$') > -1) {
		d = d.substring(d.indexOf('$') + 1).valueOf();
		}
		else{
			d = 0;
		}
		if (e.indexOf('$') > -1) {
		e = e.substring(e.indexOf('$') + 1).valueOf();
		}
		else{
			e = 0;
		}
		if (f.indexOf('$') > -1) {
		f = f.substring(f.indexOf('$') + 1).valueOf();
		}
		else{
			f = 0;
		}
		if (g.indexOf('$') > -1) {
		g = g.substring(g.indexOf('$') + 1).valueOf();
		}
		else{
			g = 0;
		}
		if (h.indexOf('$') > -1) {
		h = h.substring(h.indexOf('$') + 1).valueOf();
		}
		else {
			h = 0;
		}
		if (i.indexOf('$') > -1) {
		i = i.substring(i.indexOf('$') + 1).valueOf();
		}
		else {
			i = 0;
		}
		
		var bPrice = BasePrice;
		bPrice = bPrice.substring(bPrice.indexOf('$') + 1).valueOf();
		var grandTotal = parseFloat(a) + parseFloat(b) + parseFloat(c) + parseFloat(d) + parseFloat(e) + parseFloat(f) + parseFloat(g) + parseFloat(h) + parseFloat(i) + parseFloat(bPrice);
		$('#price').val("$" + CurrencyFormatted(grandTotal));
		$('#priceNew').val("$" + CurrencyFormatted(grandTotal));
	}

	function changePrice2() {
		
		getBasePrice();
		var a = $('#button :selected').text();
		var ab = $('#buttons :selected').text();
		var b = $('#embellish :selected').text();
		var c = $('#embroidered :selected').text();
		var d = $('#fabric :selected').text();
		var e = $('#monogram :selected').text();
		var f = $('#ribbon :selected').text();
		var g = $('#itemSize :selected').text();
		var h = $('#itemTrim :selected').text();
		if (a.indexOf('$') > -1) {
			a = a.substring(a.indexOf('$') + 1).valueOf();
		}
		else {
			a = 0;
		}
		if (b.indexOf('$') > -1) {
			b = b.substring(b.indexOf('$') + 1).valueOf();
		}
		else {
			b = 0;
		}
		if (c.indexOf('$') > -1) {
			c = c.substring(c.indexOf('$') + 1).valueOf();
		}
		else {
			c = 0;
		}
		if (d.indexOf('$') > -1) {
			d = d.substring(d.indexOf('$') + 1).valueOf();
		}
		else {
			d = 0;
		}
		if (e.indexOf('$') > -1) {
			e = e.substring(e.indexOf('$') + 1).valueOf();
		}
		else {
			e = 0;
		}
		if (f.indexOf('$') > -1) {
			f = f.substring(f.indexOf('$') + 1).valueOf();
		}
		else {
			f = 0;
		}
		if (g.indexOf('$') > -1) {
			g = g.substring(g.indexOf('$') + 1).valueOf();
		}
		else {
			g = 0;
		}
		if (h.indexOf('$') > -1) {
			h = h.substring(h.indexOf('$') + 1).valueOf();
		}
		else {
			h = 0;
		}
		if (ab.indexOf('$') > -1) {
			ab = ab.substring(ab.indexOf('$') + 1).valueOf();
		}
		else {
			ab = 0;
		}
		var bPrice = BasePrice;
		bPrice = bPrice.substring(bPrice.indexOf('$') + 1).valueOf();
		var grandTotal = parseFloat(a) + parseFloat(b) + parseFloat(c) + parseFloat(d) + parseFloat(e) + parseFloat(f) + parseFloat(g) + parseFloat(h) + parseFloat(ab) + parseFloat(bPrice);
		$('#priceNew').val("$" + CurrencyFormatted(grandTotal));
	}

	function CurrencyFormatted(amount) {
		var i = parseFloat(amount);
		if (isNaN(i)) { i = 0.00; }
		var minus = '';
		if (i < 0) { minus = '-'; }
		i = Math.abs(i);
		i = parseInt((i + .005) * 100);
		i = i / 100;
		s = new String(i);
		if (s.indexOf('.') < 0) { s += '.00'; }
		if (s.indexOf('.') == (s.length - 2)) { s += '0'; }
		s = minus + s;
		return s;
	}

	function validateForm() {
		var correct = true;
		if ($('select#buttons option:selected').val() == 'none selected') {
			correct = false;
			$('span#buttons_error').html('*');
		}
		if ($('select#embellish option:selected').val() == 'none selected') {
			correct = false;
			$('span#embellish_error').html('*');
		}
		if ($('select#embroidered option:selected').val() == 'none selected') {
			correct = false;
			$('span#embroidered_error').html('*');
		}
		if ($('select#fabric option:selected').val() == 'none selected') {
			correct = false;
			$('span#fabric_error').html('*');
		}
		if ($('select#monogram option:selected').val() != 'none selected' && $('select#monogram option:selected').val() != 'no monogram') {
			if ($('textarea#monogramFabric').val() == '') {
				correct = false;
				$('span#monogramFabric_error').html('*');
			}
		}
		if ($('select#itemSize option:selected').val() == 'none selected') {
			correct = false;
			$('span#itemSize_error').html('*');
		}
		if ($('select#itemTrim option:selected').val() == 'none selected') {
			correct = false;
			$('span#trims_error').html('*');
		}
		if ($('select#itemTrim option:selected').val() == 'none selected') {
			correct = false;
			$('span#itemTrim_error').html('*');
        }
        if ($('select#contrasting_fabrics option:selected').val() == 'none selected') {
            correct = false;
            $('span#contrasting_fabrics_error').html('*');
        }
        if ($('select#contrasting_fabrics option:selected').val() == 'none selected') {
            correct = false;
            $('span#contrasting_fabrics_error').html('*');
        }
        if ($('select#style_contrast option:selected').val() == 'none selected') {
            correct = false;
            $('span#style_contrast_error').html('*');
        }
        if ($('select#ribbon option:selected').val() == 'none selected') {
            correct = false;
            $('span#ribbon_error').html('*');
        }
		
		if (!correct) {
			alert('Please fill in all required fields');
			return false;
		}
		else
			document.forms["myform"].submit(); 

	}

	function validateInput(id) {
		if ($('select#' + id + ' option:selected').val() == 'none selected')
			$('span#' + id + '_error').html('*');
		else
			$('span#' + id + '_error').html('');

	}

	//Cache images
	if (document.images) {
		var str = "/graphics/";
		var nameImage = new Array('header_07', 'header_08', 'header_09', 'header_10', 'header_13', 'header_14', 'header_15', 'header_16', 'header_17', 'tabs1', 'tabs3', 'tabs5', 'tabs7', 'tabs9', 'tabs11', 'tabs13');
        var offImage = new Array();
		var onImage = new Array();
		for (i = 0; i < 0; i++) {
			offImage[i] = new Image();
			offImage[i].src = str + nameImage[i] + ".gif";
			onImage[i] = new Image();
			onImage[i].src = str + nameImage[i] + "_on.gif";
		}
	}
	// Image swapping
	function on(name, file) {
		if (document.images) obj = eval(document.images[name]);
		if (obj) obj.src = onImage[file].src;
	}
	function off(name, file) {
		if (document.images) obj = eval(document.images[name]);
		if (obj) obj.src = offImage[file].src;
	}
	function OpenHelp(HelpPage) {
		window.open('/help.asp?p=' + HelpPage, 'HelpWindow', 'height=300,width=320,scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
	}
	function jspopup(myurl, w, h, tb, sb, st) {
		var wnd = window.open(myurl, "popup", "toolbar=" + tb + ",location=0,directories=0,status=" + st + ",menubar=0,scrollbars=" + sb + ",resizable=0,width=" + w + ",height=" + h);
		if (wnd.opener == null) wnd.opener = self;
	}

