﻿// <summary>
// global company name variable used for determining which item in the dropdown list to select
// and also displays the company name next to Vitec logo
// global browswer variable used to determine the user browser for use in IF statements to
// select browswers appropriate code syntax.
// </summary>
var companyName = "";
var browser = navigator.appName;


// <author>Javed Wahid</author>
// <created>2010-02-09</created>
// <summary>
// Main function that builds all elements of the endorsement strip and returns it
// This function calls all the other functions to create each element and appends
// them all to a div container which is returned to the calling page
// </summary>
function ESLoad(company) {
    // set companyName (global variable)
    companyName = String(company);

    // every page that calls this function needs to have a div tag at the top called 'esDiv1'
    var f = document.getElementById("esDiv1");
    // create main strip container
    var GroupEndorsementStripContainer = document.createElement("DIV");
    // create strip container
    var GroupEndorsementStrip = document.createElement("DIV");
    var img = new Image;
    img.src = "http://www.bexel.com/media/endorsement_bg.gif";

    // assign css properties to main container
    GroupEndorsementStripContainer.style.width = "1024px";
    GroupEndorsementStripContainer.style.backgroundColor = "#535353";
    
    // set strip id
    GroupEndorsementStrip.id = "GroupEndorsementStrip";
    //GroupEndorsementStrip.style.backgroundImage.src = img;
    //GroupEndorsementStrip.style.backgroundRepeat = "repeat-y";
    GroupEndorsementStrip.style.backgroundColor = "#535353";

    // assign css properties
    GroupEndorsementStrip.style.width = "1024px";
    GroupEndorsementStrip.style.height = "36px";
    GroupEndorsementStrip.style.margin = "0 auto";
    

    // append all objects to endorsement strip
    GroupEndorsementStrip.appendChild(createImage());
    GroupEndorsementStrip.appendChild(createParagraph());
    GroupEndorsementStrip.appendChild(createESGroupNavMenu());

    // append strip to main container
    GroupEndorsementStripContainer.appendChild(GroupEndorsementStrip);
    // append container to document level div tag
    // this tag has to be placed on the webpage of every site that is calling this javascript functino
    f.appendChild(GroupEndorsementStripContainer);

    return false;
}

// <author>Javed Wahid</author>
// <created>2010-02-09</created>
// <summary>
// Create Image object/tag
// </summary>
function createImage() {
    // create image object
    var img = new Image;
    // set img src
    img.src = "http://vitecestrip.nhak.com/Endorsement_strip_logo.png";
    // assign css properties
    img.style.width = 33;
    img.style.height = 32;
    img.style.marginLeft = "30px";
    img.style.marginTop = "2px";
    if (browser == "Microsoft Internet Explorer")
        img.style.styleFloat = "left";
    else 
        img.style.cssFloat = "left";
    
    return img;
}

// <author>Javed Wahid</author>
// <created>2010-02-09</created>
// <summary>
// Create paragraph tag and text
// </summary>
function createParagraph() {
    // create paragraph object
    var para = document.createElement("P");
    // set innerHTML
    para.innerHTML = companyName + "<br />A Vitec Group brand";
    // assign css properties
    para.style.fontFamily = "arial";
    para.style.color = "#FFFFFF";
    para.style.fontSize = "11px";
    para.style.lineHeight = "13px";
    para.style.margin = "5px 0 0 5px";
    para.style.textAlign = "left";
    if (browser == "Microsoft Internet Explorer") 
        para.style.styleFloat = "left";
    else 
        para.style.cssFloat = "left";

    return para;
}

// <author>Javed Wahid</author>
// <created>2010-03-17</created>
// <summary>
// Receives a url and redirects to that url
// </summary>
function redirectTo(url) {
    if (url != '') {
        window.location = url;
    }
}

