// JavaScript Document
var url= "/IMessenger/ajaxServer.asp";
var URLNewWindow="/IMessenger/Default.asp"; // era .php
var IMTimer;
var req;



function startsystem(){
	//document.write("Inicio<br>");
    //Ajax();
    IMTimer = self.setInterval("loadXMLDoc(url)",15000);
    //IMTimer = setTimeout("asktheserver()",10000);
	//document.write("Fim<br>");
}

function loadXMLDoc(url) {
	//alert(url);
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest && !(window.ActiveXObject)) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		req.onreadystatechange = processStateChange;
		req.open("GET", url, true);
		req.send("");
	}
}




function processStateChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            // ...processing statements go here...
			// document.write("2:" + req.responseText);
			temp = req.responseText;
			
			
	
			//alert(temp);
			
						// ...processing statements go here...
			response  =  req.responseXML.documentElement;
			method    =  response.getElementsByTagName('msgs')[0].firstChild.data;
			result    =  response.getElementsByTagName('nIDPessoa')[0].firstChild.data;
			
					

			if (method == 1) 
			{
				getMessages();
			}
        } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
	
}


function getMessages(){
    window.open('/IMessenger/msg.asp','popMsg' ,'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=auto,resizable=no,copyhistory=yes,width=320px,height=280px');
}


