function do_POST_save(frm){delete xmlHttp;createXMLHttpRequest();var url=document.getElementById(frm).action;var args='';fname=document.getElementById(arguments[0]);chk_chk(fname);for(var elems=0;elems<fname.length;elems++){if(fname.elements[elems].name!==''){if((fname.elements[elems].type=="checkbox")&&(fname.elements[elems].checked==1)){if(args>''){args+='&';}args+=fname.elements[elems].name+"="+fname.elements[elems].value;}}}var query=args+'&save=save&ajx=1'+'&ts='+new Date().getTime();delete_product_rows_save(frm);if(!xmlHttp){window.document.form_frd.submit();}else{xmlHttp.open("POST",url,true);xmlHttp.onreadystatechange=handleStateChange_Save;xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlHttp.send(query);}}function handleStateChange_Save(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){begin_updates_save();}else{alert("Ooops! An error seems to have occured:: Error Code:"+xmlHttp.status);}}}function begin_updates_save(){var xmlDoc=xmlHttp.responseXML,msgs=xmlDoc.getElementsByTagName("message"),total=xmlDoc.getElementsByTagName("count"),totcost=xmlDoc.getElementsByTagName("totcost");update_bits(msgs,total,totcost);}function update_bits(msgs,total,totcost){var msg='',count='',totalprice='',itemkey='',currentProd=null,currentMsg=null,currentTot=null,currentTotCost=null;currentMsg=msgs[0];if((currentMsg!==null)&&(currentMsg.childNodes[0]!==null)){msg=currentMsg.childNodes[0].nodeValue;}currentTot=total[0];if((currentTot!==null)&&(currentTot.childNodes[0]!==null)){count=currentTot.childNodes[0].nodeValue;}currentTotCost=totcost[0];if((currentTotCost!==null)&&(currentTotCost.childNodes[0]!==null)){totalprice=currentTotCost.childNodes[0].nodeValue;}if(msg>''){if(msg.substr(0,4)=='PASS'){if(count>0){document.getElementById('slcount').innerHTML='('+count+')';}else if(count===0){document.getElementById('slcount').innerHTML='';document.getElementById('tdcell2').innerHTML='';toggleDisable('create');toggleDisable('save');}document.getElementById('slcount2').innerHTML='('+count+' items)';if(totalprice>''){document.getElementById('totalcost').innerHTML=totalprice;}}else if(msg.substr(0,4)=='FAIL'){alert("Ooops! A problem seems to have occured ... You may wish to refresh the page and try again");}}}function delete_product_rows_save(){var fname=document.getElementById(arguments[0]);for(var elems=0;elems<fname.length;elems++){if(fname.elements[elems].type=="checkbox"){if(fname.elements[elems].checked==1){var elem=fname.elements[elems].name;var row=document.getElementById('r'+elem.substr(4));var id='r'+elem.substr(4);var rowRef=document.getElementById(id);document.getElementById(id).style.display='none';try{var id2='r2'+elem.substr(4);var rowRef = document.getElementById(id2);document.getElementById(id2).style.display='none';}catch(e){};try{var id3='r3'+elem.substr(4);var rowRef = document.getElementById(id3);document.getElementById(id3).style.display='none';}catch(e){};}}}for(elems=0;elems<fname.length;elems++){if(fname.elements[elems].type=="checkbox"){if(fname.elements[elems].checked==1){fname.elements[elems].checked=0;elem=fname.elements[elems].name;row=document.getElementById('r'+elem.substr(4));id='r'+elem.substr(4);rowRef=document.getElementById(id);rowRef.parentNode.removeChild(rowRef);}}}if(typeof oldprods!="undefined"){var rcount=document.getElementById('oldprods').rows.length;alert(rcount);if(rcount===0){document.getElementById('oldp').style.display='none';}}}