var
 playingObj = null,
 CHECK_INTERVAL = 500;

function updatePlayState()
{
 var
  plr = document.getElementById("playDiv").firstChild;

// alert("2. Inside play thread");
 if (plr.playState == 1)
 {
  setPlayingObj(null);
  return;
 }
// alert("3. Resetting play thread");
 setTimeout("updatePlayState()",CHECK_INTERVAL);
}

function onPlayingObjChanged(poldPlayingObj)
{
 var
  PlayList = document.getElementById("playDiv"),
  plr = PlayList.firstChild;

 if (poldPlayingObj != null)
 {
  poldPlayingObj.src = "img/bt_play_o.gif";
//  alert("pOldPlayingObj != null");
 }
 if (this.playingObj != null)
 {
  this.playingObj.src = "img/bt_stop.gif";
//  alert("this.playingObj != null");
 }
 else
 {
//  alert("Player controls stopped!");
  plr.controls.stop();
 }
}

function setPlayingObj(pplayingObj)
{
 var
  oldPlayingObj = this.playingObj;

 if (pplayingObj == this.playingObj)
  this.playingObj = null;
 else
  this.playingObj = pplayingObj;
 this.onPlayingObjChanged(oldPlayingObj);
}


function Getbrowser(objDiv,Str)
{
PlayList=document.getElementById("playDiv")
var objImage = objDiv.firstChild;
if(objImage.src == "img/bt_play_o.gif")
{
    PlayList.innerHTML = "";
    //PlayList.innerText = '';
return;
}
var browserName=navigator.appName;

//alert("0. Browser Name: "+browserName);
if(browserName=="Netscape")
{
    PlayList.innerHTML =" "
    PlayList.innerHTML += "<OBJECT CLASSID='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' WIDTH='0' HEIGHT='0' CODEBASE='http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0'><param name='src' value='" + Str + "'><PARAM name='AUTOPLAY' VALUE='true'><PARAM name=kioskmode value='false'><PARAM name=cache value='false'><PARAM name='CONTROLLER' VALUE='TRUE'><PARAM name='TYPE' VALUE='video/quicktime'><PARAM name='PLUGINSPAGE' VALUE='http://www.apple.com/quicktime/download/indext.html'><PARAM name='target' VALUE='myself'><embed width='0' height='0' src='" + Str + "' target='myself' controller='true' type='video/quicktime' autoplay='true' pluginspage='http://www.apple.com/quicktime/download/indext.html' cache=false kioskmode=false></OBJECT>";	 
   //alert(PlayList.innerHTML)    
}

else if(browserName=="Microsoft Internet Explorer")
{ 
    PlayList.innerHTML =" "
    PlayList.innerHTML += "<object id='player' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' type='application/x-oleobject' width='0' height='0'><param name='autoStart' value='true'><param name='enableContextMenu' value='false'><param name='enabled' value='true'><param name='URL' value='" + Str + "'></object>";
}

else if(browserName=="Safari")
{
	PlayList.innerHTML =" "
	PlayList.InnerHtml += "<OBJECT ID='quicktimemov' CLASSID='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' WIDTH='660' HEIGHT='500' CODEBASE='http://www.apple.com/qtactivex/qtplugin.cab'><PARAM name='qtsrc' VALUE='" + Str + "'> <PARAM name='AUTOPLAY' VALUE='true'><PARAM name='CONTROLLER' VALUE='true'><PARAM name='LOOP' VALUE='false'><EMBED src='Sample.mov' qtsrc='" + Str + "' pluginspage='http://www.apple.com/quicktime/download/' height='1' width='1' AUTOPLAY='true' LOOP='false' CONTROLLER='true' name='quicktimemov' scale='tofit' enablejavascript='true'></EMBED></OBJECT>"               
	
}
else
{
    PlayList.innerHTML =" "
    PlayList.InnerHTML += "<OBJECT ID='NSPlay WIDTH=0  HEIGHT=0	classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'	CODEBASE='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715'	standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'><PARAM NAME='FileName' VALUE='" + Str + "'><param name='Volume' value='-15'><Embed type='application/x-mplayer2'		pluginspage='http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&'	 src='" + Str + "'	Name=NSPlay	 ShowControls=1  ShowDisplay=0	ShowStatusBar=0	  width=0	 height=0> </embed></OBJECT>"
    //alert(  PlayList.InnerHTML )
}

//alert("1. Starting play thread");
window.setTimeout("updatePlayState();",CHECK_INTERVAL);
}

function ChangeAndStop(objImage)
{
 this.setPlayingObj(objImage);
}

/*
function ChangeAndStop(objImage)
{
   if(objImage.src == "http://www.vizsoftwares.com/site2/img/bt_play_o.gif")
    {
        var arrImageCollection = document.getElementsByTagName("img");
        for(var intCount=0;intCount<arrImageCollection.length;intCount++)
        {
            if(arrImageCollection[intCount].src=="http://www.vizsoftwares.com/site2/img/bt_stop.gif")
                arrImageCollection[intCount].src = "http://www.vizsoftwares.com/site2/img/bt_play_o.gif";
        }
        objImage.src = "http://www.vizsoftwares.com/site2/img/bt_stop.gif";
        
    }
    else
    {
        //PlayList=document.getElementById("playDiv");
        //PlayList.innerHTML = ' ';
        objImage.src = "http://www.vizsoftwares.com/site2/img/bt_play_o.gif";
        this.lastObjImage = objImage;
    }
}
*/