$(document).ready(function(){
	if ($("a[rel='sertificate']").length)
		$("a[rel='sertificate']").colorbox();

	$('.awards a.picture').hover(function(){
		$(this).addClass('hov');
		var h = $(this).height();
		$(this).find('.blackout').height(h);
	}, function(){
		$(this).removeClass('hov');
	});
	
	$('.next_code').click(function(){
		var r = Math.floor(Math.random()*10000) + 100;
		$(this).parent().find('.pic').find('img').attr('src', '/scripts/kcaptcha/index.php?r='+r);
		return false;
	});
	
	//ALERT
	if($("#alert_msg").length) {
		var alertMsg = $("#alert_msg").text();
		if ($('#'+alertMsg).length)
			alertMsg = $('#'+alertMsg).text();
		alertBox(alertMsg);
	}
});

function addToCart(id, count) {
	$.post(
		'/feedback.php',
		{action: "cart", add: true, id:  id, count: count},
		function(xmlDoc) {
			if ($('page count', xmlDoc).length) {
				var cc = $('page count', xmlDoc).text();
				$('.korzina').find('span').html(cc);
				alertBox($('#const_basic38').text());
			} else {				
				alertBox($('#const_basic39').text());
			}
		}
	);
}

function editCart(id, count) {
	if (count == '' || count == 0)
		count = 1;
	$.post(
		'/feedback.php',
		{action: "cart", id:  id, count: count},
		function(xmlDoc) {
			if ($('page count', xmlDoc).length) {
				var cc = $('page count', xmlDoc).text();
				$('.korzina').find('span').html(cc);
			} else {				
				alertBox($('#const_basic39').text());
			}
		}
	);
}

function delFromCart(id) {
	$.post(
		'/feedback.php',
		{action: "cart", id:  id, count: 0},
		function(xmlDoc) {
			if ($('page count', xmlDoc).length) {
				var cc = $('page count', xmlDoc).text();
				$('.korzina').find('span').html(cc);
			} else {				
				alertBox($('#const_basic39').text());
			}
		}
	);
}


function alertBox(msg) {
	$.stickr({note:msg, className:'', position:{left:100,top:100}});
}

