// JavaScript Document
function callFunc()
{
	start()
	startDatum()
	uppdateDate()
	showDaysLeft()
	//msgWindow()
}
//retunerar ID
function getObj(elementID)
{
	return document.getElementById(elementID);
	
}
function loadContent(elemID, URL){
	getObj(elemID).src = URL;
}

var timer = null

function stop()
{
clearTimeout(timer)
}

function start()
{
var time = new Date()
var hours = time.getHours()
var minutes = time.getMinutes()
minutes=((minutes < 10) ? "0" : "") + minutes
var seconds = time.getSeconds()
seconds=((seconds < 10) ? "0" : "") + seconds
var clock = hours + ":" + minutes + ":" + seconds
var theObj = getObj('tid')
theObj.innerHTML=clock
//document.forms[0].display.value = clock
timer = setTimeout("start()",1000)
}
function startDatum()
{
var d = new Date()
var date = (d.getFullYear())+(".")+(d.getMonth() + 1)+(".")+(d.getDate())

var theObj = getObj('datum')
theObj.innerHTML= date
}

function msgWindow()
{
//alert("kalle kula")
//	window.open("../pdf/Arets _Ledare _och _stipendium.pdf","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=550, height=600")
//	showModelessDialog("html/aretsTranare.htm")
	showModelessDialog("html/varmlandsTennis60.htm")
	window.open('html/varmlandsTennis60.htm','_blank','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=620, height=900')
}

function storlek()
{
//	showModelessDialog("matchdag_060127.htm")
//resizeTo(700,400)
}
function showPopup(){
//	open("html/matchdag1.html",""," width=800, height=400")
//	open("html/matchdag_060128.html",""," width=800, height=800")
	//window.open('html/girona.htm','_blank','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, width=500, height=430')
//	showModalDialog("html/aretsTranare.htm")
}
// Visar antal dagar innan Avspark/Start
function uppdateDate(){
	var currentTime = new Date();
	var actionTime = new Date();
	actionTime.setHours(23);
	actionTime.setMinutes(59);
	actionTime.setSeconds(59);
	var msekunder = (actionTime - currentTime);
	
	//alert(actionTime);
	//alert(currentTime);
		//alert(msekunder);
	
	var timer = setTimeout("showDaysLeft();",msekunder);
}

function showDaysLeft(){
	var currentDate = new Date();
	//alert(currentDate);
	var actionDate = new Date("August 14,2008 11:59:59");
	var sekunder = (actionDate.getTime() - currentDate.getTime()) /1000;
	//alert("actionDate=" +actionDate.getTime());
	//alert("currentDate=" +currentDate.getTime());
	var theObj = getObj('days');
	var daysLeft = Math.round(sekunder/60/60/24);
	if(daysLeft == 0){
		daysLeft = 1;
		theObj.innerHTML=daysLeft;
	}
	if(daysLeft < 0){
		daysLeft = 0;
		theObj.innerHTML=daysLeft;
	}
	else
		theObj.innerHTML=daysLeft;

	
	//alert(theObj);
	theObj.innerHTML=daysLeft;
	}
