/**
 * Librairie javascript du détail du catalogue
 *
 * @author		Julie Tétard <julie@2jstudio.com> 
 * @version		2.1
 * @package		Ecog
 * @subpackage 	javascript
 * @category 	catalogue
 */
 


/**
 * Attache événements
 */

ECOG_smartAttachEvent(window, 'load', ECOG_catalogue_initEvents, false);


/**
 * Fonctions d'initalisation
 */

	/**
	 * Fonction attachant un les événements aux éléments du menu
	 *
	 * @return		-
	 */
	function ECOG_catalogue_initEvents()
	{
		var imgTab = document.getElementById('galerie').getElementsByTagName('div')[0].getElementsByTagName('img');
		for (i = 0 ; i < imgTab.length ; i++) {
			ECOG_smartAttachEvent(imgTab[i], 'click', ECOG_viewer_galleryOpen, false);
		}
	} 


/**
 * Fonctions d'exécution
 */

	/**
	 * Fonction de rollover simple
	 *
	 * @param  		event		obj			objet événement
	 * @return		-
	 */
	function ECOG_viewer_galleryOpen(event)
	{
		var target = ECOG_smartGetTarget(event);
		var srcTab  = target.src.split('/');
		var newWidth = 500;
		var newHeight = 500;
		var top = (screen.height - newHeight) / 2;
		var left = (screen.width - newWidth) / 2;
		var win = window.open('catalogue_viewer.php?id=' + document.getElementById('id').value + '&bienId=' + document.getElementById('bienId').value  
					+ '&photoName=' + srcTab[srcTab.length-1], 'viewer', "scrollbars=1,toolbar=no,status=yes,menubar=no,resizable=yes,top="+top+",left="+left+",width="+newWidth+",height="+newHeight);
		win.focus();
	}

