function calculateY(){
	var posY = 0;
	if(document.documentElement && document.documentElement.scrollTop){
		posY = document.documentElement.scrollTop;
	} 
	else if(document.body && document.body.scrollTop) {
		posY = document.body.scrollTop;
	} 
	else if(window.pageYOffset) {
		posY = window.pageYOffset;
	} 
	else if(window.scrollY) {
		posY = window.scrollY;
	}
	return posY ;
}

function floatingbanner(bannerID, posTop){
	var banner = document.getElementById(bannerID);
	banner.style.top = calculateY()+ posTop + "px";
	window.setTimeout('floatingbanner("'+bannerID+'",'+posTop+')', 50);
}

function popBanner( Title, W,H, Type, Contents ){
    
	if(Get_Cookie(Title)) return;
	
	if(Type=='swf'){
		//var Contents = '<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\"  width=\"'+W+'\" height=\"'+H+'\">  <param name=\"movie\" value=\"'+Contents+'\"> <param name=\"quality\" value=\"high\"> <param name=\"wmode\" value=\"transparent\" /> <embed src=\"'+Contents+'" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"'+W+'\" height=\"'+H+'\"></embed> </object>';
		var theWin ="<div id='bannerPopup' class='bannerPopupSwf'>"+Contents+"</div>";
	}
	else{
		var theWin ="<div id='bannerPopup' class='bannerPopupImg'><div id='bannerPopupClose'><a href='javascript:closePopup()'>x</a></div><div id='bannerContent'>"+Contents+"</div></div>";
	}
	var width = W;
	var height = H;
	var windowHeight = getVisibleHeight();
	document.write(theWin);
	//littleWin.focus();
	if (document.documentElement && document.documentElement.scrollTop)	 theTop = document.documentElement.scrollTop;
	else theTop = document.body.scrollTop;	
	
	var objTop = (theTop+(windowHeight/2)-(height/2)-45);
	if(objTop<0) objTop = 50;
	
	var objLeft = (document.body.scrollLeft+((document.body.clientWidth)/2)-(width/2)-5);
	o('bannerPopup').style.left = objLeft+'px';
	o('bannerPopup').style.top = objTop+'px';
	
	floatingbanner('bannerPopup', objTop); 
	
	Set_Cookie(Title, 1);
}

function closePopup(){
	o('bannerPopup').style.display = "none";
}

var today = new Date();
var zero_date = new Date(0,0,0);
today.setTime(today.getTime() - zero_date.getTime());
var cookie_expire_date = new Date(today.getTime() + (8 * 7 * 86400000)); 

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
	}
	
	
	
function getVisibleHeight(Width, Height) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function o(identyfikator) {
	return document.getElementById(identyfikator);
}

