// JavaScript Document


//looks for array in document productArray with extra product fields listed for addition to the price sum.
function CalculateSubscriptionPrice(){
	if(typeof(productArray) !='undefined'){
		productArray[productArray.length] = 'subscription';
		productArray[productArray.length] = 'giftSubscription';
	}else
		var productArray = new Array('subscription','giftSubscription');
	var productSelection = new Array();
	var productSum = 0;
	for(a=0; a<productArray.length; ++a){
			v=1;
		while(typeof(document.getElementById(productArray[a]+'_'+v)) != null){
			var pObject = document.getElementById(productArray[a]+'_'+v);
			if(pObject.checked == true){
				productSum += parseFloat(pObject.getAttribute('price')); //alert('tarray: '+productArray[a]+'_'+v+' '+parseFloat(pObject.getAttribute('price')));//
				break;
			}else{
				++v;
			}
			
		}
	}
	//alert(productSum);
	var price = FormatPrice(productSum);
	var totalPrice = document.getElementById('totalPrice');
	totalPrice.value = price;
	return price;
}


function FormatPrice(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 FullCardNum(){
	var box1 = document.order.ccBox1.value;
	var box2 = document.order.ccBox2.value;
	var box3 = document.order.ccBox3.value;
	var box4 = document.order.ccBox4.value;
	
	document.order.fullCardNumber.value = box1 + "-" + box2 + "-" + box3 + "-" + box4;
}

/* from old script

function showHideBonus(selectedValue, type, idhide){
	var theobj = document.getElementById(idhide);
	switch(type){
		case'QBDATickets':
			if(selectedValue >=3){
				theobj.style.display='';
			}else{
				theobj.style.display='none';
			}
			break;
	}
}
*/