jQuery(document).ready(function(){
	jQuery('#top-access .menu-item').each(function(){
		jQuery(this).mouseenter(function(){
			jQuery(this).addClass('hover');
		});
		jQuery(this).mouseleave(function(){
			jQuery(this).removeClass('hover');
		});
	});
	
	jQuery('#search-box, #form-offre-min').mouseenter(function(){
		jQuery('#form-offre-min').addClass('hover');
	});
	jQuery('#search-box, #form-offre-min').mouseleave(function(){
		jQuery('#form-offre-min').removeClass('hover');
	});
	
	jQuery('#idspecialite, #idregion').mouseleave(function(event){
		event.stopPropagation(); 
	});
	
	jQuery('#idspecialite, #idregion').change(function(event){
		event.stopPropagation(); 
	});
	          
	jQuery("#form-offre-min select[name='idspecialite'], #form-offre select[name='idspecialite']").change(function(evt) {
    var cible = jQuery(evt.target);
    $.ajax({
      type: "POST",
      url: bloginfo+"/wp-admin/admin-ajax.php",
      data: "action=choicespecialite&idspecialite="+$(evt.target).val(),
      async: true,
      success: function(msg) {
    	if ($("select[name='idspecialite']").val() == 'all') { 
	        if(cible.parent().parent().parent().parent().parent().attr('id') == 'form-offre-min')
	          $("select[name='idregion']").eq(0).html(msg);
	        else if($("select[name='idregion']").eq(1).length != 0) 
	          $("select[name='idregion']").eq(1).html(msg);
	        else
	          $("#idregion").html(msg);
    	}
        $("select[name='idspecialite']").val($(evt.target).val());
      }
    });
  });
	
	jQuery("#form-offre-min select[name='idregion'], #form-offre select[name='idregion']").change(function(evt) {
    var cible = jQuery(evt.target);
    $.ajax({
      type: "POST",
      url: bloginfo+"/wp-admin/admin-ajax.php",
      data: "action=choiceregion&idregion="+$(evt.target).val(),
      async: true,
      success: function(msg) {
    	if ($("select[name='idspecialite']").val() == 'all') { 
	        if(cible.parent().parent().parent().parent().parent().attr('id') == 'form-offre-min')
	          $("select[name='idspecialite']").eq(0).html(msg);
	        else if($("select[name='idspecialite']").eq(1).length != 0) 
	          $("select[name='idspecialite']").eq(1).html(msg);
	        else
	          $("#idspecialite").html(msg);
        }
        $("select[name='idregion']").val($(evt.target).val());
      }
    });
  });
	
	jQuery(".title-list").click(function() {
     jQuery(this).next().slideToggle('slow');
  });
	
	function removeObjectInIE(el) {
	    var jbo = (typeof(el) == "string" ? getElementById(el) : el);
	    if (jbo) {
	        for (var i in jbo) {
	            if (typeof jbo[i] == "function") {
	                jbo[i] = null;
	            }
	        }
	        jbo.parentNode.removeChild(jbo);
	    }
	}
	
	//appel du flash
	var flashvars = {};
	var params = {wmode : 'transparent'};
	var attributes = {};
	swfobject.embedSWF('http://www.dailymotion.com/swf/video/xaldoh', 'dailyvideo', '206', '118', '9.0.0' , 'Scripts/expressInstall.swf', flashvars, params, attributes);
	
	jQuery('.homepage .thumbs a').click(function(event){
		event.preventDefault();
		jQuery('#dailyvideo').remove();
		jQuery('.homepage .video').html('<div id="dailyvideo"></div>');
		swfobject.embedSWF(jQuery(this).attr('href'), 'dailyvideo', '206', '118', '9.0.0' , 'Scripts/expressInstall.swf', flashvars, params, attributes);
		
		/*
		jQuery('#flav [name="movie"]').attr('value',jQuery(this).attr('href'));
		
		if(!jQuery.browser.msie || jQuery.browser.msie==undefined){
			jQuery('#flav embed').attr('src',jQuery(this).attr('href'));
		}
		*/
		
		/*
		else{
			jQuery('#flav').append('<param name="movie" value="'+jQuery(this).attr('href')+'" />');
		}
		var object = jQuery('.video object');
		jQuery('.video object').remove();
		jQuery('.video').html(object);
		*/
		
		//jQuery('#flav').css('display','none');
		//jQuery('#flav').css('display','block');
		
	});
	
	jQuery(".homepage .scrollable").scrollable({circular: true, mousewheel: true}).navigator().autoscroll({
		interval: 4000		
	});
	jQuery('#sidebar-left li a').each(function(){
		if(parseFloat($(this).height())>21 && parseFloat($(this).height())<41)
			$(this).addClass('big');
		else if(parseFloat($(this).height())>41 && parseFloat($(this).height())<61)
			$(this).addClass('big2');
		else if(parseFloat($(this).height())>61 && parseFloat($(this).height())<81)
			$(this).addClass('big3');
		else if(parseFloat($(this).height())>81)
			$(this).addClass('big4');
	});
});
