// trace home page utilities


//cache tab images

tabimages = [
	'/images/trace/icon_viruses_up.gif',
	'/images/trace/icon_phishing_up.gif',
	'/images/trace/icon_spam_down.gif',
	'/images/trace/nvc_Medium.gif',
	'/images/trace/nvc_Low.gif',
	'/images/trace/nvc.jpg'
	];


tablen = tabimages.length;
tabcache = [];
for(var i=0; i<tablen; i++)
{
	tabcache[i] = new Image;
	tabcache[i].src = tabimages[i];
}


function pickmap() { 
//gyrations below to make it work in Opera 9. Although even with this it only works the first time.
if (document.mapselect.pickmap.selectedIndex>0) {
document.overviewmap.src="/images/trace/"+document.mapselect.pickmap[document.mapselect.pickmap.selectedIndex].value;
if (document.overviewmap.src.indexOf("country")>0) {
	type="Country";
	document.overviewmap.removeAttribute("useMap");
	document.overviewmap.setAttribute("useMap","#country");
//	document.overviewmap.useMap="#country"
	}
else {
	type="Continent";
	document.overviewmap.removeAttribute("useMap");
	document.overviewmap.setAttribute("useMap","#continent");
//	document.overviewmap.useMap="#continent"
	}
if (document.overviewmap.src.indexOf("spam")>0) {
	stat="Spam"
	}
else {
	stat="Phishing"
	}


}
}

function pickmap2() { 
//gyrations below to make it work in Opera 9. Should be able to just replace the UseMap, but Opera chokes.
if (document.mapselect.pickmap.selectedIndex>0) {
repltext='<img style="border:1px solid #eeeeee;" name=overviewmap id=overviewmap src="/images/trace/'+document.mapselect.pickmap[document.mapselect.pickmap.selectedIndex].value+'" alt= ""  useMap="#'

if (repltext.indexOf("country")>0) {
	type="Country";
	repltext=repltext+'country" border=0 width=500 height=200>'
	}
else {
	type="Continent";
	document.overviewmap.removeAttribute("useMap");
	repltext=repltext+'continent" border=0 width=500 height=200>'
	}
if (repltext.indexOf("spam")>0) {
	stat="Spam"
	}
else {
	stat="Phishing"
	}


}
document.getElementById("ovmapwrapper").innerHTML=repltext;
}

function enlargemap(thedate) { 
openquery="?image="+document.overviewmap.src.substr(0,document.overviewmap.src.length-7)+"1600.gif&set_date="+thedate+"&name="+document.mapselect.pickmap[document.mapselect.pickmap.selectedIndex].text
window.open("http://www.marshal8e6.com/trace/enlarge_map.asp"+openquery,'_blank','scrollbars=yes,width=1600,height=640');
}

function picktab(thisone) {

switch(thisone)
{
case "spam":

document.spamtab.src="/images/trace/icon_spam_up.gif";
document.virustab.src="/images/trace/icon_botnets_down.gif";
document.phishtab.src="/images/trace/icon_phishing_down.gif";
document.getElementById("tabcontent").innerHTML = spamvar;
document.getElementById("statlink").innerHTML = spamlinkvar;
break; 

case "virus":

document.spamtab.src="/images/trace/icon_spam_down.gif";
document.virustab.src="/images/trace/icon_viruses_up.gif";
document.phishtab.src="/images/trace/icon_phishing_down.gif";
document.getElementById("tabcontent").innerHTML = virvar;
document.getElementById("statlink").innerHTML = viruslinkvar;
break; 

case "phish":

document.spamtab.src="/images/trace/icon_spam_down.gif";
document.virustab.src="/images/trace/icon_botnets_down.gif";
document.phishtab.src="/images/trace/icon_phishing_up.gif";
document.getElementById("tabcontent").innerHTML = phishvar;
document.getElementById("statlink").innerHTML = phishlinkvar;
break; 

case "bot":

document.spamtab.src="/images/trace/icon_spam_down.gif";
document.virustab.src="/images/trace/icon_botnets_up.gif";
document.phishtab.src="/images/trace/icon_phishing_down.gif";
document.getElementById("tabcontent").innerHTML = botvar;
document.getElementById("statlink").innerHTML = botlinkvar;
break; 
}

}

function sTT(e,location){
showTip=false; 
if (stat=="Spam") {
	
	if (type=="Continent") {
		tip= "Spam Sources by Continent:<br>"+continents[location] + ": "+spamContinentValues[location];
		showTip=true;
		}
	else 
	{if (spamCountryValues[location]>0) {
		tip= "Spam Sources by Country:<br>"+countries[location] + ": "+spamCountryValues[location];
		showTip=true;
		}
		}
	}
else {
	
	if (type=="Continent") {
		tip= "Phishing Sources by Continent:<br>"+continents[location] + ": "+phishContinentValues[location];
		showTip=true;
		}
	else 
	{if (spamCountryValues[location]>0) {
		tip= "Phishing Sources by Country:<br>"+countries[location] + ": "+phishCountryValues[location];
		showTip=true;
		}
	}
	}

if (showTip) {
ToolTipObject=document.getElementById("ToolTip")
	ToolTipObject.innerHTML="<table><tr><td class=ToolTipTD>"+tip+"%</td></tr></table>"; 
	ToolTipObject.style.left=(e.clientX+18+document.overviewmap.scrollLeft) + "px"; 
	ToolTipObject.style.top=(e.clientY+5+document.overviewmap.scrollTop) + "px";
	ToolTipObject.style.visibility="visible";
	}
} 

function sTT2(e,location){
showTip=false; 
if (stat=="Spam") {
	
	if (type=="Continent") {
		tip= "Spam Sources by Continent:<br>"+continents[location] + ": "+spamContinentValues[location];
		showTip=true;
		}
	else 
	{if (spamCountryValues[location]>0) {
		tip= "Spam Sources by Country:<br>"+countries[location] + ": "+spamCountryValues[location];
		showTip=true;
		}
		}
	}
else {
	
	if (type=="Continent") {
		tip= "Phishing Sources by Continent:<br>"+continents[location] + ": "+phishContinentValues[location];
		showTip=true;
		}
	else 
	{if (spamCountryValues[location]>0) {
		tip= "Phishing Sources by Country:<br>"+countries[location] + ": "+phishCountryValues[location];
		showTip=true;
		}
	}
	}

if (showTip) {
correction=0;
// if (document.body.clientWidth>870) {correction=document.body.clientWidth/2}
correction=Math.floor((document.body.clientWidth-870)/2);

ToolTipObject=document.getElementById("ToolTip")
	ToolTipObject.innerHTML="<table><tr><td class=ToolTipTD>"+tip+"%</td></tr></table>"; 
	ToolTipObject.style.left=(e.clientX+18-correction+document.overviewmap.scrollLeft) + "px"; 
	ToolTipObject.style.top=(e.clientY+5+document.overviewmap.scrollTop) + "px";
	ToolTipObject.style.visibility="visible";
	}
} 

function hTT(){ 
ToolTipObject=document.getElementById("ToolTip")
ToolTipObject.style.visibility="hidden"; 
} 
