
function checkfields() {
        var strcompanyname;
        var strcontact;
        var straddress;
        var strcity;
        var strstate;
        var strzipcode;
        var strcountry;
        var strphone;
        var strfax;
        var stremail;
        var strwebsite;
        var stryears;
        var strlocations;
        var strapproximatesales;
        var strvalidationpic;
        var error=false;
        var msg="";
        
        strcompanyname=window.document.partner.companyname.value;
        strcontact=window.document.partner.primarycontact.value;
        straddress=window.document.partner.address.value;
        strcity=window.document.partner.city.value;
        strstate=window.document.partner.state.value;
        strzipcode=window.document.partner.zipcode.value;
        strcountry=window.document.partner.country.value;
        strphone=window.document.partner.phone.value;
        strfax=window.document.partner.fax.value;
        stremail=window.document.partner.email.value;
        strwebsite=window.document.partner.website.value;
        stryears=window.document.partner.years.value;
        strlocations=window.document.partner.locations.value;
        strapproximatesales=window.document.partner.approximatesales.value;
        strvalidationpic=window.document.partner.validationpic.value;
        strpicnumber=window.document.partner.picnumber.value;
        
        if (strcompanyname=="") {
                msg="Please provide your company name.\n"
                error=true;
        }
        
        if (strcontact=="") {
                msg = msg +"Please provide us with the primary contact name.\n";
                error=true;
        }
        
        if (straddress=="") {
                        msg = msg +"Please provide us with an address.\n";
                        error=true;
        }
        
        if (strcity=="") {
                        msg = msg +"Please provide us with the city.\n";
                        error=true;
        }
        
        if (strstate=="") {
                        msg = msg +"Please provide us with your state.\n";
                        error=true;
        }
        
        if (strzipcode=="") {
                        msg = msg +"Please provide us with your zipcode.\n";
                        error=true;
        }
        
        if (strcountry=="") {
                        msg = msg +"Please provide us with your country.\n";
                        error=true;
        }
        
        if (strphone=="") {
                        msg = msg +"Please provide us with your phone number.\n";
                        error=true;
        }
        
        if (strfax=="") {
                        msg = msg +"Please provide us with your fax number.\n";
                        error=true;
        }
        
        if (stremail=="") {
                        msg = msg +"Please provide us with your email address.\n";
                        error=true;
        }
        
        else if(!EmailIsValid(stremail)){
                msg = msg + "Please enter in a valid email address.\n";
                error = true;
        }
        
        if (strwebsite=="") {
                        msg = msg +"Please provide us with your website address.\n";
                        error=true;
        }
        
        if (stryears=="") {
                        msg = msg +"Please provide your years in business.\n";
                        error=true;
        }
        
        if (strlocations=="") {
                        msg = msg +"Please provide the number of locations.\n";
                        error=true;
        }
        
        if (strapproximatesales=="") {
                        msg = msg +"Please provide us with an approximate sales amount.\n";
                        error=true;
        }
        
        if(strpicnumber=="1" && strvalidationpic != "pictures") {
          msg = msg +"Please type the correct characters before submitting\n";
          error=true;
        }
        
        if(strpicnumber=="2" && strvalidationpic != "tooth") {
          msg = msg +"Please type the correct characters before submitting\n";
          error=true;
        }
          
        if(strpicnumber=="3" && strvalidationpic != "outlet") {
          msg = msg +"Please type the correct characters before submitting\n";
          error=true;
        }
        
        if(strpicnumber=="4" && strvalidationpic != "gigabyte") {
          msg = msg +"Please type the correct characters before submitting\n";
          error=true;
        }
        
        if(strpicnumber=="5" && strvalidationpic != "story") {
          msg = msg +"Please type the correct characters before submitting\n";
          error=true;
        }
        
        if(strpicnumber=="6" && strvalidationpic != "vendor") {
          msg = msg +"Please type the correct characters before submitting\n";
          error=true;
        }
        
        if(strpicnumber=="7" && strvalidationpic != "change") {
          msg = msg +"Please type the correct characters before submitting\n";
          error=true;
        }
        
        if(strpicnumber=="8" && strvalidationpic != "confidence") {
          msg = msg +"Please type the correct characters before submitting\n";
          error=true;
        }
        
        if(strpicnumber=="9" && strvalidationpic != "newsletter") {
            msg = msg +"Please type the correct characters before submitting\n";
            error=true;
        }
        
        if(strpicnumber=="10" && strvalidationpic != "style") {
            msg = msg +"Please type the correct characters before submitting\n";
            error=true;
        }
        
        if(strpicnumber=="11" && strvalidationpic != "apartment") {
            msg = msg +"Please type the correct characters before submitting\n";
            error=true;
        }
        
        if(strpicnumber=="12" && strvalidationpic != "greeting") {
            msg = msg +"Please type the correct characters before submitting\n";
            error=true;
        }
        
        if(strpicnumber=="13" && strvalidationpic != "ranking") {
            msg = msg +"Please type the correct characters before submitting\n";
            error=true;
        }
        
        if (error==true) {
                        alert(msg);
                        return false;
        }
        return true;
}

function EmailIsValid(checkThisEmail)
{
var myEMailIsValid = true;
var myAtSymbolAt = checkThisEmail.indexOf('@');
var myLastDotAt = checkThisEmail.lastIndexOf('.');
var mySpaceAt = checkThisEmail.indexOf(' ');
var myLength = checkThisEmail.length;


// at least one @ must be present and not before position 2
// @yellow.com : NOT valid
// x@yellow.com : VALID

if (myAtSymbolAt < 1 )
 {myEMailIsValid = false}


// at least one . (dot) afer the @ is required
// x@yellow : NOT valid
// x.y@yellow : NOT valid
// x@yellow.org : VALID

if (myLastDotAt < myAtSymbolAt)
 {myEMailIsValid = false}

// at least two characters [com, uk, fr, ...] must occur after the last . (dot)
// x.y@yellow. : NOT valid
// x.y@yellow.a : NOT valid
// x.y@yellow.ca : VALID

if (myLength - myLastDotAt <= 2)
 {myEMailIsValid = false}


// no empty space " " is permitted (one may trim the email)
// x.y@yell ow.com : NOT valid

if (mySpaceAt != -1)
 {myEMailIsValid = false}

return myEMailIsValid;
}

function displayFormPic() {
  var theTime = new Date();
  var sec = theTime.getSeconds();
  
  var pic = (sec % 13) + 1;
  
  document.write("<img src='Images/" + pic + ".jpg' width='100'><input type='hidden' name='picnumber' id='picnumber' value='" + pic + "'>");
}

function displayProductPic(picName, picNumber, idNumber) {
  //alert ("<img src='Images/" + picName + picNumber + ".jpg'>"); 
  
  document.getElementById(picName + idNumber).innerHTML="<a href='Images/" + picName + picNumber + "bg.jpg' target='_blank'><img src='Images/" + picName + picNumber + ".jpg'></a>";
}