// Mojo XMLhttp Object Stuff var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) // JScript gives us Conditional compilation, we can cope with old IE versions. // and security blocked creation of the objects. try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } // mojo function check_new_messages() { path = './im_get_messages.php'; xmlhttp.open("GET",path,true); xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { //alert(xmlhttp.responseText); var response = xmlhttp.responseText; if(response.substring(0, 20) == '__MOJO_NEW_MESSAGE__') { // write new message //document.location = './mojoim_message_history.php'; //document.getElementById('visitor_message').innerHTML = xmlhttp.responseText; document.getElementById('visitor_message').innerHTML = response.substring(20); // Output Message //echo addslashes($GLOBALS['_SESSION']['user']['im']['visitor_message']); // Clear Message //$GLOBALS['_SESSION']['user']['im']['visitor_message'] = ''; //alert(xmlhttp.responseText); //alert(document.body.clientWidth); // top and left positions var top = document.body.clientHeight; if(top == 'undefined') top = window.innerHeight; var left = document.body.clientWidth; if(left == 'undefined') left = window.innerWidth; top = Math.round(top / 3); left = Math.round(left / 4); // Show Message window //document.getElementById('visitor_message').style.visibility = 'visible'; document.getElementById('visitor_message_box').style.position = 'absolute'; document.getElementById('visitor_message_box').style.top = top+'px'; document.getElementById('visitor_message_box').style.left = left+'px'; document.getElementById('visitor_message_box').style.visibility = 'visible'; // Scroll Window new FloatLayer('visitor_message_box',15,15,10); function detach(){ lay=document.getElementById('visitor_message_box'); l=getXCoord(lay); t=getYCoord(lay); lay.style.position='absolute'; lay.style.top=t; lay.style.left=l; getFloatLayer('visitor_message_box').initialize(); alignFloatLayers(); } window.onscroll = function() { alignFloatLayers();} detach(); } } } xmlhttp.send(null) setTimeout("check_new_messages();", 5000); } // execute setTimeout("check_new_messages();", 5000);