﻿
$(document).ready(function() {
    /* ENABLES TRANCPERNCY IN IE 6*/
    $(document).pngFix();


    $('.ansvarig a.contact').click(function() {
        $('#contact-popup').addClass('opened');
        var myElement = $('#contact-popup.opened');
        myElement.css({
            position: 'absolute',
            left: '50%',
            top: '50%',
            'margin-left': 0 - (myElement.width() / 2),
            'margin-top': 0 - (myElement.height() / 2),
            'z-index': '10000'

        });

    });

    $('#contact-popup .close').click(function() {
        $('#contact-popup').removeClass('opened');
        var myElement = $('#contact-popup');
        myElement.css({
            position: 'absolute',
            left: '-400px',
            top: '-400px',
            'z-index': '10000'
        });

    });

    /* TOGGLE DIVS ON REGISTERPAGE*/
    $('#arbetsgivarinfo').show();
    $('#nuvarandeinfo').show();

    $('.arbetsgivare a').click(function() {
        $('.arbetsgivare span').toggle();
        $('#arbetsgivarinfo').slideToggle(400);
        return false;
    });

    $('.nuvarande a').click(function() {
        $('.nuvarande span').toggle();
        $('#nuvarandeinfo').slideToggle(400);
        return false;
    });


    /*ROUNDCORNERS IN NEWSLISTINGS*/
    $("<div class='tr'></div><div class='bl'></div>").appendTo("#newsarea .image");
    $("<div class='tr'></div><div class='bl'></div>").appendTo("#newsarea2 .image");

    /*ROUNDCORNERS ON STANDARDPAGES*/
    $("<div class='tr'></div><div class='bl'></div>").appendTo("#rightcolumn .rcpuff");

    /*SETTINGS FOR SLIDESHOW ON STARTPAGE*/
    $('.slideshow .img').cycle({
        fx: 'fade', /*'scrollHorz',*/
        speed: 1200,
        timeout: 7000,
        next: '#next',
        prev: '#prev'
    });

    


    /* TOGGLE MESSAGEHISTORY ON MY MESSAGES PAGE  */
  //  $(".toggle_container").hide();

    /*$("span.trigger").toggle(function() {
        $(this).addClass("active");

    },
    function() {
        $(this).removeClass("active");
    });
*/
   // $("span.trigger").click(function() {

  //  $(this).next(".toggle_container").slideToggle("slow");


    /*$(this).next(".toggle_container .knapp").trigger('click');

*/

     /*   $.ajax({
        type: "POST",
        
        url: "/Templates/Public/Pages/MyMessages.aspx?id=66&epslanguage=sv/Testar",
        dataType: "json",
        data: "{}",
        error: function(xhr, ajaxOptions, thrownError) {
            alert(xhr.status);
            alert(thrownError); 
        },
        success: function(msg) {
        $(".testar").text(msg.d);
        }
        })
        */
        
    //});








    /*SETTINGS FOR SLIDESHOW ON OBJECTPAGE*/
    $('.slideshow-small').cycle({
        fx: 'scrollHorz',
        speed: 1200,
        timeout: 0,
        pager: '#nav',
        pagerEvent: 'click',
        before: onBefore
    });

    /*DISABLES ENTERPRESS IF YOUR IN #CONTENT-DIV*/
    $("#content").keypress(function(e) {
        if (e.which == 13) {
            return false;
        }
    });

});

function Show_Popup(action, userid) {
    $('#popup').fadeIn('fast');
    $('#window').fadeIn('fast');
}

function Close_Popup() {
    $('#popup').fadeOut('fast');
    $('#window').fadeOut('fast');
};

function onBefore(curr, next, opts) {
    var $slide = $(next);
    var w = $slide.outerWidth();
    var h = $slide.outerHeight();
    $slide.css({
        marginTop: (190 - h) / 2,
        marginLeft: (420 - w) / 2
    });
};


