<!--
function LayerOn(element){
	if(document.all) document.all[element].style.visibility='visible';
	else document.getElementById(element).style.visibility='visible';
}
function LayerOff(element){
	if(document.all) document.all[element].style.visibility='hidden';
	else document.getElementById(element).style.visibility='hidden';
}

function CheckLink(lnk){
	if(lnk.href.length < 10) return false;
	else return true;
}

var actual_searchengine = 'trips_searchengine';
function switchSearchengine(element1,element2){
	if(actual_searchengine == element2){
		document.getElementById(element2).innerHTML = document.getElementById('current_searchengine').innerHTML;
		document.getElementById('current_searchengine').innerHTML = document.getElementById(element1).innerHTML;
		document.getElementById(element1).innerHTML='';
	}
	actual_searchengine = element1;
}
function fkod(id) {
  dot=id.value.indexOf('/')
    lastdot=id.value.lastIndexOf('/')
    error=0
    if( (dot==-1) || (dot!=lastdot)) {
      error=1;
      msg="Symbol oferty musi mieć taki format: 1234/567";
    }
  for (i = 0; i < id.value.length; i++) {
    if(!isDigit(id.value.substring(i,i+1))) {
      error=1
			msg="Symbol oferty musi mieć taki format: 1234/567";
    }
  }

  if (error) {
	location.replace('/web/?page=wrong_symbol&kod='+id.value);
  } else {
    location.replace('/kod=' + id.value);
  }
  return error;
}
function isDigit(n){
  if( (n < "0") || ("9" < n)) {
    if (n="/") {
      return true
    }
    return false
  } else {
    return true
  }
}
function podzielSie(){
  if(document.getElementById('podzielOkno').style.display == 'none') podzielOpen();
  else podzielClose();
}
function podzielOpen(){
  document.getElementById('podzielOkno').style.display = 'block';
}
function podzielClose(){
  document.getElementById('podzielOkno').style.display = 'none';
}
function podzielWindow(url, name){
  window.open(url, name);
  podzielClose();
}
function d_wykop(){
  var t = encodeURIComponent(document.title);
  var u = encodeURIComponent((document.location.href == undefined ? '' : document.location.href));
  podzielWindow('http://www.wykop.pl/dodaj?url='+u+'&title='+t+'&desc='+t+': '+u, 'wykop');
}
function d_email(){
  var t = encodeURIComponent(document.title);
  var u = encodeURIComponent((document.location.href == undefined ? '' : document.location.href));
  location.href = 'mailto:?subject='+t+'&body='+t+': '+u;
  podzielClose();
}
function d_facebook(){
  var t = encodeURIComponent(document.title);
  var u = encodeURIComponent((document.location.href == undefined ? '' : document.location.href));
  podzielWindow('http://www.facebook.com/sharer.php?u='+u+'&t='+t, 'facebook');
}
function d_ulubione(){
  var t = document.title;
  var u = document.location.href == undefined ? '' : document.location.href;
  podzielClose();
  if(window.sidebar){
		window.sidebar.addPanel(t, u, '');
	}else if(window.external){
		window.external.AddFavorite(u, t); 
  }else if(window.opera && window.print){
		var elem = document.createElement('a');
    elem.setAttribute('href', u);
    elem.setAttribute('title', t);
    elem.setAttribute('rel', 'sidebar');
    elem.click();
    return false;
  }
}
function d_google(){
  var t = encodeURIComponent(document.title);
  var u = encodeURIComponent(document.location.href == undefined ? '' : document.location.href);
  podzielWindow('http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk='+u+'&title='+t, 'google bookmarks');
}
function d_twitter(){
  var u = encodeURIComponent(document.location.href == undefined ? '' : document.location.href);
  podzielWindow('http://twitter.com/home?status='+u, 'twitter');
}
function d_blip(){
  var t = encodeURIComponent(document.title);
  var u = encodeURIComponent(document.location.href == undefined ? '' : document.location.href);
  podzielWindow('http://m.blip.pl/update/new?body='+u+'%20'+t, 'blip');
}
function d_delicious(){
  var t = encodeURIComponent(document.title);
  var u = encodeURIComponent(document.location.href == undefined ? '' : document.location.href);
  podzielWindow('http://del.icio.us/post?url='+u+'&title='+t, 'delicious');
}
function d_buzz(){
  var u = encodeURIComponent(document.location.href == undefined ? '' : document.location.href);
  podzielWindow('http://www.google.com/buzz/post?url='+u, 'buzz');
}
function d_grono(){
  var t = encodeURIComponent(document.title);
  var u = encodeURIComponent(document.location.href == undefined ? '' : document.location.href);
  podzielWindow('http://grono.net/pub/page/link/urlfetch/?url='+u+'&title='+t, 'grono');
}
function d_live(){
  var u = encodeURIComponent(document.location.href == undefined ? '' : document.location.href);
  podzielWindow('http://www.live.com/?add='+u, 'live');
}
function d_ggstatus(){
  var t = document.title;
  var u = document.location.href == undefined ? '' : document.location.href;
  location.href = 'gg:/set_status?description='+u+' '+t;
  podzielClose();
}
function d_gwar(){
  var u = encodeURIComponent(document.location.href == undefined ? '' : document.location.href);
  podzielWindow('http://www.gwar.pl/DodajGwar.html?u='+u, 'gwar');
}
function d_sledzik(){
  var t = encodeURIComponent(document.title);
  var u = encodeURIComponent(document.location.href == undefined ? '' : document.location.href);
  podzielWindow('http://nasza-klasa.pl/sledzik?shout='+u+'%20'+t, 'sledzik');
}

