﻿/* -- Adobe GoLive JavaScript Library */

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function ouvrirPopup(Link) {
	popup=window.open(Link.href,'popup','menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,resizable=no,width=405,height=450');
	if (popup.window.focus) { popup.window.focus(); }
	return false;
}

function ouvrirPlanning(Link) {
	popup=window.open(Link.href,'popup','menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,resizable=no,width=800,height=500');
	if (popup.window.focus) { popup.window.focus(); }
	return false;
}

function ouvrirPopup2(Link) {
	popup=window.open(Link.href,'popup','menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,resizable=no,width=405,height=500');
	if (popup.window.focus) { popup.window.focus(); }
	return false;
}

function ouvrirPopup3(Link) {
	popup=window.open(Link.href,'popup','menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,resizable=no,width=500,height=200');
	if (popup.window.focus) { popup.window.focus(); }
	return false;
}

function ouvrirPopup4(Link) {
	popup=window.open(Link.href,'Newsletter','menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,resizable=no,width=620,height=600');
	if (popup.window.focus) { popup.window.focus(); }
	return false;
}

function ouvrirPopup5(Link) {
	popup=window.open(Link.href,'Newsletter','menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,resizable=no,width=580,height=550');
	if (popup.window.focus) { popup.window.focus(); }
	return false;
}

function ouvrirPopup6(Link) {
	popup=window.open(Link.href,'Planning des cours collectifs','menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,resizable=no,width=580,height=450');
	if (popup.window.focus) { popup.window.focus(); }
	return false;
}

function ouvrirPopupImage(Link) {
	popup=window.open(Link.href,'Photo','menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,resizable=no,width=765,height=490');
	if (popup.window.focus) { popup.window.focus(); }
	return false;
}

function changeImages() {
	changeImagesArray(changeImages.arguments);
}
CSStopExecution=false;
function CSAction(array) {return CSAction2(CSAct, array);}
function CSAction2(fct, array) { 
	var result;
	for (var i=0;i<array.length;i++) {
		if(CSStopExecution) return false; 
		var aa = fct[array[i]];
		if (aa == null) return false;
		var ta = new Array;
		for(var j=1;j<aa.length;j++) {
			if((aa[j]!=null)&&(typeof(aa[j])=="object")&&(aa[j].length==2)){
				if(aa[j][0]=="VAR"){ta[j]=CSStateArray[aa[j][1]];}
				else{if(aa[j][0]=="ACT"){ta[j]=CSAction(new Array(new String(aa[j][1])));}
				else ta[j]=aa[j];}
			} else ta[j]=aa[j];
		}			
		result=aa[0](ta);
	}
	return result;
}
CSAct = new Object;
function CSOpenWindow(action) {
	var wf = "";	
	wf = wf + "width=" + action[3];
	wf = wf + ",height=" + action[4];
	wf = wf + ",resizable=" + (action[5] ? "yes" : "no");
	wf = wf + ",scrollbars=" + (action[6] ? "yes" : "no");
	wf = wf + ",menubar=" + (action[7] ? "yes" : "no");
	wf = wf + ",toolbar=" + (action[8] ? "yes" : "no");
	wf = wf + ",directories=" + (action[9] ? "yes" : "no");
	wf = wf + ",location=" + (action[10] ? "yes" : "no");
	wf = wf + ",status=" + (action[11] ? "yes" : "no");		
	window.open(action[1],action[2],wf);
}
function initImgID() {var di = document.images; if (mustInitImg && di) { for (var i=0; i<di.length; i++) { if (!di[i].id) di[i].id=di[i].name; } mustInitImg = false;}}
function findElement(n,ly) {
	var d = document;
	if (browserVers < 4)		return d[n];
	if ((browserVers >= 6) && (d.getElementById)) {initImgID; return(d.getElementById(n))}; 
	var cd = ly ? ly.document : d;
	var elem = cd[n];
	if (!elem) {
		for (var i=0;i<cd.layers.length;i++) {
			elem = findElement(n,cd.layers[i]);
			if (elem) return elem;
		}
	}
	return elem;
}
function changeImagesArray(array) {
	if (preloadFlag == true) {
		var d = document; var img;
		for (i=0;i<array.length;i+=2) {
			img = null; var n = array[i];
			if (d.images) {
				if (d.layers) {img = findElement(n,0);}
				else {img = d.images[n];}
			}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (!img && d.getElementsByName) {
				var elms = d.getElementsByName(n);
				if (elms) {
					for (j=0;j<elms.length;j++) {
						if (elms[j].src) {img = elms[j]; break;}
					}
				}
			}
			if (img) {img.src = array[i+1];}
		}
	}
}
function Cacher(id)
{
  objet = document.getElementById(id);
  if (objet.style.display == "block")
            objet.style.display = "none";
        else
            objet.style.display = "block";
}

function writediv(texte,div)
{
document.getElementById(div).innerHTML = texte;
}

function do_link(url, valeur)
{
	window.location.href = url;// + ((url.indexOf("?") != -1)?"&":"?") + "item=" + valeur;
}

var marked_row = new Array;

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0) 
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function


var FadeInterval = 500;
var StartFadeAt = 5;

// This is list of steps that will be used for the color to fade out
var FadeSteps = new Array();
	FadeSteps[1] = "ff";
	FadeSteps[2] = "ee";
	FadeSteps[3] = "dd";
	FadeSteps[4] = "cc";
	FadeSteps[5] = "bb";
	FadeSteps[6] = "aa";
	FadeSteps[7] = "99";
	FadeSteps[8] = "88";
	FadeSteps[9] = "77";
	FadeSteps[10] = "66";
	FadeSteps[11] = "55";
	FadeSteps[12] = "44";
	FadeSteps[13] = "33";
	FadeSteps[14] = "22";
	FadeSteps[15] = "11";
	FadeSteps[16] = "00";

function Highlight(target) {
	var FadeInterval = 800;
	var StartFadeAt = 16;
    DoFade(StartFadeAt, target);
}

// This is the recursive function call that actually performs the fade
function DoFade(colorId, targetId) {
    if (colorId >= 1) {
		document.getElementById(targetId).style.backgroundColor = "#ffff" + FadeSteps[colorId];
		//writediv("#ffff" + FadeSteps[colorId],'resultats');
        if (colorId==1) {
            document.getElementById(targetId).style.backgroundColor = "#fff";
		}
        colorId--;
        setTimeout("DoFade("+colorId+",'"+targetId+"')", FadeInterval);
	}
}
