///////////////////////////////////////////
function workshopValidator(theForm)
///////////////////////////////////////////
{	  	
	if(!isStudentIDValid(theForm)) return false;
	if(!validateFirstName(theForm)) return false;
	if(!validateLastName(theForm)) return false;
	return true;
}
///////////////////////////////////////////
function resolveSessionID()
///////////////////////////////////////////
{
	//get the session id from the URL
	var urlquery=location.href.split("?");
	if(urlquery.length > 1)	
	{
		var pair1=urlquery[1].split("=");
		this.sessionID=pair1[1];
	}
}
///////////////////////////////////////////	
function getSessionData()
///////////////////////////////////////////
{
	sessionCookie = new Cookie(document, "RCC_Workshop_Session");
	if(!sessionCookie.load())
	{
		window.location = 'index.html';
	}
	if(sessionCookie.sessionID && (sessionCookie.sessionID == this.sessionID))
	{
		if(sessionCookie.sid) 
		{
			this.sid = sessionCookie.sid;
		}
		if(sessionCookie.fname) 
		{
			this.fname = sessionCookie.fname;
		}
		if(sessionCookie.lname) 
		{
			this.lname = sessionCookie.lname;
		}
		if(sessionCookie.p) 
		{
			if(new Number(sessionCookie.p).valueOf()+1 != this.p)
			{
				window.location = 'index.html';
			}
		}
		sessionCookie.remove();
	}
	else
	{
		sessionCookie.remove();
		window.location = 'index.html';
	}
}
///////////////////////////////////////////	
function getFormData()
///////////////////////////////////////////
{

	if(sessionCookie.sessionID && (sessionCookie.sessionID == this.sessionID))
	{
		if(sessionCookie.goal) 
		{
			this.goal = sessionCookie.goal;
		}
		if(sessionCookie.major) 
		{
			this.major = sessionCookie.major;
		}
		if(sessionCookie.whours) 
		{
			this.whours = sessionCookie.whours;
		}
	}
}

///////////////////////////////////////////	
function getStatusData()
///////////////////////////////////////////
{
	if(sessionCookie.sessionID && (sessionCookie.sessionID == this.sessionID))
	{
		if(sessionCookie.status) 
		{
			this.status = sessionCookie.status;
		}
	}
}

///////////////////////////////////////////	
function getPlanData()
///////////////////////////////////////////
{
	if(sessionCookie.sessionID && (sessionCookie.sessionID == this.sessionID))
	{
		if(sessionCookie.plan) 
		{
			this.plan = sessionCookie.plan;
		}
	}
}



///////////////////////////////////////////
function isRadioChecked(radioGroup)
///////////////////////////////////////////
{	
	for (i = 0;  i < radioGroup.length;  i++)
	{
		if(radioGroup[i].checked == true)
		{
			return true;
		}
	}
	return false;
}


///////////////////////////////////////////
function checkstate1(theForm)
///////////////////////////////////////////
{
	if(!isRadioChecked(theForm.q1))
	{
		alert("please select an answer for question 1");
		theForm.q1[0].focus();
		return false;
	}
	if(!isRadioChecked(theForm.q2))
	{
		alert("please select an answer for question 2");
		theForm.q2[0].focus();
		return false;
	}
	if(!isRadioChecked(theForm.q3))
	{
		alert("please select an answer for question 3");
		theForm.q3[0].focus();
		return false;
	}
	if(!isRadioChecked(theForm.q4))
	{
		alert("please select an answer for question 4");
		theForm.q4[0].focus();
		return false;
	}
	return true;
}

///////////////////////////////////////////
function checkstate2(theForm)
///////////////////////////////////////////
{	
	if(!theForm.q1[0].checked)
	{
		return false;
	}
	if(!theForm.q2[0].checked)
	{
		return false;
	}
	if(!theForm.q3[1].checked)
	{
		return false;
	}
	if(!theForm.q4[0].checked)
	{
		return false;
	}
	alert("Good Job!  You have answered all of the questions correctly.");
	return true;
}
///////////////////////////////////////////	
function state2(theForm)
///////////////////////////////////////////
{
	alert("Sorry, you have not answered all of the questions correctly. please review the begining of the workshop and try again.");
	this.p=1;
	theForm.ws_session2.value=sessionID;
	var cookieData = new Cookie(document, "RCC_Workshop_Session");
	if(!cookieData.load() || !cookieData.sessionID || !cookieData.sid)
	{
		cookieData.sessionID = this.sessionID;
		cookieData.sid = this.sid;
		cookieData.fname = this.fname;
		cookieData.lname = this.lname;
		cookieData.p = this.p;
	}
	cookieData.store();
	document.getElementById('form2').submit();
}
///////////////////////////////////////////	
function clearselectV()
///////////////////////////////////////////
{
	this.goal="";
	document.getElementById('certificate').disabled=true;
	document.getElementById('certificate').value="Please enter the certificate.";
}
///////////////////////////////////////////	
function clearselectD()
///////////////////////////////////////////
{
	this.goal="";
	document.getElementById('degree').disabled=true;
	document.getElementById('degree').value="Please enter the degree.";
}

