﻿/*
Copyright (c) 2008 ATXOOM.  Tous Droits Réservés.

1 - PROPRIETE INTELLECTUELLE
Ce Logiciel est la propriété de ATXOOM ou de ses fournisseurs.
Ce Logiciel est protégé par la loi relative au droit d'auteur et
par les conventions internationales. En conséquence, vous devez
considérer ce Logiciel comme n'importe quel autre matériel protégé
par un droit d'auteur (par exemple, un livre ou un enregistrement
sonore). Cependant, l'autorisation vous est accordée d'effectuer
une copie du Logiciel à seule fin de constituer une sauvegarde ou
une archive. Vous n'êtes pas autorisé à reproduire la documentation
fournie avec le Logiciel, sauf pour un usage personnel autorisé.

Toute personne ne respectant pas ces dispositions se rendra
coupable du délit de contrefaçon et sera passible des sanctions
pénales prévues par la loi.

2 - ACCORD DE LICENSE
Le droit d'utilisation qui vous est concédé permet l'installation et
l'utilisation du Logiciel sur un et seul ordinateur.

3 - CESSION
Le droit d'utilisation qui vous est concédé est incessible et non
transférable.


Copyright (c) 2008 ATXOOM.  All Rights Reserved.

1 - COPYRIGHT
The Software is owned by ATXOOM or its suppliers and is protected
by copyright laws and international treaty provisions. Therefore,
you must treat the Software like any other copyrighted material
(e.g., a book or musical recording) except that you may make one
copy of the Software solely for back up or archival purposes.
You may not copy the user documentation provided with the Software, except
for your own authorized use. 

2 - GRANT OF LICENSE
This Software License Agreement ("License") permits you to install
and use one copy solely of the Software on one computer solely.

3 - NOT FOR RESALE SOFTWARE
The software is labeled “Not For Resale” or “NFR”, then, notwithstanding
other sections of this license, your use of the software is limited to
use for demonstration, test, or evaluation purposes and you may
not resell, or otherwise transfer for value, the software.
*/
var MovingDivTop = 0;
var MovingDivIsMoving = null;
var CurrentMovingDivTop = 0;
var CachedWebRoot = null;

/*window.onscroll= function() {
    try {
		MovingDivTop = (document.all) ? document.documentElement.scrollTop : window.pageYOffset;
		MovingDivTop = Math.max(0, MovingDivTop - 277);
		if (MovingDivIsMoving == null) {
			MovingDivIsMoving = setTimeout('RelativeMoveMovingDiv();', 250);
		}
    } catch (e) {}
}*/

function atx_Start() {

	PaintControls();

	if (UseScreenSize == true) {
		if (screen.width <= 800) {
			if (document.styleSheets[0].href.indexOf('_big') >= 0) {
				if (document.location.search == '') {
					document.location = document.location + "?atx=800";
				}
				else if (document.location.search.indexOf('?atx=') < 0 && document.location.search.indexOf('&' + 'atx=') < 0) {
					document.location = document.location + "&' + 'atx=800";
				}
				else {
					document.location = document.location.toString().replace(/atx=1024/, 'atx=800');
				}
			}
		}
		else {
			if (document.styleSheets[0].href.indexOf('_big') < 0) {
				if (document.location.search == '') {
					document.location = document.location + "?atx=1024";
				}
				else if (document.location.search.indexOf('?atx=') < 0 && document.location.search.indexOf('&' + 'atx=') < 0) {
					document.location = document.location + "&' + 'atx=1024";
				}
				else {
					document.location = document.location.toString().replace(/atx=800/, 'atx=1024');
				}
			}
		}
	}

	autoSize();

}

function PaintControls() {

	var strBtnPattern = 'actions/btn';
	if (typeof(strLangId) != "undefined") {
		strBtnPattern = 'actions/' + strLangId + '/btn';
	}
	try {
		var objButton = document.getElementsByTagName('img');
		if (objButton.length <= 1) {
		}
		else {
			for (var i = 0; i < objButton.length; i++) {
				if (objButton[i].src.indexOf(strBtnPattern) >= 0) {
					objButton[i].onmouseover = function () { atx_OnButton(this) };
					objButton[i].onmouseout = function () { atx_OffButton(this) };
				}
			}
		}
	}
	catch (e) {}

	try {
		var objButton = document.getElementsByTagName('input');
		if (objButton.length <= 1) {
		}
		else {
			for (var i = 0; i < objButton.length; i++) {
				if (objButton[i].src) {
					if (objButton[i].src.indexOf(strBtnPattern) >= 0) {
						objButton[i].onmouseover = function () { atx_OnButton(this) };
						objButton[i].onmouseout = function () { atx_OffButton(this) };
					}
				}
			}
		}
	}
	catch (e) {}
}

function autoSize() {
	var obj = document.getElementById('Content-Left-Content');
	if (obj != null) {
		if (obj.scrollHeight < 310) {
			obj.style.height = '310px';
		}
	}
}

/* ================================================= */

function RelativeMoveMovingDiv() {
    try {
        var MovingDivToMove1 = document.getElementById('MovingBoxMenu');
        var MovingDivToMove2 = document.getElementById('ContentRight');
        var Distance = Math.ceil(Math.abs(CurrentMovingDivTop - MovingDivTop) / 2);
        var IsIE = navigator.appName.indexOf('Microsoft') >= 0;
        if (CurrentMovingDivTop < MovingDivTop) {
            CurrentMovingDivTop = Math.min(MovingDivTop, CurrentMovingDivTop + Distance);
            if (IsIE) MovingDivToMove1.style.top = CurrentMovingDivTop + 'px';
            MovingDivToMove2.style.top = CurrentMovingDivTop + 'px';
        }
        else if (CurrentMovingDivTop > MovingDivTop) {
            CurrentMovingDivTop = Math.max(MovingDivTop, CurrentMovingDivTop - Distance);
            if (IsIE) MovingDivToMove1.style.top = CurrentMovingDivTop + 'px';
            MovingDivToMove2.style.top = CurrentMovingDivTop + 'px';
        }

        if (CurrentMovingDivTop != MovingDivTop) {
            MovingDivIsMoving = setTimeout('RelativeMoveMovingDiv();', 10);
        }
        else {
            MovingDivIsMoving = null;
        }

    } catch (e) {alert(e.message);}
}

