var is_flipping_book = true;

new Event.observe(window, 'load', function() {

	    // Gestion des click pour ajout en bookmark
	$$('.add_bookmark_bt').each(function(el) {
		new Event.observe(el, 'click', function() {
        	if(is_flipping_book) flippingBook.getFlippingBookReference().wmode = "transparent";
            Dialog.info({url: "/projet/phpjs/connection_book_project.php", options: {method: '1000'}}, {className: "ms", width:450, height:300, zIndex: 10});
            WindowCloseKey.init();
		});
	});
        
});

function buildBookProject()
{
	var parameters = '';
	if(is_flipping_book) parameters = '?rep=catalogue_produits&bm=' + flippingBook.rightPageNumber;
    
    $('reference_new_project').update('<img src="/design/images/ajax-loader.gif" alt="Terminer" width="16" height="16" />');
    
	new Ajax.Request('/projet/phpjs/build_book_project.php' + parameters, {
    	method: 'get',    
		onSuccess: function(transport) {
        	var reponse = transport.responseText;
            $('reference_new_project').update(reponse);	
            $('reference_new_project_bt').update('<img src="/js/window/ms/terminer.png" alt="Terminer" width="108" height="35" />');
            $('reference_new_project_bt').onclick = function() { 
            	location.reload(); 
                //location.href = '/rep-projet.html';
            };
            if(Windows) Windows.focusedWindow.updateHeight();
   		}
    });
}

function editBookProject(code)
{
	var parameters = '?code=' + code;
	if(is_flipping_book) parameters += '&rep=catalogue_produits&bm=' + flippingBook.rightPageNumber;
    
	$('reference_old_project').update('<img src="/design/images/ajax-loader.gif" alt="Terminer" width="16" height="16" />');
    
	new Ajax.Request('/projet/phpjs/edit_book_project.php' + parameters, {
		onSuccess: function(transport) {
        	var reponse = transport.responseText;
            if(reponse == '1')
            {
            	$('reference_old_project').update('Vous avez &eacute;t&eacute; correctement connect&eacute; &agrave; votre Book Projet.<br />Bonne navigation !');
            	$('reference_old_project_bt').update('<img src="/js/window/ms/terminer.png" alt="Terminer" width="108" height="35" />');
            	if(is_flipping_book) $('reference_old_project_bt').onclick = function() { location.href = '/rep-catalogue_produits/page-' + flippingBook.rightPageNumber + '.html'; };
                else 
                {
                	$('reference_old_project_bt').onclick = function() { 
                        location.reload();
                        //location.href = '/rep-projet.html'; 
                    };
                }
                $('reference_projet_label').hide();
            } else {
            	$('reference_old_project').update('<span style="color: #dd8300;">Cette r&eacute;f&eacute;rence projet n\'existe pas, v&eacute;rifiez que votre saisie ou cr&eacute;ez un nouveau projet.</span>');
            }
            Windows.focusedWindow.updateHeight();
   		}
    });
}

function addBookCommentRealisations(title, action)
{
	Dialog.info({url: "/projet/phpjs/addbookmark_realisations_book_project.php?title=" + title + '&action=' + action, options: {method: '1000'}}, {className: "ms", width:450, height:260, zIndex: 10});
    WindowCloseKey.init();
}