
	var request=null
	function createRequest()
	{
		try
		{
			request=new XMLHttpRequest()
		}
		catch(trymicrosoft)
		{
			try
			{
				request=new ActiveXObject("Msxml2.XMLHTTP")
			}
			catch(othermicrosoft)
			{
				try
				{
					request=new ActiveXObject("Microsoft.XMLHTTP")
				}
				catch(failed)
				{
					request=null
				}
			}
		}
		if(request==null)
		{
			alert("Error creating request object")
		}
	}
	
var ETFform
var rememberlinkbtn //holds the innerHTML of the link button while it's processing
	function processquest(frmname,ajaxpath,ajaxfname)
	{
		createRequest()
		
		var theForm = eval('document.'+frmname)
		rememberlinkbtn=document.getElementById(frmname+'linkbutton').innerHTML
		document.getElementById(frmname+'linkbutton').innerHTML='processing...'
		var url=''
		url = ajaxpath //"/rpc/mailtofriend/"		
		url += ajaxfname //"mailtofriend.asp"
		var sel=''
		
		for(var h=0;h<theForm.elements.length;h++)
		{
			sel+=theForm.elements[h].name+'='+theForm.elements[h].value+'&'
		}
		sel=sel.substr(0,sel.length-1)
		//alert(sel)

		request.open("POST",url,true)

		ETFform=frmname
		request.onreadystatechange = updateETFPage
		request.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
		request.send(sel)
	}

	function updateETFPage()
	{
		//alert('frmname='+frmname+'\nrequest.readyState='+request.readyState+'\nrequest.responseText='+request.responseText)

		if(request.readyState==4)
		{

			document.getElementById(ETFform).style.visibility='hidden'
			//alert(request.responseText)
			if (request.status==200)
			{
				var resp=request.responseText
				//alert(request.responseText)
				document.getElementById(ETFform+'link').innerHTML='<span style="color:#FF0000">'+resp+'</span>'
				document.getElementById(ETFform+'linkbutton').innerHTML=rememberlinkbtn
			}
			else
			{
				//alert("The server said: "+request.status+'\n'+resp)
				document.getElementById(ETFform+'link').innerHTML='<span style="color:#FF0000">There was an error processing your message</span>'
				document.getElementById(ETFform+'linkbutton').innerHTML=rememberlinkbtn
			}
		}
		//document.getElementById(ETFform+'linkbutton').innerHTML=rememberlinkbtn
	}
/*
VIC_Question_00026 - Friend's e-mail
VIC_Question_00025 - Friend's name
VIC_Question_00418 - Your e-mail
VIC_Question_00419 - Your name
VIC_Question_00421 - page to send
VIC_ID
ETF_Form_Action*/

function VF_ETFForm(frmname,ajaxpath,ajaxfname)
{
	var theForm = eval('document.'+frmname)
	var errMsg = "";
	var setfocus = "";
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

	if(theForm['VIC_Question_00025'].value == '')
	{
		theForm['VIC_Question_00025'].value="Friend"
	}

	if(theForm['VIC_Question_00419'].value == '')
	{
			errMsg = "The Your Name field is required";
			setfocus = "['VIC_Question_00419']";
	}


	if (theForm['VIC_Question_00418'].value != ''){
		if (!emailRE.test(theForm['VIC_Question_00418'].value)){
			errMsg = "The E\-mail Address is not valid.";
			setfocus = "['VIC_Question_00418']";
		}
	}

	if (theForm['VIC_Question_00026'].value != ''){
		if (!emailRE.test(theForm['VIC_Question_00026'].value)){
			errMsg = "The E\-mail Address is not valid.";
			setfocus = "['VIC_Question_00026']";
		}
	}


	if (errMsg != "")
	{
		alert(errMsg);

		//this loops through the elements on the form and if the name of the current element in the loop
		//matches the name passed in setfocus, it sets the focus to that form element.
		for (var c=0;c<theForm.elements.length;c++)
		{
			if(theForm.elements[c].name == setfocus.substring(2,(setfocus.length-2)))
			{
				//alert(theForm.elements[c].name+' '+c)
				theForm.elements[c].focus()
				theForm.elements[c].select()
				break;
			}
		}
	}
	else
	{
		processquest(frmname,ajaxpath,ajaxfname);
	}
}

function printableArticle()
{
	var printWindow
	var ih=document.getElementById('content').innerHTML
	//strip out toolbox for printable version
	//alert(ih)
	//alert(ih.substr(0,ih.indexOf('<!--begin toolbox-->')-1))
	//ih=ih.substr(0,ih.indexOf('<!--begin toolbox-->')-1)+ih.substring(ih.indexOf('<!--end toolbox-->')+18,ih.length)
	
	printWindow = window.open('','printableArticle','width=800px, height=600px, resizable,menubar,scrollbars');
	printWindow.document.write('<html><head><title>Billy Graham Evangelistic Association</title>')
	printWindow.document.write('<link rel="stylesheet" type="text/css" href="/includes/Hurricane_General.css">')
	printWindow.document.write('<link rel="stylesheet" type="text/css" href="/includes/dmagstyles.css">')
	printWindow.document.write('</head>')
	printWindow.document.write('<body onload="document.getElementById(\'articletools\').style.visibility=\'hidden\';document.getElementById(\'articletools\').style.display=\'none\';document.getElementById(\'emailtofriendlink\').style.visibility=\'hidden\'">')
	printWindow.document.write(ih)
	printWindow.document.write('</body></html>')
	printWindow.document.close()
	//alert(printWindow.document.getElementById('emailtofriend').style.visibility)
}
