// Inicjalizacja skryptow
function init()
{
  prepend();
  initLightbox();
  winOnLoad();
}

// Popup
function imgshow(url, width, height)
{
  leftPosition = (screen.width) ? (screen.width-width) / 2 : 100;
  topPosition = (screen.height) ? (screen.height-height) / 2 : 100;
  var win = window.open(url,'showpic','width=' + width + ',height=' + height + ',top=' + topPosition + ',left=' + leftPosition + ',resizable=0,scrollbars=no,menubar=no,toolbar=no,status=no');
}

function ChangeAttribute( elem, attr, value )
{
	elem.attr = value;
}

function prepend()
{
  document.cookie = "screenWidth="+ screen.width;
  document.cookie = "screenHeight="+ screen.height;
  var leftMarg = (screen.width/2)-100;
  var topMarg = (screen.height/3);
  if( $('error-layer') )  {
    document.getElementById( 'error-layer' ).style.left = leftMarg+'px';
    document.getElementById( 'error-layer' ).style.top = topMarg+'px';
    new Draggable( 'error-layer' );
  }
  if( $('info-layer') )  {
		document.getElementById( 'info-layer' ).style.left = leftMarg+'px';
		document.getElementById( 'info-layer' ).style.top = topMarg+'px';
		new Draggable( 'info-layer' );
  }
}

// Zamykanie banera
function closeBanner()
{
  document.getElementById('floater').style.visibility="hidden";
  document.getElementById('floater').style.display="none";
  document.getElementById('topbanner').style.visibility="visible";
}

// Zamykanie banera
function closeSkyscraper()
{
  document.getElementById('floater2').style.visibility="hidden";
  document.getElementById('floater2').style.display="none";
  document.getElementById('towerbanner').style.visibility="visible";
}

// Zamykanie banera
function closeScroller()
{
  document.getElementById('floater3').style.display="none";
}

// Funkcje do "latajacych" banerow {{{
var slideTime = 700;
var topMargin1, topMargin2;
var height;
function winOnLoad()
{
  // do banera
  topMargin1 = xPageY('topbanner');
  topMargin1 = topMargin1 - 15;
  // do scrollera
  topMargin3 = 500;
  height = getHeight();
  topMargin3 = height - 55;
  winOnResize(); // set initial position
  xAddEventListener(window, 'resize', winOnResize, false);
  xAddEventListener(window, 'scroll', winOnScroll, false);
  return;
}

function winOnResize()
{
  height = getHeight();
  topMargin3 = height - 55;
  // do banera
  xMoveTo('floater', xPageX('topbanner'), topMargin1);
  xShow('floater');
  // do scrollera
  xMoveTo('floater3', 0, topMargin3);
  xShow('floater3');
  winOnScroll(); // initial slide
}

function winOnScroll()
{
  // do banera
  xSlideTo('floater', xLeft('floater'), xScrollTop() + topMargin1, slideTime);
  // do scrollera
  xSlideTo('floater3', xLeft('floater3'), xScrollTop() + topMargin3, slideTime);
}

function setSlideTime(st) {
  st = parseInt(st);
  if (!isNaN(st)) slideTime = st;
  var e = xGetElementById('st');
  e.value = st;
  return false;
}

function getWidth()
{
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function getHeight()
{
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function BlurLogin()  {
	if( $( 'inpLog' ).value == '' )  {
		$( 'inpLog' ).value = 'login';
	}
	return flase;
}

function BlurPass()  {
	if( $( 'inpPas' ).value == '' )  {
		$( 'inpPas' ).value = 'hasło';
	}
	return false;
}

// }}}