


function galleri(){
		if(!$('flash')) return false;
		var i = 0;
		var arr = $('flash').childElements();
		
		new PeriodicalExecuter(function() {
			
			if ((i+1) == arr.size()){
				i = 0;
				Effect.Appear(arr[0], { duration: 1.0 });
				window.setTimeout(function() { arr.invoke('show'); } , 5000);
			}else{
				Effect.Fade(arr[i], { duration: 1.0 });
				i += 1;
			};
		},5);
	}
	

function duplicate()
	{
		var brukernavn = $('#epost').val();
		$('#brukernavn').attr("value", brukernavn);
	}

function toplinker_over(arg)
	{
		document.getElementById(arg).className = "act_"+arg;
		document.getElementById(arg).style.color='#000';
	}
	
function toplinker_out(arg)
	{
		document.getElementById(arg).className = "pass_"+arg;
		document.getElementById(arg).style.color='#999692';
	}


function carousel() {
	 // Using default configuration
	    if(!$("#foo1")) return false;
			$("#foo1").carouFredSel();
			
	     
	    // Using custom configuration
	   if(!$("#foo2")) return false;
	   		
	   		$("#foo2").carouFredSel({
	       	items               : 1,
	        direction           : "left",
			width				: "510px",
			height				: "328px",	
			
			auto : {
				play			: true,
				pauseDuration	: 3500,
				delay			: 0
			},
			
			prev : {
				button			: $("#nav_left")
			},
			
			next : {
				button			: $("#nav_right")
			},
			
	        scroll : {
	            items           : 1,
	            effect          : "easeOutBounce",
				easing 			: "swing",
	            duration        : 900,                        
           		pauseOnHover    : false
	        }                  
	    });
}

function validate() {
		var valid = true;
		var msg = "Følgende felter er feil fylt ut:" + "\n";
		$('#validate_form input').each(function(index) {
			var navn = $(this).attr('navn');
			if($(this).attr('type') != "hidden") {
				if($(this).attr('rel') == "text") {
					
					if($(this).val().length < 2) {
						$(this).css('background','#ff8484');
						valid = false;
						msg += "-" + navn + "\n";
					}else{
						$(this).css('background','#fff');
					}
				}
			}
				if($(this).attr('rel') == "number") {
					if(isNaN(parseInt($(this).val())) || $(this).val().length < 4) {
						$(this).css('background','#ff8484');
						valid = false;
						msg += "-" + navn + "\n";
					}else{
						$(this).css('background','#fff');
					}
					
				}
				
				if($(this).attr('rel') == "e-post") {
					if($(this).val().indexOf('@') == -1) {
						$(this).css('background','#ff8484');
						valid = false;
						msg += "-" + navn + "\n";
					}else{
						$(this).css('background','#fff');
					}
				}
				
				
			
		});
				
		if(valid == false) {
			alert(msg);
			return false;
		}
	}


$(document).ready(function() {
	 if($('#box_front')) { carousel() };  
	 galleri();
	  //setInterval( "slideSwitch()", 3500 );
	});

	
	



