function loadWimpyGutterVideoScreen(movieNm, thumbnailImgNm) {
	crossobj= document.getElementById("gutterVideoScreen");
	crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="180" height="165" id="wasp89164" name="wasp89164" align="middle"> <param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="../media_players/wasp.swf?theFile='+movieNm+'&defaultImage='+thumbnailImgNm+'&startPlayingOnload=yes" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="noscale" /><param name="salign" value="lt" /><param name="bgcolor" value="#000000" /><embed src="../media_players/wasp.swf?theFile='+movieNm+'&defaultImage='+thumbnailImgNm+'&startPlayingOnload=yes" loop="false" menu="false" quality="high" scale="noscale" salign="lt" width="180" height="165" name="wasp89164" align="middle" bgcolor="#000000" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	return false;
}

function loadVaultJW5Item(movieNm, thumbnailImgNm, elementNm, width, height, autoplay, closedCaptionFlNm, descriptiveAudioFlNm, autoStartCC, lang, base) {
    var players = "";
    var requiredPlugins = "";
    var useHTML5 = false;

    var enableHTML5Chrome = false;

    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
        useHTML5 = true;
    }

    if (enableHTML5Chrome) {
        if ((navigator.userAgent.match(/Chrome/i))) {
            useHTML5 = true;
        }
    }
    var autoPlayCC = "false";
    if (closedCaptionFlNm != "") {
        if (autoStartCC == 1) {
            autoPlayCC = "true";
        }
        requiredPlugins = "captions";
    }
    if (descriptiveAudioFlNm != "") {
        if (requiredPlugins != "") requiredPlugins += ", ";
        requiredPlugins += "audiodescription";
    }
    if (requiredPlugins != "") requiredPlugins += ", ";
    requiredPlugins += "gapro-2";
    var shareTitle = "Share this video";
    var embedtitle = "Embed this video";
    var replay = "Play Again?";
    var shareLink = base + movieNm;
    shareLink = shareLink.replace("\.\.\/", "");
    movieNm = movieNm.replace("\.\.", "");
    if (lang == "f") {
        shareTitle = "Partager cette vidéo";
        embedtitle = "Intégrer cette video";
        replay = "Jouez encore?";
    }
    var innerVidId = 'innerVid_' + elementNm;
    document.getElementById("vidContainer_" + elementNm).innerHTML = "<div id='" + innerVidId + "'></div>";
    jwplayer(innerVidId).setup({
        file: movieNm,
        image: thumbnailImgNm,
        height: height,
        width: width,
        autostart: autoplay,
        controlbar: "bottom",
        "captions.file": closedCaptionFlNm,
        "captions.state": autoPlayCC,
        "audiodescription.file": descriptiveAudioFlNm,
        "audiodescription.state": "false",
        "gapro.trackingobject": "pageTracker",
        "plugins": requiredPlugins,
        "pcoshare.sharetitle": shareTitle,
        "pcoshare.embedtitle": embedtitle,
        "pcoshare.replay": replay,
        lang: lang,
        "pcoshare.link": shareLink,
        path_to_player: "/media_players/JW/player.swf",
        path_to_plugins: "plugins",
        base: base,
        dock: "false",
        stretching: "fill",
        players: [
                 { type: "flash", src: "/media_players/JW/player.swf", config: { file: movieNm} },
                 { type: "html5", config: { file: movieNm} },
                 { type: "download", config: { file: movieNm} }
            ],
        modes: [
                 { type: "flash", src: "/media_players/JW/player.swf", config: { file: movieNm} },
                 { type: "html5", config: { file: movieNm} },
                 { type: "download", config: { file: movieNm} }
            ]
    });
}

