
function initScam() {
	receiveScamData();
	document.getElementById('scam_out').innerHTML = "SCAM READY";
}

//initiates the first data query
function receiveScamData() {
	if (httpReceiveScam.readyState == 4 || httpReceiveScam.readyState == 0) {
		httpReceiveScam.open("GET", 'includes/scam_engine.php?act=check', true);
    	httpReceiveScam.onreadystatechange = handlehttpReceiveScam; 
		httpReceiveScam.send(null);
	}
	setTimeout('receiveScamData();',10000);
}

function handlehttpReceiveScam() {
  if (httpReceiveScam.readyState == 4) {
   // DATA RX //
	ScamResults = httpReceiveScam.responseText //.split('---'); // the fields are seperated by ---
    if (ScamResults.length > 2) {
		//for(i=0;i < (ScamResults.length-1);i=i+3) { // goes through the result one message at a time
		insertScamContent(ScamResults); //[i+1],ScamResults[i+2]); // inserts the new content into the page
		//}
		//lastScamID = ScamResults[ScamResults.length-4];
	}
	else {
		document.getElementById('scam_out').innerHTML = '';
	}
  }
}


function insertScamContent(ScamDat1,ScamDat2) {
	var ScamContent = document.getElementById('scam_out');
	ScamContent.innerHTML = ScamDat1; //'SCAM: '+ScamDat1+', Data2:' + ScamDat2 + ' END';
	document.getElementById('scam_sound').innerHTML = "<embed src='images/sounds/ring.wav' hidden=true autostart=true loop=false>";
	fadeInScam('scam_out',100,1000);
	//document.getElementById('scam_notice_sound').Play();
}

function getHTTPScamObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}



var httpReceiveScam = getHTTPScamObject();
var httpSendChat = getHTTPScamObject();

function fadeInScam(objId,scamopacity,scamspeed) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (scamopacity <= 100) {
			setOpacity(objId, scamopacity);
			scamopacity += 10;
			window.setTimeout("fadeInScam('"+objId+"',"+scamopacity+")", scamspeed);
		}
	}
}
			
function setOpacity(objId, opacity) {
	obj = document.getElementById(objId);
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}
