/**
 * Javascript Funktionen für den Produktvergleich
 * @author ahoogestraat
 */

$(document).ready(function () {
	$('.comparisionLinks').css('display', '');
});

var prodCount = 0;

function addComparision(obj, product_id, ckey, sid) {
	$.ajax({
	   type: "GET",
	   url: "ajaxComparator.php",
	   data: "addCompProd=" + product_id + "&ckey=" + ckey + "&sid=" + sid,
	   success: function(cnt) {
		prodCount = cnt;
	   }
	});


	$($('a', $(obj)).get(1)).html('Nicht vergleichen');
	$('img', $(obj)).get(0).src = $('img', $(obj)).get(0).src.replace('not_checked', 'checked');
	obj.onclick = function() { return removeComparision(obj, product_id, ckey, sid); };
	
	return false;
}

function removeComparision(obj, product_id, ckey, sid) {
	
	$.ajax({
	   type: "GET",
	   url: "ajaxComparator.php",
	   data: "removeCompProd=" + product_id + "&ckey=" + ckey + "&sid=" + sid,
	   success: function(cnt) {
		prodCount = cnt;
	   }
	});
	
	$($('a', $(obj)).get(1)).html('Vergleichen');
	$('img', $(obj)).get(0).src = $('img', $(obj)).get(0).src.replace('checked', 'not_checked');
	obj.onclick = function() { return addComparision(obj, product_id, ckey, sid); };
	
	return false;
}