// dymki
/*
Graculini's Popup Engine - GPE v1.0
Copyright Gracjan Lech 2003.
Contact me: gracjan.lech@poczta.fm
This notice must remain untouched at all times.
*/

var cienX = 1;
var cienY = 1;
var cienKolor = '#aaaaaa';

function dostosuj(pX, pY, pKolor)
{
  var z = document.getElementById('info').scrollHeight;
  var tpX = 0;
  var tpY = 0;
  var sX = 0;
  pX++; pY++;
  
  //alert(navigator.userAgent + ', ' + navigator.userAgent.indexOf('IE'));
  
  if ((popupBorderWidth == 0) && (navigator.userAgent.indexOf('IE') > -1)) pX++;
  if ((textPadding > 0) && (navigator.userAgent.indexOf('IE') < 0))
  {
    pX -= 1;
    pY -= 1;
    tpX = textPadding + 1;
    tpY = textPadding - 1;
    sX = -1;
  }
  //pX += 2*textPadding;
  //pY += 2*textPadding;
  

  document.getElementById('main').style.height = z + pY + popupBorderWidth;
  document.getElementById('main').style.width = popupWidth + pX - 1;

  document.getElementById('info').style.width = popupWidth - (popupBorderWidth - 1);

  document.getElementById('shadow').style.height = z + pY;
  document.getElementById('shadow').style.top = popupBorderWidth + pY - 2;
  document.getElementById('shadow').style.left = popupBorderWidth + pX - 2;
  document.getElementById('shadow').style.width = popupWidth + 2*tpX + 2 + sX;
  document.getElementById('shadow').style.backgroundColor = pKolor;
}

function displayConfig() {
 //KONFIGURACJA START
 //Odstęp popup'a od kursora w poziomie
 if ((popupOffsetX=getValue("popupOffsetX"))==NA)
  popupOffsetX=15
 //Odstęp popup'a od kursora w pionie
 if ((popupOffsetY=getValue("popupOffsetY"))==NA)
  popupOffsetY=20
 //Położenie popup'a względem myszki
 if ((popupAlign=getValue("popupAlign"))==NA)
  popupAlign="center" //Inne opcje - left, center
 //Długość popup'a
 if ((popupWidth=getValue("popupWidth"))==NA)
  popupWidth=200
 if (getValue("popupv2"))
  popupWidth=390
 //Szerokość obramowania całego popup'a
 if ((popupBorderWidth=getValue("popupBorderWidth"))==NA)
  popupBorderWidth=1
 //Kolor obramowania popup'a
 if ((popupBorderColor=getValue("popupBorderColor"))==NA)
  popupBorderColor="#C7C7C7"
 //Styl obramowania popup'a (dotted, double...)
 if ((popupBorderStyle=getValue("popupBorderStyle"))==NA)
  popupBorderStyle="solid"
 //Domyślna przeźroczystość popup'a
 if ((popupOpacity=getValue("popupOpacity"))==NA)
  popupOpacity=97
 //Kolor czcionki nagłówka
 if ((captionColor=getValue("captionColor"))==NA)
  captionColor="Black"
 //Styl czcionki nagłówka
 if ((captionFontStyle=getValue("captionFontStyle"))==NA)
  captionFontStyle="normal"
 //Pogrubienie czcionki nagłówka
 if ((captionFontWeight=getValue("captionFontWeight"))==NA)
  captionFontWeight="bold"
 //Wielkość czcionki nagłówka
 if ((captionFontSize=getValue("captionFontSize"))==NA)
  captionFontSize="9px"
 //Czcionka nagłówka
 if ((captionFontFamily=getValue("captionFontFamily"))==NA)
  captionFontFamily="Verdana, sans-serif"
 //Wypełnienie ogólne
 if ((captionPadding=getValue("captionPadding"))==NA)
  captionPadding="0px";
 //Kolor tła nagłówka
 if ((captionBackgroundColor=getValue("captionBackgroundColor"))==NA)
  captionBackgroundColor=popupBorderColor
 //Tło nagłówka
 if ((captionBackgroundImage=getValue("captionBackgroundImage"))==NA)
  captionBackgroundImage=""
 //Dodatki do tła
 if ((captionBackgroundImageProperties=getValue("captionBackgroundImageProperties"))==NA)
  captionBackgroundImageProperties=""
 //Kolor czcionki tekstu
 if ((textColor=getValue("textColor"))==NA)
  textColor="Black"
 //Styl czcionki tekstu
 if ((textFontStyle=getValue("textFontStyle"))==NA)
  textFontStyle="normal"
 //Pogrubienie czcionki tekstu
 if ((textFontWeight=getValue("textFontWeight"))==NA)
  textFontWeight="normal"
 //Wielkość czcionki tekstu
 if ((textFontSize=getValue("textFontSize"))==NA)
  textFontSize="7pt"
 //Czcionka tekstu
 if ((textFontFamily=getValue("textFontFamily"))==NA)
  textFontFamily="Tahoma"
 //Wypełnienie ogólne
 if ((textPadding=getValue("textPadding"))==NA)
  textPadding=5;
 //Kolor tła tekstu
 if ((textBackgroundColor=getValue("textBackgroundColor"))==NA)
  textBackgroundColor="#FFFFBF"
 //Tło tekstu
 if ((textBackgroundImage=getValue("textBackgroundImage"))==NA)
  textBackgroundImage=""
 //Dodatki do tła 
 if ((textBackgroundImageProperties=getValue("textBackgroundImageProperties"))==NA)
  textBackgroundImageProperties=""
 //fadeIn
 if ((fadeIn=params.indexOf("fadeIn"))!=-1)
  fadeIn=true
 //Domyślny czas fadeIn
 if (fadeIn && ((fadeInTime=getValue("fadeInTime"))==NA))
  fadeInTime=1
 //fadeOut
 if ((fadeOut=params.indexOf("fadeOut"))!=-1)
  fadeOut=true
 //Domyślny czas fadeOut
 if (fadeOut && ((fadeOutTime=getValue("fadeOutTime"))==NA))
  fadeOutTime=1
 
 //DODATKOWE SZATY
 
 layout[1]="textBackgroundColor: #ffffe1; popupBorderColor: #000000; textFontFamily: verdana; textFontSize: 11px;"
 layout[2]="textFontStyle: italic;"
 
 //KONFIGURACJA KONIEC  
}

