jQuery(document).ready(function() {
	
	jQuery('#header-bloc-login').hide();

	jQuery('#lien-login').click(function (e) {
		e.preventDefault();
	   jQuery('#header-bloc-login').slideToggle("normal");
    });

	//jQuery('#bloc-more-details').hide();

	jQuery('#btn-more-details').click(function (e) {
		e.preventDefault();
	   jQuery('#bloc-more-details').slideToggle("normal");
    });

    //select all the a tag with name equal to modal	
	jQuery('a[name=modal]').mouseover(function(e) {
        //Cancel the link behavior
        //e.preventDefault();

/************************************************************************************************************/
		
        var productId = jQuery(this).attr('id');
		
		jQuery('#product_data').html('<div style="text-align:center; color:#3b6567; font-size:14px; font-weight:bold;">Chargement des informations du produit...</div>');
		jQuery.ajax({
			type: "POST",
			url: baseUrl+"productbook",
			data: "id="+productId,
			success: function(msg){
				jQuery('#product_data').empty().append(msg);
				getCartInfo();
			}
		});
		
/************************************************************************************************************/




        //Get the A tag
        //var id = jQuery(this).attr('href');
        var id = "#dialog";
     
        //Get the screen height and width
        var maskHeight = 0;//jQuery(document).height();
        var maskWidth = 0;//jQuery(window).width();
     
        //Set height and width to mask to fill up the whole screen
        //jQuery('#mask').css({'width':maskWidth,'height':maskHeight, 'top':0});
         
        //transition effect    
        //jQuery('#mask').fadeIn('fast');
        //jQuery('#mask').fadeTo("slow",1.0); 
     
        //Get the window height and width
        var winH = jQuery(window).height();
        var winW = jQuery(window).width();
		
		var yOffset = 450;
		var xOffset = 200;
			
		// Grab the coordinates for the element with the tooltip and make a new copy
		// so that we can keep the original un-touched.
		var pos = jQuery(this).offset();
		var nPos = pos;
			
		// Add the offsets to the tooltip position
		nPos.top = pos.top - yOffset;
		nPos.left = pos.left - xOffset;
		if(nPos.left < 0) {
			nPos.left = pos.left + xOffset;
		}
		if((nPos.left+400) > winW) {
			nPos.left = pos.left - xOffset - 200;
		}
		if(nPos.top < 0) {
			nPos.top = pos.top + yOffset + 100;
		}
			
		// Make sure that the tooltip has absolute positioning and a high z-index, 
		// then place it at the correct spot and fade it in.
		jQuery(id).css('position', 'absolute').css('z-index', '1000');
		jQuery(id).css(nPos).fadeIn(300);
     
    });
	 
    //if close button is clicked
    jQuery('.window .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();
		jQuery('#product_data').empty();
        jQuery('#mask, .window').fadeOut(1000);
    });    
     
    //if mask is clicked
    jQuery('#mask').click(function () {
        jQuery(this).fadeOut(1000);
        jQuery('.window').fadeOut(1000);
    });        
     
});
