// JavaScript Document
var server = "http://malmoarena.com";

	window.onload = function(){
		if(setonload==1) initialize();
	}
	
function showDiv(divName){
	document.getElementById(divName).style.display = '';
}
function hideDiv(divName){
	document.getElementById(divName).style.display = 'none';
}
function showHideDiv(divName){
	var divstatus = document.getElementById(divName).style.display;
	if(divstatus=='none'){
		document.getElementById(divName).style.display = '';
	}else{
		document.getElementById(divName).style.display = 'none';
	}
}
function showAllGroup(groupName){

		var cells = document.getElementsByTagName("div"); 
		for (var i = 0; i < cells.length; i++) { 
			var status = cells[i].getAttribute("name"); 
			if (status == groupName) { 
				cells[i].style.display = '';
			}
		}
}
function hideAllGroup(groupName){

		var cells = document.getElementsByTagName("div"); 
		for (var i = 0; i < cells.length; i++) { 
			var status = cells[i].getAttribute("name"); 
			if (status == groupName) { 
				cells[i].style.display = "none";
			}
		}
}	


	function clearfield(thefield){
		document.getElementById(thefield).value = '';	
	}
	
function showIcon(div)
{
	thisclass = document.getElementById(div).className;
	document.getElementById(div).className = 'icon showicon';
}
function hideIcon(div)
{
	document.getElementById(div).className = thisclass;
}

function iconswift(theimg,number)
{
	newimg = theimg+number+".jpg";
	document.getElementById(theimg).src= server+"/img/"+newimg;
}

function bookmarksite(title,url){
	if (window.sidebar){ // firefox
		window.sidebar.addPanel(title, url, "");
	}else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}else if(document.all){// ie
		window.external.AddFavorite(url, title);
	}else{
		alert("Funktion fungerar tyvärr ej i din webbläsare");	
	}
}

	function ifEmpty()
						{
							var thename = document.getElementById('namn').value;
							var theemail = document.getElementById('email').value;
							thisvaln = thename.replace(/ /g,"");
							thisvale = theemail.replace(/ /g,"");
							if(thisvaln=='' || thisvale=='')
							{
								document.getElementById('fblike').style.visibility = 'hidden';
								document.getElementById('vidare').style.display = '';
							}
						}
						function ifEmpty2()
						{
							var thename = document.getElementById('namn').value;
							var theemail = document.getElementById('email').value;
							thisvaln = thename.replace(/ /g,"");
							thisvale = theemail.replace(/ /g,"");
							if(thisvaln=='' || thisvale=='')
							{
								document.getElementById('fblike').style.visibility = 'hidden';
								document.getElementById('vidare').style.display = '';
								alert('Du måste fylla i namn och epost först!');
							
							}
						}
						function validateEmail()
						{
						var x=document.getElementById('email').value;
						var atpos=x.indexOf("@");
						var dotpos=x.lastIndexOf(".");
						if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
						  {
						   if(x!='') alert("Du har inte skrivit en korrekt email-adress");
								document.getElementById('fblike').style.visibility = 'hidden';
								document.getElementById('vidare').style.display = '';
						  return false;
						  }
						}



// SCROLLFUNKTION FÖR EVENEMANGSLISTA I SIDHUVUD

		var defaultStep=1;
		var step=defaultStep;
		var timer;

		function scrollDiv(id,s){
			 var obj=document.getElementById(id);
			 var iScrollTop = obj.scrollTop;
			 step=s||step;
			 if (iScrollTop == 0){
					 step=defaultStep;
			 }
			 else if (obj.clientHeight + iScrollTop - obj.scrollHeight==0){
				
				 window.setTimeout(function(){scrollDiv(id,-defaultStep); },1000)
			 }
				clearTimeout(timer);
				 obj.scrollTop+=step;
				timer=setTimeout(function(){ scrollDiv(id); },50)
		}


		function stopMe(id){
		 clearTimeout(timer);
		}

		function pauseMe(id,s){
		 clearTimeout(timer);
		 window.setTimeout(function(){scrollDiv(id,s); },5000)

		}

		function getSpecs(id){
		 var obj=document.getElementById(id);
		 var iScrollHeight = obj.scrollHeight;
		 var iScrollTop = obj.scrollTop;
		 var iClientHeight = obj.clientHeight;
		 var iPOS = (iClientHeight + iScrollTop) - iScrollHeight;
		 alert("The value of scrollHeight is:" + iScrollHeight + "px" + "\nScrollTop is:" + iScrollTop + "\nViewable height:" + iClientHeight + "\nLeft:" + iPOS)
		}

		function scrollMe(id){
			 window.setTimeout(function(){scrollDiv(id); },3000)
		}




$(document).ready(function(){
	
	//$(".accordion h3:first").addClass("active");
	//$(".accordion p:not(:first)").hide();

 	$(".accordion p").hide();

	$(".accordion h3").click(function(){
		$(this).next("p").slideToggle("slow")
		.siblings("p:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});


});


$(window).load(function() {$('#slider').nivoSlider()});
