var xmlHttp;



function GetXmlHttpObject(){
	var xmlHttp=null;
	try {
		 // Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		//Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
function openGalleryPhotoEmailForm(){
	//window.open('/emailForm.php?photo='+photo+'&album='+album,'EmailACopyOfThisAlbumPhotoToAFriend','width=500,height=500');
	 $('#email_gallery_photo_form').find(':input').each(function() {
         $(this).val('');
  	});
	$('#email_gallery_photo_responce').hide();
	$('#email_gallery_photo_form_content').show();
	$('#email_gallery_photo_form').show();
        InputHelperCreate("#email_gallery_photo_form_fn_email", "friend1@example.com\nfriend2@example.com\nfriend3@example.com");
}

function submitGalleryPhotoEmail(photo, album, site_id, profile_id, profile_name)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	var urname = document.getElementById("email_gallery_photo_form_urname").value;
	var email = document.getElementById("email_gallery_photo_form_email").value;
	var remarks = document.getElementById("email_gallery_photo_form_remarks").value;
	var fn_email = document.getElementById("email_gallery_photo_form_fn_email").value.replace("\n", ",");
	var em = document.getElementById("email_gallery_photo_form_em").value;
	
//	<input type="hidden" name="site_id" value="<?=$_REQUEST['site_id']?>">
//	<input type="hidden" name="profile_id" value="<?=$_REQUEST['profile_id']?>">
//	<input type="hidden" name="profile_name" value="<?=$_REQUEST['profile_name']?>">
	
	var url = '/emailFormAjax.php?photo='+photo+'&album='+album+'&site_id='+site_id+'&profile_id='+profile_id+'&profile_name='+profile_name+"&urname="+urname+"&email="+email+"&remarks="+remarks+"&fn_email="+fn_email+"&em="+em;
	//alert(url);
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	if (xmlHttp.status==200) { 
		document.getElementById("email_gallery_photo_responce").innerHTML=xmlHttp.responseText ;
		document.getElementById("email_gallery_photo_form_content").style.display="none";
		document.getElementById("email_gallery_photo_responce").style.display="inline";
	}
	else
		alert(xmlHttp.status);
}
//function openGalleryPhotoEmailForm(photo, album, site_id, profile_id, profile_name){
//	var url = '/emailForm.php?photo='+photo+'&album='+album+'&site_id='+site_id+'&profile_id='+profile_id+'&profile_name='+profile_name;
//	window.open(url,'EmailACopyOfThisAlbumPhotoToAFriend','width=500,height=500'); 
//}



