var activeLink=-1; 
var activeDoc;
var currentAlbum=-1;
function focus() {
	document.forms[0].user.focus();  
}


function changeAlbum(index) {
currentAlbum=index;
}

function writeMenuItem(e) { // e is en event object
  var itemText = e.target.innerHTML;

  var textElement = document.getElementById("showText");
  textElement.innerHTML = itemText;
  textElement.parentNode.style.display = "block";
}

// Add event listeners to all li elemnts in the menus
function initEvents() {
  var menuBlock = document.getElementById("menus");
  var liList = menuBlock.getElementsByTagName("li");
  for (var i=0; i<liList.length; i++) {
    liList[i].addEventListener('mouseover',writeMenuItem,false);

  }
}


function toggleMenu(showNr) {
  var menuBlock = document.getElementById("menus");
  var menuList = menuBlock.getElementsByTagName("ul");
  var menuVisible = (menuList[showNr].style.display == "block");
  for (var i=0; i<menuList.length; i++) {
    menuList[i].style.display = "none";
  }
  if (!menuVisible) menuList[showNr].style.display = "block";
}









function Show(id){ //Visa CSS-objektet med namnet id 
 if (document.getElementById(id).style.visibility=="hidden") {
 	document.getElementById(id).style.visibility = "visible";					
 }
 else {
	  document.getElementById(id).style.visibility = "hidden";
 }
 } 
 function hide2(id){ 

	
		tmp=("val"+id);
		document.getElementById(tmp).style.fontWeight="normal";
	
 }
  function hide(id){ 
		
		var tmp;
		tmp=("pop"+id);
		if(document.getElementById(tmp)) {
			if (document.getElementById(tmp).style.visibility=="hidden") {
				document.getElementById(tmp).style.visibility = "visible";
				
				
			}	
			document.getElementById(tmp).style.visibility="hidden";
		}
	
 }
function changeGlobalMenu(id) //Används för att återställa och ändra aktivt menyalternativ
{
	if (id.src==window.location.href+"button.png") {
		id.src="button2.png";
	}
	else{
		id.src="button.png";
	}
} 
function change(id) //Används för att återställa och ändra aktivt menyalternativ
{

		

	var obj = id;

	
	obj.style.borderStyle = "inset";
	//obj.style.background = "black";
	//obj.style.color="white";
	//obj.style.fontWeight="bold";

} 
function reset(id) //Används för att återställa och ändra aktivt menyalternativ
{

	var obj = id;
	obj.style.borderStyle = "outset";
	

	//obj.style.background = "white";
	//obj.style.color="black";
	//obj.style.fontWeight="bold";
}
MenyAlternativ=new Array("val1","val2","val3","val4","val5","val6","val7");
function resetMenu() {
	var i=0;
	var obj;
	var popnr;
	var tmp;
	while (document.getElementById(MenyAlternativ[i])!=null) {
		obj=document.getElementById(MenyAlternativ[i]);

		obj.style.fontWeight="normal";

		if (obj.id==id.id) {
			popnr=i+1;	
		}
		i++;
		tmp=("pop"+i); //i
	
		document.getElementById(tmp).style.visibility="hidden";
	
	}
}

function MenyHandler(id) {
	var i=0;
	var obj;
	var popnr;
	var tmp;
	//MenyAlternativ.lengt
	while (document.getElementById(MenyAlternativ[i])!=null) {
		//alert(i);
		obj=document.getElementById(MenyAlternativ[i]);
		//obj.style.border="solid";
		//obj.style.borderwidth=1;
		
		obj.style.fontWeight="normal";
		//alert("test: "+obj.id+"=?"+id.id);
		if (obj.id==id.id) {
			popnr=i+1;	
		}
		i++;
		tmp=("pop"+i); //i
		
		if (document.getElementById(tmp)) {
		document.getElementById(tmp).style.visibility="hidden";
		}
	}
	//id.style.border="solid";
	//id.style.borderwidth=1;
	//id.style.color="black";
	id.style.fontWeight="bold";
	tmp=("pop"+popnr);

	var pop=document.getElementById(tmp);
	if (pop) {
	pop.style.visibility="visible";
	pop.style.opacity = 0.95;

	}
}

function check() 
{
	    
if ((document.forms[0].namn.value.length <= 1) || (!isNaN(document.forms[0].namn.value))) {     
document.forms[0].namn.focus();
alert("Ogiltigt Förnamn!");

}

else {
	if (!/^[0-9]{2,4}[\s|-]?[0-9]{5,8}$/.test(document.forms[0].tele.value)) {	
		alert("Ogiltigt telefonnummer");
		document.forms[0].tele.focus();	
	}
	
else   {	
document.forms[0].submit();

}
}}

function kolladata() 
  {
	    
if ((document.forms[0].fn.value.length <= 1) || (!isNaN(document.forms[0].fn.value))) {     
document.forms[0].fn.focus();
alert("Ogiltigt Förnamn!");

}
else {
	if ((document.forms[0].ln.value.length <= 1) || (!isNaN(document.forms[0].ln.value)))    {
	document.forms[0].ln.focus();    	
	alert("Ogiltigt efternamn!");     
  }

else {
	 if ((document.forms[0].ad.value.length <= 1) || (!isNaN(document.forms[0].ad.value)))  {
	document.forms[0].ad.focus();  
	alert("Ogiltig address!");
}
else {
	if ((document.forms[0].zip.value.length <= 4) || (isNaN(document.forms[0].zip.value)))  {
	document.forms[0].zip.focus();  	
	alert("Ogiltigt postnummer!");
}
else 
	{
	if ((document.forms[0].city.value.length <= 1) || (!isNaN(document.forms[0].city.value)))  {
	document.forms[0].city.focus();
	alert("Ogiltigt ortnamn!");       
}
else {
	if (!/^[0-9]{2,4}[\s|-]?[0-9]{5,8}$/.test(document.forms[0].tele.value)) {	
		alert("Ogiltigt telefonnummer");
		document.forms[0].tele.focus();	
	}

else {
	if (document.forms[0].user.value.length <= 1)  {
	document.forms[0].user.focus();  
    alert("Ogiltigt användarnamn!");
       
}

else   {	
document.forms[0].submit();

}
}}}}}}}

function hideAll() {
	hide(1);
	hide(2);
	hide(3);
	hide(4);
	hide(5);
	hide(6);
}
function colorMeny() {
	//alert(document.getElementById('menyn').value);
	var trueOrFalse=true;
	var theMenu=document.getElementById("menyAlts");
	var inputList=document.getElementsByTagName("div");
	theMenu.style.opacity = 0.4;

	for (var i=0; i<inputList.length; i++) {		

	if (inputList[i].id=="menyn") {
		inputList[i].style.opacity = 0.8;
		if (trueOrFalse) {
			inputList[i].style.backgroundColor="white";
			inputList[i].style.borderstyle="dotted";
			
			trueOrFalse=false;
		}
		else {
			inputList[i].style.backgroundColor="#B6D6F4";
			inputList[i].style.color="black";
			trueOrFalse=true;
		}
		
	}
	}
}
		