// Created by: Will Bontrager :: http://www.willmaster.com/
function FillBilling(f) {
  if(f.billingtoo.checked == true) {
    f.Sample.value = f.website.value;
  }
}

// =========  Counter for textarea box

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit)
  field.value = field.value.substring(0, maxlimit);
  // otherwise, update 'characters left' counter
  else
  countfield.value = maxlimit - field.value.length;
}

// =========  Check form fields

function checkFields() {
  with (document.contribform) {
    if (realname.value=="") {
      alert("Please enter your name and re-submit.");
      realname.select(); realname.focus(); return false;
    } else if (email.value=="") {
      alert("Please enter your e-mail address and re-submit.");
      email.select(); email.focus(); return false;
    } else if (website.value=="http://") {
      alert("Please enter your Web site's address (URL) and re-submit.");
      website.select(); website.focus(); return false;
    } else if (website.value.indexOf('http://http://')>-1) {
      alert("Oops! It looks like there is more than one 'http://' in your Web site URL.\nPlease check and re-enter your Web site's URL if necessary then re-submit.");
      website.select(); website.focus(); return false;
    } else if (script_name.value=="") {
      alert("Please enter the name of the script you would like to contribute and re-submit.");
      script_name.select(); script_name.focus(); return false;
    } else if (script_category.options[script_category.selectedIndex].value == "") {
      alert("Please select a category for the script you would like to contribute and re-submit.");
      script_category.focus();
      return false;
    } else if (Sample.value == "http://") {
      alert("Please enter the Web address where you have uploaded the online\nexample of the script you would like to contribute and then re-submit.");
      Sample.select(); Sample.focus(); return false;
    } else if (Sample.value.indexOf('http://http://')>-1) {
      alert("Oops!  It looks like there is more than one 'http://' parts in your sample URL.\nPlease check and re-enter your sample URL if necessary then re-submit.");
      Sample.select(); Sample.focus(); return false;

    } else if (description.value.length == "") {
alert("Please enter a few sentences (between 50 and 500 characters)\nthat describe the script you are submitting.  This description will be\nconsidered for the actual script description we use if the script is \nadded to our script library.");
description.select(); description.focus(); return false;

    } else if (!agree.checked) {
      alert("You need to read the Terms and Conditions and then check the agreement box and re-submit.");
      agree.select(); website.focus(); return false;
    }
    subject.value = "Contribution:  " + script_name.value + "";
    return true;
  }
}


// ===================================
function popUp(winURL) {
  window.open(winURL,"popup","width=500,height=480,scrollbars=yes");
}

