function frontpageRotator() {
    $('div#frontpageImages a').css({ opacity: 0.0 });
    $('div#frontpageImages a:first').css({ opacity: 1.0 });
    //Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('rotate()', 6000);
}

function rotate() {
    var current = ($('div#frontpageImages a.show') ? $('div#frontpageImages a.show') : $('div#frontpageImages a:first'));
    var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#frontpageImages a:first') : current.next()) : $('div#frontpageImages a:first'));

    //Set the fade in effect for the next image, the show class has higher z-index
    next.css({ opacity: 0.0 })
  .addClass('show')
  .animate({ opacity: 1.0 }, 1000);

    //Hide the current image
    current.animate({ opacity: 0.0 }, 1000)
  .removeClass('show');
}

$(document).ready(function () {
    //Load the slideshow
    frontpageRotator();
});

// searchfield reset
$(document).ready(function () {
    $('.default-value').each(function () {
        var default_value = this.value;
        $(this).focus(function () {
            if (this.value == default_value) {
                this.value = '';
            }
        });
        $(this).blur(function () {
            if (this.value == '') {
                this.value = default_value;
            }
        });
    });
});

// FAQ thingy
$(document).ready(function () {
    $('.faqElement').each(function (a, faq) {
        $(faq).find('h3').click(function () {
            var parent = $(this).parent();
            $(parent).find('div.faqInner').slideToggle('fast');
        });
    });
});

// Print icon
$(document).ready(function () {
    $('a[rel="print"]').click(function() {
        window.print();
        return false;
    });
});

// Cufon
Cufon.replace('#header a');
Cufon.replace('#top-content ul li a', {
    hover: true
});
Cufon.replace('.frontpageShortCuts h2');
Cufon.replace('.inner h2');
Cufon.replace('h1');
Cufon.replace('.faqElement h3');
Cufon.replace('.box h2');
 


// New User Submit
$(document).ready(function() {
    if ($('.signupform').length != 0) {

        jQuery.validator.addMethod(
   "selectNone",
   function(value, element) {
       if (element.value == "none") {
           element.Class = 'error'; 
           return false;
       }
       else return true;
   },
   "V&aelig;lg fra listen."
 );

        $('#aspnetForm').validate({
            rules: {
                username: "required", // simple rule, converted to {required:true}   
                email: {// compound rule   
                    required: true,
                    email: true
                },
                firstname: {
                    required: true,
                    minlength: 2

                },
                lastname: {
                    required: true,
                    minlength: 2
                },
                address: {
                    required: true,
                    minlength: 2
                },
                zip: {
                    required: true,
                    minlength: 4
                },
                city: {
                    required: true,
                    minlength: 2
                },
                email: {
                    required: true,
                    email: true
                },
                sex: {
                    selectNone: true

                },
                country: {
                    selectNone: true

                },
                birth: {
                    required: true
                },
                job: {
                    required: true
                },
                password: {
                    required: true
                },
                rep_password: {
                    required: true
                }
            },
            messages: {
                firstname: "Udfyld venligst dit fornavn",
                lastname: "Udfyld venligst dit efternavn",
                address: "Udfyld venligst din adresse",
                zip: "Udfyld venligst dit post.nr.",
                city: "Udfyld venligst by",
                birth: "Udfyld venligst dit f&oslash;dsels&aring;r",
                job: "Udfyld venligst din stilling",
                username: {
                    required: "Udfyld venligst dit personalenr.",
                    minlength: "Your username must consist of at least 2 characters"
                },
                password: {
                    required: "Udfyld venligst din adgangskode",
                    minlength: "Your password must be at least 5 characters long"
                },
                rep_password: {
                    required: "Udfyld venligst dit adgangskode",
                    minlength: "Your password must be at least 5 characters long",
                    equalTo: "Please enter the same password as above"
                },
                email: "Udfyld venligst din email addresse",
                agree: "Please accept our policy"
            }

        });
    }
});   

