﻿/* ===================================================================================================================*/
/* billywig player */
var openPlayerID = "";
var isCarrouselPlayer = "";

function openPlayer(id) {

    // remember me
    openPlayerID = id;

    // hide all slides
    $("#slides").hide();
    // show player
    $("#play_" + id).show();
}

function openCarrouselPlayer(id) {

    // remember me
    openPlayerID = id;
    isCarrouselPlayer = 1;

    // hide all slides
    $("#slides").hide();
    
    // show player
    $("#play_" + id).show();
}

function closePlayer() {

    // hide player
    $("#play_" + openPlayerID).hide();

    // show slides
    $("#slides").show();

    // reset player
    isCarrouselPlayer = "";
    openPlayerID = "";
}

/* ===================================================================================================================*/
/* mediacarrousel */
function showSlide(slide) {
    if (isCarrouselPlayer == "") {
        // show correct slide
        $("#slides div.slide").hide();
        $("#slides div.slide" + slide).show();

        // select button
        $("#buttons li").removeAttr("id");
        $("#buttons .jcarousel-item-" + slide).attr("id", "button_selected");
    }
}

function slideToSelectedButton(page) {
    if (carrouselPage > page) {
        $(".jcarousel-prev").click();
    }
    else if (carrouselPage < page) {
        $(".jcarousel-next").click();
    }
    if (carrouselPage != page) {
        setTimeout(function() { slideToSelectedButton(page); }, 425);
    }
}

/* ===================================================================================================================*/
/* Mailto function */
function insertMailToTag(domainName, userName) {
    var emailId;
    var atSign = "&#64;"

    emailId = userName;
    emailId = "" + emailId + atSign;
    emailId = emailId + domainName;

    document.write("<a href='mail" + "to:" + emailId + "'>" + emailId + "</a>");
}

/* ===================================================================================================================*/
/* subnavigation */
function showSubnav(menu) {
    if (typeof (hideSubnavTimeout) != "undefined") {
        clearTimeout(hideSubnavTimeout);
    }
    $("." + menu + "menu").show();
}

function hideSubnav(menu) {
    hideSubnavTimeout = setTimeout(function() { $(".subnav").hide(); }, 500);
}

/* FOOTER LOGOLOOP 
=============================================*/
data = new Array();  // your images
data[0] = new Array("/sites/shared/images/sponsors/nrc-handelsblad.gif", "http://www.nrc.nl", "NRC");
data[1] = new Array("/sites/shared/images/sponsors/de_krakeling.gif", "http://krakeling.cramgo.net/", "Jeugdtheater De Krakeling");
data[2] = new Array("/sites/shared/images/sponsors/doen.gif", "http://www.doen.nl", "Stichting DOEN");
data[3] = new Array("/sites/shared/images/sponsors/sns-reaal-fonds.gif", "http://www.snsreaalfonds.nl", "SNS Reaal Fonds");
data[4] = new Array("/sites/shared/images/sponsors/podiumkunsten.gif", "http://www.nfpk.nl", "Nederlands Fonds voor Podiumkunsten");
data[5] = new Array("/sites/shared/images/sponsors/gemeente-amsterdam.gif", "http://www.amsterdam.nl", "Gemeente Amsterdam");
data[6] = new Array("/sites/shared/images/sponsors/dioraphte.gif", "", "Stichting Dioraphte");
data[7] = new Array("/sites/shared/images/sponsors/prins-bernhard-cultuurfonds.gif", "http://www.prinsbernhardcultuurfonds.nl", "Prins Bernhard Cultuurfonds");
data[8] = new Array("/sites/shared/images/sponsors/vsb-fonds.gif", "http://www.vsbfonds.nl", "VSBfonds");
data[9] = new Array("/sites/shared/images/sponsors/fonds-voor-de-kunst.gif", "http://www.amsterdamsfondsvoordekunst.nl", "Amsterdams Fonds voor de Kunst");
data[10] = new Array("/sites/shared/images/sponsors/time-out-amsterdam.gif", "http://www.timeoutamsterdam.nl", "Time Out Amsterdam");
data[11] = new Array("/sites/shared/images/sponsors/atelier-van-gog.gif", "http://www.ateliervangog.nl", "Atelier van GOG");
data[12] = new Array("/sites/shared/images/sponsors/ssba_lang.gif", "http://www.ssba.nl", "Stadsschouwburg Amsterdam");
data[13] = new Array("/sites/shared/images/sponsors/TIN_logo.gif", "http://www.theaterinstituut.nl", "Theater Instituut Nederland");
data[14] = new Array("/sites/shared/images/sponsors/bpp_beelmerk_pc.gif", "http://www.promotiepodiumkunsten.nl", "Bureau Promotie Podiumkunsten");
data[15] = new Array("/sites/shared/images/sponsors/HF-tekengrid9.gif", "http://www.hollandfestival.nl", "Holland Festival");
data[16] = new Array("/sites/shared/images/sponsors/NAPK.gif", "http://www.napk.nl", "Nederlandse Associatie voor PodiumKunsten");
data[17] = new Array("/sites/shared/images/sponsors/amsterdam_festivals.gif", "http://www.amsterdamfestivals.nl", "Amsterdam Festivals");

