//****************************************************************************************************************
//** Page Name		: scripts.js
//** Description	: Client side scripting functions
//** Comment			: 
//** Author				: Jason M
//** Last Revised	: 08/01/2007
//****************************************************************************************************************

function moreFiles() {
 for (i = 2; i <= 5; i++) document.getElementById('more'+i).style.display = '';
 document.getElementById('morelink').style.display = 'none';
}

function selectPackage(p, i) {
 price = p;
 document.frm.package[i].checked = true;
 updatePrice();
}

function updatePrice() {
 var total_mins = 0;
 var total_price = 0;
 for (i = 1; i <= 5; i++) {
  mins = document.getElementById('minutes'+i).value;
  if (mins != '') {
   if (mins.substr(0, 1) == '0') mins = mins.substring(1);
   total_mins += parseInt(mins);
  }
 }
 total_price = price * total_mins;
 total_price = total_price.toFixed(2);
 if (total_price > 0) {
  document.getElementById('checkout').innerHTML = '<p>' + total_mins + ' minutes @<br />' + symbol + price + ' per min</p>';
  document.getElementById('total').innerHTML = '<p><strong>' + symbol + total_price + '</strong></p>';
  document.getElementById('price').value = total_price;
 }
}

function validate() {
 if (document.getElementById('price').value == "0") {
  alert("You must upload at least 1 file and enter the minutes!");
  return false;
 }
 else if (!isValidEmail(document.getElementById('email').value)) {
  alert("Please enter a valid email address!");
  document.getElementById('email').focus();
  return false;
 }
 else {
  document.getElementById('hidepricing').style.display = 'none';
  document.getElementById('loading').style.display = '';
  return true;
 }
}

function isValidEmail(str) {
 return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}


function onProceedCheckout()
{
 var terms = null;
 if (document.all)
 {
	terms = document.all.acceptterms;
 }
 else 
 {
	terms = document.getElementById("acceptterms");
 }
 if (terms) 
 {
	if (!terms.checked)
	{
		alert("You must accept the Subscriber Terms before proceeding");
		return (false);
	}
	else
	{
		document.secpayform.submit();
	}
 }
}