$(document).ready(function () {
	$.ajaxSetup ({  
        cache: false
    }); 
});
function createXMLHttpRequest() {
	var req 
	if (window.XMLHttpRequest)
	{
		req = new XMLHttpRequest();

	} 
	else if (window.ActiveXObject) 
	{
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)
		{
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
   return req;
}

//this will only work for elements that have mass EG TR and TABLE cannot be used in this way
function loadFile(url, ID)
{
	$("#"+ID).html("<div style='text-align:center; margin:20px;'><img src='assets/loading.gif'/></div>")
	$("#"+ID).load(url);  
	/*loadXMLDoc(url , function()
	{
		if (this.readyState==4 && this.status==200)
		{
			var element = document.getElementById(ID)
			element.innerHTML = this.responseText
		}
	});*/
}
function loadFileCallBack(url, rfunc )
{
	var result
	loadXmlFileCallBack(url , function()
	{
		if (this.readyState==4 && this.status==200)
		{
			//var element = document.getElementById(ID)
			result = this.responseText
			rfunc(result)
		}
	}
	);
}

//this will only work for elements that are TR
//this will remove ALL cells and create 1 cell in its place

function loadFileTableRow(url, ID, colSpan)
{
	loadXMLDoc(url , function()
	{
		//alert(xmlhttp.readyState)
		if (this.readyState==4 && this.status==200)
		{
			var element = document.getElementById(ID)
			var totalcell = element.cells.length
			var cell1 = element.cells[0]
			for (var i = 0 ; i < totalcell; i++)
			{
				element.deleteCell(0);
			}
			
			element.insertCell(0);
			element.cells[0].colSpan=colSpan;
			element.cells[0].style.padding="0px"
			element.cells[0].innerHTML= this.responseText;

		}
	});
}
function loadXmlFileCallBack(url, cfunc)
{
	var xmlhttp
	xmlhttp= createXMLHttpRequest();
	xmlhttp.onreadystatechange=cfunc;
	xmlhttp.open("GET",url,true);
	xmlhttp.send();

//return xmlhttp
}
function loadXMLDoc(url, cfunc)
{
	var xmlhttp
	xmlhttp= createXMLHttpRequest();
	xmlhttp.onreadystatechange=cfunc;
	xmlhttp.open("GET",url,true);
	xmlhttp.send();

//return xmlhttp
}

function loadXMLGET(url)
{
	var xmlhttp
	xmlhttp= createXMLHttpRequest();
	xmlhttp.open("GET",url,true);
	xmlhttp.send();
}
//
function decodeXML(data){
	var xmlDoc
	if (window.DOMParser)
	{
		parser=new DOMParser();
		xmlDoc=parser.parseFromString(data,"text/xml");
	}
	else // Internet Explorer
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.loadXML(data);
	} 
	return xmlDoc;
}


