
function buttonClick()
{
	var text = 	document.getElementById("searchText").value;
	text = text.replace(/<>/, "");



	resetParas();
	if( checkGoodQuery(text) )
	{
		document.getElementById("button1").disabled=true;
		document.getElementById("results").innerHTML="CHECKING";
		document.getElementById("resultsP1").innerHTML="<strong>Running:</strong> Performing scan.";
		document.getElementById("resultsP2").innerHTML="";
		document.getElementById("resultsPic").innerHTML="<img border='0' src='ajax-loader_big.gif' width='48' height='48' />"
		setParaOne();

	}
}

function checkSearchString(theString)
{



	theString = theString.toLowerCase();

	if (theString.indexOf("@") >= 0)
	{
		var whiteList = getEmailWhiteList();
	}
	else
	{
		var whiteList = getURLWhiteList();
	}

	for (white in whiteList)
	{
		if (theString.indexOf(whiteList[white]) >= 0)
		{
			return true;
		}
	}


	return false;

}

function checkGoodQuery(theString)
{

	if ( (theString != "") && ( (theString.indexOf("www") >= 0) || (theString.indexOf("http://") >= 0) || (theString.indexOf("@") >= 0) ) )
	{
		return true
	}
	else
	{

		document.getElementById("results").innerHTML="ERROR";
		document.getElementById("resultsPic").innerHTML="<img border='0' src='Sys-48.png' id='halt' width='48' height='48' />"
		document.getElementById("resultsP1").innerHTML=" Cannot understand search term.";
		document.getElementById("resultsP2").innerHTML="<strong>EXAMPLE </strong> www.DollarCashMachineAtHome.com";
		return false
	}


}


function setParaOne()
{
	var delay = randomIntBetween(1000, 5000)
	document.getElementById("p1").innerHTML="<strong>### Checking Global Scam Network Database ... </strong><img border='0' src='ajax-loader.gif' id='loader1' width='16' height='16' />";
	setTimeout("setParaTwo()",delay );


}
function setParaTwo()
{
	var delay = randomIntBetween(1000, 5000)
	document.getElementById("p1").innerHTML='<strong>### Checking Global Scam Network Database ... </strong>DONE';
	document.getElementById("p2").innerHTML="<strong>### Performing Domain Trace ...</strong> <img border='0' src='ajax-loader.gif' id='loader2' width='16' height='16' />";
	setTimeout("setParaThree()",delay);


}

function setParaThree()
{
	var delay = randomIntBetween(1000, 5000)
	document.getElementById("p2").innerHTML='<strong>### Performing Domain Trace ...</strong> DONE';
	document.getElementById("p3").innerHTML="<strong>### Massive Social Complaint Matrix Analysis ...</strong> <img border='0' src='ajax-loader.gif' id='loader2' width='16' height='16' />";
	setTimeout("setParaFour()",delay);

}

function setParaFour()
{
	var delay = randomIntBetween(1000, 5000)
	document.getElementById("p3").innerHTML='<strong>### Massive Social Complaint Matrix Analysis ...</strong> DONE';
	document.getElementById("p4").innerHTML="<strong>### Running Genetic Algorithm ...</strong> <img border='0' src='ajax-loader.gif' id='loader2' width='16' height='16' />";
	setTimeout("setParaFive()",delay);

}

function setParaFive()
{
	var confidence = randomIntBetween(65, 92)
	document.getElementById("p4").innerHTML="<strong>### Running Genetic Algorithm ...</strong> DONE";
		
	document.getElementById("button1").disabled=false;

	var text = 	document.getElementById("searchText").value;
	text = text.replace(/<>/, "");
	var itType = "SCAM"
	if (text.indexOf("@") >= 0)
	{
		itType = "SCAMMER"
	}



	if(checkSearchString(text) == false)
	{	
	document.getElementById("p5").innerHTML="<strong>###  "+ itType + "</strong> -- " + confidence + "% Confidence";

	document.getElementById("results").innerHTML= itType + "!";

	var text = 	document.getElementById("searchText").value;
	document.getElementById("resultsP1").innerHTML="<strong>"+ text + "</strong> is most likely a " + itType.toLowerCase() + "!";
	document.getElementById("resultsPic").innerHTML="<img border='0' src='Halt-48.png' id='halt' width='48' height='48' />"

	if(itType == "SCAMMER")
	{
		document.getElementById("resultsP2").innerHTML="Be careful, and proceed with caution!";
	}
	else
	{
		document.getElementById("resultsP2").innerHTML="For more details about this site, check <a href='http://www.google.com/search?hl=en&safe=active&q=" + text + "+scam'> here </a>.";
	}
}
else
{
	document.getElementById("p5").innerHTML="<strong>###  SAFE </strong> -- " + confidence + "% Confidence";
	document.getElementById("results").innerHTML="IT'S OKAY!";

	var text = 	document.getElementById("searchText").value;
	document.getElementById("resultsP1").innerHTML="<strong>"+ text + "</strong> is most likely NOT a " + itType.toLowerCase() + "!";
	document.getElementById("resultsP2").innerHTML="But if your instinct is telling you otherwise, stay away!";
	document.getElementById("resultsPic").innerHTML="<img border='0' src='Smiley-48.png' id='halt' width='48' height='48' />"
}
	document.getElementById("button1").disabled=false;
}

function resetParas()
{
	document.getElementById('p1').innerHTML="";
	document.getElementById('p2').innerHTML="";
	document.getElementById('p3').innerHTML="";
	document.getElementById('p4').innerHTML="";
	document.getElementById('p5').innerHTML="";


}

function randomIntBetween(low, high)
{
	return low + Math.floor(Math.random()*((high-low)+1))
}

