
function msgRedirect(titre,content,url,LabelOK) {
	//win = Dialog.confirm(content, {width:460, okLabel: LabelOK, title: titre,buttonClass: "myButtonClass", id: "myDialogId", ok:function(win) {window.location=url; return true;}, showEffectOptions: {duration:0}, closable:true });
	win = Dialog.alert(content, {width:460, okLabel: LabelOK, title: titre,buttonClass: "myButtonClass", id: "myDialogId", ok:function(win) {window.location=url; return true;}, showEffectOptions: {duration:0}, closable:true });
	win.setZIndex(4444);
}

function msgConfirm(titre,content,url,LabelOK,LabelCancel) {
	win = Dialog.confirm(content, {width:460, okLabel: LabelOK,cancelLabel: LabelCancel, title: titre,buttonClass: "myButtonClass", id: "myDialogId", cancel:function(win) {debug("cancel confirm panel")}, ok:function(win) {window.location=url; return true;}, showEffectOptions: {duration:0}, closable:true });
	win.setZIndex(4444);
}


// MSG de confirmation avec redirection dans le 2 cas
function msgConfirmAction(titre,content,urlOk,urlCancel,LabelOK,LabelCancel) {
	win = Dialog.confirm(content, {width:460, okLabel: LabelOK,cancelLabel: LabelCancel, title: titre,buttonClass: "myButtonClass", id: "myDialogId", cancel:function(win) {window.location=urlCancel; return true;}, ok:function(win) {window.location=urlOk; return true;}, showEffectOptions: {duration:0}, closable:false });
	win.setZIndex(4444);
}

function msgConfirmSubmit(titre,content,formName,LabelOK,LabelCancel) {
	win = Dialog.confirm(content, {width:460, okLabel: LabelOK,cancelLabel: LabelCancel, title: titre,buttonClass: "myButtonClass", id: "myDialogId", cancel:function(win) {debug("cancel confirm panel")}, ok:function(win) {document.getElementById(formName).submit(); return true;}, showEffectOptions: {duration:0}, closable:true });
	win.setZIndex(4444);
}

function msgAlert(titre,content,LabelClose) {
    win = Dialog.alert(content, {width:460, height:200, okLabel: LabelClose, title: titre,ok:function(win) {debug("validate alert panel"); return true;}, closable:true });
	win.setZIndex(4444);
}

function msgUrl(titre,content,LabelClose) {
    win = Dialog.alert({url: content, options: {method: 'get'}}, {width:"600", height:"400", title: titre, okLabel: LabelClose});
	win.setZIndex(4444);
}

function info(titre,content,LabelClose,width,height) {
    win = Dialog.alert(content, {width:width, height:height, okLabel: LabelClose, title: titre,ok:function(win) {debug("validate alert panel"); return true;}, recenterAuto:false, closable:true });
	win.setZIndex(4444);
}

function imagePreview (nom,content,btn,width,height){
	info(nom,"<a href='#' onclick='win.close();' ><img src='"+content+"' border='0' /></a>",btn,width+20,height+100);
}


//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}


function fadeimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";

	//make image transparent
	changeOpac(0, imageid);

	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}

}


FuncOL = new Array();
function StkFunc(Obj) {
    FuncOL[FuncOL.length] = Obj;
}

// Execution des scripts au chargement de la page
window.onload = function() {
    for(i=0; i<FuncOL.length; i++)
        {FuncOL[i]();}
}



function CheckAll(FormName, FieldName)
{
	if (document.getElementById("checkall").checked == true)
			CheckValue = 1;
	else	CheckValue = 0 ;


	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}

// D�tecte le scan du code barre et n'execute pas le return
function checkScan (field, evt) {
  var keyCode =
	document.layers ? evt.which :
	document.all ? event.keyCode :
	document.getElementById ? evt.keyCode : 0;
  if (keyCode == 13)
	  return false;
}

function is_array(input){
	return typeof(input)=='object'&&(input instanceof Array);
}

function difference_jour(dateArrivee, dateDepart) {
    dateArriveeTmp = new Date (dateArrivee.substr(6,4), (dateArrivee.substr(3,2) - 1), dateArrivee.substr(0,2),13,13,13) ;
    dateDepartTmp = new Date (dateDepart.substr(6,4), (dateDepart.substr(3,2) - 1), dateDepart.substr(0,2),13,13,13) ;
    return Math.round((dateDepartTmp - dateArriveeTmp) / (1000 * 60 * 60 * 24)) ;
}

function decalage_date(date, nbJour) {
    date = new Date (date.substr(6,4), (date.substr(3,2) - 1), date.substr(0,2),13,13,13) ;
    val = new Date(date.getTime() + (1000 * 60 * 60 * 24 * nbJour));
    jour = val.getDate()+'';
    if (jour.length == 1) jour = "0" + jour;

    mois = val.getMonth()+1;
    mois = mois + "";
    if (mois.length == 1) mois = "0" + mois;
    annee=val.getFullYear();
    return (jour+"."+mois+"."+annee);
}
