function web2lead(mode){
	// FORM ELEMENTS
	var txtFirstName = document.getElementById('txtFirstName');
	var txtLastName = document.getElementById('txtLastName');
	var txtEmail = document.getElementById('txtEmail');
	var txtOperatingSystem = document.getElementById('txtOperatingSystem');
	var txtBrowser = document.getElementById('txtBrowser');
	var txtSchool = document.getElementById('txtSchool');
	var txtDistrict = document.getElementById('txtDistrict');
	var txtCity = document.getElementById('txtCity');
	var txtState = document.getElementById('ddlState');
	var txtQuestions = document.getElementById('txtQuestions');
	var error = false;
	var errormessage = document.getElementById('errormessage');

	// VALIDATE
	if(mode == 'validate'){
		
		if(txtFirstName.value == null || txtFirstName.value == ''){
			error = true;
		}
		if(txtLastName.value == null || txtLastName.value == ''){
			error = true;
		}
		if(txtEmail.value == null || txtEmail.value == ''){
			error = true;
		}
		//if(txtOperatingSystem.value == null || txtOperatingSystem.value == ''){
		//	error = true;
		//}
		//if(txtBrowser.value == null || txtBrowser.value == ''){
		//	error = true;
		//}
		if(txtSchool.value == null || txtSchool.value == ''){
			error = true;
		}
		if(txtDistrict.value == null || txtDistrict.value == ''){
			error = true;
		}
		if(txtCity.value == null || txtCity.value == ''){
			error = true;
		}
		if(txtQuestions.value == null || txtQuestions.value == ''){
			error = true;
		}
		if(ddlState.selectedIndex == 0){
			error = true;
		}
		if(error){
			errormessage.innerHTML = '<strong>ERROR</strong>: Fill in required fields and resubmit.';	
			//window.scroll(0,0);
			window.scroll(0,400);
			//window.scrollByLines(-15);
		}
		else {
			//document.leadform.submit();
			SendEmail(txtFirstName.value,txtLastName.value,txtEmail.value,txtOperatingSystem.value,txtBrowser.value,txtSchool.value,txtDistrict.value,txtCity.value,txtState.value,txtQuestions.value);
			document.getElementById('buttonSubmit').disabled = 'disabled';
		}
	}
	// RESET
	if(mode == 'reset'){
		document.leadform.reset();
	}
}

function SendEmail(txtFirstName,txtLastName,txtEmail,txtOperatingSystem,txtBrowser,txtSchool,txtDistrict,txtCity,txtState,txtQuestions)
{

var xmlhttp;

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtMessage").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("POST","/form/sendemail.php?txtFirstName="+txtFirstName+"&txtLastName="+txtLastName+"&txtEmail="+txtEmail+"&txtOperatingSystem="+txtOperatingSystem+"&txtBrowser="+txtBrowser+"&txtSchool="+txtSchool+"&txtDistrict="+txtDistrict+"&txtCity="+txtCity+"&txtState="+txtState+"&txtQuestions="+txtQuestions,true);
xmlhttp.send();
}



function PageSetup()
{
//
// Bold nagivation page & Update Title
//
var tmp=location.pathname
var tmp2 = tmp.substring(tmp.indexOf("/")+1,tmp.length)
var tmp3 = tmp.indexOf('news')

tmp2.toLowerCase()

//alert(" URL is " + tmp);
//alert(" Webpage is " + tmp2);
//alert(" tmp3 is " + tmp3);

 if (tmp2 == "index.php")
 {
  document.title = "Pearson Perspective - Home";
 }
 else if (tmp2 == "experience.php")
 {
  document.title = "Pearson Perspective - Experience";
 }
 else if (tmp2 == "understand.php")
 {
  document.title = "Pearson Perspective - Understand"; 
 }
 else if (tmp2 == "connect.php")
 {
  document.title = "Pearson Perspective - Connect"; 
 }
 else if (tmp2 == "about.php")
 {
  document.title = "Pearson Perspective - About"; 
 }
 else if (tmp2 == "news.php")
 {
  document.title = "Pearson Perspective - News Releases"; 
 }
 else if (tmp2 == "additionalfeatures.php")
 {
  document.title = "Pearson Perspective - Additional Features"; 
 }
 else if (tmp2 == "contact.php")
 {
  document.title = "Pearson Perspective - Contact Us"; 
 }
 else if (tmp2 == "keyfeatures.php")
 {
  document.title = "Pearson Perspective - Key Features"; 
 }
 else if (tmp2 == "learninglocator.php")
 {
  document.title = "Pearson Perspective - Learning Locator"; 
 }
 else if (tmp2 == "overview.php")
 {
  document.title = "Pearson Perspective - Overview"; 
 }
 else if (tmp2 == "studyguides.php")
 {
  document.title = "Pearson Perspective - Study Guides"; 
 }
 else if (tmp2 == "understandscoring.php")
 {
  document.title = "Pearson Perspective - Understand Scoring"; 
 }
 else if (tmp2 == "resouces.php")
 {
  document.title = "Pearson Perspective - Resouces"; 
 }
 else if (tmp3 > 0)
 {
  document.title = "Pearson Perspective - News Release";
 }
 else if (tmp2 == "")
 {
  document.title = "Pearson Perspective - Home";
 }
}

function rotateImages() 
{

var oCurPhoto = $('#fboxrotate div.current');
var oNxtPhoto = oCurPhoto.next();

	if (oNxtPhoto.length == 0)
		oNxtPhoto = $('#fboxrotate div:first');

        oCurPhoto.removeClass('current').addClass('previous');
        oNxtPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity: 1.0 }, 1000,

        function() 
        {
        	oCurPhoto.removeClass('previous');
        }
        );
}
