/****************************************
*	Embed media with this small js object
*
*   Copyright © 2005-2006 Somalism.com,
*   All rights reserved
*   Author: Said (a.k.a Siciid)
*
*   Last mod.: 20 march 2006
****************************************************/


function vidObject(filename,height,width,mediaType,path) {

    this.mediaType= mediaType.replace("\n","");
    this.mediaType= this.mediaType.replace(/^\s*|\s*$/g,"");

    this.width=width;
    this.height=height;
    this.filename= filename.replace("\n","");
//  this.filename= this.filename.replace(/^\s*|\s*$/g,"");
    this.path=path;
    this.objectTag="";

//alert(this.path+this.filename+'.'+this.mediaType)

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
    this.checkIt = function(string){
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
	}

    this.init = function(){
      switch(this.mediaType) {
		case 'asx':  
        case 'wmv':
		case 'wmx':
		case 'mpg':
		case 'avi':
           this.objectTag+='<table align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td align="center" valign="top"> <table border="0" cellpadding="0" cellspacing="0"><tbody><tr> <td align="left" background="/media/videos/videoBox/bg_left.gif" valign="top" width="12"><img src="/media/videos/videoBox/edge_topleft-w.gif" height="25" width="12"></td><td rowspan="2" align="left" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr> <td align="left" background="/media/videos/videoBox/bg_top.gif" valign="top"><img src="/media/videos/videoBox/bg_top.gif" height="12" width="50"></td></tr><tr> <td align="center" bgcolor="#000000" valign="middle">';

			if(this.checkIt('firebird') || this.checkIt('opera')){
           	this.objectTag+='<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="mediaplayer1" showstatusbar="1" EnableContextMenu="false" autostart="true"  width="'+this.width+'" height="'+this.height+'"  transparentstart="1" loop="0" controller="true" src="'+this.path+this.filename+'.'+this.mediaType+'"></embed>';
				}
			else{			
           this.objectTag+='<object style="z-index:0" name="MediaPlayer" id="MediaPlayer" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'+this.width+'" height="'+this.height+'">';
           this.objectTag+='<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="mediaplayer1" showstatusbar="1" EnableContextMenu="false" autostart="true"  width="'+this.width+'" height="'+this.height+'"  transparentstart="1" loop="0" controller="true" src="'+this.path+this.filename+'.'+this.mediaType+'"></embed>';
           this.objectTag+='<param name="uiMode" value="none" /><!-- none, mini, full -->';
           this.objectTag+=' <param name="autoStart" value="True" />';
           this.objectTag+='<param name="URL" value="'+this.path+this.filename+'.'+this.mediaType+'" />';
           this.objectTag+='<PARAM NAME="ShowControls" VALUE="False">';
           this.objectTag+='<PARAM NAME="ShowPositionControls" VALUE="False">';
           this.objectTag+='<PARAM NAME="SendOpenStateChangeEvents" VALUE="True">';
           this.objectTag+='<PARAM NAME="ShowStatusBar" VALUE="True">';
           this.objectTag+='<PARAM NAME="stretchToFit" VALUE="True">';
           this.objectTag+='<PARAM NAME="windowlessVideo" VALUE="true">';
           this.objectTag+='<PARAM NAME="defaultFrame" VALUE="MediaPlayer">';
           this.objectTag+='<PARAM NAME="enableContextMenu" VALUE="true">';
           this.objectTag+='</object>';


	           this.objectTag+='</tr><tr bgcolor="black"><td align="center" class="vidButtons">';
	           this.objectTag+='<a href="javascript:void(0);" onclick="somalismVid(\'play\');return false;"><img src="/media/videos/videoBox/buttons/play.jpg" title="Baleey da fiidiyow"></a>';
	           this.objectTag+='<a href="javascript:void(0);" onclick="somalismVid(\'pause\');return false;"><img src="/media/videos/videoBox/buttons/pause.jpg" title="Boows da fiidiyow"></a>';
	           this.objectTag+='<a href="javascript:void(0);" onclick="somalismVid(\'stop\');return false;"><img src="/media/videos/videoBox/buttons/play_stop.jpg" title="istoop da fiidiyow"></a>';
	           this.objectTag+='<a href="javascript:void(0);" onclick="somalismVid(\'reverse\');return false;"><img src="/media/videos/videoBox/buttons/fast_rev.jpg" title="Faast Riferse"></a>';
	           this.objectTag+='<a href="javascript:void(0);" onclick="somalismVid(\'forward\');return false;"><img src="/media/videos/videoBox/buttons/fast_forward.jpg" title="Fast foorwar"></a>';
	           this.objectTag+='<a href="javascript:void(0);" onclick="somalismVid(\'hide\');return false;"><img src="/media/videos/videoBox/buttons/preferences.jpg" title="Show Kontorools"></a>';
	           this.objectTag+='<a href="javascript:void(0);" onclick="somalismVid(\'fullScr\');return false;"><img src="/media/videos/videoBox/buttons/fullscreen.jpg" title="Show fuul iskiriin"></a>';
	           this.objectTag+='<span style="vertical-align:top;padding-left:20px;color:red;font-size:18px;" id="loadbar"></span></td>';

			}
           this.objectTag+='</tr><tr> <td align="left" background="/media/videos/videoBox/bg_bottom.gif" valign="top"><img src="/media/videos/videoBox/bg_bottom.gif" height="13" width="50"></td></tr></tbody></table></td><td align="left" background="/media/videos/videoBox/bg_right_002.gif" valign="top" width="12"><img src="/media/videos/videoBox/edge_topright_002-w.gif" height="25" width="12"></td></tr><tr> <td align="left" background="/media/videos/videoBox/bg_left.gif" valign="bottom" width="12"><img src="/media/videos/videoBox/edge_botleft_002-w.gif" height="25" width="12"></td><td align="left" background="/media/videos/videoBox/bg_right_002.gif" valign="bottom" width="12"><img src="/media/videos/videoBox/edge_botright_002-w.gif" height="25" width="12"></td></tr></tbody></table>';
          break;

          case'swf':
	      this.objectTag+='<table align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td align="center" valign="top"> <table border="0" cellpadding="0" cellspacing="0"><tbody><tr> <td align="left" background="/media/videos/videoBox/bg_left.gif" valign="top" width="12"><img src="/media/videos/videoBox/edge_topleft-w.gif" height="25" width="12"></td><td rowspan="2" align="left" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr> <td align="left" background="/media/videos/videoBox/bg_top.gif" valign="top"><img src="/media/videos/videoBox/bg_top.gif" height="12" width="50"></td></tr><tr> <td align="center" bgcolor="#000000" valign="middle">';
          this.objectTag+='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+this.width+'" height="'+this.height+'">';
          this.objectTag+='<param name="movie" value="'+this.path+this.filename+'.'+this.mediaType+'" />';
          this.objectTag+='<param name="quality" value="high" />';
          this.objectTag+='<embed src="'+this.path+this.filename+'.'+this.mediaType+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+this.width+'" height="'+this.height+'"></embed>';
          this.objectTag+='</object>';
          this.objectTag+='</tr><tr> <td align="left" background="/media/videos/videoBox/bg_bottom.gif" valign="top"><img src="/media/videos/videoBox/bg_bottom.gif" height="13" width="50"></td></tr></tbody></table></td><td align="left" background="/media/videos/videoBox/bg_right_002.gif" valign="top" width="12"><img src="/media/videos/videoBox/edge_topright_002-w.gif" height="25" width="12"></td></tr><tr> <td align="left" background="/media/videos/videoBox/bg_left.gif" valign="bottom" width="12"><img src="/media/videos/videoBox/edge_botleft_002-w.gif" height="25" width="12"></td><td align="left" background="/media/videos/videoBox/bg_right_002.gif" valign="bottom" width="12"><img src="/media/videos/videoBox/edge_botright_002-w.gif" height="25" width="12"></td></tr></tbody></table>';
          break;


          case'mov':
          this.objectTag+='<table align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td align="center" valign="top"> <table border="0" cellpadding="0" cellspacing="0"><tbody><tr> <td align="left" background="/media/videos/videoBox/bg_left.gif" valign="top" width="12"><img src="/media/videos/videoBox/edge_topleft-w.gif" height="25" width="12"></td><td rowspan="2" align="left" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr> <td align="left" background="/media/videos/videoBox/bg_top.gif" valign="top"><img src="/media/videos/videoBox/bg_top.gif" height="12" width="50"></td></tr><tr> <td align="center" bgcolor="#000000" valign="middle">';	
          this.objectTag+='<object classid="clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b" width="'+this.width+'" height="'+this.height+'" codebase="http://www.apple.com/qtactivex/qtplugin.cab">\n';
          this.objectTag+='<param name="src" value="'+this.path+this.filename+'.'+this.mediaType+'">\n';
          this.objectTag+='<param name="autoplay" value="true">\n';
          this.objectTag+='<param name="controller" value="true">\n';
          this.objectTag+='<param name="scale" value="Aspect">\n';
          this.objectTag+='<param name="bgcolor" value="#000000">\n';
          this.objectTag+='<embed src="'+this.path+this.filename+'.'+this.mediaType+'" width="'+this.width+'" height="'+this.height+'" autoplay="true" bgcolor="#000000" scale="Aspect" controller="true" pluginspage="http://www.apple.com/quicktime/download/"></embed>\n';
          this.objectTag+='</object>\n';
          this.objectTag+='</tr><tr> <td align="left" background="/media/videos/videoBox/bg_bottom.gif" valign="top"><img src="/media/videos/videoBox/bg_bottom.gif" height="13" width="50"></td></tr></tbody></table></td><td align="left" background="/media/videos/videoBox/bg_right_002.gif" valign="top" width="12"><img src="/media/videos/videoBox/edge_topright_002-w.gif" height="25" width="12"></td></tr><tr> <td align="left" background="/media/videos/videoBox/bg_left.gif" valign="bottom" width="12"><img src="/media/videos/videoBox/edge_botleft_002-w.gif" height="25" width="12"></td><td align="left" background="/media/videos/videoBox/bg_right_002.gif" valign="bottom" width="12"><img src="/media/videos/videoBox/edge_botright_002-w.gif" height="25" width="12"></td></tr></tbody></table>';
          break;

       case 'ram':
       case 'rm':
	      this.objectTag+='<table align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td align="center" valign="top"> <table border="0" cellpadding="0" cellspacing="0"><tbody><tr> <td align="left" background="/media/videos/videoBox/bg_left.gif" valign="top" width="12"><img src="/media/videos/videoBox/edge_topleft-w.gif" height="25" width="12"></td><td rowspan="2" align="left" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr> <td align="left" background="/media/videos/videoBox/bg_top.gif" valign="top"><img src="/media/videos/videoBox/bg_top.gif" height="12" width="50"></td></tr><tr> <td align="center" bgcolor="#000000" valign="middle">';	
          this.objectTag+='<object id="myMovie" classid="CLSID:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="'+this.width+'" height="'+this.height+'" />\n';
          this.objectTag+='<param name="controls" value="ImageWindow" />\n';
          this.objectTag+='<param name="console" value="_master" />\n';
          this.objectTag+='<embed name="myMovie" src="'+this.path+this.filename+'.'+this.mediaType+'" width="'+this.width+'" height="'+this.height+'" nojava="true" controls="ImageWindow" console="_master" center="true" pluginspage="http://www.real.com/" /></embed></object><br>\n';
          this.objectTag+='<object id="myMovie" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="'+this.width+'" height="36" />\n';
          this.objectTag+='<param name="src" value="'+this.path+this.filename+'.'+this.mediaType+'" />\n';
          this.objectTag+='<param name="console" value="video2" />\n';
          this.objectTag+='<param name="controls" value="ControlPanel" />\n';
          this.objectTag+='<param name="autostart" value="true" />\n';
          this.objectTag+='<param name="loop" value="false" />\n';
          this.objectTag+='<embed name="myMovie" src="'+this.path+this.filename+'.'+this.mediaType+'" height="36" width="'+this.width+'" autostart="true" loop="tfalse" nojava="true" console="video2" controls="ControlPanel" /></embed>\n';
          this.objectTag+='<noembed><a href="'+this.path+this.filename+'.'+this.mediaType+'">Play Video clip in Realplayer</a></noembed>\n';
          this.objectTag+='</object />\n';
          this.objectTag+='</tr><tr> <td align="left" background="/media/videos/videoBox/bg_bottom.gif" valign="top"><img src="/media/videos/videoBox/bg_bottom.gif" height="13" width="50"></td></tr></tbody></table></td><td align="left" background="/media/videos/videoBox/bg_right_002.gif" valign="top" width="12"><img src="/media/videos/videoBox/edge_topright_002-w.gif" height="25" width="12"></td></tr><tr> <td align="left" background="/media/videos/videoBox/bg_left.gif" valign="bottom" width="12"><img src="/media/videos/videoBox/edge_botleft_002-w.gif" height="25" width="12"></td><td align="left" background="/media/videos/videoBox/bg_right_002.gif" valign="bottom" width="12"><img src="/media/videos/videoBox/edge_botright_002-w.gif" height="25" width="12"></td></tr></tbody></table>';
          break;

       case 'swf':
	      this.objectTag+='<table align="center" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td align="center" valign="top"> <table border="0" cellpadding="0" cellspacing="0"><tbody><tr> <td align="left" background="/media/videos/videoBox/bg_left.gif" valign="top" width="12"><img src="/media/videos/videoBox/edge_topleft-w.gif" height="25" width="12"></td><td rowspan="2" align="left" valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr> <td align="left" background="/media/videos/videoBox/bg_top.gif" valign="top"><img src="/media/videos/videoBox/bg_top.gif" height="12" width="50"></td></tr><tr> <td align="center" bgcolor="#000000" valign="middle">';
	      this.objectTag+='<object';
	      this.objectTag+='classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	      this.objectTag+='codebase="http://download.macromedia.com';
	      this.objectTag+='/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"';
	      this.objectTag+='width="'+this.width+'" height="'+this.height+'" id="movie" align="">';
	      this.objectTag+='<param name="movie" value="'+this.path+this.filename+'.'+this.mediaType+'">';
	      this.objectTag+='<embed src="'+this.path+this.filename+'.'+this.mediaType+'" quality="high" width="'+this.width+'"';
	      this.objectTag+='height="'+this.height+'" name="movie" align="" ';
	      this.objectTag+='type="application/x-shockwave-flash"';
	      this.objectTag+='plug inspage="http://www.macromedia.com/go/getflashplayer"> ';
	      this.objectTag+='</object>';
          this.objectTag+='</tr><tr> <td align="left" background="/media/videos/videoBox/bg_bottom.gif" valign="top"><img src="/media/videos/videoBox/bg_bottom.gif" height="13" width="50"></td></tr></tbody></table></td><td align="left" background="/media/videos/videoBox/bg_right_002.gif" valign="top" width="12"><img src="/media/videos/videoBox/edge_topright_002-w.gif" height="25" width="12"></td></tr><tr> <td align="left" background="/media/videos/videoBox/bg_left.gif" valign="bottom" width="12"><img src="/media/videos/videoBox/edge_botleft_002-w.gif" height="25" width="12"></td><td align="left" background="/media/videos/videoBox/bg_right_002.gif" valign="bottom" width="12"><img src="/media/videos/videoBox/edge_botright_002-w.gif" height="25" width="12"></td></tr></tbody></table>';
          break;



         case('ramAlt'):
          this.objectTag+='<p align="center"><embed src="'+this.path+this.filename+'.'+this.mediaType+'" width="'+this.width+'" height="'+this.height+'" type="audio/x-pn-realaudio-plugin" NOJAVA="true" AUTOSTART="true" LOOP="true" CONTROLS="ImageWindow" CONSOLE="hospital" />\n';
          this.objectTag+='<p align="center"><embed src="'+this.path+this.filename+'.'+this.mediaType+'" width="44" height="26" type="audio/x-pn-realaudio-plugin" NOJAVA="true" CONTROLS="playbutton" CONSOLE="hospital" />\n';
          this.objectTag+='<embed src="'+this.path+this.filename+'.'+this.mediaType+'" width="26" height="26" type="audio/x-pn-realaudio-plugin" NOJAVA="true" CONTROLS="stopbutton" CONSOLE="hospital" />\n';
          this.objectTag+='<embed src="'+this.path+this.filename+'.'+this.mediaType+'" width="192" height="26" type="audio/x-pn-realaudio-plugin" NOJAVA="true" CONTROLS="positionfield" CONSOLE="hospital" />\n';
          break;
		default:
		//alert(this.filename+"."+this.mediaType+"]");
		break;
        }
    }

    this.play = function() {
        return(this.objectTag);
    }
}

	var visible="false";


