
/*function mailVal(){
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms['alitalia'].elements['mail'].value;
   if(reg.test(address) == false) {
	return false;
   }
   return true;
}*/

function chgcol(elm, mode){
	if(mode==1){
		elm.style.backgroundColor='#CFEDFC';
	}else{
		elm.style.backgroundColor='#FFFFFF';
	}
	
}

function setdisbl(elid){
	if (elid.value=='country'){
		document.getElementById('kraje').disabled=false;		
		document.getElementById('miasta').disabled=true;
		document.getElementById('miasta').selectedIndex=0;
	}else{
		document.getElementById('kraje').disabled=true;
		document.getElementById('kraje').selectedIndex=0;
		document.getElementById('miasta').disabled=false;		
	}
}

function rozw (elem) {
 var elmarr=new Array('dtip', 'dtipr', 'dtop');
 for (var i=0; i<elmarr.length; i++){
	if(elem==elmarr[i]){
		if(document.getElementById(elem).style.display=='block'){
 			document.getElementById(elem).style.display="none";
		}else{
			document.getElementById(elem).style.display="block";
		}
	}else{
		document.getElementById(elmarr[i]).style.display="none";
	}
 }
}
function zmimg (elem ,mode, iname) {
 	var elSpan = document.getElementById(elem);
 	if (elSpan && mode==0) {
 		elSpan.src = 'ws/templates/lataj3/img/'+iname+'_2.png';
	}
	if (elSpan && mode==1) {
 		elSpan.src = 'ws/templates/lataj3/img/'+iname+'_1.png';
	}
}

function jump() {
location.href="#";
}

function splash(iddiv){
	document.getElementById(iddiv).style.display='block';	
	document.getElementById('lotlista').style.display='none'; 	
	jump();
}
function divh(){
	 var elmarr=new Array('dtip', 'dtipr', 'dtop');
	 var mode=0;
 	for (var i=0; i<elmarr.length; i++){
	if(document.getElementById(elmarr[i]).style.display=='block'){
		mode=1;
	}
	}
	if(mode==1){
	document.getElementById('dhotele').style.display='block';	
	document.getElementById('shotele').style.display='none'; 
	}else{
	document.getElementById('shotele').style.display='block';	
	document.getElementById('dhotele').style.display='none'; 
	}
}


var indico=0;
function chgimge(imgeid){
//alert(row.className);
if(String(imgeid.src).indexOf('2') != -1){
	indico=1;
}else{
	imgeid.src=String(imgeid.src).replace(/1/, "2");
}
}
function retrnimge(imgeid){
	if(indico==0){
imgeid.src=String(imgeid.src).replace(/2/, "1");
	}
	
	indico=0;
}

function showd (elem, nr) {
	var ub='ubezp';
	var tk='tkt';
	var rs='rstr';
	var pr='price';
	var inf='info';
var elmarr=new Array(ub+nr, tk+nr, rs+nr, pr+nr, inf+nr);
var idarr=new Array(ub, tk, rs, pr, inf);
var dv='dv'+nr;
for (var i=0; i<elmarr.length; i++){
	if(elem==elmarr[i]){
		if(document.getElementById(elem).style.display=='block'){
 			document.getElementById(elem).style.display="none";
			indico=0;
			//MM_swapImage(elem+'im','','templates/lataj3/img/'+idarr[i]+'_1.png',1);
		}else{
			document.getElementById(elem).style.display="block";
			//MM_swapImage(elem+'im','','templates/lataj3/img/'+idarr[i]+'_2.png',1);
			indico=1;
		}
	}else{
		document.getElementById(elmarr[i]).style.display="none";
		MM_swapImage(elmarr[i]+'im','','templates/lataj3/img/'+idarr[i]+'_1.png',1);
	}
}
}


