objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++)
{
    objects[i].outerHTML = objects[i].outerHTML;
}

function validateOrderInput(formObj)
{
  var bpaypalorder = GetComboIndex(document.order.billing_type) != 3;

  if (emptyField(formObj.licensequantity)) {
    formObj.licensequantity.focus();
    alert("Please specify the number of licenses");
  } else if (emptyField(formObj.domain)) {
    formObj.domain.focus();
    alert("Please specify your Server Hostname");
  } else if (emptyField(formObj.serverip)) {
    formObj.serverip.focus();
    alert("Please specify your cPanel server IP Address");
  } else if (emptyField(formObj.first_name)) {
    formObj.first_name.focus();
    alert("Please enter First Name");
  } else if (emptyField(formObj.last_name)) {
    formObj.last_name.focus();
    alert("Please enter Last Name");
  } else if (!validEmail(formObj.email)) {
    formObj.email.focus();
    alert("Please specify your contact E-Mail");
  } else if (emptyField(formObj.contact_phone)) {
    formObj.contact_phone.focus();
    alert("Please specify your Contact Phone number");
  } else if (emptyField(formObj.card_holder) && bpaypalorder) {
    formObj.card_holder.focus();
    alert("Please specify Card Holder Name");
  } else if (emptyField(formObj.card_number) && bpaypalorder) {
    formObj.card_number.focus();
    alert("Please specify Credit Card Number");
  } else if (!formObj.expiration_month.disabled && emptyField(formObj.expiration_month) && bpaypalorder) {
    formObj.expiration_month.focus();
    alert("Please specify expiration date");
  } else if (!formObj.expiration_year.disabled && emptyField(formObj.expiration_year) && bpaypalorder) {
    formObj.expiration_year.focus();
    alert("Please specify expiration date");
  } else if (!formObj.card_security_code.disabled && emptyField(formObj.card_security_code) && bpaypalorder) {
    formObj.card_security_code.focus();
    alert("Please specify security code");
  } else if (!formObj.billing_password.disabled && emptyField(formObj.billing_password)) {
    formObj.billing_password.focus();
    alert("Please specify your Billing Password");
  } else if (!formObj.confirm_billing_password.disabled && formObj.billing_password.value != formObj.confirm_billing_password.value ) {
    formObj.billing_password.value = '';
    formObj.confirm_billing_password.value = '';
    formObj.billing_password.focus();
    alert("The billing password does not match.");
  } else if (emptyField(formObj.street_address)) {
    formObj.street_address.focus();
    alert("Please specify your Address");
  } else if (emptyField(formObj.city)) {
    formObj.city.focus();
    alert("Please specify your City");
  } else if (emptyField(formObj.state)) {
    formObj.state.focus();
    alert("Please specify your State");
  } else if (emptyField(formObj.country)) {
    formObj.country.focus();
    alert("Please specify your Country");
  } else if (emptyField(formObj.zip_code)) {
    formObj.zip_code.focus();
    alert("Please enter Zip Code");
  } else return true;

  return false;
}


function validateSupportFormInput()
{
  var formObj = document.submit;

  if (emptyField(formObj.name)) {
    formObj.name.focus();
    alert("Please enter your Name");
  } else if (!validEmail(formObj.email)) {
    formObj.email.focus();
    alert("Please specify your valid contact E-mail");
  } else if (emptyField(formObj.message)) {
    formObj.message.focus();
    alert("Please submit your request.");
  } else {
    document.getElementById('support_form').submit();
  }

  return false;
}

function validEmail(textObj)
{
	if (emptyField(textObj) || textObj.value.indexOf('@', 0) == -1) {
		return false;
	}
	return true;
}

function emptyField(textObj)
{
     if (textObj.value.length == 0) return true;
     for (var i=0; i<textObj.value.length; ++i) {
          var ch = textObj.value.charAt(i);
          if (ch != ' ' && ch != '\t') return false;
     }
     return true;
}

function validateLicensesInput(licenseQuantity)
{
  var i;
  if (document.licenses.nextstep.value > 1)
  {
  for (i = 2; i <= licenseQuantity; i++)
  {
    if (emptyField(document.licenses['ipaddress'+i]))
    {
      document.licenses['ipaddress'+i].focus();
      alert("Please specify the IP Address " + i);
      return false;
    } 
  }
  }

  return true;
}

