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 loadJW5Video(movieNm, thumbnailImgNm, elementNm, width, height, autoplay, closedCaptionFlNm, autoStartCC, lang, base, audioDescFlNm) {

    var players = "";
    var useHTML5 = false;

    var enableHTML5Chrome = false;

    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) { //|| (navigator.userAgent.match(/Chrome/i))
        useHTML5 = true;
    }

    if (enableHTML5Chrome) {
        if ((navigator.userAgent.match(/Chrome/i))) {
            useHTML5 = true;
        }
    }

    var autoPlayCC = "false";
    if (closedCaptionFlNm != "") {
        if (autoStartCC == 1) {
            autoPlayCC = "true";
        }
    }

    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?";
    }



    //alert('loading new vid');
    //use JW Embedder to load a new vid
    //jwplayer("innerVid").remove();
    var innerVidId = 'innerVid_' + elementNm;
    document.getElementById("vidContainer_" + elementNm).innerHTML = "<div id='" + innerVidId + "'></div>";
    /*we have 4 scenarios: 
    1)with HTML5 - no captions or audio desc
    2)with CC and with audio desc
    3)with CC and without audio desc
    4)without CC and with audio desc
    5)without CC and without audio desc
    */

    //1)with CC and with HTML5
   if (useHTML5 == true) { //1)with HTML5 - no captions or audio desc
        //alert('3:'+movieNm);
        jwplayer(innerVidId).setup({
            file: movieNm,
            image: thumbnailImgNm,
            height: 362,
            width: 592,
            autostart: autoplay,
            controlbar: "bottom",
            //plugins:{"/media_players/JW/pcoshare.swf" : {  }},  
            "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,
            skin: "/media_players/JW/glow/glow.xml",
            dock: "false",
            stretching: "fill",
            players: [
                     { type: "html5" },
                     { type: "flash", src: "/media_players/JW/player.swf" }
                ]
        });
    }
    else if (closedCaptionFlNm != "" && audioDescFlNm != "") { //2)with CC and with audio desc
        //alert('2:'+movieNm);
        jwplayer(innerVidId).setup({
            file: movieNm,
            image: thumbnailImgNm,
            height: 362,
            width: 592,
            autostart: autoplay,
            controlbar: "bottom",
            plugins: {//"/media_players/JW/pcoshare.swf" : {  },     
                captions: { file: closedCaptionFlNm, state: autoPlayCC},
                audiodescription: {file: audioDescFlNm, state: "false"} //audiodescription-1
            },
            "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,
            skin: "/media_players/JW/glow/glow.xml",
            dock: "false",
            stretching: "fill",
            players: [
                     { type: "flash", src: "/media_players/JW/player.swf" }
                ]
        });
    }
    else if (closedCaptionFlNm == "" && audioDescFlNm != "") { //3)without CC and with audio desc
        jwplayer(innerVidId).setup({
            file: movieNm,
            image: thumbnailImgNm,
            height: 362,
            width: 592,
            autostart: autoplay,
            controlbar: "bottom",
            plugins: {//"/media_players/JW/pcoshare.swf" : {  },     
                audiodescription: { file: audioDescFlNm, state: "false"} //audiodescription-1
            },
            "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,
            skin: "/media_players/JW/glow/glow.xml",
            dock: "false",
            stretching: "fill",
            players: [
                         { type: "flash", src: "/media_players/JW/player.swf" }
                    ]
        });
    }
    else if (closedCaptionFlNm != "" && audioDescFlNm == "") { //4)with CC and without audio desc
        jwplayer(innerVidId).setup({
            file: movieNm,
            image: thumbnailImgNm,
            height: 362,
            width: 592,
            autostart: autoplay,
            controlbar: "bottom",
            plugins: {//"/media_players/JW/pcoshare.swf" : {  },     
                captions: { file: closedCaptionFlNm, state: autoPlayCC }
            },
            "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,
            skin: "/media_players/JW/glow/glow.xml",
            dock: "false",
            stretching: "fill",
            players: [
                         { type: "flash", src: "/media_players/JW/player.swf" }
                    ]
        });
    }
    else if (closedCaptionFlNm == "" && audioDescFlNm == "") { //4)without CC and without audio desc
        jwplayer(innerVidId).setup({
            file: movieNm,
            image: thumbnailImgNm,
            height: 362,
            width: 592,
            autostart: autoplay,
            controlbar: "bottom",
            "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,
            skin: "/media_players/JW/glow/glow.xml",
            dock: "false",
            stretching: "fill",
            players: [
                         { type: "flash", src: "/media_players/JW/player.swf" }
                    ]
        });
    }

}

function 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 loadAudioPlayer(audioFileNm, autoLaunch, elementNm, bgColor, width, height) {
	crossobj = document.getElementById(elementNm);
    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;
    }
}
