function load_js()
{
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
        var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number

        if (ieversion<7)
            CFInstall.check({
             mode: "overlay",
             destination: "http://www.google.com"
            });
        }
        
}


function eventMap(el_evt, el, bloc){
	
	if( el_evt ) {  
	
	el_evt.addEvents({
		
		'mouseover': function(ev) {
			el.setStyle('display', 'block');
			el.setStyle('z-index', '8');
			/*el.addClass(classHover);*/
		}
			
	});
	
	}
	
	if( el ) {  
	
	el.addEvents({
		
		'click': function(ev) {
			new Event(ev).stop();
			
			bloc.setStyle('display', 'block');
			bloc.setStyle('position', 'absolute');
			
			var posX = $('carte-france').offsetLeft;
			var posY = $('carte-france').offsetTop;
			posX = posY = 0;
			x = (navigator.appName.substring(0,3) == "Net") ? ev.pageX : event.x+document.body.scrollLeft;
			y = (navigator.appName.substring(0,3) == "Net") ? ev.pageY : event.y+document.body.scrollTop;
			/*
			if ((version >= 5.5)) {
				bloc.setStyle('top', (y) + 20 );
				bloc.setStyle('left', (x) + 20 );
			}else{
				bloc.setStyle('top', (posY) + 20 );
				bloc.setStyle('left', (posX) + 20 );
			}
                        */
                       
                        bloc.setStyle('top', (posY) + 20 );
                        bloc.setStyle('left', (posX) + 20 );
                
			bloc.setStyle('z-index', '10');
			
		},
		
		'mouseout': function() {
			el.setStyle('display', 'none');
			bloc.setStyle('display', 'none');
		}	
			
	});	
	
	}		
}



window.addEvent('domready',function() {
    
    $$('.external').addEvent('click', function(ev){
			window.open(this.href);new Event(ev).stop();return;});
    
    
    $$('h2#la_societe a').addEvent('click', function(e){
        $$('ul#navSociete').removeClass('visibility_off');
    });
    
    eventMap($('paris'), $('b_paris'), $('bloc_paris'));
    eventMap($('vilaine'), $('b_vilaine'), $('bloc_vilaine'));
    eventMap($('armor'), $('b_armor'), $('bloc_armor'));
    eventMap($('morbihan'),$('b_morbihan'), $('bloc_morbihan'));
    eventMap($('finistere'), $('b_finistere'), $('bloc_finistere'));
    eventMap($('loire'),$('b_loire'), $('bloc_loire'));
    eventMap($('basse'),$('b_basse'), $('bloc_basse'));
    eventMap($('haute'), $('b_haute'), $('bloc_haute'));
    eventMap($('centre'), $('b_centre'), $('bloc_centre'));
    eventMap($('poitou'), $('b_poitou'), $('bloc_poitou'));
    eventMap($('aquitaine'), $('b_aquitaine'), $('bloc_aquitaine'));
    eventMap($('alsace'), $('b_alsace'), $('bloc_alsace'));
    eventMap($('lorraine'), $('b_lorraine'), $('bloc_lorraine'));
    eventMap($('franche'), $('b_franche'), $('bloc_franche'));
    eventMap($('rhone'), $('b_rhone'), $('bloc_rhone'));
    eventMap($('champagne'), $('b_champagne'), $('bloc_champagne'));
    eventMap($('bourgogne'), $('b_bourgogne'), $('bloc_bourgogne'));
    eventMap($('auvergne'), $('b_auvergne'), $('bloc_auvergne'));
    eventMap($('provence'), $('b_provence'), $('bloc_provence'));
    eventMap($('languedoc'), $('b_languedoc'), $('bloc_languedoc'));
    eventMap($('midi'), $('b_midi'), $('bloc_midi'));
    eventMap($('limousin'), $('b_limousin'), $('bloc_limousin'));
    eventMap($('picardie'), $('b_picardie'), $('bloc_picardie'));
    eventMap($('nord'), $('b_nord'), $('bloc_nord'));
    eventMap($('corse'), $('b_corse'), $('bloc_corse'));

    if($('home_pulse_image'))
    {
        var pf = new PulseFade('home_pulse_image',{
            min: 0,
            max: 1,
            duration: 2000,
            times: 0,
            pause: 5000
        })

        pf.start();
    }
    
    //slideshow
    if($('slideNews'))
    {
        basic1 = new SlideShow('slideNews', {
        autoplay: true,
        delay: 5000,
        transition: 'crossFade'
        });
    }


    if($('slideDesserts'))
    {
        basic2 = new SlideShow('slideDesserts', {
        autoplay: true,
        delay: 5000,
        transition: 'crossFade'
        });
        
        $$('.prev').addEvent('click', function(e){
            basic2.show('previous');
        });
        
        $$('.next').addEvent('click', function(e){
            basic2.show('next');
        });
    }
    
    if($('accordion'))
    {
        var accordion = new Fx.Accordion($('accordion'), 'div#accordion div.toggler', 'div#accordion div.element', {
                opacity: true,
                display: -1,
                alwaysHide:true,
                onActive: function(toggler, element){
                    var v = $('accordion').getElement('a')
                    if(v.text=='Lire la suite')
                        v.innerHTML='Fermer';
                },
                onBackground: function(toggler, element){
                    var v = $('accordion').getElement('a')
                    if(v.text=='Fermer')
                        v.innerHTML='Lire la suite';
                },
                onComplete: function(){
                    
                }
            });
        
        $$('.readNext').addEvent('click', function(e){
            accordion.display(0);
        });
    }  


    if($('contactremarque'))
    {
        $('contactremarque').addEvent('click', function(e){
            $('blockContact').setStyle('display', 'block');
        });
    }
    
    if($('contactcomment'))
    {
        $('contactcomment').addEvent('click', function(e){
            $('blockContact').setStyle('display', 'none');
        });
    }
    
    
    if($$('li.item'))
    {
        $$('li.item').each(function(el){
            el.setStyle('cursor', 'pointer');
        });

        $$('li.item').addEvent('click', function(e){
                this.setStyle('cursor', 'pointer');
                var href = this.getElement('a').href;
                document.location = href;
        });
    }
    //$$('div#home_images img').set('tween', {duration: 2000, transition: 'back:inout'}).tween('opacity', 0, 1);
   
/*
    var dessert = $('dessert').getNext().setOpacity(0.7);
		var hs6 = new noobSlide({
			mode: 'vertical',
			box: $('dessert'),
			items: sampleObjectItems,
			/*items: $('info_dessert'),*/
			/*size: 264,
			autoPlay: true,
			handles: $ES('div','handles6_1'),
			handle_event: 'click',	
			fxOptions: 'Quad',
			onWalk: function(currentItem,currentHandle){
				dessert.empty();
				new Element('h4').setHTML('<span>'+currentItem.title+'</span>'+'<a href="'+currentItem.link+'">en savoir plus</a>').inject(dessert);
				this.handles.setOpacity(0.3);
				currentHandle.setOpacity(1);
			}
		});
		hs6.next();
	*/
	 });

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

	 
function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}

function EcrireCookie(nom, valeur)
{
	var argv=EcrireCookie.arguments;
	var argc=EcrireCookie.arguments.length;
	var expires=(argc > 2) ? argv[2] : null;
	var path=(argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=nom+"="+escape(valeur)+
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}

function getCookieVal(offset)
{
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1) endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function LireCookie(nom)
{
	var arg=nom+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen)
	{
	var j=i+alen;
	if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
	i=document.cookie.indexOf(" ",i)+1;
	if (i==0) break;
	
	}
	return null;
}
