function add() {
	var index = parseInt(window.parent.frames.tdForm.document.getElementById('countOfTermins').value);
	index++;
	window.parent.frames.tdForm.document.getElementById('countOfTermins').value = index;
	return true;
}
function minus() {
    var index = parseInt(window.parent.frames.tdForm.document.getElementById('countOfTermins').value);
    if ( --index < 0 ) {
	index = 0;
    }
    window.parent.frames.tdForm.document.getElementById('countOfTermins').value = index;
    return true;
}
function clearTdOffers() {
    window.parent.frames.tdForm.document.getElementById('terminy').value = '';
    window.parent.frames.tdForm.document.getElementById('countOfTermins').value = 0;
    alert("Hello.");
    return true;
}
//function tourdeskAddOfferNew( zdjecie, dataWyjazdu, nazwaImprezy, panstwo, region, miasto, standard, wyzywienie, cena7Dni, cena14Dni, wyjazdZ, linkDoOferty ) {
function tourdeskAddOfferNew( divId ) {
    /*
    if ( zdjecie ) {
	sDocument = sDocument + '<div class="tripPictures"><img src="' + zdjecie + '" border="0" /></div>';
    }
    if ( dataWyjazdu ) {
	sDocument = sDocument + '<div class="tripDate">' + dataWyjazdu + '</div>';
    }
    if ( nazwaImprezy ) {
	sDocument = sDocument + '<div class="tripName">' + nazwaImprezy + '</div>';
    }
    if ( panstwo ) {
	sDocument = sDocument + '<div class="tripCountry">' + panstwo + '</div>';
    }
    if ( region ) {
	sDocument = sDocument + '<div class="tripRegion">' + region + '</div>';
    }
    if ( miasto ) {
	sDocument = sDocument + '<div class="tripCity">' + miasto + '</div>';
    }
    if ( standard ) {
	sDocument = sDocument + '<div class="tripStandard">' + standard + '</div>';
    }
    if ( wyzywienie ) {
	sDocument = sDocument + '<div class="tripBoard">' + wyzywienie + '</div>';
    }
    if ( cena7Dni ) {
	sDocument = sDocument + '<div class="terminPrice">';
	sDocument = sDocument + '<div class="terminPrice7Days">' + cena7Dni + '</div>';
	if ( cena14Dni ) {
	    sDocument = sDocument + '<div class="terminPrice14Days">' + cena14Dni + '</div>';
	}
	sDocument = sDocument + '</div>';
    }
     if ( wyjazdZ ) {
	sDocument = sDocument + '<div class="tripFrom">' + wyjazdZ + '</div>';
    }
    if ( linkDoOferty ) {
	sDocument = sDocument + '<div class="tripOfferHref"><a href="' + linkDoOferty + '" target="blank"> odnośnik do oferty </a></div>';
    }
    */
    var sDoc = window.parent.frames.tdForm.document;
    var sDocument = '<tr class="oferta">' + document.getElementById(divId).innerHTML + '</tr>';
    sOldString = sDoc.getElementById("terminy").value;
    sDoc.getElementById("terminy").value = sOldString + sDocument;
    add();
    alert("Dodano ofertę.");
}

function tourdeskAdd( idg,imgHtml )
{ 
  var sDoc = window.opener.document;
  if ( idg == 'hotel' )
  {
    var _htmlHotel = '';
    var _htmlHotelHead = '';
    
    //pobierz nazwe hotelu
    var _hotelNameId = document.getElementById('tripData');
    var _hotelName = '';
    if ( _hotelNameId != null )
    {
      _hotelName = _hotelNameId.innerHTML;
    }
    
    if ( _hotelName != "" )
    {
      _htmlHotelHead = '<table class="tdofferhotelhead">'+_hotelName+'</table>';
    }
    /*
    //pobierz region
    var _hotelIdRegion = document.getElementById('tourdesk_region');
    var _hotelRegion = '';
    if ( _hotelIdRegion != null )
    {
      _hotelRegion = _hotelIdRegion.innerHTML;
    }
    
    if ( _hotelRegion != "" )
    {
      _htmlHotel = _htmlHotel + '<tr><td class="headerTblT">Region:</td><td>'+_hotelRegion+'</td></tr>';    
    }
    //pobierz wyzywienie
    var _hotelIdWyzywienie = document.getElementById('tourdesk_wyzywienie');
    var _hotelWyzywienie = '';
    if ( _hotelIdWyzywienie != null )
    {
      _hotelWyzywienie = _hotelIdWyzywienie.innerHTML;
    }
    
    if ( _hotelWyzywienie != "" )
    {
      _htmlHotel = _htmlHotel + '<tr><td class="headerTblT">Wyżywienie:</td><td>'+_hotelWyzywienie+'</td></tr>';    
    }
    _htmlHotel = _htmlHotel + '</table>';
    //pobierz fotke
    */
    /*
    var _foto = document.getElementById('placeholder');
    var _foto_src = '';
    if ( _foto != null )
    {
      _foto_src = _foto.src;
      if ( _foto_src != "" )
      { 
        sDoc.getElementById('foto').value = '<img src="'+_foto_src+'" />';
      }
    }
    */
    sDoc.getElementById('foto').value = imgHtml;
    //dodanie opisu hotelu
    var _hotel = document.getElementById('page1').innerHTML;
    _hotel = '<table class="tdofferhoteldesc">'+_hotel+'</div>';
    //window.opener.document.catchForm.hotel.value="s";
    window.opener.document.getElementById("hotel").value = _htmlHotelHead+_htmlHotel+_hotel;
    //alert(window.opener.document.catchForm.hotel);

 //   window.opener.document.forms.catchForm.elements['hotel'].value = 'x';
    alert("Dodano opis hotelu");
  }
}

function tourdeskAddOffer(wyjazd,data,ilosc_dni,wyzywienie,cena)
{
  var sDoc = window.opener.document;
  var _out = '<table class="tdoffers">';
  if ( wyjazd != "" )
  {
    _out = _out + '<tr><td><b>Wyjazd z:</b> '+wyjazd+'</td></tr>';
  }
  if ( data != "" )
  {
    _out = _out + '<tr><td><b>Data:</b> '+data+'</td></tr>';
  }
  if ( ilosc_dni != "" )
  {
    _out = _out + '<tr><td><b>Ilość dni:</b> '+ilosc_dni+'</td></tr>';
  }  
  if ( wyzywienie != "" )
  {
    _out = _out + '<tr><td><b>Wyżywienie:</b> '+wyzywienie+'</td></tr>';
  }  
  if ( cena != "" )
  {
    _out = _out + '<tr><td><b>Cena:</b> '+cena+'</td></tr>';
  } 
  _out = _out + '</table>';
  
  //dodanie pojedynczego terminu
  //jezeli byl juz dodany termin -> lacz terminy
  var _insertedOffers = sDoc.getElementById('termin').value;
  sDoc.getElementById('termin').value = _insertedOffers + _out
  alert("Dodano termin"); 
}

