//
// (c) 2006 webActive group

function $(s_ID)
{
    return document.getElementById(s_ID);
}

function isset(s_VarName)
{
    return (typeof(window[s_VarName]) != 'undefined');
}

function isIE()
{
    var s_Browser = navigator.userAgent.toLowerCase();
    return (s_Browser.indexOf('msie') != -1 && s_Browser.indexOf('opera') == -1); 
}

function isOpera()
{
    var s_Browser = navigator.userAgent.toLowerCase();
    return s_Browser.indexOf('opera') != -1; 
}

function include(s_Filename)
{
    var o_Script = document.createElement('script');
    o_Script.src = s_Filename;
    o_Script.type = 'text/javascript';
    document.body.appendChild(o_Script);
}

function addEvent(target, event, func)
{
	if (target.addEventListener)
		target.addEventListener(event, func, false);
	else
		target.attachEvent('on' + event, func);
}

function addFlashObject(fileURL, objName, width, height, targetTag)
{
    var o_Flash = $(targetTag);
    
    o_Flash.innerHTML = '<object id = "' + objName + '" width = "' + width + 'px" height = "' + height + 'px" classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">'
                      + '    <param name = "allowScriptAccess" value = "sameDomain" />'
                      + '    <param name = "movie" value="' + fileURL + '" />'
                      + '    <param name = "loop" value="false" />'
                      + '    <param name = "menu" value="false" />'
                      + '    <param name = "quality" value="high" />'
                      + '    <embed name = "' + objName + '" src = "' + fileURL + '" swLiveConnect = "true" loop = "false" menu = "false" quality = "best" allowScriptAccess = "sameDomain" width = "' + width + 'px" height = "' + height + 'px" allowScriptAccess = "sameDomain" type = "application/x-shockwave-flash" pluginspage = "http://www.macromedia.com/go/getflashplayer"></embed>'
                      + ' </object>';
}


function getFlashObject(s_MovieName)
{
    if (window.document[s_MovieName]) 
    {
        return window.document[s_MovieName];
    }
    
    if (isIE() || isOpera())
    {
        if (document.embeds && document.embeds[s_MovieName])
        {
            return document.embeds[s_MovieName]; 
        }
    }
    else
    {
        return $(s_MovieName);
    }
}

function popUp(file, w, h)
{
  var xpos = (screen.availWidth / 2)-(w / 2) - 50;
  var ypos = (screen.availHeight / 2)-(h / 2);
  var okienko = window.open(file,'newWinodow','toolbar=0, statusbar=0, scrollbars=1 , location=0, width='+w+',height='+h+', left='+xpos+', top='+ypos);
  okienko.focus();
}

function winOpen(file,title,w,h)
{
  var look = '';
  var sbars = 0;
  var resize = 0;

  if(w > screen.availWidth)
  {
    w = screen.availWidth-30;
    sbars = 0;
    resize = 1;
  }
  if(h > screen.availHeight)
  {
    h = screen.availHeight-60;
    sbars = 0;
    resize = 1;
  }

  xpos = (screen.availWidth / 2)-(w / 2);
  ypos = (screen.availHeight / 2)-(h / 2);

  if(typeof(newWin)=='object')
  {
    if(!newWin.closed)
      newWin.resizeTo(w+10, h+29);
  }
  look = 'scrollbars='+sbars+', resizable='+resize+', width='+w+', height='+h+', left='+xpos+', top='+ypos;
  newWin = window.open(file,'newWinodow','toolbar=0,statusbar=0,location=0,'+look);
  newWin.document.write("<html><head><title>"+title+"</title></head>");
  newWin.document.write("<body leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0 marginwidth=0 marginheight=0 margin=0 BGCOLOR=#F2F1F1><img src=" +file+ " onClick='window.close();' border=0 />");
  newWin.document.write("</body></html>");
  newWin.focus();
  newWin.document.close();
} 

