$(function(){
    var gUrl = jQuery.url.attr("anchor");
    if (gUrl == 'wrong_form'){
        $().message("Norādīji nepareizu vārdu vai paroli!");
    } else if (gUrl == 'welcome'){
        $().message("Laipni lūdzam klubiņā!")
    }else if (gUrl == 'profile_success'){
        $().message("Nomainīji informāciju par sevi!")
    }else if (gUrl == 'profile_failure'){
        $().message("Neizdevās nomainīt informācij!")
    }else if (gUrl == 'logout'){
        $().message("Gribēji aiziet neatvadījies?")
    }else if (gUrl == 'logged_in'){
        $().message("Tagad esi iekšā!")
    };
    $("#poster").jCarouselLite({
        btnNext: '.next',
        btnPrev: '.prev',
        auto: 5000,
        speed: 500,
        visible: 1
    });    
    $('.post_avatar, #album_cover').corner("5px");
    $('#article_img, #comments .gravatar').corner("5px");
    $('#poster .buttons li').corner("3px");
    $('div#article_img a').fancybox({
    	'overlayOpacity'	:	0.7,
    	'overlayColor'		:	'#000',
    	'zoomSpeedIn'		:	300,
    	'zoomSpeedOut'		:	300, 
    });
    function remember( selector ){
        $(selector).each(function(){
            //if this item has been cookied, restore it
            var name = $(this).attr('name');
            if( $.cookie( name ) ){
                $(this).val( $.cookie(name) );
            }
            //assign a change function to the item to cookie it
            $(this).change(
                function(){
                    $.cookie(name, $(this).val(), { path: '/', expires: 365 });
            });
        });
    }
    remember( '[name=author]' );
    remember( '[name=mail]' );
    remember( '[name=www]' );
});

// Icons & Social apps

function DraugiemSay( title, url, titlePrefix ){
    window.open(
        'http://www.draugiem.lv/say/ext/add.php?title=' + encodeURIComponent( title ) +
        '&link=' + encodeURIComponent( url ) +
        (titlePrefix ? '&titlePrefix=' + encodeURIComponent( titlePrefix ) : '' ),
        '',
        'location=1,status=1,scrollbars=0,resizable=0,width=530,height=400'
    );
    return false;
}
