// JavaScript Document

// This function verifies the form used to fill out personal and company information
//function verify_form() {
//
//	var nonoptional = ""; // string will be created from missing data
//	var labels = document.getElementsByTagName('label'); // create an array with all label objects
//	var required_fields = new Array("First_Name", "Last_Name", "Email", "Password", "Password2") // create an array with required input name
//	var required_fields_company = new Array("Company_Name", "Address", "City", "State", "Zip", "Country", "Company_Phone", "Fax") // create an array with required input name
//	var selectionMade = false;
//	
//	
//	
//	//// Make sure company fields are black if a selection is made or add company fields to the array
////	if (selectionMade) for(var i = 0; i < required_fields_company.length; i++) change_color(document.meetingForm[required_fields_company[i]], labels, "black");
////	else for(var i = 0; i < required_fields_company.length; i++) required_fields.push(required_fields_company[i]);
//		
//	for (var i = 0; i < required_fields.length; i++) {		
//		// reset colors to black if field's not empty
//		if (document.meetingForm[required_fields[i]].value != "") change_color(document.meetingForm[required_fields[i]], labels, "#003366");				
//		// change border & label to red if blank; build notification
//		if (document.meetingForm[required_fields[i]].value == "") {
//			nonoptional += document.meetingForm[required_fields[i]].name + "\n";			
//			change_color(document.meetingForm[required_fields[i]], labels, "#C83921");		
//		} // if
//	} // for	
//	
//	// check string to see if it's not empty		
//	if (nonoptional != "") {		
//		alert("The highlighted fields must be filled out \n" + nonoptional);
//		return false;
//	} // if
//	// make sure passwords match
//	else if (document.meetingForm.Password.value != document.meetingForm.Password2.value) {
//		alert("Your passwords do not match!")
//		return false;
//	}// else if
//	else {
//		// check to see if a company was selected
//		for(var i = 0; i < document.meetingForm.companyID.options.length; ++i) {
//			if (document.meetingForm.companyID.options[i].selected) { 
//				var selectionMade = true;
//				break;
//			} // if		
//		} // for	
//		if (!selectionMade) {			
//			alert("Please select an option from the list.")
//			return false;
//		} //else		
//	}// else	
//	
//} // verify_form


// This function checks whether an input was made before submiting the form
function verify_email() {
	if (document.meetingForm.Email.value == "") {
		alert("Please fill in your email address.");
		return false;
	} //if
	if (document.meetingForm.Password.value == "") {
		alert("Please fill in your password.");
		return false;
	} //if
} // verify_email

// This function is used for the password change; checks that both are filled out and they match
function verify_password() {
	if ((document.meetingForm.Password.value == "") || (document.meetingForm.Password2.value == "")){
		alert("Please enter your password in both fields.");
		return false;
	} //if
	
	if (document.meetingForm.Password.value != document.meetingForm.Password2.value) {
		alert("Your passwords do not match!")
		return false;
	}// else if	
	else return true; // change to true when ready to access database
} // verify_password

// This function changes the color of the input box
function change_color(reg_field, label, color) {
	if (color != "#C83921") reg_field.style.backgroundColor = "white" // change input background back to white
	else reg_field.style.backgroundColor = "#FFFFCC" // change input background to light yellow
	// loop through label elements until match is found
	for (var i in label) {
		if (label[i].htmlFor == reg_field.id) label[i].style.color = color; // change label color
	} // for
	return;
} // change_color

// This function opens a new window to display meeting details
function details(url) {
	detailsWindow = window.open(url, "detailsWin", "height=600,width=700,scrollbars");
	detailsWindow.focus( );
} //details

// This function 
function verify_selection() {
	var selectionMade = false;	
	if (document.meetingForm.ID.length) {		
		for(var i = 0; i < document.meetingForm.ID.length; i++) {		
			if (document.meetingForm.ID[i].checked) {	
				selectionMade = true;
				break;							
			} // if		
		} // for
	} // if
	else {
		if (document.meetingForm.ID.checked) selectionMade = true;
	} // else
	if (selectionMade) return true
	else {
		alert("You must make a selection before you can continue.");
		return false;
	} // else	
} // verify_selection

// This function 
function verify_selection3() {
	var selectionMade = false;	
	if (document.meetingForm.attendeeID.length) {		
		for(var i = 0; i < document.meetingForm.attendeeID.length; i++) {		
			if (document.meetingForm.attendeeID[i].checked) {	
				selectionMade = true;
				break;							
			} // if		
		} // for
	} // if
	else {
		if (document.meetingForm.attendeeID.checked) selectionMade = true;
	} // else
	if (selectionMade) return true
	else {
		alert("You must make a selection before you can continue.");
		return false;
	} // else	
} // verify_selection

function verify_selection2() {
	var selectionMade = false;	
	if (document.meetingForm.ID.length) {		
		for(var i = 0; i < document.meetingForm.ID.length; i++) {		
			if (document.meetingForm.ID[i].checked) {	
				selectionMade = true;
				break;							
			} // if		
		} // for
	} // if
	else {
		if (document.meetingForm.ID.checked) selectionMade = true;
	} // else
	if (selectionMade) {
		if (confirm("Are you sure?")) 
			return true;
		else
			return false;
	} //if
	else {
		alert("You must make a selection before you can continue.");
		return false;
	} // else	
} // verify_selection2

