
var xmlHttp

function SimpleFetch(action)
{ 
	var xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=action;
	//url=url+"?fname="+fname
	//url=url+"&lname="+lname
	var urlAry=url.split("&id=");
	var id = urlAry[1];
	var pg = urlAry[0].split(".");

	//xmlHttp.onreadystatechange=stateChanged 
	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;
	//url=url+"?fname="+fname
	//url=url+"&lname="+lname
	var urlAry=url.split("&id=");
	var id = urlAry[1];
	var pg = urlAry[0].split(".");

	//xmlHttp.onreadystatechange=stateChanged 
	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)
{
//alert(placetoreplace);
	xmlHttp1=GetXmlHttpObject();
	var url = action;
	var params = "fld=1000";
	xmlHttp1.open("POST", url, true);
	
	//Send the proper header information along with the request
	xmlHttp1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp1.setRequestHeader("Content-length", params.length);
	xmlHttp1.setRequestHeader("Connection", "close");
	
	xmlHttp1.onreadystatechange = function() {//Call a function when the state changes.
		if(xmlHttp1.readyState == 4 && xmlHttp1.status == 200) {
			//alert(placetoreplace + '-' + xmlHttp1.responseText);
			document.getElementById(placetoreplace).innerHTML=xmlHttp1.responseText 
		}
	}
	xmlHttp1.send(params);	
}

function UsingPost_ship(action_ship, placetoreplace_ship)
{
	//alert(placetoreplace);
	xmlHttp2=GetXmlHttpObject();
	var url = action_ship;
	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);
			document.getElementById(placetoreplace_ship).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
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		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);
}

/*var xmlHttp

function showCustomer(str)
{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url="getcustomer.php"
	url=url+"?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function StartProcedure(action, placetoreplace)
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url=action
	//url=url+"?fname="+fname
	//url=url+"&lname="+lname
	xmlHttp.onreadystatechange=stateChanged (placetoreplace)
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged(placetoreplace) {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		//alert(xmlHttp.responseText);
		//var result = xmlHttp.responseText.split("|");
		//alert(result[0]);
		//if(result[0] != "") {
			//document.getElementById(placetoreplace).innerHTML=result[0];
		//}
		//if(result[1] != "") {
			//document.getElementById(placetoreplace).innerHTML=result[1];
		//}
		document.getElementById(placetoreplace).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
}*/