function addeal(kid,p,n,w){

var div = document.getElementById("Magic");
var ww=document.getElementById(w).value;  
var nn=document.getElementById(n).value; 
var qty = Number(document.getElementById("mqty").value)+1;  document.getElementById("mqty").value=qty; 
var tstr=div.innerHTML; 
var result = [];

var nowprice=0;
var total=0;
var magictotal=0;
var save=0;

var end="<tr><td colspan='2' height='8'>";
document.getElementById("quantity"+kid).value+=1;
if( tstr.indexOf("Total")<0) 
            tstr="<table width='100%'border='0'cellpadding='0' cellspacing='0'><tr><td width='33%' height ='8' style='border-width: 1px; border-style: none none solid ;' >ID:</td>"+
             "<td style='border-width: 1px; border-style: none none solid ;' >Was</td><td style='border-width: 1px; border-style: none none solid ;' >Now</td></tr>";  
			 else  tstr=tstr.substring(0, tstr.indexOf("Total")-(end.length)+3+1);//
//p=0;
 p=document.getElementById("price"+kid).value;
qty=(1-Math.round(Math.random()*100)/100).toFixed(2); 
if(qty<(1/(qty%3+1)*0.9).toFixed(2)) qty=(1/(qty%3+1)*0.9).toFixed(2);
nowprice=Math.round(Number(p)*qty*100)/100;		   
magictotal=Math.round((Number(nn)+ nowprice)*100)/100; 
document.getElementById(n).value=magictotal;
total=Math.round((Number(ww)+ Number(p))*100)/100; 
document.getElementById(w).value=total;
save=(total-magictotal).toFixed(2); 
result.push("<tr><td height= '3'>hot"+ kid + "</td><td class=blue >$"+ p + "</td> <td class=red>"+nowprice+"</td></tr>");
result.join(result);
div.innerHTML=""; 
div.innerHTML +=tstr+result+"<tr><td colspan='3' height='8'>Total:$"+total+"</td></tr><tr><td colspan='3' style='border-width:1px; border-style:solid none none;' bgcolor='#ffff66' class=red>Save:"+save+
"</td></tr><tr><td height='8'colspan='3' bgcolor='#ffff66'  class=blue> Magic Total:$"+magictotal+"</td></tr></table>";
window.scrollBy(0,15); //alert (div.innerHTML);

return;

}
function clearCal(){
var div = document.getElementById("Magic");
var was = document.getElementById("wwas");
var qty = document.getElementById("mqty");
var nn = document.getElementById("nnow");
div.innerHTML="<div align=center >Mix Order with another item<br><font class=red>Can Save More! </font></div>"; 
was.value="";
qty.value="";
nn.value="";
return;
}

function getMagic() {
var mgc = document.getElementById("Magic");

return mgc.innerHTML;
}


