$(document).ready(function() {
    
	$("button.ajax_vote").live("click", 
	
	function(){
		
		var box=$(this).attr("id");
		$.ajax({
			data: $(".sonda_vote").serialize(),
			type: $(".sonda_vote").attr('method'),
			url: $(".sonda_vote").attr('action'),
			success: function(response) { 
				if(response=="false"){
				        alert("Proszę wybrac jedną z opcji!");
				}else{
                    alert(response);
				    //$("#q"+box).fadeOut('slow');
				    $("#q"+box).parent().hide();
				    //$("#a"+box).fadeIn('slow');
				    $("#a"+box).css({'display':'block'});
				    $("#a"+box).parent().removeClass('noborder');
				    //$("#scorre").fadeIn('slow');
				  
				}
				return false
			}
		});
		return false;
	})
	

    
	  
  // przycisk powrotu
  $('a.back').bind('click', function(){
  history.back();
  return false;
  });
  
  // wywolanie drukowania
  $('a.print').bind('click', function(){
  window.print();
  return false;
  });
  
  // Kadra - lekarze
  
  //$(".toggle_container").hide();

  $("h5.trigger").toggle(function(){
	  $(this).addClass("active"); 
	  }, function () {
	  $(this).removeClass("active");
  });
	
  $("h5.trigger").click(function(){
	  $(this).next(".toggle_container").slideToggle("slow,");
  });
  

  // slideshow glowna
  
  $('#slideshow').cycle({ 
    delay:  2000, 
    speed:  500,
    prev:   '#prev', 
    next:   '#next'
  });
  
  
  // cufon
  Cufon.replace('.sondyCont h2, #top p, #branding h2, #slideshow-title, #banners a, .content-main h2, #registration a, .content h3, #baner-questionnaire a, #baner-saloon a ', { fontFamily: 'Myriad Pro' });

     //Select all anchor tag with rel set to tooltip  
     $('a[rel=tooltip]').mouseover(function(e) {  
           
         //Grab the title attribute's value and assign it to a variable  
         var tip = $(this).attr('title');      
           
         //Remove the title attribute's to avoid the native tooltip from the browser  
         $(this).attr('title','');  
           
         //Append the tooltip template and its value  
         $(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');       
           
         //Set the X and Y axis of the tooltip  
         $('#tooltip').css('top', e.pageY + 5 );  
         $('#tooltip').css('left', e.pageX + 5 );  
           
         //Show the tooltip with faceIn effect  
         $('#tooltip').fadeIn('500');  
         $('#tooltip').fadeTo('10',1.0);  
           
     }).mousemove(function(e) {  
       
         //Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse  
         $('#tooltip').css('top', e.pageY + 5 );  
         $('#tooltip').css('left', e.pageX + 5 );  
           
     }).mouseout(function() {  
       
         //Put back the title attribute's value  
         $(this).attr('title',$('.tipBody').html());  
       
         //Remove the appended tooltip template  
         $(this).children('div#tooltip').remove();  
           
     }); 
      
      
//Forumularz kontaktowy walidacja wymaganych pol
    $("#submit").click(function(){
		error=false;
		fields=new Array();
		$("#aaeC").html("");
		if($("#name_f").val()<=0){
			fields.push("Imię i nazwisko");
			error=true;
		}
		
		if($("#email_f").val()==""){
			fields.push("E-mail");
			error=true;
		}
		
		if($("#question_f").val()==""){
			fields.push("Treść wiadomości");
			error=true;
		}
		
		if(error==true){
			
			
			var t="";
			$.each(fields,function(i,v){
				t+=v+"\n";
			});
			
			alert("Prosimy uzupełnić wymagane pola:\n"+t);
			return false;
		}
	});


});

