function login()
{
	if(document.getElementById('login_all').style.display == 'block')
	{
		document.getElementById('login_all').style.display = 'none';
		if(document.getElementById('lang_all').style.display == 'block')
		{
			document.getElementById('location').style.display = 'none';
		}
		else
		{
			document.getElementById('location').style.display = 'block';
		}
	}		
	else
	{
		document.getElementById('login_all').style.display = 'block';
		document.getElementById('location').style.display = 'none';
	}
}

function anxlang()
{
	if(document.getElementById('lang_all').style.display == 'block')
	{
		document.getElementById('lang_all').style.display = 'none';
		if(document.getElementById('login_all').style.display == 'block')
		{
			document.getElementById('location').style.display = 'none';
		}
		else
		{
			document.getElementById('location').style.display = 'block';
		}
	}
	else
	{
		document.getElementById('lang_all').style.display = 'block';
		document.getElementById('location').style.display = 'none';
	}
}

function generate_country_list()
{
	c_sel = document.getElementById('banner_country');
	c_sel.length = 0;
	country = "1010";
	if(readCookie("country") != null)
		country = readCookie("country");
	Country_tbl = Country_tbl.sort(compareName);
	
	for(i = 0; i < Country_tbl.length;i++)
	{
		c_sel.options[c_sel.options.length] = new Option (Country_tbl[i][1],Country_tbl[i][0]);
		 if(Country_tbl[i][0] == country && (Country_tbl[i][3] != 'LU' || (Country_tbl[i][3] == 'LU' && readCookie("country_sel") == 'LU')))
			c_sel.options[c_sel.options.length - 1].selected = true;
	}
	generate_lang_list()
} 

function generate_lang_list()
{
	c_sel = document.getElementById('banner_country');
	l_sel = document.getElementById('banner_lang');
	
	l_sel.length = 0;
	lang_sel = c_sel.selectedIndex;

	for(i = 0; i < Country_tbl[lang_sel][2].length;i++)
	{
		Country_tbl[lang_sel][2].sort(compareLang);
		text = Country_tbl[lang_sel][2][i];
		for(j = 0; j < Lang_tbl.length; j++)
		{
			if(Country_tbl[lang_sel][2][i] == Lang_tbl[j][0])
			text = Lang_tbl[j][1];
		}
		l_sel.options[l_sel.options.length] = new Option (text,Country_tbl[lang_sel][2][i]);
		if(readCookie("anxlang") != null)
		{		
			if(Country_tbl[lang_sel][2][i].toUpperCase() == readCookie("anxlang").toUpperCase())
			l_sel.options[l_sel.options.length - 1].selected = true;
		}
	}
}
function compareName(a,b)
{
    a1 = a[1].toLowerCase();
    b1 = b[1].toLowerCase();
    if(escape(a1.substring(0,1)) == '%u0142'){
    if("l" < b1.substring(0,1))return -1;
    else return 1;
    }
	if(a1 < b1)
	return -1;
	else		
	return 1;	
}

function compareLang(a,b)
{
	a1 = a;
	b1 = b;
	for(j = 0; j < Lang_tbl.length; j++)
	{
		if(a == Lang_tbl[j][0])
			a1 = Lang_tbl[j][1];
		if(b == Lang_tbl[j][0])
			b1 = Lang_tbl[j][1];
	}
	if(a1 < b1)
		return -1;
	else		
		return 1;
}

