$(document).ready(function () {
    $('#regionGoButton').click(function () {
        var regionSelectorVal = $('#regionSelector').val();
        if (regionSelectorVal != '') {
            window.open(regionSelectorVal);
        } else {
            alert('Du har ikke valgt en kommune');
        }
	return false;
    });
    $(".photoScroller").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev"
    });

    $('.next').hover(function () {
        this.src = '/images/scroller_right_hover.gif';
    }, function () {
        this.src = '/images/scroller_right.gif';
    });
    $('.prev').hover(function () {
        this.src = '/images/scroller_left_hover.gif';
    }, function () {
        this.src = '/images/scroller_left.gif';
    });

    $('.photoScroller ul li').hover(function () {
        $(this).css('border', '1px solid #e41283');    
    }, function () {
        $(this).css('border', '1px solid #dedede');
    });

    $(".photoScroller li a").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 600,
        'speedOut': 200,
        'overlayShow': true,
	'overlayOpacity': '0.8',
	'overlayColor': '#000',
        'titlePosition': 'inside',
        'margin': 0
    });

    $("a.lightbox_photo, a.lightbox_photo_link").fancybox({
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 600,
        'speedOut': 200,
        'overlayShow': true,
	 'overlayOpacity': '0.8',
	 'overlayColor': '#000',
        'titlePosition': 'inside',
        'margin': 0,
	'titleShow': false
    });

    $('a.email').each(function () {
        e = this.rel.replace('/', '@');
        this.href = 'mailto:' + e;
        $(this).text(e);
    });
});