////////////////////////////////////////////////////////////////////////////////////
//
//    eValdo PopWMpl_Musicalia_Lib.js
//
////////////////////////////////////////////////////////////////////////////////////


  window.onerror=null;

  var WMPVer = false;
  var is_WMP = false;
  var is_WMP64 = false;
  var is_WMP7up = false;
  var is_WMP_plugins=false;

  var SoundWin=null;
  var VideoWin=null;

  function KalbekEmb(spn,url,txtf,ntxteil)
  {
    CloseAllWindows();
    
    var str="";
    var iex=false;
    var BgCol='#000000';
    var LineCol='#444444';

    var agt    = navigator.userAgent.toLowerCase();
    is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); 

    var bname  = navigator.appName;
    var appVer = navigator.appVersion.toLowerCase();

    var is_opera=(agt.indexOf("opera")!=-1);

    var bname  = navigator.appName;
    var appVer = navigator.appVersion.toLowerCase();

    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    var iePos=appVer.indexOf('msie');

    if ( iePos!=-1 ) 
    {
      is_minor=parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
      is_major=parseInt(is_minor);
    }

    is_ie=(agt.indexOf("msie")!=-1) && !is_opera;

    var is_ie3=(is_ie && (is_major<4));

    var msie_vers_start=agt.indexOf("msie")+5;
    var msie_real_vers=parseFloat(agt.substring(msie_vers_start, msie_vers_start+3));

    var is_ie4=(is_ie && (is_major==4) && (msie_real_vers<5));
    var is_ie4up=(is_ie && (is_major>=4));

    var is_ie5=(is_ie && (is_major==4) && (agt.indexOf("msie 5.")!=-1));
    var is_ie5up=(is_ie && !is_ie3 && !is_ie4);

    var is_ie5_5  = (is_ie && (agt.indexOf("msie 5.5") !=-1)); 
    is_ie5_5up =(is_ie && is_minor >= 5.5);               

    x=128; y=128;

    if ( is_ie5_5up )
    {
      var objMediaPlayer;
    
      try 
      {
        objMediaPlayer = new ActiveXObject("MediaPlayer.MediaPlayer.1");
        is_WMP = true;
        is_WMP64 = true;
      }
    
      catch(objError) 
      {
        is_WMP = false;
        is_WMP64 = false;
      }
    
      if (is_WMP) 
      {
        try 
        {
          objMediaPlayer = new ActiveXObject("WMPlayer.OCX");
          is_WMP7up = true;
        }
      
        catch(objError) 
        {
          is_WMP7up = false;
        }
      }

      if ( is_WMP==false ) return;

      if (is_WMP7up)
      {
        WMPVer = "7up";
      }
      else WMPVer = "6.4";

      CurPlay=spn;
      scw=120; sch=0; swh=sch+ntxteil;  

      document.all[spn].style.visibility='visible'; 

      str=str+"<table border='0' cellpadding='0' cellspacing='0' width='122' bgcolor="+BgCol+" bordercolor=#ae824b>";

      str=str+"<tr><td width='100%' height='4' bgcolor='#dbc6ac' background='images/VirsJuosta.jpg'>";
      str=str+"</td></tr>";

      str=str+"<tr><td width='100%' height='12' align='center' bgcolor='#dbc6ac' background='images/PlFonas122.jpg'>";

      str=str+"<div class='StatusBar' ID='Laikas' align='center' ";
      str=str+"style='width:120; height:18; position:relative; left: 0; top: 0;'>";
      str=str+"</div>";

      str=str+"<div ID='Grojikas' align='center' style='width:120; height:"+swh+"; background-color:"+BgCol+"; position:relative; left: 0; top: 0;'>";

      str=str+"<OBJECT ID='eVPlay' Width="+scw+" Height="+sch+" ";

      if ( WMPVer=="6.4" ) 
      { 
        str=str+"classid='clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95'> ";

        str=str+"CODEBASE='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'  ";
        str=str+"standby='Loading Microsoft® Windows® Media Player components...'  ";
        str=str+"type='application/x-oleobject'>  ";

        str=str+"<PARAM NAME='FileName' VALUE="+url+"> ";
        str=str+"<PARAM NAME='ShowStatusBar' VALUE='0'> ";
        str=str+"<PARAM NAME='AutoStart' VALUE='True'> ";
        str=str+"<PARAM NAME='ShowControls' VALUE='0'> ";
        str=str+"<PARAM NAME='ShowDisplay' VALUE='0'> ";
        str=str+"<PARAM NAME='ShowStatusBar' VALUE='0'> ";
        str=str+"<PARAM NAME='AutoSize' VALUE='0'> ";
        str=str+"<PARAM NAME='AnimationAtStart' VALUE='True'> ";
        str=str+"<PARAM NAME='TransparentAtStart' VALUE='True'> ";
      } 
      else 
      {
        str=str+"classid='clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6'> ";
 
        str=str+"<param name='uiMode' value='none'> ";
        str=str+"<PARAM NAME='AutoStart' VALUE='true'> ";
  
        str=str+"<param name='url' value="+url+"> ";
      }
  
      str=str+"</OBJECT> ";

    str=str+'<script LANGUAGE="JavaScript" FOR="eVPlay" EVENT="PlayStateChange(NewState)"> ';
    str=str+'ChangeTime();';
    str=str+'</SCRIPT> ';  
    str=str+"</div>";

    str=str+"</td></tr>";

    str=str+"<tr><td width='100%' height='12' align='center' bgcolor='#dbc6ac' background='images/PlFonas122.jpg'>";

    str=str+"<div ID='Valdymas' align='center' style='width:122; height:"+swh+"; background-color:"+BgCol+"; position:relative; left: 0; top: 0;'>";
    str=str+"<table border='0' cellpadding='0' cellspacing='0' width='120' bgcolor="+BgCol+">";
    str=str+"<tr><td width='100%' height='12' bgcolor="+BgCol+" background='images/SlJuosta.jpg'>"
    str=str+"<span ID='Slider' class='butn' style='position:relative; left: 0; top: 0; width:116; height:12;'>";
    str=str+"<img src='images/slider.jpg' valign='middle' style='position:relative; left: 0; top: 1;' ";
    str=str+" id='Vert' onchange='' class='sliderHandle' type='x' width=4 height=10 alt='' border='0'>";
    str=str+"</span>";
    str=str+"</td></tr></table>";
    str=str+"</div>";

    str=str+"</td></tr>";

    str=str+"<tr><td width='100%' bgcolor="+BgCol+" align='center' background='images/PlFonas122.jpg'>"
    str=str+"<a href='#' onclick='PlayClick(); return false' style='cursor:hand;'>";
    str=str+"<span class='Play'>";
    str=str+"<img id=Play name='Play' src='images/garsas_n.gif' width=22 height=22 hspace=0 vspace=4 border=0 alt='Klausyti'";
//      str=str+"onmouseover='this.src=images/garsas_l.gif' onmouseout='this.src=images/garsas_n.jpg'";
    str=str+"></a></span>";
    str=str+"<a href='#' onclick='PauseClick(); return false' style='cursor:hand;'>";
    str=str+"<span class='Pause'>";
    str=str+"<img id=Pause name='Pause' src='images/pause_n.gif' width=22 height=22 hspace=0 vspace=4 border=0 alt='Pristabdyti'";
//      str=str+" onmouseover='this.src=images/pause_l.gif' onmouseout='this.src=images/pause_n.jpg'";
    str=str+"></a></span>";
    str=str+"<a href='#' onclick='StopClick(); return false' style='cursor:hand;'>";
    str=str+"<span class='Stop'>";
    str=str+"<img id=Stop name='Stop' src='images/stop_n.gif' width=22 height=22 hspace=0 vspace=4 border=0 alt='Stabdyti'";
//      str=str+"onmouseover='this.src=images/stop_l.gif' onmouseout='this.src='images/stop_n.jpg'";
    str=str+"></a></span>";
    str=str+"<a href='#' onclick='CloseDiv(); return false' style='cursor:hand;'>";
    str=str+"<span class='Close'>";
    str=str+"<img id=Close name='Close' src='images/close_n.gif' width=22 height=22 hspace=0 vspace=4 border=0 alt='Baigti'";
//      str=str+"onmouseover='this.src=images/close_l.gif' onmouseout='this.src=images/close_n.jpg'";
    str=str+"></a><span>";

    str=str+"</td></tr>";
    str=str+"<tr><td width='100%' height='4' bgcolor='#dbc6ac' background='images/ApatJuosta.jpg'>";
    str=str+"</td></tr></table>";

    document.all[spn].innerHTML=str;
    document.all[spn].style.visibility='visible';

    ValdasPlay=true;
    ChangeTime();

       return;
    } 

    var x=-96; var y=224;
    var pElement = document.getElementById(spn).offsetParent; 

    while ( pElement != document.body) 
    { 
      x += pElement.offsetLeft; 
//      y += pElement.offsetTop; 
      pElement = pElement.offsetParent; 
    } 
    
    strd=url.split("/")[0];                
    strf=url.split("/")[1];                

    str=strd+"&"+strf+"&"+x+"&"+y+"&"+txtf+"&"+ntxteil;
    SoundWin=window.open("PopWMplMusAudio.htm?"+str,"_PopWMPlM","statusbar=no, menubar=no, resize=yes");

    SoundWin.focus();
  }

  function RodykLange(url,x,y,txtt,txtf,ntxteil)
  {
    CloseVideoWin();

    strd=url.split("/")[0];                
    strf=url.split("/")[1];                

    str=strd+"&"+strf+"&"+x+"&"+y+"&"+txtt+"&"+txtf+"&"+ntxteil;
    VideoWin=window.open("PopWMplMusVideo.htm?"+str,"_PopWMPlM","statusbar=no, menubar=no, resize=yes");
    VideoWin.focus();
  }

  function CloseSoundWin() 
  {
    if ( SoundWin!=null && SoundWin.open ) SoundWin.close(); 
    SoundWin=null; 
  }

  function CloseVideoWin() 
  {
    if ( VideoWin!=null && VideoWin.open ) VideoWin.close(); 
    VideoWin=null; 
  }

  function CloseDiv()
  {          
    if ( CurPlay!=false || ValdasPlay!=false )
    {
      StopClick(); 
      CloseClick();

      document.all[CurPlay].innerHTML="";
//    if ( iex ) document.all[CurPlay].style.visibility='hidden';
      CurPlay=false;
      ValdasPlay=false;
    }
  }

  function CloseAllWindows()
  {
    CloseSoundWin();
    CloseVideoWin();
    CloseDiv();
  }