img_places = 4;  // number of images visible
img_width = 144;  // width of the images
img_height = 64;  // height of the images
img_spacer = 48;  // space between the images
rdm_img = 1;  // 0 = no  1 = yes  show images at random

border = 0;  // container border width
bordertype = "ridge";  // container border type
bordercolor = "#afa684";  // container border colour
borderbackground = "#ffffff";  // container background colour

css_positioning = 0;  // use CSS to position the display 0 = no  1 = yes
css_left = 400;  // used if css_positioning is selected
css_top = 100;  // used if css_positioning is selected

reuse_window = 1;  // 0 = use same window for links, 1 = use new window for links

// ********** End User Defining Area **********


if (rdm_img == 1) { // generate random images list

    temp_array = new Array();
    for (i = 0; i < data.length; i++) { // create temp array identical to data array
        temp_array[i] = data[i];
    }

    rdm_array = new Array();  // random images list
    for (p = 0; p < data.length; p++) {
        rndnum = Math.floor(Math.random() * (temp_array.length));  // select a random image from temp_array
        rdm_array[p] = temp_array[rndnum];  // put selected image in rdm_array
        temp_array.splice(rndnum, 1);  // remove selected image from temp_array
    }

}

step = 1;
nextpic = 0;
speed = 10;
next_right = "";
initpos = new Array();
nowdivpos = new Array();
moz = document.getElementById && !document.all;

function create_thumbshow() {

    if (css_positioning == 0) {
        document.write("<div id=\"container\" style=\"position:relative; width:0px;height:0px; border:" + border + "px " + bordertype + " " + bordercolor + ";background:" + borderbackground + "\">");
    }
    else {
        document.write("<div id=\"container\" style=\"position:absolute; left:" + css_left + "px; top:" + css_top + "px; width:0px;height:0px; border:" + border + " " + bordertype + " " + bordercolor + ";background:" + borderbackground + "\">");
    }

    document.write("<div id=\"display_area\" style=\"position:absolute; left:0; top:0; width:0px; height:0px; clip:rect(0 0 0 0);\" onmouseover=\"stopme()\" onmouseout=\"animate()\">");

    for (i = 0; i < img_places + 1; i++) { // create image holders
        document.write("<div id=\"div_" + [i] + "\" style=\"position:absolute\">");
        if (this.location != '') {
            document.write("<a id=\"loc_" + [i] + "\" href=\"\" onclick=\"newwin(this.location);return false\">");
            document.write("<img src=\"\" id=\"pic_" + [i] + "\" width=\"" + img_width + "\" height=\"" + img_height + "\" alt=\"Multiple Image SlideShow\" border=\"0\">");
            document.write("</a>");
        }
        else {
            document.write("<img src=\"\" id=\"pic_" + [i] + "\" width=\"" + img_width + "\" height=\"" + img_height + "\" alt=\"Multiple Image SlideShow\" border=\"0\">");
        }
        document.write("</div>");
    }
    document.write("</div>");
    document.write("</div>");
}