function somalismVid(action){
	//player.URL = "";
	//player.playState

	var player=document.getElementById('MediaPlayer');

	switch(action){

		case 'play':
        	player.controls.play();
			break;

		case 'pause':
       	player.controls.pause();
		//alert(player.controls.currentPosition);
		break;

		case 'stop':
        	player.controls.stop();
		break;

		case 'fullScr':
		if (player.playState == 3){ 
			player.uiMode ='full';
        	player.fullScreen = 'true';
			  }
		break;

		case 'reverse':
			if (player.controls.isAvailable('FastReverse'))
		        player.controls.fastReverse();
		break;

		case 'forward':
			if (player.controls.isAvailable('FastForward'))
		        player.controls.fastForward();
		break;


		case 'hide':
			if(visible=="false"){
        		player.uiMode ='full';
				visible="true";
				}
			else{
        		player.uiMode ='none';
				visible="false";
				}
		break;
	}


}

function pState(){
	var player=document.getElementById('MediaPlayer');
	var s=[6,7,11];

	if(s.inArray(player.playState))
		document.getElementById('loadbar').innerHTML='<blink>Fadlan, sug waxyar..<blink>';
	else 	document.getElementById('loadbar').innerHTML='';

//	document.getElementById('loadbar').innerHTML=Math.round(((player.controls.currentPosition / player.currentMedia.duration) * 100)) + '%';

}