/**
 * @author dareyes
 */


/**************************************
directions:  
inser the following html:

    <div id="videoPlayerContainer">
        <div id="videoPlayer"></div>
        <div id="videoTextContainer">
            <div id="videoTextHeader"></div>
                <span>Video URL:</span><input type="text" id="textVideoUrl" />
                <span>Embed Code:</span><input type="text" id="textVideoCode" />
        </div>
    </div>
    <a href="javascript:void(0);" onclick="OnVideoClick(12345, 'text for video 1');">video 1</a>
    <a href="javascript:void(0);" onclick="OnVideoClick(123456, 'text for video 2');">video 2</a>
    <a href="javascript:void(0);" onclick="OnVideoClick(123453, 'text for video 3');">video 3</a>


and then trigger the video switch by making a call to OnVideoClick('2023434112', 'cheese') with the 
corresponding video id and caption to be placed in the header text.
***************************************/
var defaultWidth = 480;
var defaultHeight = 400;

// loads the video player and then changes the text.
// width and height are optional
function OnVideoClick(videoId, cid, headerText, width, height)
{
    LoadVideo(videoId, cid, width, height);
    LoadVideoText(videoId, headerText);
}

// loads the video player
// width and height are optional
function LoadVideo(videoId, cid, width, height)
{
    // if the width and height have been specified, we set it.
    // otherwise we use the default width and height that are defined above
    width = (width) ? width : defaultWidth;
    height = (height) ? height : defaultHeight;
    
    // change the video source   
    var videoPlayerContainer = document.getElementById('videoPlayer');
    //videoPlayerContainer.innerHTML = '<embed src="http://lads.myspace.com/videos/vplayer.swf" flashvars="sr=0&a=1&m=' + videoId + '&type=video" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>';
	
	videoPlayerContainer.innerHTML = '<embed width="'+width+'" height="'+height+'" flashvars="e=http%3A//vids.myspace.com/index.cfm%3Ffuseaction%3Dvids.individual%26VideoID%3D'+videoId+'" allowfullscreen="true" allowscriptaccess="always" wmode="transparent" quality="high" bgcolor="#000000" name="vplayer" id="vplayer" style="" src="http://mediaservices.myspace.com/services/media/embed.aspx/m='+videoId+',t=1,mt=video,ap=1" type="application/x-shockwave-flash"/>';
    
	document.getElementById('player_moreeps').setAttribute("href","http://vids.myspace.com/index.cfm?fuseaction=vids.channel&ChannelID=" + cid);
}

// sets the text header, video url, and video embed code.
function LoadVideoText(videoId, videoText)
{
    document.getElementById('videoTextHeader').innerHTML = '<a href="http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=' + videoId + '" title="'+videoText+'">' + videoText + '</a>';
    //document.getElementById('textVideoUrl').value = 'http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=' + videoId;
    //document.getElementById('textVideoCode').value = '<embed src="http://lads.myspace.com/videos/vplayer.swf" flashvars="m=' + videoId + '&type=video" type="application/x-shockwave-flash" height="388" width="482"></embed>';
}