// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Udviklet af: HUSET G (http://husetg.dk/)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

/* jQuery.clearField by Nicolaj Kirkgaard Nielsen
* Useage: $('input.text').clearField();
* Type of action is controlled by the class of the input field
* <input class="clear" value="Text to be cleared" /> - Normal clear field
* <input class="clear once" value="Text to be cleared" /> - Clear field, but don't return to previous value on blur
*/
var gallerychecker = $('#thumbHolder img:first-child').attr("src");
if (gallerychecker != null) {
    $('.imagebox').attr('src', "");
};


(function ($) { $.fn.clearField = function (options) { var opts = $.extend({}, $.fn.clearField.defaults, options); return this.each(function () { var $this = $(this); var text_val = $.trim($this.val()); $this.data('clearField', { txt: text_val }); $this.focus(function () { if ($.trim($(this).val()) === $(this).data('clearField').txt) { $(this).val(""); } }).blur(function () { if ($.trim($(this).val()) === "" && (!$(this).hasClass('once') && opts.type != 'once')) { $(this).val($(this).data('clearField').txt); } }); }); }; $.fn.clearField.defaults = { type: 'auto' }; })(jQuery);

jQuery(document).ready(function () {

    //Danish signup field
    $('#AccessUserEmail_3').attr('value', 'Indtast e-mail');
    $('#AccessUserEmail_3').clearField();

    //English signup field
    $('#AccessUserEmail_281').attr('value', 'Enter e-mail');
    $('#AccessUserEmail_281').clearField();

    // Email de-obfuscation e.g. "bill (at) mail dot com"
    $('a.mail').each(function () {
        var txt = $(this).text().replace(/\s\(at\)\s/, "@").replace(/\sdot\s/, ".");
        $(this).text(txt).attr('href', 'mailto:' + txt);
    });
    // Gallery

});

//if gallery is active remove article foto
jQuery('#logo').ready(function () {

    if ($('#thumbHolder img:first-child').attr("src") != null) {
        // Gallery
        var regex = /image=([^&]+)/i;
        var linkbuild = "Admin/Public/GetImage.aspx?Image=[X]&Width=685&Height=234";

        //Taking first gallery element at replaces current article img (if galleri is active)
        var firstLink = $('#thumbHolder img:first-child').attr("src");
        var firstAlt = $('#thumbHolder img:first-child').attr("alt");

        firstLink = firstLink.match(regex)[1];

        firstLink = linkbuild.replace("[X]", firstLink);
    }
    $('.imagebox').attr('src', firstLink);
    $('.imagebox').attr('alt', firstAlt);

    //Clickin on an image
    $('#thumbHolder > img').click(function () {
        var link = $(this).attr("src");
        var alt = $(this).attr("alt");

        link = link.match(regex)[1];

        link = linkbuild.replace("[X]", link);

        $('.imagebox').attr('src', link);
        $('.imagebox').attr('alt', alt);
        return false;
    });

});

