function sponsor_gold_switcher(c) {

	//console.log(sponsor_gold_switcher.i);

	if ( typeof sponsor_gold_switcher.count == 'undefined' ) {
        sponsor_gold_switcher.count = c;
    }
	
	if ( typeof sponsor_gold_switcher.i == 'undefined' ) {
        sponsor_gold_switcher.i = 0;
    }

	sponsor_gold_switcher.i++;
	
	$('#bottom_all .items').find('ul li').hide('medium');
	
	if(sponsor_gold_switcher.i == sponsor_gold_switcher.count) {
		sponsor_gold_switcher.i = 0;
	}
	
	$('#bottom_all .items').find('ul li:eq('+(sponsor_gold_switcher.i)+')').show('medium');
}
//
// Główny skrypt
//
$(document).ready(function(){

	
	
	// fancybox
	$('.lightBox').fancybox();
	
	// hover dla gornego menu

	$(".logopp").hover(
		function(){
			var src = $(this).children("img").attr("src");												
			src = src.replace(".gif", "_on.gif")						
			$(this).children("img").attr("src",src);
		},
		function() {
			var src = $(this).children("img").attr("src");												
			src = src.replace("_on.gif", ".gif")						
			$(this).children("img").attr("src",src);		
		}
	);

	
	$("#topmenu a").hover(		
			function () {				
				var src = $(this).children("img").attr("src");												
				src = src.replace(".jpg", "_on.jpg")				
				$(this).children("img").attr("src",src);
			}, 
			function () { 			
				var src = $(this).children("img").attr("src");								
				src = src.replace("_on.jpg", ".jpg")
				$(this).children("img").attr("src",src);
			}				 
		); 	

	// dlgNewsletter
	$('a[href="#dlgNewsletter"]').fancybox();
		
	


	//
	// zdjęcia w artykule
	//
	$('#artPic4Carousel').jCarouselLite({		
		btnNext: ".nextB",
        btnPrev: ".prevB",			
		visible: 7,	
		vertical:false,
		circular:false
	});



	//
	// Logotypy w stopce
	//
	$('#sponsorzy .carousel').jCarouselLite({
		/*auto: 10000,*/
		speed: 1000,
		visible: 5,
		vertical: true
	});

   $('.sponsorzy .carousel').jCarouselLite({
		/*auto: 10000,*/
		speed: 1000,
		visible: 4
	});


	var vitemcount = 5
	// if ($.browser.msie) { vitemcount = 3 }
	$('#pm .carousel').jCarouselLite({
		auto: 10000,
		speed: 1000,
		visible: vitemcount
	});
	
	// fix
	//$('#pm .carousel').css( 'width', 840 );
	//$('#pm .carousel li').css( 'width', 190 );
	
	$('#pw .carousel').jCarouselLite({
		auto: 10000,
		speed: 1000,
		visible: 4		
	});

	// console.log($('#pww .carousel li').length);
	if ($('#pww .carousel li').length > 3) {
		$('#pww .carousel').jCarouselLite({		
			auto: 10000,
			speed: 1000,
			visible: 3
		});
	} else {
		$('#pww .carousel').removeClass('carousel').addClass('no_carousel');
	}
	

	$('#pmerr .carousel').jCarouselLite({		
		auto: 10000,
                speed: 1000,
		visible: 3
	});		
	
	$('#pmer .carousel').jCarouselLite({
		auto: 10000,
		speed: 1000,
		visible: 3
	});	
	
	$('#bottom_all .items').each(function() {
		var count = $(this).find('ul li').length;
		var i = 0;
		sponsor_gold_switcher(count);
		setInterval('sponsor_gold_switcher('+count+')', 10000);
	})
	
	$(".tooltip").each(function(){
		if ($(this).attr('title')!=''){
			$(this).wTooltip({
			style: {
				border: "1px solid #e7e7e7",
				background: "white",
				maxWidth: "500px"
			}
			})
		}						
	});

	$('.nav>li>ul').hide();
	
	var element_aktywny = $('a.active', $('.nav') );
	
	element_aktywny.show();
	element_aktywny.parent().show();
	element_aktywny.parent().parent().show();
	element_aktywny.parent().parent().parent().show();

	$('a', $('.nav')).each(function(i,el){				
		if (($(this).attr('href')==location.href)&&(location.href.indexOf('product,index,')==-1)){
			$(this).parent().children('ul').show();			
			//$(this).parent().children('a').css('backgroundColor','#83161D');			
			$(this).parent().children('a').css('color','white');			
			$(this).parent().children('a').css('fontWeight','bold');													
		}
				
	});	

	$('a', $('.nav')).each(function(i,el){				
		if ($(this).attr('href')==location.href){
			$(this).parent().children('ul').show();
									
			$(this).parent().show();
			$(this).parent().parent().show();
		}
				
	});		
	

	$(".lang_box").hover(		
		function () { 				
			$(this).attr('className','lang_box_on');			
		}, 
		function () { 			
			$(this).attr('className','lang_box');			
		}				 
	); 				
	
	// gorne menu
	$(".topmenu1").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/pl/menu1_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 			
	$(".topmenu2").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/pl/menu2_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 				
	$(".topmenu3").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/pl/menu3_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 			
	$(".topmenu4").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/pl/menu4_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 			

	$(".topmenu5").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/pl/menu5_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 				

	$(".topmenu6").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/pl/menu6_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 			

	// gorne menu EN
	$(".topmenu1_en").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/en/menu1_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 			
	$(".topmenu2_en").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/en/menu2_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 				
	$(".topmenu3_en").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/en/menu3_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 			
	$(".topmenu4_en").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/en/menu4_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 			

	$(".topmenu5_en").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/en/menu5_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 				

	$(".topmenu6_en").hover(		
		function () { 	
			$(this).attr('rel',$(this).attr('src'));
			$(this).attr('src','../views/img/en/menu6_on.jpg');
		}, 
		function () { 			
			$(this).attr('src',$(this).attr('rel'));
		}				 
	); 			







	
	$("#wyslij_zapytanie_img").bind('click',function(e){							
		$("#wyslij_zapytanie").slideToggle("slow");
	});		
	
	
	$(".menu_boczne .menuItem0 > a").hover(		
		function () { 				
			//$(this).css('text-decoration','none');			
			//$(this).attr('alt',$(this).css('backgroundColor')+'|'+$(this).css('fontWeight'));
			$(this).css('color','#007c2e');			
			//$(this).css('backgroundColor','#83161C');				
		}, 
		function () { 			
			//$(this).css('text-decoration','none');								
			//var zmienna = $(this).attr('alt').split('|');			
			//$(this).css('backgroundColor',zmienna[0]);						
			//if ((zmienna[0]!='rgb(131,22,28)')&&(zmienna[0]!='rgb(131, 22, 28)'))
				//$(this).css('color','#222222');
			//else
				;//alert('i tak');
			$(this).css('color','black');
			
			
			$('a', $('.nav')).each(function(i,el){				
				if (($(this).attr('href')==location.href)&&(location.href.indexOf('product,index,')==-1)){
					$(this).parent().children('ul').show();								
					$(this).parent().children('a').css('color','#007c2e');	
					$(this).parent().children('a').css('fontWeight','bold');										
				}
			});							
			
		}		
		 
	); 		
	
	$(".menu_boczne .menuItem1 > a").hover(		
		function () { 			
			$(this).attr('alt',$(this).css('background'));			
			$(this).attr('rev',$(this).css('fontWeight'));			
			$(this).css('background','url(views/img/right_arrow_gray.gif) no-repeat scroll 0 55% #FFFFFF');				
			$(this).css('textDecoration','none');
			$(this).css('fontWeight','bold');
		}, 
		function () { 						
			$(this).css('background',$(this).attr('alt'));			
			$(this).css('fontWeight','normal');			
			if ($(this).attr('className')=='active'){
				$(this).css('fontWeight','bold');			
			}	
			$(this).css('textDecoration','none');
			//$(this).css('fontWeight','normal');
		}		
		 
	); 		
		

	$(".middle").hover( 
		function () { 			
			$(this).css('border','3px solid #00731e');			
		}, 
		function () { 			
			$(this).css('border','3px solid #FFFFFF');
		}		
		 
	); 	
	
	$(".previous").hover( 
		function () { 			
			$(this).css('text-decoration','underline');						
		}, 
		function () { 			
			$(this).css('text-decoration','none');
		}		
		 
	); 	

	
	$("#contact_wyslij_pl").hover( 
		function () { 			
			$(this).attr('src','http://vero.unito.pl/views/img/pl/button_contact_on.png');
		}, 
		function () { 			
			$(this).attr('src','http://vero.unito.pl/views/img/pl/button_contact.png');
		}		
		 
	); 	
	$("#contact_wyslij_en").hover( 
		function () { 			
			$(this).attr('src','http://vero.unito.pl/views/img/en/button_contact_on.png');
		}, 
		function () { 			
			$(this).attr('src','http://vero.unito.pl/views/img/en/button_contact.png');
		}		
		 
	); 		

	$(".box_salonu").hover( 
		function () { 			
			$(this).css('background','#ffffff');
		}, 
		function () { 			
			$(this).css('background','none');
		}		
		 
	); 	
	$('.box_salonu').bind('click',function(e){			
		$(this).children(".wewnatrz").children(".link").click();
	});							



	$('.sitemap .p0 a').each(function(i,el){
		var randID = 'rand'+Math.floor(Math.random()*1000);
		var tmp = document.createElement("span");		
		$(el).wrap(tmp);
		$(el).attr('id',randID);
		
		var tekst = el.innerHTML.replace('&nbsp;',' ');
		
		swfobject.embedSWF(
			'/views/flash/textbox.swf?tekst='+tekst, 
			randID, 
			"690px", 
			"40px", 
			"9.0.0", 
			"",
				{ },
				{swliveconnect: true, wmode: "transparent", scale: "noScale", menu: "false", align: "left", salign: "TL"},
				{id: randID, name: randID}
		);

		
	});		



	
	$('.naglowek').each(function(i,el){
		var randID = 'rand'+Math.floor(Math.random()*1000);
		var tmp = document.createElement("span");
        tmp.style.marginLeft = '0px';
		$(el).wrap(tmp);
		$(el).attr('id',randID);

		var tekst = el.innerHTML.replace('&nbsp;',' ');
		
		swfobject.embedSWF(
			'/views/flash/textbox.swf?tekst='+tekst, 
			randID, 
			"690px", 
			"40px", 
			"9.0.0", 
			"",
				{ },
				{swliveconnect: true, wmode: "transparent", scale: "noScale", menu: "false", align: "left", salign: "TL"},
				{id: randID, name: randID}
		);

		
	});		
	
	$('.naglowek_z_data').each(function(i,el){
		var randID = 'rand'+Math.floor(Math.random()*1000);
		var tmp = document.createElement("span");		
		$(el).wrap(tmp);
		$(el).attr('id',randID);

		var tekst = el.innerHTML.replace('&nbsp;',' ');
		var moja_data = $("#data_dodania").attr("value");
		swfobject.embedSWF(
			'/views/flash/textbox.swf?tekst='+tekst+'&dodano='+moja_data, 
			randID, 
			"690px", 
			"40px", 
			"9.0.0", 
			"",
				{ },
				{swliveconnect: true, wmode: "transparent", scale: "noScale", menu: "false", align: "left", salign: "TL"},
				{id: randID, name: randID}
		);

		
	});			
	
	
	$('.naglowek2').each(function(i,el){
		var randID = 'rand'+Math.floor(Math.random()*1000);
		var tmp = document.createElement("span");		
		$(el).wrap(tmp);
		$(el).attr('id',randID);
        $(el).css('margin-left','0px');
		
		var tekst = el.innerHTML.replace('&nbsp;',' ');
		
		swfobject.embedSWF(
			'/views/flash/textbox.swf?tekst='+tekst, 
			randID, 
			"300px", 
			"30px", 
			"9.0.0", 
			"",
				{ },
				{swliveconnect: true, wmode: "transparent", scale: "noScale", menu: "false", align: "left", salign: "TL"},
				{id: randID, name: randID}
		);

		
	});	
	


	$(".box_salonu").hover( 
		function () { 			
			$(this).css('background','#ffffff');
		}, 
		function () { 			
			$(this).css('background','none');
		}		
		 
	); 	
	
	
	$('.naglowek').each(function(i,el){
		var randID = 'rand'+Math.floor(Math.random()*1000);
		var tmp = document.createElement("span");		
		$(el).wrap(tmp);
		$(el).attr('id',randID);
		$(el).css('margin-left', '0px');
		var tekst = el.innerHTML.replace('&nbsp;',' ');
		
		swfobject.embedSWF(
			'/views/flash/textbox.swf?tekst='+tekst, 
			randID, 
			"690px", 
			"40px", 
			"9.0.0", 
			"",
				{ },
				{swliveconnect: true, wmode: "transparent", scale: "noScale", menu: "false", align: "left", salign: "TL"},
				{id: randID, name: randID}
		);

		
	});		
	
	// Strona główna, top
	// flashvars, params, attributes
	swfobject.embedSWF(
		'views/flash/baner.swf', 'top_srodek',
		'430', '170', '9.0.0', '', {sciezka: 'Awards.php'}, { }, {'wmode': 'transparent'}
	);

	swfobject.embedSWF(
		'views/flash/salony.swf', 'salony',
		'435', '375', '9.0.0', '', {}, { }, {'wmode': 'transparent'}
	);	
	
	swfobject.embedSWF(
		'views/flash/animacja.swf', 'main_flash_podmianka',
		'940', '486', '9.0.0', '', {'wmode': 'transparent'}, {'wmode': 'transparent'}, {'wmode': 'transparent'} 
	);

	$.datepicker.setDefaults({
		firstDay: '1',
		dateFormat: 'yy-mm-dd',
		changeYear: true,
		dayNames: ['Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'],
		dayNamesMin: ['Nd', 'Pn', 'Wt', 'Śr', 'Cz', 'Pt', 'So'],
		monthNames: ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień']
	});

	// IE hover hack.
	$('.newsDetails img').mouseenter(function(){
		$(this).addClass('on');
	}).mouseleave(function(){
		$(this).removeClass('on');
	});

	//
	// Logotypy w stopce
	//
	$('#spolki .carousel').jCarouselLite({
		auto: 3000,
		speed: 1000,
		visible: 7
	});

	//
	// Zewnętrzne linki
	//
	$('a[rel~="external"]').attr('target', '_blank');

	//
	// LI float hack :]
	//
	//$('.fck ul li').prepend($('<img src="views/img/arrow.gif" alt="" />'));

	//
	// Hack na tło w tabelach FCK
	//
	$.each($('.fck td'), function(){
		var value = $(this).attr('bgcolor');

		if (value)
			$(this).css('background-color', value);
	});

	$.each($('.fck img'), function(){
		var value = $(this).attr('align');

		if (value)
			$('.fck img').css('text-align', 'left');
	});

	$.each($('.fck td'), function(){
		var value = $(this).attr('valign');

		if (value)
			$(this).css('vertical-align', value);
	});

	$.each($('.fck table'), function(){
		var value = $(this).attr('cellpadding');

		if (value)
			$(this).css('border-spacing', value + 'px');
	});
	
	
	$('#.oneBaner').css('width','312px');
	
	
	$('#.oneBaner').css('width','312px');

	$('#artPic4Carousel').click(function() {
		$('#uptopContent embed').hide();
	})

	$('.calosc, #uptop_all, #bottom_all').mouseover(function() {
		$('#uptopContent embed').show();
	});
	
	
	
	/* PRZERÓBKA FORMULARZA */
	
	
	$('#pierwszydzien, #drugidzien').change(function() {
		
		$('#dwadni').attr('checked', false);
		$('#jedendzien').attr('checked', false);
		
		// Jeśli są zaznaczone obie kratki...
		if ($('#pierwszydzien').attr('checked') && $('#drugidzien').attr('checked')) {
			$('#dwadni').attr('checked', true);
			$('#drugidzien_wybierz_sesje').show();
		}
		
		// Jeżeli jest zaznaczony tylko pierwszy dzień...
		else if ($('#pierwszydzien').attr('checked') && !$('#drugidzien').attr('checked')) {
			$('#jedendzien').attr('checked', true);
			$('#jedendzien_6').click();
			$('#drugidzien_wybierz_sesje').hide();
		}
		
		// Jeżeli jest zaznaczony tylko drugi dzień...
		else if (!$('#pierwszydzien').attr('checked') && $('#drugidzien').attr('checked')) {
			$('#jedendzien').attr('checked', true);
			$('#jedendzien_7').click();
			
			// pokaż listę sesji do wyboru
			$('#drugidzien_wybierz_sesje').show();
			
		}
		
		// jeżeli nie jest zaznaczona żadna kratka
		else {
			$('#drugidzien_wybierz_sesje').hide();
		}
		
		oblicz_cene();
		
	})
	
	/* i jeszcze wybór sesji */
	$('#drugidzien_wybierz_sesje input').change(function() {
		
		$('#jedendzien_wybierz_sesje input[value="'+$(this).attr('value')+'"]').attr('checked', $(this).attr('checked') );
		$('#dwadni_wybierz_sesje input[value="'+$(this).attr('value')+'"]').attr('checked', $(this).attr('checked') );
		
		
	})
	
	// zablokuj możliwość wybrania obu rabatów
	$("input[name='rabat_terminowy']").change( function() {
		if ($("input[name='rabat_studencki']").attr('checked') == true) {
			$("input[name='rabat_studencki']").click();
			oblicz_cene();
		}
	})
	
	$("input[name='rabat_studencki']").change( function() {
		if ($("input[name='rabat_terminowy']").attr('checked') == true) {
			$("input[name='rabat_terminowy']").click();
			oblicz_cene();
		}
	})
	
	
	
	

});

