// open webcam window

function webcam(x, y)
{
	window.open(x, y,'status=no,scrollbars=no,resizable=yes,width=420,height=400');
	window.name="main";
}

function glasto2005webcam(x, y)
{
	window.open(x, y,'status=no,scrollbars=no,resizable=yes,width=420,height=400');
	window.name="main";
}


// This function brings up an alert if field is empty
// The fieldLabel variable can be used to insert the field name in the alert
function validRequired(formField, fieldLabel) {

	var result = true;
	if (formField.value == "") {
	
		alert('Please enter a value for the "' + fieldLabel + '" field.');
		formField.focus();
		result = false;
		
	}
	return result;	

}



// This function validates emails simply
// It checks that the field is filled in
// It also checks to see if the @ and . are present
function validEmail(formField) {

	var result = true;
	var string1 = formField.value;
	if (formField.value == "") {
	
		alert("Please enter a value for the email field.");
		formField.focus();
		result = false;
		
	} else if (string1.indexOf("@")==-1 || string1.indexOf(".")==-1) {
	
		alert("You have not entered a correct email address.");
		formField.focus();
		result = false;
			
	}
	
	return result;

}



// checkbox validation
function validCheckbox(formField) {

	var result = true;
	if (!formField.checked) {
	
		result = false;
		
	}
	return result;

}



// radio button validation
function validRadio(formField) {

	var result = true;
	var cnt = 0;
	for (i=0; i<formField.length; i++) {
		if (formField[i].checked) {
			cnt++;
		}
	}	
	if (cnt == 0) {
		alert('you must choose to Subscribe or Un-subscribe.');
		var result = false;
	}
	return result;
	
}

function checkCharLength(formFieldValue, theLength) {

	var result = true;
	var field = formFieldValue.value;
	if (field == "") {

		alert("Please enter a comment.");
		formFieldValue.focus();
		result = false;	
	
	} else {
	
		if (field.length >= theLength) {
			alert('Your comment is too long to process, please shorten.');
			formFieldValue.focus();
			result = false;
		}
	}
	return result;
}


// This is the main functions called when validating forms
function validateFeedback(theForm) {
	
	var result = false;
	
	if (theForm.email) {
	
		if (validEmail(theForm.email)) {
	
			result = true;
	
		}
		
	} else {
	
		result = true;
	
	}
	
	return result;					

}


function popwin(aPage, aTarget, w, h, var1, var2){
        window.open(aPage,aTarget,'status=no,scrollbars=no,resizable,width='+w+',height='+h);
}

