/* Popup blocker detection */
windowOpened = 0;
function checkForWindow() {
	if (!windowOpened) {
		alert('Please disable your popup blocker\nin order to use some of our advanced features.');
	} else {
		windowOpened = 0;
	}
}

function showActivity() {
	element = document.getElementById('activity_icon');
	if (element) {element.src='img/indicator.gif';}
}

function hideActivity() {
	element = document.getElementById('activity_icon');
	if (element) {element.src='img/spacer.gif';}
}

function makeAjaxRequest(target_url) {
	if (callInProgress(xmlhttp)) {
		xmlhttp.abort();
	}
	
	xmlhttp.open("GET", target_url);
	xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			response = xmlhttp.responseText; 
			if (response!='ERR' && response>0) {
				launchWin('popups/popup_im.cfm?im_id='+xmlhttp.responseText,'IM_'+Math.round(Math.random()*100000000000),400,400,0,0,1);
				setTimeout("checkForWindow()",5000);
			}
			if (document.getElementById('activity_icon')) {hideActivity();}
        }
    }
    xmlhttp.send(null);
}

function makeCalls() {
	if (document.getElementById('activity_icon')) {showActivity();}
	
	// Text Message Check
	makeAjaxRequest('ajax/ajax_requests.cfm?request_type=1&nocache='+Math.round(Math.random()*100000000000));
}