﻿$(document).ready(function () {

    // Add pdf icons to pdf links
    $(".attachments a").addClass("download"); //default icon, might be overridden later    
    $(".attachments a[href$='.pdf']").addClass("pdf");
    $(".attachments a[href$='.mp3'], .attachments a[href$='.wav']").addClass("audio");
    $(".attachments a[href$='.doc'], .attachments a[href$='.rtf'], .attachments a[href$='.docx']").addClass("word");
    $(".attachments a[href$='.xls'], .attachments a[href$='.xlsx'], .attachments a[href$='.csv']").addClass("excel");
    $(".attachments a[href$='.jpg'], .attachments a[href$='.png'], .attachments a[href$='.gif'], .attachments a[href$='.tif'], .attachments a[href$='.tiff'], .attachments a[href$='.bmp']").addClass("picture");
    $(".attachments a[href$='.avi'], .attachments a[href$='.flv'], .attachments a[href$='.wmv'], .attachments a[href$='.mov'], .attachments a[href$='.divx'], .attachments a[href$='.mpeg']").addClass("video");
    $(".attachments a[href$='.zip'], .attachments a[href$='.rar']").addClass("zip");

    document.createElement("header");
    document.createElement("nav");
    document.createElement("section");
    document.createElement("aside");
    document.createElement("article");
    document.createElement("footer");
    document.createElement("figure");
    document.createElement("figcaption");
    /*
    // Add email icons to email links
    $("a[href^='mailto:']").addClass("email");

    //Add external link icon to external links - 
    $('a').filter(function() {
    //Compare the anchor tag's host name with location's host name
    return this.hostname && this.hostname !== location.hostname;
    }).addClass("external");
    */

    //You might also want to set the _target attribute to blank
    /*
    $('a').filter(function() {
    //Compare the anchor tag's host name with location's host name
    return this.hostname && this.hostname !== location.hostname;
    }).addClass("external").attr("target", "_blank");
    */




    //send to friend dialog
    var dlg1 = $("#sendBox").dialog({
        autoOpen: false,
        modal: true,
        resizable: false,
        title: "Tips en venn om denne siden",
        width: "auto",
        height: "auto",
        buttons: {
            "OK": function () {
                $(".sendLinkOK").trigger("click");
            },
            "Avbryt": function () {
                //console.log("# Cancel send message...");
                $("#sendBox").dialog('close');
            }
        },
        close: function (ev, ui) {
        }
    });
    dlg1.parent().appendTo($("form"));

    $(".sendLink").click(function () {
        //console.log("# Showing new address dialog...");
        $("#sendBox").dialog('open');
        //$(".dialogFocus").focus();
        return false;
    });


});
function fillTextBox(place) {
    switch (place) {
        case 'name':
            $(".delName").val($(".newName").val());
            if ($(".invoName").length) {
                $(".invoName").val($(".newName").val());
            }
            break;
        case 'surname':
            $(".delSurname").val($(".newSurname").val());
            if ($(".invoSurname").length) {
                $(".invoSurname").val($(".newSurname").val());
            }
            break;
        default:
            break;
    }
}
function sendmail(user, domain, suffix) {
    document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '</a>');
}

