﻿// ===========================================
//
// Fonctions communes
//
// ===========================================

var strToolNameVersion = '';

function atx_OutOfFrame() {
	if (top.location != location) {
		top.location.href = document.location.href;
	}

	var btnDelete          = document.getElementById('btnDelete');

	try {
	    if (btnDelete != null) {
	        btnDelete.onclick = atx_AlertDelete;
	    }
	}
	catch (e) {}
}

function atx_LinkOver(strStatusText) {
	window.status = strStatusText;
	return (navigator.appName != 'Opera');
}

function atx_LinkOut(strStatusText) {
	window.status = strStatusText;
}


// ===========================================
//
// Protection du bouton Supprimer
//
// ===========================================

function atx_AlertDelete() {

	var objElem = window.event;

	if (confirm(strToolNameVersion
	+ '\n\nVous avez demandé la suppression de l\'information sélectionnée.\nCette opération ne peut pas être annulée.\n\n'
	+ 'Vous pouvez choisir de :\n\n'
	+ ' - Cliquer sur ANNULER pour revenir dans l\'outil sans supprimer l\'information.\n'
	+ ' - Cliquer sur OK pour confirmer la suppression de l\'information.') == true) {
		__doPostBack('btnDelete','');
	}
}

// ===========================================
//
// Sélection type "Pays" ou "New"
//
// ===========================================

function axt_FlagClicked(objLink) {

	var objTr	= null;

	try {

		var objImgTag = atx_GetParent(objLink).getElementsByTagName('IMG');
		var strImgSrc = objImgTag[0].src;
		
		var objFlags = document.getElementById('ml_liste').getElementsByTagName('TR');
		for (var i = 1; i < objFlags.length; i++) {
			objFlags[i].style.display = 'none';
		}

		var objFlags = document.getElementById('ml_liste').getElementsByTagName('IMG');
		for (var i = 0; i < objFlags.length; i++) {

			if (objFlags[i].src == strImgSrc) {
				objTr = atx_GetParent(objFlags[i])
				if (objTr != null) {
					objTr = atx_GetParent(objTr)
					if (objTr != null) {
						if (objTr.nodeName == "TR") {
							objTr.style.display = '';
						}
					}
				}
			}
		}
		atx_colH();
	}
	catch (e) {alert(e.message);}
}

function atx_GetParent(objAtx) {
	if (objAtx.parentElement != null) return objAtx.parentElement;
	else if (objAtx.parentNode != null) return objAtx.parentNode;
	else return null;
}

// =================================================
//
// Fonction NoSpamHyperlink
// (issue du domaine public)
//
// =================================================

function atx_LinkToMe(link,seed){var ky=
"yJzdeB4CcDnmEFbZtvuHlI1hA8SiLo9MwfN3O6Y5QaRqKTjUpxVk2WgXrP7Gs0";
if(document.all){link=document.all[link];}else{link=document.getElementById(link);}
var storeText=link.innerHTML;var baseNum=parseInt(seed);var atSym=link.href.indexOf("@");
if(atSym==-1)atSym=0;var dotidx=link.href.indexOf(".",atSym);if
(dotidx==-1)dotidx=link.href.length;var scramble=link.href.substring(7,
dotidx);var unscramble="";var su=true;for(i=0;i<scramble.length;i++)
{var ch=scramble.substring(i,i+1);var idx=ky.indexOf(ch);if(idx<0)
{unscramble=unscramble+ch;continue;}idx-=(su?-baseNum:baseNum);
baseNum-=(su?-i:i);while(idx<0)idx+=ky.length;idx%=ky.length;
unscramble=unscramble+ky.substring(idx,idx+1);su=!su;}var emAdd=
unscramble+link.href.substring(dotidx,link.href.length+1);link.href=
"mailto:"+emAdd;var findEm=storeText.indexOf(scramble);while(findEm>
-1){storeText=storeText.substring(0,findEm)+emAdd+
storeText.substring(findEm+emAdd.length,storeText.length);findEm=
storeText.indexOf(scramble);}link.innerHTML=storeText;}


// =================================================
//
// Fonctions COOKIES
// (issues du domaine public)
//
// =================================================

function getCookieVal (offset) {

  var endstr = document.cookie.indexOf (';', offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {

  var argv = GetCookie.arguments;
  var argc = GetCookie.arguments.length;
  var defaultvalue = (argc > 1) ? argv[1] : null;
  var arg = name + '=';
  var alen = arg.length;
  var cookievalue;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg){
      cookievalue = getCookieVal(j);
      if(cookievalue == 'null') return defaultvalue;
      return getCookieVal (j);
    }
    i = document.cookie.indexOf(' ', i) + 1;
    if (i == 0) break; 
  }
  return defaultvalue;
}

