// JavaScript Document
	var currentPosition;
	var currentVolume;
	var currentItem;
	var currentState;
	var totalTime;
	
	

	// these functions are caught by the JavascriptView object of the player.
		function sendEvent(typ,prm)
		{ 
			if(''!=typ && ''!=prm)
			{
				if(thisMovie("mpl"))
				   thisMovie("mpl").sendEvent(typ,prm); 
				else
				   window.document["mpl"].sendEvent(typ,prm); 
			}
		};
	
	//getUpdate method ---------------------------------------
	function getUpdate(typ,pr1,pr2,pid)
	{
		//alert(typ+" "+pr1+" "+pr2+" "+pid);
		var timeNow    = getCurrentTime();
		var timeNowStr = '';
		if(timeNow < 60)
		{
			if(timeNow < 10 )
				timeNow = '0'+timeNow;  
			timeNowStr = '0:'+timeNow;	
		}
		else if(timeNow > 60)
		{
			var mins   = 	Math.floor(timeNow / 60) ;
			var secs   = 	timeNow % 60 ;
			if(secs < 10 )
			{
				secs = '0'+secs;  
			}
			timeNowStr = mins+':'+secs;				
		}
		
//get total time		
		if(typ == "time")  
		{ 
				currentPosition = pr1;
				if(pr1 == 0 && pr2 != 0)
			{
		     total_len = pr2;
				 total_len_str='0:00';
						if(total_len < 60)
					{
						 if(total_len < 10 )
						 total_len = '0'+total_len;  
						 total_len_str = '0:'+total_len;	
					}
					else if(total_len > 60)
					{
						 var mins   = 	Math.floor(total_len / 60) ;
						 var secs   = 	total_len % 60 ;
						if(secs < 10 )
					 {
						 secs = '0'+secs;  
					 }
						total_len_str = mins+':'+secs;				
				}
	    }
		}
		setLengthValue(timeNow);
		
		if(typ == "time")        { 
										currentPosition = pr1;
										if(pr1 == 0 && pr2 != 0)
										{
											 totalTime = pr2;
										}			 
						    		}
		else if(typ == "volume")  { 
		                               currentVolume = pr1; 
		                          }
		else if(typ == "state")  { 
			                            currentState = pr1;
										if( currentState == 3 ) { 
											var imgObj = document.getElementById('vid_action');
											var imgSrc = imgObj.getElementsByTagName( 'img' )[ 0 ].src  ;	
											var replaceName = imgSrc.replace(/pause_video.png/, "play_video.png") ; 
											
											imgObj.innerHTML = '<a href="javascript:void(0);" onClick="javascript:ShowPlayPauseAction(0)"><img src="'+replaceName+'" border="0"></a>'; 
										}
		                         }
		else if(typ == "item")	 { 
		                               currentItem = pr1; 
									   setTimeout("getItemData(currentItem)",100);
								  }
//get total time and currunt time 		
		document.getElementById('showPlayTime').innerHTML = '<span class="style1">'+timeNowStr+'/ '+total_len_str+'</span>';
		
		//var id = document.getElementById(typ);
		//pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
		
	};

	// These functions are caught by the feeder object of the player.
	function loadFile(obj)    {  thisMovie("mpl").loadFile(obj); };
	function addItem(obj,idx) {  thisMovie("mpl").addItem(obj,idx); }
	function removeItem(idx)  {  thisMovie("mpl").removeItem(idx); }
	function getItemData(idx) {
		/*var obj = thisMovie("mpl").itemData(idx);
		var nodes = "";
		for(var i in obj) { 
			nodes += "<li>"+i+": "+obj[i]+"</li>"; 
		}*/
		//document.getElementById("data").innerHTML = nodes;
	};

	// This is a javascript handler for the player and is always needed.
	function thisMovie(movieName) {
	    if(navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName];
		} else {
			return document[movieName];
		}
	};

	// custom function written by me
	/*
	function playStopVideo() 
	{
	    sendEvent('playpause');
		
	};
	function startPlaying() 
	{
		var startPlayTime = document.getElementById('startPlayTime');
		sendEvent('scrub',startPlayTime.value);
		sendEvent('playpause');
	};
	
	function getCurrentstatus() 
	{
		var playpause1state = document.getElementById('playpause1state');
		if(currentState>0)
			playpause1state.value = "Playing";
		else
			playpause1state.value = "Stopped";
	};
	*/
	function startPlaying(act) 
	{
		
		if(currentState == 0)
		{
			alert("First play the video!");
			return 0;
		}
		
		if(act == 1 && (currentPosition + 2) > 0 && (currentPosition + 2) < totalTime)
		{
			sendEvent('scrub', (currentPosition + 2) );
		}
		else if (act == 0 && (currentPosition - 2) > 0 )
		{
			sendEvent('scrub', (currentPosition - 2) );
		}		
		else  if(  act == 0 && (currentPosition - 2) <= 0)
		{			  
		   sendEvent('scrub', 0 );
		}	
		else
			alert("You can not go beyond total time!");
			
			setLengthValue(currentPosition); 
			
	};
	
	function getCurrentTime() 
	{
		return currentPosition;		
	};
	
	function stopPlayVideo() 
	{
		sendEvent('playpause');
	};
	
	// New Function Created By pradip to change play pause image
	function stopPlayVideoNew() 
	{
		sendEvent('playpause');
	};
	var timeSet	=	0;
	function getPlayVideo() 
	{
			sendEvent('stop');
	};	
	
	function getTotalTime() 
	{

	       // do nothing
		   //sendEvent('playpause');
		   alert(pr1+pr2);	
	};
	
	function increamentVolume(currVol)
	{
			sendEvent('volume',currVol);
	};
	
	 
	function setLengthValue(val){
		
		var units ;
		units = Math.round(100/totalTime);
		timeinterval =2;
		
		cval = (val) * units;
		cval = Math.round(cval);
				
		if(cval <= 100)		
		if( typeof(s1) != 'undefined' )s1.setValue(cval);		
	};
	
	
