// JavaScript Document
//var size;

function getSize() {
 var variable= "size";
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
		size = pair[1];
		return pair[1];
    } 
  } 
  //alert('Query Variable ' + variable + ' not found');
}

function getMediaClip(){
	
	var size = getSize();
	
    if (size == "QTHDsmall")
    {
        movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=262\&vendorid=600';
        width = 1920;
        height = 796+16;
		
		embedQuicktime(movieAddress, width, height);
    }
    else if (size == "QTHDmedium")
    {
        movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=261\&vendorid=600';
        width = 1280;
        height = 532+16;
		
        embedQuicktime(movieAddress, width, height);
    }
    else if (size == "QTHDlarge")
    {
        movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=260\&vendorid=600';
        width = 1920;
        height = 796+16;
        embedQuicktime(movieAddress, width, height);
    }
    else if (size == "QTsmall")
    {
        movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=251\&vendorid=600';
        width = 240;
        height = 102+16;
		
		embedQuicktime(movieAddress, width, height);

    }
    else if (size == "QTmedium")
    {
		movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=240\&vendorid=600';
        width = 320;
        height = 136+16;
		
        embedQuicktime(movieAddress, width, height);
    }
    else if (size == "QTlarge")
    {
        movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=241\&vendorid=600';
        width = 480;
        height = 208+16;
        embedQuicktime(movieAddress, width, height);
    }
	else if (size == "QThuge")
    {
        movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=242\&vendorid=600';
        width = 640;
        height = 256+16;
        embedQuicktime(movieAddress, width, height);
    }
	else if (size == "WMsmall")
    {
		movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=233\&vendorid=600';
        width = 192;
        height = 84+46;
		
        embedWindowsMedia(movieAddress, width, height);
    }
    else if (size == "WMmedium")
    {
		movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=234\&vendorid=600';
        width = 240;
        height = 104+46;
        
		embedWindowsMedia(movieAddress, width, height);

    }
    else if (size == "WMlarge")
    {
		movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=235\&vendorid=600';
        width = 320;
        height = 136+46;
		
        embedWindowsMedia(movieAddress, width, height);
    }
    else if (size == "RMsmall")
    {
		movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=236\&vendorid=600';
        width = 192;
        height = 84;
		
        embedRealMedia(movieAddress, width, height);
    }
    else if (size == "RMmedium")
    {
		movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=237\&vendorid=600';
        width = 240;
        height = 104;
		
        embedRealMedia(movieAddress, width, height);
    }
    else if (size == "RMlarge")
    {
		movieAddress = 'http://www.totaleclips.com/Player/Bounce.aspx?eclipid=e28166\&bitrateid=238\&vendorid=600';
        width = 320;
        height = 136;
        
		embedRealMedia(movieAddress, width, height);
    }
	else if (size == "IPOD")
    {
		movieAddress = 'http://bvim-qref.sitestream.com/ThePrestige/ThePrestige_Trailer1_iPod.m4v.zip';
        width = 320;
        height = 240;
        
		downloadIPOD(movieAddress, width, height);
    }
	else if (size == "PSP")
	{
		movieAddress = 'http://bvim-qref.sitestream.com/ThePrestige/ThePrestige_Trailer1_PSP.MP4.zip';
        width = 320;
        height = 208;
        
		downloadPSP(movieAddress, width, height);
    } 
}


//// various media write methods

//function embedQuicktime(movieAddress, width, height)
function embedQuicktime(m, w, h){
	document.write ( '<table border=\'0\' cellpadding=\'0\' align=\"center\">' );
	document.write ( '<tr><td>' ); 
	document.write ( '<OBJECT classid=\'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\' width=\" ' + w + ' \" '); 
	document.write ( 'height=\" ' + h + ' \" codebase=\'http://www.apple.com/qtactivex/qtplugin.cab\'> '); 
	document.write ( '<param name=\'src\' value=\"qtlogo.mov\"> ');
	document.write ( '<param name=\'qtsrc\' value=\" ' + m + ' \"> ');
	document.write ( '<param name=\'autoplay\' value=\"true\"> <param name=\'controller\' value=\"true\"> <param name=\'loop\' value=\"true\"> ');
	document.write ( '<EMBED src=\"qtlogo.mov\" qtsrc=\" ' + m + ' \"' ); 
	document.write ( 'width=\" ' + w + ' \" height=\" ' + h + ' \" autoplay=\"true\" controller=\"true\" loop=\"true\" pluginspage=\'http://www.apple.com/quicktime/download/\'>' );
	document.write ( '</EMBED> </OBJECT>' );
	document.write ( '</td></tr>' );
	document.write ( '</table>' );
}

