function supply_change(v){
 $('.supply_price').hide();
 $('.cart_input').attr('disabled', 'true');
 $('.cart_input_'+v).removeAttr('disabled');
 $('#supply_'+v).show();
}
function confirmDelete(delUrl) {
	if (confirm("Rekord zostanie usunięty na trwałe! Kontynuować operację?")) {
		document.location = delUrl;
	}
}
function confirmSend(delUrl) {
	if (confirm("Utworzyć nowe hasło i wysłać dane do użytkownika?")) {
		document.location = delUrl;
	}
}
function changeLang(lang){
 $('.div_lang').css('display', 'none');
 $('.lang a img').css('border', '10px solid #EFEFEF');
 
 $('#'+lang).css('display', 'block');
 $('#a_'+lang).css('border', '10px solid #2C96E4');
}

function changeTab(tab) {
   $('.contener_tab .tab').css('display', 'none');
   $('#'+tab).show();
  
}
function activeTab(tab) {
   $('.wpis_zakladki ul li a').removeClass("active");
   $('#'+tab).addClass("active");
}

function selectAll() {
      $('input[@type=checkbox]').attr('checked', 'checked');
      $('#selectall').toggle();
      $('#deselectall').toggle();
       return false;
}

function deSelectAll() {
      $('input[@type=checkbox]').removeAttr('checked');
      $('#selectall').toggle();
      $('#deselectall').toggle();      
       return false;
}

function regionList() {
      var id = $('#country').val();
      
      $('.div_region').hide();
      $('.select_region').attr('disabled', 'true');
      
      $('#select_' + id).removeAttr('disabled');
      $('#div_' + id).show();
      
      $('#select_0').attr('disabled', 'true');
      
      return false;
}
function regionListFront() {
      var id = $('#country').val();
      
      $('.div_region').hide();
      $('.select_region').attr('disabled', 'true');
      
      $('#select_' + id).removeAttr('disabled');
      $('#div_' + id).show();
      
      
      return false;
}


function modelListFront() {
      var id = $('#make').val();
      
      $('.div_model').hide();
      $('.div_serie').hide();
      $('.select_model').attr('disabled', 'true');
      $('.select_serie').attr('disabled', 'true');
      $('.select_model').val('null');
      $('.select_serie').val('null');
      $('#select_0_' + id).removeAttr('disabled');
      $('#div_0_' + id).show();
      
     // $('#select_0_0').removeAttr('disabled');
     // $('#div_0_0').show();     
      
      
      return false;
}

function serieListFront(model) {
      var id = $('#'+ model).val();
      
      $('.div_serie').hide();
      $('.select_serie').attr('disabled', 'true');
      
      $('#select_0_0_' + id).removeAttr('disabled');
      $('#div_0_0_' + id).show();
      
      
      return false;
}

/*auto*/
function auto(){
 var view_auto = $('#checkbox_auto').attr('checked');
 if(view_auto){
  $('#auto').hide();
  $('#auto input').attr('disabled', 'true');
  $('#auto select').attr('disabled', 'true');
 }else{
 $('#auto').show();
 $('#auto input').removeAttr('disabled'); 
 $('#auto select').removeAttr('disabled'); 
 }
}

/*notatka*/
function notatka(){
 var view_note = $('#checkbox_note').attr('checked');
 if(view_note){
  $('#note').show();
  }else{
  $('#note').hide();
  }
 }

/*company*/
function view_company(){
 var view_company = $('#checkbox_company').attr('checked');
 
 if(view_company){
 $('#table_company').show();
 $('#table_company input').removeAttr('disabled'); 
 }else{
  $('#table_company').hide();
  $('#table_company input').attr('disabled', 'true');
 }
 
}

/*change_packet*/
function change_packet(){
 var packet_id = $('#select_packet').val();
 
 $('.packet_box').hide();
 $('#packet_' + packet_id).show();
}


/* comment */
function plusik(){
 $('#mark').removeAttr('disabled');
 $('#minus').attr('src', '/img/layout/ikony/hand_bad1.gif');
 $('#plus').attr('src', '/img/layout/ikony/hand_ok.gif');
 $('#mark').val('1');
}
function minusik(){
 $('#mark').removeAttr('disabled');
 $('#plus').attr('src', '/img/layout/ikony/hand_ok1.gif'); 
 $('#minus').attr('src', '/img/layout/ikony/hand_bad.gif');
 $('#mark').val('0');
}


/*tree*/

function selectAllTree(val) {
      $('.'+val+' input[@type=checkbox]').attr('checked', 'checked');
      $('.'+val+' #selectall').toggle();
      $('.'+val+' #deselectall').toggle();
       return false;
}

function deSelectAllTree(val) {
      $('.'+val+' input[@type=checkbox]').removeAttr('checked');
      $('.'+val+' #selectall').toggle();
      $('.'+val+' #deselectall').toggle();      
       return false;
}

