/*
 * Ustawia strone startowa
 */
function setHomepage()
{
 if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
  		document.body.setHomePage('http://xstart.pl');
 
    }
    else if (window.sidebar)
    {
    if(window.netscape)
    {
		try
		{ 
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
		} 
		catch(e) 
		{ 
		alert("Twoja przeglądarka nie obsługuje automatycznej zmiany strony startowej. By ją zmienić przejdź do 'Edycja'->'Preferencje' a w zakładce 'Ogólne' zmień 'Strona Startowa' na http://xstart.pl lub przeciągnij logo serwisu na znaczek domku w Twojej przeglądarce"); 
		}
	}
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage','http://xstart.pl');
 }
}

$(document).ready(function(){
    $('#q').focus();

    /*
     * Wyswietla poddzialy
     */
    $('#sections .menu ul li').mouseenter(function() {
        $('#sections .menu ul li').removeClass('select');
        $(this).addClass('select');
        $('#sections .body div.item').hide();
        $('#'+$(this).attr('go')).show();
    });
    
    $('.sections-min .menu ul li').mouseenter(function() {
        $('.sections-min .menu ul li').removeClass('select');
        $(this).addClass('select');
        $('.sections-min .body div.item').hide();
        $('#'+$(this).attr('go')).show();
    });
    
    /*
     * Podobne artykuly
     */
    
    $('a.similar').mouseenter(function() {
        $('div.glowny').hide();
        $('#'+$(this).attr('id')).show();
    });
    
    /*
     * Ustawia radio na srodku w glownych dzialach
     */
    $('#menu_center ul li a').each(function(){
        $(this).children('img').css('left',Math.round(($(this).width()-7)/2));
        
    });
    
    /*
     * Po najechaniu zmienia zaznaczenie radio
     */
    $('#menu_center ul li a')
            .mouseover(function(){  
                $(this).children('img').attr('src','images/' + $(this).children('img').attr('over') + ".gif");
            })
            .mouseout(function(){  
                $(this).children('img').attr('src','images/' + $(this).children('img').attr('out') + ".gif");
            });
            
$('#edodatki_widget_weather_city').find('.link').css('display','none');
$('#edodatki_widget_weather_city').find('.city_name').css('cursor','pointer');
            
    /*
     * Obsluguje zmiane miasta w pogodzie
     */
    $('.city_name').click(function() {
        if($(this).attr('select'))
        {
            $(".city_name").change(function () {
                  var str = "";
                  $(".city_name select option:selected").each(function () {
                        str = $(this).val();
                      });
                $("#edodatki_widget_weather_city").ajaxStart(function(){
                   $('.city_name').append('<img src="images/load.gif" alt="" />');
                 });

                $.ajax({
                    type: "GET",
                    url: "ajax.php",
                    data: "setCity="+str,
                    success: function(msg) {
                        if(msg == 'reload')
                        {
                            window.location.href = 'http://xstart.pl/';
                        }
                    }
                });
            });
        }
        else
        {
            $("#edodatki_widget_weather_city").ajaxStart(function(){
                   $('.city_name').append('<img src="images/load.gif" alt="" />');
                 });

             $("#edodatki_widget_weather_city").ajaxStop(function(){
               $('.city_name img').remove();
             });
                 
            $.ajax({
                type: "GET",
                url: "ajax.php",
                data: "getCity=1",
                success: function(msg) {
                    $('.city_name').html(msg);
                    $('.city_name').attr('select','true');
                }
            });
        }
    });
    
});

/*
 * TWORZY LADNE LINKI
 */
function redirect(f,url_base)
{ 
    window.location.href=url_base+'/'+f.elements['year'].value+'/'+f.elements['month'].value+'/'+f.elements['day'].value+'/'; 
    return false;
}