function change_lang()
{
	document.Language._lang.value = document.getElementById('banner_lang').value;
	document.Language._cid.value = document.getElementById('banner_country').value;
	
	lang_sel = document.getElementById('banner_country').selectedIndex;
	
	
	document.getElementById('country_flag').src = '../img/flag_'+Country_tbl[lang_sel][3]+'.gif';
	document.getElementById('country_name').innerHTML = Country_tbl[lang_sel][1];
	
	for(i = 0; i < Lang_tbl.length;i++)
	{		
		if(Lang_tbl[i][0] == document.getElementById('banner_lang').value)
			document.getElementById('lang_name').innerHTML = Lang_tbl[i][1];
	}

	eraseCookie("country");
	createCookie("country",document.getElementById('banner_country').value);
		
	eraseCookie("anxlang");
	createCookie("anxlang",document.getElementById('banner_lang').value);	
	
	eraseCookie("country_sel");
	createCookie("country_sel",Country_tbl[lang_sel][3]);

	//window.location.href ='/default.aspx?_lang='+document.getElementById('banner_lang').value+'&_cid='+document.getElementById('banner_country').value;
	var oldLocation = window.location.href;
	var pathSegments = oldLocation.split('/');
	
	/*
	pathSegments[pathSegments.length - 2] = document.Language._lang.value;
	pathSegments[pathSegments.length - 1] = 'WebCheckInLogin.aspx';
	var newLocation = new String();
	for (var i = 0; i < pathSegments.length; i++) {
	    newLocation += pathSegments[i];
	    if (i < pathSegments.length - 1) {
	        newLocation += '/';
	    }
	}
	*/
	var newLocation = new String();
	// https: /    / redesign.devlot.anixe.pl
	//  [0]    [1]            [2]
	var hostPos = 2;
	for (var i = 0; i <= hostPos; i++)
	{
	    newLocation += pathSegments[i] + '/';
	}
	newLocation += 'default.aspx';
	
	//var appPath = oldLocation.substr(0, oldLocation.lastIndexOf('/'));
	window.location.href = newLocation + '?_lang=' + document.getElementById('banner_lang').value + '&_cid=' + document.getElementById('banner_country').value;
}

function set_default_lang()
{
	lang_sel = document.getElementById('banner_country').selectedIndex;
	
	document.getElementById('country_flag').src = '../img/flag_'+Country_tbl[lang_sel][3]+'.gif';
	document.getElementById('country_name').innerHTML = Country_tbl[lang_sel][1];
	
	for(i = 0; i < Lang_tbl.length;i++)
	{		
		if(Lang_tbl[i][0] == document.getElementById('banner_lang').value)
			document.getElementById('lang_name').innerHTML = Lang_tbl[i][1];
	}
}


function select_menu(id)
{
	for(i = 1; i < tbl_page.length;i++)
	{
		n = tbl_page[i].length;			
		for(j = 1; j < n; j++)
		{		
			if(parseFloat(tbl_page[i][j]) == parseFloat(id))
			{
				document.getElementById('menu_'+i+'_'+j).className = 'level2 sel';
				for(k = 1; k < n; k++)
				{
					document.getElementById('menu_'+i+'_'+k).style.display = 'block';
				}
			}
		}
	}     
}

function set_menu(k)
{                
	for(i = 1; i <= 12; i++)
	{                            
		for(j = 0; j < tbl[i];j++)
		{                                    
			if(i == k)
			{
				document.getElementById('menu_'+i+'_'+(j+1)).style.display = 'block';
			}
			else
			{
				document.getElementById('menu_'+i+'_'+(j+1)).style.display = 'none';
			}
		}
	}
}

function set_top_name(t1,l1,t2,l2,t3,l3,t4,l4)
{
	if(t1 != '' && (l1 == null || l1 == ''))
	{
		l1 = '#';
	}
	if(t2 != '' && (l2 == null || l2 == ''))
	{
		l2 = '#';
	}
	if(t3 != '' && (l3 == null || l3 == ''))
	{
		l3 = '#';
	}
	if(t4 != '' && (l4 == null || l4 == ''))
	{
		l4 = '#';
	}
	text = '';
	header = t1;
	
	if(t2 != '' && t2 != null)
		header = t2;
	if(t3 != '' && t3 != null)
		header = t3;
	if(t4 != '' && t4 != null)
		header = t4;
	
	if(t4 != '' && t4 != null)
		text += '&#160;>&#160;<a href="'+l4+'">' + t4 +'</a>';
	if(t3 != '' && t3 != null)
		text += '&#160;>&#160;<a href="'+l3+'">' + t3 +'</a>';
	if(t2 != '' && t2 != null)
		text += '&#160;>&#160;<a href="'+l2+'">' + t2 +'</a>';
	if(t1 != '' && t1 != null)
		text += '&#160;>&#160;<a href="'+l1+'">' + t1 +'</a>';
	
	try
	{
		document.getElementById('top_dir1').innerHTML = header;
	}
	catch(e){}
	document.getElementById('banner_dir1').innerHTML = text;
}
	
function check_emailFormat(email) 
{
	invalid = " /:,;";
	if(email == "") { return false }
	for(i=0; i < invalid.length; i++)
	{
		bad = invalid.charAt(i);
		if (email.indexOf (bad, 0) != -1) { return false }
	}
	at = email.indexOf("@", 0);
	if( (at == -1) || (at == 0) ) { return false }
	if(email.indexOf("@", at+1) != -1) { return false }
	period = email.indexOf(".", at);
	if( (period == -1) || (period == at+1) ) { return false }
	if(period+3 > email.length == -1) { return false }
	return true;
}

