﻿// replaces the hard-coded classes in the menucontrol
if (typeof (WPSC) == "undefined") {
    WPSC = new Object();
    WPSC.Init = function() {
        //do nothing
    }
    WPSC.WebPartPage = new Object();
    WPSC.WebPartPage.Parts = new Object();
    WPSC.WebPartPage.Parts.Register = function() {
        //do nothing
    }
}


$(document).ready(function() {

    //hide the first listitem of the first level
    $("#box-menu li:first").css("visibility", "hidden");
    //add cssclass to the first visible (thus second) listitem on the first level
    $("#box-menu li").eq(1).addClass("first");

    $("#box-menu ul ul li:first-child").addClass("first");
    $('#box-menu li:last-child').addClass('last');

    $("#display-tools1 li:first-child").addClass("first");
    $('#display-tools1 li:last-child').addClass('last');
    
    
    

    $("#display-tools2 li:first-child").addClass("first");
    $('#display-tools2 li:last-child').addClass('last');

    
});

//script for fetching background images from webservice

var backgrounds = new Array();

//set default value in case the webservice call is unsuccessful
backgrounds[0] = '/SiteCollectionImages/background-default.jpg';

//url is composed in FusionMasterPage
if (typeof backgroundImageServiceUrl != 'undefined' && page != 'popup') {
    GetBackgroundImagesFromService(backgroundImageServiceUrl);
}

function GetBackgroundImagesFromService(backgroundImageServiceUrl) {
    // webservice request to get the backgroundimages
    $.ajax({
        url: backgroundImageServiceUrl,
        dataType: 'json',
        async: false,
        success: SetBackgrounds
    });
}

function SetBackgrounds(data) {
    if (data && data.toString().length > 0) {
        backgrounds = [];
        backgrounds = data;
    }
}