///////////////////////////////////////////	
function clearAll()
///////////////////////////////////////////
{
	document.getElementById('certificate').disabled=true;
	document.getElementById('certificate').value="Please enter the certificate.";
	document.getElementById('degree').disabled=true;
	document.getElementById('degree').value="Please enter the degree";
  	document.getElementById('egoal0').checked=false;
	document.getElementById('egoal1').checked=false;
	document.getElementById('egoal2').checked=false;	
	document.getElementById('transfer0').disabled=true;
	document.getElementById('transfer1').disabled=true;
	document.getElementById('transfer2').disabled=true;
	document.getElementById('transfer3').disabled=true;
	document.getElementById('transfer0').checked=false;
	document.getElementById('transfer1').checked=false;
	document.getElementById('transfer2').checked=false;
	document.getElementById('transfer3').checked=false;
	document.getElementById('fmajor').value="Undecided";
	document.getElementById('whours').value="0";
	this.goal="";
}


///////////////////////////////////////////	
function vSelect()
///////////////////////////////////////////
{
	clearselectD();
	document.getElementById('certificate').disabled=false;
	this.goal="Certificate - ";
	document.getElementById('certificate').value="";
	document.getElementById('certificate').focus();
}
///////////////////////////////////////////	
function dSelect()
///////////////////////////////////////////
{
	clearselectV();
	document.getElementById('degree').disabled=false;
	this.goal="Associate Degree - ";
	document.getElementById('degree').value="";
	document.getElementById('degree').focus();
}
///////////////////////////////////////////	
function tSelect()
///////////////////////////////////////////
{
	clearselectD();
	clearselectV();
	this.goal="Transfer - "
	document.getElementById('transfer0').disabled=false;
	document.getElementById('transfer1').disabled=false;
	document.getElementById('transfer2').disabled=false;
	document.getElementById('transfer3').disabled=false;
	document.getElementById('transfer0').focus();
}
///////////////////////////////////////////	
function collectData()
///////////////////////////////////////////
{
	if(	document.getElementById('egoal0').checked)
	{
		this.goal = this.goal + document.getElementById('certificate').value;
	}
	if(	document.getElementById('egoal1').checked)
	{
		this.goal = this.goal + document.getElementById('degree').value;
	}
	if(	document.getElementById('egoal2').checked)
	{
		if(document.getElementById('transfer0').checked){this.goal = this.goal + "CSU"}
		if(document.getElementById('transfer1').checked){this.goal = this.goal + "UC"}
		if(document.getElementById('transfer2').checked){this.goal = this.goal + "Private"}
		if(document.getElementById('transfer3').checked){this.goal = this.goal + "Undecided"}
	}
	this.major=document.getElementById('fmajor').value;
	this.whours=document.getElementById('whours').value;
}
///////////////////////////////////////////	
function writeTicket()
///////////////////////////////////////////
{
	document.write("<span class='coloryellow'>" + this.fname + " ");
	document.write(this.lname + "</span><br />");
	document.write("Student ID: " + "<span class='coloryellow'>" + this.sid + "</span><br />");
	document.write("Educational Goal: " + "<span class='coloryellow'>" + this.goal  + "</span><br />");
	document.write("Major: " + "<span class='coloryellow'>" + this.major + "</span><br />");
	document.write("Work hours per week: " + "<span class='coloryellow'>" + sessionCookie.whours + "</span><br />");
	document.write("Reason for dismissal:" + "<span class='coloryellow'>" + sessionCookie.status + "</span><br />");
	document.write("Plan to get off Dismissal:" + "<span class='coloryellow'>" + sessionCookie.plan + "</span>");
}

