window.setInterval("checkRefresh()", 1000);
var stronaValue;
function checkRefresh(){
	if(document.cookie!=''){
		cookieName='strona';
		strona=document.cookie.indexOf(cookieName);
		if (strona!="-1"){
			var theCookie=""+document.cookie;
			var ind=theCookie.indexOf(cookieName); 
			var ind1=theCookie.indexOf(';',ind);
			if (ind1==-1) ind1=theCookie.length; 
			oldStronaValue=stronaValue;
			stronaValue=unescape(theCookie.substring(ind+cookieName.length+1,ind1));
			if(oldStronaValue!=stronaValue){
				scroll(0,0);
			};
		};
	};
}


function grupoweReplace(elementID){
inputField=document.getElementById(elementID);
if (elementID=='wylot1'){
	inputFieldFiled=document.getElementById('cel12');
};
if (elementID=='cel1'){
inputFieldFiled=document.getElementById('wylot12');
};
if (inputField.value.length>2){
inputFieldFiled.value=inputField.value;
};

}

function Eventy(){
if (document.getElementById('data1')){
if (document.getElementById('data1').addEventListener){
document.getElementById('data1').getElementsByTagName('span')[0].addEventListener("click", trigeredRangeCalendar,false);
document.getElementById('data1').getElementsByTagName('span')[1].addEventListener("click", trigeredRangeCalendar,false);
for (var i=0; document.getElementById('data1').getElementsByTagName('div').length!=i; ++i){
	if(document.getElementById('data1').getElementsByTagName('div')[i].className=='day' || document.getElementById('data1').getElementsByTagName('div')[i].className=='weekendDay'){
		document.getElementById('data1').getElementsByTagName('div')[i].addEventListener("click", trigeredRangeCalendar,false);
	};
};
}
else if (document.getElementById('data1').attachEvent){
document.getElementById('data1').getElementsByTagName('select')[0].attachEvent("onchange", trigeredRangeCalendar,false);
document.getElementById('data1').getElementsByTagName('span')[0].attachEvent("onclick", trigeredRangeCalendar,false);
document.getElementById('data1').getElementsByTagName('span')[1].attachEvent("onclick", trigeredRangeCalendar,false);
for (var i=0; document.getElementById('data1').getElementsByTagName('div').length!=i; ++i){
	if(document.getElementById('data1').getElementsByTagName('div')[i].className=='day' || document.getElementById('data1').getElementsByTagName('div')[i].className=='weekendDay'){
		document.getElementById('data1').getElementsByTagName('div')[i].attachEvent("onclick", trigeredRangeCalendar,false);
	};
};
};
};
}
function wprowadzUwagi(what){
if (document.getElementById('popUwagiStyl')){
document.getElementById('popUwagiStyl').style.display="block";
document.getElementById('popUwagiStyl').style.visibility="visible";
};
if (document.getElementById('popUwagiStyl')==undefined){
	popUwagi=document.createElement('div');
	document.getElementById('formularz1').appendChild(popUwagi);
	popUwagiTitleText=document.createTextNode('Wprowadź swoje uwagi:');
	popUwagiTitle=document.createElement('span');
	popUwagi.appendChild(popUwagiTitle);
	popUwagiTitle.appendChild(popUwagiTitleText);
	popUwagi.setAttribute('id','popUwagiStyl');
	popUwagiBox=document.createElement('textarea');
	document.getElementById('popUwagiStyl').appendChild(popUwagiBox);
	popUwagiBox.setAttribute('name','uwagi');
	placeOfLink=findPos(document.getElementById('uwagiGrupowe'));
	if(document.styleSheets[0].cssText){
		topPos=placeOfLink[1]-500;
		leftPos=placeOfLink[0]-200;
	}
	else{
		topPos=placeOfLink[1]-300;
		leftPos=placeOfLink[0]-200;
	};
	popUwagi.style.top=topPos+'px';
	popUwagi.style.left=leftPos+'px';
	popUwagiBox.setAttribute('cols','35');
	popUwagiBox.setAttribute('rows','5');
	popUwagi.innerHTML=popUwagi.innerHTML+"<br/><input type='button' value='zapisz' onclick='wprowadzUwagi(\"hide\")'/>";
	//popSave=document.createElement('input');
	//popUwagi.appendChild(popSave);
	//popSave.setAttribute('type','button');
	//popSave.setAttribute('value','Zapisz');
	//popSave.setAttribute('onclick',"wprowadzUwagi('hide')");
	//zapisz=document.createTextNode('Zapisz');
	//popSave.appendChild(zapisz);
	
};
if (what=='hide'){
document.getElementById('popUwagiStyl').style.display="none";
document.getElementById('popUwagiStyl').style.visibility="hidden";
};
}

