var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var savXML  

function postXML()
	{
	if (((f.country.value=="PL") && (f.fp5.checked)) || (f.name.value.substr(1,3)=="590") || (f.name.value.substr(2,3)=="590"))	
		xmlhttp.Open("POST", "gepirserverpl.asp", false);
	else 	xmlhttp.Open("POST", "gepirserverpl.asp", false);
	var XMLReq = new ActiveXObject("Microsoft.XMLDOM");
	XMLReq.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"")

	root = XMLReq.createElement("GEPIR00")
	XMLReq.appendChild(root)
	root.setAttribute("Version", "2.0")
//	root.setAttribute("xmlns:xsi", "http://www.w3.org/1999/XMLSchema-instance")
//	root.setAttribute("xsi:noNamespaceSchemaLocation", "gepir00v2.xsd")
	term = XMLReq.createElement("T0095")
//	term.text="4000001000005" //udajemy Niemcy
	term.text="5900009900002" //udajemy pOLSKE
	root.appendChild(term)
	term = XMLReq.createElement("TYPE")
	if (f.fp5.checked) term.text = "3"              // name 
	else if (f.fp4.checked) term.text = "2"         // GLN 
	else term.text = "1";             
	root.appendChild(term)
	
	term = XMLReq.createElement("SUBTYPE")
	if (f.fp1.checked) term.text = "8"              // EAN 8 
	else if (f.fp2.checked) term.text = "13"
	else if (f.fp3.checked) term.text = "14"        // EAN 14 
	else if (f.fp6.checked) term.text = "18"        // SSCC 
	else if (f.fp4.checked) term.text = "1"
	else term.text = f.country.value; 
	root.appendChild(term)	
	
	term = XMLReq.createElement("VAL")
	if (f.fp5.checked) {
		term.text = f.name.value    		  // name
		}
	else term.text = f.number.value;
	root.appendChild(term)	

	term = XMLReq.createElement("ZIP")
	term.text=""
	root.appendChild(term)

	term = XMLReq.createElement("CITY")
	term.text=""
	root.appendChild(term)

	
	term = XMLReq.createElement("CASCADE")
	term.text="9"
	root.appendChild(term)



//	alert(XMLReq.xml); test//pokazuj zapytania
	xmlhttp.Send(XMLReq);
	
	resp = xmlhttp.responseXML;
	// document.write(xmlhttp.responseXML.xml); //pokazuj odpowiedz

	if ((xmlhttp.statusText == "OK") && (xmlhttp.responseXML.parseError.errorCode == 0) && (xmlhttp.responseXML.documentElement != null)) {
		divHTML.innerHTML = xmlhttp.responseXML.documentElement.transformNode(XSLDoc.documentElement)
		savXML = xmlhttp.responseXML.documentElement
		f.B2.style.visibility = "visible"
		}
	else {
		divTEXT.innerHTML = xmlhttp.responseText
		divHTML.innerHTML = xmlhttp.responseXML.parseError.reason
		f.B2.style.visibility = "hidden"
		}




	}





function postXMLa()
	{    
	xmlhttp.Open("POST", "gepirserverpl.asp", false);                   // with server 
	var req = XMLReq.XMLDocument.documentElement;                     // point at document root 
	req.childNodes.item(0).text = "5900009900002"                     // me 
	if (f.fp5.checked) req.childNodes.item(1).text = "3"              // name 
	else if (f.fp4.checked) req.childNodes.item(1).text = "2"         // GLN 
	else req.childNodes.item(1).text = "1";                           // GTIN or SSCC 
	if (f.fp1.checked) req.childNodes.item(2).text = "8"              // EAN 8 
	else if (f.fp3.checked) req.childNodes.item(2).text = "14"        // EAN 14 
	else if (f.fp6.checked) req.childNodes.item(2).text = "18"        // SSCC 
	else req.childNodes.item(2).text = "13";                          // EAN 13 
	if (f.fp5.checked) {
		req.childNodes.item(3).text = f.name.value    		  // name
		req.childNodes.item(2).text = f.country.value		  // country 
		}
	else req.childNodes.item(3).text = f.number.value                 // number
	xmlhttp.setRequestHeader("Content-type", "text/xml")
	xmlhttp.Send(XMLReq.XMLDocument);
	
	document.write(xmlhttp.responseText);
	if ((xmlhttp.statusText == "OK") && (xmlhttp.responseXML.parseError.errorCode == 0) && (xmlhttp.responseXML.documentElement != null)) {
		divHTML.innerHTML = xmlhttp.responseXML.documentElement.transformNode(XSLDoc.documentElement)
		savXML = xmlhttp.responseXML.documentElement
		f.B2.style.visibility = "visible"
		}
	else {
		divTEXT.innerHTML = xmlhttp.responseText
		divHTML.innerHTML = xmlhttp.responseXML.parseError.reason
		f.B2.style.visibility = "hidden"
		}
	}
	
function cleanup()
	{
	f.number.value = "5900000000000";
	numopen();
	divTEXT.innerHTML = " ";
	divHTML.innerHTML = " ";
	}

function numopen()
	{
	f.number.disabled = false;
	f.name.disabled = true;
	f.country.disabled = true;
	}


function nameopen()
	{
	f.number.disabled = true;
	f.name.disabled = false;
	f.country.disabled = false;
	}

function showXML()
	{
	divHTML.innerText = savXML.xml
	f.B2.style.visibility = "hidden"
	}
