var scrollpos=540;
var nowpic=1;
var intervalid
var refreshpage =null;

$(function(){
 nextpage('velkommen.htm')
 fsprog=sprog_flag.split(',');
 for(var i=0;i<fsprog.length;i++)
    $('a[value='+fsprog[i]+']').show();	
$('a.flag').click(function(){
	
	createCookie('papper_sprog',$(this).attr('value'),60);
    inipage();
	return false;
})


});

function nextpage(purl){
	
	$('#xdata').html('');
	$.ajax({
        url: purl,
        dataType: "html",
        success: function(data) {
		
           $('#xdata').append($(data).find('#datatb'));
		   nowurl=purl;
           inipage();
        },

        error:function (XMLHttpRequest, textStatus, errorThrown) {
alert(eval(sprog +'_error') );
        }   });
	
}
function nextpic(){
var i=nowpic
i++
 activpic=$('#picmenu td:visible');
 if(i>activpic.length-1)
    i=0;
if(i!=nowpic)	
   picfade(activpic.get(i));

 nowpic=i;
}


var iniscroll=0;


function getobj(name)
{
return document.getElementById(name)
}

function changepic(obj)
{
window.clearInterval(intervalid);
 picfade(obj)
}
function picfade(obj){
if(obj.length==0)
  return;
var pictb=$('#picshow');
var  picdiv=$('#picshow div');
picdiv.get(0).style.backgroundImage=pictb.get(0).style.backgroundImage;
picdiv.show();
pictb.get(0).style.backgroundImage='url('+obj.picname+')';
picdiv.fadeOut('slow');

$('#picmenu td.selmenu').removeClass('selmenu')

$(obj).addClass('selmenu');
}
var nowurl
function gotopage(url,scroll)
{

if(scroll!=null)
  iniscroll=scrollpos;
if(url==nowurl)
   {scrolldw(iniscroll)
   iniscroll=0;
    }
else{
	
	nextpage(url)
}
}
function g_show(obj,show)
{
if(obj!=null)
{
if(show)
   obj.style.display='';
else
   obj.style.display='none';
}}
function showsubmenu(no,no2)
{
var tb=document.getElementById('mmenu')
for(var i=0;i<tb.rows.length;i++)
{
var submenu=document.getElementById('menusub'+i)
g_show(submenu,i==no);
for(var x=0;x<6;x++)
	{
	   var submenu=document.getElementById('menusub'+i+'_'+x)
	   g_show(submenu,x==no2);
    }
}
}
function putfistpic()
{
 nowpic=0;
changepic(document.getElementById('firstpic'));
intervalid=window.setInterval(nextpic,3000);
}

function xrolldown(topos)
{
//imgx.height=imgx.height-20;


   showsubmenu(-1)
   getobj('mainmenu').style.display='';
   return false;
}

var ypos
var nowpos=0
var dir

function scrolldw(xpos)
{

 ypos=xpos;

 nowpos=scrollingDetector();
 if(nowpos != xpos)
     scrollwin();
 return false;
}

function scrollingDetector(){

if (navigator.appName == "Microsoft Internet Explorer")
return  document.body.scrollTop ;
return window.pageYOffset;
}

function scrollwin()
{



var diff=parseInt((ypos-nowpos)/4,10);
nowpos=nowpos+diff;
if (Math.abs(nowpos-ypos)<8)
{
  window.scrollTo(0,ypos);
  nowpos=ypos;

 }
else
{
  window.scrollTo(0,nowpos)
  window.setTimeout(scrollwin,20);
}
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
location.reload();
}
MM_reloadPage(true);
//-->


