

//________ begin checkers

// Check for email address look for [@] and [.]

function isEmail(elm) {
    if (elm.value.indexOf("@") + "" != "-1" &&
        elm.value.indexOf(".") + "" != "-1" &&
        elm.value != "")
    return true;
    else return false;
}

// Check for null and for empty

function isFilled(elm) {
    if (elm.value == "" ||
        elm.value == null)
    return false;
    else return true;
}

// Check to see if user has made a selection

function isChosen(elm) {
    if (elm.selectedIndex == "")
    return false;
    else return true;
}


// Check to see if user has selected NA

function isChosenNA(elm) {
    var choice = elm.selectedIndex;
    if (choice == "2"  || 
         choice == "1")
    return true;
    else return false;
}

// Check to see if user has selected CA

function isChosenCA(elm) {
    var choice = elm.selectedIndex;
    if (choice == "2" || choice == "39")
    return true;
    else return false;
}

// Check to see if user has selected CA prov

function isChosenCAProv(elm) {
    var provchoice = elm.selectedIndex;
    if (provchoice == "1" ||
     	provchoice == "2" ||
     	provchoice == "3" ||
     	provchoice == "4" ||
     	provchoice == "5" ||
     	provchoice == "6" ||
     	provchoice == "7" ||
     	provchoice == "8" ||
     	provchoice == "9" ||
     	provchoice == "10" ||
     	provchoice == "11" ||
        provchoice == "12")
    return true;
    else return false;
}



//________begin questions


function isReady(form) {


  // has a country been chosen ?

    if (isChosen(form.country_contact) == false) {
    alert("Please enter your Country by clicking-and-holding on the country drop-down menu.");
    form.city_contact.focus();
    return false;
    }

  // has a province/state been chosen ?

    if (isChosenNA(form.country_contact) == true &&
     	 isChosen(form.state_contact) == false) { 
      		alert("You have indicated that your country is the U.S. or Canada.  If this is correct, please indicate your state or province.  Or please change your country selection.");
     		 form.city_contact.focus();
     		 return false;
      		}
       
   // has a CA province been chosen ?

    if (isChosenCA(form.country_contact) == false &&
     	 isChosenCAProv(form.state_contact) == true) { 
      		alert("You have selected a Canadian province even though you have not chosen Canada as your country.  Please either choose Canada as your country, or change the state/province.");
     		form.city_contact.focus();
     		 return false;
      		}
       
   // has a CA province been chosen - other way round ?

    if (isChosenCA(form.country_contact) == true &&
     	 isChosenCAProv(form.state_contact) == false) { 
      		alert("You have selected Canada as your country, but have not chosen a Canadian province.  Please choose a province, or select a different country.");
     		 form.city_contact.focus();
     		 return false;
      		}       

	if (document.order_form.Sameas_Contact.checked==false) {

	// is Last_Name_pay element filled?

	if (isFilled(form.LastName_pay) == false) {
		alert("Please enter the name of the company that you would like us to pay, or please check the box indicating that you would like us to pay YOU personally.");
		form.LastName_pay.focus();
		return false;
	}
  
}

     // Redirect Page?

    if (isFilled(form.redirect_page_name) == false) {
    alert("Please specify the SINGLE word that you would like to use for your unique Referrer Redirect URL (RR URL).");
    form.redirect_page_name.focus();
    return false;
    }

	// Accept Agreement?
	if (document.order_form.Rejection.checked == false) {
		alert("Sorry, we cannot consider your application until you CERTIFY that you do not, and will not, use any marketing methods that would be cause for rejection of this application.  Please check the &quot;Yes, I so certify&quot; box.");
		return false;

	}
}



//Empties text fields if needed and makes them read-only
function emptyme(field) {
	if (document.order_form.Sameas_Contact.checked==true) {
			document.order_form.LastName_pay.value="";
	}
}
//Tells user that he doesn't have to fill out fields
//this option is unavailable in Netscape
function dunclick() {
	if (document.order_form.Sameas_Contact.checked==true){
		alert("You have indicated that we should pay You. If this is correct, please do not enter anything in field below. If you want us to pay a company, please uncheck this box, and fill in the exact company name below.");
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