//function verify_company() {
//	var nonoptional = ""; // string will be created from missing data
//	var labels = document.getElementsByTagName('label'); // create an array with all label objects
//	var required_fields_company = new Array("Company_Name", "Address", "City", "State", "Zip", "Country", "Company_Phone", "Fax") // create an array with required input name
//	var selectionMade = false;
//	
//	// check to see if a company was selected	
//	for(var i = 0; i < document.meetingForm.companyID.options.length; ++i) {
//		if (document.meetingForm.companyID.options[i].selected) { 
//			selectionMade = true;
//			break;
//		} // if
//	} // for	
//	
//	// Make sure company fields are black if a selection is made or add company fields to the array
//	if (selectionMade) for(var i = 0; i < required_fields_company.length; i++) change_color(document.meetingForm[required_fields_company[i]], labels, "black");
//	//else for(var i = 0; i < required_fields_company.length; i++) required_fields.push(required_fields_company[i]);
//	else {
//		for (var i = 0; i < required_fields_company.length; i++) {		
//			// reset colors to black if field's not empty
//			if (document.meetingForm[required_fields_company[i]].value != "") change_color(document.meetingForm[required_fields_company[i]], labels, "#003366");				
//			// change border & label to red if blank; build notification
//			if (document.meetingForm[required_fields_company[i]].value == "") {
//				nonoptional += document.meetingForm[required_fields_company[i]].name + "\n";			
//				change_color(document.meetingForm[required_fields_company[i]], labels, "#C83921");		
//			} // if
//		} // for
//	} //else
//	
//	// check string to see if it's not empty		
//	if ((nonoptional != "") || (selectionMade = false)) {		
//		alert("The highlighted fields must be filled out \n" + nonoptional);
//		return false;
//	} // if
//	else return true; // change to true when ready to access database
//} // verify_company

//function verify_company_existing() {
//	var nonoptional = ""; // string will be created from missing data
//	var labels = document.getElementsByTagName('label'); // create an array with all label objects
//	var required_fields_company = new Array("Company_Name", "Address", "City", "State", "Zip", "Country", "Company_Phone", "Fax") // create an array with required input name
//	var selectionMade = false;		
//	
//	for (var i = 0; i < required_fields_company.length; i++) {		
//		// reset colors to black if field's not empty
//		if (document.meetingForm[required_fields_company[i]].value != "") change_color(document.meetingForm[required_fields_company[i]], labels, "#003366");				
//		// change border & label to red if blank; build notification
//		if (document.meetingForm[required_fields_company[i]].value == "") {
//			nonoptional += document.meetingForm[required_fields_company[i]].name + "\n";			
//			change_color(document.meetingForm[required_fields_company[i]], labels, "#C83921");		
//		} // if
//	} // for	
//	
//	// check string to see if it's not empty		
//	if (nonoptional != "") {		
//		alert("The highlighted fields must be filled out \n" + nonoptional);
//		return false;
//	} // if
//	else return true; // change to true when ready to access database
//} // verify_company

// This function verifies the form used to fill out personal and company information
//function verify_personal() {
//
//	var nonoptional = ""; // string will be created from missing data
//	var labels = document.getElementsByTagName('label'); // create an array with all label objects
//	var required_fields = new Array("First_Name", "Last_Name", "Email") // create an array with required input name
//		
//	for (var i = 0; i < required_fields.length; i++) {	
//		// reset colors to black if field's not empty
//		if (document.meetingForm[required_fields[i]].value != "") change_color(document.meetingForm[required_fields[i]], labels, "#003366");				
//		// change border & label to red if blank; build notification
//		if (document.meetingForm[required_fields[i]].value == "") {
//			nonoptional += document.meetingForm[required_fields[i]].name + "\n";			
//			change_color(document.meetingForm[required_fields[i]], labels, "#C83921");		
//		} // if
//	} // for	
//	// check string to see if it's not empty		
//	if (nonoptional != "") {		
//		alert("The highlighted fields must be filled out \n" + nonoptional);
//		return false;
//	} // if
//	else return true; // change to true when ready to access database
//} // verify_personal

function presentation_notify() {
	
	alert("Please be patient while your presentation is being sent.")
}

// This function verifies the form used to fill out contact information
function verify_newForm(req_type) {

	var nonoptional = ""; // string will be created from missing data
	var labels = document.getElementsByTagName('label'); // create an array with all label objects
	// create an array with required input name based on request type (new or existing)
	if (req_type == "new") {
		var required_fields = new Array("First_Name", "Last_Name", "Company_Name", "Address", "City", "State", "Zip", "Country", "Company_Phone", "Fax", "Email", "Password", "Password2") 
	}
	else var required_fields = new Array("First_Name", "Last_Name", "Company_Name", "Address", "City", "State", "Zip", "Country", "Company_Phone", "Fax", "Email");	
			
	for (var i = 0; i < required_fields.length; i++) {		
		// reset colors to black if field's not empty
		if (document.meetingForm[required_fields[i]].value != "") change_color(document.meetingForm[required_fields[i]], labels, "#003366");				
		// change border & label to red if blank; build notification
		if (document.meetingForm[required_fields[i]].value == "") {
			nonoptional += document.meetingForm[required_fields[i]].name + "\n";			
			change_color(document.meetingForm[required_fields[i]], labels, "#C83921");		
		} // if
	} // for	
	// check string to see if it's not empty		
	if (nonoptional != "") {		
		alert("The highlighted fields must be filled out \n" + nonoptional);
		return false;
	} // if
	// make sure passwords match
	else if (req_type == "new") {
		if (document.meetingForm.Password.value != document.meetingForm.Password2.value) {
		alert("Your passwords do not match!")
		return false;
		} // if
	}// else if
	else return true; // change to true when ready to access database
} // verify_newForm


// -->