// JavaScript Document

function actuBox(){
	//alert('ok');
	gestionPopUp('#actu','#fondGris3');
}

function carrouselRenePierre() {
	//jQuery('#mycarousel').jcarousel();
	jQuery('#mycarousel').jcarousel({					
		wrap: 'last',
		visible: 4,
		scroll: 4
	});
}

function mycarousel_initCallback(carousel){
	//,			initCallback: mycarousel_initCallback
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});
	
	carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
	});
	
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
				carousel.startAuto();
	});
};

function gestionPopUp(divContenu,conteneur,valideCarroussel){
		
	var LargeurGlobal = $(window).width();
	var HauteurGlobal = $(window).height();
		
	$(window).resize(function(){
		var LargeurGlobal = $(window).width();
		var HauteurGlobal = $(window).height();
		
		var posTop = (HauteurGlobal/2)-($(divContenu).height()/2);
		var posLeft = (LargeurGlobal/2)-($(divContenu).width()/2);
		
		$(divContenu).css({"top":posTop+"px","left":posLeft+"px"});
		
		$(conteneur).css({"opacity":0.7,"display":"block","width":LargeurGlobal+"px","height":HauteurGlobal+"px"});
		
	});
	$(divContenu).fadeIn("fast");
	
	var LargeurGlobal = $(window).width();
	var HauteurGlobal = $(window).height();
	
	var posTop = (HauteurGlobal/2)-($(divContenu).height()/2);
	var posLeft = (LargeurGlobal/2)-($(divContenu).width()/2);
	
	$(divContenu).css({"top":posTop+"px","left":posLeft+"px"});

	$(conteneur).css({"opacity":0.7,"display":"block","width":LargeurGlobal+"px","height":HauteurGlobal+"px"});
	
	if(valideCarroussel){
		carrouselRenePierre();		
	}
	
}

function gestionPopUpProduit(divContenu,conteneur,valideCarroussel,id_categorie){
		
	var LargeurGlobal = $(window).width();
	var HauteurGlobal = $(window).height();
		
	$(window).resize(function(){
		var LargeurGlobal = $(window).width();
		var HauteurGlobal = $(window).height();
		
		var posTop = (HauteurGlobal/2)-($(divContenu).height()/2);
		var posLeft = (LargeurGlobal/2)-($(divContenu).width()/2);
		
		$(divContenu).css({"top":posTop+"px","left":posLeft+"px"});
		
		$(conteneur).css({"opacity":0.7,"display":"block","width":LargeurGlobal+"px","height":HauteurGlobal+"px"});
		
	});
	$(divContenu).fadeIn("fast");
	
	var LargeurGlobal = $(window).width();
	var HauteurGlobal = $(window).height();
	
	var posTop = (HauteurGlobal/2)-($(divContenu).height()/2);
	var posLeft = (LargeurGlobal/2)-($(divContenu).width()/2);
	
	$(divContenu).css({"top":posTop+"px","left":posLeft+"px"});

	$(conteneur).css({"opacity":0.7,"display":"block","width":LargeurGlobal+"px","height":HauteurGlobal+"px"});
	
	/*if(valideCarroussel){
		carrouselRenePierre();		
	}*/
	
	$.ajax({

		type: "POST",
		url: "/BODY/BODY-listing-produit.php",
		data: "id_categorie="+id_categorie,
		success: function(msg) {
				
				Shadowbox.init({
					language: 'fr',
						players:  ['img', 'html', 'iframe', 'qt', 'wmp', 'swf', 'flv']	,
						autoplayMovies: true,
						overlayColor : '#000000',
						overlayOpacity:0.70
				});
				$(divContenu).html(msg);
				
			if(valideCarroussel){
				carrouselRenePierre();		
			}
				

		}


	});
	
		
}


$(document).ready(function() {
	$(".Classfancybox2").fancybox({
		'easingIn' : 'easeInQuint',
		'frameWidth' : 932,
		'frameHeight' : 689,
		'hideOnContentClick':false
	});		
	$(".closeListing").click(function(){
		$("#collections").fadeOut("fast");
		$("#collectionsbaby").fadeOut("fast");
		$("#espacedeco").fadeOut("fast");
		$("#accessoires").fadeOut("fast");
		$("#promotions").fadeOut("fast");
		$(".fondGris").fadeOut("fast");
	});
	$(".closeListing2").click(function(){
		$("#listing").fadeOut("fast");
		$("#fondGris2").fadeOut("fast");
	});
	$(".closeListing3").click(function(){
		$("#actu").fadeOut("fast");
		$("#fondGris3").fadeOut("fast");
		
	});
	 var container = $('div.blockError');
	// validation form a l'envoi
	$("#formContact").validate({
		rules: {
			nom: "required",
			tel: "required",
			email: "required",
			mailContact: {
				required:true,
				email: true
			},
			message:"required"							
		},
		errorContainer: container,
		errorLabelContainer: $("ol", container),
		wrapper: 'li',
		meta: "validate",
		highlight: function(element, errorClass) {
			$(container).slideDown("slow",function() {
			$(element).addClass(errorClass)
			})
		},
		unhighlight: function(element, errorClass) {
			$(element).removeClass(errorClass);
		}
	});
	
	
	
	
});

jQuery(function($){
    $('div.demo').each(function(i){
        var opts = { align:        [ 'middle'][i] 
                   , size:         [ 45 ][i]
                   , distance:     [ 60 ][i]
                   , coefficient : [ 1.5 ][i]
                   , labels:       [true][i] 
                   , duration:     200 //default
         };
        $(this).jqDock(opts);
      });
  });

$(function(){
         var docGroup = '';
          var fileName = 'coda_bubble_demo';
         
         if(fileName == 'jquery_pagination_demo')
         {
           var cpn = parseInt(readCookie('px'));
           cpn = !cpn ? 0 : cpn;
           var options = {postUrl:"",
               itemsPerPage: 2,
               elementModel: ['<div style="margin-bottom:20px;"><img src="{0}"/>', '<h1><span class="date">{2}</span>', ' - <span style="font-size:12px;color:red;">{1}</span></h1>','<p class="text">{3}</p>', '<a href=""><div class="sub_btn"><h4 class="span">Read More</h4></div></a><br class="clear" /><div class="dotted_spacer"></div></div>'],
               fieldnames:["thumb_cmimg", "title", "date_dpicker","nbody_cmtxt", "id", "title_wwwsafe"],
               currentPage: cpn,
               showPrev: true,
               showNext: true,
               showPageXofY : true,
               xofyLeft : true,
               xofyRight : false
            };
            $("#paginator").paginator(options);
            
         }
         
         if(fileName == 'coda_bubble_demo')
         {
             opts = {
               distances : [20,20,20],
               leftShifts : [-67,-50,-67],
			   TopShifts: [-50,-60,-45],
               bubbleTimes : [200,200,200],
               hideDelays : [0,0,0],
               bubbleWidths : [180,150,190],
               bubbleImagesPath : "../images",
               msieFix : true,
               msiePop : true
            };
            $('.coda_bubble').codaBubble(opts);
         }
});

