var urlRefs = "mxajax/core/cf/refTrendToInsight.cfc";

	function refreshTrendsList(params, destination) {
	    new mxAjax.Data({
	        executeOnLoad:true,
	        paramArgs: new mxAjax.Param(urlRefs,{param:params, cffunction:"refreshTrends"}),
	        postFunction: handleData
	    });
	   
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
	        document.getElementById(destination).innerHTML = myHTMLOutput;
	    }
	}	

	function showAddFormTrends(params, destination) {
	    new mxAjax.Data({
	        executeOnLoad:true,
	        paramArgs: new mxAjax.Param(urlRefs,{param:params, cffunction:"searchTrend"}),
	        postFunction: handleData
	    });
	   
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
	        document.getElementById(destination).innerHTML = myHTMLOutput;
	    }
	}
	
	function showAddFormTrendsCancel(destination) {
	    document.getElementById(destination).innerHTML = '';
	}	
	
	function sendDataTrends(params, destination) {
		document.getElementById("showIndicator").style.visibility = 'visible';
	    new mxAjax.Data({
	        executeOnLoad:true,
	        paramArgs: new mxAjax.Param(urlRefs,{param:params, cffunction:"searchTrendsTable"}),
	        postFunction: handleData
	    });
	   
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
	        document.getElementById(destination).innerHTML = myHTMLOutput;
			document.getElementById("showIndicator").style.visibility = 'hidden';
	    }
	}		



	function sendRefData(params, destination, refreshList) {
	    new mxAjax.Data({
	        executeOnLoad:true,
	        paramArgs: new mxAjax.Param(urlRefs,{param:params, cffunction:"refInsight"}),
	        postFunction: handleData
	    });
		
		refreshTrendsList(params, refreshList);
	   
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
	        document.getElementById(destination).innerHTML = myHTMLOutput;
			
	    }
	}	

	
	
	function removeRef(params, destination) {
	
	
		if (window.confirm("Are you sure you want to remove this reference?")) {
		    new mxAjax.Data({
		        executeOnLoad:true,
		        paramArgs: new mxAjax.Param(urlRefs,{param:params, cffunction:"remRefAlt"}),
		        postFunction: handleData
		    });
	   
		}
		else {
		}
	
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
			document.getElementById(destination).style.display = 'none';
			// shotNoteList(expandComments);
	    }
	
	}
	
	
var urlReport = "mxajax/core/cf/refInsightToReport.cfc";

	function refreshTrendsList(params, destination) {
	    new mxAjax.Data({
	        executeOnLoad:true,
	        paramArgs: new mxAjax.Param(urlReport,{param:params, cffunction:"refreshTrends"}),
	        postFunction: handleData
	    });
	   
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
	        document.getElementById(destination).innerHTML = myHTMLOutput;
	    }
	}	

	function showAddFormReports(params, destination) {
	    new mxAjax.Data({
	        executeOnLoad:true,
	        paramArgs: new mxAjax.Param(urlReport,{param:params, cffunction:"searchReport"}),
	        postFunction: handleData
	    });
	   
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
	        document.getElementById(destination).innerHTML = myHTMLOutput;
	    }
	}

	function showLinkedInsights(params, destination) {
	    new mxAjax.Data({
	        executeOnLoad:true,
	        paramArgs: new mxAjax.Param(urlReport,{param:params, cffunction:"showInsights"}),
	        postFunction: handleData
	    });
	   
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
	        document.getElementById(destination).innerHTML = myHTMLOutput;
	    }
	}

	function showAddFormReportsCancel(destination) {
	    document.getElementById(destination).innerHTML = '';
	}	
	
	function sendDataReports(params, destination) {
		document.getElementById("showIndicator").style.visibility = 'visible';
	    new mxAjax.Data({
	        executeOnLoad:true,
	        paramArgs: new mxAjax.Param(urlReport,{param:params, cffunction:"addReport"}),
	        postFunction: handleData
	    });
	   
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
	        document.getElementById(destination).innerHTML = myHTMLOutput;
			document.getElementById("showIndicator").style.visibility = 'hidden';
	    }
	}		

	function removeReport(params, destination) {
	
	
		if (window.confirm("Are you sure you want to remove this report?")) {
		    new mxAjax.Data({
		        executeOnLoad:true,
		        paramArgs: new mxAjax.Param(urlReport,{param:params, cffunction:"removeReport"}),
		        postFunction: handleData
		    });
	   
		}
		else {
		}
	
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
			document.getElementById(destination).style.display = 'none';
			// shotNoteList(expandComments);
	    }
	
	}

	function sendRefData(params, destination, refreshList) {
	    new mxAjax.Data({
	        executeOnLoad:true,
	        paramArgs: new mxAjax.Param(urlReport,{param:params, cffunction:"refInsight"}),
	        postFunction: handleData
	    });
		
		refreshTrendsList(params, refreshList);
	   
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
	        document.getElementById(destination).innerHTML = myHTMLOutput;
			
	    }
	}	

	
	
	function delinkInsight(params, destination) {
	
	
		if (window.confirm("Are you sure you want to remove this insight from the report?")) {
		    new mxAjax.Data({
		        executeOnLoad:true,
		        paramArgs: new mxAjax.Param(urlReport,{param:params, cffunction:"remRefAlt"}),
		        postFunction: handleData
		    });
	   
		}
		else {
		}
	
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
			document.getElementById(destination).style.display = 'none';
			// shotNoteList(expandComments);
	    }
	
	}
	
	var urlLikes = "mxajax/core/cf/likeInsights.cfc";

	function likethis(params, totLikes, destination) {
	    new mxAjax.Data({
	        executeOnLoad:true,
	        paramArgs: new mxAjax.Param(urlLikes,{param:params, cffunction:"likeThis"}),
	        postFunction: handleData
	    });
	   
	    function handleData(response) {
	        var myHTMLOutput = JSON.parse(response);
	        document.getElementById(destination).innerHTML = myHTMLOutput;
			updateTotal(params, totLikes);

		}
	}		
	

			function updateTotal(params, totLikes) {
				new mxAjax.Data({
					executeOnLoad:true,
					paramArgs: new mxAjax.Param(urlLikes,{param:params, cffunction:"countikes"}),
					postFunction: handleDataLikes
				});
			   
				function handleDataLikes(response) {
					var myHTMLOutput = JSON.parse(response);
					document.getElementById(totLikes).innerHTML = myHTMLOutput;
				}
			}	
	



