/**
 * cleanSearch: vide le champ de recherche quand la valeur est 'Recherche'
 */
function cleanSearch() {
	if (document.getElementById("me_searchField") && document.getElementById("me_searchField").value == 'Recherche') {
		document.getElementById("me_searchField").value = '';
	}
}

function loadVideo(video_path, subtitleURL, audioURL, div, sMedia, sPlugName, width, height) {
	var flashvars = {
		file:video_path,
		autostart:"true",
		playlistsize:"0",
		playlist:"bottom",
		shuffle:'false',
		enablejs:'true',
		autoscroll:'false',
		plugins:'captions-1,audiodescription-1',
		shuffle:"false",
		javascriptid:'videoItem',
		captions:subtitleURL,
		audio:audioURL
    }
        
    var params = {
        allowfullscreen:"true",
        allowscriptaccess:"always",
        seamlesstabbing:'true'
    }
    
    var attributes = {
        id:'player'+div,
        name:'player'+div
    }
    
    if (swfobject.hasFlashPlayerVersion("9.0.115")) {
    	swfobject.embedSWF(sMedia + "/plugin/" + sPlugName + "/jw_flv_player/phpsflvplayer.swf", div, width, height, "9.0.115", false, flashvars, params, attributes);
    	return false;
    } else {
    	return true;
    }
}



$(function() { 
	$(".me_linkPrint, .me_pictoIncreaseFont, .me_pictoDecreaseFont").show();

/* -- Bouton d'impression -- */

	$(".me_linkPrint a").click(function () {
		window.print();
		return false;
	});
	
	var containerUneHeight = function () {
		var indexEl = $(".me_blockUneOnglets .scrollable .items > li").index( $('.active')[0] );
		indexEl++;
		var elId = $(".me_listUne .innerlistUne > li#me_une"+indexEl);
		var heightLi = elId.height();
		if (heightLi < $(".me_blockUneOnglets").height()) {
			$(".me_listUne .innerlistUne > li#me_une"+indexEl+" > div > div > div > div").height($(".me_blockUneOnglets").height());
		}
		$(".me_listUne").animate({height:heightLi}, 100);
	}
	
	var containerHeight = function () {
		var heightLi;
			heightLi = $(".me_listUne .innerlistUne > li:visible").height();
		$(".me_listUne .innerlistUne > li").not(':visible').css("margin", "0");
		$(".me_listUne").height(heightLi);
	}
	
	var txtSize = 11;
	var increase=0;
	$(".me_contentHeader").css("fontSize", "11px");
	$(".me_pictoIncreaseFont a").click(function () {
		if (increase < 3) {
			txtSize = txtSize+2;
			$("body").css("fontSize", txtSize+"px");
			containerHeight();
			containerUneHeight();
			increase++;
		}
		return false;
	});
	$(".me_pictoDecreaseFont a").click(function () {
		if (increase > 0) {
			txtSize = txtSize-2;
			$("body").css("fontSize", txtSize+"px");
			containerHeight();
			containerUneHeight();
			increase--;
		}
		return false;
	});

	if (document.getElementById('pop')) {
		document.getElementById('pop').style.display = 'block';
	}
	
	$("iframe").load(function () {
  	adjustMyFrameHeight($(this).attr('id'));
	});
});

function hidePop(id) {
	var obj = document.getElementById(id);
	if (obj) {
		obj.style.left = "-100%"; 
		obj.style.top = "-100%";
		obj.style.display = "none";
	}
}


	function getElement(aID) {
		return (document.getElementById) ?
		document.getElementById(aID) : document.all[aID];
	}
	
	function getIFrameDocument(aID) {
		var rv = null;
		var frame=getElement(aID);
		
		if (frame.contentDocument)
			rv = frame.contentDocument;
		else
			rv = document.frames[aID].document;
		
		return rv;
	}
	
	function adjustMyFrameHeight(id) {
		var frame = getElement(id);
		var frameDoc = getIFrameDocument(id);
		
		frame.style.height = frameDoc.body.offsetHeight+'px';
		frame.style.width	 = frameDoc.body.offsetWidth+'px';
		
		frame.height = frameDoc.body.offsetHeight;
		frame.width = frameDoc.body.offsetWidth;
	}
	
	Shadowbox.init({
		players: ["html","iframe"],
		language:   "fr"
	});

