var iCache = 0;
var aCache = Array( );
function cOILoad( oObj, sImg, sImgO ){
  aCache[iCache] = new Image;
  aCache[iCache].src = sImgO;
  oObj.onmouseover = function(){ cOI( oObj, sImgO ) };
  oObj.onmouseout = function(){ cOI( oObj, sImg ) };
  iCache++;
}

function imgPreLoad( ){
  var iCount = imgPreLoad.arguments.length;
  for ( var i = 0; i < iCount; i++ ){
    aCache[iCache] = new Image;
    aCache[iCache].src = imgPreLoad.arguments[i];
    iCache++;
  }
}

function cOI( oObj, sImg ){
  oObj.src = sImg;
}

function windowNew( sAdres, iWidth, iHeight, sTitle, iReturn ){
  if ( !sTitle )
    sTitle = '';
  if( !iReturn )
    iReturn = false;

	if( !iWidth )
		var iWidth = 750;
	if( !iHeight )
		var iHeight = 530;

	if( +iWidth > 750 )
		iWidth = 750;
	else
		iWidth = +iWidth + 40;

	if( +iHeight > 530 )
		iHeight = 530
	else
		iHeight = +iHeight + 40;

	var iX = ( screen.availWidth - iWidth ) / 2;
	var iY = ( screen.availHeight - iHeight ) / 2;

  var refOpen = window.open( sAdres, sTitle, "height="+iHeight+",width="+iWidth+",top="+iY+",left="+iX+",resizable=yes,scrollbars=yes,status=0;" );
  
  if( iReturn == true )
  	return refOpen
}

function windowPhoto( sPhotoAdres, sTitle, sPageUrl, iReturn ){
	if( !sTitle )
		sTitle = 'Photo';
  if( !iReturn )
    iReturn = false;
  if( !sPageUrl )
    sPageUrl = '';

  var refFoto = window.open( sPageUrl + "window.php?p=showPhoto&adresFoto=" + sPhotoAdres + "&sPageTitle=" + sTitle, 'Photo', "heigth=500,width=700,top=20,left=20,resizable=yes,scrollbars=yes,status=0;" );

  if( iReturn == true )
  	return refOpen
}

function gEBI( objId ){
  return document.getElementById( objId );
}

function fix( f ){
	f	= f.toString( );
	var re	= /\,/gi;
	f	= f.replace( re, "\." );

	f = Math.round( f * 100 );
	f = f.toString( );
	var sMinus = f.slice( 0, 1 );
	if( sMinus == '-' ){
	 f = f.slice( 1, f.length )
	}
	else
	 sMinus = '';
	if( f.length < 3 ) {
		while( f.length < 3 )
			f = '0' + f;
	}

	var w = sMinus + f.slice( 0, f.length-2 ) + "." + f.slice( f.length-2, f.length );

  var poprawnyFloat = /^-?[0-9]{1,}[.]{1}[0-9]{1,}$/i;
	if( w.search( poprawnyFloat ) == -1 )
		w = '0.00';
	return w;

}

_bUa=navigator.userAgent.toLowerCase();
_bOp=(_bUa.indexOf("opera")!=-1?true:false);
_bIe=(_bUa.indexOf("msie")!=-1&&!_bOp?true:false);
_bIe4=(_bIe&&(_bUa.indexOf("msie 2.")!=-1||_bUa.indexOf("msie 3.")!=-1||_bUa.indexOf("msie 4.")!=-1)&&!_bOp?true:false)
isIe=function(){return _bIe;}
isOldIe=function(){return _bIe4;}
var olArray=[];

function AddOnload( f ){
  if( isIe && isOldIe ){
    window.onload = ReadOnload;
    olArray[olArray.length] = f;
  }
  else if( window.onload ){
    if( window.onload != ReadOnload ){
      olArray[0] = window.onload;
      window.onload = ReadOnload;
    }
    olArray[olArray.length] = f;
  }
  else
    window.onload=f;
}
function ReadOnload(){
  for( var i=0; i < olArray.length; i++ ){
    alert( olArray[i] );
    olArray[i]();
  }
}



//1
function ramkaOver1( oObj ){
  oObj.src =  'templates/img/menu/firma_02.gif';
}
function ramkaOut1( oObj ){
  oObj.src =  'templates/img/menu/firma_01.gif';
}

//2
function ramkaOver2( oObj ){
  oObj.src =  'templates/img/menu/portfolio_02.gif';
}
function ramkaOut2( oObj ){
  oObj.src =  'templates/img/menu/portfolio_01.gif';
}

//3
function ramkaOver3( oObj ){
  oObj.src =  'templates/img/menu/proces_02.gif';
}
function ramkaOut3( oObj ){
  oObj.src =  'templates/img/menu/proces_01.gif';
}

//4
function ramkaOver4( oObj ){
  oObj.src =  'templates/img/menu/kontakt_02.gif';
}
function ramkaOut4( oObj ){
  oObj.src =  'templates/img/menu/kontakt_01.gif';
}

//5
function ramkaOver5( oObj ){
  oObj.src =  'templates/img/menu/sklep_02.gif';
}
function ramkaOut5( oObj ){
  oObj.src =  'templates/img/menu/sklep_01.gif';
}

//Do góry
function ramkaOver6( oObj ){
  oObj.src =  'templates/img/do_gory_02.gif';
}
function ramkaOut6( oObj ){
  oObj.src =  'templates/img/do_gory_01.gif';
}