// XP log function
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }
};

var itemCnt=0;

// SHOP: start
function displayCart(data) {
    var cartNumText='';
    itemCnt=0;
    if (data.numItems==0) cartNumText='no items';
    if (data.numItems==1) cartNumText='1 item';
    if (data.numItems>1) cartNumText=data.numItems+' items';
    $('.shopBagText .numItems').html(cartNumText);
    var html='';
    if (data.numItems<1) {
        html+='<div style="width:100%;padding:15px;font-size:13px;font-weight:bold;color:white;">';
        html+='your cart is empty.';
        html+='</div>';
    } else {
        html+='<div class="dynaCartItemScroll">';
        var n=0;
        for(var x=data.cart.length-1;x>=0;x--) {
            n++;
            html+='<div class="cartLine cl_'+n+'" id="dynaCart_'+data.cart[x].pid+'">';
            html+='<table cellpadding=1 cellspacing=0 border=0>';
            html+='<tr><td valign="top" width="80" align="right" style="max-width:80px;">';
            if (data.cart[x].image) html+='<img src="'+data.cart[x].image+'" />';
            html+='</td>';
            html+='<td style="padding-left:10px;width:185px;"><span style="color:white;font-size:13px;font-weight:bold;">'+data.cart[x].pname+'<br>'+data.cart[x].priceExt+'</span>';
            html+='<br><br><span class="dynaCartDetailLine">qty: '+data.cart[x].qty;
            if (data.cart[x].color!='') html+='<br>color: '+data.cart[x].color;
            html+='<br><a href="#" onClick="removeFromCart('+data.cart[x].pid+');return false;">remove</a>';
            html+='</span>';
            html+='</td></tr></table>';
/*            html+='<div style="float:left">';
            if (data.cart[x].image) html+='<img src="'+data.cart[x].image+'" width="50"/>';
            html+='</div>';
            html+='<div class="cartLineHeadRight"><p>'+data.cart[x].pname+'</p>';
            html+='<table cellpadding=1 cellspacing=0 border=0 class="cartValueTable">';
            if (data.cart[x].color!='') html+='<tr><td width="50" align=right class="cartLineLabel">color</td><td class="cartLineValue">'+data.cart[x].color+'</td>';
            html+='<td align=right><button type="button" onClick="removeFromCart('+data.cart[x].pid+')" class="buttonSmall">Remove</button></tr>';
            html+='<tr><td class="cartLineLabel" align=right>price</td><td class="cartLineValue" colspan=2>'+data.cart[x].price+'</td></tr>';
            html+='<tr><td class="cartLineLabel" align=right>qty</td><td class="cartLineValue">'+data.cart[x].qty+'</td><td class="cartLinePrice" align=right>'+data.cart[x].priceExt+'</td></tr>';
            html+='</table>';
            html+='</div>'; */
            html+='</div>';
        }
        html+='</div>';
        
/*        html+='<table cellpadding=3 cellspacing=0 width="100%">';
        for(var x=0;data.cart.length>x;x++) {
            html+='<tr><td valign=top>';
            if (data.cart[x].image) html+='<img style="border:1px solid #888;" src="'+data.cart[x].image+'" width="50"/>';
            html+='</td>';
            html+='<td valign=top style="line-spacing:1.2em">';
            html+='<span style="font-weight:bold;font-size:13px;">'+data.cart[x].pname+'</span><br>';
            if (data.cart[x].color!='') html+='Color: '+data.cart[x].color+'<br>';
            html+=data.cart[x].qty+' @ '+data.cart[x].price+'<br>';
            html+='</td>';
            html+='<td valign=bottom align=right>'+data.cart[x].priceExt+'</td>';
            html+='</tr>';
        }
        html+='</table>'; */
        html+='<div class="dynaCartSubtotalLine">';
        html+='<div style="float:left;"><b>subtotal:</b></div><div style="float:right;"><b>'+data.total+'</b></div>';
        html+='</div>';
/*        html+='<div style="width:100%;background:black;color:white;overflow:hidden;">';
        html+='<div class="dynaCartSubTotal"><span class="dynaCartTotalText">subtotal</span><br/><span class="dynaCartTotal">'+data.total+'</span></div>';
        html+='<div style="float:right;padding-top:2px;margin-left:5px;"><a class="button" href="shopping-bag.php">Checkout</a></div>'; */
        html+='<div style="margin-left:130px;padding:15px 0 15px 0;"><a class="dynaCartButton" href="shopping-bag.php">Checkout</a></div>';
        html+='</div>';
    }
    positionDynaCart();
    $('#dynaCartInner').html(html);
    var b=navigator.userAgent;
    if (b.indexOf('Chrome/')>0) {
    	$('.dynaCartSubtotalLine').width(250);
    }
    if (data.numItems>3) {
        $('.dynaCartItemScroll .cl_1 img').load(function() { adjustScrollerCount();   });
        $('.dynaCartItemScroll .cl_2 img').load(function() { adjustScrollerCount();   });
        $('.dynaCartItemScroll .cl_3 img').load(function() { adjustScrollerCount();   });
    }
    $('#dynaCart').slideDown(250,function() {
        setTimeout("dynaCartClose()",7000);
        $('.addToBagButton').show();
        $('.addToBagText').hide();
        $('.dynaCartItemScroll').jScrollPane();
    });
}