function SetCookie (name, value) {

  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;

  document.cookie = name + '=' + escape (value) +
    ((expires == null) ? '' : ('; expires=' + expires.toGMTString())) +
    ((path == null) ? '' : ('; path=' + path)) +
    ((domain == null) ? '' : ('; domain=' + domain)) +
    ((secure) ? '; secure' : '');
}
/* ================================================= */

function atx_ObjectListProperties(objObject) {
//
// Liste les propriétés d'un objet
// De manière à ne pas occuper trop de place, les valeurs
// trop longues sont tronquées (64 caractères), les fonctions
// ne sont pas listées (<blacklisted>) car consultables en
// mode EDIT...
//
	var strList = 'Properties of object ' + objObject.toString() + '\n\n';
	var i = 0;
	for (prop in objObject) {
		try {
			if (objObject[prop] != null) {
				if ((typeof(objObject[prop]) == 'string') && (objObject[prop].length > 0)) {
					strList = strList + prop + '\t\t (' + typeof(objObject[prop]) + ')\t = '
					strList = strList + objObject[prop].substr(0,64) + '\n';
				}
				else if (typeof(objObject[prop]) == 'function') {
					strList = strList + prop + '\t\t (' + typeof(objObject[prop]) + ')\t = '
					strList = strList + '<blacklisted> \n';
				}
				else if ('<'+objObject[prop]+'>' != '<>') {
					strList = strList + prop + '\t\t (' + typeof(objObject[prop]) + ')\t = '
					strList = strList + objObject[prop] + '\n';
				}
				i += 1;
				if (i == 50) {
					alert(strToolNameVersion + '\n\n'
					+ strList);
					strList = '';
					i = 0;
				}
			}
		}
		catch (e) {
			strList = strList + prop + '\t\t\t  !!! ' + e.message + '\n';
			i += 1;
			if (i == 50) {
				alert(strToolNameVersion + '\n\n'
				+ strList);
				strList = '';
				i = 0;
			}
		}
	}
	alert(strToolNameVersion + '\n\n'
		+ strList);
	return true;
}

// ===========================================
//
// Egalisation de la hauteur des colonnes
//
// ===========================================

function atx_colH() {

	var i;
	var oh;
	var hh;

	var h=0;
	var dA=document.atx_eqc;
	var an=document.atx_eqa;
	
	if (dA && dA.length){

		for ( i = 0; i < dA.length; i++) {
			dA[i].style.height = 'auto';
		}
		
		for ( i = 0; i < dA.length; i++) {
			oh = dA[i].offsetHeight;
			h = (oh > h) ? oh : h;
		}
		
		for ( i = 0; i < dA.length; i++) {
			if (an) {
				dA[i].style.height = h + 'px';
			}
			else {
				atx_eqA(dA[i].id, dA[i].offsetHeight, h);
			}
		}
		
		if (an) {
			for ( i = 0; i < dA.length; i++) {
				hh = dA[i].offsetHeight;
				if (hh > h) {
					dA[i].style.height = (h - (hh - h)) + 'px';
				}
			}
		}
		else {
			document.atx_eqa = 1;
		}

		document.atx_eqth = document.body.offsetHeight;
		document.atx_eqtw = document.body.offsetWidth;
	}
}

function atx_eqT() {

	if (document.atx_eqth != document.body.offsetHeight || document.atx_eqtw != document.body.offsetWidth) {
		atx_colH();
	}
}

function atx_equalCols() {

	if (document.getElementById) {
		document.atx_eqc = new Array;
		if (arguments.length == 0) {
			var i = 0
			while (0 == 0) {
				if (document.getElementById('c' + (i + 1).toString()) == null) break;
				document.atx_eqc[i] = document.getElementById('c' + (i + 1).toString());
				i++;
			}
		}
		else {
			for (i = 0; i < arguments.length; i++) {
				document.atx_eqc[i] = document.getElementById(arguments[i]);
			}
		}
		setInterval("atx_eqT()", 10);
	}
}

function atx_equalColsFast() {

	if (document.getElementById) {
		document.atx_eqc = new Array;
		for (i = 0; i < arguments.length; i++) {
			document.atx_eqc[i] = document.getElementById(arguments[i]);
		}
	}
}

function atx_eqA(el, h, ht) {

	var sp = 10;
	var inc = 10;
	var nh = h;
	var g = document.getElementById(el);
	var oh = g.offsetHeight;
	var ch=parseInt(g.style.height);
	
	ch = (ch) ? ch : h;
	
	var ad = oh-ch;
	var adT = ht-ad;

	nh += inc;
	nh = (nh > adT) ? adT : nh;
	
	g.style.height = nh+'px';
	oh = g.offsetHeight;
	
	if (oh > ht) {
		nh = (ht - (oh - ht));
		g.style.height = nh + 'px';
	}

	if (nh < adT) {
		setTimeout("atx_eqA('" + el + "'," + nh + "," + ht + ")", sp);
	}
}

