////////////////////////////////////////////////////////////////////////////////////
//
//
//
////////////////////////////////////////////////////////////////////////////////////

var Valdas=null;
window.onerror=null;

var myPlugin="false";
var myPlugType="false";

var PopWin="false";
var popWinName="pop";
var PopWinIsOpen="false";

var SoundWin="false";
var SoundWinName="snd";
var SoundWinIsOpen="false";

var FoneSoundWin="false";
var FoneSoundWinName="EmbSnd";
var FoneSoundWinIsOpen="false";

var geras="false";
var browser = "oldAndInTheWay";
var bName = navigator.appName;
var bVersion = parseInt(navigator.appVersion);

if ( bName=="Netscape" ) 
{ 
  browser="ns";
  if ( bVersion>=3 ) geras="true";
} 
else 
{
  if ( bName=="Microsoft Internet Explorer" )
  {
    browser="ie";
    if ( bVersion>=4 ) geras="true";
  }
}

function brVersion() 
{
  if ( bName=="Netscape" ) 
  { 
    browser="ns";
    if ( bVersion>=3 ) geras="true";
  } 
  else 
  {
    if ( bName=="Microsoft Internet Explorer" )
    {
      browser="ie";
      if ( bVersion>=4 ) geras="true";
    }
  }
}

function Kalbek(WavFile,x,y,txt)
{ 
  CloseAllWindows();
  OpenSoundWin(WavFile,x,y,txt);
}

function Rodyk(WavFile,x,y,txt)
{ 
  CloseAllWindows();
  OpenVideoWin(WavFile,x,y,txt);
}

function OpenSoundWin(url,x,y,txt) 
{
  if ( browser=="ie" && bVersion>=4 )
  { 
    SoundWin=window.open("",SoundWinName,
      "resizable=no,scrollbars=no,menubar=no,width=162,height=80,left="+x+",top="+y); 

    SoundWin.document.open();

    SoundWin.document.write("<html><head><title>");
    SoundWin.document.write(txt);
    SoundWin.document.write("</title></head>");

    SoundWin.document.write("<body bgcolor='#dddddd'>");

    SoundWin.document.write("<center>");
    SoundWin.document.write("<embed src="); 

    SoundWin.document.write(url);

    SoundWin.document.write(" autostart=");
    SoundWin.document.write("True ");

    SoundWin.document.write("WIDTH='230' HEIGHT='44' ");

    SoundWin.document.write("controls='console' ");
    SoundWin.document.write("hidden=");
    SoundWin.document.write("False>");
    SoundWin.document.write("</center>");

    SoundWin.document.write("</body></html>");
    SoundWin.document.close();

    if ( SoundWin!="false" )
    {    
      if ( SoundWin.closed ) {} else
      {
        SoundWinIsOpen="true";
        if ( SoundWin.focus ) SoundWin.focus();
      }
    }	

    return;
  }

  if ( browser=="ns" && bVersion>=4 )
  { 
    myPlugin=navigator.plugins["LiveAudio"]; 

    if ( !myPlugin ) 
    {
      return;
    }

    myPlugType=myPlugin["audio/wav"]; 

    if ( !myPlugType || myPlugType.enabledPlugin!=myPlugin ) 
    {
      return;
    }

    SoundWin=window.open("",SoundWinName,
      "resizable=no,scrollbars=no,menubar=no,width=162,height=80,left="+x+",top="+y); 

    SoundWin.document.open();

    SoundWin.document.write("<html><head><title>");
    SoundWin.document.write(txt);
    SoundWin.document.write("</title></head>");

    SoundWin.document.write("<body bgcolor='#dddddd'>");

    SoundWin.document.write("<center>");
    SoundWin.document.write("<embed src="); 
    SoundWin.document.write(url);
    SoundWin.document.write(" WIDTH='144' HEIGHT='60'");
    SoundWin.document.write(" autostart=True");
    SoundWin.document.write(" hidden=False");
    SoundWin.document.write(" NAME='mysound' MASTERSOUND><br>");

    SoundWin.document.write("</center>");
    SoundWin.document.write("</body></html>");
    SoundWin.document.close();

    if ( SoundWin!="false" )
    {    
      if ( SoundWin.closed ) {} else
      {
        SoundWinIsOpen="true";
        if ( SoundWin.focus ) SoundWin.focus();
      }
    }	

    return;
  }

  if ( browser!="ie" )
  {
    SoundWin=window.open(url,SoundWinName,
      "resizable=no,scrollbars=no,menubar=no,width=162,height=108,left="+x+",top="+y);
  }
  else
  { 
    KalbekFone(url);
  }

  if ( SoundWin!="false" )
  {    
    if ( SoundWin.closed ) {} else
    {
      SoundWinIsOpen="true";
      if ( SoundWin.focus ) SoundWin.focus();
    }
  }	
}

