
// preloading images


// sets the first textitem in the first form as active
function startForm()	{
	document.forms[0].elements[0].focus(); 
}


// changes the image on mouseover/mouseout
function changeImage(img,status)	{
	if(status == "on")	{
		var imgOn = eval(img + "_on.src");
		document.images[img].src = imgOn;
	}
	else if(status == "off")	{
		if (img != activeImage)	{
			var imgOff = eval(img + "_off.src");
			document.images[img].src = imgOff;
		}
	}
}	


// makes one image active
function makeActive(img)  {	
	// Turn off currently active
	if (activeImage != img)  {
		imgTemp = activeImage;
		activeImage = img;
		if(imgTemp != ""){
			changeImage(imgTemp, 'off');
			changeImage(imgTemp, 'off');
		}
	alert("activeImg: " + activeImage + ", imgTemp: " + imgTemp)		
	}
}


// changes the class for the top-menu to the on-colour 
function colorOn(object)	{
	if(ie4_up || ns6_up)	{
		if(object.className == "topmenuOff")	{
			object.className = "topmenuOn";
		}
	}
	
}


// changes the class for the top-menu to the off-colour 
function colorOff(object)	{
	if(ie4_up || ns6_up)	{
		if(object.className == "topmenuOn")	{
			object.className = "topmenuOff";
		}	
	}

}


function gotoDepartment()	{
	var objForm = document.navigation;
	var lngDepartmentID = objForm.departments[objForm.departments.selectedIndex].value;
	if (lngDepartmentID == "-1")	{
		self.location = "/index.asp";
	}
	else	{
		self.location = "/departmentStart.asp?DeptID=" + lngDepartmentID; 
	}
}

function gotoProject()	{
	var objForm = document.navigation;
	var lngProjectID = objForm.projects[objForm.projects.selectedIndex].value;
	var lngDepartmentID = objForm.projects[objForm.projects.selectedIndex].id;
	if(lngProjectID == "-1")	{
		self.location = "/index.asp"; 
	}
	else	{
		self.location = "/projectStart.asp?DeptID=" + lngDepartmentID + "&ProjID=" + lngProjectID; 
	}
}


// returns the window width 
function getScreenWidth()	{
	if (ns4_up)	{
		screenWidth = window.outerWidth;
	}
	else	{
		screenWidth = document.body.offsetWidth;
	}	
	return screenWidth;
}

// returns the window height 
function getScreenHeight()	{
	if (ns4_up)	{
		screenHeight = window.outerHeight;
	}
	else	{
		screenHeight = document.body.offsetHeight;
	}	
	return screenHeight;
}


// returns the right x-value to center a popup-window
function getMidWidth(newWinWidth)	{
	var winWidth = getScreenWidth();
	var midWidth = ((winWidth + (screen.width - winWidth))/2) - (newWinWidth/2);
	return midWidth;
}


// returns the right y-value to center a popup-window
function getMidHeight(newWinHeight)	{
	var winHeight = getScreenHeight();
	var midHeight = ((winHeight + (screen.height - winHeight))/2) - (newWinHeight/2);
	return midHeight;
}


// opens a popupwindow with the given properties
function openPopWindow(url, name,  width, height, scroll)	{
	if (scroll == "1")	{
		scroll = "yes";
	}
	else	{
		scroll = "no";
	}	
	var screenX = getMidWidth (width);
	var screenY = getMidHeight (height);
	var popupWin = window.open(url, name, "width=" + width + ",height=" + height + ",scrollbars=" + scroll + ",left=" + screenX + ",top=" + screenY);
}


function doSearch()	{
	var strWord = document.searchForm.searchText.value;
	if (strWord.length > 1)	{
		return true;
	}	
	else	{
		alert("Du måste ange minst två bokstäver i sökrutan.")
		return false;
	}	
}


function checkLoginForm()	{
	var objForm = document.login;
	var strError = "";
	if (objForm.login.value == "")	{
		strError = strError + "Du måste fylla i ditt användarnamn.\n";
	}	
	if (objForm.pwd.value == "")	{
			strError = strError + "Du måste fylla i ditt lösenord.\n";
	}
	if (strError == "")	{
		return true;
	}
	else	{
		alert(strError);
		return false;	
	}	
}