function toggleAll(val) {
      $('.'+val+' input[@type=checkbox]').each( function() {
                $(this).attr('checked', !$(this).attr('checked'));
       });
       return false;
}

function showTree(val) {
      $('.'+val+' ul ul').slideDown('slow');
      $('.'+val+' ul a').addClass('minus');
      $('.'+val+' #showtree').toggle();
      $('.'+val+' #hidetree').toggle();
       return false;
}

function hideTree(val) {
      $('.'+val+' ul ul').slideUp('slow');
      $('.'+val+' ul a').removeClass('minus');
      $('.'+val+' #showtree').toggle();
      $('.'+val+' #hidetree').toggle();
       return false;
}

/*chmurka*/
function chmurka(){
$('.chmurka').tooltip({
	delay: 0,
	showURL: false
});
}

function cytuj() {
 var text = $(".forum:select").text();
 alert(text);

}

/*start do inputa*/
/*
 * jQuery Form Example Plugin 1.4.1
 * Populate form inputs with example text that disappears on focus.
 *
 * e.g.
 *  $('input#name').example('Bob Smith');
 *  $('input[@title]').example(function() {
 *    return $(this).attr('title');
 *  });
 *  $('textarea#message').example('Type your message here', {
 *    className: 'example_text'
 *  });
 *
 * Copyright (c) Paul Mucur (http://mucur.name), 2007-2008.
 * Dual-licensed under the BSD (BSD-LICENSE.txt) and GPL (GPL-LICENSE.txt)
 * licenses.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
(function($) {
  
  $.fn.example = function(text, args) {

    var isCallback = $.isFunction(text);

    var options = $.extend({}, args, {example: text});
    
    return this.each(function() {

      var $this = $(this);

      if ($.metadata) {        
        var o = $.extend({}, $.fn.example.defaults, $this.metadata(), options);
      } else {
        var o = $.extend({}, $.fn.example.defaults, options);
      }
      
      $this.attr('placeholder', isCallback ? o.example.call(this) : o.example);
  
      if (!$.fn.example.boundClassNames[o.className]) {

        $(window).unload(function() {
          $('.' + o.className).val('');
        });

        $('form').submit(function() {
        
          /* Clear only the fields inside this particular form. */
          $(this).find('.' + o.className).val('');
        });
      
        /* Add the class name to the array. */
        $.fn.example.boundClassNames[o.className] = true;
      }

      if ($.browser.msie && !$this.attr('defaultValue') && (isCallback || $this.val() == o.example))
        $this.val('');
      

      if ($this.val() == '' && this != document.activeElement) {
        $this.addClass(o.className);
        

        $this.val(isCallback ? o.example.call(this) : o.example);
      }
      

      $this.focus(function() {
        
        /* jQuery 1.1 has no hasClass(), so is() must be used instead. */
        if ($(this).is('.' + o.className)) {
          $(this).val('');
          $(this).removeClass(o.className);
        }
      });
    
      /* Make the example text reappear if the input is blank on blurring. */
      $this.blur(function() {
        if ($(this).val() == '') {
          $(this).addClass(o.className);
          
          $(this).val(isCallback ? o.example.call(this) : o.example);
        }
      });
    });
  };
  

  $.fn.example.defaults = {
    className: 'example'
  };
  
  /* All the class names used are stored as keys in the following array. */
  $.fn.example.boundClassNames = [];
  
})(jQuery);
/*koniec do inputa*/


 function autoplay(klasa){
           
					 var el = $('.'+klasa + ' .highlight');
					 var el_now;
					 if(el.hasClass('last')){
            el_now = $('.'+klasa + ' .first');
           }else{
		      	el_now =  $('.'+klasa + ' .highlight').next();
           }
           $('.'+klasa + ' div').hide();
           $('.'+klasa + ' div').removeClass('highlight');
           el_now.addClass('highlight');
           el_now.fadeIn('slow');
           setTimeout('autoplay("promotion_box")', 5000);
           //setTimeout('autoplay("news_box")', 5000);
          }	

         $(document).ready(function () {
          setTimeout('autoplay("promotion_box")', 5000);
         // setTimeout('autoplay("news_box")', 5000);
				});
				
   function autoplay1(klasa){
           
					 var el = $('.'+klasa + ' .highlight');
					 var el_now;
					 if(el.hasClass('last')){
            el_now = $('.'+klasa + ' .first');
           }else{
		      	el_now =  $('.'+klasa + ' .highlight').next();
           }
           $('.'+klasa + ' div').hide();
           $('.'+klasa + ' div').removeClass('highlight');
           el_now.addClass('highlight');
           el_now.fadeIn('slow');
           //setTimeout('autoplay("promotion_box")', 5000);
           setTimeout('autoplay1("news_box")', 5000);
          }	



$(document).ready(function(){

 setTimeout('autoplay1("news_box")', 5000);

 $('.field').example(function() {
 return $(this).attr('title'); 
 });

	
});
