currId = String("");
function cloudText(id) {

	id = String(id);
	
	if(currId != "") {
	$("#"+currId).slideUp("slow");	
	}
	
	if(currId === id) {
		currId = String("");
		return;
	}
	
	currId = id ;
	$("#"+id).slideDown("slow");
}

function hideText() {
	$("#"+currId).slideUp();
}



function rate(hodnota) {

	var i = hodnota / 1 ;
	var clanek = $("#postid").val();
	
	$.post("/post/rate", { rate: hodnota, id: $("#postid").val() }, function(data, textStatus) { $('#rating').toggle(); $('#rating').html(data); $('#rating').fadeIn(3000); }, "html");
	$.cookie('dominoo_clanek_'+clanek, hodnota, { expires: 365 });
	$.cookie("example", "foo", { expires: 7 });
}

function mouseRate(hodnota) {
	
switch(hodnota) {
case 1: 
	$("#rate").html("<span> 1 - Hodně špatný článek.</span>");
	break;
case 2: 
	$("#rate").html("<span> 2 -  Spíš horší článek.</span>");
	break;	
case 3: 
	$("#rate").html("<span> 3 - Dobrý článek.</span>");
	break;
case 4: 
	$("#rate").html("<span> 4 - Docela dobrý článek.</span>");
	break;	
case 5: 
	$("#rate").html("<span> 5 - Výborný článek.</span>");
	break;
case 0: 
	$("#rate").html("<span> Ještě jste nehodnoťili.</span>");
	break;	
}
	
}

/* Jquery cookie plugin */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