function anxLogout()
{
	var loc = window.location.pathname;
	if(loc.indexOf("Portal") != -1)
	{
		var lang = loc.substring(8,10);         
	}
	else
	{
		var lang = document.Language._lang.value;   
	}
	var country = readCookie("country");
	if(!readCookie("country"))
	{
		country = '1010';
	}
	location.replace('/Default.aspx?_cmd=LOT_IBE_Logout&_lang='+lang+'&_cid='+country);
}

function anxLogin(user, pass, remember)
{
	var loc = window.location.pathname;
	n = loc.indexOf("Portal");
	var lang = 'pl';
	if(n != -1)
	{
		lang = loc.substring(n+2,n+4); 
		document.Login._lang.value = lang;        
	}
	
	document.Login.login.value = user;
	document.Login.password.value = pass;
	if(remember)	
	document.Login.rememberme.value = remember;	
	document.Login.submit()
}
function findBannerCookie(nazwa)
{
	return readCookie(nazwa);
}
function eraseCookie(name)
{
    try
    {
    document.cookie = name+'=; expires=Fri, 27 Jul 2001 02:47:11 UTC; path=/'
    }
    catch(e){createCookie(name,"",-1);}
}
function createCookie(name,value)
{
	ToDay=new Date(); 
	ToDay.setTime(Expires = (24*60*60*1000*365) + ToDay.getTime()); 
	Expires= (ToDay.toGMTString()); 
	document.cookie = name+"="+value+"; path=/;EXPIRES="+Expires;
}
function eraseCookiePath(name,path)
{
	createCookiePath(name,"",-1,"");
}
function createCookiePath(name,value,date,path)
{
	document.cookie = name+"="+value+"; path=/"+path+";EXPIRES="+date;
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function check_cookie()
{
	if(document.cookie == '')
	document.getElementById('content').innerHTML = 'wlacz obsluge cookie';
}
function setFliFo()
{
 var ie = 0; ns = 0; gecko = 0; opera = 0;
 var agent = navigator.userAgent;
 var browser = navigator.appName;
 var version = parseInt(navigator.appVersion);
 agent = agent.toLowerCase();
 browser = browser.charAt(0);
 if (agent.indexOf('gecko') != -1) {gecko = true;}
 if (agent.indexOf('opera') != -1) {opera = true;}
 if (browser=="N" && version < 5) {ns = true;} else {ie = true;}
 ns6 = (navigator.vendor == ("Netscape6") || navigator.product == ("Gecko"));
 var mainDate = new Date(); 
 mainDate.setDate(mainDate.getDate()-2)  
 for(i = 0; i<=2;i++)
 {
  mainDate.setDate(mainDate.getDate()+1)
  var MM = parseFloat(mainDate.getMonth()) + parseFloat(1)
  if(MM < 10){MM = '0'+MM;}
   dd = mainDate.getDate();
  if(dd < 10){dd = '0'+dd;}
  if(ns || ns6 || opera)
   var yyyy = mainDate.getYear() + 1900;
  else
   var yyyy = mainDate.getYear();
  date = dd + '.' + MM + '.' + yyyy; 
  yyyy =  String(yyyy).substring(2,4);    
  text = dd + '.' + MM + '.' + yyyy;    
  document.getElementById('FliFo').options[document.getElementById('FliFo').options.length] = new Option (text,date);
 }
 document.getElementById('FliFo').options[1].selected = true;
}
function set_dates()
{
 Form = document.flightForm;
 dd = Form.date.options[Form.date.selectedIndex].value.substring(0,2);    
 MM = Form.date.options[Form.date.selectedIndex].value.substring(3,5);
 yyyy = Form.date.options[Form.date.selectedIndex].value.substring(6,10);
 Form.dd.value = dd;
 Form.MM.value = MM;
 Form.yyyy.value = yyyy;
}
function Flight_submit()
{
 Form = document.flightForm;
 var number = Form.flight_number.value;
 
 if(number.substring(0,2) == 'LO' || number.substring(0,2) == 'lo' || number.substring(0,2) == 'Lo' || number.substring(0,2) == 'lO')
  number = Form.flight_number.value.substring(2)
 
 if(isFinite(number) && number != '' && number.length > 0)
 {                
  Form.flight_number.value = number;
  Form.submit()
 }
 else
 {                                    
    document.getElementById('flight_number').className = "label error";
 }  
}