﻿$(document).ready(function()
{
    //if (!(Uvtc.ua.isIE6 || Uvtc.ua.isMobile)) {
    if (!(Uvtc.ua.isIE6)) {
        //features
        $('#featurelist .tabs li a').featureList({
            output: '#featurelist .output li',
            start_item: 0
        });
        //add a bottom carousel with blue dots to the features with the same functionality
        $('#featurelist .output .carousel .first').click(function() {
            $('#featurelist .tabs .tab1').click();
        });
        $('#featurelist .output .carousel .second').click(function() {
            $('#featurelist .tabs .tab2').click();
        });
        $('#featurelist .output .carousel .third').click(function() {
            $('#featurelist .tabs .tab3').click();
        });
        $('#featurelist .output .carousel .fourth').click(function() {
            $('#featurelist .tabs .tab4').click();
        });

        //scrollpane
        $(".scroll-pane").scrollPane();

        //accordion
        var icons = {
            header: "expand",
            headerSelected: "collapse"
        };
        $(".accordion").accordion({
            icons: icons,
            fillSpace: true
        });

        //disable for now the featurelist-services rotator
        /*
        $('#featurelist-services .output').cycle({
            fx: 'scrollVert',
            speed: 800,
            timeout: 6000,
            pause: 1,
            pager: '#featurelist-services .tabs',
            pagerEvent: 'mouseover',
            pauseOnPagerHover: true,
            pagerAnchorBuilder: function(idx, slide) {
                return '#featurelist-services .tabs li:eq(' + idx + ') a';
            }
        });
        */
        
        //tooltip bubble (small i triangle in the bottom-left corner)
        /*
	    $('.bubbletooltip').qtip({
            position: {
                my: 'bottom center',
                target: 'mouse',
                viewport: $(window), // Keep it on-screen at all times if possible
                adjust: {
                    x: 0,  y: 15
                }
            },
            hide: {
                fixed: true // Helps to prevent the tooltip from hiding ocassionally when tracking!
            },
            style: {
                classes: 'bubblepopup ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'
            }
        });
        */
        
        //newsticker
        var newsticker = function()
        {
            setTimeout(function(){
                $('#ticker li:first').animate( {marginTop: '-41px'}, 500, function()
                {
                    var moveToEnd = $(this).removeAttr('style').detach();
                    $('#ticker li:last').after(moveToEnd);
                    
                });
                newsticker();
            }, 5000);
        };
        newsticker();
        $('#ticker-controls #next').click(function() {
            $('#ticker li:first').animate( {marginTop: '-41px'}, 500, function()
            {
                var moveToEnd = $(this).removeAttr('style').detach();
                $('#ticker li:last').after(moveToEnd);
            });
        });
        $('#ticker-controls #prev').click(function() {
            $('#ticker li:first').animate( {marginTop: '41px'}, 500, function()
            {
                var moveToEnd = $(this).removeAttr('style').detach();
                $('#ticker li:last').after(moveToEnd);
            });
        });
    }
	
    //search box
    //disable for now the chat box
    //$("#chat .textbox").watermark({ text: "Din fråga..." });
    
    //dealen popup
    $('#popup-dealen .arrow.next').click(function(){
        $('#popup-dealen #slider-movingboxes ul').animate({"marginLeft": "-804px"}); //536px without stadsnat
    });
    $('#popup-dealen .arrow.prev').click(function(){
        $('#popup-dealen #slider-movingboxes ul').animate({"marginLeft": "0px"});
    });
    $('#popup-dealen .painting').hover(function(){
        $(this).find(".overlaycontent").show().animate({"height": "165px"});
        //$(this).find(".overlaycontent").animate({"width": "213px"});
    },
    function(){
        $(this).find(".overlaycontent").animate({"height": "0px"}).hide();
        //$(this).find(".overlaycontent").animate({"width": "0px"});
    })

});