// <author>Javed Wahid</author>
// <created>2010-02-09</created>
// <summary>
// Create Div tag and dropdown list
// </summary>
function createESGroupNavMenu() {
    // create div object
    var ESGroupNavMenu = document.createElement("DIV");
    // create dropdown object
    var sel = "";

    // assign css properties to div
    ESGroupNavMenu.style.marginRight = "20px";
    ESGroupNavMenu.style.marginTop = "7px";
    ESGroupNavMenu.style.padding = "0px";
    if (browser == "Microsoft Internet Explorer") {
        ESGroupNavMenu.style.styleFloat = "right";
    }
    else {
        ESGroupNavMenu.style.cssFloat = "right";
    }
    // create opening select tag
    sel = "<select name='ESGroupNavMenu' size='1' onchange='redirectTo(this.value);'>";

    // add all dropdown options
    sel += addOption(sel, 'Vitec Group websites', "");
    sel += addOption(sel, 'The Vitec Group', 'http://www.vitecgroup.com');

    sel += addOption(sel, "---------------------", "");
    sel += addOption(sel, 'Imaging &amp; Staging Division', 'http://www.vitecgroup.com/group/photographic.aspx');
    sel += addOption(sel, "Avenger &trade;", "http://www.avenger-grip.com/");
    sel += addOption(sel, "Brilliant Stages", "http://www.brilliantstages.com/");
    sel += addOption(sel, "Gitzo &trade;", "http://www.gitzo.com/");
    sel += addOption(sel, "Kata &trade;", "http://www.kata-bags.com/");
    sel += addOption(sel, "Litec &trade;", "http://www.litectruss.com/");
    sel += addOption(sel, "Manfrotto &trade;", "http://www.manfrotto.com/");
    sel += addOption(sel, "Manfrotto Distribution", "http://www.manfrottodistribution.com/");
    sel += addOption(sel, "National Geographic &trade;(manufactured &amp; distributed under licence)", "http://www.supporthexperience.com");
    sel += addOption(sel, "Tomcat", "http://www.tomcatglobal.com/");

    sel += addOption(sel, "---------------------", "");
    sel += addOption(sel, "Videocom Division", "http://www.vitecgroup.com/group/broadcast_systems.aspx");
    sel += addOption(sel, "Anton/Bauer", "http://www.antonbauer.com/");
    sel += addOption(sel, "Autoscript", "http://www.autoscript.tv/");
    sel += addOption(sel, "The Camera Store", "http://www.thecamerastore.co.uk/");
    sel += addOption(sel, "Litepanels", "http://www.litepanels.com/");
    sel += addOption(sel, "Microwave Service Company", "http://www.microwaveservice.com/");
    sel += addOption(sel, "Nucomm", "http://www.nucomm.com/");
    sel += addOption(sel, "OConnor", "http://www.ocon.com/");
    sel += addOption(sel, "Petrol Bags", "http://www.petrolbags.com/");
    sel += addOption(sel, "RF Central", "http://www.rfcentral.com/");
    sel += addOption(sel, "Sachtler &trade;", "http://www.sachtler.com/");
    sel += addOption(sel, "Vinten &trade;", "http://www.vinten.com/");
    sel += addOption(sel, "Vinten Radamec", "http://www.vintenradamec.com/");

    sel += addOption(sel, "---------------------", "");
    sel += addOption(sel, "Services Division", "http://www.vitecgroup.com/group/broadcast_services.aspx");
    sel += addOption(sel, "Bexel", "http://www.bexel.com/");
    sel += "</select>";

    // add dropdown list code to the div tag
    ESGroupNavMenu.innerHTML = sel;

    return ESGroupNavMenu;
}

// <author>Javed Wahid</author>
// <created>2010-02-09</created>
// <summary>
// Add option to dropdown
// </summary>
function addOption(selectbox, text, value) {
    var opt = "";
    var cName = companyName;
    // create opening option tag
    opt = "<option value='" + value;
    if (companyName == text) {
        // find company and mark selected
        opt += " selected='selected'";
    }
    // add closing tag
    opt += "'>" + text + "</option>";

    return opt;
}

