﻿

function initialiseBanner(crew) {

    var baseUrl = getBaseURL();

    swfobject.embedSWF(baseUrl + "flash/rotator.swf", "media-flash", "274", "251", "9.0.0", "/flash/expressInstall.swf", {
    loc: crew == false ? (baseUrl + "feeds/media.ashx/default") : (baseUrl + "feeds/media.ashx/default/crew")
    }
    , {
        quality: "high",
        play: "true",
        loop: "false",
        scale: "noscale",
        wmode: "transparent",
        devicefont: "false",
        menu: "true",
        allowfullscreen: "true",
        allowscriptaccess: "always",
        salign: "lt"
    }, {});

    if(crew)
        $("#BannerImage").attr("src", baseUrl + "content/images/crew.jpg");
    else
        $("#BannerImage").attr("src", baseUrl + "content/images/home.jpg");
}

function getBaseURL() {
    var url = location.href;  // entire url including querystring - also: window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 14));


    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);

        return baseLocalUrl + "/";
    }
    else {
        // Root Url for domain name
        return baseURL + "/";
    }
}