function iduna() {
	noweOkno = window.open('https://ssl.voyager.pl/PolisaOnline/Partner.aspx?id=EXPERTNIKK','iduna','menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=no, status=no, width=620, height=800, left=0, top=0');
	}

function euro() {
	noweOkno = window.open('https://ssl.voyager.pl/PolisaEuro26/Partner.aspx?Id=EXPERTNIKK','euro','menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=no, status=no, width=620, height=800, left=0, top=0');
	}

function voyager() {
	noweOkno = window.open('http://www.voyager.pl/BusPAgKK.nsf/Bilet?OpenForm&IDAKW=EXPERTNIKK','voyager','menubar=no, toolbar=no, location=no, scrollbars=yes, resizable=no, status=no, width=620, height=545, left=0, top=0');
	}

function centralwings() {
	noweOkno = window.open('_centralwings.html','centralwings','menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width=200, height=398, left=0, top=0');
	}

function changeBackgroundColor( id, kolor )
{
  document.getElementById(id).style.backgroundColor=kolor;
}

function turoperator( id )
{
  Nowe=window.open("turoperator.php?id="+id, "","toolbar=no, scrollbars=yes, location=no, directories=no, status=no, menubar=no, resizable=no, width=400, height=400");
}

function print( t )
{
  Nowe=window.open("print.php?t="+t, "","toolbar=no, scrollbars=yes, location=no, directories=no, status=no, menubar=no, resizable=no, width=400, height=400");
}

function tpShow( start, end, ilosc )
{
  
  for( i=1; i<=ilosc; i++ )
  {
    if( i<start )
    {
      document.getElementById('tp'+i).style.display='';
    }
    else {
      document.getElementById('tp'+i).style.display='none';
    }
  }
  
}


function wybierzOpcjeOferty()
{
  var dlugosc = document.formularz.elements.opcje_oferty.options.length
  
  for ( var i=0; i<dlugosc; i++ ) 
  {

    if( document.formularz.opcje_oferty.options[i].selected )
    {
      var wartosci = document.formularz.opcje_oferty.options[i].value.split("|");

      document.getElementById('termin_od_do').innerHTML = wartosci[0];
      document.getElementById('ilosc_dni').innerHTML = wartosci[1];
      document.getElementById('cena').innerHTML = wartosci[2];
    }
  }
  
}


function showNextPhoto( total )
{

  var actual = eval(document.getElementById( 'zdj_akt' ).innerHTML);
  var next_v = actual+1;

  if ( next_v <= total )
  {
    document.getElementById( 'img'+actual).style.display='none';
    document.getElementById( 'img'+next_v).style.display='';
    
    //opacity('img'+next_v , 0, 300, 500);
    document.getElementById( 'zdj_akt' ).innerHTML = next_v;
    
    document.getElementById( 'bpV' ).innerHTML = document.getElementById( 'bpId_'+next_v ).innerHTML;
    
  }
  
  if( next_v <= total )
  {
    closePhoto( 'th2' );
    return true;
  }
  else {
    return false;
  }
}


function showPrevPhoto( total )
{
  //closePhoto( 'th2' );
  
  var actual = eval(document.getElementById( 'zdj_akt' ).innerHTML);
  var prev_v = actual-1;

  if ( prev_v >=1 && prev_v <= total )
  {
    document.getElementById( 'img'+actual).style.display='none';
    document.getElementById( 'img'+prev_v).style.display='';
    
    document.getElementById( 'zdj_akt' ).innerHTML = prev_v;
    
    document.getElementById( 'bpV' ).innerHTML = document.getElementById( 'bpId_'+prev_v ).innerHTML;
  }

  if( prev_v <= total && prev_v >=1 )
  {
    closePhoto( 'th2' );
    return true;
  }
  else {
    return false;
  }
}


