function changeBackGround()
{
	setTimeout('swapImage()',2000);
//	setTimeout('swapImage2()',4000);
//	setTimeout('swapImage()',6000);
}
function swapImage()
{
	opacity3('bkg_div',100,0,1000);
	background_image.src='images/bkg_soj.jpg';
	opacity3('bkg_div',0,100,1000);
	setTimeout('swapImage2()',10000);
}
function swapImage2()
{
	opacity3('bkg_div',100,0,1000);
	background_image.src='images/bkg_jof.jpg';
	opacity3('bkg_div',0,100,1000);
	setTimeout('swapImage()',10000);
}

function hideFocusBorders()
{
	var theahrefs = document.getElementsByTagName("a");
	if (!theahrefs){return;}
		for(var x=0;x!=theahrefs.length;x++)
		{
			theahrefs[x].onfocus = function stopLinkFocus(){this.hideFocus=true;};
		}
}
function showhide(id)
{
	if (document.getElementById)
	{
		obj = document.getElementById(id);
		if(!(obj == null))
		{
			if (obj.style.display == "none")
			{
				obj.style.display = "";
			}
			else
			{
				obj.style.display = "none";
			}
		}
	}
} 
function fadeInDiv(id)
{
	opacity2(id, 0, 100,300);
} 
function fadeOutDiv(id)
{
	opacity2(id, 100, 0,300);
} 
function hideDiv(id)
{
	if (document.getElementById)
	{
		obj = document.getElementById(id);
		if(!(obj == null))
		{
			obj.style.display = "none";
		}
	}
} 
function showDiv(id)
{
	if (document.getElementById)
	{
		obj = document.getElementById(id);
		if(!(obj == null))
		{
			obj.style.display = "inline";
		}
	}
} 
function showInfo()
{
	hideAll();
	showDiv('info_bkg_info');
	//showDiv('information_bkg_right');
	fadeInDiv('info_pic');
	fadeInDiv('info_in_action');
	fadeInDiv('info');
}
function showKontakt()
{
	hideAll();
	//showDiv('information_bkg');
	showDiv('information_bkg_kontakt');
	fadeInDiv('kontakt');
	fadeInDiv('kontakt_right');
}
function showReferens()
{
	hideAll();
	showDiv('referens_bkg');
	fadeInDiv('referens');
}
function showKollegor()
{
	hideAll();
	showDiv('kollegor_bkg');
	fadeInDiv('kollegor');
}
function showGalleri()
{
	hideAll();
	showDiv('gallery2010_bkg');
	fadeInDiv('gallery2010');
}

function showErbjudande()
{
	hideAll();
	showDiv('information_bkg');
	showDiv('information_bkg_right');
	
	fadeInDiv('erbjudande');
	fadeInDiv('erbjudande_right');

}

function hideAll()
{
	opacity2('info_pic',1,0,1);
	opacity2('info_in_action',1,0,1);
	opacity2('info',1,0,1);
	
	opacity2('kontakt',1,0,1);
	opacity2('kontakt_right',1,0,1);
	
	opacity2('erbjudande',1,0,1);
	opacity2('erbjudande_right',1,0,1);
	
	hideDiv('information_bkg');
	hideDiv('information_bkg_right');
	hideDiv('information_bkg_kontakt');
	hideDiv('info_bkg_info');
	
	hideDiv('gallery2010_bkg');
	opacity2('gallery2010',2,1,1);
	
	showDiv('kontakt_confirm');
	//hideDiv('kontakt_confirm');
	
	hideDiv('referens_bkg');
	hideDiv('referens');
	
	hideDiv('kollegor_bkg');
	hideDiv('kollegor');
}

function opacity2(id, opacStart, opacEnd, millisec)
{
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd)
	{
		for(i = opacStart; i >= opacEnd; i-=2)
		{
			setTimeout("opac2(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
		hideDiv(id);
	}
	else if(opacStart < opacEnd)
	{
		showDiv(id);
		for(i = opacStart; i <= opacEnd; i+=2)
		{
			setTimeout("opac2(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}
function opacity3(id, opacStart, opacEnd, millisec)
{
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd)
	{
		for(i = opacStart; i >= opacEnd; i-=2)
		{
			setTimeout("opac2(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
	else if(opacStart < opacEnd)
	{
		for(i = opacStart; i <= opacEnd; i+=2)
		{
			setTimeout("opac2(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}
function opac2(opac, id)
{
	document.poppedLayer = eval('document.all[\'' + id + '\']');
	document.poppedLayer.style.opacity = (opac / 100);
	document.poppedLayer.style.filter = "alpha(opacity=" + opac + ")";
}
