
//Date (header) ****************************************
function Datum(){
	var now = new Date();
	var jour = now.getDay();
	var day = now.getDate();
	var year=now.getFullYear();
	var month=now.getMonth();

	(month==0)?month="Janvier":(month==1)?month="Février":(month==2)?month="Mars":
	(month==3)?month="Avril":(month==4)?month="Mai":(month==5)?month="Juin":
	(month==6)?month="Juillet":(month==7)?month="Août":(month==8)?month="Septembre":
	(month==9)?month="Octobre":(month==10)?month="Novembre": month="Décembre";

	//Doesn't work
	//(jour==0)?jour="Dim":(jour==1)?jour="Lun":(jour==2)?jour="Mar":(jour==3)?jour="Mer":
	//(jour==4)?jour="Jeu":(jour==5)?jour="Ven":(jour==6)?jour="Sam";

	if (jour==0) {jour="Dim.";}
	if (jour==1) {jour="Lun.";}
	if (jour==2) {jour="Mar.";}
	if (jour==3) {jour="Merc.";}
	if (jour==4) {jour="Jeu.";}
	if (jour==5) {jour="Ven.";}
	if (jour==6) {jour="Sam.";}

	document.writeln(""+jour+" "+day+" "+month+" "+year+"");
}

//Time clock (header) *********************************
function Clock() {
	//if (!document.layers && !document.all) return;

	var runTime = new Date();
	var hours = runTime.getHours();
	var minutes = runTime.getMinutes();
	var seconds = runTime.getSeconds();
	//var GMT = runTime.getTimeZoneOffset();

	if (hours == 0) {
		hours = 12;
	}

	if (minutes <= 9) {
		minutes = "0" + minutes;
	}

	if (seconds <= 9) {
		seconds = "0" + seconds;
	}

	movingtime = ""+ hours + ":" + minutes + ":" + seconds;
	
	window.document.getElementById("clock").innerHTML = movingtime;	

/*	if (document.layers) {
		document.layers.clock.document.write(movingtime);
		document.layers.clock.document.close();
	}
	else if (document.all) {
		clock.innerHTML = movingtime;
	}*/

	setTimeout("Clock()", 1000)
}


//Change cell color ***********************************
function ChangeCellBG(el, myColor) {
     el.style.background =myColor;
}

//Table Highlight *************************************
var rowHighlight = true // turn on row highlights
var colHighlight = false // turn off row highlights

function getElement(el) {
	var tagList = new Object
	for (var i = 1; i < arguments.length; i++)
		tagList[arguments[i]] = true
	while ((el!=null) && (tagList[el.tagName]==null))
		el = el.parentElement
	return el
}

function checkHighlight(which) {
	var el = getElement(event.srcElement,"TH","TD")
	if (el==null) return

	if ((el.tagName=="TH") && (colHighlight)) {
		var idx = el.cellIndex
		var table = getElement(el, "TABLE")
		var column = table.all.tags("COL")[idx]

		if (which)
			column.className="ListHighlight"
		else
			column.className=""
	}

	if ((el.tagName=="TD") && (rowHighlight)) {
		var row = getElement(el, "TR")
		var table = getElement(row, "TABLE")

		if (which)
			row.className = "ListHighlight"
		else
			row.className = ""
		cache = row
	}
}

//PopUp ***********************************************
function screenshot(id, nb) {
	popup = window.open('screenshots.php?id='+id+'&nb='+nb, 'popup', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=780, height=580, dependent=1'); 
	popup.focus();
}

//PopUp ***********************************************
function popup(lnk) {
	popup = window.open(lnk, 'popup', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=700, height=250, dependent=1'); 
	popup.focus();
}

//Add CTC *********************************************
function AddCtcPopup() {
	addctc = window.open('ctcaddtel.php', 'addctc', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=350, height=250, dependent=1'); 
	addctc.focus();	
}

//CTC tel edit ***************************************
function CtcTelAddPopup(key_ctc) {
 ctcteledit = window.open('ctcteledit.php?key_ctc='+key_ctc, 'ctcteledit1', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=450, height=185, dependent=1'); 
 ctcteledit.focus();
}

function CtcTelEditPopup(key_ctctel) {
 ctcteledit = window.open('ctcteledit.php?key_ctctel='+key_ctctel, 'ctcteledit1', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=450, height=185, dependent=1'); 
 ctcteledit.focus();
}

//CTC adr edit ***************************************
function CtcAdrAddPopup(key_ctc) {
	ctcadredit = window.open('ctcadredit.php?key_ctc='+key_ctc, 'ctcadredit', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=450, height=300, dependent=1'); 
	ctcadredit.focus();
}

function CtcAdrEditPopup(key_ctcadr) {
	ctcadredit = window.open('ctcadredit.php?key_ctcadr='+key_ctcadr, 'ctcadredit', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=450, height=300, dependent=1'); 
	ctcadredit.focus();
}

//LIT add *********************************************
function LitAddPopup(key_pos) { //non terminé. pas en foncion
	ctcadredit = window.open('ctcadredit.php?key_ctc='+key_ctc, 'ctcadredit', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=450, height=300, dependent=1'); 
	ctcadredit.focus();
}

//Filters popup ***************************************
function FiltersPopup() {
	filters = window.open('search_filter.php?tablename=<? echo $tablename?>', 'filters', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=675, height=250, dependent=1'); 
	filters.focus();
} 

//Filters popup ***************************************
function HelpPopup(section) {
	HelpPopup = window.open('help.php#'+section, 'HelpPopup', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=500, height=250, dependent=1'); 
	HelpPopup.focus();
} 

//Hide emails *****************************************
function WriteEmail(user, site, subject, text) {
	document.write('<a href=\"mailto:' + user + '@' + site + '?subject=' + subject + '\">' + text + '</a>');	
}

//Swap images *****************************************
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
