
var offerCnt=0;
var offerMax=0;
var autoOffer = true;
function nextOffer(){
  
  if(!autoOffer)return false;
  
  offerCnt++;
  if(offerCnt >= offerMax)
    offerCnt=0;
  $('#offer ul li').eq(offerCnt).click();
  window.setTimeout(nextOffer, 5000)
}


  

  





$(document).ready(function(){

    
    var width=900;
    var i=0;
    $('#content div .badanie ').each(function(){
        
        $(this).css('left', i*width+'px');
        i++;
        
    });
    $('#offer ul li').hover(function(){
      if(!$(this).hasClass('active') )
      $(this).addClass('hover');
    }, function(){
      $(this).removeClass('hover');
    });
    
    
    $('#faq li > div').hide();
    $('#faq li > strong').click(function(){
      $(this).parent().find('div').toggle('slow');
      
    });
    //$('#faq li:first > div').show();
    
    
    
    
    
    $('#offer ul#menu li').click(function(e){
        if(e.pageX != undefined)
          autoOffer=false;
        $(this).parent().find('.active').removeClass('active');
        $(this).removeClass('hover');
        $(this).addClass('active');
        
        
        var m = $('#content .all .'+$(this).attr('id')).css('left');
        m = parseInt(m);
        
        $('#content .all').animate({
           marginLeft: '-'+m+'px'
        });
       
    });
    
    offerCnt = 2;
    offerMax = $('#offer ul li').size();
    $('#badanie3').click();
    
    window.setTimeout(nextOffer, 5000)
    
    
    
    $('#whywe ul li').click(function(){
      
      
      $('#whywe .content div').fadeOut();
     
      $('#whywe .content div.'+$(this).attr('rel')).fadeIn();
      $(this).parent().find('.active').removeClass('active');
      $(this).addClass('active')
      
      
    }).hover(function(){
      $(this).addClass('hover');
    },function(){
      $(this).removeClass('hover');
    });
    $('#whywe li:first').click();
    
    
    
 		$.validator.addMethod("phone", function(ph, element) {
		if (ph == null) {
		return false;
		}
		var stripped = ph.replace(/[\s()+-]|ext\.?/gi, "");
		// 10 is the minimum number of numbers required
		return ((/\d{9,}/i).test(stripped));
		}, "Please enter a valid phone number");

    
    
    $("#form form").validate({
	rules: {
            name: {
                required:true,
                minlength: 5
            },
            company: {
                required:true,
                minlength: 3
            },	    
            position: {
                required:true,
                minlength: 5
            },
            phone: {
                    required: true,
                    phone: true
                    
            },
            mail: {
                    required: true,
                    email: true
            }
	},
	messages: {
		name: "Proszę wpisać swoje dane",
		position: "Proszę wpisać stanowisko",
		company: "Proszę wpisać nazwę firmy",
		mail: "Proszę wpisać poprawny e-mail",
		tresc: "Proszę wpisać treść wiadomości",
		phone: "Proszę wpisać poprawny numer"
	}
    });
    
    
    
    $('a.more').click(function(){
      $($(this).attr('rel')).find('.min').hide();
      $($(this).attr('rel')).find('.more').show();
      
      return false;
    });
    
   $('.submit').hover(function(){
      
      $(this).addClass('hover')
   },function(){
      $(this).removeClass('hover')
   })

    
    
    
    
});

