// JavaScript Document
var xmlhttp = false;
function loadDeviceOptions(num, prd, type, lang){
	var man_id = $('manufac_' + num).value;
   
	//var url = "http://192.168.0.61/typo3_colorgate/typo3conf/ext/cg_productconfigurator/res/ajax_device_selection.php?man_id=" + man_id + "&prd=" + prd + "&type=" + type + "&num=" + num + "&lang=" + lang;
	var url = "http://www.colorgate.com/typo3conf/ext/cg_productconfigurator/res/ajax_device_selection.php?man_id=" + man_id + "&prd=" + prd + "&type=" + type + "&num=" + num + "&lang=" + lang;
	getHttpRequest(url, 'deviceSelectionDrop_' + num);
}

function addDeviceSelection(prd, type, lang){
		var selectionNum = parseInt($('selectionNum').innerHTML);
		if( isNaN(selectionNum)){ selectionNum = 0; }
		
		var divTag = document.createElement("div");
		divTag.id = "deviceSelection_" + (selectionNum + 1);		
		$('deviceSelections').appendChild(divTag);
		
		//var url = "http://192.168.0.61/typo3_colorgate/typo3conf/ext/cg_productconfigurator/res/ajax_device_selection_area.php?prd=" + prd + "&type=" + type + "&num="+ (selectionNum + 1) +"&lang=" + lang;
		var url = "http://www.colorgate.com/typo3conf/ext/cg_productconfigurator/res/ajax_device_selection_area.php?prd=" + prd + "&type=" + type + "&num="+ (selectionNum + 1) +"&lang=" + lang;
		getHttpRequest(url, 'deviceSelection_' + (selectionNum + 1));
		$('selectionNum').innerHTML = selectionNum + 1;
}


function setHTMLContent(update, text){
	$(update).innerHTML = text;
	GLT.init();
}

function getHttpRequest(url, update) {   
    var xmlhttp = null;
		var response = '';    
    if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); }// Mozilla
    else if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }// IE
   
    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            setHTMLContent(update, xmlhttp.responseText);
        }
    }
    xmlhttp.send(null);
} 