﻿//Create Fake checkboxes
function CreateFakeCheckboxes() {
    jQuery("input:checkbox").each(function () {
        var label = jQuery(this).parent().find("label[for='" + this.id + "']");

        if (label != null && label.html() != null) {
            var string = "<div class='item'><a href='#'  found='" + this.id + "' class='fakecheck' id='fake" + this.id + "'>" + label.html() + "</a></div>";
            label.html(string);
            label.addClass("item");
            jQuery(this).hide();
        }
        if (this.checked) {
            jQuery("#fake" + this.id).addClass('fakechecked');
        }
        else {
            jQuery("#fake" + this.id).removeClass('fakechecked');
        }
    });
    jQuery(".fakecheck").each(function (elem) {
        var chkelement = jQuery(this);
        if (chkelement.attr("href") == "#") {
            chkelement.unbind("click");
        }
    });

    jQuery(".fakecheck").click(function () {
        var chkelement = jQuery(this);
        if (chkelement.attr("href") != "#") {
            return true;
        }
        if (chkelement.hasClass('fakechecked')) {
            chkelement.removeClass('fakechecked');
        }
        else {
            chkelement.addClass('fakechecked');
        }

        var inputBox = jQuery("#" + chkelement.attr("found"));
        inputBox.click();
        var className = inputBox.parent().parent().attr("class") + "";
        if (className.indexOf(" all") > -1) {
            var table = inputBox.parents("table");
            var checkboxes = table.find(".selectcheckbox .fakecheck");
            var inputboxes = table.find(".selectcheckbox input");
            if (inputBox.is(":checked")) {
                checkboxes.addClass('fakechecked');
                inputboxes.attr("checked", true);
            }
            else {
                checkboxes.removeClass('fakechecked');
                inputboxes.attr("checked", false);
            }

        }
        return false;
    });
}

//FLEMMINGS STYLINGSVARIABEL, DENNE BLIVER TRUKKET FRA CENTER COLLONNEN
//  NÅR VENSTRE/HØJREMENUERNE BLIVER VIST, OG TRUKKET FRA NÅR DE IKKE BLIVER VIST!
var colWidth = 16;
var centerWidth = 98;


function columnInit() {
    var columnsVisible = 0;
    if (jQuery("#leftMenu").is(":visible"))
        columnsVisible++;
    if (jQuery("#rightMenu").is(":visible"))
        columnsVisible++;

    var width = centerWidth - (colWidth * (columnsVisible));
    jQuery(".colCenter").animate({ width: (width) + "%" }, 1, function () {
    });
}
//Slides leftmenu or infocenter:
function swap(id, slideDirection) {
    var columnsVisible = 0;
    if (jQuery("#leftMenu").is(":visible"))
        columnsVisible++;
    if (jQuery("#rightMenu").is(":visible"))
        columnsVisible++;
    if (jQuery(id).is(":hidden")) {
        columnsVisible++;
        var width = centerWidth - (colWidth * (columnsVisible));
        jQuery(".colCenter").animate({ width: (width) + "%" }, 1, function () {
            showcol(id, slideDirection);
        });
    } else {
        columnsVisible--;
        var width = centerWidth - (colWidth * (columnsVisible));

        jQuery(id).hide("slide", { direction: slideDirection }, 1, function () {
            jQuery(this).width("0px");
            setcenterwidth(width);
        });
    }
}
//helper functions for Slidefunctionality
function setcenterwidth(width) {
    jQuery(".colCenter").animate({ width: (width) + "%" }, 1);
}
function showcol(id, slideDirection) {
    jQuery(id).width(colWidth + "%");
    jQuery(id).show('slide', { direction: slideDirection }, 1);
}

