
function submit_splash( form )
{
	with( form )
	{
		if( date_day.value == '' )
		{
			alert("A day must be selected");
			date_day.focus();
			return false;
		}
		
		if( date_month.value == '' )
		{
			alert("A month must be selected");
			date_month.focus();
			return false;
		}
		
		if( date_year.value.length != 4 || date_year.value.match( new RegExp( "^[0-9]{4}$" )) == false )
		{
			alert("The year format must be in YYYY. Eg 2003");
			date_year.focus();
			return false;
		}
		
		if( calc_age( date_year.value, date_month.value, date_day.value ) < 18 )
		{	
			alert('The date of birth you have entered is less than 18 years of age');
			return false;
		}
	}
	
	return true;
}

function calc_age( year, month, day )
{
	if( cur_month > month || ( month == cur_month && cur_day >= day ) )
	{
		return cur_year - year;
	}
	else
	{
		return cur_year - year - 1;
	}
}

function iframe_location( location )
{
	var iframe = document.getElementById('iframe'); 
	if (! iframe) return false;
	
	iframe.src = location;
}


function gallery_show_img( file )
{
	var img_obj = document.getElementById('img_enlarge'); 
	if (! img_obj) return false;
	
	img_obj.src = 'gallery/show.php?f=' + file;
}

function restore_image() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swap_image() { //v3.0
  var i,j=0,x,a=swap_image.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function popWin(url, name, h, w, scroll, toolbar){
  // open a new window with dimensions that of the image to be opened in it
     // format dimensions and window attributes
        var attributes = 'width='+h+',height='+w+',scrollbars='+scroll+',toolbar='+toolbar;
     // open window
        window.open(url, name, attributes);
        return false;
}

function show_subscribe()
{
	
}

function checkEmpty(input, text) {
	with (input) {
		if (value == "" || value == null) {
			if (text != "" && text != null) {
				alert(text);
			} 
			return false;
		} else {
			return true;
		}
	}
}

function checkEmail(entered, strAlert) {
	with (entered) {
		apos = value.indexOf("@"); 
		dotpos = value.lastIndexOf(".");
		lastpos = value.length - 1;

		if (apos < 1 || dotpos - apos < 2 || lastpos - dotpos > 3 || lastpos - dotpos < 2) {
			if (strAlert) {
				alert(strAlert);
			} 

			return false;
		}
		else {
			return true;
		}
	}
}

function checkMailingListForm( the_form )
{
	with ( the_form ) 
	{
		if( !checkEmpty( name, 'ERROR : Your name must be entered' ) )
		{
			name.focus();
			return false;
		}

		if( !checkEmpty( email, 'ERROR : Your E-Mail address must be entered' ) )
		{
			email.focus();
			return false;
		}
		
		if( !checkEmail( email, 'ERROR : The email address you entered is invalid. Please enter a valid email address.' ) )
		{
			email.focus();
			return false;
		}
		
		return true;
	}
}