/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    * Filename: oceanbox.js
    * Website: http://www.oceanbox.fr
    * Author: Conseil.Net
    * Description: javascript 

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

function init(){
        sfHover();
      }
      womAdd('init();');

/* script pour récupérer l'URL de la miniature et lui retirer le /thumbnails/ pour obtenir l'URL de l'image version grande.
___________________________________________________ */
  function createURL(lien) {
   return $(lien).children("img").attr('src').replace('/thumbnails/','/'); 
 }
   

/* Select de la liste des écoles : activation du lien
___________________________________________________ */      
function charge_site(url) {
		window.location.replace(url);
 
	} 

/* Activation rollover choix sports de glisse
___________________________________________________ */
function rollover(father,src){
	var img=father.getElementsByTagName('img');
	if(img.length>0){
		img=img[0];
		if(src==''){
			img.style.display='none';
		}else{
			img.style.display='inline';
			img.src=src;
		}
	}
}

/* Début Jquery 
_____________________________________________ */

/* Tabs productPresentation */    
$(function() {
  $('#productPresentation').tabs({ fxSlide: true, fxFade: true, fxSpeed: 'normal',onShow:updateFormAction});
            });
  function updateFormAction(link,div){
    $('form',$(div)).attr('action',link.href);
  }  
  

$(document).ready(function()	{

/* rendre actif en homepage le bouton accueil*/
if ($(".breadcrumb_navigation a:last").attr("href") == "/") {
	$(".first_level li").eq(5).addClass("active");
	}
	else {$(".first_level li").eq(5).removeClass("active")
	;}



 
			
function css_emulateMaxWidthHeight() { 
$('.short_product .picture img').each(function() {       

if( $(this).css('max-width') != 'none' || $(this).css('max-height') != 'none' ) { 
max_width = $(this).css('max-width').replace(/[^0-9]/g, ''); 
max_height = $(this).css('max-height').replace(/[^0-9]/g, '');       
if( $(this).width() > max_width || $(this).height() > max_height ) { 
if( (max_width / $(this).width()) < (max_height / $(this).height()) ) { 
$(this).css('height', Math.round($(this).height() * (max_width / $(this).width()))); 
$(this).css('width', max_width); 
} else { 
$(this).css('width', Math.round($(this).width() * (max_height / $(this).height()))); 
$(this).css('height', max_height); 
} 
} 
} 
}); 
} 
$(document).ready(function() { 

css_emulateMaxWidthHeight(); 

});  



	
/* Menu page d'accueil */
function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".sub").css({'width' : rowWidth});
			
		}
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}


	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 500, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li").hoverIntent(config);


});

$(document).ready(function(){	
		$("#slider").easySlider({
			auto: true,
		  continuous: true 
		});
	});
/* Fin Jquery 
_____________________________________________ */


/* Sous menu pour IE6
___________________________________________________ */

navHover = function() {
	var lis = document.getElementById("first_level").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
			
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", navHover);


/* Carte de France
___________________________________________________ */
/* 
 * Preload onmouseover images
 */
function preload_image(_image) {
	var image = new Image;
	image.src = _image;
}

/* 
 * Change county image onmouseover on index page 
 */
function change_image(region) {
	var ShowItem = document.getElementById("area_image");
	var LinkItem = document.getElementById("county_" + region);
	ShowItem.style.backgroundImage = 'url(/images/carte_france/map_' + region + '.png)';
	LinkItem.style.textDecoration = "none";
	LinkItem.style.color = "#f8ae00";
	return true;
}

/* 
 * Change back county image onmouseout on index page
 */ 
function hide_image(region) {
	var ShowItem = document.getElementById("area_image");
	var LinkItem = document.getElementById("county_" + region);
	ShowItem.style.backgroundImage = 'url(/images/carte_france/none.gif)';
	LinkItem.style.textDecoration = "none";
	LinkItem.style.color = "#0577bc";
	return true;
}

preload_image('/images/carte_france/map_1.png'); 
preload_image('/images/carte_france/map_2.png'); 
preload_image('/images/carte_france/map_3.png'); 
preload_image('/images/carte_france/map_4.png'); 
preload_image('/images/carte_france/map_5.png'); 
preload_image('/images/carte_france/map_6.png'); 
preload_image('/images/carte_france/map_7.png'); 
preload_image('/images/carte_france/map_8.png');
preload_image('/images/carte_france/map_9.png'); 
preload_image('/images/carte_france/map_10.png');
preload_image('/images/carte_france/map_11.png');


