/* -----------------------------------------
   Author:    Fulup Ar Foll 
   Date:      June 2008
   Copyleft:  GNU with no support :)
   Object:    javascript to embed divX Web Player into Linux and Windows
   reference: http://www.quirksmode.org/js/detect.html

   download: http://www.fridu.org/download/samples/fulup-divxplayer.js
   demo:     http://movies.fridu.org/html/fulup-divxwebplayer.html

   usage: copy this file on your web site and add in your html page
   ----------------------------------------------------------------
   <html>
   <head> <title>Fulup Javascript for DivX Web Player under Linux and Windows</title>
      <script type='text/javascript' src="fulup-divxplayer.js"></script>
   </head>

   <body>
     <script type="text/javascript"> <!--
     // syntaxe: DivxWebPlayer (width, height, preview, video);
     // warning: do not resize your video our result will be very poor !!!
     DivxWebPlayer ( 960, 526
       ,"http://movies.fridu.org/divx/Erwan-Test.jpg"
       ,"http://movies.fridu.org/divx/Erwan-Test.divx"
     );
     --> </script>
   </body>
   </html>

*/

<!--
var BrowserDetect = {
	init: function () {
      		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
        dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

function DivxWebPlayer (width, height, preview, video) {

 var OsBrowser;
 OsBrowser = BrowserDetect.OS + '-' + BrowserDetect.browser;
 // document.write ("OsBrowser=" + OsBrowser + "preview=" + preview + "video=" + video + "</p>");

 switch (OsBrowser) {
   case "Windows-Explorer" :
   document.write (" <object classid=\"clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616\" ");
   document.write (" width=" + width + "\" height=\"" + height );
   document.write (" codebase=\"http://go.divx.com/plugin/DivXBrowserPlugin.cab\">");
   document.write (" <param name=\"previewImage\" value=\"" + preview + "\" />");
   document.write (" <param name=\"src\" value=\"" + video + "\" />");
   document.write (" <param name=\"custommode\" value=\"Stage6\" />");
   document.write (" <param name=\"autoPlay\" value=\"false\" />");
   break;

   case "Linux-Konqueror" :
     document.write (" <a href=\"" + video + "\" >");
     document.write (" <img src= \"" + preview + "\" width=\""+ width + "\" height=\"" + height + "\"");
     document.write (" </a>");
     break;

   case "Linux-Firefox" :
    document.write (" <EMBED");
    document.write (" width=\""+ width + "\" height=\"" + height + "\"");
    document.write (" src=\"" + preview + "\"");
    document.write (" qtsrc=\"" + video + "\"");
    document.write (" loop=\"false\" type=\"video/divx\" controller=\"true\" autoplay=\"true\" ");
    document.write (" pluginspage=\"http://packman.links2linux.org/package/mplayerplug-in\" target=\"myself\" > ");
    document.write (" </EMBED>");
    break;

   case "Windows-Firefox":
   case "Windows-Mozilla":
   default:
    document.write (" <EMBED");
    document.write (" width=\""+ width + "\" height=\"" + height + "\"");
    document.write (" previewImage=\"" + preview + "\"");
    document.write (" src=\"" + video + "\"");
    document.write (" loop=\"false\" type=\"video/divx\" controller=\"true\" autoplay=\"false\" ");
    document.write (" pluginspage=\"http://go.divx.com/plugin/download\" target=\"myself\" > ");
    document.write (" </EMBED>");

 } // end switch
 
 // add here your trailler info
 document.write ("</br><center><small><i>");
 document.write ("Video direct download to disk <a href=\"" + video + "\" >[here] </a><br>");
 document.write ("</br></center></small></i> ");

}; // end DivxWebPlayer

BrowserDetect.init();

