function toFavorites(uid,pid,uname,sid,state){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	} // if
	if(state == 'add') var theUrl = "scripts/addtofavorites.php";
	else var theUrl = "scripts/removefromfavorites.php";
	theUrl = theUrl+"?uid="+urlEncode(uid);
	theUrl = theUrl+"&pid="+urlEncode(pid);
	theUrl = theUrl+"&uname="+urlEncode(uname);
	theUrl = theUrl+"&sid="+urlEncode(sid);
	xmlHttp.onreadystatechange = programFormStateChanged;
	xmlHttp.open("GET",theUrl,true);
	xmlHttp.send(null);
//	alert('yo'+uid+pid+uname+sid);
} // function



function programFormStateChanged(){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
		var theReturn = xmlHttp.responseText;
		//var stringVals = longString.split('|');
		// document.programform.'program'+favprogram.value = checked;
		// alert(theReturn);
	} // if
} // function



function add2Hidden(thisinput,thatinput){
var ip1 = document.getElementById(thisinput);
var ip2 = document.getElementById(thatinput);
var ip1content = ip1.name+'~'+ip1.value+'|';
var ip2content = ip2.value;
ip2.value = ip2content+ip1content;
}



function checkPPForm(){
var firstNameInput=document.getElementById('fname');
var lastNameInput=document.getElementById('lname');
var schoolInput=document.getElementById('school');
var ageInput=document.getElementById('age');
var refererInput=document.getElementById('ref');
var referer2Input=document.getElementById('ref2');
var emailInput = document.getElementById('email');
var pwInput = document.getElementById('pw');
var cpwInput = document.getElementById('cpw');
var alertText = '';
if(pwInput.value !=cpwInput.value) alertText = 'your two passwords are not the same\r\n';
if(pwValidation(pwInput.value) !=true) alertText = 'password must be at least 6 characters, no more than 33, letters and numbers only\r\n';
if(emailValidation(emailInput.value) !=true) alertText = 'please provide us with a valid email address\r\n';
if(!refererInput.value && !referer2Input.value) alertText = 'please let us know how you heard about us\r\n';
if(!schoolInput.value) alertText = 'please tell us the name of your school\r\n';
if(!ageInput.value) alertText = 'please tell us your age\r\n';
if(!lastNameInput.value) alertText = 'please tell us your last name\r\n';
if(!firstNameInput.value) alertText = 'please tell us your first name\r\n';
if(alertText) alert(alertText); else document.getElementById('applyPart1').submit();
}



function emailValidation(thetext){
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(thetext.match(emailExp)) return true; else return false;
}

function pwValidation(thetext){
var pwExp = /^[a-zA-z0-9]{6,33}$/;
if(thetext.match(pwExp)) return true; else return false;
}