function validateCancelInput(formObj)
{
  if (emptyField(formObj.first_name)) {
    formObj.first_name.focus();
    alert("Please enter your First Name");
  } else if (emptyField(formObj.last_name)) {
    formObj.last_name.focus();
    alert("Please enter your Last Name");
  } else if (!validEmail(formObj.email)) {
    formObj.email.focus();
    alert("Please specify your valid contact E-mail");
  } else if (emptyField(formObj.serverip)) {
    formObj.serverip.focus();
    alert("Please specify your Server IP Address.");
  } else if (emptyField(formObj.billing_password)) {
    formObj.billing_password.focus();
    alert("Please specify your Billing Password");
  } else if (formObj.billing_password.value != formObj.confirm_billing_password.value ) {
    formObj.billing_password.value = '';
    formObj.confirm_billing_password.value = '';
    formObj.billing_password.focus();
    alert("The billing password does not match.");
  } else return true;

  return false;
}

function validateChangeIPInput(formObj)
{
  if (emptyField(formObj.first_name)) {
    formObj.first_name.focus();
    alert("Please enter your First Name");
  } else if (emptyField(formObj.last_name)) {
    formObj.last_name.focus();
    alert("Please enter your Last Name");
  } else if (!validEmail(formObj.email)) {
    formObj.email.focus();
    alert("Please specify your valid contact E-mail");
  } else if (emptyField(formObj.currentip)) {
    formObj.currentip.focus();
    alert("Please specify your Current IP Address.");
  } else if (emptyField(formObj.newip)) {
    formObj.newip.focus();
    alert("Please enter your New IP Address.");
  } else if (emptyField(formObj.billing_password)) {
    formObj.billing_password.focus();
    alert("Please specify your Billing Password");
  } else if (formObj.billing_password.value != formObj.confirm_billing_password.value ) {
    formObj.billing_password.value = '';
    formObj.confirm_billing_password.value = '';
    formObj.billing_password.focus();
    alert("The billing password does not match.");
  } else return true;

  return false;
}

function validateTrialInput(formObj)
{
  if (emptyField(formObj.first_name)) {
    formObj.first_name.focus();
    alert("Please enter your First Name");
  } else if (emptyField(formObj.last_name)) {
    formObj.last_name.focus();
    alert("Please enter your Last Name");
  } else if (!validEmail(formObj.email)) {
    formObj.email.focus();
    alert("Please specify your valid contact E-mail");
  } else if (emptyField(formObj.domain)) {
    formObj.domain.focus();
    alert("Please specify your Server Hostname.");
  } else if (emptyField(formObj.serverip)) {
    formObj.serverip.focus();
    alert("Please enter your Server IP Address.");
  } else return true;

  return false;
}

function validateRequestInstallInput(formObj)
{
  if (emptyField(formObj.first_name)) {
    formObj.first_name.focus();
    alert("Please enter your First Name");
  } else if (emptyField(formObj.last_name)) {
    formObj.last_name.focus();
    alert("Please enter your Last Name");
  } else if (!validEmail(formObj.email)) {
    formObj.email.focus();
    alert("Please specify your valid contact E-mail");
  } else if (emptyField(formObj.serverip)) {
    formObj.serverip.focus();
    alert("Please specify your Server IP Address.");
  } else if (emptyField(formObj.root_login)) {
    formObj.root_login.focus();
    alert("Please submit your Root Login.");
  } else if (emptyField(formObj.root_password)) {
    formObj.root_password.focus();
    alert("Please submit your Root Password.");
  } else if (formObj.root_password.value != formObj.confirm_password.value ) {
    formObj.root_password.value = '';
    formObj.confirm_password.value = '';
    formObj.root_password.focus();
    alert("The password does not match.");
  } else if (emptyField(formObj.billing_password)) {
    formObj.billing_password.focus();
    alert("Please specify your Billing Password");
  } else if (formObj.billing_password.value != formObj.confirm_billing_password.value ) {
    formObj.billing_password.value = '';
    formObj.confirm_billing_password.value = '';
    formObj.billing_password.focus();
    alert("The billing password does not match.");
  } else return true;

  return false;
}

var bV=parseInt(navigator.appVersion);
var IE4 = ((document.all) && (bV >= 4)) ? true : false;
var NS4 = (document.layers) ? true : false;
var strVisible = IE4 ? 'visible':'show';
var strInvisible = IE4 ? 'hidden':'hide';


function ShowElement(elem, bVisible)
{  
  var ctrl = null;

  if (NS4)
  {
    ctrl = document.layers ['' + elem];
  } else
  {
    ctrl = document.getElementById(elem).style;
  }

  if (ctrl) 
  {
    ctrl.display = bVisible ? "" : "none";
  }
}

function GetComboIndex(element)
{
  if (element && (element.length > 0))
    for (var i = 0; i < element.length; i++)
      if (element[i].selected)
        return i;
  return -1;
}

function GetComboValue(element)
{
  if (element && (element.length > 0))
    for (var i = 0; i < element.length; i++)
      if (element[i].selected)
        return element[i].text;
  return '';
}