//function embedWindowsMedia(movieAddress, width, height);
function embedWindowsMedia(m, w, h){
	document.write ( '<table border=\"0\" cellpadding=\"0\" align=\"center\"> ');
	document.write ( '<tr><td> ');
	document.write ( '<OBJECT id=\"mediaPlayer\" width=\"' + w + '\" height=\"' + h + '\"  ');
	document.write ( 'classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"  ');
	document.write ( 'codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" ');
	document.write ( 'standby=\"Loading Microsoft Windows Media Player components...\" type=\"application/x-oleobject\"> ');
	document.write ( '<param name=\"fileName\" value=\" ' + m + '\"> ');
	document.write ( '<param name=\"animationatStart\" value=\"true\"> ');
	document.write ( '<param name=\"transparentatStart\" value=\"true\"> ');
	document.write ( '<param name=\"autoStart\" value=\"true\"> ');
	document.write ( '<param name=\"showControls\" value=\"true\"> ');
	document.write ( '<param name=\"loop\" value=\"true\"> ');
	document.write ( '<EMBED type=\"application/x-mplayer2\" ');
	document.write ( 'pluginspage=\"http://microsoft.com/windows/mediaplayer/en/download/\" ');
	document.write ( 'id=\"mediaPlayer\" name=\"mediaPlayer\" displaysize=\"4\" autosize=\"-1\"  ');
	document.write ( 'bgcolor=\"darkblue\" showcontrols=\"true\" showtracker=\"-1\"  ');
	document.write ( 'showdisplay=\"0\" showstatusbar=\"-1\" videoborder3d=\"-1\" width=\"' + w + '\" height=\"' + h + '\"  ');
	document.write ( 'src=\"' + m + '\" autostart=\"true\" designtimesp=\"5311\" loop=\"true\"> ');
	document.write ( '</EMBED></OBJECT> ');
	document.write ( '</td></tr> ');
	document.write ( '<tr><td align=\"center\"> ');
	document.write ( '<p class=\"callToAction\"><a href=\"' + m + '\" >Launch in external player</a> ');
	document.write ( '</p></td></tr></table> ');
}

//function embedRealMedia(movieAddress, width, height);
function embedRealMedia(m, w, h){
	document.write ( '<table border=\'0\' cellpadding=\'0\' align=\"center\"> ');
	document.write ( '<tr><td> ');
	document.write ( '<OBJECT id=\'rvocx\' classid=\'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\' ');
	document.write ( 'width=\"' + w + '\" height=\"' + h + '\"> ');
	document.write ( '<param name=\'src\' value=\"' + m + '\"> ');
	document.write ( '<param name=\'autostart\' value=\"true\"> ');
	document.write ( '<param name=\'controls\' value=\'imagewindow\'> ');
	document.write ( '<param name=\'console\' value=\'video\'> ');
	document.write ( '<param name=\'loop\' value=\"true\"> ');
	document.write ( '<EMBED src=\"' + m + '\" width=\"' + w + '\" height=\"' + h + '\"  ');
	document.write ( 'loop=\"true\" type=\'audio/x-pn-realaudio-plugin\' controls=\'imagewindow\' console=\'video\' autostart=\"true\"> ');
	document.write ( '</EMBED></OBJECT> ');
	document.write ( '</td></tr> ');
	document.write ( '<tr><td> ');
	document.write ( '<OBJECT id=\'rvocx\' classid=\'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\' width=\"' + w + '\" height=\"30\"> ');
	document.write ( '<param name=\'src\' value=\"' + m + '\"> ');
	document.write ( '<param name=\'autostart\' value=\"true\"> ');
	document.write ( '<param name=\'controls\' value=\'ControlPanel\'> ');
	document.write ( '<param name=\'console\' value=\'video\'> ');
	document.write ( '<EMBED src=\"' + m + '\" width=\"'+ w + '\" height=\"30\"  ');
	document.write ( 'controls=\'ControlPanel\' type=\'audio/x-pn-realaudio-plugin\' console=\'video\' autostart=\"true\">  ');
	document.write ( '</EMBED></OBJECT> ');
	document.write ( '</td></tr> ');
	document.write ( '<tr><td align=\'center\'> ');
	document.write ( '<p class=\"callToAction\"><a href=\"' + m + '\" >Launch in external player</a></p> ');
	document.write ( '</td></tr> ');
	document.write ( '</table> ');
}

//downloadIPOD(movieAddress, width, height);
function downloadIPOD(m, w, h){
	document.write ( '<table border=\'0\' cellpadding=\'0\' align=\"center\"> ');
	document.write ( '<tr><td> ');
	document.write ( '<h1 class=\"downloadInstructsHead\"><a href=\"' + m + '\" >DOWNLOAD TRAILER FOR IPOD</a></h1> ');
	document.write ( '<p class=\"downloadInstructs\">Download the zip file to a desired location.<br> ' );
	document.write ( 'Size : ' + w + ' x ' + h +'</p> ' );
	document.write ( '</td></tr> ');
	document.write ( '</table> ');
}

//downloadPSP(movieAddress, width, height);
function downloadPSP(m, w, h){
	document.write ( '<table border=\'0\' cellpadding=\'0\' align=\"center\"> ');
	document.write ( '<tr><td> ');
	document.write ( '<h1 class=\"downloadInstructsHead\"><a href=\"' + m + '\">DOWNLOAD TRAILER FOR PSP</a></h1> ');
	document.write ( '<p class=\"downloadInstructs\">Download the zip file to a desired location.<br> ' );
	document.write ( 'Size : ' + w + ' x ' + h +'</p> ' );
	document.write ( '</td></tr> ');
	document.write ( '</table> ');
}