function displayHelp(content, ObjectId){
if (content=='kill'){
	for (var i=0; document.getElementsByTagName('div').length>i; ++i){
		if (document.getElementsByTagName('div')[i].className=='helpQuestion'){
			document.body.removeChild(document.getElementsByTagName('div')[i]);
		};
	};
}
else{
RN=0;
tresc=undefined;
obj=document.getElementById(ObjectId);
placeOfLink=findPos(obj);
RN=Math.floor(Math.random()*101);
RNT=Math.floor(Math.random()*101);
help[RN]=document.createElement('div');
tresc=document.createTextNode(content);
document.body.appendChild(help[RN]);
help[RN].appendChild(tresc);
help[RN].className='helpQuestion';
topPos=placeOfLink[1]-20;
leftPos=placeOfLink[0]+5;
help[RN].style.top=topPos+'px';
help[RN].style.left=leftPos+'px';
};
}
function findPos(obj) {
if(obj){
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} 
		while (obj = obj.offsetParent);
	return [curleft,curtop];
	};
};
}
function loaderFunction (){
if (document.getElementById("load")){
	document.getElementById("load").style.display="none";
	document.getElementById("loadInfo").style.display="none";
};
	document.getElementById("content").style.height=("2000px");
	scroll(0,0);
	
}
function hidedate() {
	document.getElementById("data2").style.display=('none');
	document.getElementById("data2").style.visibility=('hidden');
	document.getElementById("hiddenInput2").value="";
	// document.getElementById("date2label").style.display=('none');
	// document.getElementById("date2label").style.visibility=('hidden');
}
function showdate() {
	document.getElementById("data2").style.display=('block');
	document.getElementById("data2").style.visibility=('visible');
	// document.getElementById("date2label").style.display=('block');
	// document.getElementById("date2label").style.visibility=('visible');
}
function showlotniska() {
	document.getElementById("where_are_we").style.display=('block');
	document.getElementById("where_are_we").style.visibility=('visible');
}
function hidelotniska(){
	document.getElementById("where_are_we").style.display=('none');
	document.getElementById("where_are_we").style.visibility=('hidden');
}
function openDodatkowe(){
	document.getElementById("opendodatkowe").innerHTML=("<a href=\"#wyszukiwarka_lotow\" class=\"form_title\" onclick=\"closeDodatkowe()\" style=\"clear:left; float:left;\">Kliknij by zamknąć opcje dodatkowe</a>");
	document.getElementById('opcjedodatkowe').style.display=('block');
	document.getElementById('szukaj_air').style.top=('70px');
	document.getElementById('szukaj_air').style.left=('150px');
	document.getElementById('wyszukiwanie_podstawowe').innerHTML=('');
	document.getElementById('wyszukiwanie_zaawansowane').innerHTML=('<input type=\"image\" src=\"images/szukaj.gif\" name=\"Submit\" id=\"szukaj_air\" />');
	firstIEfix()
	//document.getElementById('addsomespace').innerHTML=('<br/><br/><br/><br/><br/><br/><br/>');
	starters();
}
function firstIEfix(){
var
ie=("Microsoft Internet Explorer");
	if (navigator.appName==ie) {
		//document.getElementById('moving').style.top=('84px');
		//document.getElementById('szukaj_air').style.margin=('-8px 0px 0px 0px');
	}
	else {
		//document.getElementById('moving').style.top=('113px');
		//document.getElementById('szukaj_air').style.margin=('-16px 0px 0px 0px');
	}
}
function closeDodatkowe() {
	document.getElementById("opendodatkowe").innerHTML=("<a href=\"#wyszukiwarka_lotow\" class=\"form_title\" onclick=\"openDodatkowe()\" style=\"clear:left; float:left;\">Kliknij by wyświetlić opcje klasy przelotu i wyboru linii lotniczej.</a>");
	document.getElementById('opcjedodatkowe').style.display=('none');
	//document.getElementById('moving').style.top=('0px');
	document.getElementById('szukaj_air').style.top=('0px');
	document.getElementById('szukaj_air').style.left=('0px');
	document.getElementById('wyszukiwanie_podstawowe').innerHTML=('<input type=\"image\" src=\"images/szukaj.gif\" name=\"Submit\" id=\"szukaj_air\" />');
		document.getElementById('wyszukiwanie_zaawansowane').innerHTML=('');
	//document.getElementById('addsomespace').innerHTML=('');
	starters();
}
function showcsapromo(){
document.getElementById("promocja_csa_window").style.visibility=("visible");
}
function hidecsapromo(){
document.getElementById("promocja_csa_window").style.visibility=("hidden");
}
function help(){
document.getElementById("main").style.visibility=('hidden');
document.getElementById("right_nav").style.visibility=('hidden');
document.getElementById("pomoc").innerHTML="<br/><br/><h1>Pomoc</h1><a style=\"float:right\" href=\"#\" onClick=\"close_help()\" name=\"Zamknij pomoc\">Zamknij pomoc</a><br/><br/><br/><br/><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus lectus. Etiam vitae pede. Proin ipsum. Donec a lacus laoreet est tempor lobortis. Quisque at risus. Donec lectus tellus, ultrices et, posuere id, varius sed, lacus. Sed rutrum dignissim felis. Suspendisse euismod. Nam purus augue, luctus in, fermentum ut, egestas quis, leo. Aliquam lorem. Maecenas in mi non orci bibendum blandit. Phasellus neque urna, ullamcorper eu, elementum vel, imperdiet nec, justo. Pellentesque viverra nibh tincidunt arcu. Nullam tempor egestas purus. In enim justo, pulvinar eleifend, varius et, varius eu, est. Ut aliquet. Etiam aliquet justo quis risus.</p><p>Curabitur eros velit, tempus a, dapibus non, porttitor rhoncus, augue. Cras mauris. Nulla facilisi. Vestibulum a mauris non diam auctor imperdiet. Suspendisse potenti. Nulla facilisi. Fusce ante ligula, lacinia eget, ullamcorper sed, egestas sed, nunc. Aliquam vulputate porta nisi. Mauris mauris mi, facilisis sed, vehicula eu, convallis vel, eros. Nulla luctus augue a mi. In mattis feugiat elit. Quisque quam justo, posuere ut, luctus et, dapibus dictum, nisi. Duis ac eros. Integer id augue. Quisque vulputate urna. Integer velit magna, suscipit non, porta ultricies, scelerisque sit amet, ligula.</p>";
document.getElementById("pomoc_tematy").innerHTML="<br\/><br\/><h1>Wybierz temat pomocy</h1><ul><li>temat 1</li><li>temat 2</li><li>temat 3</li><li>temat 4</li></ul>";
document.getElementById("pomoc_link").innerHTML="";
document.getElementById("pomoc").style.width=('540px');
document.getElementById("pomoc_tematy").style.width=('330px');
document.getElementById("pomoc_tematy").style.margin=('15px');
document.getElementById("pomoc").style.margin=('15px');
starters();

}

