
var specListObj
function GetSpecList(obj,articleId,specId,frontEndId,i){
	var http_request = GetHttpRequest();
	if(!http_request) return false; // Kan geen ajax component aanmaken.

	var specItemId2
	if (document.getElementById("specsItemId_"+i)){
  	specListObj = document.getElementById("specsItemId_"+i)
		specItemId2 = specListObj.options[specListObj.selectedIndex].value
	}else{
		specListObj = obj
	}
	url = _PROJECT_URL + "xml/GetSpecList.xml.asp?frontEndId="+frontEndId+"&articleId="+articleId+"&specId="+specId+"&specItemId="+obj.options[obj.selectedIndex].value+"&specItemId2="+specItemId2
	//window.open(url)
	http_request.onreadystatechange = function() { FillSpecList(http_request); };
	http_request.open('GET', url, true);
	http_request.send(null);
}

function FillSpecList(http_request){
	if (http_request.readyState == 4)	{
		if (http_request.status == 200) {
			var xmldoc = http_request.responseXML;
			var specOptionListLength = xmldoc.getElementsByTagName('spec').length
			var xmlItems = xmldoc.getElementsByTagName('spec')
			if (specOptionListLength>0){
				document.getElementById(specListObj.id).options.length = 0
				for (var i=0;i<specOptionListLength;i++){
					document.getElementById(specListObj.id).options[i] = new Option(xmlItems[i].getElementsByTagName("lable")[0].childNodes[0].nodeValue,xmlItems[i].getElementsByTagName("id")[0].childNodes[0].nodeValue)
				}
			}
			document.getElementById("xml_price").innerHTML=xmldoc.getElementsByTagName('prices')[0].getElementsByTagName('c_price')[0].childNodes[0].nodeValue
			//document.getElementById("price").value=xmldoc.getElementsByTagName('prices')[0].getElementsByTagName('price')[0].childNodes[0].nodeValue
		}
	}	
}

function GetSpecPrice(articleId,frontEndId,obj1,obj2){
	var http_request = GetHttpRequest();
	if(!http_request) return false; // Kan geen ajax component aanmaken.

	var specId_1
	if (document.getElementById(obj1)){
		specId_1 = document.getElementById(obj1).options[document.getElementById(obj1).selectedIndex].value
	}else{
		specId_1 = ""
	}
	var specId_2
	if (document.getElementById(obj2)){
		specId_2 = document.getElementById(obj2).options[document.getElementById(obj2).selectedIndex].value
	}else{
		specId_2 = ""
	}
	
	if (specId_1==""){
		specId_1=specId_2
		specId_2=""
	}
	url = _PROJECT_URL + "xml/GetSpecPrice.xml.asp?frontEndId="+frontEndId+"&articleId="+articleId+"&specId_1="+specId_1+"&specId_2="+specId_2
	//window.open(url)
	http_request.onreadystatechange = function() { FillSpecPrice(http_request); };
	http_request.open('GET', url, true);
	http_request.send(null);
}

function FillSpecPrice(http_request){
	if (http_request.readyState == 4)	{
		if (http_request.status == 200) {
			var xmldoc = http_request.responseXML;
			document.getElementById("xml_price").innerHTML=xmldoc.getElementsByTagName('prices')[0].getElementsByTagName('c_price')[0].childNodes[0].nodeValue
			//document.getElementById("price").value=xmldoc.getElementsByTagName('prices')[0].getElementsByTagName('price')[0].childNodes[0].nodeValue
		}
	}	
}