//Venstremenuen med åbne/lukke funktionalitet:
function createLeftMenu() {
    var id = 0;
    var selectedId = 1;
    jQuery(".leftmenu .level1").parent().children().each(function () {

        var level1 = false;
        var val = "" + jQuery(this).attr("class");

        if (val == "level1") {
            id++;
            jQuery(this).attr("tid", "" + id);
            level1 = true;

        }
        else if (val == "level1_selected") {
            id++;
            jQuery(this).attr("tid", "" + id);
            level1 = true;
            selectedId = id;

        }
        else if (val == "level2wrap") {

            jQuery(this).attr("tid", "" + id);

            jQuery(this).hide();

        }

        if (level1) {
            jQuery(this).click(function () {
                var tid = jQuery(this).attr("tid");
                var elem = jQuery(".level2wrap[tid='" + tid + "']");
                if (elem.is(":visible")) {
                    elem.hide();
                }
                else {
                    elem.show();
                }
            });
        }
    });
    jQuery(".level2wrap[tid='" + selectedId + "']").show();
}
var init = false;
var visible = true;
var firstRun = true;
var netto;
var ba;

function initializeJavascript() {
    POandDoInit();
    CreateFakeCheckboxes();
}
function POandDoInit() {
    if (jQuery("input[value=radioProductListPrisOpslag]").length != 0) {
        if (firstRun) {
            netto = jQuery("tr td.netto");
            ba = jQuery("tr td.ba");
            jQuery("input[value=radioProductListNormal]").click(function () {
                if (jQuery(this).attr("checked")) {
                    visible = true;
                    setTimeout("ShowPriceColumns();", 1);
                }
            });

            jQuery("input[value=radioProductListPrisOpslag]").click(function () {
                if (jQuery(this).attr("checked")) {
                    visible = false;
                    setTimeout("HidePriceColumns();", 1);
                }
            });
            if (jQuery("input[value=radioProductListPrisOpslag]").is(":checked")) {
                visible = false;
            }
            var cook = readCookie('poanddo');
            if (cook != null) {
                if (cook == '0')
                    visible = false;
                if (cook == '1')
                    visible = true;
            }
            if (visible) {

                ShowPriceColumns();
            }
            else {

                HidePriceColumns();
            }
            firstRun = false;
            setTimeout("firstRunDone()", 10);
        }
    }

}


function HidePriceColumns() {
    if (netto == null)
        netto = jQuery("tr td.netto");
    if (ba == null)
        ba = jQuery("tr td.ba");
    netto.hide();
    ba.hide();
    jQuery(".basket .level2wrap").hide();
    jQuery('input[value=radioProductListPrisOpslag]').attr('checked', 'checked');
    createCookie('poanddo', '0');
}

function ShowPriceColumns() {

    if (netto == null)
        netto = jQuery("tr td.netto");
    if (ba == null)
        ba = jQuery("tr td.ba");
    jQuery(".basket .level2wrap").show();
    netto.show();
    ba.show();
    jQuery('input[value=radioProductListNormal]').attr('checked', 'checked');

    createCookie('poanddo', '1');
}
function firstRunDone() {
    firstRun = true;
}


function CreateNotePopup() {
    if (jQuery("#WhiteBox").html().trim() != '') {
        jQuery("#WhiteBox").html(jQuery("#WhiteBox").html() + "<div class='closeButton'><a href='#' class='close'>&nbsp;</a></div>");

        var winH = jQuery(window).height();
        var winW = jQuery(window).width();

        //Set the popup window to center
        jQuery("#WhiteBox").css('top', winH / 2 - jQuery("#WhiteBox").height() / 2);
        jQuery("#WhiteBox").css('left', winW / 2 - jQuery("#WhiteBox").width() / 2);
        jQuery("#WhiteBox").fadeIn(500);
        jQuery('#mask').fadeTo(500, 0.5);
        jQuery('#WhiteBox .closeButton').click(function (e) {
            e.preventDefault();
            jQuery("#WhiteBox").hide();
            jQuery('#mask').hide();

        });
    }
    else {
        jQuery("#WhiteBox").hide();
        jQuery('#mask').hide();
    }

}

//
//GOOGLE MAP FUNKTIONALITET::
//
var geocoder;
var map;
var currentPosition;
var currentPitch = 0;
var currentHeading = 0;
var currentZoom = 1;
var EditMode = false;
var mapDivId;
var mooving = false;
function CreateStoreMap() {
    jQuery(document).ready(function () {
        EditMode = IsEditMode();
        IncludeGoogleMapsScript("initializeGoogleMaps");
    });
}
function IncludeGoogleMapsScript(callbackfunction) {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://maps.google.com/maps/api/js?sensor=false&language=da&callback=" + callbackfunction;
    document.body.appendChild(script);
}
function IsEditMode() {
    return !jQuery("input[id$='tbAfdelingsNavn']").is(":disabled");
}