function init_thumbshow() {
    container_border = parseInt(document.getElementById("container").style.borderWidth) * 2;
    container_width = ((img_places) * img_width) + ((img_places - 1) * img_spacer);
    document.getElementById("container").style.width = container_width + (!moz ? container_border : "") + "px";
    document.getElementById("container").style.height = img_height + (!moz ? container_border : "") + "px";

    displayarea = document.getElementById("display_area");
    displayarea.style.width = container_width + "px";
    displayarea.style.height = img_height + "px";
    displayarea.style.clip = (!moz ? "rect(0 " + container_width + "px " + img_height + "px 0)" : "rect(0 " + container_width + "px " + img_height + "px 0)");

    img_pos = -document.getElementById("pic_0").width - border;

    for (i = 0; i < img_places + 1; i++) {
        img_pos += (document.getElementById("pic_0").width) + img_spacer;
        initpos[i] = img_pos;
        document.getElementById("div_" + [i]).style.left = initpos[i] + "px";

        if (nextpic == data.length) {
            nextpic = 0;
        }

        if (rdm_img == 1) {
            document.getElementById("loc_" + [i]).location = rdm_array[nextpic][1];
            document.getElementById("pic_" + [i]).src = rdm_array[nextpic][0];
            document.getElementById("pic_" + [i]).alt = rdm_array[nextpic][2];
        }
        else {
            document.getElementById("loc_" + [i]).location = data[nextpic][1];
            document.getElementById("pic_" + [i]).src = data[nextpic][0];
            document.getElementById("pic_" + [i]).alt = data[nextpic][2];
        }
        nextpic++;
    }

    animate();
}

var next_right = "";
function animate() {
    clearTimeout(next_right);
    for (i = 0; i < img_places + 1; i++) {
        nowdivpos[i] = parseInt(document.getElementById("div_" + i).style.left);
        nowdivpos[i] -= step;

        if (nowdivpos[i] <= -(document.getElementById("pic_0").width + img_spacer)) {
            document.getElementById("div_" + [i]).style.left = parseInt(container_width + img_spacer) + "px";

            if (nextpic > data.length - 1) {
                nextpic = 0;
            }

            if (rdm_img == 1) {
                document.getElementById("loc_" + [i]).location = rdm_array[nextpic][1];
                document.getElementById("pic_" + [i]).src = rdm_array[nextpic][0];
                document.getElementById("pic_" + [i]).alt = rdm_array[nextpic][2];
            }
            else {
                document.getElementById("loc_" + [i]).location = data[nextpic][1];
                document.getElementById("pic_" + [i]).src = data[nextpic][0];
                document.getElementById("pic_" + [i]).alt = data[nextpic][2];
            }

            nextpic++;

        }
        else {
            document.getElementById("div_" + [i]).style.left = nowdivpos[i] + "px";
        }

    }
    next_right = setTimeout("animate()", speed);

}

function stopme() {
    clearTimeout(next_right);
}

function newwin(loc) {
    if (loc == "") {return; }
    if (reuse_window == 0) {
        location = loc;
    }
    else {
        //window.open(loc)
        window.open(loc, '', 'left=100,top=50,width=800,height=600,menubar=1,resizable=1,status=1,toolbar=1,resizable=1,location=1');  // use for specific size and positioned window
    }
}

// only in site, not in popup-windows
$(document).ready(function() {
    if (document.getElementById("display_area")) {
        setTimeout(function() { init_thumbshow(); }, 5000);
    }
});

/* ICONBAR
=============================================*/
function showIcons(panelID) {
    document.getElementById(panelID).style.display = '';
}
function hideIcons(panelID) {
    document.getElementById(panelID).style.display = 'none';
}