function replaceProduct(divId,newPid,oldPid,compare,functionNameId,link){
	continueVar = true ;
	if ('function' == typeof beforeReplaceProduct) {
		if (!beforeReplaceProduct (oldPid,newPid)) {
			continueVar = false ;
		}
	}
	
	if (continueVar) {
	
		if(!compare)
			compare = false;
		//if(!favoritesFlag)
		//	favoritesFlag = false;
		$("#"+divId+" .productThumbBox").html('<div class="loadingBox"></div>');
		//alert("/ajaxproduct.html?pid="+newPid+"&compare="+compare+"&favoritesFlag="+favoritesFlag+"&link="+link+"&time="+new Date().getTime());
		$.get("/ajaxproduct.html?pid="+newPid+"&compare="+compare+"&functionNameId="+functionNameId+"&link="+link+"&time="+new Date().getTime(),function(data){
			$("#"+divId).replaceWith(data);
			
			if ('function' == typeof afterReplaceProduct) {
				afterReplaceProduct (oldPid,newPid) ;
			}
		});
	}
}

function saveProduct (pid, randomId) {
	$.post (
		"/mydelta/saveProduct.json",
		{ "pid":pid },
		function(data) {

			$("#"+randomId).addClass ("saved") ;
			$("#saveLink" + randomId).hide() ;
			$("#removeLink" + randomId).show() ;
			
			if ('function' == typeof onSaveProduct) {
				onSaveProduct (pid) ;
			}
			
			if ('function' == typeof showConfirmation) {
				showConfirmation (data) ;
			}
		},
		"json"
	) ;
}

function removeProduct (pid, randomId) {
	$.post (
		"/mydelta/removeProduct.json",
		{ "pid":pid },
		function(data) {

			$("#"+randomId).removeClass ("saved") ;
			$("#saveLink" + randomId).show() ;
			$("#removeLink" + randomId).hide() ;
			
			if ('function' == typeof onRemoveProduct) {
				onRemoveProduct (pid) ;
			}

			if ('function' == typeof showConfirmation) {
				showConfirmation (data) ;
			}
		},
		"json"
	) ;
}