function initGoogleComponents(latLng, divId) {

    mapDivId = divId;
    geocoder = new google.maps.Geocoder();
    var myOptions =
        {
            zoom: 6,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }
    if (latLng != null) {
        myOptions.center = latLng;
    }
    map = new google.maps.Map(document.getElementById(mapDivId), myOptions);
}
function loadCurrentPosition() {

    if (currLong != undefined && currLat != undefined && currLong != "" && currLat != "") {
        currentPosition = new google.maps.LatLng(parseFloat(currLat), parseFloat(currLong));
    }
}
function initializeGoogleMaps() {
    jQuery("#streetView-Button").show();
    jQuery("#streetView-Button").click(function () {
        jQuery(this).hide();
        jQuery("#streetViewBack-Button").show();
        currentPosition = marker.getPosition();
        showStreetView();
        return false;
    });
    jQuery("#streetViewBack-Button").hide();
    jQuery("#streetViewBack-Button").click(function () {
        jQuery(this).hide();
        jQuery("#streetView-Button").show();
        initializeGoogleMaps();
        return false;
    });

    initGoogleComponents(null, "googleMap");
    var myOptions =
        {
            zoom: 14,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            streetViewControl: false
        }
    map.setOptions(myOptions);
    loadCurrentPosition();
    //load værdier fra sitecore, hvis disse er null skal der søges ud på adressen og dette skal så gemmes:
    if (1 == 2) {
        currentPosition = new google.maps.LatLng(parseFloat(0), parseFloat(0));
        currentHeading = 110;
        currentZoom = 1;
        presentStore("", currentPosition);
    }
    else if (currentPosition != null) {
        presentStore("", currentPosition);
    }
    else {
        var address = "";
        address += GetValueFromBoxWithServerSideId("tbAdresse") + " ";
        address += GetValueFromBoxWithServerSideId("tbBy");
        findStore(address);
    }

}
function GetValueFromBoxWithServerSideId(serversideID) {
    return jQuery("[id$='" + serversideID + "']").attr("value");
}

function showStreetView() {
    if (currentPosition != null) {
        SwitchToStreetView(currentPosition);
        jQuery("#gPanorama").html("Panorama: zoom - " + currentZoom + ", Horisontal - " + currentHeading + ", Vertikal - " + currentPitch);

        if (EditMode) {
            google.maps.event.addListener(panorama, "pov_changed", function () {
                if (!mooving) {
                    mooving = true;
                    setTimeout(function () {
                        if (!mooving) {
                            currentZoom = panorama.getPov().zoom;
                            currentHeading = panorama.getPov().heading;
                            currentPitch = panorama.getPov().pitch;
                            jQuery("#gPanorama").html("Panorama: zoom - " + currentZoom + ", Horisontal - " + currentHeading + ", Vertikal - " + currentPitch);
                        }

                    }, 210);
                    setTimeout(function () { mooving = false; }, 200);
                }


            });
            google.maps.event.addListener(panorama, "position_changed", function () {
                currentPosition = panorama.getPosition();
                jQuery("#glatlng").html("position: " + currentPosition.toString());
            });

        }


    }
}

function presentStore(kode, position) {
    if (position != null) {
        currentPosition = position;
        var image = "/~/media/System/google_marker.ashx?mh=18";
        AddMarkerToMap(position, image);
        jQuery("#glatlng").html("position: " + currentPosition.toString());
        google.maps.event.addListener(marker, "drag", function () {
            jQuery("#glatlng").html("position: " + currentPosition.toString());
            currentPosition = marker.getPosition();
            currentPitch = 0;
            currentZoom = 0;
        });
        map.setCenter(position);
        google.maps.event.addListener(marker, 'click', function (e) {
            var image = jQuery("#billede").html().toString();
            image = image.replace("mw=206", "mw=100");
            image = image.substring(image.indexOf("src"));
            image = image.substring(0, image.indexOf("\"", 6) + 1);
            var butiksnavn = GetValueFromBoxWithServerSideId("tbAfdelingsNavn");
            var content = "<div class=\"google-infobox\">" + butiksnavn + " <div class='googlestore-image'><img " + image + " /></div> </div>";
            var infowindow = new google.maps.InfoWindow({ content: "", maxWidth: 180 });
            infowindow.setContent(content);
            infowindow.setPosition(position);
            infowindow.open(map, marker);
        });
    }
}

