/* Javascripts utilisés sur le site
 * Mettez l'ensemble de vos fonctions générique javascript ici
 * 
 * La liaison avec les page se fait à l'aide du code ci-dessous :
 * <script type="text/javascript" src="css-js/scripts.js"></script>
 */

/* CORRECTION DU BUG DE FLASH AVEC IE */
function bugFlash() {
	//Determine browser, we only need this for Internet Explorer
	if (navigator.appName == "Microsoft Internet Explorer") {
		
		//Array of elements to be replaced
		var arrElements = new Array(3);
		arrElements[0] = "object";
		arrElements[1] = "embed";
		arrElements[2] = "applet";
	
		
		//Loop over element types
		for (n = 0; n < arrElements.length; n++) {
		
			//set object for brevity
			replaceObj = document.getElementsByTagName(arrElements[n]);
			
			//loop over element objects returned
			for (i = 0; i < replaceObj.length; i++ ) {
			
				//set parent object for brevity
				parentObj = replaceObj[i].parentNode;
				
				//grab the html inside of the element before removing it from the DOM
				newHTML = parentObj.innerHTML;
				
				//remove element from the DOM
				parentObj.removeChild(replaceObj[i]);
				
				//stick the element right back in, but as a new object
				parentObj.innerHTML = newHTML;
			
				}
			}
		}
	}



function montre(id) {
		var myStretch = document.getElementsByClassName('stretch');
		var myStretcher = document.getElementsByClassName('stretcher');
		var myAccordion = new fx.Accordion(myStretch, myStretcher, {opacity: true});
                myAccordion.showThisHideOpen(myStretcher[id]);
}


function AddCodeToFunction(strFunc, strCode)
{
	var strParams = "";
	if (strCode.length > 0)
	{
		if (window[strFunc] != null)
		{
			strFnCode = window[strFunc].toString();
			if (strFnCode.length > 0)
			{
				var nPos = strFnCode.indexOf("{");
				var nParamPos = strFnCode.indexOf("(");
				var nLastPos;
				if ((nParamPos >= 0) && (nParamPos < nPos))
				{
					nLastPos = nParamPos + 1;
					while ((strFnCode.charAt(nLastPos) != ")") && (nLastPos < strFnCode.length))
						nLastPos++;
					strParams = strFnCode.substr(nParamPos + 1, nLastPos - nParamPos - 1);
				}

				nLastPos = strFnCode.lastIndexOf("}");
				strFnCode = strFnCode.substr(nPos + 1, nLastPos - nPos - 1);
			}
			strFnCode =  strFnCode + ";" + strCode + ";";
		}
		else
			strFnCode = strCode;
		window[strFunc] = new Function(strParams, strFnCode);
	}
}