﻿$(document).ready(function() {
    $(".videoLink").click(function() {
        var videosrc = $(this).attr("href");
        $(this).attr("href", "#view");
        var vw = parseInt($(this).attr("videowidth"));
        var vh = parseInt($(this).attr("videoheight"));
        var vt = $(this).attr("title");
        var videoboxy = new Boxy("<div style=\"width:" + vw + "px;height:" + vh + "px; background-color:#000000; padding:0px;\"><div id=\"video1\" style=\"z-index: 0;\"></div></div>", {
            "title": vt,
            modal: true,
            unloadOnHide: true,
            afterShow: function() {
                $("#video1").flash({
                    swf: videosrc,
                    height: vh,
                    width: vw,
                    params: {
                        wmode: "transparent"
                    }
                });
            }
        });

    });
    $(".category-item.btn").prepend("<span class=\"l\"></span><span class=\"r\"></span>");
    $(".boxy").boxy();
    $(".modal-boxy").boxy({
        modal: true
    });

});
function initPage()
	{
	}

function SameAsBilling()
	{
		if(document.forms[0].cb_use_same.checked)
		{
			document.forms[0].vsg_ship_name.value = document.forms[0].vsg_bill_name.value;
			document.forms[0].vsg_ship_address1.value = document.forms[0].vsg_bill_address1.value;
			document.forms[0].vsg_ship_address2.value = document.forms[0].vsg_bill_address2.value;
			document.forms[0].vsg_ship_city.value = document.forms[0].vsg_bill_city.value;
			document.forms[0].vsg_ship_state.selectedIndex = document.forms[0].vsg_bill_state.selectedIndex;
			document.forms[0].vsg_ship_postal.value = document.forms[0].vsg_bill_postal.value;
		}
		else
		{
			document.forms[0].vsg_ship_name.value = '';
			document.forms[0].vsg_ship_address1.value = '';
			document.forms[0].vsg_ship_address2.value = '';
			document.forms[0].vsg_ship_city.value = '';
			document.forms[0].vsg_ship_state.selectedIndex = 0;
			document.forms[0].vsg_ship_postal.value = '';
		}
		
	}
	
function updateExp()
    {
        var expmo = document.forms[0].vsg_exp_mo;
        var expyr = document.forms[0].vsg_exp_yr;
        var mo = expmo.options[expmo.selectedIndex].value+'';
        var yr = expyr.options[expyr.selectedIndex].value+'';
        document.forms[0].vsg_card_exp.value = mo+yr;
    }
	
function cvchelp()
	{
		winpop = window.open('cardcode.aspx','','width=350,height=300,titlebar=no,scrollbars=1');
		winpop.moveTo(10,10);
		winpop.focus();
	}
	
function completeOrder()
	{
	document.forms[0].action = 'cart.aspx?action=complete';
	document.forms[0].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;
}

//window.onload += initPage();

function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
//for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
//num = num.substring(0,num.length-(4*i+3))+','+
//num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}