// JavaScript Document
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false;}
else {return true;}
}
}

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false;}
else {return true}
}
}

function validate_spam(field,alerttxt)
{
with (field)
{
if (value=="select"||value=="")
  {alert(alerttxt);return false;}
else {return true}
}
}

function validate_checkbox(field,alerttxt)
{
with (field)
{
if (field.checked == false)
  {alert(alerttxt);return false;}
else {return true}
}
}

function getSelectedOptionValue(element) {
    if (!element.options[element.selectedIndex]) {
        return false;
    }
    return element.options[element.selectedIndex].value;
}

function validate_select(field,alerttxt)
{
 if (getSelectedOptionValue(field)=="Select")
  {alert(alerttxt);return false;}
 return true;
}

function validate_form_contact(thisform)
{
with (thisform)
{
if (validate_required(name,"Please enter your name.")==false)
  {name.focus();return false;}
if (validate_email(email,"Please enter a valid email address.")==false)
  {email.focus();return false;}
if (validate_required(comment,"Please enter your comments.")==false)
  {comment.focus();return false;}
if (validate_spam(livecontrol,"Spam Control - Please select Confirm on the drop-down to continue")==false)
  {livecontrol.focus();return false;}
}
}

function validate_form(order)
{
with (order)
{
if (validate_required(first_name,"Please enter your Name.")==false)
   {first_name.focus();return false;}
if (validate_required(last_name,"Please enter your Last Name.")==false)
   {last_name.focus();return false;}
if (validate_required(address,"Please enter your Address.")==false)
   {address.focus();return false;}
if (validate_required(zip,"Please enter your ZIP Code.")==false)
   {zip.focus();return false;}
if (validate_email(email,"Please enter a valid email address.")==false)
   {email.focus();return false;}
if (validate_required(card_number,"Please enter the Credit Card Number.")==false)
   {card_number.focus();return false;}
if (validate_required(name_on_card,"Please enter the name printed on the Credit Card.'")==false)
   {name_on_card.focus();return false;}
if (validate_required(phone,"Please enter the Phone Number.'")==false)
   {phone.focus();return false;}
if (validate_checkbox(terms_conditions,"If you read the Term & Conditions, please click on the checkbox, and click Submit.'")==false)
   {terms_conditions.focus();return false;}
}
}

function validate_form_textlink(textlink)
{
with (textlink)
{
if (validate_required(name,"Please enter your Name.")==false)
   {name.focus();return false;}
if (validate_email(email,"Please enter a valid email address.")==false)
   {email.focus();return false;}
if (validate_required(url,"Please enter the website address.")==false)
   {url.focus();return false;}
}
}

function validate_form_ppc(ppc)
{
with (ppc)
{
if (validate_select(ppcplan,"Please select the PPC Plan you are interested in.")==false)
   {ppcplan.focus();return false;}
if (validate_required(name,"Please enter your Name.")==false)
   {name.focus();return false;}
if (validate_email(email,"Please enter a valid email address.")==false)
   {email.focus();return false;}
if (validate_required(url,"Please enter the website address.")==false)
   {url.focus();return false;}
}
}

function validate_form_adonnetwork(adonnetwork)
{
with (adonnetwork)
{
if (validate_select(adonnetworkservice,"Please select the Power Network Service you are interested in.")==false)
   {adonnetworkservice.focus();return false;}
if (validate_required(name,"Please enter your Name.")==false)
   {name.focus();return false;}
if (validate_email(email,"Please enter a valid email address.")==false)
   {email.focus();return false;}
if (validate_required(url,"Please enter the website address.")==false)
   {url.focus();return false;}
}
}

function validate_form_trial(trial)
{
with (trial)
{
if (validate_required(name,"Please enter your Name.")==false)
   {name.focus();return false;}
if (validate_email(email,"Please enter a valid email address.")==false)
   {email.focus();return false;}
if (validate_required(login,"Please enter the desired Login (A-Z | 0-9).")==false)
   {login.focus();return false;}
if (validate_required(password,"Please enter the desired Password (A-Z | 0-9).")==false)
   {password.focus();return false;}
}
}

function validate_trial(trial)
{
with (trial)
{
if (validate_required(name,"Please enter the Name.")==false)
   {name.focus();return false;}
if (validate_email(email,"Please enter a valid email address.")==false)
   {email.focus();return false;}
if (validate_required(login,"Please enter the desired Login (A-Z | 0-9).")==false)
   {login.focus();return false;}
if (validate_required(password,"Please enter the desired Password (A-Z | 0-9).")==false)
   {password.focus();return false;}
if (validate_required(trial_number,"Please enter the Trial Cart number.")==false)
   {trial_number.focus();return false;}
if (validate_select(sales_person,"Please select the sales person.")==false)
   {sales_person.focus();return false;}
}
}
