function saveAd(adId){
	$.ajax({
        type: "GET",
        url: APPURL+"ajax/user/save-ad/",
        data: "ad="+adId,
        processData: false,
        success: function(responseText) {
           if(responseText == 'ok'){
	           	$('#save_link_'+adId ).html('');
				$( "<a></a>" )
				.addClass( 'remove' ) 
				.append( 'Remove' )
				.attr( 'href', 'javascript: void(0);' )
				.click(function() {
				     removeAd(adId);
				 })
				.appendTo( '#save_link_'+adId );
           }else{
           		showGeneralMessageDialog("Error", responseText);
           }
        }
    });
}
function removeAd(adId){
	$.ajax({
        type: "GET",
        url: APPURL+"ajax/user/remove-ad/",
        data: "ad="+adId,
        processData: false,
        success: function(responseText) {
        	if(responseText == 'ok'){
        		$('#save_link_'+adId ).html('');
				$( "<a></a>" )
				.html('')
				.addClass( 'save' ) 
				.append( 'Save' )
				.attr( 'href', 'javascript: void(0);' )
				.click(function() {
				     saveAd(adId);
				 })
				.appendTo( '#save_link_'+adId );
        	}else{
        		showGeneralMessageDialog("Error", responseText);
        	}
        }
    });
}
