// JavaScript Document
//obsolete 
var ie4 = document.all;
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all; 

// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
 if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

// * Dependencies * 
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');
// <div id="div1399" style="display: none; visibility: hidden;"> 
function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') {
			visStr = 'visible';
			//posStr = 'relative'; 
			disStr = 'block';// <--lepiej działa z IE 
		} 
		else if(visStr == 'hide') {
			visStr = 'hidden';
//			posStr = 'absolute';
			disStr = 'none';
		}
      }
      obj.visibility = visStr;
	//  obj.position = posStr;
	  obj.dispay = disStr;
    }
  }
}


// * Dependencies * 
// Przełącza warstwe miedzy stanami widoczna / niewidoczna 
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
// JavaScript/readable_MM_functions/showHideLayers()
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// repeat...
// UWAGA ID NAZWY NIEMOZE BY NUMEREM!!!!!
// Example: switchVisLayer(Layer1, Layer2);

function switchVisLayer (){
   var i, visStr, posStr, disStr, obj, args = switchVisLayer.arguments, con;
   for (i=0; i<(args.length); i++)
  {
    if ((obj = findObj(args[i])) != null)
    {
	  //obj = document.getElementById('div185');
	  if (ie4) var con1 = document.all(args[i]).innerHTML;
	  if (obj.style)
      {
        obj = obj.style;
 		visStr = obj.visibility;
        if(visStr == 'hidden') {
			visStr = 'visible';
			posStr = 'relative';
			disStr = 'block'
		} 
		else if(visStr == 'visible') {
			visStr = 'hidden';
			posStr = 'absolute';
			disStr = 'none';
		} else {
			alert("Nic nie pasuje");
		}
      }
	 // obj.position = posStr;
	  obj.visibility = visStr;
	  obj.display = disStr;

  }
  }
}

// * Dependencies * 
//TODO - nie działą poprawnie: chyba funkcja findObj działą tylko na layerach / divach ;/
// przełącza tło obiektu miedzy podanymi w menu
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj

//
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: img1.
// arg 2: img2.
// 
// Example: switchBgImg('bg','/images/left_menu_beck.jpg','/images/left_menu_beck2.jpg');

function switchBgImg (objName,img1,img2) 
{
    alert("obj " + objName + " " + img1 + " " + img2);
	if (obj = findObj(objName) != null)
    {
		bgStr (obj);
		bgStr = obj.background;
		alert (bgStr);
        if(bgStr == img1) {
			bgStr = img2;
		} 
		else if(bgStr == img2) {
			bgStr = img1;
		}
    }
}

// JavaScript Document
// Example:
// onMouseOver="toolTip('tool tip text here')";
// onMouseOut="toolTip()";
// -or-
// onMouseOver="toolTip('more good stuff', '#FFFF00', 'orange')";
// onMouseOut="toolTip()"; 
/*
MOVE this to the <body>:
<div id="toolTipLayer" style="position:absolute; visibility: hidden; border:1px solid black;font-size:10px;background-color:white"></div>
<script language="JavaScript"><!--
initToolTips(); //--></script>
*/
offsetX = 0;
offsetY = 20;
var toolTipSTYLE="";
function initToolTips()
{
  if(ns4||ns6||ie4)
  {
    if(ns4) toolTipSTYLE = document.toolTipLayer;
    else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
    else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
    if(ns4) document.captureEvents(Event.MOUSEMOVE);
    else
    {
      toolTipSTYLE.visibility = "visible";
      toolTipSTYLE.display = "none";
    }
    document.onmousemove = moveToMouseLoc;
  }
}
function toolTip(msg, fg, bg)
{
  if(toolTip.arguments.length < 1) // hide
  {
    if(ns4) toolTipSTYLE.visibility = "hidden";
    else toolTipSTYLE.display = "none";
  }
  else // show
  {
    if(!fg) fg = "#777777";
    if(!bg) bg = "#FFFFFF";
    var content =
    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg + 
    '"><td align="center"><FONT>&nbsp\;' + msg +
    '&nbsp\;</font></td></table></td></table>';
    if(ns4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
    if(ns6)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display='block'
    }
    if(ie4)
    {
      document.all("toolTipLayer").innerHTML=content;
      toolTipSTYLE.display='block'
    }
  }
}
function moveToMouseLoc(e)
{
  if(ns4||ns6)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else
  {
    x = event.x + document.body.scrollLeft;
    y = event.y + document.body.scrollTop;
  }
  toolTipSTYLE.left = x + offsetX;
  toolTipSTYLE.top = y + offsetY;
  return true;
}



