/* SUBMIT CONTACT FORM */
function submit_form()
{
	if(document.form_elert.onsubmit())
	{
	document.form_elert.submit();
	}
}
/* VALID EMAIL FOR FORM */
function validEmail(email) {
	invalidChars = ' !#$%^&*(){}[]+=~`?/:;,"'

	
	if (email == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) { //does it contain any invalid characters?
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1)  		//there must be one "@" symbol
		if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1) != -1) { //and only one "@"
		return false;
	}
	periodPos = email.indexOf(".",atPos+1)  //and at least one "." after the "@"
		if (periodPos == -1) {
		return false;
	}
	if (email.charAt(atPos+1) == ".") {	//is there a "." right after the "@"
		return false;
	}
	if (periodPos+3 > email.length) {  	//must be at least 2 characters after the "."
		return false;
	}
	return true;
}
/* CONTACT FORM VALIDATION*/
function ValidateElert(form) {
 
	if (form.firstname.value == '') {
		alert("Please fill in your First Name.");
		form.firstname.focus();
		form.firstname.select();
		return false;
	}
	
	if (form.lastname.value == '') {
		alert("Please fill in your Last Name.");
		form.lastname.focus();
		form.lastname.select();
		return false;
	}
	
	if (!validEmail(form.emailaddress.value)) {
		alert("A valid E-mail Address is required.");
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	
	return true;	
}

/* START PHOTO THUMBNAILS */
function TheatreThumb(intPhotoID, intPhotoBoxID)
{
	document.getElementById("theatre_image").innerHTML = "<div align='center' style='margin: 0px; padding-top: 130px; width: 501px;'><img src='images/ajax_loading.gif' /></div>";
	DWREngine._execute("function_ajax.cfm", null, 'readPhotoThumbNail', intPhotoID, getMainEventsResult);
}
function getMainEventsResult(result)
{
	document.getElementById("theatre_image").innerHTML = result;
	
}
/* END PHOTO THUMBNAILS */

function drawBorder(intPhotoID, intMaxCount) {
	for (x=1; x <= intMaxCount; x++) 
	{
		$("#photo" + x).addClass("thumb_no_focus").show("slow");
		$("#photo" + x).removeClass("thumb_focus").show("slow");
	}
	
	$("#photo" + intPhotoID).addClass("thumb_focus").show("slow");
	$("#photo" + intPhotoID).removeClass("thumb_no_focus").show("slow");

}


/* START SHOW GALLERY */

function myPhoto(intShow, intPhoto)
{
	// display the loading image
	document.getElementById("show_image").innerHTML = "<div align='center' style='margin: 0px; padding-top: 100px; width: 480px; height: 255px;'><img src='images/ajax_loading.gif' /></div>";
	DWREngine._execute("function_ajax.cfm", null, 'readPhotoFunction', intShow, intPhoto, getMyPhoto);
}
function getMyPhoto(result)
{
	//var intBlockID   = result.charAt(3);
	document.getElementById("show_image").innerHTML = result;
}



/* END SHOW GALLERY */

/* POP PIC WINDOW */
var win= null;
function NewWindow(mypage,myname,w,h,scroll){
  var winl = 1;
  var wint = 1;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=no';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

/* PR CONTACT FORM */
function ValidatePRForm(form) {
 
	if (form.name.value == '') {
		alert("Please fill in your First Name.");
		form.name.focus();
		form.name.select();
		return false;
	}
	
	if (!validEmail(form.email.value)) {
		alert("A valid E-mail Address is required.");
		form.email.focus();
		form.email.select();
		return false;
	}
	
	return true;	
}

