var xmlHttp

function SimpleFetch(action)
{ 
	var xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=action;
	var urlAry=url.split("&id=");
	var id = urlAry[1];
	var pg = urlAry[0].split(".");

	
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 			
			document.getElementById(id).innerHTML=xmlHttp.responseText ;
		} 
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function UsingGet(action)
{ 
	var xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=action;
	
	
	var urlAry=url.split("&id=");
	var id = urlAry[1];
	var pg = urlAry[0].split(".");


	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			if(id=='task_list')
			{
				if(pg[0]=='update_task')
				{
					id2 = 'tsk_msg';
					document.getElementById(id2).style.backgroundColor="#90C311";
					document.getElementById(id2).style.color="#FFFFFF";
					document.getElementById(id2).style.fontWeight="bold";					
					document.getElementById(id2).innerHTML='Tasks have been Updated successfully.';	
				}
				document.getElementById(id).innerHTML=xmlHttp.responseText ;					
			}
			else
			{
				if(pg[0]!='project_user_list')
				{
					document.getElementById(id).style.backgroundColor="#90C311";
					document.getElementById(id).style.color="#FFFFFF";
					document.getElementById(id).style.fontWeight="bold";
				}
				document.getElementById(id).innerHTML=xmlHttp.responseText ;
			}
		} 
	}
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}



function UsingPost(action, placetoreplace)
{

	xmlHttp1=GetXmlHttpObject();
	var url = action;
	var params = "fld=1000";
	xmlHttp1.open("POST", url, true);
	
	
	xmlHttp1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp1.setRequestHeader("Content-length", params.length);
	xmlHttp1.setRequestHeader("Connection", "close");
	
	xmlHttp1.onreadystatechange = function() {
		if(xmlHttp1.readyState == 4 && xmlHttp1.status == 200) {

		if(document.getElementById(placetoreplace))
			document.getElementById(placetoreplace).innerHTML=xmlHttp1.responseText 
		}
	}
	xmlHttp1.send(params);	
}

function UsingPost_ship(action_ship, placetoreplace_ship)
{

	xmlHttp2=GetXmlHttpObject();
	var url = action_ship;
	var params = "fld=1000";
	xmlHttp2.open("POST", url, true);
	
	
	xmlHttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp2.setRequestHeader("Content-length", params.length);
	xmlHttp2.setRequestHeader("Connection", "close");
	
	xmlHttp2.onreadystatechange = function() {
		if(xmlHttp2.readyState == 4 && xmlHttp2.status == 200) {

		if(document.getElementById(placetoreplace_ship))
			document.getElementById(placetoreplace_ship).innerHTML=xmlHttp2.responseText 
		}
	}
	xmlHttp2.send(params);	
}
function UsingPost_Tusu(action_tusu, placetoreplace_tusu)
{
	//alert(placetoreplace);
	xmlHttp2=GetXmlHttpObject();
	var url = action_tusu;
	var params = "fld=1000";
	xmlHttp2.open("POST", url, true);
	
	//Send the proper header information along with the request
	xmlHttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp2.setRequestHeader("Content-length", params.length);
	xmlHttp2.setRequestHeader("Connection", "close");
	
	xmlHttp2.onreadystatechange = function() {//Call a function when the state changes.
		if(xmlHttp2.readyState == 4 && xmlHttp2.status == 200) {
			//alert(placetoreplace + '-' + xmlHttp2.responseText);
		if(document.getElementById(placetoreplace_tusu))
			document.getElementById(placetoreplace_tusu).innerHTML=xmlHttp2.responseText 
		}
	}
	xmlHttp2.send(params);	
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
	} 
} 
function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}


function ajaxFunction(url)
{
	var xmlHttp;
	try
	{
		
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		
		try
			{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
    xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById("productlist").innerHTML=document.getElementById("productlist").innerHTML+xmlHttp.responseText;
		}
	}
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}


