function movieWindowSD(movieURL,s)
{
var size=parseInt(s);
var width=size;
var height=Math.round(0.75*width);
width+=72;
height+=72;
return movieWindow(movieURL,width,height);
}
function movieWindowHD(movieURL,s)
{
var size=parseInt(s);
var width=size;
var height=Math.round(9*width/16);
width+=72;
height+=72;
return movieWindow(movieURL,width,height);
}
function movieWindow(movieURL,width,height)
{
var left = (screen.availWidth-width)/2;
var top = (screen.availHeight-height)/2;
var w = window.open(movieURL, "MovieWindow", "autoplay=yes,statusbar=yes,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width="+(width)+",height="+(height)+",top="+(top)+",left="+(left));
if (w)
{

w.location.href=movieURL;
w.resizeTo(width,height);
w.moveTo(left,top);
w.status=movieURL;


w.focus();
}
return w;
}
function inlineMovie(movieURL,width,height,options)
{
if (!options){options="border=0 autoplay=false cache=true controller=true loop=false scale=aspect";}
var p,text="";
if (RegExp){
p = /controller="?true"?/i;
if (p.test(options)){height+=16;}
p = /(\w+)="?(\w+)"?/g;

text+="<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" width=\""+width+"\" height=\""+height+"\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\">\n";
text+="<param name=\"src\" value=\""+movieURL+"\">\n";
var result,new_options="",i=0;
if (p.lastIndex != null){
while ((result=p.exec(options)) != null && i++<6)
{
text+="<param name=\""+result[1]+"\" value=\""+result[2]+"\">\n";
new_options+=" "+result[1]+"=\""+result[2]+"\"";
}
}else{					// IE doesn't have lastIndex and exec() doesn't work
result=options.split(' ');
var key_value;
for (var i in result)
{
key_value=result[i].split('=');
text+="<param name=\""+key_value[0]+"\" value=\""+key_value[1]+"\">\n";
new_options+=" "+key_value[0]+"=\""+key_value[1]+"\"";
}
}

text+="<embed src=\""+movieURL+"\" width=\""+width+"\" height=\""+height+"\" pluginspage=\"http://www.apple.com/quicktime/download/\""+new_options+"></embed>\n";
text+="</object>\n";
}else{
text="<embed src=\""+movieURL+"\" width=\""+width+"\" height=\""+height+"\" pluginspage=\"http://www.apple.com/quicktime/download/\""+options+"></embed>\n";
}
return text;
}
function embedQT(posterURL,movieURL,width,aspectRatio,allowSave,inline,showcontroller,loop,bgcolor)
{
if (showcontroller==null) showcontroller=false
if (allowSave==null) allowSave=false;
if (inline==null) inline=false;
if (loop==null) loop=false;
if (!inline)
{
showcontroller=false;
loop=false;
}
var height;
if (aspectRatio<3)
height=Math.floor(width/aspectRatio+0.5);
else height=aspectRatio;
if (showcontroller) height+=16;

var html='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+width+'" height="'+height+'">\n';
var embed='<embed pluginspage="http://www.apple.com/quicktime/download/" type="video/quicktime" width="'+width+'" height="'+height+'" ';
html+='<param name="SRC" value="'+posterURL+'" />\n';
embed+='src="'+posterURL+'" ';
if (inline)
{
html+='<param name="QTSRC" value="'+movieURL+'" />\n';
html+='<param name="AUTOPLAY" value="true" />\n';
embed+='qtsrc="'+movieURL+'" ';
embed+='autoplay="true" ';
}else{
html+='<param name="HREF" value="'+movieURL+'" />\n';
html+='<param name="TARGET" value="quicktimeplayer" />\n';
embed+='href="'+movieURL+'" ';
embed+='target="quicktimeplayer" ';
}
html+='<param name="CACHE" value="true" />\n';
embed+='cache="true" ';
html+='<param name="QTSRCDontUseBrowser" value="false" />\n';
embed+='qtsrcdontusebrowser="false" ';
if (!allowSave)
{
html+='<param name="KIOSKMODE" value="true" />\n';
embed+='kioskmode="true" ';
}
if (loop)
{
html+='<param name="LOOP" value="'+loop+'" />\n';
embed+='loop="'+loop+'" ';
}
html+='<param name="CONTROLLER" value="'+showcontroller+'" />\n';
embed+='controller="'+showcontroller+'" ';
html+='<param name="SCALE" value="aspect" />\n';
embed+='scale="aspect" ';

if (bgcolor!=null)
{
html+='<param name="BGCOLOR" value="'+bgcolor+'" />\n';
embed+='bgcolor="'+bgcolor+'" ';
}

embed+=" />";
html+=embed+'\n</object>';
return html;
}
function pictureFrame(imgHTML,imgWidth,imgHeight,frameURL,frameExt,frameTop,frameRight,frameBottom,frameLeft)
{
if (frameRight==null) frameRight=frameTop;
if (frameBottom==null) frameBottom=frameTop;
if (frameLeft==null) frameLeft=frameRight;
if (imgHeight<3)
imgHeight=Math.floor(imgWidth/imgHeight+0.5);
if (frameURL.charAt(frameURL.length-1)!='/')
frameURL+='/';
var html='<div style="padding: 0;margin: 0;font-size: 0;line-height: 0;text-align: center;">\n';
html+='<div><img src="'+frameURL+'tl.'+frameExt+'" alt="" width="'+frameLeft+'" height="'+frameTop+'" /><img src="'+frameURL+'t.'+frameExt+'" alt="" width="'+imgWidth+'" height="'+frameTop+'" /><img src="'+frameURL+'tr.'+frameExt+'" alt="" width="'+frameRight+'" height="'+frameTop+'" /></div>\n';
html+='<div><img src="'+frameURL+'l.'+frameExt+'" alt="" width="'+frameLeft+'" height="'+imgHeight+'" />'+imgHTML+'<img src="'+frameURL+'r.'+frameExt+'" alt="" width="'+frameRight+'" height="'+imgHeight+'" /></div>\n';
html+='<div><img src="'+frameURL+'bl.'+frameExt+'" alt="" width="'+frameLeft+'" height="'+frameBottom+'" /><img src="'+frameURL+'b.'+frameExt+'" alt="" width="'+imgWidth+'" height="'+frameBottom+'" /><img src="'+frameURL+'br.'+frameExt+'" alt="" width="'+frameRight+'" height="'+frameBottom+'" /></div>\n';
html+='</div>\n';

return html;
}
function frameImage(imgURL,imgAlt,imgHREF,imgWidth,imgHeight,frameURL,frameExt,frameTop,frameRight,frameBottom,frameLeft)
{
if (imgHeight<3)
imgHeight=Math.floor(imgWidth/imgHeight+0.5);
var html='<img src="'+imgURL+'" alt="'+imgAlt+'" width="'+imgWidth+'" height="'+imgHeight+'" style="border-style: none;" />';
if (imgHREF) html='<a href="'+imgHREF+'">'+html+"</a>";
html=pictureFrame(html,imgWidth,imgHeight,frameURL,frameExt,frameTop,frameRight,frameBottom,frameLeft);
return html;
}
function frameImageWithID(imgID,imgURL,imgAlt,imgHREF,imgWidth,imgHeight,frameURL,frameExt,frameTop,frameRight,frameBottom,frameLeft)
{
if (imgHeight<3)
imgHeight=Math.floor(imgWidth/imgHeight+0.5);
var html='<img id="'+imgID+'" src="'+imgURL+'" alt="'+imgAlt+'" width="'+imgWidth+'" height="'+imgHeight+'" style="border-style: none;" />';
if (imgHREF) html='<a href="'+imgHREF+'">'+html+"</a>";
html=pictureFrame(html,imgWidth,imgHeight,frameURL,frameExt,frameTop,frameRight,frameBottom,frameLeft);
return html;
}
function frameMovie(posterURL,movieURL,showcontroller,loop,imgWidth,imgHeight,frameURL,frameExt,frameTop,frameRight,frameBottom,frameLeft)
{
if (imgHeight<3)
imgHeight=Math.floor(imgWidth/imgHeight+0.5);
var html=embedQT(posterURL,movieURL,imgWidth,imgHeight,false,true,showcontroller,loop,"#000000");
if (showcontroller) imgHeight+=16;
html=pictureFrame(html,imgWidth,imgHeight,frameURL,frameExt,frameTop,frameRight,frameBottom,frameLeft);
return html;
}
