// JavaScript Document

<!-- The following is used in the MARKETS section of this form-->

<!-- Begin
function checkAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function uncheckAll(field)
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}
//  End -->



function EnterFunc() {
	i=1
	i=i+++1 
	while (i < 11) {
	for (x = 1; x < 10; x++) { document.all['ROW'+i+'_' +x].style.display="none";
		}
		i++
	}
}

//Call all the functions****************

function onSubmitFunctions() {

  if (nameCheck() ==false) {
  return false; 
  }
  if (phoneCheck() ==false) {
  return false; 
  }
  if (emailCheck() ==false) {
  return false; 
  }
  if (companyNameCheck() ==false) {
  return false; 
  }  
  if (stateCheck() ==false) {
  return false; 
  }
  if (countryCheck() ==false) {
  return false; 
  }  
  if (prodCheck() ==false) {
  return false; 
  }
  if (SendIt() == false) { 
  return false; 
	} 
} 



//Enf of Call all the functions****************

function EnterFunc() {
	i=1
	i=i+++1 
	while (i < 11) {
	for (x = 1; x < 10; x++) { document.all['ROW'+i+'_' +x].style.display="none";
		}
		i++
	}
}

//Input field checks

function nameCheck() {
	var f=document.mailMe;
	if(f.Name.value=="") {
	alert("Please enter your name.");
	f.Name.focus();
	return false;
	}
} 

function companyNameCheck() {
	var f=document.mailMe;
	if(f.CompanyName.value=="") {
	alert("Please enter your Company name.");
	f.CompanyName.focus();
	return false;
	}
} 

function stateCheck() {
	var f=document.mailMe;
	var fn=f.State;
	var z=fn.selectedIndex;
  if(z==0) {
  alert("Please select a State/Province/Other from the drop down list.");
  fn.focus();
  return false;
	  }
}

function countryCheck() {
	var f=document.mailMe;
	var fn=f.Country;
	var z=fn.selectedIndex;
  if(z==0) {
  alert("Please select a Country from the drop down list.");
  fn.focus();
  return false;
	  }
}

function phoneCheck() {
	var f=document.mailMe;
	if(f.Phone.value=="") {
	alert("Please enter your phone number.");
	f.Phone.focus();
	return false;
	}
}

function emailCheck() {
	var f=document.mailMe;	
     var estr = new String(f.Email.value);
    var atindex = estr.indexOf("@");
     if(atindex ==-1){
         alert("You must enter a valid EMail Address.")
         f.Email.focus();
          return false;
	}
}

//End of INPUT Field Checks

//Radio Field Check*****

function LCYNCheck() {
	var f=document.mailMe;
	var fldVal;
	var isChecked;

isChecked = false;
fldVal = f.LightConsultantInPast.length;
for ( i = 0; i < fldVal; i++ ) {
if ( f.LightConsultantInPast[i].checked ) {
isChecked = true;
	}
}
if ( ! isChecked ) {
alert( 'Please let us know if you\'ve used a lighting consultant in the past.' );
f.LightConsultantInPast[0].focus();
return false;
	}
}

//End of Radio Field Check

//Checkbox Field Check

function prodCheck() {
var f=document.mailMe;
var fldVal;
var isChecked;

isChecked = false;
fldVal = f.Markets.length;
for ( i = 0; i < fldVal; i++ ) {
if ( f.Markets[i].checked ) {
isChecked = true;
	}
}
if ( ! isChecked ) {
alert( 'Please make a selection from the Market section.' );
f.Product_Line[0].focus();
return false;
	}
}

//End of Checkbox Field Check




function SendIt(){
var f=document.mailMe;
	f.submit();
	return false;
}
