﻿$(document).ready(function () {

    $.backstretch("/Images/Background.jpg", {
        speed: 150,
        centeredY: false
    });





});

function callFyllinn(txt) {

    if (txt.value.toLowerCase() == "fyll inn") {
        txt.value = "";
        txt.select();
    } else {
        txt.select();
    }
}


function loadItemfromid(txt,language) {

  $("div#lastPostsLoader").html("<img src=\"/Images/loader.gif\"/>");


    var webMethod = '/InternalWebService.asmx/GetNewsList';
    if(txt=="0"){
        var id = "0";
    }else{
        var id = $(".standardbox:last").attr("id");
    }

    $.ajax({
        type: "POST",
        url: webMethod,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        data: "{ 'id': '" + id + "','language': '" + language + "'}",

        success: function (msg) {
            var result = JSON.parse(msg.d);

            $.each(result, function (key, val) {

                $.each(val, function (key2, val2) {
                    switch (key2) {

                        case "dato":
                            dato = val2;
                            break;
                        case "link":
                            link = val2;
                            break;
                        case "tittel":
                            tittel = val2;
                            break;
                        case "sortOrder":
                            sortOrder = val2;
                            break;
                        case "videoArticle":
                            videoArticle = val2;
                            break;
                        case "image":
                            image = val2;
                            break;
                        default:

                    }
                });

                if (videoArticle == "true") {
                    showVideo = 'style="display:inline;"';
                } else {
                    showVideo = 'style="display:none;"';
                }

                $('#newsSection').append('<div class="standardbox orangebox" id="' + sortOrder + '"> <a href="' + link + '" class="konsertlink"><div class="playbtn" ' + showVideo + '></div><div class="datobox"><div class="konsert konsertDato"> <span>' + dato + '</span> </div></div><img src="' + image + '"><div class="infobox"> <span class="konsert konsertNavn">' + tittel + '</span> </div></a></div>');

            });

            $("div#lastPostsLoader").empty();
        },

        error: function (XMLHttpRequest, textStatus, errorThrown) {
        }
    });
}

 



