var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 4.5") !=-1));
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
var is_mac = (agt.indexOf("mac")!=-1);

function upgrade() {
  top.location.href = "http://www.webstandards.org/upgrade/";
}

function browserCheck() {
  if (is_nav4 || is_ie3) {
    upgrade();
  } 
}

function goToUrl(theUrl) {
  top.location.href = theUrl;
}

// DOM-enabled?
if (!document.getElementById) { 
	var is_dom = false;
} else {
	var is_dom = true;
}

function writeNewDiv(id,newCnt) {
	
	var theDelay = true;
	
	if (is_dom) {
		document.getElementById(id).innerHTML=newCnt;
	}
	else {
		if (is_nav) {
			document.layers[id].document.write(newCnt);
			document.layers[id].document.close();
		}
		else {
		//IE4 crashes if you set the innerhtml without a delay, strange
			if (is_ie4) {
				if (theDelay == true) {
					thisID = id;
					setTimeout("writeNewDiv(thisID);",100);
					theDelay = false;
				}
				else {
					document.all[id].innerHTML=newCnt;
					theDelay = true;
				}
			}
			else {
				document.all[id].innerHTML=newCnt;
			}
		}
	}
	return false;
}

function checkPlugin(plgIn, autoGo) { //checkPlugin('Shockwave Flash',false);return document.MM_returnValue
  var ok=false; document.MM_returnValue = false;
  with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
    ok=(plugins && plugins[plgIn]);
  } else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
    if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
    else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
    else ok=autoGo; }
	
  if (!ok) { 
	var hasPlugin = false;
  } else {
	var hasPlugin = true;
  }
}

function pullautaFlash(src, width, height) {
	document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"' + width + '\" height=\"' + height + '\"><param name=\"movie\" value=\"' + src + '\"><param name=\"quality\" value=\"high\"><param name=\"menu\" value=\"false\"><param name=\"bgcolor\" value=\"#1A1A1A\"><embed src=\"' + src + '\" width=\"' + width + '\" height=\"' + height + '\" quality=\"high\" bgcolor=\"#1A1A1A\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" menu=\"false\"></embed></object>');
}

function pullautaKuva(src, width, height) {
	document.write('<img src=\"' + src + '\" width=\"' + width + '\" height=\"' + height + '\" border=\"0\">');
}

function mplayerStatus(title) {
  writeNewDiv('mplayer_status', '<div class=\"line4\"><img src=\"img/px.gif\" width=\"1\" height=\"4\"></div><span class=\"nav\">NOW PLAYING <br><strong>' + title + '</strong><br><a href=\"mplayer_init.php\" target=\"player\" onClick=\"mplayerStop();\">STOP?</a></span>');
}
function mplayerStop() {
  writeNewDiv('mplayer_status', '');
}

function mlistValidate() {
if ((document.mailinglist.email.value == "email@address.com")) {
   window.alert ("E-mail address, please?");
   return false;
   }
}

function noSpam(user,domain) {
locationstring = "mailto:" + user + "@" + domain;
window.location = locationstring;
}

function transfer_to(url) {
  locationstring = url;
  window.location = locationstring;
}
function transfer(dest) {
  setTimeout("transfer_to(dest)", 4000);
}

function soopaPopSetup() {
	var a;
	for (var i = 0; (a = document.links[i]); i++) {
		if (a.target && a.target.indexOf("_soopaPop") == 0) {
			a.onclick = soopaPop;
		}
	}
}
function soopaPop() {
	var a = this.target.split(":");
	var sFeatures = a[1];
	window.open(this.href, a.length > 2 ? a[2] : String((new Date()).getTime()), sFeatures);
	return false;
	alert("hi")
}