function hideElement(name) {
	var elem = document.getElementById(name);
	if (elem) {
		elem.style.visibility = 'hidden';
		elem.style.display = 'none';
	}
}

function showElement(name) {
	var elem = document.getElementById(name);
	if (elem) {
		elem.style.visibility = 'visible';
		elem.style.display = 'block';
	}
}

/*home made number format*/
function addCommas(nStr) {
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


function detect_flash() {
/** Brug ikke MSDetect. flashinstalled > 0 betyder at playeren er til stede **/
	var flashinstalled = 0;
	var flashversion = 0;
	MSDetect = "false";
	if (navigator.plugins && navigator.plugins.length)
	{
		x = navigator.plugins["Shockwave Flash"];
		if (x)
		{
			flashinstalled = 2;
			if (x.description)
			{
				y = x.description;
				flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
		else
			flashinstalled = 1;
		if (navigator.plugins["Shockwave Flash 2.0"])
		{
			flashinstalled = 2;
			flashversion = 2;
		}
	}
	else if (navigator.mimeTypes && navigator.mimeTypes.length)
	{
		x = navigator.mimeTypes['application/x-shockwave-flash'];
		if (x && x.enabledPlugin)
			flashinstalled = 2;
		else
			flashinstalled = 1;
	}
	else { MSDetect = "true"; }

	if (flashinstalled == 0 && MSDetect == "false") { 
		window.location="index.php?flash=false&iam=kanin"; 
	}
}


var dom			= document.getElementById ? 1 : 0;
var ie			= document.all ? 1 : 0;
var mac			= (navigator.userAgent.indexOf("Mac") > -1) ? 1 : 0;
var ieReal		= (ie && (!mac) && ( typeof(window.offscreenBuffering) != 'undefined') ) ? 1 : 0;
var isActiveX	= ieReal;
var isSp2		= ieReal && (window.navigator.userAgent.indexOf("SV1") != -1);

function changeOpacity(obj, opacity) {
if(ieReal) {
obj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + (opacity * 100) + ')';
}
else if(dom) {
obj.style.MozOpacity = opacity;
//obj.style.opacity = opacity;
}
}

/*
function matchRefresh(country, division) {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
 				alert("Your browser does not support AJAX!");
				return false;
			}
 		}
	}

	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			document.getElementById('ajaxbox').innerHTML = xmlHttp.responseText;
			
			window.setTimeout('matchRefresh(\''+country+'\','+division+')',6000);
			//setTimeout(matchRefresh(country,division),60000);
			//alert(xmlHttp.responseText);
		}
	}

	xmlHttp.open("GET","live_leaguematches.php?country="+country+"&division="+division,true);
	xmlHttp.send(null);


}
*/
function countdown() {
  var elm_sekund = document.getElementById('tid_sekund').innerHTML

  document.getElementById('tid_sekund').innerHTML = (elm_sekund==59)? countdown_minut() : twoDigits(++elm_sekund);

  setTimeout('countdown()',1000);
}

function countdown_minut() {
  var elm_minut = document.getElementById('tid_minut').innerHTML

  document.getElementById('tid_minut').innerHTML = (elm_minut==59)? countdown_time() : twoDigits(++elm_minut);
  
  return "0" + 0;
}

function countdown_time() {
      var elm_time = document.getElementById('tid_time').innerHTML;

      document.getElementById('tid_time').innerHTML = (elm_time==23)? "00" : twoDigits(++elm_time);
      
      return "0" + 0;
  }

function twoDigits(num){
  return num>9 ? num : "0" + num;
}

  window.onload = countdown

var current = null;
function visskjul(id) {
  var elm = document.getElementById(id);
  if (elm.style.display=="block") {
    if (current==id) {
	elm.style.display =  "none";
    current = null;
	}
  } else {
    elm.style.display = "block";
    if (current != null) {
      current.style.display = "none"; 
    }
    current = elm;
  }
}

function $(id) {
	return document.getElementById(id);
}
if(!Array.indexOf){
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			if(this[i]==obj){
				return i;
			}
		}
		return -1;
	}
}
/*
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
*/