function pok_date(){
 DayName = new Array(7) 
 DayName[0] = "niedziela " 
 DayName[1] = "poniedziałek " 
 DayName[2] = "wtorek " 
 DayName[3] = "środa " 
 DayName[4] = "czwartek " 
 DayName[5] = "piątek " 
 DayName[6] = "sobota "

 MonthName = new Array(12) 
 MonthName[0] = "01" 
 MonthName[1] = "02" 
 MonthName[2] = "03" 
 MonthName[3] = "04" 
 MonthName[4] = "05" 
 MonthName[5] = "06" 
 MonthName[6] = "07" 
 MonthName[7] = "08" 
 MonthName[8] = "09" 
 MonthName[9] = "10" 
 MonthName[10] = "11" 
 MonthName[11] = "12" 
 
 var Today = new Date() 
 var WeekDay = Today.getDay() 
 var Month = Today.getMonth() 
 var Day = Today.getDate() 
 var Year = Today.getFullYear() 

 if(Year <= 99) Year += 1900 
 
 return DayName[WeekDay] + "," + " " + Day + "." + MonthName[Month] + "." + Year;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}



function sprawdz_email(mail)
{
   if(!mail.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/))
      return false;
   else
      return true;
}

function opwind(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  var toolbar_str = toolbar;
  var menubar_str = menubar;
  var statusbar_str = statusbar;
  var scrollbar_str = scrollbar;
  var resizable_str = resizable;
  var newokno=window.open(url,name,'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str+'\'');
}

function subm(kod,miasto)
	{	
	if(parent.opener.document.p=='D')
		{
		parent.opener.document.forms[parent.opener.document.f].w_kod_d.value=kod; 
		parent.opener.document.forms[parent.opener.document.f].miasto_d.value=miasto; 
	}else	
	if(parent.opener.document.p=='Z')
		{
		parent.opener.document.forms[parent.opener.document.f].w_kod_z.value=kod;
		parent.opener.document.forms[parent.opener.document.f].miasto_z.value=miasto;
	}else{
		var kodz='w_kod_'+parent.opener.document.p;
		var cityz='miasto_'+parent.opener.document.p;
		parent.opener.document.forms[parent.opener.document.f].elements[kodz].value=kod;
		parent.opener.document.forms[parent.opener.document.f].elements[cityz].value=miasto;		
	}
	
	parent.self.close();
	}

function otworz(p,path,f)
{
document.p = p;
document.f = f;
	
	noweOkno = window.open(path+'atlas.multi.php'+'?p='+p+'&f='+f, 'win', 'menubar=no, toolbar=no, location=no, scrollbars=auto, resizable=no, status=no, width=590, height=300',p);
}






function in_array(needle, haystack){
	var len=haystack.length;
	for ( var x=0; x<=len; x++ ) {
		if ( haystack[x]==needle ) return true;
	}
	return false;	
}

function sprawdz_ile_mlo(mlo)
{
	if(mlo==0)
		{
		if(document.forms.panel.ile_mlo.selectedIndex>0)
			{
			alert("Brak możliwosci łaczenia młodzieży z osobami dorosłymi, dziećmi lub niemowlętami");
			document.forms.panel.elements['ile_mlo'].selectedIndex=0;
			}
		}
	else
		{
if(document.forms.panel.ile_dor.selectedIndex>0 || document.forms.panel.ile_dzi.selectedIndex>0 || document.forms.panel.ile_nie.selectedIndex>0)
			{
			alert("Brak możliwosci łaczenia młodzieży z osobami dorosłymi, dziećmi lub niemowlętami");
			document.forms.panel.elements['ile_dor'].selectedIndex=0;
			document.forms.panel.elements['ile_dzi'].selectedIndex=0;
			document.forms.panel.elements['ile_nie'].selectedIndex=0;
			}
		}
}

