function AJAX_Object() { var temp; if (window.XMLHttpRequest) { //----------------------------------------------- //If IE7, Mozilla, Safari, etc: Use native object //----------------------------------------------- temp = new XMLHttpRequest(); if (temp.overrideMimeType) { //------------------------------------------------ //set type accordingly to anticipated content type //------------------------------------------------ temp.overrideMimeType('text/html'); } } else { if (window.ActiveXObject) { //------------------------------------------------------- //...otherwise, use the ActiveX control for IE5.x and IE6 //------------------------------------------------------- try { temp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { temp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } } return(temp); } var xmlHttp = AJAX_Object(); function send() { $('send').value = 'Sending...'; $('send').disabled = true; $('msg').style.display = 'none'; vars='name='+encodeURI($('name').value); vars+='&email='+encodeURI($('email').value); vars+='&msg='+wysiwyg('text'); xmlHttp.open("POST","/script/send.php", true); xmlHttp.onreadystatechange = handleSend; xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.setRequestHeader("Content-length", vars.length); xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.send(vars); } function handleSend() { if(xmlHttp.readyState == 4) { if(xmlHttp.status == 200) { result = xmlHttp.responseText; $('send').value = 'Send'; $('send').disabled = false; if(result=='success') { tinyMCE.activeEditor.setContent(''); $('name').value = ''; $('email').value = ''; $('msg').innerHTML = 'Message succesfully sent.  Thanks!'; $('msg').style.display = 'block'; $('msg').style.fontWeight = 'bold'; $('msg').style.color = 'green'; $('msg').style.padding = '10px 0px'; $('msg').style.textAlign = 'center'; } else { $('msg').innerHTML = 'There was an error sending your message.  Sorry!'; $('msg').style.display = 'block'; $('msg').style.fontWeight = 'bold'; $('msg').style.color = 'red'; $('msg').style.padding = '10px 0px'; $('msg').style.textAlign = 'center'; } } else { //???? } } } function wysiwyg(inst) { var content = tinyMCE.activeEditor.getContent().replace(/\+/g, "+"); content = content.replace(/\\/g, "\"); content = escape(content); return content; }