function article_vote (a_id) {
	$.get("/", { fn: "vote_add", a_id: a_id }, 
		function(data){
			if (!data) { alert('Sie haben bereits für dieses Produkt abgestimmt.'); return false; }
			$("#ecato-votes-a"+a_id).fadeOut("fast", function() {
				var html_old = $(this).html();
				var html_new = html_old.replace(/^\d+/, data);
				$(this).html(html_new).fadeIn("fast");
			});
		}
	);
}

function limitChars (textid, limit, infodiv) {
	var text = $('#'+textid).val();
	var textlength = text.length;

	if (textlength > limit) textlength_info = limit;
	else textlength_info = textlength;
	$('#'+infodiv).html('('+textlength_info+'/'+limit+')');

	if (textlength > limit) {
		$('#'+textid).val(text.substr(0,limit));
		return false;
	} else {
		return true;
	}
}

$(document).ready(function () {
	$("a.ecato-popup").click(function () {
		width = 250;
		height = 250;
		url = this.href;
		popup = window.open(url, '', 'resizable=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,toolbar=0,width='+width+',height='+height+''); 
		return false;
	});
	$("a.ecato-img-zoom").append('<div class="ecato-info-zoom"></div>');
});

$(document).ready(function () {
	if (typeof admin == 'undefined') return false;
	
	$("body .ecato-overpage").prepend('<div class="ecato-meta-admin"><div class="ecato-content"><div class="ecato-left">Bearbeitungsmodus aktiv</div><div class="ecato-right"><a href="'+admin['url_edit_stop']+'">beenden</a> | <a href="'+admin['url_marketplace_edit']+'">Kundenbereich</a></div></div></div>');
	
	$(".ecato-article").each(function (i) {
		var a_id = this.id.replace(/^.*article-/, '');
		if (a_id == '') return false;
		this.style.position = 'relative';
		$('#'+this.id).append('<a href="'+admin['url_article_edit']+a_id+'" title="Produkt bearbeiten" style="position:absolute;top:5px;right:10px;"><img src="/~img/icons/edit.png" alt="" /></a>');
	});
	$(".ecato-category-info").each(function (i) {
		var c_id = this.id.replace('ecato-category-info-', '');
		if (c_id == '') return false;
		this.style.position = 'relative';
		this.style.minHeight = '16px';
		$('#'+this.id).append('<a href="'+admin['url_category_edit']+c_id+'" title="Kategorie bearbeiten" style="position:absolute;top:0px;right:0px;"><img src="/~img/icons/edit.png" alt="" /></a>');
	});

});
