﻿$(function() {
	$('body').removeClass('no-js').addClass('js');

	$('a[rel*=external]').click(function() {
		window.open(this.href);
		return false;
	});

	$('a.email[rel]').each(function() {
		e = this.rel.replace('/', '@');
		this.href = 'mailto:' + e;
		$(this).text(e);
	});

	// v 2.0
	$('form:has(input[type=submit])').each(function() {
		var thisForm = $(this);
		var submitButton = thisForm.find('input[type=submit]');
		var link = $('<a href="#" class="submitReplacement" title="' + submitButton.attr('value') + '">' + submitButton.attr('value') + '</a>');
		link.insertAfter(submitButton).click(function() {
			thisForm.submit();
			return false;
		});
		submitButton.remove();
	});

	// Stary cufon
	Cufon.replace("#home #row3 .offer .mini", { fontFamily: "DaxlineProTB" });
	Cufon.replace("#nav .navItems a", { fontFamily: "DaxlineProRM", textShadow: '#747575 1px 1px' });
	Cufon.replace("#home #row1 .news h2, #home #row3 .calendarBox .inner h2", { fontFamily: "DaxlineProRM" });
	Cufon.replace("#home #row3 .offer .more", { fontFamily: "DaxlineProRM", hover: true });
	Cufon.replace("#home #row3 .calendar .all", { fontFamily: "DaxlineProRM", hover: true });
	Cufon.replace("#home #row3 .offer h3 a", { fontFamily: "DaxlineProRM", hover: true });
	Cufon.replace("#home #row2 .select a", { fontFamily: "DaxlineProRM", hover: true });
	Cufon.replace(".bnrAccounting .zl, .bnrAccounting .gr, .bnrAccounting .napisZl", { fontFamily: "DaxlineProRM" });
	Cufon.replace("#home #row2 #featuresCarousel li .mini", { fontFamily: "DaxlineProTB" });
	Cufon.replace("#home #row2 #featuresCarousel li h2", { fontFamily: "DaxlineProRM" });
	Cufon.replace("#home #row2 #featuresCarousel li .details", { fontFamily: "DaxlineProRM" });

	// Cufon :
	Cufon.replace("#nav .navItems a", { fontFamily: "DaxlineProRM", textShadow: '#747575 1px 1px' });
	Cufon.replace("#nav .cooperation p, #nav .cooperation .seeOffer, #linksBar .go-up, #home .news h2", { fontFamily: "DaxlineProRM" });
	Cufon.replace("#header h1, #default .infoBox .left h2,  #vertmenu h2", { fontFamily: "DaxlineProRM" });
	Cufon.replace(".side-bnr-accounting .zl, .side-bnr-accounting .gr, .side-bnr-accounting .napisZl, .side-news h2", { fontFamily: "DaxlineProRM" });
	Cufon.replace("#default .table table th", { fontFamily: "DaxlineProRM" });
	Cufon.replace("#default .infoBox .center li", { fontFamily: "DaxlineProRM", hover:true, hoverables: { a: true } });
	Cufon.replace('#top .slogan', { fontFamily: 'DaxlineProRM' });
	Cufon.replace('#top .slogan strong', { fontFamily: 'DaxlineProTB' });

	// 30.06.11

	Cufon.replace('#top .contact p, #top .contact-link', { fontFamily: 'DaxlinePro-Light' });
	Cufon.replace('#top .contact p strong, #top .contact-link strong, #home .solutions h2,', { fontFamily: 'DaxlineProRM' });
	Cufon.replace('#home .software h2, #home .solutionz h2, #home .product .more, .side h2,',{ fontFamily: 'DaxlineProRM'});
	Cufon.replace('#home .software .subtitle', { fontFamily: 'DaxlinePro-Light'});
	Cufon.replace('#home .product .price strong, #home .solutions .minihead', { fontFamily: 'DaxlineProTB' });
	/* IE9+ */

	// Loginy :
	$("#loginLogin").placeholder();
	$("#loginPassword").placeholder();

	//Cycle na głównej :
	$('#slideshow').cycle({
		slideExpr: '.slide',
		timeout: 4000,
		fx: 'fade',
		pager: '#slideshowPager'
	});

	// Cycle oprogramowanie
	$('#softwareCycle').cycle({
		slideExpr: '.item',
		next: '#softwareNext',
		prev: '#softwarePrev',
		timeout: 4000
	});

	// Scroll na głównej :
	$('#go-up').smoothScroll();

	// 

	var $solutions = $('#solutions');
	var czas = 'fast';
	if (! jQuery.support.leadingWhitespace) czas = 0;

	$solutions.children('.desc').each(function() {
		$(this).css("height", $(this).height());
	});

	$solutions.children('.desc').hide().eq(0).show();
	$solutions.children('h3:first').addClass('expanded');
	$solutions.children('h3').css('cursor', 'pointer').click(function() {
		var toToggle = $(this).next();
		if (! toToggle.is(':visible')) {
			$solutions.children('.desc').slideUp(czas);
			$solutions.children('h3').removeClass('expanded');
			$(this).addClass('expanded');
			toToggle.slideDown(czas, function() {
			});

		}
	});

// part 2//
	var $solutionz = $('#solutionz');
	var czas = 'fast';
	if (! jQuery.support.leadingWhitespace) czas = 0;

	$solutionz.children('.desc').each(function() {
		$(this).css("height", $(this).height());
	});

	$solutionz.children('.desc').hide().eq(0).show();
	$solutionz.children('h3:first').addClass('expanded');
	$solutionz.children('h3').css('cursor', 'pointer').click(function() {
		var toToggle = $(this).next();
		if (! toToggle.is(':visible')) {
			$solutionz.children('.desc').slideUp(czas);
			$solutionz.children('h3').removeClass('expanded');
			$(this).addClass('expanded');
			toToggle.slideDown(czas, function() {
			});

		}
	});


//cycle

$('#slideshowContainer').append('<div class="control"></div>');
	$('#slideshowContainer .control')
			.append('<div id="slideshowPager"></div>')
			.append('<div id="slideshowLoader"></div>')
			.append('<p id="slideshowCaption"></p>');

	$('#slideshowContainer').cycle({
		slideExpr: '.slide',
		timeout: 4000,
		fx: 'fade',
		pager: '#slideshowPager',
		before: function() {
			$('#slideshowLoader').removeClass('loading');
			$('#slideshowCaption').text($(this).children('img').attr('alt'));
		},
		after: function() {
			$('#slideshowLoader').addClass('loading');
		}
	});


});