function findStore(address) {
    GoogleLookupAddress(address, "", presentStore);
}
function AddMarkerToMap(position, image) {
    marker = new google.maps.Marker(
        {
            position: position,
            map: map,
            icon: image,
            draggable: EditMode
        }
    );
}
function SwitchToStreetView(position) {

    panoramaOptions = {
        addressControl: true,
        addressControlOptions: {
            style: { backgroundColor: 'grey', color: 'yellow' }
        },
        position: position,
        pov: {
            heading: currentHeading,
            pitch: currentPitch,
            zoom: currentZoom
        }
    };

    panorama = new google.maps.StreetViewPanorama(document.getElementById(mapDivId), panoramaOptions);
    map.setStreetView(panorama);

}
function GoogleLookupAddress(address, kode, callback) {

    geocoder.geocode({ 'address': address }, function (results, status) {

        if (status == google.maps.GeocoderStatus.OK) {
            var lat = results[0].geometry.location.lat();
            var lng = results[0].geometry.location.lng();
            callback(kode, new google.maps.LatLng(parseFloat(lat), parseFloat(lng)));
        }
    });
}
//
//GOOGLE MAP FUNKTIONALITET SLUT
//

//SmartNavigation:
function ActivateSmartScroll() {
    var x = jQuery("[id$='scrollX']").val();
    var y = jQuery("[id$='scrollY']").val();
    scrollTo(x, y);
}
function SaveScroll() {
    var scrollX, scrollY;
    if (document.all) {
        if (!document.documentElement.scrollLeft)
            scrollX = document.body.scrollLeft;
        else
            scrollX = document.documentElement.scrollLeft;

        if (!document.documentElement.scrollTop)
            scrollY = document.body.scrollTop;
        else
            scrollY = document.documentElement.scrollTop;
    }
    else {
        scrollX = window.pageXOffset;
        scrollY = window.pageYOffset;
    }
    if (scrollX != undefined && scrollX > 0) {
        jQuery("[id$='scrollX']").val(scrollX);
    }
    if (scrollY != undefined && scrollY > 0) {
        jQuery("[id$='scrollY']").val(scrollY);
    }
}
function ActivateSmartScrollListener() {
    jQuery(window).keypress(SaveScroll);
    jQuery(window).scroll(SaveScroll);
}
//SmartNavigation end

/* Hjælpe funktioner der kan udføre
forskellige opgaver */

