﻿
$(document).ready(function () {
    $(".rightimage").each(function () { //.interview .image img, 
        var imageurl = $(this).attr("src");
        var imagewidth = 220;
        var imageheight = $(this).attr("height");
        var imageframe = createimageframe(imageurl, imagewidth, imageheight);

        //$(this).attr("width", 200).attr("height", "");
        //var parent = $(this).parent();
        //parent.empty();
        //imageframe.appendTo(parent);
        //$(this).replaceWith(imageframe);

        //alert(imageframe.html());
    });


    $(".interview .image img").each(function () { //.interview .image img, 
        var imageurl = $(this).attr("src");
        var imagewidth = $(this).attr("width");
        var imageheight = $(this).attr("height");
        var imageframe = createimageframe(imageurl, imagewidth, imageheight);


        //var parent = $(this).parent();
        //parent.empty();
        //imageframe.appendTo(parent);
        //$(this).replaceWith(imageframe);
    });

    $(".quoteframe .text").each(function () {
        var content = $(this).html();
        var newcontent = "<img src='/BluerangeEasy/templates/2167/images/quotesign_start.gif' class='startquote'/>" + content + "<img src='/BluerangeEasy/templates/2167/images/quotesign_end.gif' class='endquote'/>";

        //$(this).html(newcontent);
    });
});

function createimageframe(imageurl, imagewidth, imageheight) {
    var frame = $("<div></div>").addClass("imageframe").css("width", imagewidth).css("height", imageheight);
    $("<img/>").attr("src", imageurl).appendTo(frame).attr("alt", "hejsan");
    $("<img/>").attr("src", "/BluerangeEasy/templates/2167/images/roundedimg_topleft.png").addClass("topleft").appendTo(frame);
    $("<img/>").attr("src", "/BluerangeEasy/templates/2167/images/roundedimg_topright.png").addClass("topright").appendTo(frame);
    $("<img/>").attr("src", "/BluerangeEasy/templates/2167/images/roundedimg_bottomright.png").addClass("bottomright").appendTo(frame);
    $("<img/>").attr("src", "/BluerangeEasy/templates/2167/images/roundedimg_bottomleft.png").addClass("bottomleft").appendTo(frame);

    return frame;
}

function writenewsmenu(categoryid) {
    //make the request
    $.ajax({
        url: "/-nyheter-/?newsview=leftnewsmenu&newscategory=" + categoryid + "&xslt=blank.xsl",
        success: function (data) {
            $("#leftmenunews").html(data);
            if ($("#topimageframe").length == 0) {
                $(".leftmenuframe").css("top", 100);
            }
        }
    });
}
function writecalendarmenu(categoryid) {
    //make the request
    $.ajax({
        url: "/-kalender-/?calendarview=leftcalendarmenu&calendarcategory=" + categoryid + "&xslt=blank.xsl",
        success: function (data) {
            $("#leftmenucalendar").html(data);
            if ($("#topimageframe").length == 0) {
                $(".leftmenuframe").css("top", 100);
            }
        }
    });
}