function close_help(){
document.getElementById("main").style.visibility=('visible');
document.getElementById("right_nav").style.visibility=('visible');
document.getElementById("pomoc").innerHTML="";
document.getElementById("pomoc_tematy").innerHTML="";
document.getElementById("pomoc_link").innerHTML="Pomoc";
document.getElementById("pomoc").style.width=('');
document.getElementById("pomoc_tematy").style.width=('');
document.getElementById("pomoc_tematy").style.margin=('');
document.getElementById("pomoc").style.margin=('');
starters();
}

function starters(){
if (document.getElementById('data1')){
ajax('yes', 'data1', 'hiddenInput1');
ajax('yes', 'data2', 'hiddenInput2');
};
var 
contentHeight=document.getElementById("content").offsetHeight;
topHeight=document.getElementById("top").offsetHeight;
windowWidth=document.body.offsetWidth;
//footer
z=contentHeight+topHeight;
y=(z+"px");
document.getElementById("footer").style.top=y;
document.getElementById("footer").style.visibility=("visible");
//positionOfmain=findPos(document.getElementById('main'));
//document.getElementById("footer").getElementsByTagName('p')[0].style.width=('900px');

if (windowWidth <= 1024) {
		document.getElementById("Global_Airline_Services").style.visibility=("hidden");
		
	}
else {};
/*if (windowWidth <= 1000) {
		document.getElementById("content").style.left=("0px");
		document.getElementById("top").style.left=("0px");
		document.getElementById("top").style.marginLeft=("0px");
		document.getElementById("content").style.marginLeft=("0px");
		document.getElementById("footer").style.width=(windowWidth);
	};*/
Eventy();
}
