// Fixar den fula ramen som IE ger "besökta länkar"
function fixUglyIE(){
	for (a in document.links) document.links[a].onfocus = document.links[a].blur;
}

if (document.all){
	 document.onmousedown = fixUglyIE;
}

function changeBkground(id,link){
	id.style.backgroundColor = "#003366";
	link.style.color = "#ffffff";
}
function changeBack(id,link){
	id.style.backgroundColor = "#99ccff";
	link.style.color = "#000000";
}

function changeText(id){
	id.style.color = "#ffffff";
}
function changeTextBack(id){
	id.style.color = "#000000";
}

var popUpWin;
function popup(path,width,height){

	if(popUpWin)popUpWin.close();
	popUpWin=window.open(path, "popUpWin","scrollbars=no,width=" + width + ",height=" + height + ",dependent=no,top=150,left=150");
	popUpWin.self.focus();

} 

function popupScroll(path,width,height){

	if(popUpWin)popUpWin.close();
	popUpWin=window.open(path, "popUpWin","scrollbars=yes,width=" + width + ",height=" + height + ",dependent=no,top=150,left=150");
	popUpWin.self.focus();

} 

function popupScrollResize(path,width,height){

	if(popUpWin)popUpWin.close();
	popUpWin=window.open(path, "popUpWin","scrollbars=yes,resizable=yes,width=" + width + ",height=" + height + ",dependent=no,top=150,left=150");
	popUpWin.self.focus();

}

function popupDoc(path,width,height){

	if(popUpWin)popUpWin.close();
	popUpWin=window.open(escape(path), "popUpWin","scrollbars=yes,width=" + width + ",height=" + height + ",dependent=no,top=150,left=150");
	popUpWin.self.focus();

} 

function its_showtime(){
	nu =  new Date();
	tim = nu.getHours();
	min = nu.getMinutes();
	sek = nu.getSeconds();

	varde = tim;
	varde += ((min < 10) ? ":0" : ":") + min;
	varde += ((sek < 10) ? ":0" : ":") + sek;
	setTimeout("its_showtime()",1000);
	//document.tidig.tid.value = varde; 
	Clock.innerHTML = varde;
}

//Datumfunktionen
function its_showDay(){
	s_date = new Date();
    var weekDay = "";

	selectMonth = new Array(12);
			selectMonth[0] = "januari";
			selectMonth[1] = "februari";
			selectMonth[2] = "mars";
			selectMonth[3] = "april";
			selectMonth[4] = "maj";
			selectMonth[5] = "juni";
			selectMonth[6] = "juli";
			selectMonth[7] = "augusti";
			selectMonth[8] = "september";
			selectMonth[9] = "oktober";
			selectMonth[10] = "november";
			selectMonth[11] = "december";

	if(s_date.getDay() == 1){
			weekDay = "Måndagen";
	}
	if(s_date.getDay() == 2){
			weekDay = "Tisdagen";
	}
	if(s_date.getDay() == 3){
			weekDay = "Onsdagen";
	}
	if(s_date.getDay() == 4){
			weekDay = "Torsdagen";
	}
	if(s_date.getDay() == 5){
			weekDay = "Fredagen";
	}
	if(s_date.getDay() == 6){
			weekDay = "Lördagen";
	}
	if(s_date.getDay() == 7){
			weekDay = "Söndagen";
	}
	if(s_date.getDay() == 0){
			weekDay = "Söndagen";
	}


	var setYear = s_date.getYear();

	var BName = navigator.appName;

	 if(BName == "Netscape"){
         var setYear = s_date.getYear() + 1900;}
	
	varde= weekDay + " den "  +s_date.getDate() +  " "+ selectMonth[s_date.getMonth()] +" " + setYear
	
	Datum.innerHTML = varde;
}

// Vi kollar att formuläret är korrekt ifyllt när anv ska skicka det
function validateForm(daForm)
{
	if(	daForm.user.value == ""){
		alert("Du har glömt att fylla i \nanvändarnamn");
		return false;
	}
	else if( daForm.psswd.value == ""){
		alert("Du har glömt att fylla i \nditt lösenord");
		return false;
	}
	else
	{
		return true;
	}
}

function validateFirstForm(daForm)
{
	
	if(	daForm.newsItemTitleText.value == ""){
		alert("Du har glömt att fylla i \nen rubrik");
		return false;
	}
	else if( daForm.newsItemBodyText.value == ""){
		alert("Du har glömt att fylla i \nnågon text");
		return false;
	}
	else if(daForm.elements["teamID[]"].value == "0"){
			alert("Du har glömt att välja \n vilket lag texten hör till");
			return false;
		}
	else
	{
		return true;
	}
}

function validateBigForm(daForm)
{
	
	if(	daForm.newsItemTitleText.value == ""){
		alert("Du har glömt att fylla i \nen rubrik");
		return false;
	}
	else if( daForm.newsItemBodyText.value == ""){
		alert("Du har glömt att fylla i \nnågon text");
		return false;
	}
	else if(daForm.elements["teamID[]"].value == "0"){
			alert("Du har glömt att välja \n vilken lagtillhörighet användaren har");
			return false;
		}
	else
	{
		return true;
	}
}

function validateEventForm(daForm)
{
	
	if(	daForm.recurrEvent.value > 0){
		if(daForm.dayOfWeek.value > 6){
			alert("Du har glömt att välja dag\nför händelsen");
			return false;
		}
	}
	else{
		if(daForm.date.value == ""){
			alert("Du har glömt att skriva datum\nför händelsen");
			return false;
		}
	}
	if( daForm.description.value == ""){
		alert("Du har glömt att fylla i \nnågon text");
		return false;
	}
	else if(daForm.description.value){
		x = daForm.description.value;
		if (x.length > 100){
			alert("OBSERVERA! \n Beskrivningen får innehålla max 100 tecken\n inklusive mellanslag, radbyten och liknande");
			return false;
		}
	}
	else
	{
		return true;
	}
}

function validateStats(daForm){
		
		if( !daForm.play.checked){
			alert("Du har inte kryssat i att\n spelaren spelat matchen");
			return false;
		}
		else
			return true;

}

function validateGastbok(daForm)
	{
		if(	daForm.authorName.value == ""){
			alert("Du har glömt att fylla i \nditt namn");
			return false;
		}
		if(	daForm.subject.value == ""){
			alert("Du har glömt att fylla i \nett ämne");
			return false;
		}
		else if( daForm.message.value == ""){
			alert("Du har glömt att fylla i \nnågon text");
			return false;
		}
		else
		{
			return true;
		}
	}

window.onload = function()
{
 its_showtime();
 its_showDay();
}