function KalbekFone(WavFile)
{ 
  if ( browser=="ie" )
  {
    document.EmbSnd.document.open();

    SoundWin.document.write("<html><head><title>");
    SoundWin.document.write("Audio");
    SoundWin.document.write("</title></head>");

    document.EmbSnd.document.write("<body bgcolor='#dddddd'>");
    document.EmbSnd.document.write("<center>");

    document.EmbSnd.document.write("<embed src="); 
    document.EmbSnd.document.write(WavFile);
    document.EmbSnd.document.write(" autostart=");
    document.EmbSnd.document.write("True ");
    document.EmbSnd.document.write(" hidden=");
    document.EmbSnd.document.write("True>");
    document.EmbSnd.document.write("</center>");

    document.EmbSnd.document.write("</body></html>");
    document.EmbSnd.document.close();

    FoneSoundWin="true";
    FoneSoundWinIsOpen="true"; 
  }
  else 
  {
    document.EmbSound.play(false,WavFile);
  }
}

function OpenVideoWin(url,x,y,txt) 
{
  if ( browser=="ie" && bVersion>=4 )
  { 
    SoundWin=window.open("",SoundWinName,
    "resizable=no,scrollbars=no,menubar=no,width=340,height=320,left="+x+",top="+y); 

    SoundWin.document.open();

    SoundWin.document.write("<html><head><title>");
    SoundWin.document.write(txt);
    SoundWin.document.write("</title></head>");

    SoundWin.document.write("<body bgcolor='#111111'>");
    SoundWin.document.write("<center>");

    SoundWin.document.write("<embed src="); 
    SoundWin.document.write(url);
    SoundWin.document.write(" autostart=");
    SoundWin.document.write("True ");
    SoundWin.document.write("controls='console' ");
    SoundWin.document.write("hidden=");
    SoundWin.document.write("False>");

    SoundWin.document.write("</center>");
    SoundWin.document.write("</body></html>");
    SoundWin.document.close();

    if ( SoundWin!="false" )
    {    
      if ( SoundWin.closed ) {} else
      {
        SoundWinIsOpen="true";
        if ( SoundWin.focus ) SoundWin.focus();
      }
    }	

    return;
  }

  if ( browser=="ns" )
  { 
    return;
    
    SoundWin=window.open("",SoundWinName,
    "resizable=no,scrollbars=no,menubar=no,width=338,height=320,left="+x+",top="+y); 

    SoundWin.document.open();

    SoundWin.document.write("<html><head><title>");
    SoundWin.document.write(txt);
    SoundWin.document.write("</title></head>");

    SoundWin.document.write("<body bgcolor='#111111'>");

    SoundWin.document.write("<center>");
    SoundWin.document.write("<embed src="); 
    SoundWin.document.write(url);
    SoundWin.document.write(" autostart=");
    SoundWin.document.write("True ");
    SoundWin.document.write("controls='console' ");
    SoundWin.document.write("hidden=");
    SoundWin.document.write("False>");

    SoundWin.document.write("</center>");
    SoundWin.document.write("</body></html>");
    SoundWin.document.close();

    if ( SoundWin!="false" )
    {    
      if ( SoundWin.closed ) {} else
      {
        SoundWinIsOpen="true";
        if ( SoundWin.focus ) SoundWin.focus();
      }
    }	

    return;
  }
}

function CloseSoundWin() 
{
  if ( SoundWin!="false" )
  {                                
    if ( geras=="true" )   
    {
      if ( SoundWin.closed ) {} else
      {
        if ( SoundWinIsOpen=="true" )
          { SoundWin.close(); }
      }
    }
    else
    {
      SoundWin=window.open("",SoundWinName,
      "resizable=no,scrollbars=no,menubar=no,width=128,height=128");
      SoundWin.close();
    }
   
    SoundWinIsOpen="false"; SoundWin="false"; 
  }
}

function CloseFoneSoundWin() 
{
  if ( browser=="ie" && bVersion<4 )
  {
    document.EmbSnd.document.open();
    document.EmbSnd.document.write("<head><title>Close</title></head>");
    document.EmbSnd.document.write("<body> </body>");
    document.EmbSnd.document.close();

    FoneSoundWin="false";
    FoneSoundWinIsOpen="false";
  }
}

function OpenPopWin(url,x0,y0,x,y,mode,depend) 
{
  PopWin=window.open(url,popWinName,
    "dependent="+depend+",resizable=no,scrollbars=yes,menubar=no,width="+x+",height="+y+",left="+x0+",top="+y0);

  if ( PopWin!="false" )
  {    
    if ( PopWin.closed )  {} else
    {
      PopWinIsOpen="true";

      if ( mode>0 ) 
      {
        if ( PopWin.focus ) PopWin.focus();
      }
    }
  }	
}

function ClosePopWin() 
{
  if ( PopWin!="false" )
  {    
    if ( geras=="true" )   
    {
      if ( PopWin.closed ) {} else
      {
        if ( PopWinIsOpen=="true" )
          { PopWin.close(); }
      }
    }
    else
    {
      PopWin=window.open("",popWinName,
      "resizable=no,scrollbars=no,menubar=no,width=128,height=128");
      PopWin.close();
    }
    
    PopWinIsOpen="false"; PopWin="false";
  }
}

function CloseAllWindows() 
{
  if ( PopWin!="false" ) ClosePopWin(); 
  if ( SoundWin!="false" ) CloseSoundWin(); 
  if ( FoneSoundWin!="false" ) { if ( geras=="true" ) CloseFoneSoundWin(); }
}


