function createObjectRequest()
{
	var request;
	try
	{
		request = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			request = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(e)
		{
			request = false;
		}
	}
	if(!request && typeof XMLHttpRequest != 'undefined')
	{
		try
		{
			request = new XMLHttpRequest();
		}
		catch(e)
		{
			request = false;
		}
	}
	return request;
}
var httpAddCartPersoaneFizice = createObjectRequest();
var idArticol;
function addCartPersoaneFizice(idArticol)
{
	ID = idArticol;
	pretSpalat = 0;
	pretCalcat = 0;
	var denumirea = document.getElementById("hidAdaugaInCosPersoaneFiziceDenumirea_" + idArticol).value;
	var UM = document.getElementById("hidAdaugaInCosPersoaneFiziceUM_" + idArticol).value;
	var cantitatea = document.getElementById("txtAdaugaInCosPersoaneFiziceCantitatea_" + idArticol).value;
	if(document.getElementById("chkAdaugaInCosPersoaneFizicePretSpalat_" + idArticol).checked == true)
		pretSpalat = document.getElementById("chkAdaugaInCosPersoaneFizicePretSpalat_" + idArticol).value;
	if(document.getElementById("chkAdaugaInCosPersoaneFizicePretCalcat_" + idArticol).checked == true)
		pretCalcat = document.getElementById("chkAdaugaInCosPersoaneFizicePretCalcat_" + idArticol).value;
	httpAddCartPersoaneFizice.open("get","procese.php?op=adauga_in_cos_persoane_fizice&id_articol=" + idArticol + "&denumirea=" + denumirea + "&um=" + UM + "&cantitatea=" + cantitatea + "&pret_spalat=" + pretSpalat + "&pret_calcat=" + pretCalcat);
	httpAddCartPersoaneFizice.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	httpAddCartPersoaneFizice.onreadystatechange  = processRequestAddCartPersoaneFizice;
	httpAddCartPersoaneFizice.send(null);
}
function processRequestAddCartPersoaneFizice()
{
	if(httpAddCartPersoaneFizice.readyState == 4 && httpAddCartPersoaneFizice.status == 200)
	{
		var response = httpAddCartPersoaneFizice.responseText;
		if(response)
		{
			document.getElementById("status_produs_" + ID).style.display = "block";
			document.getElementById("status_produs_" + ID).innerHTML = response;
			document.getElementById("txtAdaugaInCosPersoaneFiziceCantitatea_" + ID).value = "";
			if(response == '<span style="background-color:#0F0; padding:4px;">Produsul a fost adăugat</span>')
				total = pretTotalCosPersoaneFizice();
		}
	}
	else
	{
		document.getElementById("status_produs_" + ID).style.display = "block";
		document.getElementById("status_produs_" + ID).innerHTML = "<img src='img/ajax-loader.gif' width='220' height='19'>";
	}
}
var httpPretTotalCosPersoaneFizice = createObjectRequest();
function pretTotalCosPersoaneFizice()
{
	ID = idArticol;
	httpPretTotalCosPersoaneFizice.open("get","procese.php?op=pret_si_cantitate_total_cos");
	httpPretTotalCosPersoaneFizice.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	httpPretTotalCosPersoaneFizice.onreadystatechange  = processRequestPretTotalCosPersoaneFizice;
	httpPretTotalCosPersoaneFizice.send(null);
}
function processRequestPretTotalCosPersoaneFizice()
{
	if(httpPretTotalCosPersoaneFizice.readyState == 4 && httpPretTotalCosPersoaneFizice.status == 200)
	{
		var response = httpPretTotalCosPersoaneFizice.responseText;
		if(response)
		{
			document.getElementById("cosstanga").innerHTML = response;
		}
	}
	else
	{
		document.getElementById("cosstanga").innerHTML = "<img src='img/ajax-loader-square.gif' width='64' height='64'>";
	}
}
//----------persoane juridice
var httpAddCartPersoaneJuridice = createObjectRequest();
var idArticol;
function addCartPersoaneJuridice(idArticol)
{
	ID = idArticol;
	pretSpalat = 0;
	pretCalcat = 0;
	var denumirea = document.getElementById("hidAdaugaInCosPersoaneJuridiceDenumirea_" + idArticol).value;
	var UM = document.getElementById("hidAdaugaInCosPersoaneJuridiceUM_" + idArticol).value;
	var cantitatea = document.getElementById("txtAdaugaInCosPersoaneJuridiceCantitatea_" + idArticol).value;
	if(document.getElementById("chkAdaugaInCosPersoaneJuridicePretSpalat_" + idArticol).checked == true)
		pretSpalat = document.getElementById("chkAdaugaInCosPersoaneJuridicePretSpalat_" + idArticol).value;
	if(document.getElementById("chkAdaugaInCosPersoaneJuridicePretCalcat_" + idArticol).checked == true)
		pretCalcat = document.getElementById("chkAdaugaInCosPersoaneJuridicePretCalcat_" + idArticol).value;
	httpAddCartPersoaneJuridice.open("get","procese.php?op=adauga_in_cos_persoane_juridice&id_articol=" + idArticol + "&denumirea=" + denumirea + "&um=" + UM + "&cantitatea=" + cantitatea + "&pret_spalat=" + pretSpalat + "&pret_calcat=" + pretCalcat);
	httpAddCartPersoaneJuridice.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	httpAddCartPersoaneJuridice.onreadystatechange  = processRequestAddCartPersoaneJuridice;
	httpAddCartPersoaneJuridice.send(null);
}
function processRequestAddCartPersoaneJuridice()
{
	if(httpAddCartPersoaneJuridice.readyState == 4 && httpAddCartPersoaneJuridice.status == 200)
	{
		var response = httpAddCartPersoaneJuridice.responseText;
		if(response)
		{
			document.getElementById("status_produs_" + ID).style.display = "block";
			document.getElementById("status_produs_" + ID).innerHTML = response;
			document.getElementById("txtAdaugaInCosPersoaneJuridiceCantitatea_" + ID).value = "";
			if(response == '<span style="background-color:#0F0; padding:4px;">Produsul a fost adăugat</span>')
				total = pretTotalCosPersoaneJuridice();
		}
	}
	else
	{
		document.getElementById("status_produs_" + ID).style.display = "block";
		document.getElementById("status_produs_" + ID).innerHTML = "<img src='img/ajax-loader.gif' width='220' height='19'>";
	}
}
var httpPretTotalCosPersoaneJuridice = createObjectRequest();
function pretTotalCosPersoaneJuridice()
{
	ID = idArticol;
	httpPretTotalCosPersoaneJuridice.open("get","procese.php?op=pret_si_cantitate_total_cos");
	httpPretTotalCosPersoaneJuridice.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	httpPretTotalCosPersoaneJuridice.onreadystatechange  = processRequestPretTotalCosPersoaneJuridice;
	httpPretTotalCosPersoaneJuridice.send(null);
}
function processRequestPretTotalCosPersoaneJuridice()
{
	if(httpPretTotalCosPersoaneJuridice.readyState == 4 && httpPretTotalCosPersoaneJuridice.status == 200)
	{
		var response = httpPretTotalCosPersoaneJuridice.responseText;
		if(response)
		{
			document.getElementById("cosstanga").innerHTML = response;
		}
	}
	else
	{
		document.getElementById("cosstanga").innerHTML = "<img src='img/ajax-loader-square.gif' width='64' height='64'>";
	}
}