function old__loadVideoPlayer(movieNm, thumbnailImgNm, elementNm, width, height, autoplay) {
	crossobj= document.getElementById(elementNm);
	//only use html5 video tag if we are on an Apple product	
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)))
    {   
        
        //if video tag doesnt exist, add it top the dom
        var videoTagArray = document.getElementsByTagName("video");
        
        if (videoTagArray.length == 0){
            //add a video tag surrounding the object tag for HTML5 usage
            var videoTag = document.createElement('video');
            videoTag.setAttribute('id', 'html5player');
            videoTag.setAttribute('src', movieNm);
            videoTag.setAttribute('width', width);
            videoTag.setAttribute('height', height);
            videoTag.setAttribute('poster', thumbnailImgNm);
            videoTag.setAttribute('controls', 'controls');
            videoTag.setAttribute('autoplay', autoplay); 
            
            var objectTag = document.getElementsByTagName("object")[0]; 
            var obj_copy = objectTag.cloneNode(true);           
            objectTag.parentNode.insertBefore(videoTag, objectTag);
            videoTag.appendChild(obj_copy);
            objectTag.parentNode.removeChild(objectTag);
        }
         
        // if on iPad, change filename from flv to m4v
        //var exten = movieNm.substring(movieNm.length - 3, movieNm.length);
        //if (exten.toUpperCase() == "FLV"){ 
        //    movieNm = movieNm.substring(0, movieNm.length - 3);
        //    movieNm += "m4v";
        //}
    
        var myVideo = document.getElementById('html5player');
        myVideo.src= movieNm;
        myVideo.load();
        myVideo.play();  
	}
    else if (crossobj != null){
        crossobj.innerHTML= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '" id="flvplayer" align="middle" image="' + thumbnailImgNm +'"> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowfullscreen" value="true" /> <param name="movie" value="/media_players/flvPlayer.swf?autostart='+autoplay+'&amp;controlbar=over&amp;file='+movieNm+'&amp;image='+thumbnailImgNm+'" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <param name="image" value="'+thumbnailImgNm+'" /> <param name=wmode VALUE=transparent> <embed src="/media_players/flvPlayer.swf?file='+movieNm+'&amp;autostart='+autoplay+'&amp;image='+thumbnailImgNm+'" menu="false"  quality="high" wmode=transparent width="' + width + '" height="' + height + '" name="flvplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
	}  
	return false;
}

function old__loadAudioPlayer(audioFileNm, autoLaunch, elementNm, bgColor, width, height) {

    crossobj = document.getElementById(elementNm);
    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
        crossobj.innerHTML = '<audio id="audio" src="'+audioFileNm+'" controls="controls"></audio>'
    }
    else if (crossobj != null) {
        crossobj.innerHTML = '<object id="mp3player" type="application/x-shockwave-flash" data="../media_players/afAMP_player.swf" width="' + width + '" height="' + height + '" style="vertical-align: middle;"><!-- MP3 Flash player. Credits, license, contact & examples: http://pyg.keonox.com/flashmp3player/ --><param name="type" value="application/x-shockwave-flash" /><param name="codebase" value="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" /><param name="movie" value="../media_players/afAMP_player.swf" /><param name="FlashVars" value="file=' + audioFileNm + '&amp;autolaunch=' + autoLaunch + '&amp;l_loading=&amp;l_complete=&amp;l_stopped=&amp;l_playing=&amp;l_paused=&amp;my_color1=0xF3F3F3" /><param name=bgcolor VALUE="' + bgColor + '"><embed swliveconnect="true" src="../media_players/afAMP_player.swf" width="' + width + '" height="' + height + '" quality="high" bgcolor="' + bgColor + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" id = "mp3player" name="mp3player" FlashVars="file=' + audioFileNm + '&amp;autolaunch=' + autoLaunch + '&amp;l_loading=&amp;l_complete=&amp;l_stopped=&amp;l_playing=&amp;l_paused=&amp;my_color1=0xF3F3F3"/></object>';
    }
	return false;
}

function setPhotoGalleryImage(imageSrc, elementNm, imageCaption) {
	crossobj = document.getElementById(elementNm);
    crossobj.innerHTML= '<img src="' + imageSrc + '" alt="' + imageCaption + '">';
	return false;
}

