$(document).ready(function(){      
    $(".ci-hm-button").hover(
        function(){ 
            $(this).addClass("ci-hm-button");
        }, 
        function(){ 
            $(this).removeClass("ci-hm-button"); 
    });
    $(".ci-button").hover(
        function(){ 
            $(this).addClass("ui-state-hover"); 
        },
        function(){ 
            $(this).removeClass("ui-state-hover"); 
    });
    
    $(".add-favorite a").click(function(){
        if(document.all) {
            window.external.AddFavorite('http://www.zpravyihned.cz/','ZprávyIHNED | Vždy aktuální zprávy');   
        } else if(window.sidebar) {
            window.sidebar.addPanel('ZprávyIHNED | Vždy aktuální zprávy','http://www.zpravyihned.cz/','');
        }    
    });    
    $(".add-homepage a").click(function(){
        window.location = "http://www.zpravyihned.cz/cz/p/nastavit-jako-domovskou-stranku/";
    });

});        



function redirectFormInit(actionUrl){
    var form = '<form id="redirectForm" name="redirectForm" action="' + actionUrl + '" method="post" target="_self">';
    form += '<input type="hidden" id="rss_item_url" name="rss_item_url" value="">';
    form += '</form>';
    
    $("body").append(form);
}

function redirectForm(redirectUrl, submit){
    $("#rss_item_url").val(redirectUrl);
    if (submit){document.redirectForm.submit();}
}

function URLEncode(urlString){
    var SAFECHARS = "0123456789" +                    // Numeric
                    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +    // Alphabetic
                    "abcdefghijklmnopqrstuvwxyz" +
                    "-_.!~*'()";                    // RFC2396 Mark characters
    var HEX = "0123456789ABCDEF";

    var plaintext = urlString;
    var encoded = "";
    for (var i = 0; i < plaintext.length; i++ ) {
        var ch = plaintext.charAt(i);
        if (ch == " ") {
            encoded += "+";                // x-www-urlencoded, rather than %20
        } else if (SAFECHARS.indexOf(ch) != -1) {
            encoded += ch;
        } else {
            var charCode = ch.charCodeAt(0);
            if (charCode > 255) {
                alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
                          "(URL encoding only supports 8-bit characters.)\n" +
                          "A space (+) will be substituted." );
                encoded += "+";
            } else {
                encoded += "%";
                encoded += HEX.charAt((charCode >> 4) & 0xF);
                encoded += HEX.charAt(charCode & 0xF);
            }
        }
    } 

    return encoded;
};