var allot_types = { T : 'rezerwuj', S : 'stop', N : 'zamów' };

function checkPlaces(t, from, to, i, o, text){
  var regexp = /termin=([0-9]+\-[0-9]+)/;
  var term   = regexp.exec(t.href)[1];
  var types  = new Array('', 'Zakwaterowanie', 'Transport', 'Pozostałe');
  
  jQuery('#row-'+from+'-'+to).after('<tr id="row-places-'+from+'-'+to+'"><td class="additionalallots" colspan="7"><div class="placesLoading"><img src="/web/edytor/sartbyweb/checkPlaces/gfx/ajax-loader.gif" alt="Trwa ładowanie..." /></div></td></tr>');
  
  jQuery.get('/web/edytor/sartbyweb/checkPlaces/?i='+i+'&o='+o+'&t='+term, function(data){
    var status   = jQuery(data).find('status').text();
    var def_pers = jQuery(data).find('default_persons').text();
    if(def_pers == '') def_pers = 2;
    t.href       = t.href.replace(/liczba=[0-9]+/i, 'liczba='+def_pers);
    t.onclick    = '';
    var all_type = jQuery(data).find('allot_type').text()
    var typ = allot_types[all_type];
    if(typ == undefined) typ = allot_types.N;
    t.innerHTML  = typ;
    t.title      = typ;
    var link     = ' <span style="float:right;"><a href="'+t.href+'">'+t.innerHTML+'</a>&nbsp;</span>';
    var str      = link;
    if(status == 0){
      str = '<div>Błąd podczas sprawdzania miejsc.'+link;
    }else if(status == 1){
      str = '<div>Oferta tylko na zamówienie.'+link;
    }else if(status == 2){
      var mem   = '';
      str = '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
      jQuery(data).find('ingredient').each(function(){
        str += '<tr><td>';
        var type      = jQuery(this).find('type').text();
        var name      = jQuery(this).find('name').text();
        var places    = jQuery(this).find('places').text();
        var isdefault = jQuery(this).find('default').text();
        
        if(mem != type){
          str += '<div><b>'+types[type]+'</b></div></td><td>&nbsp;</td></tr><tr><td>';
          mem = type;
        }
        if(isdefault == 1)  isdefault = '<span title="Domyślny składnik">*</span> ';
        else                isdefault = '';
        
        if(type == 1){
          if(all_type == 'S')     link = 'sprzedaż zakończona';
          else if(places == 'no') link = '<a href="'+t.href.replace(/liczba=[0-9]+/i, 'liczba='+jQuery(this).find('persons').text())+'">zamów</a>';
          else                    link = '<a href="'+t.href.replace(/liczba=[0-9]+/i, 'liczba='+jQuery(this).find('persons').text())+'">'+allot_types[all_type]+'</a>';
        }
        else                      link = '';
        
        var                                       p = ' (<b>MIEJSCA: '+places+'</b>)';
        if(places == '>5')                        p = ' (<b>powyżej 5 miejsc!</b>)';
        if(places == 'no')                        p = ' (<b>brak miejsc!</b>)';
        if(places == 'notset' || all_type == 'S') p = '';
        str += '<div class="arow">'+isdefault+name+p+'</div>'+'</td><td class="bookPlacesLink">'+link;
      });
      str += '</td></tr></table>';
    }
    jQuery('#row-places-'+from+'-'+to+' td').html(str);
    
  });
  
  return false;
}
  

//-->