function checkfrm(){
	var miz='',
		mid='',
		koz='';
	if (document.getElementById('tripmode').value=='roundtrip'){
		miz='miasto_z';
		mid='miasto_d';
		koz='w_kod_z';
	}else
	if (document.getElementById('tripmode').value=='multitrip'){
		miz='miasto_z1';
		mid='miasto_d1';
		koz='w_kod_z1';		
	}		
		if(document.getElementById(mid).value=='' || document.getElementById(mid).value=='wpisz miasto przylotu' || document.getElementById(mid).value=='wpisz kod lub nazwę miasta'){
			document.getElementById(mid).style.backgroundColor='#FF9999';
			alert('Prosze wybrać miasto przylotu');
			return false;
		}
		if(document.getElementById(miz).value==''){
			document.getElementById(miz).style.backgroundColor='#FF9999';
			alert('Prosze wybrać miasto wylotu');
		
			return false;
		}
	
		if (document.getElementById(koz).value=='WAW' && (document.getElementById(mid).value!='WARSZAWA (OKĘCIE)' || document.getElementById(mid).value!='WARSZAWA')){
			document.getElementById(koz).value='';
		}

	var dor=document.getElementById('ile_dor');
	var mlo=document.getElementById('ile_mlo');
	var dzi=document.getElementById('ile_dzi');
	var nie=document.getElementById('ile_nie');
	var sum=parseInt(dor.options[dor.selectedIndex].value)+parseInt(mlo.options[mlo.selectedIndex].value);
	var sum2=parseInt(dor.options[dor.selectedIndex].value)+parseInt(dzi.options[dzi.selectedIndex].value);
	if (nie.options[nie.selectedIndex].value>sum){
	alert('Liczba niemowląt nie może przekraczać liczby dorosłych pasażerów ');
	return false;
	}
	
	if (sum2>9){
	alert(' Liczba pasażerów (nie licząc niemowląt)\n nie może przekraczać 9 (dziewięć)');
	return false;
	}
	
	if (sum<1){
	alert('Proszę podać liczbę pasażerów');
	return false;
	}
	
	if (document.getElementById('tripmode').value=='roundtrip'){
		zd(document.getElementById('w_dat_do'),document.getElementById('w_dat_mo'),document.getElementById('w_dat_ro'),document.getElementById('p_dat_do'),document.getElementById('p_dat_mo'),document.getElementById('p_dat_ro') );
	}
	
	return czyjutro();
}


function czyjutro(){
	var selstring='';
	if (document.getElementById('tripmode').value=='roundtrip'){
		selstring=document.getElementById('w_dat_do').value+''+document.getElementById('w_dat_mo').value+''+document.getElementById('w_dat_ro').value;
	}else
	if (document.getElementById('tripmode').value=='multitrip'){
		var seltbl=document.getElementById('dataz1').value.split('/');
		selstring=seltbl[0]+''+seltbl[1]+''+seltbl[2];
	}
	var jutro=0;
	var kiedy= new Array('dzisiaj', 'jutrzejszy', 'już za 2 dni', 'już za 3 dni');
	for(i=1; i<=3; i++){
		var now=new Date();
		now.setDate(now.getDate()+i);
		var monthnumber = now.getMonth()+1;
    	var monthday    = now.getDate();
		if(document.all) {
    		var year= now.getYear();
		}else{
			var year= now.getYear()+1900;
		}
		var nowstring=monthday+''+monthnumber+''+year;
		if (nowstring==selstring){
			jutro=i;
			break;
		}
	}
	if (jutro>0){
		if (confirm("UWAGA! Rezerwacja biletu na lot "+kiedy[jutro]+", jest możliwa tylko w przypadku płatności kartą kredytową! Czy chcesz kontynuowac?")){
   			warn=true;
		}else{
   			warn=false;
		}
	}else{
		warn=true;
	}
	return warn;
}

