var bgalleryaccess = false;

function mysubmitfunc(v,m,f){
	an = m.children('#alertName');

	if($('#alertName').val() == ""){
		$('#gallerydivwarning').html('email cannot be blank');
		return false;
	}
	else
{
	var baccess = true;
//	$('#gallerydivresult').load('gallerypermission.php?id='+(new Date().getTime()),{email: $('#alertName').val()}, function(){alert($('#gallerydivresult').html());});

$.ajax({
   async: false,
   type: "POST",
   url: "gallerypermission.php",
   data: "email="+$('#alertName').val(),
   success: function(msg){
     if(eval(msg)==0)
	baccess=false;
   }
 });
	
//if(eval($('#gallerydivresult').html())==0) baccess =false;  
	
	if(!baccess)
	{
		$('#gallerydivwarning').html('Your email has not been granted access rights');
		return false;
	}
	
}

	bgalleryaccess = true;	

	return true;

}


function galleryprompt()
{
if(bgalleryaccess)
	return true;
var txt = 'Enter your email address to access hi-res images:<br /><input type="text" id="alertName" name="myname" value="" /><div style="display:none" id="gallerydivresult"></div><br/><div style="color: red" id="gallerydivwarning"></div>';

$.prompt(txt,{
	submit: mysubmitfunc,
	buttons: { Ok:true }});
}
