
function setLocation(url){
	window.location.href = url;
}




function validateAnmalan(f) {

	if(f.namn.value == "") {
		f.namn.focus();
		alert("Vad god kontrollera ert Namn!");
		return false;
	}

	if(f.postadress.value == "") {
		f.postadress.focus();
		alert("Vad god kontrollera er Postadress!");
		return false;
	}

	if(f.tele.value == "") {
		f.tele.focus();
		alert("Vad god kontrollera ert Telefonnummer!");
		return false;
	}

	if(f.epost.value == "") {
		f.epost.focus();
		alert("Vad god kontrollera er E-post!");
		return false;
	}

	return true;
}

var delay = 2000;
var start_frame = 0;

function init() {
	var lis = $('#slide-images').getElementsByTagName('li');

	for( i=0; i < lis.length; i++){
		if(i!=0){
			lis[i].style.display = 'none';
		}
	}
	end_frame = lis.length -1;

	start_slideshow(start_frame, end_frame, delay, lis);


}



function start_slideshow(start_frame, end_frame, delay, lis) {
	setTimeout(fadeInOut(start_frame,start_frame,end_frame, delay, lis), delay);
}


function fadeInOut(frame, start_frame, end_frame, delay, lis) {
	return (function() {
		lis = $('#slide-images').getElementsByTagName('li');
		Effect.Fade(lis[frame]);
		if (frame == end_frame) { frame = start_frame; } else { frame++; }
		lisAppear = lis[frame];
		setTimeout("Effect.Appear(lisAppear);", 0);
		setTimeout(fadeInOut(frame, start_frame, end_frame, delay), delay + 1850);
	})

}

function slideSwitch() {
    var $active = $('#content_banner DIV.active');

    if ( $active.length == 0 ) $active = $('#content_banner DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#content_banner DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );

	$('.galleryImageList').each(function() {
		$('#'+$(this).attr('id')+' a').lightBox({
			overlayBgColor: '#FFF',
			overlayOpacity: 0.2,
			imageLoading: cmsMainURL+'www/images/lightbox-ico-loading.gif',
			imageBtnClose: cmsMainURL+'www/images/lightbox-btn-close.png',
			imageBtnClose2:	cmsMainURL+'www/images/lightbox_close.png',
			imageBtnPrev: cmsMainURL+'www/images/lightbox-btn-prev.png',
			imageBtnNext: cmsMainURL+'www/images/lightbox-btn-next.png',
			containerResizeSpeed: 50
		});
	});
});
