function ClientBrowse() { this.w=0; this.h=0;
if (self.screen) { this.w=screen.width; this.h=screen.height; }
else if (self.java) { var jkit=java.awt.Toolkit.getDefaultToolkit(); var scrsize=jkit.getScreenSize(); this.w=scrsize.width; this.h=scrsize.height; } return this; }
function OpenWin(url,nwin,w,h,s) { p=new ClientBrowse();
if (w) { leftPos=(p.w-w)/2; } else { w=p.w-100; leftPos=(p.w-w)/2; }
if (h) { topPos=(p.h-h)/2; } else { h=p.h-100; topPos=10; }
(s==1)?null:s=0; (nwin)?null:nwin="win"; var property="left="+leftPos+",top="+topPos+",width="+w+",height="+h+",scrollbars="+s;
window.open (url,nwin,property); }


$(function(){
   
   if( typeof window.console == 'undefined' ) {
      window.console = { log: function(){} };
   }
   
   /*lightbox init*/
   $('a[rel]').each(function(){
      $('a[rel=' + this.rel + ']').lightBox();
   });
   
   filterChange();
   
   /*filter form init*/
   $('#sel_dir_id').change(filterChange);
   $('#sel_style_id').change(filterChange);
   
});

function filterChange(){
   // var queryStr = 'dir_id=' + $(this).val();
   var queryStr = $('#search_form').serialize();
   
   $.ajax({
      type: "POST",  
      url: "/cgi-bin/catalog/get_data.pl",  
      data: queryStr,
      success: function( resp ) {
         eval( 'var result=' + resp );
         if( result.style_opts ) {
            // console.log( result.style_opts )
            $('#sel_style_id').html( result.style_opts );
         }
         if( result.company_opts ) {
            $('#sel_company_id').html( result.company_opts );
         }
         
      },
      error: function() {
         /*
         alert( 'При загрузке данных произошла ошибка.\n \
            Попробуйте перезагрузить страницу.\n \
            Если она повторится вновь, сообщите нам об этом.' );
         */
      }
   });
   
}//filterChange