function avisredir(mode){
	if(mode==1){
		document.getElementById('favis').src='http://www.avis.pl/avisonline/pl/IBE.nsf/ReservationStep1?OpenForm&MST=349BAF8D850E164DC12574B7002D786C';
		document.getElementById('butt1').innerHTML='Czy jesteś posiadaczem karty Avis Preferred<br/>i chcesz zarezerwować samochód?<br/><input name="Button" type="button" class="butavis" value="Rezerwacja Avis Preferred" style="width:250px; height:30px; border:1px solid #117FE1; margin-top:6px" onClick="avisredir(2)"/>';
		document.getElementById('butt2').innerHTML='Czy chcesz zmodyfikować<br/>lub anulować rezerwację?<input name="Button2" type="button" class="butavis" value="Modyfikacja / Anulowanie" style="width:250px; height:30px; border:1px solid #117FE1; margin-top:6px" onClick="avisredir(3)"/>';		
	}
	if(mode==2){
		document.getElementById('favis').src='http://www.avis.pl/avisonline/pl/IBE.nsf/EPLogin?OpenForm&MST=349BAF8D850E164DC12574B7002D786C';
		document.getElementById('butt1').innerHTML='Chcesz sprawdzić cenę<br/>lub zarezerwować samochód?<br/><input name="Button" type="button" class="butavis" value="Cena / Rezerwacja" style="width:250px; height:30px; border:1px solid #117FE1; margin-top:6px" onClick="avisredir(1)"/>';
		document.getElementById('butt2').innerHTML='Czy chcesz zmodyfikować<br/>lub anulować rezerwację?<input name="Button2" type="button" class="butavis" value="Modyfikacja / Anulowanie" style="width:250px; height:30px; border:1px solid #117FE1; margin-top:6px" onClick="avisredir(3)"/>';	
	}
	if(mode==3){
		document.getElementById('favis').src='http://www.avis.pl/avisonline/pl/IBE.nsf/modifycancel?OpenForm&MST=349BAF8D850E164DC12574B7002D786C';
		document.getElementById('butt1').innerHTML='Chcesz sprawdzić cenę<br/>lub zarezerwować samochód?<br/><input name="Button" type="button" class="butavis" value="Cena / Rezerwacja" style="width:250px; height:30px; border:1px solid #117FE1; margin-top:6px" onClick="avisredir(1)"/>';
		document.getElementById('butt2').innerHTML='Czy jesteś posiadaczem karty Avis Preferred<br/>i chcesz zarezerwować samochód?<br/><input name="Button" type="button" class="butavis" value="Rezerwacja Avis Preferred" style="width:250px; height:30px; border:1px solid #117FE1; margin-top:6px" onClick="avisredir(2)"/>';
		
	}
	
	
}

function checkinsfrm(fmode){
	
	var dor=document.getElementById('ile_dor');
	var mlo=document.getElementById('ile_mlo');
	var dzi=document.getElementById('ile_dzi');
	var nie=document.getElementById('ile_nie');
	var sum=parseInt(dor.options[dor.selectedIndex].value)+parseInt(mlo.options[mlo.selectedIndex].value);
	var sum2=parseInt(dor.options[dor.selectedIndex].value)+parseInt(dzi.options[dzi.selectedIndex].value);
	if (nie.options[nie.selectedIndex].value>sum){
	alert('Liczba niemowląt nie może przekraczać liczby dorosłych pasażerów ');
	return false;
	}
	
	if (sum2>9){
	alert(' Liczba pasażerów (nie licząc niemowląt)\n nie może przekraczać 9 (dziewięć)');
	return false;
	}
	
	if (sum<1){
	alert('Proszę podać liczbę pasażerów');
	return false;
	}
	
	zd(document.getElementById('w_dat_do'),document.getElementById('w_dat_mo'),document.getElementById('w_dat_ro'),document.getElementById('p_dat_do'),document.getElementById('p_dat_mo'),document.getElementById('p_dat_ro') );
	if(fmode==1){
	document.getElementById('insplash').style.display='block';
	document.getElementById('inslist').style.display='none';
	xajax_compInses(xajax.getFormValues('panel'));
	}
	return true;
}

