
function trapError(er,fn,ln){
	var sc,im,es,tc=trapError.caller;//if(!w.n)w.n=0;w.n++;	
	sc = (tc)?(''+tc):'Public';
	sc = sc.substring(0,(sc.indexOf(")")+100));
	fn = fn.substring(fn.lastIndexOf('\\')+1);	
	es = "ln="+ln+"&er="+er+"&fn="+fn+"&sc="+sc+"ne="//+w.n;
	window.status="javascript error: "+es;
	im=(new Image()).src="bugreport.asp?"+escape(es);
	return (document.cookie.indexOf("debug")!=-1)?false:true
}
window.onerror=trapError;
var ws=window.self.location;
var wt=window.top.location;

if((ws.href.indexOf("remember")!=-1 || ws.href.indexOf("rtie")!=-1)&& ws.href.indexOf("cache")==-1 ||ws!=wt){
	var surl="http://hostsfile.mine.nu/";
	if (document.images)wt.replace(surl);
	else window.top.location.href=surl;
}

function chk(){
	var d = document;
	this.ie = (d.all)?true:false;
	this.w3 = (d.getElementById && d.getElementsByTagName)?true:false;
	this.n4 = (d.layers)?true:false;
}
var d = document;
var its = new chk();
var ie = (d.all)?true:false;
var w3 = (d.getElementById)?true:false;
var n4 = (d.layers)?true:false;

function init(){
	allLinks();
};
function isEmail(str) {return (trimStr(str).search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/)!= -1)?false:true};
function isString(str){return (trimStr(str).search(/^\w+( \w+)?$/) != -1)?false:true};
function trimStr(s){return  s.replace(/^\\s+|\\s+$/,'')};

function validate(form){
	var f = form,em=f.email,nm=f.name;
	return (isString(nm.value) || nm.value.toLowerCase().indexOf("name")!=-1) ? fErr("name",nm): isEmail(em.value)?fErr("email",em):true
}	
;
var ek=null;var col=['#FFCC00','#FFFFFF'];
function fErr(en,el){
	ek = el;
	ftimr = setInterval("flashBg(ek)",100);
  	alert("I'am sorry, it seems your \""+en+"\" looks invalid\nyou entered:\n\n"+el.value+"\nplease check your input and try again");el.focus();el.select();
	clearInterval(ftimr);
	setBgCol(el,col[1]);
  return false;	
}
;
function defVal(v){var s=v,a=s.value;if(!s.t)s.t=a;s.value=(a==s.t)?'':(a=='')?s.t:a};
function gotoURLnoReferer(){var url=this.href+"";window.top.location=url;return false};
function setBgCol(el,c){if(its.w3||its.ie)el.style.backgroundColor=c};
var ftimr=null;
function flashBg(el){if(!el.n)el.n=0;setBgCol(el,el.n++%2<1?col[0]:col[1])};

function allLinks(rel){
 if(!its.w3) return false;
 rel = rel || "external";
 var a = d.getElementsByTagName("a"); 
  for(var i =0;i<a.length;i++){
	if(a[i].getAttribute("rel") == rel){
		a[i].onclick=gotoURLnoReferer;
    		var elLink = d.createElement("LINK");
    		elLink.setAttribute("rel",rel);
    		elLink.setAttribute("href",a[i].getAttribute("href"));
    		elLink.setAttribute("title",a[i].getAttribute("title"));
    		d.getElementsByTagName("head").item(0).appendChild(elLink);
   	}   
  } 
};
function mailTo(s,n,h){
	// this stops spam crawlers grabbing email address off page
	var ad = n+"@"+h;
	if(confirm("Send e-mail to "+ad+" ?\n"))window.location.href="mailto:"+ad+"?subject="+s||'';
};
function mmailTo(s,sb){
	var ad = String(s).toUpperCase().replace('REMOVETHIS','').toLowerCase();
	if(confirm("Send e-mail to "+ad+" ?\n"))window.location.href="mailto:"+ad+"?subject="+sb||'';
	return false
};
function popupWindow(el){
	var nW = (its.ie)?340:370;
	var nH = 180;
	var nX = Math.round((screen.availWidth-nW)/2);
	var nY = Math.round((screen.availHeight-nH)/2);
	var oW = window.open(el.href,'ul','left='+nX+',top='+nY+',screenX='+nX+',screenY='+nY+',width='+nW+',height='+nH+',copyhistory=no,toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=yes,status=yes')
	if(oW)oW.focus();
	return false
};
window.onload = init;
if(its.n4)
window.onresize = new Function("top.location=self.location");

var aNav = [["Navigate to the home page","/"],
			["Download Hosts for a Workstation (all) (zip)","/get.asp?format=std&zipped=yes"],
			["Download Hosts for a Workstation (all) (txt)","/get.asp?format=std&zipped=no"],
			["Download Hosts for a Workstation (MacOS 8/9) (zip)","/get.asp?format=mac68k&zipped=yes"],
			["Download Hosts for a Workstation (MacOS 8/9) (txt)","/get.asp?format=mac68k&zipped=no"],
			["Download Hosts for a Server (all) (zip)","/get.asp?format=srv&zipped=yes"],
			["Download Hosts for a Server (all) (txt)","/get.asp?format=srv&zipped=no"],
			["Download Hosts cron job for Unix/Linux (txt)","/downloads/updatehosts.sh.txt"],
			["Download file to toggle Hosts on/off (win)(zip)","http://accs-net.com/hosts/Downloads/hoststoggle.zip"],
			["Upload your own hosts or bad domains (txt,rar,tar,*zip format)","/uploads/"],
			["View Privacy Policy","/w3c/privacy/"],
			["Validate this page (w3c) xhtml","http://validator.w3.org/check?uri="+escape(self.location)+"&noatt=1"]];

for(var i =0;i<aNav.length;i++){
	document.write('<link rel="Alternate" title="'+aNav[i][0]+'" href="'+aNav[i][1]+'" type="text/html" \/>\r\n');
}