function adjustScrollerCount() {
    itemCnt++;
    if (itemCnt==3) {
        var totHeight=
            $('.cl_1').outerHeight()
            + $('.cl_2').outerHeight()
            + $('.cl_3').outerHeight();
        $('.dynaCartItemScroll').css('max-height',totHeight+'px');
        $('.dynaCartItemScroll').jScrollPane();
    }
}
function positionDynaCart() {
    var p=$('.shopBagText').position();
    $('.shopBagText').addClass('shopBagTextOn');
    $('#dynaCart').css('left',p.left+'px');
    $('#dynaCart').css('top',(p.top+20)+'px');
}
function removeFromCart(pid) {
    $.get('/shopping-api.php?action=remove&id='+pid, function(rawData) {
        data=$.parseJSON(rawData);
        var lineHeight=$('#dynaCart_'+pid).height();
        $('#dynaCart_'+pid).fadeOut(250,function() {
            if ($('#dynaCart .jspContainer').is(':visible')) {
                var jspHeight=$('#dynaCart .jspContainer').height();
                $('#dynaCart .jspContainer').css('height',(jspHeight-lineHeight)+'px');
            }
        });
        if (data.numItems==0) cartNumText='no items';
        if (data.numItems==1) cartNumText='1 item';
        if (data.numItems>1) cartNumText=data.numItems+' items';
        $('.shopBagText .numItems').html(cartNumText);
        $('.dynaCartTotal').html(data.total);
        positionDynaCart();
        if (data.numItems<1) {
            var html='';
            html+='<div style="width:100%;padding:15px;font-size:13px;font-weight:bold;color:white;">';
            html+='your cart is empty.';
            html+='</div>';
            $('#dynaCartInner').delay(250).html(html);
        }
        var elem = $('.dynaCartItemScroll').jScrollPane();
        var api = elem.data('jsp');
        api.destroy().reinitialise();
        moShopBagText=false;
        moDynaCart=false;
        setTimeout("dynaCartClose()",7000);
    });
}

function showDynaCart() {
    $.post('/shopping-api.php','',function(data) {
        displayCart($.parseJSON(data));
    });
}

function dynaCartClose() {
    if (!moShopBagText && !moDynaCart) {
        $('#dynaCart').slideUp(250,function () {
            $('.shopBagText').removeClass('shopBagTextOn');
        });
    }   
}

var moShopBagText=false;
var moDynaCart=false;

$(document).ready(function() {
    if (jQuery) {
        if ($('.shopBagText').is(':visible')) {
            $('.shopBagText a').remove();
            $('.shopBagText').prepend('<a href="/shopping-bag.php" id="dynaShopBagLink">shopping bag</a>');
//            $('.shopBagText a').click(function() { showDynaCart(); return false; });
            $('#dynaCart').hover(function() {
                moDynaCart=true;
            },function() {
                moDynaCart=false;
                setTimeout("dynaCartClose()",1000);
            });
            $('.shopBagText').hover(function() {
                moShopBagText=true;
                showDynaCart();
            },function() {
                moShopBagText=false;
                setTimeout("dynaCartClose()",1000);
            });
        }
    }
});
// SHOP: end

function dosearch(f) {
	if (f.search.value!='') {
		f.submit();
	}
}
var loadFlag = 0;

