function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val();	
	var textlength = text.length;
	if(textlength >= limit)
	{
		$('#' + infodiv).html('0');
		$('#'+textid).val(text.substr(0,limit));
		return false;
	}
	else
	{
		if($('#'+textid).val() == "Kaj ti leži na duši?") {
			$('#' + infodiv).html('500');
		}else{
			$('#' + infodiv).html(limit - textlength);
		}
		return true;
	}
}

$(document).ready(function () {
    limitChars('vsebina', 500, 'limit');
});

$(function(){
 	$('#vsebina').keyup(function(){
 		limitChars('vsebina', 500, 'limit');
 	});
});

function populateElement(selector, defvalue) {
	if($.trim($(selector).val()) == defvalue) {
		$(selector).css({color:"#cccccc"});
	}
	if($.trim($(selector).val()) === '') {
		$(selector).val(defvalue);
		$(selector).css({color:"#cccccc"});
	}
	$(selector).focus(function() {
		if($(selector).val() == defvalue) {
			$(selector).css({color:"#666666"});
			$(selector).val('');
		}
	});
	$(selector).blur(function() {
		if($.trim($(selector).val()) === '') {
			$(selector).css({color:"#cccccc"});
			$(selector).val(defvalue);
		 }
	});
}