function addSchoolName() {
	$('input_container').insert('<br><br>');
	var textInput = new Element('input',{type: 'text', name: 'school_name[]'});
	textInput.value = 'Enter School Name';
	$('input_container').insert(textInput);
}

var productPriceArray = new Array();
productPriceArray[1] = 100;
productPriceArray[2] = 500;
productPriceArray[3] = 2500;
productPriceArray[4] = 2500;
productPriceArray[5] = 2500;
function updateDisplayTotal() {
	currentPrice = 0;
	for(x = 1; x < productPriceArray.length; x++) {
		if($('product_qty_'+x)) {
			tempPrice = productPriceArray[x] * $('product_qty_'+x).value;
			$('product_total_'+x).update(tempPrice);
			currentPrice += tempPrice;
		}
	}
	$('total').update(currentPrice);
	
}
dropdownActive = false;
function displayLicense(formID) {
	if(!dropdownActive) {
		$('dropdownHeader').update();
		$('dropdownContent').update();
		showDropdown();
		
		$("dropdown").className = 'largeDropdown';
		dropdownActive = true;
		$("dropdownHeader").update("Software License Agreement");
		new Ajax.Updater('dropdownContent','/ajax_actions.php',{
			parameters: {
				action: 'get_software_license',
				form_id: formID
			},
			evalScripts: true,
			evalJS: 'force'
		});
	}
}

function displayLegal() {
	if(!dropdownActive) {
		$('dropdownHeader').update();
		$('dropdownContent').update();
		showDropdown();
		
		$("dropdown").className = 'largeDropdown';
		dropdownActive = true;
		$("dropdownHeader").update("Legal Information");
		new Ajax.Updater('dropdownContent','/ajax_actions.php',{
			parameters: {
				action: 'get_software_license'
			},
			evalScripts: true,
			evalJS: 'force'
		});
	}
}

function displayPrivacy(formID) {
	if(!dropdownActive) {
		$('dropdownHeader').update();
		$('dropdownContent').update();
		showDropdown();
		$("dropdown").className = 'largeDropdown';
		dropdownActive = true;
		$("dropdownHeader").update("Privacy Policy");
		new Ajax.Updater('dropdownContent','/ajax_actions.php',{
			parameters: {
				action: 'get_privacy_info',
				form_id: formID
			},
			evalScripts: true
		});
	}
}

function displayCancel() {
	if(!dropdownActive) {
		$("dropdown").className = 'smallDropdown';
		dropdownActive = true;
		$("dropdownHeader").update("Cancel Order");
		new Ajax.Updater('dropdownContent','/ajax_actions.php',{
			parameters: {
				action: 'get_cancel_order'
			},
			evalScripts: true,
			onComplete: function () {
				showDropdown();
			}
		});
	}
}

function displayCVV2Info() {
	if(!dropdownActive) {
		$("dropdown").className = 'largeDropdown';
		dropdownActive = true;
		$("dropdownHeader").update("Finding Your Security Code");
		new Ajax.Updater('dropdownContent','/ajax_actions.php',{
			parameters: {
				action: 'get_cvv2_info'
			},
			evalScripts: true,
			onComplete: function () {
				showDropdown();
			}
		});
	}
}

function sendMessage() {
	$("dropdown").className = 'smallDropdown';
	dropdownActive = true;
	$("dropdownHeader").update("Email Sent");
			
	new Ajax.Updater('dropdownContent','/ajax_actions.php',{
		parameters: {
			action: 'send_message',
			from: $('email_address').value,
			subject: $('subject').value,
			message: $('message').value
		},
		method: 'post',
		onComplete: function () {
			showDropdown();
		}
	});
}

function sendRefundMessage() {
	$("dropdown").className = 'smallDropdown';
	dropdownActive = true;
	$("dropdownHeader").update("Email Sent");
			
	new Ajax.Updater('dropdownContent','/ajax_actions.php',{
		parameters: {
			action: 'send_refund_message',
			order_id: $('order_id').value,
			token: $('token').value,
			message: $('message').value
		},
		method: 'post',
		onComplete: function () {
			showDropdown();
		}
	});
}

function displayVATInfo() {
	if(!dropdownActive) {
		$('dropdownHeader').update();
		$('dropdownContent').update();
		showDropdown();
		$("dropdown").className = 'largeDropdown';
		dropdownActive = true;
		$("dropdownHeader").update("What is a VAT?");
		new Ajax.Updater('dropdownContent','/ajax_actions.php',{
			parameters: {
				action: 'get_vat_info'
			},
			evalScripts: true
		});
	}
}

function showDropdown() {
	if($("player")) {
		$("player").hide();
	}
	new Effect.BlindDown("dropdown",
		{
			duration: .3,
			afterFinish: function () {
				dropdownActive = false;
			}
		}
	);
}

function hideDropdown() {
	dropdownActive = true;
	new Effect.BlindUp("dropdown",
		{
			duration: .3,
			afterFinish: function () {
				dropdownActive = false;
				if($("player")) {
					$("player").show();
				}
			}
		}
	);	
}


var scrollers = new Array();

function scrollUp(targetDivID) {
	var targetDiv = document.getElementById(targetDivID);
	if(targetDiv) {
		targetDiv.scrollTop = targetDiv.scrollTop - 30;
	}
}

function scrollDown(targetDivID) {
	var targetDiv = document.getElementById(targetDivID);
	targetDiv.scrollTop = targetDiv.scrollTop + 30;
}
function scrollDiv(containerDiv,scrollerDiv,percentage) {
	var max = $(containerDiv).offsetHeight - $(scrollerDiv).offsetHeight;

	var scrollTo = max * (percentage/100);
	$(scrollerDiv).scrollTop = scrollTo;
}

function wheelScroll(containerDiv,scrollerDiv,event) {
	var scrollAmount = Event.wheel(event);
	var max = $(containerDiv).offsetHeight - $(scrollerDiv).offsetHeight;
	if(max < 50) {
		max = 50;
	}
	var scrollTo = $(scrollerDiv).scrollTop - (scrollAmount * (max/50));
	scroller = scrollers[containerDiv];
	scrollerValue = (scrollTo/max)*100;
	scroller.setValue(scrollerValue);
	$(scrollerDiv).scrollTop = scrollTo;
}
Object.extend(Event, {

  wheel:function (event){

    var delta = 0;

    if (!event) event = window.event;

    if (event.wheelDelta) {

      delta = event.wheelDelta/120;

      if (window.opera) delta = -delta;

    } else if (event.detail) { delta = -event.detail/3;     }

    return Math.round(delta); //Safari Round

  }

});

function clearCreditCard() {
	$('credit_card_number').value = '';
	$('expiration_month').value = '';
	$('expiration_year').value = '';
	$('cvv2').value = '';
	$('po_radio').checked = true;
}

function clearPurchaseOrder() {
	$('purchase_order_number').value = '';
	$('credit_card_radio').checked = true;
}

