// This script handles the My Criticaleye activity thread functions

// Location of the CFC file which contains all the components for these functions
var urlFeedback = "/mxajax/core/cf/mycriticaleye.cfc";

// Show and hide the feedback form
function showFeedForm(params, destination) {
	
if ( document.getElementById(destination).innerHTML == '' ) {			
	
		new mxAjax.Data({
			executeOnLoad:true,
			paramArgs: new mxAjax.Param(urlFeedback,{param:params, cffunction:"showForm"}),
			postFunction: handleDataFeed
		});
	
}
else { document.getElementById(destination).innerHTML = '' }
   
	function handleDataFeed(response) {
		var myHTMLOutput = JSON.parse(response);
		document.getElementById(destination).innerHTML = myHTMLOutput;
	}
}			

// Capture feedback form input and send it via ajax to the CFC for emailing
function sendFeedback(destination,linkClass) {
	new mxAjax.Data({
		executeOnLoad:true,
		paramArgs: new mxAjax.Param(urlFeedback,{param:"bubble={feedbackForm},feedID={feedID},mid={mid}", cffunction:"feedbackHandler"}),
		postFunction: handleDataSend
	});
   
	function handleDataSend(response) {
		var myHTMLOutput = JSON.parse(response);
		document.getElementById(linkClass).innerHTML = myHTMLOutput;
		document.getElementById(destination).innerHTML = '';
	}
}	

// Expand the feed item via ajax
function feedItemExpand(params,destination,linkClass) {
	
	if ( document.getElementById(destination).innerHTML == '' ) {	
	
		new mxAjax.Data({
			executeOnLoad:true,
			paramArgs: new mxAjax.Param(urlFeedback,{param:params, cffunction:"feedbackExpand"}),
			postFunction: handleDataExp
		});
	
	}
	else {
		document.getElementById(destination).innerHTML = ''
		document.getElementById(linkClass).innerHTML = 'read more';
	}
	
	function handleDataExp(response) {
		var myHTMLOutput = JSON.parse(response);
		document.getElementById(linkClass).innerHTML = 'hide';
		document.getElementById(destination).innerHTML = myHTMLOutput;
	}
}	


				function showImage(imageFile, rowLine, imageHere) {
				
							var f = document.getElementById(imageHere);
							var g = document.getElementById(rowLine);
							
								g.style.backgroundColor = '#e8e6e6';
								f.innerHTML = '<img src=http://www.criticaleye.net/images/pdf-thumbs/'+imageFile+'>';
				
				}				
				function showImageAlt(imageFile, rowLine, imageHere) {
				
							var f = document.getElementById(imageHere);
							var g = document.getElementById(rowLine);
							
								g.style.backgroundColor = '#e8e6e6';
								f.innerHTML = '<img src=http://www.criticaleye.net/images/insights/'+imageFile+'>';
				
				}	
				function unShowBG(rowLine) {
				
							var g = document.getElementById(rowLine);
							
								g.style.backgroundColor = '#ffffff';
				
				}	