// JavaScript Document

var xmlHttp

function loadCalendar()
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	var url="Includes/generatecalendar.php"
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function loadAlbum()
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	
	album = document.hiddenalbum.album.value;
	 
	var url="Content/generatephotos.php?album=" + album;
	xmlHttp.onreadystatechange=photosReady; 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function photosReady() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		 document.getElementById("htmlholder").innerHTML=xmlHttp.responseText 
	 } 
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		 document.getElementById("scrollDiv").innerHTML=xmlHttp.responseText 
	 } 
}

function addEmail()
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	
	name = document.emaillist.name.value;
	email = document.emaillist.email.value;
		
	var url="Includes/echo.php?name=" + name + "&email=" + email;
	xmlHttp.onreadystatechange=emailSent; 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function addBigEmail()
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
		 alert ("Browser does not support HTTP Request")
		 return
	 }
	
	name = document.homeemaillist.homename.value;
	email = document.homeemaillist.homeemail.value;
		
	var url="Includes/echo.php?name=" + name + "&email=" + email;
	xmlHttp.onreadystatechange=bigemailSent; 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function emailSent() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		 document.getElementById("formDiv").innerHTML="<div id=\"emailreturn\" align=\"center\">Thank You</div><div id=\"emailreturn\" align=\"center\">A confirmation email should be sent to your address shortly</div>"
		 //document.getElementById("formDiv").innerHTML=xmlHttp.responseText
	 } 
}

function bigemailSent() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		 document.getElementById("homeformDiv").innerHTML="<div id=\"homeemailheader\" align=\"center\">Thank You<br /><br />A confirmation email should be sent to your address shortly</div>"
		 //document.getElementById("formDiv").innerHTML=xmlHttp.responseText
	 } 
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		 document.getElementById("scrollDiv").innerHTML=xmlHttp.responseText
	} 
}

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;
}