$( document ).ready(function()
{
  SexyLightbox.initialize( {
    imagesdir: strBaseUrl + 'assets/img/sexyimages',
    color: 'black'
  } );

  $('.galeria img, .tooltip').tooltip(
    {
      track: true,
      delay: 0,
      showURL: false,
      showBody: " - ",
      fade: 250
    } );

} );

function ajaxGetNewsById( intNewsId, intPage )
{
  $.ajax( {
    url: strBaseUrl + "index.php/news/ajaxGetNewsById/" + intNewsId + "/" + intPage,
    dataType: "html",
    success: function( html ) {
      if( html != '' )
      {
        $( '#div_pagination' ).remove();
        $( '#main_content' ).fadeOut( 'fast', function () {
          $( '#main_content' ).html( html );
          $( '#main_content' ).fadeIn( 'fast' );
        });
      }
    }
  } );
}

function ajaxGetNewsList( intPage )
{
  $.ajax( {
    url: strBaseUrl + "index.php/news/ajaxGetNewsList/" + intPage,
    dataType: "html",
    success: function( html ) {
      if( html != '' )
      {
        $( '#newslist' ).fadeOut( 'fast', function () {
          $( '#newslist' ).html( html );
          $( '#newslist' ).fadeIn( 'fast' );
        });
      }
    }
  } );
}

function Shop( id, trade, shop )
{
  this.id = id;
  this.trade = trade;
  this.name = shop;
}

function OnChangeTrade()
{
  set_trade_value = $( '#select_trades' ).val();
  
  for( i = document.getElementById( 'select_shops' ).length; i > 0; i-- )
  {
    document.getElementById( 'select_shops' ).options[i] = null;
  }

  j = 1;
  for(i = 1; i <= ShopsArray.length; i++)
  {
    if( ShopsArray[i-1].trade == set_trade_value )
    {
      document.getElementById( 'select_shops' ).options[j] = new Option( ShopsArray[i-1].name, ShopsArray[i-1].id );

      j++;
    }
  }
}

function OnChangeShop()
{
  set_shop_value = $( '#select_shops' ).val();
  set_shop_text = $('#select_shops :selected').text()

  if( set_shop_value >= 1 )
  {
    window.location.href = strBaseUrl + "sklep," + set_shop_value + "," + set_shop_text.replace(/\s+/g,'-').replace(/[^a-zA-Z0-9\-]/g,'') + ".html";
  }
}


function checkagreed()
{
  check = $('#agreed').attr('checked')=='checked';
  alert(check);return false;
}
