//------------------------------------------------------------------------------------------
// Script:		js/ajax.js
// Author(s):		Guillaume Lambert - guillaume@falzhobel.ca
//			Alex Gignac - alex@ax2.ca
//
// Date:		Aug 2009
//
// Javascript functions for all AJAX-based 
//
// Functions:
//	-
//
//------------------------------------------------------------------------------------------

// fetchProjectDetails(itemId)
// Carousel onclick function for projects list page
function fetchProjectPreview(itemId, categoryId) {
	// load temp loader
	$('browse_image_' + categoryId).innerHTML = '<div class="browse_loading"><img src="' + appWebPath + 'images/ajax_loader.gif" alt="" /></div>';
	$('browse_short_desc_' + categoryId).innerHTML = '';
	
	new Ajax.Request(appWebPath + 'ajax/project_preview_load.php', {
		//method:'post',
		parameters: { item_id: itemId },
		onSuccess: function(transport) {
				
			// load the response, and convert JSON into regular array
			var response = transport.responseText;
			var jsonObj = response.evalJSON();
			
			// load thumb into div
			$('browse_image_' + categoryId).innerHTML = '<a href="' + appWebPath + siteLang + '/realisations/details.php?id=' + jsonObj.project_id + '" class="no_border"><img src="' + appWebPath + '_files/projects/medium/' + jsonObj.image + '" alt="' + jsonObj.name_fr + '" border="0" /></a>';

			// load short desc into div
			$('browse_short_desc_' + categoryId).innerHTML = jsonObj.short_description_fr;

		},
		onFailure: function() {
			alert('Error in communication with server!');
		}
	});
}