var myReq = null;
function AJAXReq(methodtype,url,asynch,resp)
{
	if(window.XMLHttpRequest)
	{
		myReq = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
   	myReq = new ActiveXObject("Msxml2.XMLHTTP");
		if(!myReq)
		{
      	myReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
 
	if(myReq)
	{
		if(methodtype.toLowerCase() != "post")
		{
			execfunc(methodtype,url,asynch,resp);
		}
	   else
  		{
		   var args = arguments[4];
			execfunc(methodtype,url,asynch,resp,args);
		}
	}
	else
	{
   	alert("Your browser doesn't support AJAX utilities");
	}
}

function execfunc(methodtype,url,asynch,resp)
{
	try
	{
   	myReq.onreadystatechange = resp;
	   myReq.open(methodtype,url,asynch);
      if(methodtype.toLowerCase() == "post")
		{
      	myReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
			myReq.send(arguments[4]);
	   }
		else
		{
      	myReq.send(null);
	   }
	}
	catch(errv)
	{
    	alert("Enable to contact the server\nError: "+errv.message);
	}
}

function handleResponse(objID)
{
	var obj = document.getElementById(objID);
	if(myReq.readyState == 4 && myReq.status == 200)
	{
		obj.innerHTML = myReq.responseText;
	}
}


var xmlhttp = false;
var ie = 0;
try 
{
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	ie = 1;
}
catch (e) 
{
	try 
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		ie = 1;
	} 
	catch (E)
	{
		ie = 0;
		xmlhttp = false;
	}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
{
	xmlhttp = new XMLHttpRequest();
}
function makerequest(serverPage, objID) 
{
	var obj = document.getElementById(objID);
	xmlhttp.open("GET", serverPage);
	xmlhttp.onreadystatechange = function() 
	{
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
		{
			obj.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}
function selButton(tdBtn)
{
	document.getElementById('brch').style.fontWeight = 'normal';
	document.getElementById('brch').style.color = '#333333';
	
	document.getElementById('mnul').style.fontWeight = 'normal';
	document.getElementById('mnul').style.color = '#333333';
	
	document.getElementById('sftw').style.fontWeight = 'normal';
	document.getElementById('sftw').style.color = '#333333';
	
	document.getElementById('utls').style.fontWeight = 'normal';
	document.getElementById('utls').style.color = '#333333';
	
	//document.getElementById(tdBtn).style.backgroundPosition = '150px';
	document.getElementById(tdBtn).style.fontWeight = 'bold';
	document.getElementById(tdBtn).style.color = '#960000';
}
function loader(id, dim_width, dim_height)
{
	document.getElementById(id).style.display = 'block';
	document.getElementById(id).style.visibility = 'visible';
	document.getElementById(id).innerHTML = '<table width="' + dim_width + '" height="' + dim_height + '"><tr valign="middle"><td align="center"><img src="images/loader.gif"></td></tr></table>';
}
function AddProduct(id, param)
{
	loader(id, 660, 50);
	if (param == "off")
	{
		setTimeout("AJAXReq('GET','productlist.php',true,function (){handleResponse('"+id+"')});", 0);
	}
	else
	{
		setTimeout("AJAXReq('GET','productlist.php?"+param+"',true,function (){handleResponse('"+id+"')});", 500);
	}
}
function LoadDownloadContent(id, param)
{
	loader(id, 600, 200);
	if (param == "off")
	{
		setTimeout("AJAXReq('GET','download_content.php',true,function (){handleResponse('"+id+"')});", 0);
	}
	else
	{
		setTimeout("AJAXReq('GET','download_content.php?"+param+"',true,function (){handleResponse('"+id+"')});", 500);
	}
}