﻿/*
Copyright (c) 2006 - 2009 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.


2006 - 2009 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 CachedWebRoot = null;

var MovingDivTop = 0;
var MovingDivIsMoving = null;
var CurrentMovingDivTop = 0;

window.onscroll= function() {
    try {
		MovingDivTop = (document.all) ? document.documentElement.scrollTop : window.pageYOffset;
		MovingDivTop = Math.max(0, MovingDivTop - 10 -111 - 2 * 20);
		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';
    }

    var objButton = null;
    try {
        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 {
        objButton = document.getElementsByTagName('input');
        if (objButton.length <= 1) {
        }
        else {
            for (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 objHeight = 0;
    var obj1 = document.getElementById('ContentLeft');
    if (obj1 != null) {
        objHeight = Math.max(objHeight, obj1.scrollHeight-155);
    }
    var obj2 = document.getElementById('ContentRight');
    if (obj2 != null) {
        objHeight = Math.max(objHeight, obj2.scrollHeight);
    }

    objHeight = objHeight.toString() + 'px';
    if (obj1 != null) {
        obj1.style.height = objHeight;
    }
    if (obj2 != null) {
        obj2.style.height = objHeight;
    }
}

/* ================================================= */

function RelativeMoveMovingDiv() {
    try {
        var MovingDivToMove1 = document.getElementById('MovingBoxMenu');
        var MovingDivToMove2 = document.getElementById('MovingBoxMenu');
        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;
}

function ValidateContactForm(oSrc, args) {

    args.IsValid = false;

    if (args.Value != '') {

        var value = args.Value.toLowerCase();
        if (value.indexOf('href') >= 0) {
            document.location = '/';
            return;
        }

        if (value.indexOf('http') >= 0) {
            document.location = '/';
            return;
        }

        if (value.indexOf('https') >= 0) {
            document.location = '/';
            return;
        }

        var pattern1 = /<(\s|\t|\0\n\f\r\v)*a/igm;
        if (pattern1.test(value) == true) {
            document.location = '/';
            return;
        }

        var pattern2 = /<(\s|\t|\0\n\f\r\v)*\/(\s|\t|\0\n\f\r\v)*a(\s|\t|\0\n\f\r\v)*>/igm;
        if (pattern2.test(value) == true) {
            document.location = '/';
            return;
        }
    }

    args.IsValid = true;
}

/* ================================================= */

function ShowListePays(ListeId) {
	try {
		var MyListe = document.getElementById(ListeId);
		//MyListe.style.visibility = 'visible';
		MyListe.className = 'ListePays';
	}
	catch (e) {
	}
}

function HideListePays(ListeId) {
	try {
		var MyListe = document.getElementById(ListeId);
		MyListe.className = 'Introduction';
	}
	catch (e) {
	}
}

function ShowListeGammes(ListeId) {
	try {
		var MyListe = document.getElementById(ListeId);
		//MyListe.style.visibility = 'visible';
		MyListe.className = 'ListeGammes';
	}
	catch (e) {
	}
}

function HideListeGammes(ListeId) {
	try {
		var MyListe = document.getElementById(ListeId);
		MyListe.className = 'Introduction';
	}
	catch (e) {
	}
}

/* ================================================= */
// 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 {
        CurrentLatField.value = CurrentLatField.PreviousValue;
        CurrentLonField.value = CurrentLonField.PreviousValue;
        alert(toolNameVersion + '\n\n'
	    + 'L\'action a été ignorée car\naucune coordonnée n\' a été indiquée...');
    }
}

/* ================================================= */
//
// Smooth Scroller Script, version 1.0.1
// (c) 2007 Dezinerfolio Inc.
// Correc. bug if l.onclick is already defined!
/* ================================================= */

Scroller = {
    // control the speed of the scroller.
    // dont change it here directly, please use Scroller.speed=50;
    speed: 10,

    // returns the Y position of the div
    gy: function(d) {
        gy = d.offsetTop
        if (d.offsetParent) while (d == d.offsetParent) gy += d.offsetTop
        return gy
    },

    // returns the current scroll position
    scrollTop: function() {
        body = document.body
        d = document.documentElement
        if (body && body.scrollTop) return body.scrollTop
        if (d && d.scrollTop) return d.scrollTop
        if (window.pageYOffset) return window.pageYOffset
        return 0
    },

    // attach an event for an element
    // (element, type, function)
    add: function(event, body, d) {
        if (event.addEventListener) return event.addEventListener(body, d, false)
        if (event.attachEvent) return event.attachEvent('on' + body, d)
    },

    // kill an event of an element
    end: function(e) {
        if (window.event) {
            window.event.cancelBubble = true
            window.event.returnValue = false
            return;
        }
        if (e.preventDefault && e.stopPropagation) {
            e.preventDefault()
            e.stopPropagation()
        }
    },

    // move the scroll bar to the particular div.
    scroll: function(d) {
        i = window.innerHeight || document.documentElement.clientHeight;
        h = document.body.scrollHeight;
        a = Scroller.scrollTop()
        if (d > a)
            if (h - d > i)
            a += Math.ceil((d - a) / Scroller.speed)
        else
            a += Math.ceil((d - a - (h - d)) / Scroller.speed)
        else
            a = a + (d - a) / Scroller.speed;
        window.scrollTo(0, a)
        if (a == d || Scroller.offsetTop == a) clearInterval(Scroller.interval)
        Scroller.offsetTop = a
    },
    // initializer that adds the renderer to the onload function of the window
    init: function() {
        Scroller.add(window, 'load', Scroller.render)
    },

    // this method extracts all the anchors and validates then as # and attaches the events.
    render: function() {
        a = document.getElementsByTagName('a');
        Scroller.end(this);
        window.onscroll
        for (i = 0; i < a.length; i++) {
            l = a[i];
            if (l.href && l.href.indexOf('#') != -1 && ((l.pathname == location.pathname) || ('/' + l.pathname == location.pathname))) {
                Scroller.add(l, 'click', Scroller.end);
                if (l.onclick == null) {
                    l.onclick = function() {
                        Scroller.end(this);
                        l = this.hash.substr(1);
                        a = document.getElementsByTagName('a');
                        for (i = 0; i < a.length; i++) {
                            if (a[i].name == l) {
                                clearInterval(Scroller.interval);
                                Scroller.interval = setInterval('Scroller.scroll(' + Scroller.gy(a[i]) + ')', 10);
                            }
                        }
                    }
                }
            }
        }
    }
}
// invoke the initializer of the scroller
//$$$ RadDatePicker
//Scroller.init();

/* ================================================= */

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';
		 }
		 }
	 }
}

