var interval = 5000;
var slideInterval = 500;
var slideContainer = '#scrollerContainer';
var counter=0;
var aktivmenu = 0;
var article = 0;
var notaterStatus = 1;

var steps = new Array();
	steps[0] = -430;
	steps[1] = -1750;
	steps[2] = -3000;
	steps[3] = -4100;
	
var front = new Array();
	front[0] = 0;
	front[1] = 997;
	front[2] = 997*2;
	front[3] = 997*3;

function scrollSite(id) {
	
	if(id > 0) {
		
		if(notaterStatus==1) {
			jQuery("#notaterForside").hide();
			notaterStatus = 0;
		}
	
	} else if(notaterStatus == 0) {
		
		jQuery("#notaterForside").show();
		notaterStatus = 1;
	}

	if(id < 3) {
		jQuery("#menu" + id).addClass("aktiv");
	}
	if(id != aktivmenu) {
		jQuery("#menu" + aktivmenu).removeClass("aktiv");
		aktivmenu = id;
	}
	
	jQuery("#contentContainer").scrollTo({'top':'0px', 'left': front[id] + 'px'} , slideInterval );
	jQuery(slideContainer).animate({'backgroundPosition': "(" + steps[id] + "px 0)"} , {duration: slideInterval });
	

}

function loadContent(id) {

	jQuery.post('/code/page.php' , {'id': id} , function(data) {
	
		jQuery("#scroller" + id).html(data);
		
		if(id==1) {
			jQuery('#imageContinaer a').lightBox();
		}
		
		try {
			eval('jQuery("#scroller" + id).pngFix()');
		}catch(Error){}
	
	});

}

function loadArticle(id) {

	jQuery("#artikkelInsideContainer").load('/code/article.php' , { 'id': id} , function() {
	
		showArticle();
	
	});

}

function toggleArticle() {

	if(article==0) {
		
		showArticle()
	
	} else {
	
		hideArticle();
	
	}

}

function showArticle() {
	if(article==0) {
		jQuery("#artikkelContainer").show("scale", {}, 1000);
		article = 1;
	}
}

function hideArticle() {
	if(article==1) {
		jQuery("#artikkelContainer").hide("scale", {}, 1000);
		article = 0;
	}
}

function sendContactForm() {

	var navn = jQuery("#frmNavn").attr("value");
	var epost = jQuery("#frmEpost").attr("value");
	var telefon = jQuery("#frmTelefon").attr("value");
	var melding = jQuery("#frmMelding").attr("value");
	
	jQuery.post('/code/sendcontact.php' , {'navn': navn, 'epost': epost, 'telefon': telefon, 'melding': melding},function(data) {
	
		if(data==1) {

			jQuery("#successContainer").html('Meldingen er n&aring; sendt.');
			showSuccsess();
			jQuery("#soundContainer").html( '<embed src="/filer/Multimedia/Audio/ding_dong.wav" hidden="true" autostart="true" loop="false" width="0" height="0" />' );
			
			jQuery("#frmNavn").attr("value","");
			jQuery("#frmEpost").attr("value","");
			jQuery("#frmTelefon").attr("value","");
			jQuery("#frmMelding").attr("value","");
			
		} else {
		
			jQuery("#errorContainer").html(data);
			showError();
			
		}
		
	});
}

var errorVisible = 0;

function showError() {
	if(errorVisible==0) {
		errorVisible = 1;
		jQuery("#errorContainer").show("blind");
		
		window.setTimeout("hideError()",3000);
	}
}

function hideError() {
	if(errorVisible==1) {
		errorVisible = 0;
		jQuery("#errorContainer").hide("blind");
	}
}

var succsessVisible = 0;

function showSuccsess() {
	if(succsessVisible==0) {
		succsessVisible = 1;
		jQuery("#successContainer").show("blind");
		
		window.setTimeout("hideSuccsess()",7000);
	}
}

function hideSuccsess() {
	if(succsessVisible==1) {
		succsessVisible = 0;
		jQuery("#successContainer").hide("blind");
	}
}

function loadNotater(start) {
	
	jQuery("#sideTop4").load('/blocks/notater.php' , {'start':start} , function() {
	
	});
	
}

function loadSitemap() {
	
	jQuery("#artikkelInsideContainer").load('/code/sitemap.php',{},function() {
	
		showArticle();
		
	});
	
}

function loadSearch() {
	
	var search = jQuery("#impSearch").attr("value");
	
	if(search) {
		
		jQuery("#artikkelInsideContainer").load('/code/search.php' , {'search': search} , function() {
		
			showArticle();
		
		});
		
	}
	
}

jQuery(document).ready(function(){
	jQuery("#artikkelContainer").hide();
	
	for(var i=0;i<=4;i++) {

		loadContent(i);

	}
});


