function flagProduct( id, element ) { PopupTrasher.killEmAll(); var popup = DrElement.create( element.parentNode, 'div', 'problemPopup' + id, { display: 'none', position: 'absolute', clear: 'left', width: '250px' } ); popup.innerHTML = '
' + '
What is wrong with this product?
' + '[x]
' + '' + '
' ; DrElement.fadeIn( popup, 300 ); PopupTrasher.register( popup ); } var xmlhttp = null; function flag (iProductId, iFlag) { var sURL = "flag.php"; var sQueryString = "p=" + iProductId + "&f=" + iFlag; if (window.XMLHttpRequest) {// code for Mozilla, Safari, etc xmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=handleFlagResult; xmlhttp.open("POST",sURL,true); xmlhttp.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); xmlhttp.send(sQueryString); } else if (window.ActiveXObject) {//IE xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); if (xmlhttp) { xmlhttp.onreadystatechange=handleFlagResult; xmlhttp.open("POST",sURL,true); xmlhttp.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); xmlhttp.send(sQueryString); } } } function handleFlagResult () { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { var oXML; oXML = xmlhttp.responseXML; var oRedirect = oXML.getElementsByTagName("redirect").item(0); if (oRedirect) { self.location = oRedirect.getAttribute("url"); } else { var oError = oXML.getElementsByTagName("e").item(0); if (oError) { alert (oError.getAttribute("m")); } else { var oProd = oXML.getElementsByTagName("r").item(0); updateFlag (oProd.getAttribute("id"), oProd.getAttribute("f")); } } xmlhttp = null; } } } function updateFlag (iProductId, sFlag) { $( 'problemPopupActions' + iProductId ).innerHTML = sFlag; }