function newWindow(mypage, myname, w, h, scroll) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 4;

	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable, toolbar=yes'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

//
// Scrolling news items JavaScript.
//
var newsitems;
var currentfirstspan = 0;
var currentlastspan = 3;

function initspans() {
    var aspan;
    var j = 0;
    for (var i = 0; i < 4; i++) {
        aspan = document.getElementById('newsSpan' + j);
        aspan.innerHTML = newsitems[currentfirstspan + i];
        j++;
    }
    aspan = document.getElementById('navLeft');
    aspan.innerHTML = '<a href="JavaScript:movespandown();"><img  style="display: block" src="/grfx/images/leftNav.gif" alt="Move Left" /></a>';
    aspan = document.getElementById('navRight');
    aspan.innerHTML = '<a href="JavaScript:movespanup();"><img style="display: block" src="/grfx/images/rightNav.gif" alt="Move Right" /></a>';
}

function movespandown() {
    var aspan;
    var current;

    if (currentfirstspan == 0) {
        currentfirstspan = newsitems.length - 1;
    }
    else {
        currentfirstspan--;
    }

    if (currentlastspan == 0) {
        currentlastspan = newsitems.length - 1;
    }
    else {
        currentlastspan--;
    }

    current = currentfirstspan;
    for (var i = 0; i < 4; i++) {
        aspan = document.getElementById('newsSpan' + i);
        aspan.innerHTML = newsitems[current];
        if (current < newsitems.length - 1)
            current++;
        else
            current = 0;
    }
}

function movespanup() {
    var aspan;
    var current;

    if (currentfirstspan == newsitems.length - 1) {
        currentfirstspan = 0;
    }
    else {
        currentfirstspan++;
    }

    if (currentlastspan == newsitems.length - 1) {
        currentlastspan = 0;
    }
    else {
        currentlastspan++;
    }

    current = currentfirstspan;
    for (var i = 0; i < 4; i++) {
        aspan = document.getElementById('newsSpan' + i);
        aspan.innerHTML = newsitems[current];
        if (current < newsitems.length - 1)
            current++;
        else
            current = 0;
    }
}

//
//  Presents a pop-up JavaScript prompt window.
//
function showPrompt(promptTxt, url) {
    prompt(promptTxt, url);
}

//
//  Provides a pop-up lightbox copy link window.
//
function copyLink(header, title, url) {
    var txt = '<div id="prompt">\n';
    var langCd = 'e';

    if ($('html').attr('lang') == "fr") {
        langCd = 'f';
    }
    txt += '    <h2 class="alignCenter">' + title + '</h2>\n';
    txt += '    <div id="copyURL">\n';
    txt += '        <p>\n';
    txt += '        ' + url + '</p>\n';
    txt += '        <div class="alignRight">';
    txt += '<a href="#" ';
    txt += 'onmouseover="document.copyurl.src=\'/grfx/icons/copy_down_' + langCd;
    txt += '.jpg\'" onmouseout="document.copyurl.src=\'/grfx/icons/copy_up_' + langCd;
    txt += '.jpg\'" title="';
    if (langCd == "e") {
        txt += 'Copy';
    } else {
        txt += 'Copier';
    }
    txt += '">';
    txt += '<img id="copyurl" name="copyurl" src="/grfx/icons/copy_up_' + langCd;
    txt += '.jpg" alt="';
    if (langCd == "e") {
        txt += 'Copy';
    } else {
        txt += 'Copier';
    }
    txt += '" />';
    txt += '</a>';
    txt += '</div>\n';
    txt += '    </div>\n';
    txt += '</div>';
    $.fn.colorbox({
        open: true,
        height: 230,
        html: txt,
        onClosed: function() { },
        onComplete: function() { $('img#copyurl').zclip({ path: '/scripts/ZeroClipboard.swf', copy: url, afterCopy: function() { $.colorbox.close() } }); }
    });
 }
