﻿
function initPage()
	{
	    
	}

function SameAsBilling()
	{
		if(document.frm1.cb_use_same.checked)
		{
			document.frm1.frm_shipping_name.value = document.frm1.frm_billing_name.value;
			document.frm1.frm_shipping_address1.value = document.frm1.frm_billing_address1.value;
			document.frm1.frm_shipping_address2.value = document.frm1.frm_billing_address2.value;
			document.frm1.frm_shipping_city.value = document.frm1.frm_billing_city.value;
			document.frm1.frm_shipping_state.selectedIndex = document.frm1.frm_billing_state.selectedIndex-1;
			document.frm1.frm_shipping_postal.value = document.frm1.frm_billing_postal.value;
		}
		else
		{
			document.frm1.frm_shipping_name.value = '';
			document.frm1.frm_shipping_address1.value = '';
			document.frm1.frm_shipping_address2.value = '';
			document.frm1.frm_shipping_city.value = '';
			document.frm1.frm_shipping_state.selectedIndex = 0;
			document.frm1.frm_shipping_postal.value = '';
		}
		
	}
	
function updateExp()
    {
        var expmo = document.frm1.frm_exp_mo;
        var expyr = document.frm1.frm_exp_yr;
        var mo = expmo.options[expmo.selectedIndex].value+'';
        var yr = expyr.options[expyr.selectedIndex].value+'';
        document.frm1.frm_card_exp.value = mo+yr;
    }
	
function cvchelp()
	{
		winpop = window.open('cardcode.aspx','','width=350,height=300,titlebar=no');
		winpop.moveTo(10,10);
	}
	
function completeOrder()
	{
	document.frm1.action = 'cart.aspx?action=complete';
	document.frm1.submit();
	}
function popImage(iid)
			{
				win1 = window.open('popimage.aspx?id='+iid,'','width=400,height=400');
				win1.moveTo((screen.availWidth-400)/2,(screen.availHeight-400)/2);
			}
function addToCart(id)
{
    var buypath = 'app_Cart.aspx?action=add&id=';
    var optionvar = document.forms[0][id];
    buypath += optionvar.value;
    window.location = buypath;
}

function setSelectedSku(id)
{
    var optionvar = document.forms[0][id];
    var selectvar = document.forms[0]['sel_'+id];
    optionvar.value = selectvar.options[selectvar.selectedIndex].value;
}

function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
    if(q) 
    {
        for(var i=0; i < this.q.split("&").length; i++) 
        {
            this.keyValuePairs[i] = this.q.split("&")[i];
        }
    }
    this.getKeyValuePairs = function() { return this.keyValuePairs; }
    this.getValue = function(s) 
    {
        for(var j=0; j < this.keyValuePairs.length; j++) 
        {
            if(this.keyValuePairs[j].split("=")[0] == s)
            return this.keyValuePairs[j].split("=")[1];
        }
        return false;
    }
    this.getParameters = function() 
    {
        var a = new Array(this.getLength());
        for(var j=0; j < this.keyValuePairs.length; j++) 
        {
            a[j] = this.keyValuePairs[j].split("=")[0];
        }
        return a;
    }
    this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key)
{
    var page = new PageQuery(window.location.search); 
    return unescape(page.getValue(key)); 
}

//window.onload += initPage();