
var objXMLHTTPReq = false;

if (window.XMLHttpRequest)
  { objXMLHTTPReq=new XMLHttpRequest(); } //IE7+, Firefox, Chrome, Opera, Safari
else
  { objXMLHTTPReq=new ActiveXObject("Microsoft.XMLHTTP"); } //IE5,IE6


//Stuff for Google Analytics
function GAsuccess(page)
{
_gaq.push(['_trackPageview', '/GA-Virtual/'+page]);
}



function DoAjaxArrangeJQ(strURL)
{
	$.ajax({
		type: 'GET',
		url: strURL,
		dataType: 'text',
		success: function(html,textStatus, xhr) 
				{   
                                    strTemp=html;
                                    strTemp=strTemp.replace("\r",""); strTemp=strTemp.replace("\n","");
      				    if(strTemp == "1")
					alert("Request Sent");
                                    GAsuccess('Arrange-a-Viewing-Submission');
				},
		error: function(xhr,textStatus,errorThrown) {
					alert("an error occurred");
					}
		});
}


function DoAjaxReplace(divID,strURL)
{
	if(objXMLHTTPReq == false) return;
        var objElement=document.getElementById(divID);
	objXMLHTTPReq.open("GET",strURL);
	objXMLHTTPReq.onreadystatechange=function()
	{
		if( (objXMLHTTPReq.readyState==4) && (objXMLHTTPReq.status==200) )
		{
                    strResponse=objXMLHTTPReq.responseText;
//                    alert("ajax returned: " + strResponse); ///
                    objElement.innerHTML=strResponse;
   		} 
	} 
       objXMLHTTPReq.send(null);  
}	


function DoAjax(showID,hideID,blankID,strURL)
{
	if(objXMLHTTPReq == false) return;
	objXMLHTTPReq.open("GET",strURL);
	objXMLHTTPReq.onreadystatechange=function()
	{
		if( (objXMLHTTPReq.readyState==4) && (objXMLHTTPReq.status==200) )
		{
                    strResponse=objXMLHTTPReq.responseText;
                    if(strResponse == "1")
                    {
                        ShowElement(showID);
                        HideElement(hideID);
						BlankElement(blankID);
                    }
		} 
	} 
       objXMLHTTPReq.send(null);  
}	


function ShowElement(strID)
{
	if(strID.length==0) return;
    objElem=document.getElementById(strID);
    objElem.style.visibility = "visible";
    objElem.style.display = "";
}

function HideElement(strID) //Don't render it
{
	if(strID.length==0) return;
    objElem=document.getElementById(strID);
    objElem.style.visibility = "visible";
    objElem.style.display = "none";
}

function BlankElement(strID) //make invisible
{	
	if(strID.length==0) return;
    objElem=document.getElementById(strID);
    objElem.style.visibility = "hidden";
    objElem.style.display = "";
}

//-------------------------------------------------------------