document.write("<div id=\"popupDiv\" style=\"position: absolute; display: none; z-index: 1000; filter: alpha(opacity=100); -moz-opacity: 1;\">GPE v1.1 - popup engine</div>")
popup=document.getElementById("popupDiv")
OP=NS=IE=false
if (navigator.userAgent.indexOf("Opera")!=-1) OP=true
else if (navigator.appName=="Netscape") NS=true
else if (navigator.appName=="Microsoft Internet Explorer") IE=true

function gpe(arguments) {
 fadingIn=false
 fadeOut=false
 params=arguments
 layout=new Array()
 captionClass=getValue("captionClass")
 caption=getValue("caption")
 textClass=getValue("textClass")
 text=getValue("text")
 popupLayout=getValue("popupLayout")
 if (popupLayout!=null) params+=grabLay()
 NA=null
 displayConfig()
 if (popupBorderColor==NA && captionBackgroundColor!=NA) popupBorderColor=captionBackgroundColor
 po=eval(popupOpacity)
 if (NS) NSpo=(po/100)
 if (textBackgroundImage!=null) textBackgroundImage="url('"+textBackgroundImage+"') "+textBackgroundImageProperties+""
 if (captionBackgroundImage!=null) captionBackgroundImage="url('"+captionBackgroundImage+"') "+captionBackgroundImageProperties+""


  //Przesuniecie cienia w prawo
  var shadowWidth = 3;
  // Przesuniecie cienia w dol
  var shadowHeight = 3;
  
  var popupWidthPadding = "";
  var tmp = 0;
  var l1 = 0;
  var mainWidth = 0;
  
  //mainWidth=popupWidth+shadowWidth+parseInt(textPadding.substr(0, textPadding.length - 2));
  mainWidth=popupWidth+shadowWidth+textPadding;

  l1 = textPadding;
  tmp = popupWidth + 2*l1;
  popupWidthPadding = tmp;
  
 popupContent="<div id = \"main\" style = \"width: " + mainWidth + "px; height: 0px; border: 0px;\">"
 popupContent+="<div id = \"info\" style=\"z-index: 101; position: absolute; border: " + popupBorderColor + " " + popupBorderWidth + "px " + popupBorderStyle + ";"
 popupContent+="color: " + textColor + "; font-family: " + textFontFamily + "; font-style: " + textFontStyle
 popupContent+="font-weight: " + textFontWeight + "; font-size: " + textFontSize
 popupContent+="; padding: " + textPadding + "px; width: "+popupWidth+"px; border: "+popupBorderWidth
 popupContent+=" "+popupBorderStyle+" "+popupBorderColor+"; background: " + textBackgroundColor + ";\">"
 popupContent+=text
 popupContent+="</div>"
 popupContent+="<div id = \"shadow\" style = \"z-index: 100; position: absolute; top: 0px; left: 0px; width: 0px; height: 0px; background: #0000ff;\">"
 popupContent+="</div>"

 if (NS) {
  content=document.createRange();
  content.setStartBefore(popup);
  content=content.createContextualFragment(popupContent);
  with (popup) {
   if (hasChildNodes()) removeChild(lastChild)
   appendChild(content)
  }
 }
 else popup.innerHTML=popupContent
 pO(po)
 if (IE) gpePos()
 document.onmousemove=function gpePos(evt) {
  if (NS) {
   coordX=evt.pageX
   coordY=evt.pageY
   winWidth=innerWidth
  }
  else {
   coordX=event.clientX+document.body.scrollLeft
   coordY=event.clientY+document.body.scrollTop
   winWidth=document.body.clientWidth
  }
  switch (popupAlign) {
   case "left" :
    if (coordX-popupWidth-popupOffsetX<0) coordX=popupWidth+popupOffsetX
     coordX-=popupWidth+(popupOffsetX*2)
   break
   case "center" :
    if (coordX+popupWidth/2>winWidth) {coordX=winWidth-popupWidth/2; popupOffsetX=0}
    if (coordX-popupWidth/2<0) {coordX=popupWidth/2; popupOffsetX=0}
    coordX-=popupWidth/2+popupOffsetX
   break
   case "right" :
    if (coordX+popupWidth+popupOffsetX>winWidth) coordX=winWidth-popupWidth-popupOffsetX
  }
  popup.style.left=coordX+popupOffsetX
  popup.style.top=coordY+popupOffsetY
 }
 popup.style.display="block"
 if (fadeIn==true) {
  pO(0)
  fade(1)
 }
 popup.style.display="block"
 document.onmouseout=function() {
  if (fadeOut==true) {
   if (fadeIn) fadeIn=false
   else pO(po)
   fade(2)
  }
  else popup.style.display="none"
 }
 
 dostosuj(cienX, cienY, cienKolor);
}
function getValue(keyWord) {
 with (params) {
  if (indexOf(keyWord+":")==-1) return
  keyInd=lastIndexOf(keyWord+":")
  value=substring(keyInd+(keyWord.length+1),indexOf(";",keyInd))
 }
 while (value.indexOf("|:|")!=-1) {
  with (value) {
   value=substring(0,indexOf("|:|"))+";"+substring(indexOf("|:|")+3)
  }
 }
 while (value.indexOf(" ")!=-1 && keyWord!="text" && keyWord!="caption") {
  with (value) {
   value=substring(0,indexOf(" "))+substring(indexOf(" ")+1)
  }
 }
 if (keyWord=="popupOffsetX" || keyWord=="popupOffsetY" || keyWord=="popupWidth") {
  value=eval(value)
 }
 return value
}
function grabLay() {
 layParam=displayConfig+""
 with (layParam) {
  layParam=substring(indexOf("layout["+popupLayout+"]"),indexOf(";\"",indexOf("layout["+popupLayout+"]"))+1)
 }
 return layParam;
}
function fade(num) {
 if (num==1 && fadeIn==true) {
  if (pO()!=po) {
   pO(2,"+")
   fadingIn=setTimeout("fade(1)",fadeInTime)
  }
  else fadeIn=false
 }
 if (num==2 && fadeOut==true) {
  if (pO()!=0) {
   pO(2,"-")
   fadingOut=setTimeout("fade(2)",fadeOutTime)
  }
  else {
   fadeOut=false
   if (NS==false && IE==false) popup.style.display="none"
  }
 }
}
function pO(oL,op) {
 if (IE) {
  with (popup.filters.alpha) {
   if (oL==NA) return opacity
   if (op==NA) opacity=oL
   if (op=="+") {
    if (opacity>=po) opacity=po
        else opacity+=oL
   }
   if (op=="-") opacity-=oL
  }
 }
 else if (NS) {
  with (popup.style) {
   if (oL==NA) return MozOpacity
   else oL=(oL/100)
   if (op==NA) MozOpacity=oL
   if (op=="+") {
    if (MozOpacity>=NSpo) MozOpacity=NSpo
    else MozOpacity=parseFloat(MozOpacity)+oL
   }
   if (op=="-") MozOpacity=parseFloat(MozOpacity)-oL
  }
 }
 else return false
}
// / dymki