function insgo(){	
	document.getElementById('insplash').style.display='block';
	document.getElementById('inslist').style.display='none';
	xajax_showPaxFrm(xajax.getFormValues('panlins'));
	return true;	
}
function inswait(step){	
	document.getElementById('insplash').style.display='block';
	document.getElementById(step).style.display='none';	
}
function ffirmychck()
{
var puste=" nie może być puste lub ma niepoprawną wartość";

	if(!sprawdz_pop(document.forms.ffirmy.elements.imnazw.value,/^[a-zA-ZąęśćżźńółĄĘŚĆŻŹŃÓŁ \-]{3,200}$/))
		{
		alert("Pole Osoba Kontaktowa"+puste);
		return false;
		}

	if(!sprawdz_pop(document.forms.ffirmy.elements.firma.value,/^[a-zA-Z0-9ąęśćżźńółĄĘŚĆŻŹŃÓŁ () \\/_\-\.]{2,200}$/))
		{
		alert("Pole Firma"+puste);
		return false;
		}

	if(!sprawdz_pop(document.forms.ffirmy.elements.tel.value,/^[0-9 ()\-/\\ ()+]{4,30}$/))
		{
		alert("Pole Telefon kontaktowy"+puste);
		return false;
		}
		
	
	if(!sprawdz_email(document.forms.ffirmy.elements.mail.value))
		{
		alert("Pole E-mail"+puste);
		return false;
		}
		//var adr=document.forms.ffirmy.elements.adres.value;
		//var adrestxt=adr.replace(/(\x0a\x0d|\x0d\x0a|\x0a)/gi, ' ');
		
	/*if(!sprawdz_pop(adrestxt,/^[a-zA-Z0-9ąęśćżźńółĄĘŚĆŻŹŃÓŁ () \\/_\-\.,]{8,400}$/))
		{
		alert("Pole Adres firmy"+puste);
		return false;
		}*/

	return true;
}

function doFform(){
	
	if (ffirmychck()){
		xajax_dofmail(xajax.getFormValues('ffirmy'));
	}
	
}
function sprawdz_pop(val,pop)
{
   if(val.match(pop))
      return true;
   else
      return false;
}
function chgpnel(elm){
	if(elm.id=='simplet'){
		elm2=document.getElementById('multit');
		document.getElementById('arcst').src='img/luk1.gif';
		document.getElementById('multisgm').style.display='none';
		document.getElementById('onesgm').style.display='block';
		document.getElementById('tripmode').value='roundtrip';
	}else
	if(elm.id=='multit'){
		elm2=document.getElementById('simplet');
		document.getElementById('arcst').src='img/luk2.gif';
		document.getElementById('multisgm').style.display='block';
		document.getElementById('onesgm').style.display='none';
		document.getElementById('tripmode').value='multitrip';
	}
	
	elm2.style.borderBottom='1px solid #117FE1';
	elm2.style.backgroundColor='#FFFFFF';
	document.getElementById(elm2.id+'1').style.color='#117FE1';
	document.getElementById(elm2.id+'3').src='img/plane.gif';
	
	elm.style.borderBottomWidth='0px';
	elm.style.backgroundColor='#67B3F1';
	document.getElementById(elm.id+'1').style.color='#FFFFFF';
	document.getElementById(elm.id+'3').src='img/plane_red.gif';	
	
}

function chckMtrip(){
	var puste=" nie może być puste lub ma niepoprawną wartość";

	if(!sprawdz_pop(document.forms.chmt.elements.pnr.value,/^[a-zA-Z0-9]{6}$/))
		{
		alert("Pole Numer Rezerwacji"+puste);
		return false;
		}
		
	if(!sprawdz_pop(document.forms.chmt.elements.paxnm.value,/^[a-zA-ZąęśćżźńółĄĘŚĆŻŹŃÓŁ \-]{2,50}$/))
		{
		alert("Pole Nazwisko Pasażera"+puste);
		return false;
		}
	return true;
}

function smultis(){
var mshow=document.getElementById('multit');
chgpnel(mshow);
}