// JavaScript Document

var empty = new Image(); empty.src = "../images/misc/fieldError.gif";
var haveerrors = 0;

function showImage(imagename, imageurl, errors) {
document[imagename].src = imageurl;
if (!haveerrors && errors) haveerrors = errors;
}


// return true if one radiobutton is checked
function addCourses() 
{
	var el = document.forms[0].elements;
	for(var i = 0 ; i < el.length ; ++i)
	{
		if(el[i].type == "radio")
		{
		    var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
		    if (radiogroup.length == undefined) // length will not be set if there is only one radiobutton
		    {
		        return radiogroup.checked;
		    }
		
		    var itemchecked = false;
			for(var j = 0 ; j < radiogroup.length ; ++j)
			{
				// if there is one radiobutton checked, return true
				if(radiogroup[j].checked)
				{
				    return true;
				}
			}
		}
	}
	
	// No radiobutton checked
	return false;
	
}

function addCoursesSingle() {
	var oFrm = document.oForm;
	oFrm.submit();
}

function addContactDetails() {
	var oFrm = document.oForm;

haveerrors = 0;
(oFrm.companyName.value.length < 1)
? showImage("companyNameError", "../images/misc/fieldError.gif", true)
: showImage("companyNameError", "../images/misc/fieldBlank.gif", false);

(oFrm.companyAddress.value.length < 1)
? showImage("companyAddressError", "../images/misc/fieldError.gif", true)
: showImage("companyAddressError", "../images/misc/fieldBlank.gif", false);

(oFrm.companyPostal.value.length < 1)
? showImage("companyPostalError", "../images/misc/fieldError.gif", true)
: showImage("companyPostalError", "../images/misc/fieldBlank.gif", false);

(oFrm.companyCity.value.length < 1)
? showImage("companyCityError", "../images/misc/fieldError.gif", true)
: showImage("companyCityError", "../images/misc/fieldBlank.gif", false);

(oFrm.companyPhone.value.length < 1)
? showImage("companyPhoneError", "../images/misc/fieldError.gif", true)
: showImage("companyPhoneError", "../images/misc/fieldBlank.gif", false);

(oFrm.companyEmail.value.length < 1)
? showImage("companyEmailError", "../images/misc/fieldError.gif", true)
: showImage("companyEmailError", "../images/misc/fieldBlank.gif", false);

return (!haveerrors);
}

function addPartipicants() {
	oFrm = document.oForm.submit();
}

function addPartipicants2() {
	var el = document.forms[0].elements;
	for(var i = 0 ; i < el.length ; ++i){
		if(el[i].type == "text"){
		var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
		var itemchecked = false;
			for(var j = 0 ; j < radiogroup.length ; ++j){
				if(radiogroup[j].value.length > 0){
				itemchecked = true;
				break;
				}
			}
		}
	}
	if(itemchecked == false){
	return false;
	}
	else{
	return true;
	}
}

function addPartipicants2single() {
	var oFrm = document.oForm;

	if(oFrm.firstName.value.length < 1){
	return false;
	}
	if(oFrm.lastName.value.length < 1){
	return false;
	}
return true;
}


function sendOrder() {
	var oFrm = document.oForm;
	
	oFrm.nextBtn.disabled = true;
	oFrm.submit();
}
