

function calcmilk(){


var pa =''; 
    
var days = document.milkform.days.value;    
	    
if ( days != undefined) {  // ansonsten js Fehlerquelle
	pa += '&days='+days; 
}		 
			   
var price_now = document.milkform.price_now.value;    
	    
if ( price_now != undefined) {  // ansonsten js Fehlerquelle
	pa += '&price_now='+price_now; 
}

var price_target = document.milkform.price_target.value;    
	    
if ( price_target != undefined) {  // ansonsten js Fehlerquelle
	pa += '&price_target='+price_target; 
}	
	
   	var req = "action=calcMilk"+pa;
	//alert(req);
	ajaxReq(req);

}

	
function ajaxReq(request_str){
    //alert(request_str);
    sndReq('extensions/ajax/cgi.php',request_str);

}

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq( dest,postpar) {    
//alert(dest);
	http.open('POST', dest);
    http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    

    http.onreadystatechange = handleResponse;
    http.send(postpar);

}	



function handleResponse() {
    if(http.readyState == 4){
//alert(http.responseText);   
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');



            
            if(update[1]=='createDomElement') {
            	
            	

// call your function to remove all the children from your element
so_clearInnerHTML(document.getElementById("milk_calculator_2"));

	            	
ajaxt = document.createElement("div");  
ajaxt.setAttribute("id","myAjaxDiv");          	
ajaxt.appendChild(document.createTextNode(update[3]));            	
            	
            	
            	
            	
// alert('8888');
// create a DIV element, using the variable eDIV as a reference to it
eDIV = document.createElement("div");
//use the setAttribute method to assign it an id
eDIV.setAttribute("id","myAjaxDivHead");
// add the text "hello world" to the div with createTextNode
eDIV.appendChild(document.createTextNode(update[2]));

eDIV.appendChild(ajaxt);

// append your newly created DIV element to an already existing element.
document.getElementById("milk_calculator_2").appendChild(eDIV);

            } 
					
						   
        }
    }
    //openDebugPopup1("save_pos.php");
}	
	
	
function so_clearInnerHTML(obj) {
	// so long as obj has children, remove them
	while(obj.firstChild) obj.removeChild(obj.firstChild);
}
		




