var _GET = new Array();
  var query = window.location.search.substring(1);
  var parms = query.split('&');
  for (var i=0; i<parms.length; i++) {
        var pos = parms[i].indexOf('=');
        if (pos > 0) {
           var key = parms[i].substring(0,pos);
           var val = parms[i].substring(pos+1);
           _GET[key] = val;
        }
  }


$(document).ready(function() {
		
		
		
	$("#star-container").tabs("div.star-text-box", {event:'mouseover'});
	
	$(".slidetabs").tabs(".expert-advice-box", {
			// enable "cross-fading" effect
			effect: 'fade',
			fadeOutSpeed: "slow",
			
			// start from the beginning after the last tab
			rotate: true
			
			// use the slideshow plugin. It accepts its own configuration
	}).slideshow({
			interval: 6000,
			autoplay: true
	});
	
	//$("#weather_future").click(function(){
	//	$("#weather_day_box").slideDown();
	//});
	
	$("#weather_future").toggle(
      function () {
        $("#weather_day_box").slideDown(500,function() {
        	$("#weather_future").text('Zwiń');
        });
        
      },
      function () {
        $("#weather_day_box").slideUp(500,function() {
        	$("#weather_future").text('Kolejne dni');
        });
      }
    );
	
    $("#dolacz_zdjecie").toggle(
      function () {
      	$("#dolacz_zdjecie").attr('checked', 'checked');
        $("#admin_photo_box").slideDown(500);
      },
      function () {
      	$("#dolacz_zdjecie").attr('checked', 'none');
        $("#admin_photo_box").slideUp(500);
      }
    );
    
    
    
    
    $("#weather_cityname").click(function(){
    	 //$("#cityname_list").css({"display":"block"});
    	 $("#cityname_list").slideDown(250);
    	 return false;
    });
    
    $("#cityname_list").mouseleave(function(){
    	//$("#cityname_list").css({"display":"none"});
    	$("#cityname_list").slideUp(250);
    	 return false;
    });
    
    $("#event_cityname").click(function(){
    	 //$("#cityname_list").css({"display":"block"});
    	 $("#event_cityname_list").slideDown(250);
    	 return false;
    });
    
    $("#event_cityname_list").mouseleave(function(){
    	//$("#cityname_list").css({"display":"none"});
    	$("#event_cityname_list").slideUp(250);
    	 return false;
    });
    
    $.datepicker.regional['pl'] = {
		closeText: 'Zamknij',
		prevText: '&#x3c;Poprzedni',
		nextText: 'Następny&#x3e;',
		currentText: 'Dziś',
		monthNames: ['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec',
		'Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],
		monthNamesShort: ['Sty','Lu','Mar','Kw','Maj','Cze',
		'Lip','Sie','Wrz','Pa','Lis','Gru'],
		dayNames: ['Niedziela','Poniedziałek','Wtorek','Środa','Czwartek','Piątek','Sobota'],
		dayNamesShort: ['Nie','Pn','Wt','Śr','Czw','Pt','So'],
		dayNamesMin: ['N','Pn','Wt','Śr','Cz','Pt','So'],
		weekHeader: 'Tydz',
		dateFormat: 'dd.mm.yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['pl']);
    
    // Datepicker
	$('#datepicker').datepicker({
		inline: true,
		//minDate: 0,
		dateFormat: 'yy-mm-dd',
		defaultDate: _GET['d'],
		onSelect: function(dateText) {
			//alert(dateText);
			location.href='/informacje_kulturalne/?d=' + dateText;
		}
	});
    
	
	
    $(".weather_cityname").click(function(){
    		if(window.location.href == 'www.kalcio.bejbej.pl'){
    			weather_url = "http://www.kalcio.bejbej.pl/weather/";
    		}
    		else {
    			weather_url = "/main/weather/";
    		}
    		
    	$.ajax({
    		url: weather_url,
    		type: "POST",
    		data: {
    			cityname: $(this).attr('title')
    		},
    		dataType: "xml",
    		success: function(xml){
    			
    			$(xml).find("current").each(function(){
    				$("#weather_cityname").text($(this).find("location").text());
    				$("#weather_icon").attr('src', '/img/weather/' + $(this).find("icon").text());
    				$("#weather_cur_condition").text($(this).find("condition").text());
    				$("#weather_cur_wind_condition").text($(this).find("wind_condition").text());
    				$("#weather_temp").text($(this).find("temperature").text());
    				$("#weather_cur_humidity").text($(this).find("humidity").text());
    			});
    			
    			$(xml).find("forecastDay").each(function(i){
    					
    					//alert($(this).find("high").text());
    					var day_hight = $(this).find("high").text();
    					var day_low = $(this).find("low").text();
    					var weather_day_icon = $(this).find("icon").text();
    					
    					$(".weather_day").each(function(j){
    						if(i==j) {
    							$(this).find(".weather_day_icon").attr('src', '/img/weather/' + weather_day_icon);
    							$(this).find(".day_hight").text(day_hight);
    							$(this).find(".day_low").text(day_low);
    						}
    					});
    					
    			});
    			
    			//$("#cityname_list").css({"display":"none"});
    			$("#cityname_list").slideUp(250);
    			
    		},
    		error: function(){}
    	});
    	
    	return false;
    });
    
	
	$("#head_menu_8").fancybox({
		'scrolling'		: 'no',
		'padding' : 0,
		'overlayColor' : '#ffffff',
		'titleShow'		: false,
		'onClosed'		: function() {
		    $("#login_error").hide();
		}
	});
	
	$('#star-zasuwaczki').mouseover(function() {
		$("#star-zasuwaczki").css({"background-position":"0 -95px"});
		$("#star-kalcio").css({"background-position":"0 0"});
		$("#star-mleczaki").css({"background-position":"0 0"});
		$("#star-sklep").css({"background-position":"0 0"});
		$("#star-ksiegarnia").css({"background-position":"0 0"});
	});
	
	$('#star-kalcio').mouseover(function() {
		$("#star-zasuwaczki").css({"background-position":"0 0"});
		$("#star-kalcio").css({"background-position":"0 -95px"});
		$("#star-mleczaki").css({"background-position":"0 0"});
		$("#star-sklep").css({"background-position":"0 0"});
		$("#star-ksiegarnia").css({"background-position":"0 0"});
	});
	
	$('#star-mleczaki').mouseover(function() {
		$("#star-zasuwaczki").css({"background-position":"0 0"});
		$("#star-kalcio").css({"background-position":"0 0"});
		$("#star-mleczaki").css({"background-position":"0 -95px"});
		$("#star-sklep").css({"background-position":"0 0"});
		$("#star-ksiegarnia").css({"background-position":"0 0"});
	});
	
	$('#star-sklep').mouseover(function() {
		$("#star-zasuwaczki").css({"background-position":"0 0"});
		$("#star-kalcio").css({"background-position":"0 0"});
		$("#star-mleczaki").css({"background-position":"0 0"});
		$("#star-sklep").css({"background-position":"0 -95px"});
		$("#star-ksiegarnia").css({"background-position":"0 0"});
	});
	
	$('#star-ksiegarnia').mouseover(function() {
		$("#star-zasuwaczki").css({"background-position":"0 0"});
		$("#star-kalcio").css({"background-position":"0 0"});
		$("#star-mleczaki").css({"background-position":"0 0"});
		$("#star-sklep").css({"background-position":"0 0"});
		$("#star-ksiegarnia").css({"background-position":"0 -95px"});
	});
	
	
	$('#left_slider').nivoSlider({
		
	});
	
	//$(".slidetabs").data("slideshow").play();
});

function dodajDoFacebook() { window.open('http://www.facebook.pl/share.php?u=' + encodeURIComponent(location.href)+ '&t=' + encodeURIComponent(document.title), 'Facebook'); }
function gronoLinkWidget() {window.open('http://grono.net/pub/popup/link/urlfetch/?url=' + encodeURIComponent(location.href)+ '&title=' + encodeURIComponent(document.title) + '', 'Grono', 'menubar=no,width=600,height=450,toolbar=no');return false;}
function dodajDoWykopu() { window.open('http://www.wykop.pl/dodaj?url=' + encodeURIComponent(location.href)+ '&title=' + encodeURIComponent(document.title), 'Wykop'); }
function dodajDoDelicious() { window.open('http://del.icio.us/post?url=' + encodeURIComponent(location.href)+ '&title=' + encodeURIComponent(document.title), 'Delicious'); }
function dodajDoZakladekGoogle() { window.open('http://www.google.com/bookmarks/mark?op=edit&bkmk=' + encodeURIComponent(location.href)+ '&title=' + encodeURIComponent(document.title), 'Google'); }
function dodajDoDigg() { window.open('http://digg.com/submit?phase=2&url=' + encodeURIComponent(location.href)+ '&title=' + encodeURIComponent(document.title), 'Digg'); }
function dodajDoTwitter() { window.open('http://twitter.com/home?status=' + encodeURIComponent(location.href), 'Twitter'); }
function dodajDoBlip() { window.open('http://blip.pl/dashboard?body=' + encodeURIComponent(location.href), 'Blip'); }
function dodajDoSledzik() { window.open('http://nasza-klasa.pl/sledzik?shout=' + encodeURIComponent(location.href), 'Sledzik');} 
function dodajDoUlubionych(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}


