
function clearField( field_id ) 
{
    document.getElementById( field_id ).value = '';
	document.getElementById( field_id ).style.backgroundColor = '';   
}

function getMoneyFormat(num) {
    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));
	num = ((sign)?'':'-') +  num + '.' + cents;
	
	return num;
}

function getQuote()
{
    var cd_qty = document.getElementById("cd_qty").value;
    var price;
    var quote;
    var quote_text_node = document.getElementById("quote");
    
    price = .75;
    
    quote = cd_qty * price;
    quote = getMoneyFormat(quote);
        
    document.getElementById("quote").innerHTML = "$" + quote;
}

var name_first;
var name_last;
var full_name;

function updateRealname() 
{
    if( document.getElementById("name-first").value != '' ) {
        
        name_first = document.getElementById("name-first").value;
        
        if( document.getElementById("name-last").value != '' ) {
            
            name_last = document.getElementById("name-last").value;   
        } else { name_last = ''; } 
    } else { name_first = ''; }
    
    full_name = name_first + " " + name_last;
    
    document.getElementById("realname").value = full_name;
    //alert(full_name);
}

function fillShipping()
{
    var bill_name_first = document.getElementById("bill_name_first").value;
    var bill_name_last = document.getElementById("bill_name_last").value;  
    var bill_address1 = document.getElementById("bill_address1").value;
    var bill_address2 = document.getElementById("bill_address2").value;
    var bill_city = document.getElementById("bill_city").value;
    var bill_state = document.getElementById("bill_state").value;
    var bill_zip = document.getElementById("bill_zip").value;
    
    document.getElementById("ship_name_first").value = bill_name_first;
    document.getElementById("ship_name_last").value = bill_name_last;
    document.getElementById("ship_address1").value = bill_address1;
    document.getElementById("ship_address2").value = bill_address2;
    document.getElementById("ship_city").value = bill_city;
    document.getElementById("ship_state").value = bill_state;
    document.getElementById("ship_zip").value = bill_zip;
    
}

function checkWA()
{
	var bill_state = document.getElementById("bill_state").value;
	var total_with_tax = document.getElementById("total-with-tax").innerHTML;
	var total_no_tax = document.getElementById("total-without-tax").innerHTML;
	
	if( bill_state == "WA" ) {
		document.getElementById("tax-message").style.display = 'block';
		var tax = document.getElementById("tax-holder").innerHTML;
		document.getElementById("cell-tax").innerHTML = tax;
		//document.getElementById("span-tax").style.display = 'block';
		document.getElementById("total").innerHTML = "<strong>$" + total_with_tax + "</strong>";
	} else {
		document.getElementById("tax-message").style.display = 'none';
		document.getElementById("cell-tax").innerHTML = '0.00';
		//document.getElementById("span-tax").style.display = 'none';
		document.getElementById("total").innerHTML = "<strong>$" + total_no_tax + "</strong>";
	}
}

function popSystemReq()
{
	window.open('popSystemReq.php', '', 'width=570,height=400,scrollbars=yes');
}

function popCVV2()
{
	window.open('popCVV2.php', '', 'width=470,height=365,scrollbars=no');
}

function popSecureSite()
{
	window.open('popSecureSite.php', '', 'width=570,height=365,scrollbars=no');
}

