<!--
// copyright 1999-2001 Idocs, Inc. http://www.idocs.com/tags/
// Distribute this script freely, but keep this 
// notice with the code.
var submitRolls = new Object();

function submitroll(src, oversrc, name)
{
this.src=src;
this.oversrc=oversrc;
this.name=name;
this.alt="";
this.write=submitroll_write;
}

function submitroll_write()
{
var thisform = 'document.forms[' + (document.forms.length - 1) + ']';
submitRolls[this.name] = new Object();
submitRolls[this.name].over = new Image();
submitRolls[this.name].over.src = this.oversrc;
submitRolls[this.name].out = new Image();
submitRolls[this.name].out.src = this.src;

document.write
	(
	'<A onMouseOver="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].over.src"' + 
	' onMouseOut="if (document.images)document.images[\'' + this.name + "'].src=submitRolls['" + this.name + '\'].out.src"' +
	' HREF="javascript:'
	
	);

if (this.sendfield)
	{
	if (! this.sendvalue)
		this.sendvalue = 1;
	document.write(thisform, ".elements['", this.sendfield, "'].value='", this.sendvalue, "';");
	}


if(this.name == 'validateForm'){
//means form must be validated 
// from to be checked must have the following:
/*
<form name="frmCheckMe" etc
<input name="alertMessage" id="alertMessage" type="hidden" value="'.$LformErrorMessage.'">
<span class="p_sml_black" style="color: #FF0000" id="spanError" name="spanError">
*/
//
document.write('checkForm(this);"');
} else {
// simple rollover submit button, no form verification needed
document.write(thisform + '.submit();void(0);"');
}

if (this.msg)document.write(' onClick="return confirm(\'' , this.msg, '\')"');
document.write('>');

document.write('<IMG SRC="' + this.src + '" ALT="' + this.alt + '" BORDER=0 NAME="' + this.name + '"');
if (this.height)document.write(' HEIGHT=' + this.height);
if (this.width)document.write(' WIDTH='  + this.width);
if (this.otheratts)document.write(' ' + this.otheratts);
document.write('></A>');
if (this.sendfield)
	{
	document.write('<INPUT TYPE=HIDDEN NAME="' + this.sendfield + '">');
	document.forms[document.forms.length - 1].elements[this.sendfield].value='';
	}
}

//-->


function checkRequired(frmData) { 
  var bFail; 
  bFail = false; // Default to pass 


  for(iElement = 0; iElement < frmData.elements.length; iElement++) { 

    if(frmData.elements[iElement].className == 'RequiredTextBox' || 
       frmData.elements[iElement].className == 'FailedTextBox') { 
		
		
      
	  if(frmData.elements[iElement].value == '') { 
        bFail = true; 
        frmData.elements[iElement].className = 'FailedTextBox';

      } else { 

        frmData.elements[iElement].className = 'RequiredTextBox'; 

      } 
	 

    } 
	    if(frmData.elements[iElement].className == 'RequiredTextArea' || 
       frmData.elements[iElement].className == 'FailedTextArea') { 
		
		
      
	  if(frmData.elements[iElement].value == '') { 
        bFail = true; 
        frmData.elements[iElement].className = 'FailedTextArea';

      } else { 

        frmData.elements[iElement].className = 'RequiredTextArea'; 

      } 
	 

    } 
	
	
	
	

  } 
 	if(bFail){ 
	alert(document.getElementById('alertMessage').value);}
  return !bFail; 

} 

function checkForm() { 
  if(!checkRequired(document.forms['frmCheckMe'])) { 

    if(document.all) { 
      document.all.spanError.innerText = document.getElementById('alertMessage').value; 
    } else { 
      document.getElementById('spanError').innerHTML = document.getElementById('alertMessage').value; 
    } 
  } else { 
    document.forms['frmCheckMe'].submit();   
  } 
}



function checkEmail(emField,eMailFailMessage){ //reference to email field passed as argument
var fieldValue = emField.value // store field's entire value in variable

// Begin Valid Email Address Tests
//if field is not empty
if(fieldValue != ""){
var atSymbol = 0

//loop through field value string
for(var a = 0; a < fieldValue.length; a++){

//look for @ symbol and for each @ found, increment atSymbol variable by 1
if(fieldValue.charAt(a) == "@"){
atSymbol++
}
}

// if more than 1 @ symbol exists
if(atSymbol > 1){
// then cancel and don't submit form
alert(eMailFailMessage)
return false
}

// if 1 @ symbol was found, and it is not the 1st character in string
if(atSymbol == 1 && fieldValue.charAt(0) != "@"){
//look for period at 2nd character after @ symbol
var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2)

// "." immediately following 1st "." ?
var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false

//if period was not found OR 2 periods together OR field contains less than 5 characters OR period is in last position
if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
// then cancel and don't submit form
alert(eMailFailMessage)
return false
}

}
// no @ symbol exists or it is in position 0 (the first character of the field)
else{
// then cancel and don't submit form
alert(eMailFailMessage)
return false
}
}
// if field is empty
else{
// then cancel and don't submit form
alert(eMailFailMessage)
return false
}

//all tests passed, submit form
return true
}