function submit_checkout1()
{
	var validEmail=/.+@.+\.\w{2,}/;
	var doit=true;
	if (f.first_name.value == '') {
		f.first_name.style.background='#99ff99';
		doit=false;
	} else {
		f.first_name.style.background='#ffffff';
	}
	if (f.last_name.value == '') {
		f.last_name.style.background='#99ff99';
		doit=false;
	} else {
		f.last_name.style.background='#ffffff';
	}
	if (f.phone.value == '') {
		f.phone.style.background='#99ff99';
		doit=false;
	} else {
		f.phone.style.background='#ffffff';
	}
	if (f.address.value == '') {
		f.address.style.background='#99ff99';
		doit=false;
	} else {
		f.address.style.background='#ffffff';
	}
	if (f.city.value == '') {
		f.city.style.background='#99ff99';
		doit=false;
	} else {
		f.city.style.background='#ffffff';
	}

	if (f.country.options[f.country.selectedIndex].value=='United States') {
		if (f.state.selectedIndex == 0 || f.state.selectedIndex > 51) {
			f.state.style.background='#99ff99';
			doit=false;
		} else {
			f.state.style.background='#ffffff';
		}
	} else if (f.country.options[f.country.selectedIndex].value=='Canada') {
		if (f.state.selectedIndex == 0 || f.state.selectedIndex < 52) {
			f.state.style.background='#99ff99';
			doit=false;
		} else {
			f.state.style.background='#ffffff';
		}
	} else {
		f.state.style.background='#ffffff';
	}

	if (f.zip.value == '') {
		f.zip.style.background='#99ff99';
		doit=false;
	} else {
		f.zip.style.background='#ffffff';
	}
	if (f.country.selectedIndex == 0) {
		f.country.style.background='#99ff99';
		doit=false;
	} else {
		f.country.style.background='#ffffff';
	}

	if (f.pick_up.checked) {
		if (f.s_first_name.value != '') {
			f.s_first_name.style.background='#99ff99';
			doit=false;
		} else {
			f.s_first_name.style.background='#ffffff';
		}
		if (f.s_last_name.value != '') {
			f.s_last_name.style.background='#99ff99';
			doit=false;
		} else {
			f.s_last_name.style.background='#ffffff';
		}
		if (f.s_phone.value != '') {
			f.s_phone.style.background='#99ff99';
			doit=false;
		} else {
			f.s_phone.style.background='#ffffff';
		}
		if (f.s_address.value != '') {
			f.s_address.style.background='#99ff99';
			doit=false;
		} else {
			f.s_address.style.background='#ffffff';
		}
		if (f.s_address2.value != '') {
			f.s_address2.style.background='#99ff99';
			doit=false;
		} else {
			f.s_address2.style.background='#ffffff';
		}
		if (f.s_city.value != '') {
			f.s_city.style.background='#99ff99';
			doit=false;
		} else {
			f.s_city.style.background='#ffffff';
		}
		if (f.s_state.selectedIndex != 0) {
			f.s_state.style.background='#99ff99';
			doit=false;
		} else {
			f.s_state.style.background='#ffffff';
		}
		if (f.s_zip.value != '') {
			f.s_zip.style.background='#99ff99';
			doit=false;
		} else {
			f.s_zip.style.background='#ffffff';
		}
		if (f.s_country.selectedIndex != 0) {
			f.s_country.style.background='#99ff99';
			doit=false;
		} else {
			f.s_country.style.background='#ffffff';
		}
	} else {

		if (f.s_last_name.value=='' || f.s_address.value=='') {
			f.s_first_name.style.background='#ffffff';
			f.s_last_name.style.background='#ffffff';
			f.s_address.style.background='#ffffff';
			f.s_address2.style.background='#ffffff';
			f.s_phone.style.background='#ffffff';
			f.s_city.style.background='#ffffff';
			f.s_state.style.background='#ffffff';
			f.s_zip.style.background='#ffffff';
			f.s_country.style.background='#ffffff';
		}

		if (f.s_last_name.value!='' && f.s_address.value!='') {
	
			if (f.s_first_name.value == '') {
				f.s_first_name.style.background='#99ff99';
				doit=false;
			} else {
				f.s_first_name.style.background='#ffffff';
			}
			if (f.s_last_name.value == '') {
				f.s_last_name.style.background='#99ff99';
				doit=false;
			} else {
				f.s_last_name.style.background='#ffffff';
			}
			if (f.s_phone.value == '') {
				f.s_phone.style.background='#99ff99';
				doit=false;
			} else {
				f.s_phone.style.background='#ffffff';
			}
			if (f.s_address.value == '') {
				f.s_address.style.background='#99ff99';
				doit=false;
			} else {
				f.s_address.style.background='#ffffff';
			}
			if (f.s_city.value == '') {
				f.s_city.style.background='#99ff99';
				doit=false;
			} else {
				f.s_city.style.background='#ffffff';
			}
	
			if (f.s_country.options[f.s_country.selectedIndex].value=='United States') {
				if (f.s_state.selectedIndex == 0 || f.s_state.selectedIndex > 51) {
					f.s_state.style.background='#99ff99';
					doit=false;
				} else {
					f.s_state.style.background='#ffffff';
				}
			} else if (f.s_country.options[f.s_country.selectedIndex].value=='Canada') {
				if (f.s_state.selectedIndex == 0 || f.s_state.selectedIndex < 52) {
					f.s_state.style.background='#99ff99';
					doit=false;
				} else {
					f.s_state.style.background='#ffffff';
				}
			} else {
				f.s_state.style.background='#ffffff';
			}
	
			if (f.s_zip.value == '') {
				f.s_zip.style.background='#99ff99';
				doit=false;
			} else {
				f.s_zip.style.background='#ffffff';
			}
			if (f.s_country.selectedIndex == 0) {
				f.s_country.style.background='#99ff99';
				doit=false;
			} else {
				f.s_country.style.background='#ffffff';
			}
		}
	}

	if (f.email.value == '') {
		f.email.style.background='#99ff99';
		doit=false;
	} else if (!validEmail.test(f.email.value)) {
		f.email.style.background='#99ff99';
		doit=false;
	} else {
		f.email.style.background='#ffffff';
	} 
	if (f.email2.value == '') {
		f.email2.style.background='#99ff99';
		doit=false;
	} else if (!validEmail.test(f.email2.value)) {
		f.email2.style.background='#99ff99';
		doit=false;
	} else if (f.email2.value != f.email.value) {
		f.email2.style.background='#99ff99';
		doit=false;
	} else {
		f.email2.style.background='#ffffff';
	} 

	if (!doit) {
		document.verify.src='images/pleaseVerify.gif';
	}

	return(doit);
}