function createCookie(name, value) {
    createCookie(name, value, undefined);
}
function createCookie(name, value, days) {
    var expires = "";
    if (days) {
        var date = new Date();
        date.setDate(date.getDate() + days);
        expires = "; expires=" + date.toGMTString();
    }
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
function eraseCookie(name) {
    createCookie(name, "", -1);
}
function getQueryString(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}
function getCliensideId(serversideid) {
    return jQuery("[id$=" + serversideid + "]").attr("id");
}
function showHideControl(control) {

    var elem = jQuery("#" + getCliensideId(control));
    if (elem.is(":visible")) {
        elem.hide();
    }
    else {
        elem.show();
    }
}
function SetClearFunction(serversideid) {
    jQuery(document).ready(function () {
        var jqueryObj = jQuery("input[id $='" + serversideid + "']");
        var stdValue = jqueryObj.val();
        jqueryObj.blur(function () {
            resetTextBox(jqueryObj, stdValue);
        });
        jqueryObj.focus(function () {
            clearTextBox(jqueryObj, stdValue);
        });
    });
}
function clearTextBox(obj, defaulttext) {
    if (obj.val() == defaulttext)
        obj.val("");
}
function resetTextBox(obj, defaulttext) {
    if (obj.val() == "")
        obj.val(defaulttext);
}
function ValidateDokumentName(source, args) {
    if (IsDokument(args.Value))
        args.IsValid = true;
    else
        args.IsValid = false;
}

function IsDokument(string) {
    var result = true;
    if (string != undefined && string != "") {
        result = false;
        if (string.match(".(doc|docx|pdf)" + "$"))
            result = true;
    }
    return result;
}
function PresentFileUploadName(input) {
    if (input.indexOf("fakepath\\") != -1) {
        input = input.substring(input.indexOf("fakepath\\") + 9, input.length);
    }
    return "..\\" + input;
}
/* SLUT PÅ HJÆLPE FUNKTIONER */

/* FRONTEND FUNKTIONER */

/* BLOG: */
function generateDropDown() {
    jQuery(document).ready(function () {
        jQuery(".amount .wrap-item .value, .amount .wrap-item .arrow, .filtering .wrap-item .value, .filtering .wrap-item .arrow").each(function () {
            if (jQuery(this).parent().attr("href") == '#') {
                jQuery(this).parent().click(function () {
                    jQuery(document).click(function (e) {
                        if (e.button == 0) {
                            jQuery(".drop-values").hide();
                        }
                    });
                    jQuery(".drop-values").hide();
                    jQuery(this).parent().find(".drop-values").show();
                    return false;
                });
            }
        });
    });
}
function showHideSkrivKommentar(kommentarControl, imageControl) {
    var kommentar = jQuery('#' + kommentarControl);
    var billede = jQuery('#' + imageControl);

    if (kommentar.css('display') == 'none') {
        kommentar.css('display', 'table');
        billede.removeClass("plus");
        billede.addClass("minus");
    } else {
        kommentar.css('display', 'none');
        billede.removeClass("minus");
        billede.addClass("plus");
    }
}
function nulstilSkrivKommentarBoks(kommentarControl, imageControl, controlToClear1, controlToClear2, controlToClear3) {

    jQuery('#' + imageControl).removeClass("minus");
    jQuery('#' + imageControl).addClass("plus");
    jQuery('#' + kommentarControl).css('display', 'none');

    jQuery('#' + getCliensideId(controlToClear1)).val("");
    jQuery('#' + getCliensideId(controlToClear2)).val("");
    jQuery('#' + getCliensideId(controlToClear3)).val("");
}
/* BLOGEND */
//Carousel Start:
var CurrentIndex = 0;
var selectedClass = "bg-color-1";
var FrameDuration = 0;
var RotatorHasQuickLinks = false;
var LastContainer;
var Rotator;
var first = true;
function InitCarousel(rotator, hasQuickLinks, AutoRotation) {
    RotatorHasQuickLinks = hasQuickLinks;
    if (RotatorHasQuickLinks) {
        var strings = new Array("");
        var count = rotator.get_items().length;
        for (var i = 0; i < count; i++) {
            if (i == 0)
                strings.push("<a href=\"#\" class=" + i + "><span class=\"spotbutton " + selectedClass + "\">&shy;</span></a>");
            else
                strings.push("<a href=\"#\" class=" + i + "><span class=\"spotbutton\">&shy;</span></a>");

        }
        jQuery(".wrap-spotbuttons").prepend(strings.join(""));
        jQuery(".wrap-spotbuttons").find("a").each(function () {
            if (jQuery(this).hasClass("controlButton")) {
                jQuery(this).click(function () {
                    stopRotator(rotator);
                });
            }
            else {
                jQuery(this).click(function () {
                    stopRotator(rotator);
                    CarouselItemShowing(null, null);
                    CarouselItemShown(null, null);
                    CurrentIndex = parseInt(jQuery(this).attr("class"));
                    rotator.set_currentItemIndex(CurrentIndex);
                    SetActiveQuickLink();
                    setArrows(rotator);
                });
            }
        });
    }
    FrameDuration = rotator.get_frameDuration();

    if (AutoRotation) {
        startRotator(rotator, Telerik.Web.UI.RotatorScrollDirection.Left);
    }
    else
        stopRotator(rotator);
    jQuery("#PreviousArrow").click(function (e) { e.preventDefault(); stopRotator(rotator); showNextItem(rotator, Telerik.Web.UI.RotatorScrollDirection.Right); });
    jQuery("#NextArrow").click(function (e) { e.preventDefault(); stopRotator(rotator); showNextItem(rotator, Telerik.Web.UI.RotatorScrollDirection.Left); });
}
function CarouselItemShowing(sender, args) {
    if (sender != null) {
        LastContainer = jQuery("#" + sender.get_id() + "_i" + args.get_item().get_index()).find("iframe");
    } else
        LastContainer = jQuery(".rrItem").find("iframe");
}

function CarouselItemShown(sender, args) {
    if (LastContainer) {
        if (LastContainer.length > 1) {
            LastContainer.each(function () {
                var src = jQuery(this).attr("src");
                jQuery(this).attr("src", src);
            });
        }
        else {
            var src = LastContainer.attr("src");
            LastContainer.attr("src", src);
            LastContainer = undefined;
        }
    }
}

function setArrows(rotator) {
    if (!rotator.get_wrapFrames()) {
        if (rotator.get_items().length - 1 == CurrentIndex) {
            jQuery("#NextArrow").hide();
            if (rotator.autoIntervalID) {
                stopRotator(rotator);
                startRotator(rotator, Telerik.Web.UI.RotatorScrollDirection.Right);
            }
        }
        else {
                jQuery("#NextArrow").show();
        }
        if (CurrentIndex == 0) {
            jQuery("#PreviousArrow").hide();
            if (rotator.autoIntervalID && !first) {
                stopRotator(rotator);
                startRotator(rotator, Telerik.Web.UI.RotatorScrollDirection.Left);
            }
        }
        else {
            jQuery("#PreviousArrow").show();
        }
        first = false;
    }
}
function SetActiveQuickLink() {
    if (RotatorHasQuickLinks)
        jQuery(".wrap-spotbuttons").find("a[class!='controlButton']").each(function () {
            jQuery(this).find("span").removeClass(selectedClass);
        });
    jQuery(".wrap-spotbuttons").find("a[class='" + CurrentIndex + "']").find("span").addClass(selectedClass);
}
function startRotator(rotator, direction) {

    if (!rotator.autoIntervalID) {
        rotator.autoIntervalID = window.setInterval(function () {
            showNextItem(rotator, direction);
        }, FrameDuration);

    }
    if (RotatorHasQuickLinks) {
        var span = jQuery(".wrap-spotbuttons").find("a[class='controlButton']").find("span");
        span.removeClass("play");
        span.addClass("pause");
        span.parent().click(function () { stopRotator(rotator); });
    }
}

function stopRotator(rotator) {
    if (rotator.autoIntervalID) {
        window.clearInterval(rotator.autoIntervalID);
        rotator.autoIntervalID = null;
    }
    if (RotatorHasQuickLinks) {
        var span = jQuery(".wrap-spotbuttons").find("a[class='controlButton']").find("span");
        span.removeClass("pause");
        span.addClass("play");
        span.parent().click(function () { startRotator(rotator, Telerik.Web.UI.RotatorScrollDirection.Left); });
    }
}
function showNextItem(rotator, direction) {
    CalcNextIndex(rotator, direction);
    if (RotatorHasQuickLinks) {
        SetActiveQuickLink();
    }
    setArrows(rotator);
    rotator.showNext(direction);
}

function CalcNextIndex(rotator, direction) {
    var items = rotator.get_items();
    if (direction == Telerik.Web.UI.RotatorScrollDirection.Left) {
        CurrentIndex++;
        if (CurrentIndex > items.length - 1)
            CurrentIndex = 0;
    } else {
        CurrentIndex--;
        if (CurrentIndex < 0)
            CurrentIndex = items.length - 1;
    }
}

//Carousel slut

//Pageditor FIX til checkbox:
function ChangeSitecoreValue(checkbox, itemURI, revision) {
    var selectedValue = '0';
    if (checkbox.checked)
        selectedValue = '1';
    setTimeout("setCheckbox('" + checkbox.id + "'," + checkbox.checked + ");", 100);
    Sitecore.WebEdit.setFieldValue(itemURI, revision, selectedValue);
}
function setCheckbox(checkboxid, selected) {
    document.getElementById(checkboxid).checked = selected;
}
