//-------------------------------------
//FUNKCJE------------------------------
//-------------------------------------
//podpinanie działania do zdarzenia----
function abManageEvent(eventObj,event,eventHandler)
{	if(eventObj.addEventListener) 
	{	eventObj.addEventListener(event,eventHandler,false);
	}
	else if(eventObj.attachEvent)
	{	event="on"+event;
		eventObj.attachEvent(event,eventHandler);
	}
}
//-------------------------------------

//funkcja do pobierania wysokości i szerokości obiektu body
function abGetBodySize()
{	sizeOfWindow=new Array(2);
	if (typeof window.innerWidth!='undefined')
	{	sizeOfWindow[0] = window.innerHeight;
		sizeOfWindow[1] = window.innerWidth;
	}
	else
	{	if (document.documentElement &&
			typeof document.documentElement.clientWidth!='undefined' && 
			document.documentElement.clientWidth!=0)
		{	sizeOfWindow[0] = document.documentElement.clientHeight;
			sizeOfWindow[1] = document.documentElement.clientWidth;
		}
		else 
		{	if (document.body && typeof document.body.clientWidth!='undefined')
			{	sizeOfWindow[0] = document.body.clientHeight;
				sizeOfWindow[1] = document.body.clientWidth;
			}
		}
	}
	return sizeOfWindow;
}
//-------------------------------------

//funkcja do wyświetlania elementu na środku
function centerIt(element_to_center,size_of_contener)
{	alert(element_to_center.style.height+' '+element_to_center.style.width);
}

//funkcja do wyświetlania overlay'a----
function abShowWindow()
{	size_of_window=abGetBodySize();
	size_of_body=document.body.clientHeight;
	background_of_element=document.createElement('div');
	background_of_element.id='ab_background';
	background_of_element.style.height=((size_of_body>size_of_window[0]) ? (size_of_body+50) : (size_of_window[0]+250))+'px';
	background_of_element.style.width=size_of_window[1]+'px';
	
	content_of_element=document.createElement('div');
	content_of_element.id='ab_content';
	content_of_element.style.height='500px';
	
	content_of_element.style.top=((500>size_of_window[0]) ? 0 : parseInt((size_of_window[0]-500)/2))+'px';
	content_of_element.style.left=((594>size_of_window[1]) ? 0 : parseInt((size_of_window[1]-594)/2))+'px';
	
	content='<div style="float:left"><img src="images/ab_cmc2.jpg" /></div>'+
			'<img id="ab_cross" src="images/ab_cross.gif" title="ZAMKNIJ" /><div style="float:left;width:297px;text-align:center;padding: 140px 0px;">'+
			'<div style="padding: 0px 10px;">'+
			'Z PRZYJEMNOŚCIĄ INFORMUJEMY,<br />ŻE ESTER HOTEL OTRZYMAŁ<br />PRESTIŻOWĄ REKOMENDACJĘ<br />PRZEWODNIKA MICHELIN 2010<br /><br /><br />'+
			'WITH PLEASURE WE INFORM<br />THAT THE ESTER HOTEL HAS RECEIVED<br />THE MICHELIN GUIDE 2010<br />PRESTIGIOUS RECOMMENDATION  '+
			'</div></div>'+
			'<div style="clear:both"></div>';
	content_of_element.innerHTML=content;
	
	
	if(document.getElementById('ab_background'))
	document.body.removeChild(document.getElementById('ab_background'));
	document.body.appendChild(background_of_element);
	document.body.appendChild(content_of_element);
	
	abManageEvent(document.getElementById('ab_background'),'click',function()
	{	document.body.removeChild(document.getElementById('ab_background'));
		document.body.removeChild(document.getElementById('ab_content'));
	});
	abManageEvent(document.getElementById('ab_content'),'click',function()
	{	document.body.removeChild(document.getElementById('ab_background'));
		document.body.removeChild(document.getElementById('ab_content'));
	});
}
//-------------------------------------

//
//-------------------------------------

//
//-------------------------------------
abManageEvent(window,'load',function()
{	abShowWindow();
});

abManageEvent(window,'resize',function()
{	if(!document.getElementById('ab_background'))
	return;
	size_of_window=abGetBodySize();
	size_of_body=document.body.clientHeight;
	background_of_element.style.height=((size_of_body>size_of_window[0]) ? (size_of_body+50) : (size_of_window[0]+250))+'px';
	background_of_element.style.width=size_of_window[1]+'px';
	content_of_element.style.top=((500>size_of_window[0]) ? 0 : parseInt((size_of_window[0]-500)/2))+'px';
	content_of_element.style.left=((594>size_of_window[1]) ? 0 : parseInt((size_of_window[1]-594)/2))+'px';
});