function goDactive(value,thefield) {
	aVal = unescape(value);
	updThis = eval("window.opener.document.theform." + thefield + ".value='" + aVal + "';");
	window.opener.document.theform.submit();
	window.opener.focus();
	window.close();
}
function goD(value,thefield) {
	aVal = unescape(value);
	updThis = eval("window.opener.document.theform." + thefield + ".value='" + aVal + "';");
	window.opener.focus();
	window.close();
}
function goT(value,thefield) {
	aVal = unescape(value);
	updThis = eval("window.opener.document.theform." + thefield + ".value='" + aVal + "';");
	window.opener.focus();
	window.close();
}
function goInsertTxt(value,thefield) {
	aName = unescape(value);
	updThis = eval("window.opener.document.theform." + thefield + ".value=aName");
	window.opener.focus();
	window.close();
}
function goInsert(value,display,thefield) {
	aName = unescape(display);
	updThis = eval("window.opener.document.theform." + thefield + "_txt" + ".value=aName");
	updThis = eval("window.opener.document.theform." + thefield + ".value=" + value);
	window.opener.focus();
	window.close();
}
function goInsert_2(value,display,thefield) {
	aName = unescape(display);
	updThis = eval("window.opener.document.theform." + thefield + "_txt" + ".value=aName");
	updThis = eval("window.opener.document.theform." + thefield + ".value=" + value);
	updThis = eval("window.opener.document.theform." + thefield + "_2_txt" + ".value=aName");
	updThis = eval("window.opener.document.theform." + thefield + "_2.value=" + value);
	window.opener.focus();
	window.close();
}
function goInsertRelay(value,display,thefield) {
	aName = unescape(display);
	updThis = eval("window.opener.document.theform." + thefield + "_txt" + ".value=aName");
	updThis = eval("window.opener.document.theform." + thefield + ".value =" + value);
	window.opener.focus();
	window.close();
}
function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function preloadImages() {
	if (document.images) {
		loadArray = new Array;
		for (i=0;i<preloadArray.length;i++) {
			loadArray[i] = new Image();
			loadArray[i].src = preloadArray[i];
		}
	}
loadFlag = 1;
}

