function ShowSubscriptionForm(){
	ShowBlock("SubscriptionForm");
}

function CheckBilling() {
	if(GEBI("BillingNotDelivery").checked == true){
		ShowBlock("BillingInfo");
	} else {
		Hide("BillingInfo");
	}
}

/*
/	PreviewAd will hide all forms and show a
/	preview of the users ad with rate and billing info
*/
function PreviewSubscription() {
	
	var Required = "subscription_rate,delivery_firstname,delivery_lastname,delivery_email,delivery_phone,delivery_address1,delivery_city,delivery_state,delivery_zip,cardnumber";
	var HidePaymentInfo = false;
	var RequiredFlag = true;
	
	if(GEBI("BillingNotDelivery").checked == true){
		Required += ",billing_firstname,billing_lastname,billing_address1,billing_city,billing_state,billing_zip";
	} else {
		var BillingFields = "billing_firstname,billing_lastname,billing_address1,billing_address2,billing_city,billing_state,billing_zip";
		var Billing = BillingFields.split(",");
		for(var i = 0; i < Billing.length; i++){
			var Delivery = Billing[i].split("_");
			GEBI(Billing[i]).value = GEBI("delivery_"+Delivery[1]).value;
		}
	}
	
	var RequiredFields = Required.split(",");
	
	for(var i = 0; i < RequiredFields.length; i++){
		if(GEBI(RequiredFields[i]).value == "" || GEBI(RequiredFields[i]).value == "SA"){
			GEBI(RequiredFields[i]+"_required").style.color = "red";
			RequiredFlag = false;
		} else {
			GEBI(RequiredFields[i]+"_required").style.color = "black";
		}
	}
	
	//check credit card number
	//functions in credit_card_validation.js
	if(!CheckCardNumber()){
		RequiredFlag = false;
	}
	
	if(RequiredFlag){
		
		GEBI("SubscriptionPreviewDelivery").innerHTML = GEBI("delivery_firstname").value + " " + GEBI("delivery_lastname").value + "<br>" + GEBI("delivery_address1").value + " " + GEBI("delivery_address2").value + "<br>" + GEBI("delivery_city").value + ", " + GEBI("delivery_state").value + " " + GEBI("delivery_zip").value;
		
		if(GEBI("BillingNotDelivery").checked){
			GEBI("SubscriptionPreviewBilling").innerHTML = GEBI("billing_firstname").value + " " + GEBI("billing_lastname").value + "<br>" + GEBI("billing_address1").value + " " + GEBI("billing_address2").value + "<br>" + GEBI("billing_city").value + ", " + GEBI("billing_state").value + " " + GEBI("billing_zip").value;
		} else {
			GEBI("SubscriptionPreviewBilling").innerHTML = "Same as delivery.";
		}
		GEBI("SubscriptionPreviewCost").innerHTML = GEBI("subscription_rate").value;
		GEBI("SubscriptionPreviewCreditCard").innerHTML = GEBI("cardtype").value + "<br>" + GEBI("cardnumber").value + "<br>" + GEBI("cardmonth").value + "/" + GEBI("cardyear").value;
		GEBI("SubscriptionPreviewComments").innerHTML = GEBI("comments").value;
		Hide("SubscriptionContent");
		Hide("SubscriptionForm");
		if(HidePaymentInfo){
			Hide("PaymentInfo");
		}
		ShowBlock("SubscriptionPreview");
		Hide("PreviewBtn");
		window.location.hash = "top";
	}		
}

function EditSubscription() {
	
	ShowInline("PreviewBtn");
	ShowBlock("SubscriptionForm");
	Hide("SubscriptionPreview");
			
}