function AbsoluteMoveMovingDiv() {
    try {
        var MovingDivToMove1 = document.getElementById('MovingBoxMenu');
        var MovingDivToMove2 = document.getElementById('PositionedRight');
        var Distance = Math.ceil(Math.abs(CurrentMovingDivTop - MovingDivTop) / 2);
        var IsIE = navigator.appName.indexOf('Microsoft') >= 0;
        if (CurrentMovingDivTop < MovingDivTop) {
            CurrentMovingDivTop = Math.min(MovingDivTop, CurrentMovingDivTop + Distance);
            if (IsIE) MovingDivToMove1.style.top = CurrentMovingDivTop + 'px';
            MovingDivToMove2.style.top = (220 + CurrentMovingDivTop) + 'px';
        }
        else if (CurrentMovingDivTop > MovingDivTop) {
            CurrentMovingDivTop = Math.max(MovingDivTop, CurrentMovingDivTop - Distance);
            if (IsIE) MovingDivToMove1.style.top = CurrentMovingDivTop + 'px';
            MovingDivToMove2.style.top = (220 + CurrentMovingDivTop) + 'px';
        }

        if (CurrentMovingDivTop != MovingDivTop) {
            MovingDivIsMoving = setTimeout('AbsoluteMoveMovingDiv();', 10);
        }
        else {
            MovingDivIsMoving = null;
        }

    } catch (e) {alert(e.message);}
}

/* ================================================= */

function atx_OnButton(objButton) {
    try {
        if (objButton.src != null && objButton.src != '') {
            objButton.previousSrc = objButton.src;
            objButton.src = objButton.src.replace('-off.', '-on.');
        }
    }
    catch (e) { }
}

function atx_OffButton(objButton) {
    try {
        if (typeof (objButton.previousSrc) != 'undefined') {
            objButton.src = objButton.previousSrc;
        }
        else {
            objButton.src = objButton.src.replace('-on.', '-off.');
        }
    }
    catch (e) { }
}

function atx_LinkOver(strStatusText) {
    window.status = strStatusText;
    return (navigator.appName != 'Opera');
}

function atx_LinkOut(strStatusText) {
    window.status = strStatusText;
}

/* ================================================= */
// Ajax behaviors 
/* ================================================= */

function OnResponseStart() {
    DisableControls();
}

function OnResponseEnd() {
    EnableControls();
    PaintControls();
    correctPNG(null);
    autoSize();
}

function DisableControls() {
    for (var i = 0; i < document.forms[0].elements.length; i++) {
        var obj = document.forms[0].elements[i];
        obj.WasDisabled = obj.disabled;
        obj.disabled = true;
    }
}
function EnableControls() {
    for (var i = 0; i < document.forms[0].elements.length; i++) {
        var obj = document.forms[0].elements[i];
        if (obj.WasDisabled == false) {
            obj.disabled = false;
        }
    }
}

function openRadWindow(WindowUrl, Width, Height, Name) {
    var oWnd = radopen(WindowUrl, Name);
    oWnd.setSize(Width, Height);
    oWnd.center();
}

function getRadWindow() {
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

function printRadWindow() {
    var oWnd = getRadWindow();
    oWnd.GetContentFrame().contentWindow.print();
}

var CurrentLatField = null;
var CurrentLonField = null;
var MapUrl = null;
function openCoordinatesMap(url, LatId, LonId) {
    CurrentLatField = document.getElementById(LatId);
    CurrentLatField.PreviousValue = CurrentLatField.value;
    CurrentLonField = document.getElementById(LonId);
    CurrentLonField.PreviousValue = CurrentLonField.value;
    MapUrl = url;
    checkAddress();
}

function openMapWindow() {
    var url = MapUrl + '?x=' + CurrentLatField.value + '&y=' + CurrentLonField.value;
    openRadWindow(url, 900, 600);
}

function CallBackCoordinates(radWindow) {
    if (radWindow.argument != null) {
        var radWindowName = radWindow.get_name();
        CurrentLatField.value = radWindow.argument.Latitude;
        CurrentLonField.value = radWindow.argument.Longitude;
    }
    else {
        alert(toolNameVersion + '\n\n'
	    + 'L\'action a été ignorée car\naucune coordonnée n\' a été indiquée ni modifiée...');
    }
}

/* ================================================= */

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;
}

/* ================================================= */

function correctPNG(WebRoot) {
	if (WebRoot != null) {
	 CachedWebRoot = WebRoot;
	}
	if (CachedWebRoot != null) {
		 is = document.getElementsByTagName('IMG');
		 for(x=0; x<is.length; x++){
		 if(is[x].src.toLowerCase().indexOf('.png')>=0){
		 is[x].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+is[x].src+"', sizingMethod='scale')";
		 is[x].src = CachedWebRoot+'images/_protected/spacer.gif';
		 }
		 }
		 is = document.getElementsByTagName('INPUT');
		 for(x=0; x<is.length; x++){
		 if(is[x].src.toLowerCase().indexOf('.png')>=0){
		 is[x].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+is[x].src+"', sizingMethod='scale')";
		 is[x].src = CachedWebRoot+'images/_protected/spacer.gif';
		 }
		 }
	 }
}
