// JavaScript Document

function nvo (pObject) {
	var myURL = pObject.url;
	var myElement = pObject.element;
	var myHeight = pObject.height;
	var myWidth = pObject.width;
	var myPosterUrl = pObject.poster;
	var myAltTag = pObject.alttag;
	var myWebTrendsCode = pObject.webtrendscode;
	$(myElement).css({
				   "width": myWidth,
				   "height": myHeight,
				   "position": "relative",
				   "cursor": "pointer"
				   });			   
	var poster = writePoster(myPosterUrl, myWidth, myHeight, myAltTag);
	$(myElement).html( poster );
	var myHeight = myHeight;
	var myEmbed = writeEmbed(myURL, myWidth, myHeight);
	$(myElement).click(function () { $(this).html( myEmbed ); }); 
	var buttonTopPos = Math.floor((myHeight / 2) - 60);
	var buttonLeftPos = Math.floor((myWidth /2) - 60);
	var playButton = "<div id='playButton' style='position: absolute; top:" + buttonTopPos + "px; left:" + buttonLeftPos + "px; height:120px; width:120px;'><img src='http://www.niehs.nih.gov/resources/images/play_button.gif' width='120' height='120' alt='" + myAltTag + "' class='nonbordered' onclick=\"" + myWebTrendsCode + "\" /> </div>";
	$(myElement).append(playButton);
}




function writeEmbed (myUrl, myWidth, myHeight) {
	
	embedStr = "<object ";
	embedStr += "classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' codebase='http://www.apple.com/qtactivex/qtplugin.cab'";
	embedStr += "width='" + myWidth + "' height='" + myHeight + "'>";
	embedStr += "<param name='src' value='"+ myUrl +"' />"; 
	embedStr += "<param name='controller' value='true' />";
	embedStr += "<param name='autoplay' value='true' />";
	
	embedStr += "<!--[if !IE]>-->";

	embedStr += "<object type='video/quicktime'";
    embedStr += "data='"+ myUrl +"'";
    embedStr += "width='" + myWidth + "' height='"+ myHeight +"'>";
    embedStr += "<param name='autoplay' value='true' />";
    embedStr += "<param name='controller' value='true' />";
    embedStr += "</object>";
	embedStr += "<!--<![endif]-->";
    embedStr += "</object>";
// alert('This is writeEmbed: ' + embedStr);
return embedStr;

}

function writePoster (imgUrl, mWidth, mHeight, myAltTag) {
	var imgStr = "<img src='" + imgUrl + "' width='" + mWidth + "' height='" + mHeight + "' alt='" + myAltTag + "' />";
	return imgStr;
}
