
function getPlayMedia( link, width, height ) {
	if( typeof(width) == 'undefined' )
		width = 290;
	if( typeof(height) == 'undefined' )
		height = 300;
	
	var WMP7;
	try {
		if ( navigator.appName != "Netscape" ) {
			WMP7 = new ActiveXObject('WMPlayer.OCX');
		}
	}
	catch (e) {}
	
	var HTML = '';
	// Windows Media Player 7 Code
	if ( WMP7 ) {
		HTML += ('<OBJECT height="'+ height +'" width="'+ width +'" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" VIEWASTEXT>');
		HTML += ('<PARAM NAME="URL" VALUE="'+ link +'">');
		HTML += ('<PARAM NAME="rate" VALUE="1">');
		HTML += ('<PARAM NAME="balance" VALUE="0">');
		HTML += ('<PARAM NAME="currentPosition" VALUE="0">');
		HTML += ('<PARAM NAME="defaultFrame" VALUE="">');
		HTML += ('<PARAM NAME="playCount" VALUE="999">');
		HTML += ('<PARAM NAME="autoStart" VALUE="1">');
		HTML += ('<PARAM NAME="currentMarker" VALUE="0">');
		HTML += ('<PARAM NAME="invokeURLs" VALUE="-1">');
		HTML += ('<PARAM NAME="baseURL" VALUE="">');
		HTML += ('<PARAM NAME="mute" VALUE="0">');
		HTML += ('<PARAM NAME="uiMode" VALUE="full">');
		HTML += ('<PARAM NAME="stretchToFit" VALUE="0">');
		HTML += ('<PARAM NAME="windowlessVideo" VALUE="1">');
		HTML += ('<PARAM NAME="enabled" VALUE="-1">');
		HTML += ('<PARAM NAME="enableContextMenu" VALUE="0">');
		HTML += ('<PARAM NAME="fullScreen" VALUE="0">');
		HTML += ('<PARAM NAME="SAMIStyle" VALUE="">');
		HTML += ('<PARAM NAME="SAMILang" VALUE="">');
		HTML += ('<PARAM NAME="SAMIFilename" VALUE="">');
		HTML += ('<PARAM NAME="captioningID" VALUE="">');
		HTML += ('<PARAM NAME="Volume" VALUE="100">');
		HTML += ('<PARAM NAME="wmode" VALUE="transparent">');
		HTML += ('</OBJECT>');
	}
	// Windows Media Player 6.4 Code
	else {
		HTML += ('<OBJECT classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" ');
		HTML += ('codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" ');
		HTML += ('width="'+ width +'" height="'+ height +'"');
		HTML += ('standby="Loading Microsoft Windows Media Player components..." ');
		HTML += ('type="application/x-oleobject" VIEWASTEXT> ');
		HTML += ('<PARAM NAME="FileName" VALUE="'+ link +'">');
		HTML += ('<PARAM NAME="TransparentAtStart" Value="false">');
		HTML += ('<PARAM NAME="AutoStart" Value="true">');
		HTML += ('<PARAM NAME="AnimationatStart" Value="false">');
		HTML += ('<PARAM NAME="ShowControls" Value="false">');
		HTML += ('<PARAM NAME="ShowDisplay" value ="false">');
		HTML += ('<PARAM NAME="playCount" VALUE="999">');
		HTML += ('<PARAM NAME="displaySize" Value="0">');
		HTML += ('<PARAM NAME="Volume" VALUE="100">');
		HTML += ('<PARAM NAME="wmode" VALUE="transparent">');
		HTML += ('<embed type="application/x-mplayer2" ');
		HTML += ('pluginspage= ');
		HTML += ('"http://www.microsoft.com/Windows/MediaPlayer/" ');
		HTML += ('src="'+ link +'" ');
		HTML += ('Name=MediaPlayer ');
		HTML += ('transparentAtStart=0 ');
		HTML += ('autostart=1 ');
		HTML += ('playcount=999 ');
		HTML += ('volume=100 ');
		HTML += ('wmode="transparent" ');
		HTML += ('animationAtStart=0 ');
		HTML += ('width="'+ width +'" height="'+ height +'" ');	
		HTML += ('displaySize=0></embed> ');
		HTML += ('</OBJECT> ');
	}
	return HTML;
}

function playObject( id, url, width, height ) {
	var flv = /\.flv$/i;
	var swf = /\.swf$/i;
	var el = (typeof(id)=="string")? $(id) : id;
	var ext = '<div style="text-align:right;">'
	+ '<a href="javascript:closePageVideo()" style="padding:3px;" title="close">'
	+ '<img border="0" src="images/icon_close.gif" alt="close" />'
	+ '</a>'
	+ '</div>'
	;
	
	if( flv.test(url) ) {
		var so = new SWFObject('images/mediaplayer.swf','MediaPlayer',width,height,'8');
		so.addParam('allowscriptaccess', 'always');
		so.addParam('allowfullscreen', 'true');
		so.addParam('allowscale', 'true');
		so.addParam('wmode', 'transparent');
		so.addVariable('file', url);
		so.addVariable('autostart', 'true');
		
		so.write(el, ext);
	}
	else if( swf.test(url) ) {
		var so = new SWFObject(url,'MediaPlayer',width,height,'8');
		so.addParam('allowscriptaccess','always');
		so.addParam('allowfullscreen','true');
		so.addParam('wmode','transparent');
		
		so.write(el, ext);
	}
	else {
		el.innerHTML = ext + getPlayMedia( url, width, height );
	}
}

function playVideo( url, width, height ) {
	disableBody( true );
	
	if( !$('lulo_play_video') ) {
		var objBody = document.getElementsByTagName("body").item(0);
		
		var objVideo = document.createElement("div");
		objVideo.id = 'lulo_play_video';
		objVideo.className = 'play_video';
		objBody.appendChild(objVideo);
	}
	var objVideo = $('lulo_play_video');
	
	var width 	= width? width : 480;
	var height 	= height? height : 360;
	var arrayPageSize = getPageSize();
	
	objVideo.style.top = ((arrayPageSize[3] - height) / 2 - 20) + 'px';
	objVideo.style.left = ((arrayPageSize[2] - width) / 2) + 'px';
	objVideo.style.display = 'block';
	
	playObject( objVideo, url, width, height );
}

function closePageVideo( url, width, height ) {
	disableBody( false );
	
	var objVideo = $('lulo_play_video');
	
	objVideo.style.top = '-1000px';
	objVideo.style.left = '-1000px';
	objVideo.style.display = 'none';
}
