﻿//PLIK: jquery-functions.js
//OPIS: Instrukcje jQuery

$(document).ready(function()
{
//---
	
	$("span.height").hide();
	$("div.vertbar_hidden").hide();

	$(".less").click(function() {
		var t = $(this).parent("div");
		
		if ($(this).children("a").children("img").attr("src") == "./img/-.gif") {
			var h = t.height();
			t.children("span.height").html(h);
			
			t.children("div.container").hide();		
			t.animate({height: '35px'});
			
			$(this).children("a").children("img").attr("src", "./img/+.gif");
			$(this).children("a.less_tekst").html("wi&#281;cej");
			
		} else {
			$(this).children("a").children("img").attr("src", "./img/-.gif");
			$(this).children("a.less_tekst").html("");
			t.children("div.container").show();		
			h = t.children("span.height").html();
			t.animate({height: h});
		}		
	});

	$(".more").click(function() {
		var t = $(this).parent("div");
		
		if ($(this).children("a").children("img").attr("src") == "./img/+.gif") {
			t.next("div.vertbar_hidden").slideDown();
			
			$(this).children("a").children("img").attr("src", "./img/-.gif");
			$(this).children("a.more_tekst").html("");
			
		} else {
			$(this).children("a").children("img").attr("src", "./img/+.gif");
			$(this).children("a.more_tekst").html("wi&#281;cej");
			
			t.next("div.vertbar_hidden").slideUp();
		}		
	});


	$("p.button_gratisy_tekst:eq(0)").click(function() {
		$(this).parent("div").css("background-image", "url(./img/button_gratisy_01a.png)");
		$("div.button_gratisy_02").css("background-image", "url(./img/button_gratisy_02i.png)");
		$("div.button_gratisy_03").css("background-image", "url(./img/button_gratisy_03i.png)");
		$(".box_gratisy_main").children("img").attr("src", "./img/gratisy_main_01_img.gif");
		$(".box_gratisy_main").children("p").html("Zamawiając logo w serwisie barwy.org możesz wybrać jako prezent <strong>kupon Google AdWords</strong> o wartości 200 PLN!");
	});

	$("p.button_gratisy_tekst:eq(1)").click(function() {
		$(this).parent("div").css("background-image", "url(./img/button_gratisy_02a.png)");
		$("div.button_gratisy_01").css("background-image", "url(./img/button_gratisy_01i.png)");
		$("div.button_gratisy_03").css("background-image", "url(./img/button_gratisy_03i.png)");
		$(".box_gratisy_main").children("img").attr("src", "./img/gratisy_main_02_img.gif");
		$(".box_gratisy_main").children("p").html("Tylko u nas zamawiając logo dostaniesz w prezencie <strong>500 wzytówek</strong>. Tak na dobry początek promocji twojego nowego logo.");
	});
	
	$("p.button_gratisy_tekst:eq(2)").click(function() {
		$(this).parent("div").css("background-image", "url(./img/button_gratisy_03a.png)");
		$("div.button_gratisy_01").css("background-image", "url(./img/button_gratisy_01i.png)");
		$("div.button_gratisy_02").css("background-image", "url(./img/button_gratisy_02i.png)");
		$(".box_gratisy_main").children("img").attr("src", "./img/gratisy_main_03_img.gif");
		$(".box_gratisy_main").children("p").html("<strong>DVD przyjazne drukarni</strong> to przygotowana przez nas płyta DVD, gdzie zamówione logo zapisujemy w róznych formatach plików.");
	});

	$("span.box_wybrani_klienci_nastepny").css("display", "none");
	
	$("img.box_wybrani_klienci_button_reload").mouseover(function() {
		$("span.box_wybrani_klienci_nastepny").fadeIn(200);
	});

	$("img.box_wybrani_klienci_button_reload").mouseout(function() {
		$("span.box_wybrani_klienci_nastepny").fadeOut(200);
	});
	
	var src = "./img/klienci/0" + rand (6) + ".jpg";
	
	$(".box_wybrani_klienci_logo").children("img").attr("src", src);
	
	$(".box_wybrani_klienci_button_reload").click(function (){
		$(".box_wybrani_klienci_logo").children("img").fadeOut(function(){
			
			var src = "./img/klienci/0" + rand (6) + ".jpg";
			
			$(".box_wybrani_klienci_logo").children("img").attr("src", src);													 
		});
		
		$(".box_wybrani_klienci_logo").children("img").fadeIn("slow");
	});
	
//---
});

function rand (n)
{
  return ( Math.floor ( Math.random ( ) * n + 1 ) );
}

