var player_has_been_loaded = false;
var player_is_loaded = false;
var player_client_opera;
var player_client_mac;
var player_show;
var player_no_wmp;

function player_build(){

	var container = document.getElementById("PlayerContainer");
	if (typeof(container) == 'Undefined'){

		return false;
	}
	else{
		
		container.innerHTML = '<OBJECT ID="Player" height="65" width="230" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"></OBJECT>';
		container.style.display = '';
		
		return true;
	}
}

function player_load(){

	player_client_mac = navigator.appVersion.indexOf("Mac")>-1
	player_client_opera = navigator.userAgent.indexOf("Opera")>-1
	//IE5+ required, netscape, macs, and opera are not supported
	if(player_client_mac){
		player_show = false;
	}else if (navigator.appName == "Netscape" || player_client_opera) {
		player_show = false;
	} else {
		player_show = true;
	}
	player_no_wmp = false;
	if (player_show) {
//		document.write('<table width="200" cellpadding="0" cellspacing="0" border="0" id="PlayerTable"><tr><td>');
//		document.write('<OBJECT ID="Player" height="64" width="200" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">');
//		document.write('</OBJECT>');
//		document.write('</td></tr></table>');
		player_build();
		if(typeof(document.getElementById("Player")) != "object" || document.getElementById("Player").versionInfo == null)
		{
			player_no_wmp = true;
			document.getElementById("PlayerContainer").style.display = "none";
		}
		else{
			player_is_loaded = true;
		}
	}
	player_has_been_loaded = true;
}

function play_sample(SampleURL){
	if (!player_has_been_loaded){
		player_load();
	}
	if (player_is_loaded){
		document.getElementById("Player").URL = SampleURL;
	}
	else{
		document.location.href = SampleURL;
	}
//	if(player_client_mac)
//		document.location.href = "/cgi-bin/playsample.cgi?type=wma&" + SampleURL;
//	else if(player_client_no_wmp)
//		document.location.href = "/cgi-bin/playsample.cgi?omplayer=1&type=wma&" + SampleURL;
//		//window.open('/retail/wmprequired.asp', 'wmp9', 'height=200,width=373,resizable=1,location=0,status=0,scrollbars=0,menubar=0,titlebar=0,toolbar=0').focus();
//	else if(player_client_show_player)
//		document.getElementById("Player").URL = "/cgi-bin/playsample.cgi?type=wma&" + SampleURL;
//	else
//		document.location.href = "/cgi-bin/playsample.cgi?type=wma&" + SampleURL;
}

function play_video(VideoURL, player, captiontext){
	/**
	
	 
        <div id="player">Клипа се зарежда...</div>

        <script type="text/javascript">
                var so = new SWFObject('{url}/flash_flv_player/flvplayer.swf{/url}','mpl','640','480','7');
                so.addParam('allowfullscreen','true');
                so.addVariable('displayheight','480');
                so.addVariable('file','{$part.video_url}');
                so.addVariable('height','480');
                so.addVariable('width','640');
                so.addVariable('autostart','true');
                so.addVariable('shuffle','false');
                so.addVariable('usecaptions','false');
                so.write('player');
        </script>

	
	*/
 modal=true;
 var myConfirmDialog=
 '<div id="player" style="width: 640px; height: 480px;">Клипа се зарежда...</div>';
/*
 * Modify the styling appropriately for your site
 */
overlib(myConfirmDialog, EXCLUSIVEOVERRIDE,
 CAPTION, captiontext, CLOSECLICK, CLOSETEXT,'затвори [x]',
 TEXTPADDING,10,  FGCLASS,'asd',BGCLASS,'modalPlayerBG',CGCLASS,'modalPlayerCG',CAPTIONFONTCLASS,'modalPlayerCG',CLOSEFONTCLASS,'modalPlayerCG', BORDER,2,
 
 modal?MODAL:DONOTHING,
 WRAP, STICKY, EXCLUSIVE, SCROLL, MIDX,0, MIDY,0);
 
	var so = new SWFObject(player,'mpl','640','480','7');
	so.addParam('allowfullscreen','true');
	so.addVariable('displayheight','480');
	so.addVariable('file',VideoURL);
	so.addVariable('height','480');
	so.addVariable('width','640');
	so.addVariable('autostart','true');
	so.addVariable('shuffle','false');
	so.addVariable('usecaptions','false');
	so.write('player');
 
}