function loopPhoto( oid, id )
{
  var total =  eval(document.getElementById( 'total_img' ).innerHTML);
  
  // jesli podano wartosc oid i wartosc id zdjecia nie jest null
  if ( oid != null && id != null )
  {
    // jesli id jest wiekszy od 0 - przewijaj do przodu
    if( id>0 )
    {
      var loop = showNextPhoto( total );
      
      if( loop == true )
      {
        start_xmlhttp( 'showphoto.php?showph='+id+'&oidg='+oid, 'showPhoto' );  
      }
    }
    // jesli id jest mniejszy od 0 - przewijaj do tylu
    else {
      
      var loop = showPrevPhoto( total );
    
      if( loop == true )
      {
        var id = Math.abs(id);
        start_xmlhttp( 'showphoto.php?showphr='+id+'&oidg='+oid, 'showPhoto' );  
      }
    }
  }
  else {
    var loop = true;
    
    var getId = document.getElementById( 'bpV' ).innerHTML;
    start_xmlhttp( 'showphoto.php?showph='+getId, 'showPhoto' );  
  }
    
  //start_xmlhttp( 'showphoto.php?showph='+getId, 'showPhoto' );  

  document.getElementById( 'showPhoto' ).style.display='';
  //document.getElementById( 'showPhoto' ).style.width='768px;';
  //document.getElementById( 'showPhoto' ).style.height='296px;';
  //document.getElementById( 'showPhoto' ).style.visibility='visible';
  
  if( document.getElementById( 'selectOpcje' ) )
  {
    document.getElementById( 'selectOpcje' ).style.display='none';
  }
  
}

function closePhoto( id )
{
  if( document.getElementById( id ) )
  {
    if( document.getElementById( 'selectOpcje' ) )
    {
      document.getElementById( 'selectOpcje' ).style.display='';
    }
    
    document.getElementById( id ).style.display='none';
    document.getElementById( 'showPhoto' ).style.display='none';
    //document.getElementById( 'showPhoto' ).style.visibility='hidden';
  }
}


function opacity(id, opacStart, opacEnd, millisec) 
{ 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
        { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 


function changeOpac(opacity, id) 
{ 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 


function lokalizacjaLoad()
{
  var dlugosc = document.lokalizacje.elements.regiony_miasta.options.length
  
  for ( var i=0; i<dlugosc; i++ ) 
  {
    if( document.lokalizacje.regiony_miasta.options[i].selected )
    {
      var wartosci = document.lokalizacje.regiony_miasta.options[i].value;
      var typ = wartosci.substring(0,1);
      var id = wartosci.substring(1,5);
      
      if( typ == 'r')
      {
        location.href='index.php?p=lokalizacja,region,'+id;
      }
      else{

        location.href='index.php?p=lokalizacja,miasto,'+id;
      }
    }
  } 
}



function walidacjaRezerwacji( frm )
{
  
  var alerty = "";
  

  if ( frm.imie.value == "" )
  {
    alerty += 'Pole imienia musi być wypełnione.\n';
  }
  
  if ( frm.nazwisko.value == "" )
  {
    alerty += 'Pole nazwiska musi być wypełnione.\n';
  }

  if ( frm.ulica.value == "" )
  {
    alerty +=  'Pole ulicy/numeru domu musi być wypełnione.\n';
  }
  
  if ( frm.miejscowosc.value == "" )
  {
    alerty +=  'Pole miejscowości musi być wypełnione.\n';
  }
  
  if ( frm.telefon1.value == "" )
  {
    alerty +=  'Pole pierwszego telefonu kontaktowego musi być wypełnione.\n';
  }
  
  if( frm.email.value !="" )
  {
    var regex = /^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/;
    var value = frm.email.value;
    
    if (value != '' && !regex.test(value) ) {

      alerty += 'Adres e-mail nie jest poprawny\n';
    }
  }
  
  if ( !frm.zgoda.checked )
  {
    alerty +=  'Pole zgody nie zostało zaznaczone.\n';
  }
  
  if ( alerty == "" )
  {
    frm.submit();
  }
  else {
   alert(alerty);
   return false;
  }
  
  return true;
}


function showStatus( id, typ, show )
{
  if( show == 1 )
  {

    document.getElementById(id).style.display='';
    
    switch ( typ )
    {
      case 1:
          document.getElementById(id).innerHTML = 'Last minute';
      break;
      
      case 2:
          document.getElementById(id).innerHTML = 'First minute';
      break;
      
      case 3:
          document.getElementById(id).innerHTML = 'Oferta specjalna';
      break;
    }
  }
  else {
    document.getElementById(id).style.display='none';
  }
}