	function warn(url){
		var confirmed = confirm("Clicking yes will delete this, are you sure that is what you want to do?");
		if(confirmed){
			window.location.href=url;
		}
		else{
			return false;	
		}	
	}


	function showDetails(classID){	
		
		var detailsID = document.getElementById('details');
		var scheduleID = document.getElementById('schedule');			
		url = "training/class_details.php?classID="+classID;			
		theFrame = document.getElementById('work_frame');		
		theFrame.src = url;
		//document.frames['work_frame'].location.href=url;	
		detailsID.style.visibility='visible';
		detailsID.style.display="block";		
		scheduleID.style.visibility='hidden';
		scheduleID.style.display="none";		
		return false;
	}
	
	function showSchedule(){
		var detailsID = document.getElementById('details');
		var scheduleID = document.getElementById('schedule');
		detailsID.style.visibility='hidden';
		detailsID.style.display='none';
		scheduleID.style.visibility='visible';
		scheduleID.style.display='block';
		return false;
	}
	
	function checkImage(i,o, formName){
		fi = document.forms[formName].elements[i];
		fi.style.backgroundColor = "#ffffff";
		
		if(fi.value != document.forms[formName].elements[o].value){
			fi.style.backgroundColor='red';
			fi.focus();
			alert("The verification number you entered is incorrect. Please try again");	
			return false;
		}
		return true;
	}
	
	function checkForm(formName){
		submitIt = true;
		theForm = document.forms[formName];
		len = theForm.length;		
		for(i=0;i<len;i++){
			
			theName = theForm.elements[i];
			
			
			isRequired = theName.getAttribute('required');
			if(isRequired=="true"){
				val = theName.value;
				
				if(val.length==0){
					alert("You forgot to fill in a required field ("+theName.name+") ");
					theName.style.backgroundColor="red";
					theName.focus();
					submitIt = false;
					break;
				}	
				/*
				else if(val.length<2){
					alert("Not enough info: ("+theName.name+") ");
					theName.style.backgroundColor="red";
					theName.focus();
					submitIt = false;
					break;
				}	
				*/
				else if(theName.name.indexOf('email') != -1){					
					continueOn = echeck(val);
					if(!continueOn){						
						theName.style.backgroundColor="red";
						theName.focus();
						submitIt = false;
						break;
					}
				}
				else{
					theName.style.backgroundColor="white";	
				}
			}						
		}
		if(submitIt){
			theForm.submit();
		}
		else return false;
	}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

	

	
	function addAttendee(){
		//nothing generic about this function, it is specific to the attendee form, please change at your own peril
		var num_attendees = document.forms['attendees'].elements['num_attendees'].value;	
		total_attendees = parseInt(num_attendees)+1;
		document.forms['attendees'].elements['num_attendees'].value = total_attendees;
		num_attendees = total_attendees;
		
		//add a node
		theHTML = document.getElementById('td_attendees').innerHTML;
		newHTML = "<TABLE><TR><TD><INPUT TYPE=text name='firstname_"+num_attendees+"'></TD>"+
		"<TD><INPUT TYPE=text name='lastname_"+num_attendees+"'></TD>"+
		"<TD><INPUT TYPE=text name='phone_"+num_attendees+"'></TD>"+
		"<TD><INPUT TYPE=text name='email_"+num_attendees+"'></TD></TR></TABLE>";
		theHTML+=newHTML;
		obj = document.getElementById('td_attendees')
		obj.innerHTML = theHTML;
		return false;
	}
	
	function checkDelete(theAttrib, controllerID){
		var formElements = document.forms[0];
		var len = formElements.length;
		//is controllerID checked?
		var checkedStatus = document.getElementById(controllerID);
		for(i=0;i<len;i++){
			theElem = formElements[i];
			if(theElem.type == "checkbox"){
				var attribVal = theElem.getAttribute("group");
				if(theElem.checked==true){
				
				}
				if(attribVal == theAttrib){ 
					
					if(checkedStatus.checked==true){
						theElem.checked=true;						
					}
					else theElem.checked=false;
				}
			}	
		}		
	}
	
	function updateStatus(theAttrib, controllerID){
		var sim = document.getElementById(controllerID);
		var controllerVal = sim.options[sim.selectedIndex].value;		
		var formElements = document.forms[0];
		var len = formElements.length;
		//is controllerID checked?
		
		for(i=0;i<len;i++){
			theElem = formElements[i];			
			if(theElem.type == "select-one"){				
				var attribVal = theElem.getAttribute("group");				
				if(attribVal == theAttrib){ 
					theElem.value=controllerVal;
					theElem.text=controllerVal;				
				} //end of if attribs match
			} //end of if element type == select	
		} //end of for		
	} //end of function
	
	
	function q(){
		document.getElementById('prd05').innerHTML = "<IFRAME width=100% frameborder=0 border=0 src='pp.php' height=500></IFRAME>";
		return false;
	}
	
	function colorSeries(theId, theSelect){
		if(document.getElementById(theSelect).checked==true){
			document.getElementById(theId).style.backgroundColor="green";
		}
		else{
			document.getElementById(theId).style.backgroundColor="white";
		}		
	}
	
	function updateMoveStudent(theAttrib, controllerID){
		var sim = document.getElementById(controllerID);
		var controllerVal = sim.options[sim.selectedIndex].value;		
		var formElements = document.forms[0];
		var len = formElements.length;
		//is controllerID checked?
		
		for(i=0;i<len;i++){
			theElem = formElements[i];			
			if(theElem.type == "select-one"){				
				var attribVal = theElem.getAttribute("group2");				
				if(attribVal == theAttrib){ 
					theElem.value=controllerVal;
					theElem.text=controllerVal;				
				} //end of if attribs match
			} //end of if element type == select	
		} //end of for		
	} //end of function
	
	
	function updateCourses(num, course_id, course_name){
		document.forms[0].elements['course_id_'+num].value=course_id;
		document.forms[0].elements['name_'+num].value=course_name;
		if(course_id != ''){
			document.forms[0].elements['select_'+num].checked=true;
			colorSeries('tr_'+num, 'select_'+num);
			document.getElementById('work_area').src="iframe_courses.php?i="+num+"&course_id="+course_id;
		}
	}