function pop_window(url,windowName,w,h,sb) {
	winProps = 'height='+h+',width='+w+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+sb+',resizable=1';
	new_window = window.open(url,windowName,winProps);
	new_window.focus();
}

function submit_editperson() {
    var msg='';
	var validEmail=/.+@.+\.\w{2,}/;
	if (document.theform.last_name.value == '') {
		msg=msg + "Last name is required\n"; }
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_changepassword()
{
    var msg='';
	if (document.theform.verify.value != document.theform.newpw.value) {
		msg=msg + "The new password does not match the verification password\n"; }
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_sendpw()
{
    var msg='';
	if (document.theform.email.value == '') {
		msg=msg + "Email is required\n"; }
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_topic()
{
    var msg='';
	if (document.theform.text.value == '') {
		msg=msg + "Text is required\n"; }
	if (document.theform.title.value == '') {
		msg=msg + "A topic is required\n"; }
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_message()
{
    var msg='';
	if (document.theform.text.value == '') {
		msg=msg + "Text is required\n"; }
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_brochure()
{
    var msg='';
	var validEmail=/.+@.+\.\w{2,}/;
	if (document.theform.first_name.value == '') {
		msg=msg + "First name is required\n"; }
	if (document.theform.email.value == '') {
		msg=msg + "Email name is required\n";
	} else {
		if (!validEmail.test(document.theform.email.value)) {
			msg=msg + "Your Email address is not formatted correctly\n";
		}
	}
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_register2()
{
    var msg='';
	if (document.theform.cc_num.value == '') {
		msg=msg + "A credit card number is required\n"; }
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_checkout2()
{
    var msg='';
	if (document.theform.cc_num.value == '') {
		msg=msg + "your credit card number is required\n"; }
	if (document.theform.cc_code.value == '') {
		msg=msg + "your credit card security number is required\n"; }
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_signup()
{
    var msg='';
	var validEmail=/.+@.+\.\w{2,}/;
	if (document.theform.first_name.value == '') {
		msg=msg + "First name is required\n"; }
	if (document.theform.password.value != document.theform.password2.value) {
		msg=msg + "The passwords do not match\n"; }
	if (document.theform.email.value == '') {
		msg=msg + "Email name is required\n";
	} else {
		if (!validEmail.test(document.theform.email.value)) {
			msg=msg + "Your Email address is not formatted correctly\n";
		}
	}
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_nl()
{
    var msg='';
	var validEmail=/.+@.+\.\w{2,}/;
	if (document.theform.first_name.value == '') {
		msg=msg + "First name is required\n"; }
	if (document.theform.last_name.value == '') {
		msg=msg + "Last name is required\n"; }
	if (document.theform.email.value == '') {
		msg=msg + "Email is required\n";
	} else {
		if (!validEmail.test(document.theform.email.value)) {
			msg=msg + "Your Email address is not formatted correctly\n";
		}
	}
	if (msg != '') {
		alert(msg);
	} else {
		var fn=document.theform.first_name.value;
		var ln=document.theform.last_name.value;
		var em=document.theform.email.value;
		document.theform.first_name.value='';
		document.theform.last_name.value='';
		document.theform.email.value='';
		popWindow('/nlsignup.php?first_name=' + escape(fn) + '&last_name=' + escape(ln) + '&email=' + escape(em),'nlsignup','300','300');
	}
}
function submit_sb()
{
    var msg='';
	var validEmail=/.+@.+\.\w{2,}/;
	if (document.theform.name.value == '') {
		msg=msg + "Billing first name is required\n"; }
	if (document.theform.message.value == '') {
		msg=msg + "Billing city is required\n"; }
	if (document.theform.email.value == '') {
		msg=msg + "Email name is required\n";
	} else {
		if (!validEmail.test(document.theform.email.value)) {
			msg=msg + "Your Email address is not formatted correctly\n";
		}
	}
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_register1()
{
    var msg='';
	var validEmail=/.+@.+\.\w{2,}/;
	if (document.theform.first_name.value == '') {
		msg=msg + "Frst name is required\n"; }
	if (document.theform.last_name.value == '') {
		msg=msg + "Last name is required\n"; }
	if (document.theform.address.value == '') {
		msg=msg + "Address is required\n"; }
	if (document.theform.city.value == '') {
		msg=msg + "City is required\n"; }
	if (document.theform.email.value == '') {
		//msg=msg + "Email name is required\n";
	} else {
		if (!validEmail.test(document.theform.email.value)) {
			msg=msg + "Your Email address is not formatted correctly\n";
		}
	}
   	var s=document.theform.state.value;
	if (document.theform.country.options[document.theform.country.selectedIndex].value=='USA') {
		if (s == '') {
			msg=msg + "State is required\n"; }
		if (document.theform.zip.value == '') {
			msg=msg + "Zip code is required\n"; }
		if (s=='AB' || s=='BC' || s=='MB' || s=='NB' || s=='NL' || s=='NT' || s=='NS' || s=='NU' || s=='ON' || s=='PE' || s=='QC' || s=='SK' || s=='YT') {
			msg=msg + "You have choosen a Canadian Provice and USA as your country\n"; }
	}
	if (document.theform.country.selectedIndex==0) {
		msg=msg + "Country is required\n";
	}
	if (document.theform.country.options[document.theform.country.selectedIndex].value=='Canada') {
		if (s == '') {
			msg=msg + "Province is required\n"; }
		if (document.theform.zip.value == '') {
			msg=msg + "Postal code is required\n"; }
		if (s!='AB' && s!='BC' && s!='MB' && s!='NB' && s!='NL' && s!='NT' && s!='NS' && s!='NU' && s!='ON' && s!='PE' && s!='QC' && s!='SK' && s!='YT') {
			msg=msg + "You have choosen an American State and Canada as your country\n"; }
	}
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}
function submit_checkout1()
{
    var msg='';
	var validEmail=/.+@.+\.\w{2,}/;
	if (document.theform.first_name.value == '') {
		msg=msg + "Frst name is required\n"; }
	if (document.theform.last_name.value == '') {
		msg=msg + "Last name is required\n"; }
	if (document.theform.address.value == '') {
		msg=msg + "Address is required\n"; }
	if (document.theform.city.value == '') {
		msg=msg + "City is required\n"; }
	if (document.theform.email.value == '') {
		//msg=msg + "Email name is required\n";
	} else {
		if (!validEmail.test(document.theform.email.value)) {
			msg=msg + "Your Email address is not formatted correctly\n";
		}
	}
   	var s=document.theform.state.value;
	if (document.theform.country.options[document.theform.country.selectedIndex].value=='USA') {
		if (s == '') {
			msg=msg + "State is required\n"; }
		if (document.theform.zip.value == '') {
			msg=msg + "Zip code is required\n"; }
		if (s=='AB' || s=='BC' || s=='MB' || s=='NB' || s=='NL' || s=='NT' || s=='NS' || s=='NU' || s=='ON' || s=='PE' || s=='QC' || s=='SK' || s=='YT') {
			msg=msg + "You have choosen a Canadian Provice and USA as your country\n"; }
	}
	if (document.theform.country.selectedIndex==0) {
		msg=msg + "Country is required\n";
	}
	if (document.theform.country.options[document.theform.country.selectedIndex].value=='Canada') {
		if (s == '') {
			msg=msg + "Province is required\n"; }
		if (document.theform.zip.value == '') {
			msg=msg + "Postal code is required\n"; }
		if (s!='AB' && s!='BC' && s!='MB' && s!='NB' && s!='NL' && s!='NT' && s!='NS' && s!='NU' && s!='ON' && s!='PE' && s!='QC' && s!='SK' && s!='YT') {
			msg=msg + "You have choosen an American State and Canada as your country\n"; }
	}
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
		return(true);
	}
}

function submititCC()
{
	var msg='';
	if (document.theform.cc_num.value == '') {
		msg=msg + "Credit card number is required\n"; }
	if (msg != '') {
		alert(msg);
		return(false);
	} else {
        if (checksubmitted==1) {
            var response=confirm('It looks like you have already clicked the button to process your order.  Please click "Ok" and wait until this process is finished.  If you are sure your order is not currently being processed click "cancel" to try again');
            if (response) {
                return(false);
            } else {
                checksubmitted=1;
                return(true);
            }
        } else {
            checksubmitted=1;
            return(true);
        }
    }
}   

function change_qty(url,qty) {
	document.location=url + "&quantity=" + qty;
}
function setCookiePath(c_name,value,expiredays,path)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) +
(( path ) ? ";path=" + path : "" );

}
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
