//cette fonction permet de créér un intérrupteur il suffit de mettre les Id des element a afficher/masquer en arguments
function vaEtViens(){
	for (i=0;i<arguments.length;i++) {
		var myElement=document.getElementById(arguments[i]);
		myElement.style.display=(myElement.style.display=="block")?"none":"block";
	}
}
//affiche un element et lance la fonction pour le centrer
function showPopup(myId,myEffect) {
	document.getElementById(myId).style.display="block";//hack IE qui pezu pas récupérer les dimensions d'un element en disply:none;
	nova.dom.centerObjectOnViewport(document.getElementById(myId));
	document.getElementById(myId).style.display="none";
	if (myEffect) {
		document.getElementById(myId).style.zIndex=10;//pali un defaut des div  en relative
		nova.effects.addToQueue(nova.effects.fadeIn,document.getElementById(myId),{duration:500});
		nova.effects.queueNext();
	}
	else {
		document.getElementById(myId).style.display="block";
	}
}
function hidePopup(myId) {	
	nova.effects.addToQueue(nova.effects.fadeOut,document.getElementById(myId),{duration:500});
	nova.effects.queueNext();
}
//permet de recréer une scrollbar
var Timer;
var Pas = 7;
function moveLayer(Sens) {
	Objet=document.getElementById("contenu");
    if(parseInt(Objet.style.top) + (Pas*Sens)>0)  {
		clearTimeout(Timer);
	}
	else if(parseInt(Objet.style.top) + (Pas*Sens)<-(Objet.offsetHeight-document.getElementById("support").offsetHeight)) {
		clearTimeout(Timer);
	}
    else {
        Objet.style.top = (parseInt(Objet.style.top) + (Pas*Sens)) + "px";
	}
	Timer = setTimeout("moveLayer(" + Sens + ");", 30);
}
//permet de n'afficher les sliders que si cela est necessaire
function showSlider() {
	if (document.getElementById("contenu").offsetHeight>document.getElementById("support").offsetHeight) {
		document.getElementById("slides").style.display="block";
	}
	else {
		document.getElementById("slides").style.display="none";
	}
}
var version=0;
if (navigator.appVersion.indexOf("MSIE")!=-1){
	temp=navigator.appVersion.split("MSIE");
	version=parseFloat(temp[1]);
	if(version) {
	   	window.attachEvent("onload", IE_CorrectAlpha_PNG);
	}
}
//correction des png pour IE6
function IE_CorrectAlpha_PNG(){
	for(i=0; i<document.images.length; i++){
		img    = document.images[i];
		imgExt  = img.src.substring(img.src.length-3, img.src.length);
		imgExt  = imgExt.toUpperCase();
		if (imgExt == "PNG"){
			allClass=(img.className!="")?img.className.split(" "):"";
			var alphaMe=false;
			for (j=0;j<allClass.length;j++) {
				if(allClass[j]=="alphaMe") {
					alphaMe=true;
				}
			}
			if (alphaMe) {//permet de ne traiter que certaine image
				imgID    = (img.id) ? "id='" + img.id + "' " : "";
				imgClass= (img.className) ? "class='" + img.className + "' " : "";
				imgTitle= (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				imgStyle= "display:block;" + img.style.cssText;
				if (img.align == "left") { imgStyle = "float:left;"  + imgStyle; } else if (img.align == "right"){ imgStyle = "float:right;" + imgStyle; }
				if (img.parentElement.href)   { imgStyle = "cursor:hand;" + imgStyle; }       
				strNewHTML    = '<span '+imgID+imgClass+imgTitle+' style="width:'+img.width+'px; height:'+img.height+'px;'+imgStyle+';'+'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+img.src+'\', sizingMethod=\'scale\');"></span>';
				img.outerHTML = strNewHTML;
				i = i-1;
			}
		}
	}
}
//initialisation de tinymce
function launchTinyMce(myElement) {
	tinyMCE.init({
		mode : "exact",
		elements : myElement,
		theme : "advanced",
		language: "fr",
		plugins : "save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu",
		theme_advanced_buttons1_add : "fontsizeselect",
		theme_advanced_buttons2_add : "separator,forecolor,backcolor,separator,cut,copy,paste",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		plugin_insertdate_dateFormat : "%Y-%m-%d",
		plugin_insertdate_timeFormat : "%H:%M:%S",
		extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
		relative_urls : false,convert_urls : false,
		file_browser_callback : 'FileBrowser'
	});
}
function returnSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var result = new Array(myWidth,myHeight);
  return result;
}
function addStyle(myId) {
	result=returnSize();
	myElement=document.getElementById(myId);
	if (result[0]<760) {
		myElement.style.left="0";
		myElement.style.marginLeft="0";
	}
	if (result[1]<597) {
		myElement.style.top="0";
		myElement.style.marginTop="0";
	}
}
