﻿function loadMedia(url)
{
        // Mediaplayer settings and options
		playerpath = '/Movie/player/mediaplayer.swf';	// Path to the mediaplayer.swf or flvplayer.swf file
		backcolor =  '0x777777';		// Base color for the controller, color name / hex value (0x000000)
		frontcolor = '0x000000';		// Text and button color for the controller, color name / hex value (0x000000)
		lightcolor = '0x000000';		// Rollover color for the controller, color name / hex value (0x000000)
		fullscreen = 'true';			// Display fullscreen button
		autostart = 'true';			// Automatically plays the video on load
		// Quicktime options (QT plugin used for partial WMV support as well)
		autoplay = 'true';			// Automatically play movie, true / false
		bgcolor = 'black';			// Background color, name / hex value
		controller = 'true';			// Show controller, true / false
		// Flickr options
		fkBGcolor = '#000000';		// Background colour option
		fkFullscreen = 'true';		// Enable fullscreen button
		// Revver options
		revverID = '187866';			// Revver affiliate ID
		revverFullscreen = 'true';	// Fullscreen option
		revverBack = '#000000';		// Background colour
		revverFront = '#ffffff';		// Foreground colour
		revverGrad = '#000000';		// Gradation colour
		// Seesmic options
		ssFullscreen = 'true';		// Fullscreen option for Seesmic
		// Youtube options
		ytAutoplay = '1';			// Auto play, 0=false, 1=true
		// Veoh options
		vhAutoplay = '1';			// Enable autoplay, 0=false 1=true
		vhFullscreen = 'true';		// Enable fullscreen
		// Viddler options
		vdFullscreen = 'true';		// Enable fullscreen
		// Vimeo options
		vmFullscreen = '1';			// Fullscreen option, 0=false, 1=true
		vmTitle = '1';				// Show video title
		vmByline = '1';				// Show byline
		vmPortrait = '1';			// Show author portrait
		vmColor = '5ca0b5';			// Custom controller colours, hex value minus the #
		// Width and Height options
		contentsWidth = 470;
		contentsHeight = 360;
		
		// DailyMotion
		if (url.match(/dailymotion\.com/i)) {
			type = 'flash';
			object = new SWFObject(url, "sfwvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen','true');
		// Flickr
		} else if (url.match(/flickr\.com/i)) {
			type = 'flashobj';
			temp = url.split('/');
			videoID = temp[5];
			object = '<object type="application/x-shockwave-flash" width="'+contentsWidth+'" height="'+contentsHeight+'" data="http://www.flickr.com/apps/video/stewart.swf?v=1.173" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="flashvars" value="intl_lang=en-us&amp;photo_id='+videoID+'"></param> <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=1.173"></param> <param name="bgcolor" value="'+fkBGcolor+'"></param> <param name="allowFullScreen" value="'+fkFullscreen+'"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=1.173" bgcolor="'+fkBGcolor+'" allowfullscreen="'+fkFullscreen+'" flashvars="intl_lang=en-us&amp;photo_id='+videoID+'" height="'+contentsHeight+'" width="'+contentsWidth+'"></embed></object>';
		// Google Video
		} else if (url.match(/google\.com\/videoplay/i)) {
			type = 'flash';
			temp = url.split('=');
			videoID = temp[1];
			object = new SWFObject("http://video.google.com/googleplayer.swf?docId="+videoID+"&autoplay=1&hl=en", "sfwvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen','true');
		// Metacafe
		} else if (url.match(/metacafe\.com\/watch/i)) {
			type = 'flash';
			temp = url.split('/');
			videoID = temp[4];
			object = new SWFObject("http://www.metacafe.com/fplayer/"+videoID+"/.swf", "sfwvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen','true');
		// MyspaceTV
		} else if (url.match(/myspacetv\.com/i)) {
			type = 'flash';
			temp = url.split('=');
			videoID = temp[2];
			object = new SWFObject("http://lads.myspace.com/videos/vplayer.swf?m="+videoID+"&v=2&type=video", "sfwvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen','true');
		// Revver
		} else if (url.match(/revver\.com/i)) {
			type = 'flash';
			temp = url.split('/');
			videoID = temp[4];
			object = new SWFObject("http://flash.revver.com/player/1.0/player.swf?mediaId="+videoID+"&affiliateId="+revverID+"&allowFullScreen="+revverFullscreen+"&backColor="+revverBack+"&frontColor="+revverFront+"&gradColor="+revverGrad+"&shareUrl=revver", "sfwvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen','true');
		// Seesmic
		} else if (url.match(/seesmic\.com/i)) {
			type = 'flash';
			temp = url.split('/');
			videoID = temp[5];
			object = new SWFObject("http://seesmic.com/Standalone.swf?video="+videoID, "sfwvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen',ssFullscreen);
		// YouTube
		} else if (url.match(/youtube\.com\/watch/i)) {
			type = 'flash';
			temp = url.split('=');
			videoID = temp[1];
			object = new SWFObject("http://www.youtube.com/v/"+videoID+"&autoplay=1", "sfwvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen','true');
		// Veoh
		} else if (url.match(/veoh\.com/i)) {
			type = 'flash';
			temp = url.split('videos/');
			videoID = temp[1];
			object = new SWFObject("http://www.veoh.com/videodetails2.swf?permalinkId="+videoID+"&id=2907158&player=videodetailsembedded&videoAutoPlay="+vhAutoplay, "sfwvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen','true');
		// Viddler
		} else if (url.match(/viddler\.com/i)) {
			temp = url.split('/');
			videoId1 = temp[4];
			videoId2 = temp[6];
			videoID = "viddler_"+videoId1+"_"+videoId2;
			type = 'flashobj';
			object = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+contentsWidth+'" height="'+contentsHeight+'" id="'+videoID+'"><param name="movie" value="http://www.viddler.com/player/e5398221/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="'+vdFullscreen+'" /><embed src="http://www.viddler.com/player/e5398221/" width="'+contentsWidth+'" height="'+contentsHeight+'" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="'+vdFullscreen+'" name="'+videoID+'" ></embed></object>';
		// Vimeo
		} else if (url.match(/vimeo\.com/i)) {
			type = 'flash';
			temp = url.split('/');
			videoID = temp[3];
			object = new SWFObject("http://www.vimeo.com/moogaloop.swf?clip_id="+videoID+"&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=5ca0b5", "sfwvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen','true');
		// 12seconds
		} else if (url.match(/12seconds\.tv/i)) {
			temp = url.split('/');
			videoID = temp[5];
			type = 'flashobj';
			object = '<object type="application/x-shockwave-flash" data="http://embed.12seconds.tv/players/remotePlayer.swf" width="'+contentsWidth+'" height="'+contentsHeight+'" ><param name="movie" value="http://embed.12seconds.tv/players/remotePlayer.swf" /><param name="FlashVars" value="vid='+videoID+'"/><embed src="http://embed.12seconds.tv/players/remotePlayer.swf" width="'+contentsWidth+'" height="'+contentsHeight+'" flashvars="vid='+videoID+'"></embed></object>';
		// clip.vn
		} else if (url.match(/clip\.vn/i)) {
			temp = url.split('/');
			videoID = temp[5].replace(/,vn/i, '');
			type = 'flashobj';
			object = '<embed type="application/x-shockwave-flash" name="plugin" width="'+contentsWidth+'" height="'+contentsHeight+'" src="http://clip.vn/member/player/player.2.60.vn.swf?enablejs=true&amp;a='+videoID+',1,http://clip.vn/,,,"/>';
		// tamtay
		} else if (url.match(/video\.tamtay\.vn/i)) {
			temp = url.split('/');
			videoID = temp[5];
			type = 'flashobj';
			object = '<embed width="'+contentsWidth+'" height="'+contentsHeight+'" quality="high" allowFullScreen="true" allowSciptAccess="true" name="flvplayer" id="flvplayer" src="http://video.tamtay.vn/misc/player/flowplayer.swf?config=%7Bembeded%3Atrue%2CconfigFileName%3A%27http%3A%2F%2Fvideo.tamtay.vn%2Fvideo%2Fplay%2Fconfig%2F'+videoID+'%2F2%27%7D" type="application/x-shockwave-flash"/>';
		// Flash .SWF
		} else if (url.match(/\.swf/i)) {
			type = 'flash';
			object = new SWFObject(url, "sfwvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen','true');
		// Flash .FLV
		} else if (url.match(/\.flv/i)) {
		    type = 'flash';
		    if (url.match(/kapsule/i)) {
			    //object = new SWFObject("http://video.zing.vn/player/playerHD.swf", "flvvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			    object = new SWFObject("http://movie.zing.vn/Movie/player/playerHD.swf", "flvvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			    object.addParam('width', contentsWidth);
			    object.addParam('height', contentsHeight);
			    object.addParam('flashvars','htmlPage=' + url + '&autoPlay=true');
			    object.addParam('allowfullscreen','true');
		    } else {
			    object = new SWFObject(playerpath+"?file="+url+"&autostart="+autostart+"&displayheight="+contentsHeight+"&allowfullscreen="+fullscreen+"&usefullscreen="+fullscreen+"&backcolor="+backcolor+"&frontcolor="+frontcolor+"&lightcolor="+lightcolor, "flvvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			    object.addParam('allowscriptaccess','always');
			    object.addParam('allowfullscreen','true');
			}
		// Quicktime .MOV
		} else if (url.match(/\.mov/i)) {
			type = 'qt';
			if (controller=='true') {contentsHeight = (contentsHeight*1)+16};
			if (navigator.plugins && navigator.plugins.length) {
				object = '<object id="mediabox" standby="loading quicktime..." type="video/quicktime" codebase="http://www.apple.com/qtactivex/qtplugin.cab" data="'+url+'" width="'+contentsWidth+'" height="'+contentsHeight+'"><param name="src" value="'+url+'" /><param name="scale" value="aspect" /><param name="controller" value="'+controller+'" /><param name="autoplay" value="'+autoplay+'" /><param name="bgcolor" value="'+bgcolor+'" /><param name="enablejavascript" value="true" /></object>';
			} else {
				object = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" standby="loading quicktime..." codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+contentsWidth+'" height="'+contentsHeight+'" id="mediabox"><param name="src" value="'+url+'" /><param name="scale" value="aspect" /><param name="controller" value="'+controller+'" /><param name="autoplay" value="'+autoplay+'" /><param name="bgcolor" value="'+bgcolor+'" /><param name="enablejavascript" value="true" /></object>';
			}
		// Windows Media .WMV
		} else if (url.match(/\.wmv/i)) {
			type = 'wmv';
			if (controller=='true') {contentsHeight = (contentsHeight*1)+16};
			//if (navigator.plugins && navigator.plugins.length) {
				//object = '<object id="mediabox" standby="loading windows media..." type="video/x-ms-wmv" data="'+url+'" width="'+contentsWidth+'" height="'+contentsHeight+'" /><param name="src" value="'+url+'" /><param name="autoStart" value="'+autoplay+'" /></object>';
			//} else {
				//object = '<object id="mediabox" standby="loading windows media..." classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" type="video/x-ms-wmv" data="'+url+'" width="'+contentsWidth+'" height="'+contentsHeight+'" /><param name="filename" value="'+url+'" /><param name="showcontrols" value="'+controller+'"><param name="autoStart" value="'+autoplay+'" /><param name="stretchToFit" value="true" /></object>';
			//}
			object = '<object id="mediabox" standby="loading windows media..." type="application/x-oleobject" width="'+contentsWidth+'" height="'+contentsHeight+'" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"><param name="url" value="'+url+'" /><param name="EnableContextMenu" value="1" /><param name="volume" value="100" /><param name="kioskmode" value="True" /><param name="uiMode" value="full" /><param name="stretchToFit" value="True" /><param name="AnimationAtStart" value="false" /><param name="playCount" value="10" /><embed src="'+url+'" type="application/x-mplayer2" autostart="1" transparentatstart="1" animationatstart="1" showcontrols="true" kioskmode="True" showaudiocontrols="1" showpositioncontrols="0" enablecontextmenu="1" autosize="0" showstatusbar="1" displaysize="false" playcount="10" align="middle" border="0" width="'+contentsWidth+'" height="'+contentsHeight+'" /></object>';

		} else{
			type = 'flash';
		    /*
		    object = new SWFObject("http://video.zing.vn/player/playerHD.swf", "flvvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
		    object.addParam('width', contentsWidth);
		    object.addParam('height', contentsHeight);
		    object.addParam('flashvars','htmlPage=' + url + '&autoPlay=true');
		    object.addParam('allowfullscreen','true');
		    */
		    object = new SWFObject("http://movie.zing.vn/Movie/player/playerHD.swf", "flvvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('width', contentsWidth);
			object.addParam('height', contentsHeight);
			object.addParam('flashvars','htmlPage=' + url + '&autoPlay=true');
			object.addParam('allowfullscreen','true');
			/*
			object = new SWFObject("http://video.zing.vn/player/flvPlayer.swf"+"?xmlFile="+url+"&autostart="+autostart+"&displayheight="+contentsHeight+"&allowfullscreen="+fullscreen+"&usefullscreen="+fullscreen+"&backcolor="+backcolor+"&frontcolor="+frontcolor+"&lightcolor="+lightcolor, "flvvideo", contentsWidth, contentsHeight, "9", "#000000", "wmode", "transparent");
			object.addParam('allowscriptaccess','always');
			object.addParam('allowfullscreen','true');
			*/
		}
		if (type == 'flash'){
			object.write('flashContent');
		} else {
			document.getElementById('flashContent').innerHTML = object;
		}
}
