jQuery(document).ready(function() {

	// comments
	jQuery("#add_comm").fancybox({
		'speedOut' : 100
		/*'onClosed' : function(){
			location.href = location.href;
		}*/
	});
	
	jQuery("#buttontoclick").click(function() {
		jQuery('<a href="#block_comm" id="add_comm">оставить отзыв</a></td>').fancybox({
			  overlayShow: true
		}).click();
	});
	
});


function addcomment(id){
	jQuery.post('/ajax/addcomment.php',
		'comment_textadd='+jQuery('#comment_textadd').val()
		+ '&comment_textsub='+jQuery('#comment_textsub').val()
		+ '&comment_text='+jQuery('#comment_text').val()
		+ '&comment_fio='+jQuery('#comment_fio').val()
		+ '&id='+id
	,function(result){
		jQuery('#block_comm').html(result);
	});
}



/*
function addInCart(id){
	
	var parent = $.fancybox({
		'href':'#background',
		'showCloseButton'  : false,
		'transitionIn'	: 'none',
		'transitionOut'	: 'none'
	});

	var qty = 1;
	if (qty > 0){
		$.post('/ajax/addInCart.php','id='+id+'&qty='+qty, function(result){
			$('.marg_11').html(result);
			$.fancybox.close(parent);
			alert('Товар успешно добавлен в корзину');
		});
	}
	else{
		alert('Укажите количество');
	}
}

function good_update(id){
	var qty = $('input[name=qty_'+id+']').val();
	$.post('/ajax/updateCart.php','id='+id+'&qty='+qty, function(result){
			$('#cart').html(result.body);
			$('.marg_11').html(result.cart);
	},'json');
}

function good_remove(id){
	var qty = 0;
	$.post('/ajax/updateCart.php','id='+id+'&qty='+qty, function(result){
			$('#cart').html(result.body);
			$('.marg_11').html(result.cart);
	},'json');
}

function subscribe(){
	$.post('/ajax/subscribe.php','mail='+$('#smail').val(), function(result){
		alert(result);
	});
}

function set_star(id,vote){
	
	jQuery.post('/ajax/setStar.php','id='+id+'&vote='+vote,function(result){
		jQuery('#status_vote').html(result.vote);
		jQuery('#status_vote_count').html(result.count);
	},'json');
}

function add_comm(id){

	var comment_text = $('#comment').val();
	
	if (comment_text.length){
		$.post('/ajax/addComment.php','id='+id+'&comment_text='+comment_text,function(result){
			jQuery('#body_comm').html('<font color="blue">'+result+'</font>');
		});
	}else{
		alert ('Отзыв пуст');
	}
}

function submit(keyCode){

	if ((keyCode == 0xA)||(keyCode == 0xD)){
		alert('hi');
		return false;
	} 
	return true;
}
*/


