function doAjaxOnLink(object,contentDivId){
	var loadingImg="<img src='img/ajax-loader.gif'>";
 	$.ajax({
		type: "GET",
		url: object.name,
		dataType: "html",
		data: "ajaxDiv="+contentDivId,
		beforeSend:function() { 
	       if(contentDivId==""){
	       		$(document.body).empty();
				$(document.body).html(loadingImg);
			}else{
				$("#"+contentDivId).empty();
				$("#"+contentDivId).html(loadingImg);
			} 
	    },
	    success:function(msg) { 
	       if(contentDivId==""){
	       		$(document.body).empty();
				$(document.body).html(msg);
			}else{
				$("#"+contentDivId).empty();
				$("#"+contentDivId).html(msg);
			} 
	    }
    });
    return false;
}
function doAjaxOnLinkWithAppend(object,contentDivId){
 	$.ajax({
		type: "POST",
		url: object.name,
		dataType: "html",
		data: "ajaxDiv="+contentDivId,
		success: function(msg){
			if(contentDivId==""){
				$(document.body).append(msg);
			}else{
				//stavi u div
				$("#"+contentDivId).append(msg);
			}
		}
    });
    return false;
}
function prepareAjaxForm(contentDivId, formId){
	var loadingImg="<img src='img/ajax-loader.gif'>";
	var options={
		target: "#"+contentDivId
	};
	$('#'+formId).ajaxForm(options);
}
function doAjaxForm(object,contentDivId, formId){
	var valid=$("#"+formId).valid();
	if(valid==true){
		var loadingImg="<img src='img/ajax-loader.gif'>";
		var action=object.name;
		var options = { 
		    url:action+"&ajaxDiv="+contentDivId,
		    type: 'POST',
		    beforeSubmit:function() { 
		       if(contentDivId==""){
		       		$(document.body).empty();
					$(document.body).html(loadingImg);
				}else{
					$("#"+contentDivId).empty();
					$("#"+contentDivId).html(loadingImg);
				} 
		    },
		    success:function(msg) { 
		       if(contentDivId==""){
		       		$(document.body).empty();
					$(document.body).html(msg);
				}else{
					$("#"+contentDivId).empty();
					$("#"+contentDivId).html(msg);
				} 
		    } 
		};
		$('#'+formId).ajaxSubmit(options);
	}else{
	    var VALIDATE_FORM_ERROR=$("#VALIDATE_FORM_ERROR").val();
		alert(VALIDATE_FORM_ERROR);
	}
	return false;
}

function doAjaxOnLinkWithParams(object,contentDivId,extraParams){
	if(extraParams!=""){
	 	$.ajax({
			type: "POST",
			url: object.name,
			dataType: "html",
			data: "ajaxDiv="+contentDivId+"&"+extraParams,
			success: function(msg){
				if(contentDivId==""){
					$(document.body).html(msg);
				}else{
					$("#"+contentDivId).html(msg);
				}
			}
	    });
    }
    return false;
}