// creaxial.net 2006

function openDopup(divId, dopupTitle) {
	document.getElementById(divId).style.display= "block";
	document.getElementById("dopup-titlebar-text").innerHTML = dopupTitle;
	if (document.getElementById("dopupcontentiframe")) document.getElementById("dopupcontentiframe").src = document.getElementById("dopupcontentiframe").src;
}

function closeDopup(divId) {
	document.getElementById(divId).style.display= "none";
}




function openDopupUpload(divId, filetype, taskId, popupTitle, prodId) {
	document.getElementById(divId).style.display= "block";
	document.getElementById("upload-dopup-message").style.display = "none";
	document.getElementById("filetype").value = filetype;
	document.getElementById("uploadtid").value = taskId;
	document.getElementById("dopup-titlebar-text").innerHTML = popupTitle;
	document.getElementById("warning_img").innerHTML='<img src="graphics/upload_img/'+prodId+'.jpg" alt="">';
	if (filetype!=null){
		//
	}
}

function closeDopupUpload(divId) {
	document.getElementById(divId).style.display= "none";
}


function postform() {
	document.forms['formu'].submit();
}


function createRequestObject() {
    var xo;
	if (window.XMLHttpRequest) { xo = new XMLHttpRequest(); }
	else if (window.ActiveXObject) {
		try {
			xo = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xo = new ActiveXObject("Microsoft.XMLHTTP");
		}
	} else {
	   xo = false;
	}
	return xo;
}

function plus1000(itemid, upordown, displaytotal) {
	if (displaytotal!='true') displaytotal = 'false';
	var http = createRequestObject();
	http.open('get', 'common/httpRequest.php?f=plus1000&itemid='+itemid+'&upordown='+upordown+'&displaytotal='+displaytotal);
	http.onreadystatechange = function(){
		if (http.readyState == 4){
			var xmlresponse = http.responseXML;
			if (xmlresponse) {
				var node_doc = xmlresponse.getElementsByTagName('xml').item(0);
				var node_status = node_doc.getElementsByTagName('status').item(0).firstChild.data;
				if (node_status == 'true') {
					var node_newqty = node_doc.getElementsByTagName('newqty').item(0).firstChild.data;
					var node_newprix = node_doc.getElementsByTagName('newprix').item(0).firstChild.data;
					//node_newprix = parseFloat(node_newprix);
					document.getElementById("qtyvalue"+itemid).innerHTML = node_newqty;
					document.getElementById("prixvalue"+itemid).innerHTML = node_newprix;
					if (displaytotal == 'true') {
						var node_newtotal_com = node_doc.getElementsByTagName('newtotal_com').item(0).firstChild.data;
						var node_newtotal_ht = node_doc.getElementsByTagName('newtotal_ht').item(0).firstChild.data;
						var node_newtotal_tva = node_doc.getElementsByTagName('newtotal_tva').item(0).firstChild.data;
						var node_newtotal = node_doc.getElementsByTagName('newtotal').item(0).firstChild.data;
						document.getElementById("total_com").innerHTML = node_newtotal_com;
						document.getElementById("total_ht").innerHTML = node_newtotal_ht;
						document.getElementById("total_tva").innerHTML = node_newtotal_tva;
						document.getElementById("total").innerHTML = node_newtotal;
						if (node_doc.getElementsByTagName('newtotal_reduc')) document.getElementById("total_reduc").innerHTML = node_doc.getElementsByTagName('newtotal_reduc').item(0).firstChild.data;
					}
				}
			}
	    }
	};
	http.send(null);
}

function openTool(pT,pF,pL,pW,pH,pN,pS) {
	window.open('creation_tool/tool.php?pT='+pT+'&pF='+pF+'&pL='+pL+'&pW='+pW+'&pH='+pH+'&pN='+pN+'&pS='+pS,'tool','');
}
