var liEl;
$(document).ready(function() {
	
	/* actus */
	
	$('ul.actus .expand a, ul.actus h3').click(function() {

		$('ul.actus li').removeClass('expanded');
		
		liEl = $(this).parent().parent();
		
		if(liEl.get(0).nodeName != "LI")
		{
			liEl = liEl.parent();
		}
		
		liEl.addClass('expanded');
		
		return false;
		
	});
	
	$('.actus li:first-child').addClass('expanded');
	
	
	/* references */
	var first_click = true;
	$('#references-map area').click(function() {
		
		// mouse over
		
		var ref_id = $(this).attr('rel');
               
                if (first_click){

                   
                   $('#slideshow-references').cycle('destroy');
                   
                   

                    $('.reference-details').css('display', 'none');
                    $('.reference-details').css('left', '');
                    $('.reference-details').css('top', '');
                    $('.reference-details').css('position', 'relative');
                    $('.reference-details').css('z-index', '1');
                    $('.reference-details').css('opacity', '1');
                    first_click = false;

                }
                
		$('.reference-details').css('display', 'none');
		$('#reference-details-'+ref_id).css('display', 'block');
              
		if($.browser.msie)
		{
			$('.references-img:visible').css('display', 'none');
                        $('#references-img-'+ref_id).css('display', 'block');
		}
		else
		{
			 $('.references-img:visible').fadeOut(200);
                         $('#references-img-'+ref_id).fadeIn(200);
                         
		}
                return false;
              
	
	});
	$('#slideshow-references').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
                speed: 200,
                timeout:       2000,
                before : function(currSlideElement, nextSlideElement, options, forwardFlag){
                    var ref_id = $(this).attr('id').replace('reference-details-','');
                     
                    if($.browser.msie)
		{
			$('.references-img:visible').css('display', 'none');
                        $('#references-img-'+ref_id).css('display', 'block');
		}
		else
		{
			 $('.references-img:visible').fadeOut(200);
                         $('#references-img-'+ref_id).fadeIn(200);

		}
                  //  alert ($(this).attr(('id')));

            }
	});
	
	/* fancymap */
	
	$(".fancymap").fancybox({
		'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'width'				: "75%",
		'height'			: "75%",
		'type'				: 'iframe'
	});
	
	$('.fancy-2').fancybox({
		'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'width'				: 730,
                'height'                        : 700,
                'type'				: 'iframe'
	});

        $('#body-contact .more, #mentions-legales').fancybox({
		'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'width'				: 730,
                'height'                        : 700,
                'type'				: 'iframe'
	});
        $('.fancy-video').fancybox({
		'transitionIn'	: 'none',
		'transitionOut'	: 'none',
		'width'				: 750,
                'height'                        : 470,
                'type'				: 'iframe'
	});


        // slideshow
         $('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
                timeout:       2000
	});

});



function print_r(obj) {
  win_print_r = window.open('about:blank', 'win_print_r');
  win_print_r.document.write('<html><body>');
  r_print_r(obj, win_print_r);
  win_print_r.document.write('</body></html>');
 }

 function r_print_r(theObj, win_print_r) {
  if(theObj.constructor == Array ||
   theObj.constructor == Object){
   if (win_print_r == null)
    win_print_r = window.open('about:blank', 'win_print_r');
   }
   for(var p in theObj){
    if(theObj[p].constructor == Array||
     theObj[p].constructor == Object){
     win_print_r.document.write("<li>["+p+"] =>"+typeof(theObj)+"</li>");
     win_print_r.document.write("<ul>")
     r_print_r(theObj[p], win_print_r);
     win_print_r.document.write("</ul>")
    } else {
     win_print_r.document.write("<li>["+p+"] =>"+theObj[p]+"</li>");
    }
   }
  win_print_r.document.write("</ul>")
 }


