// Ajax functions

function getXMLHttpObject()
{
	var xmlHttp;
	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 contactRequestDetails(myForm, elementToChange, eventID, hideshow)
{
	xmlHttp = getXMLHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="/ajax_php/contact_request_details.php";
	url=url+"?id="+eventID;
	url=url+"&hideshow="+hideshow;
	url=url+"&sid="+Math.random();

	xmlHttp.onreadystatechange=function()
    {
		if(xmlHttp.readyState==4)
		{
			document.getElementById(elementToChange).innerHTML=xmlHttp.responseText;
			//window.open("document.writeln('" + xmlHttp.responseText + "');", 'OFFSCREEN','scrollbars=no,resizable=no,width=1024,height=768');
		}
    }

   xmlHttp.open("POST",url,true);
   xmlHttp.send(null);
}

function eventDetails(myForm, elementToChange, eventID, hideshow)
{
	xmlHttp = getXMLHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url="/ajax_php/event_details.php";
	url=url+"?id="+eventID;
	url=url+"&hideshow="+hideshow;
	url=url+"&sid="+Math.random();

	xmlHttp.onreadystatechange=function()
    {
		if(xmlHttp.readyState==4)
		{
			document.getElementById(elementToChange).innerHTML=xmlHttp.responseText;
		}
    }

   xmlHttp.open("POST",url,true);
   xmlHttp.send(null);
}

function testPrint()
{
	alert('hi');
}

function showPreview(elementToChange)
{	

	xmlHttp = getXMLHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	} 


	var url="/admin/admin_page_preview.php";
	
//	var poststr = "billing_address=" + encodeURI( document.getElementById("billing_address").value ) +
//		  		  "&billing_city=" + encodeURI( document.getElementById("billing_city").value ) +
//		  		  "&cc_zip=" + encodeURI( document.getElementById("cc_zip").value );
	

	var poststr = "thecontent=" +  encodeURI(document.getElementById("page_content").value);

	var t;

	xmlHttp.onreadystatechange=bleh;

	function bleh()
    {	
		if(xmlHttp.readyState==4)
		{
			if(xmlHttp.status==200)
			{
					//alert(xmlHttp.responseText);
				document.getElementById(elementToChange).innerHTML=xmlHttp.responseText;
				//window.open("javascript:document.writeln(" + xmlHttp.responseText + ");", 'OFFSCREEN','scrollbars=yes,resizable=yes,width=1024,height=768');
			 }
				
		}
	
    }

   xmlHttp.open("POST",url,true);
   xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   xmlHttp.setRequestHeader("Content-length", poststr.length);
   xmlHttp.setRequestHeader("Connection", "close");
   xmlHttp.send(poststr);
 
//   orderOK();
 //  alert("t is " + xmlHttp.responseText);
}

