
/**** preloader ****/

if (start) {
	var ima = new Array('tlo_menu_hover.png', 'kreska2.png', 'przejdz2.png', 'h3.png', 'punktator2.png', 'baloon1.gif', 'baloon2.png', 'baloon3.gif', 'baloon4.gif', 'baloon5.png', 'baloon6.gif', 'baloon7.png', 'baloon8.png', 'colorbox/loading.gif', 'colorbox/border.png', 'colorbox/controls.png', 'colorbox/loading_background.png', 'colorbox/overlay.png');
	for(var i = 0; i < ima.length; ++i) {
		temp = ima[i];
		ima[i] = new Image();
		ima[i].src = base+'tpl/pl/szablon1/img/'+temp;
	}
}

/***** linki do innych stron *****/

function href(url) {
	window.location.href = url;
}

$(document).ready(function() {

	var buff, temp, stop;

	// ------ _target="blank"
	buff = $('a').map(function() { return $(this); });
	jQuery.each(buff, function(index, value) {
		temp = value.attr('href');
		//if (temp != undefined && (temp.substr(0, 7) == 'http://' || temp.substr(0, 8) == 'https://')) {
		if (temp != undefined) {
			if (temp.substr(0, 7) == 'http://' || temp.substr(0, 8) == 'https://') {
				stop = temp;
				temp = temp.replace(/http:\/\//, '');
				if (temp != stop) {
					temp = temp.split('/');
					if (temp[0] != window.location.host) value.attr('target', '_blank');
				}
			} else if (temp.substr(0, 16) == 'javascript:href(') {
				value.attr('target', '_blank');
				value.attr('rel', 'nofollow');
				value.attr('href', temp.substr(17, temp.length - 19));
			} else if (temp.substr(0, 7) == 'mailto:') {
				value.attr('href', 'mailto:'+temp.substr(7, temp.length).replace(/ at /i, '@').replace(/ dot /gi, '.') );
				value.attr('title', temp.substr(7, temp.length).replace(/ at /i, '@').replace(/ dot /gi, '.') );
				value.text(temp.substr(7, temp.length).replace(/ at /i, '@').replace(/ dot /gi, '.') );
			}
		}
	});
	stop = false;

	/**** slider str glownej ****/

	if (glowna) $("#slider").SNAZslider({'random' : true});

	/**** slider portfolio ****/

	$("#slider2").SNAZslider();

	/**** slider pod-tytulu ****/

	window.setTimeout("tytul_slider()", 5000);

	/**** KolorBox ajax ****/

	kolorbox();

	/**** *** ****/

	$('#temat_wiadomosci').change(function() {
		if ($(this).attr('value') == 'Inny temat:') $('#wlasny_temat2').css({'display':''}); else $('#wlasny_temat2').css({'display':'none'});
	});

	/**** *** ****/

	$('#zaawansowanee').click(function() {
		if (!stop) {
			stop = 1;
			if ($('#zaawansowane').attr('value') == 1) {
				$('#mapa_strony').fadeOut(300, function() {
					$('#zaawansowane').attr('value', 0);
					$('#zaawansowanee').html('wyszukiwanie zaawansowane');
					stop = 0;
				});
			} else {
				$('#mapa_strony').fadeIn(500, function() {
					$('#zaawansowane').attr('value', 1);
					$('#zaawansowanee').html('wyszukiwanie proste');
					stop = 0;
				});
			}
		}
	});

	/**** *** ****/

	$('#suk').focus();

	/**** *** ****/

	$('.bix').hover(
		function() {
			$(this).css('backgroundImage', 'url("'+base+tpl+'img/kreska3.png")');
		},
		function() {
			$(this).css('backgroundImage', 'url("'+base+tpl+'img/kreska2.png")');
		}
	);

	/**** *** ****/

});

/**** KolorBox ****/

function kolorbox() {
	$('a').click(function(){
		if (this.href.indexOf('Slownik') != -1 && this.href.indexOf('.html') != -1 && window.location.href.indexOf('Slownik') == -1 && window.location.href.indexOf('Szukaj') == -1) {
			$.fn.colorbox({href:this.href+',ajax', width:'850px', onComplete:function(){ kolorbox(); }, onClosed:function(){ $('a').unbind('click'); kolorbox(); } });
			this.blur();
			return false;
		}
		if (this.href.indexOf('Portfolio') != -1) {
			$.fn.colorbox({href:this.href+',ajax', width:'780px', height:'600px', onComplete:function(){ kolorbox(); }, onClosed:function(){ $('a').unbind('click'); kolorbox(); } });
			this.blur();
			return false;
		}
	});
}

/**** rotacja pod-tytulu ****/

var tytul_slider_items = new Array('aplikacje dedykowane', 'projektowanie baz danych', 'pozycjonowanie stron www', 'projektowanie stron www', 'monitoring stron www', 'konfiguracja sieci i serwerów', 'tworzenie stron firmowych', 'tworzenie portali internetowych', 'optymalizacja kodu programów');
function fisherYates(myArray) {
	var i = myArray.length;
	if (i < 2) return;
	while (--i) {
		var j = Math.floor(Math.random() * (i+1));
		var tempi = myArray[i];
		var tempj = myArray[j];
		myArray[i] = tempj;
		myArray[j] = tempi;
	}
}
fisherYates(tytul_slider_items);
tytul_slider_items.push('strony na zamówienie');
var tytul_slider_iterator = 0;
function tytul_slider() {
	$('#top h1 strong').fadeOut(1000, function() {
		++tytul_slider_iterator;
		try {
			if (!tytul_slider_items[tytul_slider_iterator]) tytul_slider_iterator = 0;
		}
		catch(e) { tytul_slider_iterator = 0; }
		$('#top h1 strong').text(tytul_slider_items[tytul_slider_iterator]);
		$('#top h1 strong').fadeIn(1000, function() {
			window.setTimeout("tytul_slider()", 5000);
		});
	});
}

/**** *** ****/

