//
// echo "王 ";
//
// included: doc.js, docymd.js, gglike.js, prodfile.js, marquee.js,
// ajax.js, floatdiv.js, bsniffer.js, chrono.js, datetime.js,
// keydown.js, mojozoom.js, imgswap.js, tooltip.js, popup.js, inet.js,
// html.js, form.js, wridewin.js, siret.js, clipboard.js:
//
// source: http://sajjadhossain.com/2008/10/31
//   /javascript-string-trimming-and-padding/
//
//pads left
String.prototype.lpad = function(padString, length) {
	var str = this;
    while (str.length < length)
        str = padString + str;
    return str;
}
 
//pads right
String.prototype.rpad = function(padString, length) {
	var str = this;
    while (str.length < length)
        str = str + padString;
    return str;
}

// Removes leading whitespaces
function LTrim(value)
{
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim(value)
{
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim(value)
{
	return LTrim(RTrim(value));
}

/*
 * phpjs.org:
 */
function dechex (number) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philippe Baumann
    // +   bugfixed by: Onno Marsman
    // +   improved by: http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript
    // +   input by: pilus
    // *     example 1: dechex(10);
    // *     returns 1: 'a'
    // *     example 2: dechex(47);
    // *     returns 2: '2f'
    // *     example 3: dechex(-1415723993);
    // *     returns 3: 'ab9dc427'
    if (number < 0) {
        number = 0xFFFFFFFF + number + 1;
    }
    return parseInt(number, 10).toString(16);
}
function hexdec (hex_string) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philippe Baumann
    // *     example 1: hexdec('that');
    // *     returns 1: 10
    // *     example 2: hexdec('a0');
    // *     returns 2: 160
    hex_string = (hex_string + '').replace(/[^a-f0-9]/gi, '');
    return parseInt(hex_string, 16);
}
function chr(codePt) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // *     example 1: chr(75);
    // *     returns 1: 'K'
    // *     example 1: chr(65536) === '\uD800\uDC00';
    // *     returns 1: true
    if (codePt > 0xFFFF) { // Create a four-byte string (length 2) since this code point is high
        //   enough for the UTF-16 encoding (JavaScript internal use), to
        //   require representation with two surrogates (reserved non-characters
        //   used for building other characters; the first is "high" and the next "low")
        codePt -= 0x10000;
        return String.fromCharCode(0xD800 + (codePt >> 10), 0xDC00 + (codePt & 0x3FF));
    }
    return String.fromCharCode(codePt);
}
function ord(strIn) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: Brett Zamir (http://brett-zamir.me)
    // +   input by: incidence
    // *     example 1: ord('K');
    // *     returns 1: 75
    // *     example 2: ord('\uD800\uDC00'); // surrogate pair to create a single Unicode character
    // *     returns 2: 65536
    var str = strIn + '',
        code = str.charCodeAt(0);
    if (0xD800 <= code && code <= 0xDBFF) { // High surrogate (could change last hex to 0xDB7F to treat high private surrogates as single characters)
        var hi = code;
        if (str.length === 1) {
            return code; // This is just a high surrogate with no following low surrogate, so we return its value;
            // we could also throw an error as it is not a complete character, but someone may want to know
        }
        var low = str.charCodeAt(1);
        return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
    }
    if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
        return code; // This is just a low surrogate with no preceding high surrogate, so we return its value;
        // we could also throw an error as it is not a complete character, but someone may want to know
    }
    return code;
}
	
function utf8_encode (argString) {
    // Encodes an ISO-8859-1 string to UTF-8  
    // 
    // version: 1109.2015
    // discuss at: http://phpjs.org/functions/utf8_encode
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: sowberry
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +   improved by: Yves Sucaet
    // +   bugfixed by: Onno Marsman
    // +   bugfixed by: Ulrich
    // +   bugfixed by: Rafal Kukawski
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
    if (argString === null || typeof argString === "undefined") {
        return "";
    }
 
    var strIn = (argString + ''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
    var utftext = "",
        start, end, stringl = 0;
 
    start = end = 0;
    stringl = strIn.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = strIn.charCodeAt(n);
        var enc = null;
 
        if (c1 < 128) {
            end++;
        } else if (c1 > 127 && c1 < 2048) {
            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc !== null) {
            if (end > start) {
                utftext += strIn.slice(start, end);
            }
            utftext += enc;
            start = end = n + 1;
        }
    }
 
    if (end > start) {
        utftext += strIn.slice(start, stringl);
    }
 
    return utftext;
}
function utf8_decode (str_data) {
    // http://kevin.vanzonneveld.net
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +      input by: Aman Gupta
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Norman "zEh" Fuchs
    // +   bugfixed by: hitwork
    // +   bugfixed by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: utf8_decode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'
    var tmp_arr = [],
        i = 0,
        ac = 0,
        c1 = 0,
        c2 = 0,
        c3 = 0;

    str_data += '';

    while (i < str_data.length) {
        c1 = str_data.charCodeAt(i);
        if (c1 < 128) {
            tmp_arr[ac++] = String.fromCharCode(c1);
            i++;
        } else if (c1 > 191 && c1 < 224) {
            c2 = str_data.charCodeAt(i + 1);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i + 1);
            c3 = str_data.charCodeAt(i + 2);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    }

    return tmp_arr.join('');
}
function base64_encode (data) {
    // http://kevin.vanzonneveld.net
    // +   original by: Tyler Akins (http://rumkin.com)
    // +   improved by: Bayron Guevara
    // +   improved by: Thunder.m
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Pellentesque Malesuada
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Rafał Kukawski (http://kukawski.pl)
    // -    depends on: utf8_encode
    // *     example 1: base64_encode('Kevin van Zonneveld');
    // *     returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
    // mozilla has this native
    // - but breaks in 2.0.0.12!
    //if (typeof this.window['atob'] == 'function') {
    //    return atob(data);
    //}
    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
        ac = 0,
        enc = "",
        tmp_arr = [];

    if (!data) {
        return data;
    }

    data = utf8_encode(data + '');

    do { // pack three octets into four hexets
        o1 = data.charCodeAt(i++);
        o2 = data.charCodeAt(i++);
        o3 = data.charCodeAt(i++);

        bits = o1 << 16 | o2 << 8 | o3;

        h1 = bits >> 18 & 0x3f;
        h2 = bits >> 12 & 0x3f;
        h3 = bits >> 6 & 0x3f;
        h4 = bits & 0x3f;

        // use hexets to index into b64, and append result to encoded string
        tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
    } while (i < data.length);

    enc = tmp_arr.join('');
    
    var r = data.length % 3;
    
    return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);

}
function base64_decode (data) {
    // http://kevin.vanzonneveld.net
    // +   original by: Tyler Akins (http://rumkin.com)
    // +   improved by: Thunder.m
    // +      input by: Aman Gupta
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   bugfixed by: Pellentesque Malesuada
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: utf8_decode
    // *     example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
    // *     returns 1: 'Kevin van Zonneveld'
    // mozilla has this native
    // - but breaks in 2.0.0.12!
    //if (typeof this.window['btoa'] == 'function') {
    //    return btoa(data);
    //}
    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
        ac = 0,
        dec = "",
        tmp_arr = [];

    if (!data) {
        return data;
    }

    data += '';

    do { // unpack four hexets into three octets using index points in b64
        h1 = b64.indexOf(data.charAt(i++));
        h2 = b64.indexOf(data.charAt(i++));
        h3 = b64.indexOf(data.charAt(i++));
        h4 = b64.indexOf(data.charAt(i++));

        bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;

        o1 = bits >> 16 & 0xff;
        o2 = bits >> 8 & 0xff;
        o3 = bits & 0xff;

        if (h3 == 64) {
            tmp_arr[ac++] = String.fromCharCode(o1);
        } else if (h4 == 64) {
            tmp_arr[ac++] = String.fromCharCode(o1, o2);
        } else {
            tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
        }
    } while (i < data.length);

    dec = tmp_arr.join('');
    dec = this.utf8_decode(dec);

    return dec;
}
function md5(strIn) {
    // http://kevin.vanzonneveld.net
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // + namespaced by: Michael White (http://getsprink.com)
    // +    tweaked by: Jack
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: utf8_encode
    // *     example 1: md5('Kevin van Zonneveld');
    // *     returns 1: '6e658d4bfcb59cc13f96c14450ac40b9'
    var xl;

    var rotateLeft = function (lValue, iShiftBits) {
        return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
    };

    var addUnsigned = function (lX, lY) {
        var lX4, lY4, lX8, lY8, lResult;
        lX8 = (lX & 0x80000000);
        lY8 = (lY & 0x80000000);
        lX4 = (lX & 0x40000000);
        lY4 = (lY & 0x40000000);
        lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
        if (lX4 & lY4) {
            return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
        }
        if (lX4 | lY4) {
            if (lResult & 0x40000000) {
                return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
            } else {
                return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
            }
        } else {
            return (lResult ^ lX8 ^ lY8);
        }
    };

    var _F = function (x, y, z) {
        return (x & y) | ((~x) & z);
    };
    var _G = function (x, y, z) {
        return (x & z) | (y & (~z));
    };
    var _H = function (x, y, z) {
        return (x ^ y ^ z);
    };
    var _I = function (x, y, z) {
        return (y ^ (x | (~z)));
    };

    var _FF = function (a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(_F(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
    };

    var _GG = function (a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(_G(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
    };

    var _HH = function (a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(_H(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
    };

    var _II = function (a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(_I(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
    };

    var convertToWordArray = function (strIn) {
        var lWordCount;
        var lMessageLength = strIn.length;
        var lNumberOfWords_temp1 = lMessageLength + 8;
        var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64;
        var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
        var lWordArray = new Array(lNumberOfWords - 1);
        var lBytePosition = 0;
        var lByteCount = 0;
        while (lByteCount < lMessageLength) {
            lWordCount = (lByteCount - (lByteCount % 4)) / 4;
            lBytePosition = (lByteCount % 4) * 8;
            lWordArray[lWordCount] = (lWordArray[lWordCount] | (strIn.charCodeAt(lByteCount) << lBytePosition));
            lByteCount++;
        }
        lWordCount = (lByteCount - (lByteCount % 4)) / 4;
        lBytePosition = (lByteCount % 4) * 8;
        lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
        lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
        lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
        return lWordArray;
    };

    var wordToHex = function (lValue) {
        var wordToHexValue = "",
            wordToHexValue_temp = "",
            lByte, lCount;
        for (lCount = 0; lCount <= 3; lCount++) {
            lByte = (lValue >>> (lCount * 8)) & 255;
            wordToHexValue_temp = "0" + lByte.toString(16);
            wordToHexValue = wordToHexValue + wordToHexValue_temp.substr(wordToHexValue_temp.length - 2, 2);
        }
        return wordToHexValue;
    };

    var x = [],
        k, AA, BB, CC, DD, a, b, c, d, S11 = 7,
        S12 = 12,
        S13 = 17,
        S14 = 22,
        S21 = 5,
        S22 = 9,
        S23 = 14,
        S24 = 20,
        S31 = 4,
        S32 = 11,
        S33 = 16,
        S34 = 23,
        S41 = 6,
        S42 = 10,
        S43 = 15,
        S44 = 21;

    strIn = utf8_encode(strIn);
    x = convertToWordArray(strIn);
    a = 0x67452301;
    b = 0xEFCDAB89;
    c = 0x98BADCFE;
    d = 0x10325476;

    xl = x.length;
    for (k = 0; k < xl; k += 16) {
        AA = a;
        BB = b;
        CC = c;
        DD = d;
        a = _FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
        d = _FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
        c = _FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
        b = _FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
        a = _FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
        d = _FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
        c = _FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
        b = _FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
        a = _FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
        d = _FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
        c = _FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
        b = _FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
        a = _FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
        d = _FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
        c = _FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
        b = _FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
        a = _GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
        d = _GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
        c = _GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
        b = _GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
        a = _GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
        d = _GG(d, a, b, c, x[k + 10], S22, 0x2441453);
        c = _GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
        b = _GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
        a = _GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
        d = _GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
        c = _GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
        b = _GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
        a = _GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
        d = _GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
        c = _GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
        b = _GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
        a = _HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
        d = _HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
        c = _HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
        b = _HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
        a = _HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
        d = _HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
        c = _HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
        b = _HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
        a = _HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
        d = _HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
        c = _HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
        b = _HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
        a = _HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
        d = _HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
        c = _HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
        b = _HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
        a = _II(a, b, c, d, x[k + 0], S41, 0xF4292244);
        d = _II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
        c = _II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
        b = _II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
        a = _II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
        d = _II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
        c = _II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
        b = _II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
        a = _II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
        d = _II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
        c = _II(c, d, a, b, x[k + 6], S43, 0xA3014314);
        b = _II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
        a = _II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
        d = _II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
        c = _II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
        b = _II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
        a = addUnsigned(a, AA);
        b = addUnsigned(b, BB);
        c = addUnsigned(c, CC);
        d = addUnsigned(d, DD);
    }

    var temp = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);

    return temp.toLowerCase();
}

//
// fnc001: generate a random password withing the valid characters set:
//
function secGeneratePassword4()
{ 
  var salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
  //srand((double)microtime()*1000000);  
  var i = 0, pass = "", lng = salt.length, tmp;
  // change for other length
  while (i < 4)
  {
    num = Math.floor(Math.random() * lng);
    tmp = salt.substr(num, 1); 
    pass += tmp; 
    i++;
  } 
//
  return pass;
}

//
// fnc001: encode password:
//
function secDoPasswordBase64Encode(strPassword, strSalt)
{
	var i, strSaltMd5, letter, lPassword, neword, newstr;
  strSaltMd5 = md5(strSalt);
  letter = -1;
  lPassword = strPassword.length;
  newstr = "";
//var strret = "";
  for(i = 0; i < lPassword; i++)
  {
    letter++;
    if (letter > 31)
    {
      letter = 0;
    }
    neword = ord(strPassword.charAt(i)) + ord(strSaltMd5.charAt(letter));
    //
    // 256 will cause unicode, so limit to ASCII 128:
    //
    if ( neword > 127 )
    {
      neword %= 128;
    }
    newstr += chr(neword);
//  newstr += String.fromCharCode(neword);
//alert("neword=" + ord(chr(neword)));
//strret += neword + " + ";
  }
//alert("newstr=" + newstr);
//document.getElementById("log").innerHTML = strret + " newstr=" + newstr;
  return base64_encode(newstr);
}

function mthGetMin3(a,b,c) { return (a<b)?((a<c)?a:c):((b<c)?b:c); }
function mthGetMax3(a,b,c) { return (a>b)?((a>c)?a:c):((b>c)?b:c); }

// http://design.geckotribe.com/colorwheel/
function RGB2HSV(rgb) {
    hsv = new Object();
    xmax=mthGetMax3(rgb.r,rgb.g,rgb.b);
    dif=xmax-mthGetMin3(rgb.r,rgb.g,rgb.b);
    hsv.saturation=(xmax==0.0)?0:(100*dif/xmax);
    if (hsv.saturation==0) hsv.hue=0;
    else if (rgb.r==xmax) hsv.hue=60.0*(rgb.g-rgb.b)/dif;
    else if (rgb.g==xmax) hsv.hue=120.0+60.0*(rgb.b-rgb.r)/dif;
    else if (rgb.b==xmax) hsv.hue=240.0+60.0*(rgb.r-rgb.g)/dif;
    if (hsv.hue<0.0) hsv.hue+=360.0;
    hsv.value=Math.round(xmax*100/255);
    hsv.hue=Math.round(hsv.hue);
    hsv.saturation=Math.round(hsv.saturation);
    return hsv;
}
// RGB2HSV and HSV2RGB are based on Color Match Remix [http://color.twysted.net/]
// which is based on or copied from ColorMatch 5K [http://colormatch.dk/]
function HSV2RGB(hsv) {
    var rgb=new Object();
    if (hsv.saturation==0) {
        rgb.r=rgb.g=rgb.b=Math.round(hsv.value*2.55);
    } else {
        hsv.hue/=60;
        hsv.saturation/=100;
        hsv.value/=100;
        i=Math.floor(hsv.hue);
        f=hsv.hue-i;
        p=hsv.value*(1-hsv.saturation);
        q=hsv.value*(1-hsv.saturation*f);
        t=hsv.value*(1-hsv.saturation*(1-f));
        switch(i) {
        case 0: rgb.r=hsv.value; rgb.g=t; rgb.b=p; break;
        case 1: rgb.r=q; rgb.g=hsv.value; rgb.b=p; break;
        case 2: rgb.r=p; rgb.g=hsv.value; rgb.b=t; break;
        case 3: rgb.r=p; rgb.g=q; rgb.b=hsv.value; break;
        case 4: rgb.r=t; rgb.g=p; rgb.b=hsv.value; break;
        default: rgb.r=hsv.value; rgb.g=p; rgb.b=q;
        }
        rgb.r=Math.round(rgb.r*255);
        rgb.g=Math.round(rgb.g*255);
        rgb.b=Math.round(rgb.b*255);
    }
    return rgb;
}
function HueShift(h,s) {
  h+=s;
  while (h>=360.0) h-=360.0;
  while (h<0.0) h+=360.0;
  return h;
}
 
function rgbGetRgbByRgb3(red, green, blue)
{
  var i, lng, decColor = 65536 * red + 256 * green + blue;
  decColor = decColor.toString(16);
  lng = decColor.length;
  for(i = lng; i < 6; i++)
  {
  	decColor = "0" + decColor;
  }
  return decColor;
}
function rgbGetRgbHtmlByRgb3(red, green, blue)
{
  return "#" + rgbGetRgbByRgb3(red, green, blue);
}
function rgbGetRgbHtmlByRgb(objRgb)
{
  return rgbGetRgbHtmlByRgb3(objRgb.r, objRgb.g, objRgb.b);
}
function rgbGetRgbByHtml(strRgbHtml)
{
//strRgbHtml=#rrggbb:
  var strRgbHtmlNow, thisrgb;
  strRgbHtmlNow = strRgbHtml;
  if(strRgbHtmlNow.charAt(0) == '#')
  {
  	strRgbHtmlNow = strRgbHtmlNow.substr(1, strRgbHtmlNow.length - 1);
  }
  thisrgb = new Object();
	thisrgb.r = hexdec(strRgbHtmlNow.substr(0, 2));
	thisrgb.g = hexdec(strRgbHtmlNow.substr(2, 2));
	thisrgb.b = hexdec(strRgbHtmlNow.substr(4, 2));
  return thisrgb;
}
//
// fnc001: get element rgb text control:
//
function rgbGetComplementRgbHtml(strRgbHtml)
{
//strRgbHtml=#rrggbb:
  var thisrgb = rgbGetRgbByHtml(strRgbHtml);
  var temphsv = RGB2HSV(thisrgb);
  temphsv.hue = HueShift(temphsv.hue,180.0);
  temphsv = HSV2RGB(temphsv);
  return rgbGetRgbHtmlByRgb(temphsv);
}

//
// fnc001: encode password:
//   thisControl: clicked image or double-clicked password text object.
//
function secRenewPasswordImage(thisControl, strIDImage, strSalt)
{
	var i, strPass, frm, objImg;
	if(strIDImage)
	{
		if(thisControl.id == strIDImage)
		{
			// strIDImage = img+form id:
//alert(strIDImage);
      frm = domGetElementById(strIDImage.substr(3, strIDImage.length - 3));
		} 
		else
		{
      frm = thisControl.form;
    }
    if(frm)
    {
      objImg = domGetElementById(strIDImage);
      if(frm)
      {
        strPass = secGeneratePassword4();
        strPass = secDoPasswordBase64Encode(strPass, strSalt);
    	  objImg.src = nvlPrependStoreDir("grafit.php?crypt=1&text=" + strPass);
    	  frm.elements["password0"].value = strPass;
    	}
    }
  }
  return false;
}

function strisempty(strIn)
{
	if(strIn == null)
	{
		return true;
	}
	else if(strIn == "")
	{
		return true;
	}
	else
	{
		return false;
	}
}

// trim character of code >= 256:
function strTrimUtf8(strIn)
{
	var strret = "", ndel = 0, strdel = "";
	for(var i = 0; i < strIn.length; i++)
	{
		if(strIn.charCodeAt(i) < 256)
		{
      strret += strIn.charAt(i);
    }
    else
    {
    	strdel += strIn.charAt(i);
    	ndel += 1;
    }
	}
//
	if(locIsLangLocalFr())
	{
  	strdel = ndel + " caractères éliminés : '" + strdel + "'.";
  }
	else if(locIsLangLocalCn())
 	{
  	strdel = " 清除了" + ndel + "个非 ASCII 字符： '" + strdel + "'。";
 	}
 	else
 	{
  	strdel = ndel + " characters removed: '" + strdel + "'.";
 	}
  alert(strdel);
//
	return strret;
}

// character => &#77;&#88;:
function strGetHtmlString(strIn)
{
	var strret = "";
	for(var i = 0; i < strIn.length; i++)
	{
    strret += "&#" + strIn.charCodeAt(i).toString() + ";";
	}
	return strret;
}
// &#788; => character:
function strGetStringByHtml(strIn)
{
  var xarr = strIn.split(/&#/);
	var strret = "";
	for(var i = 0; i < xarr.length; i++)
	{
    if(xarr[i] != "")
    {
      strret += String.fromCharCode(parseInt(xarr[i]));
    }
	}
	return strret;
}
// \788 => &788;:
function strGetStringHtmlByHex(strIn)
{
  var xarr = strIn.split(/\\/);
	var strret = "";
	for(var i = 0; i < xarr.length; i++)
	{
    if(xarr[i] != "")
    {
      strret += "&#" + String.fromCharCode(parseInt(xarr[i], 16)) + ";";
    }
	}
	return strret;
}

// character => \77\88:
function strGetHexString(strIn)
{
	var strret = "";
	for(var i = 0; i < strIn.length; i++)
	{
    strret += "\\" + strIn.charCodeAt(i).toString(16);
	}
	return strret;
}
// character => \\77\\88:
function strGetHexString2(strIn)
{
	var strret = "";
	for(var i = 0; i < strIn.length; i++)
	{
    strret += "\\\\" + strIn.charCodeAt(i).toString(16);
	}
	return strret;
}
// \77\88 => character:
function strGetStringByHex(strIn)
{
  var xarr = strIn.split(/\\/);
	var strret = "";
	for(var i = 0; i < xarr.length; i++)
	{
    if(xarr[i] != "")
    {
      strret += String.fromCharCode(parseInt(xarr[i], 16));
    }
	}
	return strret;
}

function brwIsIE()
{
	if(navigator.userAgent.indexOf("MSIE") >= 0)
  {
    return true;
  }
  else
  {
    return false;
  }
}

//
// on HTML5 IE standard is used, so NS is false 22-JUN-2010:
// Firefox doest not meet until version 3.6.12:
// Google Chrome, Firefox: navigator.appName = Netscape.
//
function brwIsIso()
{
//
//var tooltipIsFF = (navigator.appName.indexOf("Netscape") >= 0);
//var tooltipIsFF = false;
//alert("navigator.userAgent=" + navigator.userAgent);
//
  return ((navigator.userAgent.indexOf("Firefox") >= 0)
    || (navigator.userAgent.indexOf("Safari") >= 0));
}

/*
* Source: http://www.webdeveloper.com/forum/archive/index.php/t-74982.html
** Returns the caret (cursor) position of the specified text field.
** Return value range is 0-oField.length.
*/
function doGetCaretPosition(oField) {

// Initialize
var iCaretPos = 0;

// IE Support
if (document.selection) { 

// Set focus on the element
oField.focus();

// To get cursor position, get empty selection range
var oSel = document.selection.createRange ();

// Move selection start to 0 position
oSel.moveStart ('character', -oField.value.length);

// The caret position is selection length
iCaretPos = oSel.text.length;
}

// Firefox support
else if (oField.selectionStart || oField.selectionStart == '0')
iCaretPos = oField.selectionStart;

// Return results
return (iCaretPos);
}


/*
** Sets the caret (cursor) position of the specified text field.
** Valid positions are 0-oField.length.
*/
function doSetCaretPosition(oField, iCaretPos) {

// IE Support
if (document.selection) { 

// Set focus on the element
oField.focus();

// Create empty selection range
var oSel = document.selection.createRange ();

// Move selection start and end to 0 position
oSel.moveStart ('character', -oField.value.length);

// Move selection start and end to desired position
oSel.moveStart ('character', iCaretPos);
oSel.moveEnd ('character', 0);
oSel.select ();
}

// Firefox support
else if (oField.selectionStart || oField.selectionStart == '0') {
oField.selectionStart = iCaretPos;
oField.selectionEnd = iCaretPos;
oField.focus();
}
}

//
// doc.js:
//
/*
function $(id)
{
	return document.getElementById(id);
}
*/
//
// fnc001: get ajax result div object:
//
function domGetElementById(strDiv)
{
//
  if(strDiv == "")
  {
  	return false;
  }
  else
  {
    return document.getElementById(strDiv);
  }
}

//
// fnc001: get element contents:
//
function domGetElementContentsByObject(xobj)
{
	if(xobj)
	{
  	if(xobj.tagName == "INPUT")
	  {
      return xobj.value;
    }
  	else if(xobj.tagName == "TEXTAREA")
	  {
      return xobj.value;
    }
    else
	  {
      return xobj.innerHTML;
    }
  }
  return null;
}
//
// fnc001: get element contents:
//
function domGetElementContentsById(strDiv)
{
  return domGetElementContentsByObject(domGetElementById(strDiv));
}
//
// fnc001: set element contents:
//
function domSetElementContentsByObject(xobj, varContents)
{
//alert("xobj=" + xobj);
	if(xobj)
	{
  	if(xobj.tagName == "INPUT")
	  {
      xobj.value = varContents;
    }
  	else if(xobj.tagName == "TEXTAREA")
	  {
      xobj.value = varContents;
    }
    else
	  {
      xobj.innerHTML = varContents;
    }
    return true;
  }
  return false;
}
//
// fnc001: set element contents:
//
function domSetElementContentsById(strDiv, varContents)
{
	return domSetElementContentsByObject(domGetElementById(strDiv),
	  varContents);
}

//
// hide object:
//
function domHideObject(xobj)
{
//
// nothing to do if no object:
//
  if(xobj == null)
  {
    return false;
  }
//
  else
	{
    xobj.style.display = "none";
    return true;
  }
}

//
// add event listener:
//   xobj: DOM object, window, document, element
//   strEvent: click, load,...
//   objFnc: function reference
//   blnUseCapture: capture/bubbling type, true, false
//
function domAddEventListener(xobj, strEvent, objFnc, blnUseCapture)
{
	// Moz:
  if (xobj.addEventListener)
  { 
    xobj.addEventListener(strEvent, objFnc, blnUseCapture);
    return true;
  }
  // IE:
  else if (xobj.attachEvent)
  { 
    xobj.attachEvent("on" + strEvent, objFnc); 
    return true;
  } 
  else
  { 
    return false;
  } 
}

//
// add event listener:
//   xobj: DOM object, window, document, element
//   strEvent: "click", "load",...
//   objFnc: function reference
//   blnUseCapture: capture/bubbling type, true, false
//
function domRemoveEventListener(xobj, strEvent, objFnc, blnUseCapture)
{
	// Moz:
  if (xobj.addEventListener)
  { 
    xobj.removeEventListener(strEvent, objFnc, blnUseCapture);
    return true;
  }
  // IE:
  else if (xobj.attachEvent)
 	{ 
    xobj.detachEvent("on" + strEvent, objFnc); 
    return true;
  } 
  else
  { 
    return false;
  } 
}

//
// toggle .onmouseout event handler:
//   xobj.onmouseout waits for a function reference:
//   xobj.onmouseout = fnc or
//   xobj.Attributes.Add("onmouseout", strAct);
//   xobj.setAttributes("onmouseout", strAct);
//
function domToggleHandlerMouseOut(xobj, strAct)
{
	if(! xobj.onmouseout )
	{
		// not work: xobj.onmouseout = strAct;
		//xobj.onmouseout = varFnc;
		xobj.setAttribute("onmouseout", strAct);
    return true;
	}
	else
	{
		xobj.onmouseout = null;
		return false;
	}
}

//
// docymd.js:
//
function domResetControlValue(el)
{
	el.oldvalue = el.value;
  el.value = "";
  return false;
}

function domToggleControlValue(el)
{
  if(el.oldvalue == undefined)
  {
  	if(el.value == "")
  	{
    	el.oldvalue = el.defaultValue;
    }
  	else
  	{
    	el.oldvalue = "";
    }
  }
//
//alert("domToggleControlValue(): el.oldvalue=" + el.oldvalue + ", el.value=" + el.value + ", el.defaultValue=" + el.defaultValue);
  if(el.oldvalue == el.value)
  {
   	el.value = "";
  }
  else
  {
   	var varOldValue = el.oldvalue;
   	el.oldvalue = el.value;
   	el.value = varOldValue;
   }
//
  return false;
}

function domAddSelectOptionOrdered(selectObj, strText, varValue, bIsSelected) 
{
  if (selectObj != null && selectObj.options != null)
  {
    var n = selectObj.options.length;
    if(varValue >= parseFloat(selectObj.options[n - 1].value))
    {
      selectObj.options[n] = new Option(strText, varValue, false, bIsSelected);
    }
    else
    {
    	var i, iSelected = 0;
      selectObj.options[n] = new Option("", null, false, false);
    	for(i = n; i > 0; i--)
    	{
        if((varValue >= parseFloat(selectObj.options[i - 1].value))
          && (varValue < parseFloat(selectObj.options[i].value)))
        {
          selectObj.options[i].value = varValue;
          selectObj.options[i].text = strText;
          selectObj.options[i].selected = bIsSelected;
          iSelected = i;
          break;
        }
        else
        {
          selectObj.options[i].value = selectObj.options[i - 1].value;
          selectObj.options[i].text = selectObj.options[i - 1].text;
        }
    	}
      if(iSelected == 0)
      {
      	i = iSelected;
        selectObj.options[i].value = varValue;
        selectObj.options[i].text = strText;
        selectObj.options[i].selected = bIsSelected;
      }
    }
  }
  return true;
}
function domAssureSelectOptionQuantity(selectObj, varValue) 
{
	var strText, bIsSelected;
  if (selectObj != null && selectObj.options != null)
  {
		selectObj.value = varValue;
		if(selectObj.value == "")
		{
  	  bIsSelected = true;
  	}
  	else
		{
  	  bIsSelected = (selectObj.value != varValue);
  	}
  	if(bIsSelected)
  	{
    	strText = varValue;
  	  domAddSelectOptionOrdered(selectObj, strText, varValue, bIsSelected);
  	}
  }
  return true;
}
function domIncrementSelectOptionQuantity(selectObj, varIncrement) 
{
  if (selectObj != null && selectObj.options != null)
  {
		var varValue = parseFloat(selectObj.value) + varIncrement;
    domAssureSelectOptionQuantity(selectObj, varValue) 
  }
  return true;
}

function prdSetQuantity(frm)
{
  frm.quantity.value = frm.quantity0.value;
  return 1;
}
function prdSetQuantity0(frm)
{
  domAssureSelectOptionQuantity(frm.quantity0, frm.quantity.value);
  return 1;
}
function prdSetMoreQuantity(frm)
{
	if(frm.quantity0)
	{
    frm.quantity.value++;
    prdSetQuantity0(frm);
  }
  else
  {
	  domIncrementSelectOptionQuantity(frm.quantity, 1);
	}
  return 1;
}
function prdSetLessQuantity(frm)
{
	if(frm.quantity0)
	{
    frm.quantity.value--;
    prdSetQuantity0(frm);
  }
  else
  {
	  domIncrementSelectOptionQuantity(frm.quantity, -1);
	}
  return 1;
}

function resetById(strID)
{
	var xobj;
	xobj = domGetElementById(strID);
  if(xobj)
  {
  	domToggleControlValue(xobj);
  	xobj.focus();
    return true;
  }
  return false;
}

function resetq()
{
	var xobj;
	xobj = domGetDefaultInput();
  if(xobj)
  {
  	domToggleControlValue(xobj);
  	xobj.focus();
    return true;
  }
  return false;
}

function clrTxt(form)
{
  form.year.value = "";
  form.delta.value = "";
  return 1;
}

function doThisYear(form)
{
  form.year.value = yrlong();
  form.delta.value = "";
  form.submit();
}

function doDefaultYear(form)
{
  form.year.value = yrlong();
  form.delta.value = "2";
  form.submit();
}

//
// get google form:
//
function domGetfrmgg()
{
  var frm;
  frm = domGetElementById("frmgg");
  if(! frm)
  {
    frm = domGetElementById("frmgg1");
  }
  return frm;
}

//
// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
//
function domGetRadioValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
//
// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
//
function domSetRadioValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function domGetkhasimage()
{
	var frm;
	frm = domGetfrmgg();
	if(frm)
	{
		if(frm.elements["khasimage"])
		{
			return parseInt(domGetRadioValue(frm.elements["khasimage"]));
		}
  }
  return false;
}

function imeGetq()
{
	var frm, elq;
	frm = domGetfrmgg();
	if(frm)
	{
		elq = frm.elements["q"];
  	if(! elq)
  	{
  	  elq = frm.elements["editarea"];
  	}
  }
  else
	{
  	elq = document.getElementById("q");
  	if(! elq)
  	{
  	  elq = document.getElementById("editarea");
  	}
  }
	return elq;
}
//
// fnc001: imeGetqValue:
//
function imeGetqValue()
{
	var xobj = imeGetq();
	if(xobj)
	{
    return xobj.value;
  }
  else
	{
    return "";
  }
}
//
// fnc001: imeSetqValue:
//
function imeSetqValue(strVal)
{
	var xobj = imeGetq();
	if(xobj)
	{
    xobj.value = strVal;
    return strVal;
  }
  else
	{
    return "";
  }
}
//
// fnc001: imeToggleqValueHex:
//
function imeToggleqValueHex()
{
	var xobj = imeGetq();
	if(xobj)
	{
    var lStat, strVal = xobj.value;
    if(strVal.charAt(0) == "\\")
    {
    	xobj.value = strGetStringByHex(strVal);
      lStat = -1;
    }
    else if(strVal.charAt(0) == "&")
    {
    	xobj.value = strGetStringByHtml(strVal);
      lStat = -1;
    }
    else
    {
    	xobj.value = strGetHexString(strVal);
      lStat = 1;
    }
    ggtDetectLanguageLocalGgBox();
  }
  else
	{
    lStat = 0;
  }
  return lStat;
}
//
// fnc001: imeToggleqValueHtml:
//
function imeToggleqValueHtml()
{
	var xobj = imeGetq();
	if(xobj)
	{
    var lStat, strVal = xobj.value;
    if(strVal.charAt(0) == "\\")
    {
    	xobj.value = strGetStringByHex(strVal);
      lStat = -1;
    }
    else if(strVal.charAt(0) == "&")
    {
    	xobj.value = strGetStringByHtml(strVal);
      lStat = -1;
    }
    else
    {
    	xobj.value = strGetHtmlString(strVal);
      lStat = 1;
    }
    ggtDetectLanguageLocalGgBox();
  }
  else
	{
    lStat = 0;
  }
  return lStat;
}
//
// fnc001: imeToggleqValueUtf8:
//
function imeToggleqValueUtf8()
{
	var xobj = imeGetq();
	if(xobj)
	{
    var lStat, strVal = xobj.value;
    if(strVal.charAt(0) == "\\")
    {
    	strVal = strGetStringByHex(strVal);
      lStat = -1;
    }
    else if(strVal.charAt(0) == "&")
    {
    	strVal = strGetStringByHtml(strVal);
      lStat = -1;
    }
    else
    {
    	strVal = xobj.value;
      lStat = 1;
    }
  	xobj.value = strTrimUtf8(strVal);
    ggtDetectLanguageLocalGgBox();
  }
  else
	{
    lStat = 0;
  }
  return lStat;
}

//
// set default Google AdSense search box:
//
function setFocusCseSearchBox()
{ 
  var x;
  x = document.getElementById("cse-search-box");
  if(x == null)
  {
    return false;
  }
  else
  {
    x.elements("q").focus();
    return true;
  }
}

//
// get master form:
//
function getMaster()
{
  return domGetElementById("master");
}

//
// get Ajax master form:
//
function getMasterAjax()
{
  return domGetElementById("masterajax");
}

//
// get form with q text input:
//
function getFormq0()
{
	var xobj;
	xobj = domGetElementById("q");
	if(xobj)
	{
		return xobj.form;
	}
	else
	{
    return null;
  }
}

//
// get google form:
//
function getForm0()
{
  return document.forms[0];
}

//
// get password form:
//
function getFormPassword()
{
  return document.getElementById("frmpassword");
}

//
// get form to set focus:
//
function getForm()
{
//
  var frm;
//
// check password:
//
  frm = getFormPassword();
//
// check first master:
//
  if(! frm)
  {
    frm = getMasterAjax();
//
//   check first master:
//
    if(! frm)
    {
      frm = getMaster();
//
//    check then Google Like search box:
//
      if(! frm)
      {
        frm = domGetfrmgg();
//
//      check then first form:
//
        if(! frm)
        {
        	frm = getFormq0();
          if(! frm)
          {
            frm = getForm0();
          }
        }
      }
    }
  }
//
//alert(frm.name + ": " + typeof(frm));
//
  return frm;
}

//
// get default input element:
//
function domGetDefaultInput()
{
//
  var frm;
//
  frm = getForm();
//
//alert(frm + ": " + typeof(frm));
//alert(frm.name + ": " + typeof(frm));
//
  if(frm)
  {
//
    var xarr = new Array("q", "query", "find",
      "surname", "username", "year",
      "store_user", "admin_user", "password",
      "gencod", "search");
    var i, n, xobj;
// 
    n = xarr.length;
    for (i = 0; i < n; i++)
    {
    	xobj = frm.elements[xarr[i]];
      if(xobj)
      {
      	if(typeof(xobj) == "array")
      	{
  		    var j, nsub, xSubObj;
  		    nsub = xobj.length;
          for (j = 0; j < nsub; j++)
          {
          	xSubObj = xobj[j];
        	  if(xSubObj.type != "hidden")
  	        {
              return xSubObj;
            }
      		}
      	}
    	  else if(xobj.type != "hidden")
  	    {
          return xobj;
        }
      }
    }
//
  }
//
// no form:
//
  return null;
}

//
// set default focus on YMD input document:
//
function domSetDefaultFocus()
{
//
  var xobj;
//
  xobj = domGetDefaultInput();
  if(xobj)
  {
    xobj.focus();
    return true;
  }
  else
	{
    return false;
  }
}

//
// set default date on YMD input document:
//
function setTodayDate()
{
  var datNow = new Date();
  if(document.master)
  {
//
    if(document.master.year)
    {
      document.master.year.value = datNow.getFullYear();
    }
//
    if(document.master.month)
    {
      document.master.month.value = datNow.getMonth() + 1;
    }
//
    if(document.master.day)
    {
      document.master.day.value = datNow.getDate();
    }
  }
}

//
// set query:
//
function setQuery(strQuery)
{
  if(document.master)
  {
//
    if(document.master.q)
    {
      document.master.q.value = strQuery;
    }
    else if(document.master.query)
    {
      document.master.query.value = strQuery;
    }
  }
}

//
// submit all quantity forms:
//
function frmSubmitAllQty(xobjbtn)
{
	var frms = document.getElementsByTagName("FORM");
	if(! frms)
	{
		return false;
	}
	var i, j, n, strDivResult, kMarquee, strID, regex;
  var strUrl0 = window.location.href, strUrl;
	if(strUrl0.indexOf("?") < 0)
	{
		strUrl0 += "?";
	}
  regex = new RegExp("^frmqty", "i");
  var strUrls2Submit = new Array();
	j = 0;
	for(i=0; i<frms.length; i++)
	{
  	strID = new String(frms[i].id);
		if(strID.match(regex))
		{
			//alert(strID);
			//frms[i].submit();
			// IE6 not work:
		  //strUrls2Submit[j] = strUrl0 + frms[i].serialize();
		  // IE6 OK: using prototype.js:
		  strUrls2Submit[j] = strUrl0 + Form.serialize(frms[i]);
			j++;
		}
	}
	n = strUrls2Submit.length;
	j = n - 1;
	for(i = 0; i < n; i++)
	{
	  //alert(strUrls2Submit[i]);
	  if(i == 0)
	  {
	  	strDivResult = "";
	  	kMarquee = true;
	  	//showDivPatience();
	  	launchDivPatienceMarquee();
	  }
	  else
	  {
	  	strDivResult = "";
	  	kMarquee = false;
	  }
	  if(i == j)
	  {  	
    	ajaxPost(strUrls2Submit[i], true, strDivResult, kMarquee, function() {
    		if(xobjbtn)
    		{
    			xobjbtn.form.submit();
    	  }
    	  else
    		{
    	    window.location.reload();
    	  }
    	  hideDivPatience();
    	});
	  }
	  else
	  {
    	ajaxPost(strUrls2Submit[i], true, strDivResult, kMarquee, null);
	  }
  }
	return n;
}

//
// set sample SamplebackgroundColor:
//
function setSamplebackgroundColor(rgb)
{
  document.getElementById("trnamequeryoptions").style.backgroundColor = rgb;
}

//
// set query:
//
function setNameDefault(frm)
{
//alert(frm.name);
  frm.ff.value = "fzktjw";
  frm.fsz.value = 18;
  frm.rgb.value = "";
  setSamplebackgroundColor(frm.rgb.value);
}

//
// fnc001: do mouse over:
//
function cidDoMouseOverPhoneCall(xobj)
{
  xobj.style.height = '100px';
  xobj.style.fontSize = '12pt';
  //xobj.style.backgroundColor = '#ffff00';
  //xobj.className = "shopsnapshot infobox33cc99";
  xobj.className = "infobox33cc99 shopsnapshot";
  // path from the user URL:
  //xobj.style.backgroundImage = 'url(images/banners/ah2topasiecom.gif)';
  document.body.style.backgroundColor = '#eeeeee';
  return true;
}
//
// fnc001: do mouse out:
//
function cidDoMouseOutPhoneCall(xobj)
{
  xobj.style.height = '';
  xobj.style.fontSize = '8pt';
  //xobj.style.backgroundColor = '';
  xobj.className = "";
  //xobj.style.backgroundImage = '';
  document.body.style.backgroundColor = '';
  return true;
}

//
// doc.js:
//
//
// fnc001: get document layer:
//
function getDocLayer(strName)
{
  var xobj;
  if(navigator.appName.indexOf("Netscape") != -1)
  {
    xobj = window.document.layers[strName];
  }
  else
  {
    xobj = window.document.all[strName];
  }
  return xobj;
}

//
// fnc001: reload myself:
//
function reloadme()
{
	window.location.reload();
	return false;
}

function gotoUrl(strUrl)
{
  window.location.href = strUrl;
  return false;
}

//
// gglike.js:
//
//
// fnc001: set action for Google search chance:
//
function ggSetActionSearchChance(frm)
{
  frm.action = document.location;
//
//alert(frm.action);
//
//frm.submit();
  return true;
}

//
// prodfile.js:
//
//
// popup a product file window using its representation URL:
//
function popupWinProductFile(strUrl)
{
  var win = window.open(strUrl, "winPopup", "width=400,height=430,directories=0,location=0,scrollbars=0,titlebar=0,toolbar=0,resizable=1,status=0");
  if(win != null)
  {
    win.focus();
  }
//
  return;
}

/*
 * popup a product file window using its representation URL:
 */
function pf(strUrl)
{
	popupWinProductFile(strUrl);
//
  return;
}

//
// marquee.js:
//
function setMarqueeStop(xobj)
{
  xobj.scrollAmount = 0;
  xobj.style.backgroundColor = 'yellow';
/*
  xobj.style.color = 'blue';
  xobj.style.backgroundColor = 'transparent';
  xobj.style.textDecoration = 'underline';
  xobj.style.cursor = 'hand';
 */
}

function setMarqueeSlide(xobj)
{
  xobj.scrollAmount = 1;
  xobj.style.backgroundColor = 'transparent';
/*
  xobj.style.color = 'red';
  xobj.style.backgroundColor = 'yellow';
  xobj.style.textDecoration = 'none';
  xobj.style.cursor = 'auto';
 */
}

//
// ajax.js:
//
//
// fnc001: get XML HTTP Request object:
//
 function getXhrObject() {
 	var xhr;
 	// Google Chrome, Firefox, IE9:
  if (window.XMLHttpRequest) { 
    //alert("window.XMLHttpRequest");
    xhr = new XMLHttpRequest();
  } 
 	// IE6 or lower:
  else if (window.ActiveXObject) {
    //alert("window.ActiveXObject");
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else {
  	xhr = false;
  }
//
  return xhr;
}

//
// fnc001: get XML HTTP Request object:
//
function xhrAbort()
{
	if(gobjttxhr)
	{
		//
    // abort if ajax is in action:
    //
		if(! ((gobjttxhr.readyState == 0) || (gobjttxhr.readyState == 4)))
		{
/*
      abort() error under IE under certain cases:
      this avoids .abort() error, 
      source:
        http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_a_1.html
      try {
			  gobjttxhr.abort();
			} catch (e) {
				0;
			}
 */
      gobjttxhr.onreadystatechange = function(){};
		  gobjttxhr.abort();
		}
  }
  return true;
}

//
// fnc001: get XML HTTP Request object:
//
function getXhrObjectGlobal()
{
	xhrAbort();
	if(! gobjttxhr)
	{
    gobjttxhr = getXhrObject();
//alert("getXhrObjectGlobal(): gobjttxhr=" + gobjttxhr);
  }
  return gobjttxhr;
}

//
// fnc001: show Div:
//
function showDiv(strDiv)
{
	var xobj;
	xobj = domGetElementById(strDiv);
	if(xobj == null)
	{
		return false;
	}
	xobj.style.display = "block";
  return true;
}
//
// fnc001: hide Div:
//
function hideDiv(strDiv)
{
	var xobj;
	xobj = domGetElementById(strDiv);
	if(xobj == null)
	{
		return false;
	}
  return domHideObject(xobj);
}

//
// fnc001: toggle Div associated image:
//
function toggleImageSrcPlusMinus(strIDImg)
{
  var strTitle, ximg, strImage;
//
	if(strIDImg == "")
	{
		return false;
	}
	//
	// image src can be either path + plus.gif or path + minus.gif:
	//
	ximg = domGetElementById(strIDImg);
	//
	if(ximg)
	{
		strImage = new String(ximg.src);
		if(strImage.indexOf("minus.gif") >= 0)
		{
      if(locIsLangLocalFr())
      {
        strTitle = "+ plus d'info";
      }
      else if(locIsLangLocalCn())
      {
        strTitle = "+ 更多信息";
      }
      else
      {
        strTitle = "+ more info";
      }
	    ximg.title = strTitle;
  	  ximg.src = strImage.replace("minus.gif", "plus.gif");
    }
		else
		{
      if(locIsLangLocalFr())
      {
        strTitle = "- moins d'info";
      }
      else if(locIsLangLocalCn())
      {
        strTitle = "- 少一些信息";
      }
      else
      {
        strTitle = "- less info";
      }
	    ximg.title = strTitle;
  	  ximg.src = strImage.replace("plus.gif", "minus.gif");
    }
  	return true;
  }
	return false;
}

//
// fnc001: toggle Div:
//
function toggleDivObject(xobj)
{
  var ximg, lstat, strImage, strTitle;
//
	if(xobj == null)
	{
		return 0;
	}
	// image path from /images/:
	if(xobj.style.display == "none")
	{
	  xobj.style.display = "";
    lstat = 1;
	}
	else
	{
	  domHideObject(xobj);
    lstat = -1;
	}
  toggleImageSrcPlusMinus("img" + xobj.id);
	return lstat;
}

//
// fnc001: set image IDs:
//
function setImageSrcIDsList(strIDsRegex, strImage, strTitle)
{
	var i, j, regex, str1, xobj, xobjs, xarr;
	var bSolid = (strTitle != "");
//
  xobjs = document.getElementsByTagName("img");
//alert("strIDsRegex=" + strIDsRegex + ", strImage="+strImage);
  str1 = new String(strIDsRegex);
  regex = new RegExp("[ ,;]+", "g");
  xarr = str1.split(regex);
  j = 0;
  for(i = 0; i < xarr.length; i++)
  {
    regex = new RegExp(xarr[i]);
    for(i=0; i<xobjs.length; i++)
    {
    	xobj = xobjs[i];
    	if(regex.test(xobj.id))
    	{
        xobj.src = strImage;
        if(bSolid)
        {
          xobj.title = strTitle;
        }
        j++;
      }
    }
  }
//alert(xobj);
  return j;
}

//
// fnc001: toggle Divs by className:
//
function toggleDivsByClassName(strClassName)
{
	var i, j, xobj, xobjs;
//
  xobjs = document.getElementsByClassName(strClassName);
  j = 0;
  for(i=0; i<xobjs.length; i++)
  {
  	xobj = xobjs[i];
    j += toggleDivObject(xobj);
  }
  return j;
}
//
// fnc001: toggle Divs by className:
//
function toggleDivsByClassNameMoreinfo()
{
  return toggleDivsByClassName("moreinfo");
}

//
// fnc001: toggle Divs list:
//
function toggleDivsList(strDivRegex)
{
	var i, j, regex, xobj, xobjs;
//
  xobjs = document.getElementsByTagName("div");
  regex = new RegExp(strDivRegex);
  j = 0;
  for(i=0; i<xobjs.length; i++)
  {
  	xobj = xobjs[i];
  	if(regex.test(xobj.id))
  	{
      j += toggleDivObject(xobj);
    }
  }
  return j;
}

//
// fnc001: toggle Div:
//
function toggleDiv(strDiv)
{
	var n, strDivImgRoot;
	if(strDiv.indexOf("*") >= 0)
	{
		n = toggleDivsList(strDiv);
    // strDiv like moreinfo*:
    strClassName = strDiv.replace("*", "");
    toggleImageSrcPlusMinus("img" + strClassName + "all");
    toggleImageSrcPlusMinus("img" + strClassName + "allall");
    toggleImageSrcPlusMinus("img" + strClassName + "allallall");
	}
	else
	{
	  var xobj;
	  xobj = domGetElementById(strDiv);
	  n = toggleDivObject(xobj);
	  strClassName = strDiv;
	}
	// use the root classname:
	toggleDivsByClassName(strClassName);
  return n;
}

//
// fnc001: getDivNameDivPatience:
//
function getDivNameDivPatience()
{
	return "divpatience";
}
//
// fnc001: getDivPatience:
//
function getDivPatience()
{
	return document.getElementById(getDivNameDivPatience());
}

//
// fnc001: showDivPatience:
//
function showDivPatience()
{
	var xobj = getDivPatience();
	if(xobj)
	{
		// IE6 does not show from direct argument query:
    xobj.className = "yousee";
//alert("xobj=" + xobj.className + ", in showDivPatience().");
    return true;
  }
  else
	{
    return false;
  }
}
//
// fnc001: showDivPatienceFree:
//
function showDivPatienceFree()
{
	var xobj = getDivPatience();
	if(xobj)
	{
	  xobj.className = "youseefree";
    return true;
  }
  else
	{
    return false;
  }
}
//
// fnc001: hideDivPatience:
//
function hideDivPatience()
{
	var xobj = getDivPatience();
	if(xobj)
	{
    xobj.className = "younotsee";
  }
  return false;
}
//
// fnc001: launchDivPatienceMarquee:
//
function launchDivPatienceMarquee()
{
  return ajaxSetInnerHTMLMarquee(getDivNameDivPatience());
}

//
// fnc001: get ajax result div name:
//
function ajaxGetResultDivNameDefault()
{
	return "ajaxresult";
}

//
// fnc001: get ajax result div name:
//
function ajaxGetResultDivName(strDiv)
{
//
  var strDivNow;
//
  if(strDiv == "")
  {
  	return ajaxGetResultDivNameDefault();
  }
  else
  {
  	return strDiv;
  }
//
}

//
// fnc001: get ajax result div object:
//
function ajaxGetResultDiv(strDiv)
{
//
  var strDivNow;
//
	strDivNow = ajaxGetResultDivName(strDiv);
//
  return domGetElementById(strDivNow);
}

//
// fnc001: ajaxCreateDivByContents: create a div with contents:
//
function ajaxCreateDivByContents(strDiv, strText)
{
//
  var varObj;
//
  varObj = document.createElement("div");
  if(varObj)
  {
		varObj.id = strDiv;
    varObj.className = "yousee";
	  //varObj.style.position = "absolute";
	  //varObj.style.left = "50px";
	  //varObj.style.top = "20px";
	  //varObj.style.width = "800px";
	  //varObj.style.height = "500px";
	  //varObj.style.backgroundColor = "#ffff00";
    domSetElementContentsByObject(varObj, strText);
    document.body.appendChild(varObj);
    return varObj;
  }
  else
  {
    return false;
  }
//
}

//
// fnc001: ajaxSetInnerHTML:
//
function ajaxSetInnerHTMLCreate(strDiv, strText, kCreateIfNonExistent)
{
//
  var strDivNow;
  var varObj;
//
  if(strDiv)
  {
  	if(typeof(strDiv) == "object")
  	{
      varObj = strDiv;
    }
    else
  	{
  	  strDivNow = ajaxGetResultDivName(strDiv);
      varObj = ajaxGetResultDiv(strDivNow);
    }
  }
  else
  {
  	strDivNow = ajaxGetResultDivName(strDiv);
    varObj = ajaxGetResultDiv(strDivNow);
  }
//
  if(varObj)
  {
    domSetElementContentsByObject(varObj, strText);
    return true;
  }
  else if(kCreateIfNonExistent)
  {
    return ajaxCreateDivByContents(strDivNow, strText);
  }
  else
  {
    return false;
  }
//
}

//
// fnc001: ajaxSetInnerHTML: create a new div if nonexistent:
//
function ajaxSetInnerHTML(strDiv, strText)
{
  return ajaxSetInnerHTMLCreate(strDiv, strText, true);
}

//
// fnc001: ajaxSetInnerHTMLAnyway: create a new div if nonexistent:
//
function ajaxSetInnerHTMLAnyway(strDiv, strText)
{
  return ajaxSetInnerHTMLCreate(strDiv, strText, true);
}

//
// fnc001: ajaxSetInnerHTML:
//
function ajaxSetInnerHTMLMarquee(strDiv)
{
  return ajaxSetInnerHTML(strDiv, locGetWaitMarquee());
}

//
// fnc001: ajaxSetInnerHTML:
//
function ajaxSetInnerHTMLIfExistent(strDiv, strText)
{
  return ajaxSetInnerHTMLCreate(strDiv, strText, false);
}

//
// fnc001: ajaxSetInnerHTML:
//
function ajaxSetInnerHTMLAjaxDateTime()
{
	var strDiv = "ajaxdatetime";
  var varObj = domGetElementById(strDiv);
  if(varObj)
  {
    return ajaxSetInnerHTMLIfExistent(strDiv, dtmGetDateTimeLocal());
  }
  else
  {
    return false;
  }
}

//
// fnc001: do Ajax get Request:
//   source: http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml
//
function ajaxGet(strUrl, kAsync, strDivResult, kMarquee, fncCallback)
{
//alert("ajaxGet(): strUrl=" + strUrl + ", strDivResult=" + strDivResult);
//var xobj = new getXhrObject();
  var xobj = getXhrObject();
  if(kAsync)
  {
    xobj.onreadystatechange = function() {
      if (xobj.readyState == 4) {
      	var strResponseText;
        if (xobj.status == 200 || window.location.href.indexOf("http")==-1) {
          strResponseText = xobj.responseText;
          /*
          if(brwIsIE()) {
            if(	strDivResult == "usernotesinput") {
            	var i = strResponseText.indexOf("Grenade");
              alert("ajaxGet(): strUrl=" + strUrl + ", strResponseText=" + strResponseText.substr(i, strResponseText.length - i));
            }
          }
           */
        }
        else {
          //strResponseText = xobj.statusText;
          strResponseText = "";
        }
        ajaxSetInnerHTMLAjaxDateTime();
        if(strDivResult != "")
        {
          ajaxSetInnerHTML(strDivResult, strResponseText);
          //ajaxSetFormTimeoutElement();
        }
        if(fncCallback)
        {
      	  fncCallback();
        }
      }
    };
  }
  xobj.open("GET", strUrl, kAsync);
//
  if(kMarquee)
  {
    if(strDivResult != "")
    {
      ajaxSetInnerHTMLMarquee(strDivResult);
    }
  }
//
  xobj.send(null);
//
//alert("ajaxGet(): strUrl=" + strUrl);
  if(! kAsync)
  {
   	var strResponseText;
    strResponseText = xobj.responseText;
    ajaxSetInnerHTMLAjaxDateTime();
    if(strDivResult != "")
    {
      ajaxSetInnerHTML(strDivResult, strResponseText);
    }
    if(fncCallback)
    {
  	  fncCallback();
    }
  }
//
  return xobj;
}

//
// fnc001: do Ajax get Request:
//   source: http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml
//
function ajaxGetdivpatience(strUrl)
{
  return ajaxGet(strUrl, true, getDivNameDivPatience(), true);
}

//
// fnc001: do Ajax get Request:
//   source: http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml
//
function ajaxGetDivDefault(strUrl)
{
  return ajaxGet(strUrl, true, ajaxGetResultDivNameDefault(), true);
}

//
// fnc001: do Ajax get Request without result shown:
//
function ajaxMakeRequest(strUrl)
{
  return ajaxGet(strUrl, true, "", true);
}

//
// fnc001: do Ajax get Request without result shown:
//
function ajaxMakeRequestSyncInfo(strUrl, strDivResult)
{
  return ajaxGet(strUrl, false, strDivResult, true);
}

//
// fnc001: do Ajax get Request without result shown:
//
function ajaxMakeRequestRenew(strUrl)
{
  return ajaxMakeRequest(appendUrlArg1(strUrl,
    getTimeByDateObject(null)));
}

//
// fnc001: get ajax result div object:
//
function ajaxGetRenew()
{
//var varObj = ajaxGetResultDiv("");
//
//if(varObj)
//{
//  varObj.innerHTML = locGetWaitMarquee();
//}
//
  return ajaxGet(getThisPageAppendUrlArg1("ajaxcontentsonly=1&"
    + getTimeByDateObject(null)), true, "", true);
}

//
// fnc001: get ajax result div object:
//
function ajaxGetInfoUrl(strUrl)
{
	ttPhotosInit();
	xhrAbort();
	gobjttxhr = ajaxGet(appendUrlArg1(strUrl,
	  "ajaxcontentsonly=1"), true, "ttPhotos", true);
  return gobjttxhr;
}

//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxGetRenewTimerRoot(kStartOnly, timeout)
{
//
// stop first existent timer:
//
	ajaxGetRenewTimerStop(false);
//
  glAjaxTimerHandler = window.setTimeout("ajaxGetRenewTimer(" + timeout + ")", timeout);
//
  if(kStartOnly)
  {
  	return true;
  }
  else
  {
    return ajaxGetRenew();
  }
}

//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxGetRenewTimer(timeout)
{
  return ajaxGetRenewTimerRoot(false, timeout);
}

//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxGetRenewTimerStart(timeout)
{
  return ajaxGetRenewTimerRoot(true, timeout);
}

//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxGetFormTimeoutElement()
{
	return domGetElementById("timeout");
}

//
// fnc001: do Ajax increment:
//
function ajaxIncrementRoot(strDiv, varIncrement)
{
	var xobj = domGetElementById(strDiv);
	if(xobj)
	{
		var varVal;
		varVal = parseInt(xobj.innerHTML);
		if(! isNaN(varVal))
		{
      domSetElementContentsByObject(xobj, varVal + varIncrement);
      return true;
    }
  }
  return false;
}
//
// fnc001: do Ajax increment:
//
function ajaxIncrement(strDiv)
{
  return ajaxIncrementRoot(strDiv, 1);
}
//
// fnc001: do Ajax increment:
//
function ajaxIncrementVarArgs()
{
	var i, args = ajaxIncrementVarArgs.arguments;
	for(i = 0; i < args.length; i++)
	{
    ajaxIncrement(args[i]);
  }
  return i;
}
//
// fnc001: do Ajax decrement:
//
function ajaxDecrement(strDiv)
{
  return ajaxIncrementRoot(strDiv, -1);
}
//
// fnc001: do Ajax decrement:
//
function ajaxDecrementVarArgs()
{
	var i, args = ajaxDecrementVarArgs.arguments;
	for(i = 0; i < args.length; i++)
	{
    ajaxDecrement(args[i]);
  }
  return i;
}

//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxSetFormTimeoutElement()
{
	var varObj = ajaxGetFormTimeoutElement();
	if(varObj)
	{
  	if(typeof(glngAjaxTimeout) != "undefined")
  	{
    	if(glngAjaxTimeout != "")
    	{
  	 	  varObj.value = glngAjaxTimeout;
        return glngAjaxTimeout;
  	 	}
    }
  }
//
  return 0;
}

//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxGetRenewTimerRestart()
{
	var varObj = ajaxGetFormTimeoutElement();
	if(varObj)
	{
  	glngAjaxTimeout = varObj.value;
  	glngAjaxTimeoutOld = glngAjaxTimeout
  	if(glngAjaxTimeout != "")
  	{
  		var istat;
  		istat = ajaxGetRenewTimerStart(glngAjaxTimeout);
  		if(istat)
  		{
  			var locRestartRefresh;
        if(locIsLangLocalFr())
        {
          locRestartRefresh = "Recommencer Rafraîchissement";
        }
        else if(locIsLangLocalCn())
        {
          locRestartRefresh = "重新启动自动刷新";
        }
        else
        {
          locRestartRefresh = "Restart Refreshing";
        }
        alert(locRestartRefresh + " #" + glAjaxTimerHandler + ".");
      }
      return istat;
    }
  }
//
  return false;
}

//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxPreloadImage(url)
{
	var xhr = getXhrObject();   
	xhr.onreadystatechange=function()
	{ 
		if(xhr.readyState == 4)
		{
			var strContents = xhr.responseText;
			var i = new Image();
			i.src = strContents;
		} 
	}; 
	xhr.open("GET", url , true);
	xhr.send(null); 
} 

//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxSetRenewTimeoutIncrement(kPlus)
{
	var varObj = ajaxGetFormTimeoutElement();
	if(varObj)
	{
  	glngAjaxTimeout = varObj.value;
  	glngAjaxTimeoutOld = glngAjaxTimeout
  	if(glngAjaxTimeout != "")
  	{
  		if(kPlus)
  		{
    	  glngAjaxTimeout = glngAjaxTimeout*10.0;
    	}
  		else
  		{
    	  glngAjaxTimeout = glngAjaxTimeout/10.0;
    	}
  	  glngAjaxTimeoutOld = glngAjaxTimeout
  		varObj.value = glngAjaxTimeout;
  		return glngAjaxTimeout;
    }
  }
//
  return false;
}
//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxSetRenewTimeoutPlus()
{
  return ajaxSetRenewTimeoutIncrement(true);
}
//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxSetRenewTimeoutMinus()
{
  return ajaxSetRenewTimeoutIncrement(false);
}


//
// fnc001: get ajax result div object:
//   timeout in ms:
//
function ajaxGetRenewTimerStop(kverb)
{
	if(typeof(glAjaxTimerHandler) == "undefined")
	{
		return false;
  }
//
	if(glAjaxTimerHandler)
	{
    window.clearTimeout(glAjaxTimerHandler);
//
    if(kverb)
    {
      var locStopRefresh;
      if(locIsLangLocalFr())
      {
        locStopRefresh = "Arrêter Rafraîchissement";
      }
      else if(locIsLangLocalCn())
      {
        locStopRefresh = "停止自动刷新";
      }
      else
      {
        locStopRefresh = "Stop Refreshing";
      }
      alert(locStopRefresh + " #" + glAjaxTimerHandler + ".");
    }
    glAjaxTimerHandler = 0;
    return true;
  }
  else
	{
    return false;
  }
}

//
// fnc001: do Ajax post Request:
//   source: http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml
//
function ajaxPost(strUrl, kAsync, strDivResult, kMarquee, fncCallback)
{
//var xobj = new getXhrObject();
  var xobj = getXhrObject();
  xobj.onreadystatechange = function() {
    if (xobj.readyState == 4) {
    	var strResponseText;
      if (xobj.status == 200 || window.location.href.indexOf("http")==-1) {
        strResponseText = xobj.responseText;
        //alert(xobj.responseText);
      }
      else {
        //strResponseText = xobj.statusText;
        strResponseText = "";
      }
      if(strDivResult != "")
      {
        ajaxSetInnerHTML(strDivResult, strResponseText);
      }
      if(fncCallback)
      {
      	fncCallback();
      }
    }
  };
  var strBaseUrl, strArgs;
  var i = strUrl.indexOf("?");
  if(i >= 0)
  {
  	strBaseUrl = strUrl.substr(0, i);
  	strArgs = strUrl.substr(i + 1);
  }
  else
  {
  	strBaseUrl = strUrl;
  	strArgs = "";
  }
  //alert("strBaseUrl="+strBaseUrl+",strArgs="+strArgs);
  xobj.open("POST", strBaseUrl, kAsync);
  if(kMarquee)
  {
    if(strDivResult != "")
    {
      ajaxSetInnerHTMLMarquee(strDivResult);
    }
  }
  xobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xobj.send(strArgs);
  return xobj;
}

//
// fnc001: do Ajax post Request:
//   source: http://www.javascriptkit.com/dhtmltutors/ajaxgetpost.shtml
//
function ajaxPostdivpatience(strUrl)
{
  return ajaxPost(strUrl, true, getDivNameDivPatience(), true);
}

//
// floatdiv.js:
//
//
// echo "王 ";
//
//*********************************************************
//   * You may use this code for free on any web page provided that 
//   * these comment lines and the following credit remain in the code.
//   * Floating Div from http://www.javascript-fx.com
//   ********************************************************
//
function JSFX_FloatDiv(id, sx, sy)
{
  var ns = (navigator.appName.indexOf("Netscape") != -1);
  var d = document;
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	var px = document.layers ? "" : "px";
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
  el.cx = el.sx = sx;
  el.cy = el.sy = sy;
	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};

	el.floatIt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.floatIt()", 40);
	}
	return el;
}
//JSFX_FloatDiv("floatdiv", 280, 1).floatIt();

//
// bniffer.js:
//
function ClientSnifferJr()
{
  this.ua = navigator.userAgent.toLowerCase();
  this.major = parseInt(navigator.appVersion);
  this.minor = parseFloat(navigator.appVersion);
  // DOM support
  if (document.addEventListener && document.removeEventListener) this.dom2events = true;
  if (document.getElementById) this.dom1getbyid = true;
  // opera
  this.opera = this.ua.indexOf('opera') != -1;
  if (this.opera) {
    this.opera5 = (this.ua.indexOf("opera 5") != -1 || this.ua.indexOf("opera/5") != -1);
    //return;
  } 
  // MSIE
  this.ie = this.ua.indexOf('msie') != -1;
  if (this.ie) {
    this.ie3 = this.major < 4;
    this.ie4 = (this.major == 4 && this.ua.indexOf('msie 5') == -1 && this.ua.indexOf('msie 6') == - 1);
    this.ie4up = this.major >= 4;
    this.ie5 = (this.major == 4 && this.ua.indexOf('msie 5.0') != -1);
    this.ie5up = !this.ie3 && !this.ie4;
    this.ie6 = (this.major == 4 && this.ua.indexOf('msie 6.0') != -1);
    this.ie6up = (!this.ie3 && !this.ie4 && !this.ie5 && this.ua.indexOf("msie 5.5") == -1);
    //return;
  }
  // Misc.
  this.hotjava = this.ua.indexOf('hotjava') != -1; 
  this.webtv = this.ua.indexOf('webtv') != -1;
  this.aol = this.ua.indexOf('aol') != -1; 
  if (this.hotjava || this.webtv || this.aol) return;
  // Gecko, NN4+, and NS6
  this.gecko = this.ua.indexOf('gecko') != -1;
  this.nav = (this.ua.indexOf('mozilla') != -1 && this.ua.indexOf('spoofer') == -1 && this.ua.indexOf('compatible') == -1);
  this.ns = this.nav;
  if (this.nav) {
    this.nav4 = this.major == 4;
    this.nav4up= this.major >= 4;
    this.nav5up= this.major >= 5;
    this.nav6 = this.major == 5;
    this.nav6up= this.nav5up;
  }
}

//window.is = new ClientSnifferJr();
window.bw = new ClientSnifferJr();

//
// chrono.js:
//
var timercount = 0;
var timestart  = null;

//
// fnc001: get timestamp by date object:
//   datDate: object created by new Date().
//
function getTimeByDateObject(datDate)
{
  var dat2DateHandle = new Date();
	if(datDate == null)
	{
    dat2DateHandle = new Date();
  }
  else
	{
    dat2DateHandle = datDate;
  }
//
  return dat2DateHandle.getTime();
//
}
 
function showtimer() {
//
	   if(! document.timeform) {
	     return false;
	   }
//
    if(timercount) {
        clearTimeout(timercount);
        clockID = 0;
    }
    if(!timestart){
        timestart = new Date();
    }
    var timeend = new Date();
    var timedifference = timeend.getTime() - timestart.getTime();
    timeend.setTime(timedifference);
    var minutes_passed = timeend.getMinutes();
    if(minutes_passed <10){
        minutes_passed = "0" + minutes_passed;
    }
    var seconds_passed = timeend.getSeconds();
    if(seconds_passed <10){
        seconds_passed = "0" + seconds_passed;
    }
    document.timeform.timetextarea.value = minutes_passed + ":" + seconds_passed;
    timercount = setTimeout("showtimer()", 1000);
}
 
function swStart(){
//
	   if(! document.timeform) {
	     return false;
	   }
//
    if(!timercount){
    timestart   = new Date();
    document.timeform.timetextarea.value = "00:00";
    if(document.timeform.laptime)
    {
      document.timeform.laptime.value = "";
    }
    timercount  = setTimeout("showtimer()", 1000);
    }
    else{
    var timeend = new Date();
        var timedifference = timeend.getTime() - timestart.getTime();
        timeend.setTime(timedifference);
        var minutes_passed = timeend.getMinutes();
        if(minutes_passed <10){
            minutes_passed = "0" + minutes_passed;
        }
        var seconds_passed = timeend.getSeconds();
        if(seconds_passed <10){
            seconds_passed = "0" + seconds_passed;
        }
        var milliseconds_passed = timeend.getMilliseconds();
        if(milliseconds_passed <10){
            milliseconds_passed = "00" + milliseconds_passed;
        }
        else if(milliseconds_passed <100){
            milliseconds_passed = "0" + milliseconds_passed;
        }
        if(document.timeform.laptime)
        {
          document.timeform.laptime.value = minutes_passed + ":" + seconds_passed + "." + milliseconds_passed;
        }
    }
}
 
function swStop() {
//
	   if(! document.timeform) {
	     return false;
	   }
//
    if(timercount) {
        clearTimeout(timercount);
        timercount  = 0;
        var timeend = new Date();
        var timedifference = timeend.getTime() - timestart.getTime();
        timeend.setTime(timedifference);
        var minutes_passed = timeend.getMinutes();
        if(minutes_passed <10){
            minutes_passed = "0" + minutes_passed;
        }
        var seconds_passed = timeend.getSeconds();
        if(seconds_passed <10){
            seconds_passed = "0" + seconds_passed;
        }
        var milliseconds_passed = timeend.getMilliseconds();
        if(milliseconds_passed <10){
            milliseconds_passed = "00" + milliseconds_passed;
        }
        else if(milliseconds_passed <100){
            milliseconds_passed = "0" + milliseconds_passed;
        }
        document.timeform.timetextarea.value = minutes_passed + ":" + seconds_passed + "." + milliseconds_passed;
    }
    timercount = 0;
    timestart = null;
}
 
function swReset()
{
//
	   if(! document.timeform) {
	     return false;
	   }
//
    timestart = null;
    document.timeform.timetextarea.value = "00:00";
    if(document.timeform.laptime)
    {
      document.timeform.laptime.value = "";
    }
}

//
// datetime.js:
//
function appVersionMajor1()
{
  return parseInt(navigator.appVersion);
}

function yrlong(now)
{
  var vret;
  if(now == null)
  {
    now = new Date();
  }
  if(appVersionMajor1() >= 4)
  {
    vret = now.getFullYear();
  }
  else
  {
    vret = now.getYear();
    if(vret < 100)
    {
      vret += 1900;
    }
  }
  return vret;
}

function dtmGethhmmss(now)
{
  var dobj, str1, vret;
  if(now == null)
  {
    dobj = new Date();
  }
  else
  {
    dobj = now;
  }
  str1 = dobj.getHours();
  if(str1 < 10)
  {
    str1 = "0" + str1;
  }
  vret = str1;
  str1 = dobj.getMinutes();
  if(str1 < 10)
  {
    str1 = "0" + str1;
  }
  vret += ":" + str1;
  str1 = dobj.getSeconds();
  if(str1 < 10)
  {
    str1 = "0" + str1;
  }
  vret += ":" + str1;
  return vret;
}

function dtmFormatCountDownTarget(objDate)
{
	var TargetDate, x;
  x = objDate.getMonth() + 1;
  if(x < 10)
  {
    x = "0" + x;
  }
  TargetDate = x;
  x = objDate.getDate();
  if(x < 10)
  {
    x = "0" + x;
  }
  TargetDate += "/" + x + "/" + objDate.getFullYear();
  x = objDate.getHours();
  if(x < 10)
  {
    x = "0" + x;
  }
  TargetDate += " " + x;
  x = objDate.getMinutes();
  if(x < 10)
  {
    x = "0" + x;
  }
  TargetDate += ":" + x;
  x = objDate.getSeconds();
  if(x < 10)
  {
    x = "0" + x;
  }
  return TargetDate + ":" + x;
}

//
function inetDeleteCookie(name,path,domain)
{
  if(inetGetCookie(name))
  {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
  return 1;
}

function inetGetCookie(strCookieName)
{
  if (document.cookie.length > 0)
  {
  	var c_start, c_end;
    c_start = document.cookie.indexOf(strCookieName + "=");
    if (c_start!=-1)
    {
      c_start=c_start + strCookieName.length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length;
      return unescape(document.cookie.substring(c_start,c_end));
    }
  }
  return "";
}

function inetHasCookie(strCookieName)
{
  if(inetGetCookie(strCookieName) == "")
  {
  	return false;
  }
  else
  {
  	return true;
  }
}

//
function inetSetCookie(name, value, expires, path, domain, secure)
{
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
  return 1;
}

function inetSetCookieDays(strCookieName, strCookieValue, expiredays)
{
  var exdate = new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=strCookieName+ "=" +escape(strCookieValue)+
    ((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

//
// fnc001: get Chinese digit:
//
function getChineseNumberDigit(n)
{
  var i = 1*n;
  switch(i)
  {
  	case 0:
  	  return "零";
  	case 1:
  	  return "一";
  	case 2:
  	  return "二";
  	case 3:
  	  return "三";
  	case 4:
  	  return "四";
  	case 5:
  	  return "五";
  	case 6:
  	  return "六";
  	case 7:
  	  return "七";
  	case 8:
  	  return "八";
  	case 9:
  	  return "九";
  	default:
  	  return n;
  }
}

//
// fnc001: get Chinese number unit:
//   0: unity
//   1: ten's
//   ...
//
function getChineseNumberUnit(iPos)
{
  switch(iPos)
  {
  	case 0:
  	  return "";
  	case 1:
  	  return "十";
  	case 2:
  	  return "百";
  	case 3:
  	  return "千";
  	case 4:
  	  return "万";
  	default:
  	  return "亿";
  }
}

//
// fnc001: get Chinese number unit:
//   0: unity
//   1: ten's
//   ...
//
function getChineseNumberDigitUnit(n, iPos)
{
	// 10:
	if(iPos == 1)
	{
		if(n == 1)
		{
			return getChineseNumberUnit(iPos);
		}
	}
  return getChineseNumberDigit(n) + getChineseNumberUnit(iPos);
}

//
// fnc001: format Chinese date from Gregorian date:
//
function getChineseNumber(n)
{
	var i, idx, str1 = new String(n);
	var iArr;
	iArr = str1.split("");
	idx = iArr.length - 1;
	str1 = "";
	//
	// 123456789: => array("1", "2", "3", "4", "5", "6", "7", "8", "9");
	//
  //alert(iArr[0] + "," + iArr[1] + ", lng=" + lng);
  //
  for(i = 0; i <= idx; i++)
  {
  	if((str1 == "") || (! ((i == idx) && (iArr[i] == 0))))
  	{
      str1 += getChineseNumberDigitUnit(iArr[i], idx - i);
    }
  }
  return str1;
}

//
// fnc001: get lang by Navigator:
//
function locGetLangByNavigator()
{
	return (navigator.language)
	  ? navigator.language : navigator.userLanguage;
}
//
// fnc001: get lang by cookie:
//
function locGetLangByCookie()
{
	return inetGetCookie("lang");
}
//
// fnc001: get lang by cookie:
//
function locGetLangLocal()
{
	var strLang;
  strLang = locGetLangByCookie();
	if(strLang == "")
	{
	  strLang = locGetLangByNavigator();
  	if(strLang == "")
	  {
	    strLang = "fr";
	  }
	}
	return strLang;
}
//
// fnc001: Is X language:
//   $strLang: compare language string
//
function locIsLangLocalX(strLang)
{
//
  var langLocal = locGetLangLocal();
//
  if(strLang == langLocal)
  {
    return true;
  }
  else
  {
    return false;
  }
}
//
// fnc001: English:
//
function locIsLangLocalEn()
{
  return locIsLangLocalX("en");
}

//
// fnc001: English:
//
function locIsLangLocal0()
{
  return locIsLangLocalEn();
}

//
// fnc001: French:
//
function locIsLangLocalFr()
{
  return locIsLangLocalX("fr");
}

//
// fnc001: Chinese:
//
function locIsLangLocalCn()
{
  return locIsLangLocalX("cn");
}

//
// fnc001: Chinese:
//
function locIsLangLocalBig5()
{
  return locIsLangLocalX("big5");
}

//
// fnc001: Spanish:
//
function locIsLangLocalEs()
{
  return locIsLangLocalX("es");
}

//
// fnc001: Italian:
//
function locIsLangLocalIt()
{
  return locIsLangLocalX("it");
}

//
// fnc001: Portuguese:
//
function locIsLangLocalPt()
{
  return locIsLangLocalX("pt");
}

//
// fnc001: Deutch - German:
//
function locIsLangLocalDe()
{
  return locIsLangLocalX("de");
}

function dtmGetDateTimeLocalEn()
{
  var now = new Date();
  return v2DayEn(now.getDay()) + " " +
    v2MonthEn(now.getMonth() + 1) + " " + now.getDate() + ", " +
    yrlong(now) + " " + dtmGethhmmss(now);
}

function dtmGetDateTimeLocalFr()
{
  var now = new Date();
  return v2DayFr(now.getDay()) + " " +
    now.getDate() + " " + v2MonthFr(now.getMonth() + 1) + " " + 
    yrlong(now) + " " + dtmGethhmmss(now);
}

function dtmGetDateTimeLocalCn()
{
  var now = new Date();
  return yrlong(now) + "年" + v2MonthCn(now.getMonth() + 1)
    + getChineseNumber(now.getDate()) + "日"
    + " " + v2DayCn(now.getDay())
    + " " +
    dtmGethhmmss(now);
}

//
// fnc001: get local time by lang:
//
function dtmGetDateTimeLocalLang(lang)
{
  var str1;
//
  if(lang == "fr")
  {
    str1 = dtmGetDateTimeLocalFr();
  }
  else if(lang == "cn")
  {
    str1 = dtmGetDateTimeLocalCn();
  }
  else
  {
    str1 = dtmGetDateTimeLocalEn();
  }
//
  return str1;
}

//
// fnc001: get local time by lang:
//
function dtmGetDateTimeLocal()
{
  return dtmGetDateTimeLocalLang(locGetLangLocal());
}

function getDateAdminFr()
{
  var now = new Date();
  return now.getDate() + "/" + (now.getMonth() + 1) + "/" + yrlong(now);
}

function getDateAdminEn()
{
  var now = new Date();
  return (now.getMonth() + 1) + "/" + now.getDate() + "/" + yrlong(now);
}

function getDateAdminCn()
{
  var now = new Date();
  return yrlong(now) + "." + (now.getMonth() + 1) + "." + now.getDate();
}

function v2DayFr(dv)
{
  var vret = "";
  if(dv == 0)
  {
    vret = "Dimanche";
  }
  else if(dv == 1)
  {
    vret = "Lundi";
  }
  else if(dv == 2)
  {
    vret = "Mardi";
  }
  else if(dv == 3)
  {
    vret = "Mercredi";
  }
  else if(dv == 4)
  {
    vret = "Jeudi";
  }
  else if(dv == 5)
  {
    vret = "Vendredi";
  }
  else if(dv == 6)
  {
    vret = "Samedi";
  }
  else
  {
    vret = "Jour invalide";
  }
  return vret;
}

function getDayFr(dv)
{
  var now = new Date();
  return v2DayFr(now.getDay());
}

function v2DayEn(dv)
{
  var vret;
  if(dv == 0)
  {
    vret = "Sunday";
  }
  else if(dv == 1)
  {
    vret = "Monday";
  }
  else if(dv == 2)
  {
    vret = "Tuesday";
  }
  else if(dv == 3)
  {
    vret = "Wendesday";
  }
  else if(dv == 4)
  {
    vret = "Thursday";
  }
  else if(dv == 5)
  {
    vret = "Friday";
  }
  else if(dv == 6)
  {
    vret = "Saturday";
  }
  else
  {
    vret = "Bad day value";
  }
  return vret;
}

function getDayEn()
{
  var now = new Date();
  return v2DayEn(now.getDay());
}

function v2DayCn(dv)
{
  var vret;
  if(dv == 0)
  {
    vret = "星期日";
  }
  else if(dv == 1)
  {
    vret = "星期一";
  }
  else if(dv == 2)
  {
    vret = "星期二";
  }
  else if(dv == 3)
  {
    vret = "星期三";
  }
  else if(dv == 4)
  {
    vret = "星期四";
  }
  else if(dv == 5)
  {
    vret = "星期五";
  }
  else if(dv == 6)
  {
    vret = "星期六";
  }
  else
  {
    vret = "日子不对";
  }
  return vret;
}

function v2MonthFr(mv)
{
  var vret;
  if(mv == 1)
  {
    vret = "Janvier";
  }
  else if(mv == 2)
  {
    vret = "Février";
  }
  else if(mv == 3)
  {
    vret = "Mars";
  }
  else if(mv == 4)
  {
    vret = "Avril";
  }
  else if(mv == 5)
  {
    vret = "Mai";
  }
  else if(mv == 6)
  {
    vret = "Juin";
  }
  else if(mv == 7)
  {
    vret = "Juillet";
  }
  else if(mv == 8)
  {
    vret = "Août";
  }
  else if(mv == 9)
  {
    vret = "Septembre";
  }
  else if(mv == 10)
  {
    vret = "Octobre";
  }
  else if(mv == 11)
  {
    vret = "Novembre";
  }
  else if(mv == 12)
  {
    vret = "Décembre";
  }
  else
  {
    vret = "Mois invalide";
  }
  return vret;
}

function v2MonthEn(mv)
{
  var vret;
  if(mv == 1)
  {
    vret = "January";
  }
  else if(mv == 2)
  {
    vret = "February";
  }
  else if(mv == 3)
  {
    vret = "March";
  }
  else if(mv == 4)
  {
    vret = "April";
  }
  else if(mv == 5)
  {
    vret = "May";
  }
  else if(mv == 6)
  {
    vret = "June";
  }
  else if(mv == 7)
  {
    vret = "July";
  }
  else if(mv == 8)
  {
    vret = "August";
  }
  else if(mv == 9)
  {
    vret = "September";
  }
  else if(mv == 10)
  {
    vret = "October";
  }
  else if(mv == 11)
  {
    vret = "November";
  }
  else if(mv == 12)
  {
    vret = "December";
  }
  else
  {
    vret = "Bad month value";
  }
  return vret;
}

function v2MonthCn(mv)
{
  var vret;
  if((mv >= 1) && (mv <= 12))
  {
    vret = getChineseNumber(mv) + "月";
  }
  else
  {
    vret = "不存在";
  }
  return vret;
}

function dtmGetDateFullFr()
{
  var now = new Date();
  return v2DayFr(now.getDay()) + " " +
    now.getDate() + " " + v2MonthFr(now.getMonth() + 1) + " " +
    yrlong(now);
}

function dtmGetDateFullEn()
{
  var now = new Date();
  return v2DayEn(now.getDay()) + " " +
    v2MonthEn(now.getMonth() + 1) + " " +  now.getDate() + ", " +
    yrlong(now);
}

//
// keydown.js:
//
// special keys:
//   IE, FireFox, kepyress/keydown/keyup
//   Google Crhome Catch keydown/keyup instead. 
//
function kdnGetKeyCode(ev)
{
	var code;
	if(!ev) var ev = window.event;
	if(ev.keyCode) code = ev.keyCode;
	else if(ev.which) code = ev.which;
	//alert('Fonction key1 : '+code);
	return code;
}
//
function kdnHandleKeyDown(ev)
{
	var code;
	code = kdnGetKeyCode(ev);
	if(code == 27)
	{
		window.close();
	}
}
//document.getElementsByTagName('body')[0].onkeypress = kdnHandleKeyDown;
 
//
// mojozoom.js:
//
//
// echo "王 ";
//
/*
 * MojoZoom 0.1.4 - JavaScript Image Zoom
 * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
 * Licensed under the MPL License [http://www.nihilogic.dk/licenses/mpl-license.txt]
 */

var MojoZoom = (function() {

	var $ = function(id) {return document.getElementById(id);};
	var dc = function(tag) {return document.createElement(tag);};

	var defaultWidth = 256;
	var defaultHeight = 256;
	var isDone = false;

	function addEvent(element, ev, handler) 
	{
//alert("MojoZoom.addEvent element=" + element);
		var doHandler = function(e) {
			return handler(e||window.event);
		}
		if (element.addEventListener) { 
			element.addEventListener(ev, doHandler, false); 
		} else if (element.attachEvent) { 
			element.attachEvent("on" + ev, doHandler); 
		}
	}

	function getElementPos(element)
	{
		var x = element.offsetLeft;
		var y = element.offsetTop;
		var parent = element.offsetParent;
		while (parent) {
			x += parent.offsetLeft;
			y += parent.offsetTop;
			parent = parent.offsetParent;
		}
		return {
			x : x,
			y : y
		}
	}

	function getEventMousePos(element, e) {
		var scrollX = document.body.scrollLeft || document.documentElement.scrollLeft;
		var scrollY = document.body.scrollTop || document.documentElement.scrollTop;

		if (e.currentTarget) {
			var pos = getElementPos(element);
			return {
				x : e.clientX - pos.x + scrollX,
				y : e.clientY - pos.y + scrollY
			}
		}
		return {
			x : e.offsetX,
			y : e.offsetY
		}
	}

	function doOnClick()
	{
		alert("ok");
		return false;
  }

	function makeZoomable(img, zoomSrc, zoomImgCtr, zoomWidth, zoomHeight, alwaysShow) {
//alert("zoomSrc=" + zoomSrc);
		// make sure the image is loaded, if not then add an onload event and return
		if (!img.complete && !img.__mojoZoomQueued) {
			addEvent(img, "load", function() {
				img.__mojoZoomQueued = true;
				setTimeout(function() {
				makeZoomable(img, zoomSrc, zoomImgCtr, zoomWidth, zoomHeight, alwaysShow);
				}, 1);
			});
			return;
		}

		img.__mojoZoomQueued = false;

		// Wrap everything in a timeout.
		// this fixes a problem where, if makeZoomable is called a second time after changing the src,
		// FF would not have figured out the new offsetHeight of the image yet. A small timeout helps though it's rather hackish.
		setTimeout(function(){

		// sorry
		/* var isIE = !!document.all && !!window.attachEvent && !window.opera; */
		var isIE = brwIsIE();

		var w = img.offsetWidth;
		var h = img.offsetHeight;

		var oldParent = img.parentNode;
		if (oldParent.nodeName != "A") {
			var linkParent = dc("a");
			linkParent.setAttribute("href", zoomSrc);
			//
			// Google Chrome OK, not IE:
			//linkParent.setAttribute("onclick", "alert('OKI0'); return false;");
			// Google Chrome OK, IE OK: wang.
			//
			linkParent.onclick = function()
			{
				var xParent;
				// this is the link itself:
				xParent = this.parentNode;
				if(xParent != null)
				{
	  			if(xParent.nodeName == "FORM")
  				{
		  	  	xParent.submit();
		  	  	return false;
		  	  }
			  }
			  //
			  // this disables high resolution photo display: wang.
			  //
				//return false;
			  //
			  // now we let high resolution photo display: wang.
			  //
				return true;
			};
			oldParent.replaceChild(linkParent, img);
			linkParent.appendChild(img);
		} else {
			var linkParent = oldParent;
		}

		linkParent.style.position = "relative";
		//
		// this will break down after the image like br - wang:
		// it is required to well position the zoom:
		//
		linkParent.style.display = "block";
		//
		linkParent.style.width = w+"px";
		linkParent.style.height = h+"px";

		var imgLeft = img.offsetLeft;
		var imgTop = img.offsetTop;

		var zoom = dc("div");
		zoom.className = "mojozoom_marker";

		var zoomImg = dc("img");
		zoomImg.className = "mojozoom_img";

		zoomImg.style.position = "absolute";
		zoomImg.style.left = "-9999px";
		zoomImg.style.top = "-9999px";

		document.body.appendChild(zoomImg);

		var parent = img.parentNode;

		var ctr = dc("div");
		with (ctr.style) {
			position = "absolute";
			left = imgLeft+"px";
			top = imgTop+"px";
			width = w+"px";
			height = h+"px";
			overflow = "hidden";
			display = "none";
		}

		ctr.appendChild(zoom);
		parent.appendChild(ctr);

		var zoomInput = parent;

		// clear old overlay
		if (img.__mojoZoomOverlay)
			parent.removeChild(img.__mojoZoomOverlay);
		img.__mojoZoomOverlay = ctr;

		// clear old high-res image
		if (img.__mojoZoomImage && img.__mojoZoomImage.parentNode)
			img.__mojoZoomImage.parentNode.removeChild(img.__mojoZoomImage);
		img.__mojoZoomImage = zoomImg;

		var useDefaultCtr = false;
		if (!zoomImgCtr) {
			zoomImgCtr = dc("div");
			zoomImgCtr.className = "mojozoom_imgctr";

			var imgPos = getElementPos(img);
			zoomImgCtr.style.left = w + imgPos.x + "px";
			zoomImgCtr.style.top = imgPos.y + "px";

			zoomImgCtr.style.width = (zoomWidth ? zoomWidth : defaultWidth) +"px";
			zoomImgCtr.style.height = (zoomHeight ? zoomHeight : defaultHeight) +"px";

			document.body.appendChild(zoomImgCtr);
			useDefaultCtr = true;
		}
		zoomImgCtr.style.overflow = "hidden";

		if (!alwaysShow) {
			zoomImgCtr.style.visibility = "hidden";
		}

		addEvent(zoomImg, "load", function() {

			// bail out if img has been removed from dom
			if (!zoomImg.parentNode) return;

			var zoomWidth = zoomImg.offsetWidth;
			var zoomHeight = zoomImg.offsetHeight;

			var ctrWidth = zoomImgCtr.offsetWidth;
			var ctrHeight = zoomImgCtr.offsetHeight;

			var ratioW = zoomWidth / w;
			var ratioH = zoomHeight / h;

			var markerWidth = Math.round(ctrWidth / ratioW);
			var markerHeight = Math.round(ctrHeight / ratioH);

			document.body.removeChild(zoomImg);
			zoomImgCtr.appendChild(zoomImg);

			var zoomFill = dc("div");
			zoomFill.className = "mojozoom_fill";
			zoom.appendChild(zoomFill);

			var zoomBorder = dc("div");
			zoomBorder.className = "mojozoom_border";
			zoom.appendChild(zoomBorder);

			zoom.style.width = markerWidth+"px";
			zoom.style.height = markerHeight+"px";


			if (alwaysShow) {
				zoom.style.left = "0px";
				zoom.style.top = "0px";
	
				zoomImg.style.left = "0px";
				zoomImg.style.top = "0px";
			}

			var isInImage = false;

			if (!alwaysShow) {
				addEvent(zoomInput, "mouseout", 
					function(e) {
						var target = e.target || e.srcElement;
						if (!target) return;
						if (target.nodeName != "DIV") return;
						var relTarget = e.relatedTarget || e.toElement;
						if (!relTarget) return;
						while (relTarget != target && relTarget.nodeName != "BODY" && relTarget.parentNode) {
							relTarget = relTarget.parentNode;
						}
						if (relTarget != target) {
							isInImage = false;
							ctr.style.display = "none";
							zoomImgCtr.style.visibility = "hidden";
						}
					}
				);
				// a bit of a hack, mouseout is sometimes not caught if moving mouse really fast
				addEvent(document.body, "mouseover", 
					function(e) {
						if (isInImage && !(e.toElement == zoomBorder || e.target == zoomBorder)) {
							ctr.style.display = "none";
							zoomImgCtr.style.visibility = "hidden";
							isInImage = false;
						}
					}
				);
			}

			addEvent(zoomInput, "mousemove", 
				function(e) {
					isInImage = true;

					var imgPos = getElementPos(img);

					if (useDefaultCtr) {
						zoomImgCtr.style.left = w + imgPos.x + "px";
						zoomImgCtr.style.top = imgPos.y + "px";
					}
					ctr.style.display = "block";
					zoomImgCtr.style.visibility = "visible";

					var pos = getEventMousePos(zoomInput, e);
					if (e.srcElement && isIE) {
						if (e.srcElement == zoom) return;
						if (e.srcElement != zoomInput) {
							var zoomImgPos = getElementPos(e.srcElement);
							pos.x -= (imgPos.x - zoomImgPos.x);
							pos.y -= (imgPos.y - zoomImgPos.y);
						}
					}
					var x = markerWidth/2;
					var y = markerHeight/2;

					if (!isIE) {
						pos.x -= imgLeft;
						pos.y -= imgTop;
					}

					if (pos.x < x) pos.x = x;
					if (pos.x > w-x) pos.x = w-x;
					if (pos.y < y) pos.y = y;
					if (pos.y > h-y) pos.y = h-y;

					var left = ((pos.x - x)|0);
					var top = ((pos.y - y)|0);

					zoom.style.left = left + "px";
					zoom.style.top = top + "px";

					zoomImg.style.left = -((pos.x*ratioW - ctrWidth/2)|0)+"px";
					zoomImg.style.top = -((pos.y*ratioH - ctrHeight/2)|0)+"px";
				}
			);
		});

		// I've no idea. Simply setting the src will make IE screw it self into a 100% CPU fest. In a timeout, it's ok.
		setTimeout(function() { 
			zoomImg.src = zoomSrc;
		}, 1);

		}, 1);
	}

/*
	function init() {
		var images = document.getElementsByTagName("img");
		for (var i=0;i<images.length;i++) {
			var img = images[i];
			var zoomSrc = img.getAttribute("data-zoomsrc");
			if (zoomSrc) {
				makeZoomable(img, zoomSrc, document.getElementById(img.getAttribute("id") + "_zoom"), null, null, img.getAttribute("data-zoomalwaysshow")=="true");
			}
		}
	}
 */
	function initTagX(strTag) {
		var images = document.getElementsByTagName(strTag);
		for (var i=0;i<images.length;i++) {
			var img = images[i];
			var zoomSrc = img.getAttribute("data-zoomsrc");
			if (zoomSrc) {
				makeZoomable(img, zoomSrc, document.getElementById(img.getAttribute("id") + "_zoom"), null, null, img.getAttribute("data-zoomalwaysshow")=="true");
			}
		}
	}
	function initTagImg() {
		initTagX("img");
	}
	function initTagInput() {
		initTagX("input");
	}
	function init() {
//alert("MojoZoom.init");
    if(! this.isDone)
    {
		  this.isDone = true;
		  initTagImg();
		}
//  initTagInput();
	}

	return {
		addEvent : addEvent,
		init : init,
		makeZoomable : makeZoomable
	};

})();

MojoZoom.addEvent(window, "load", MojoZoom.init);

//
// imgswap.js:
//
//
// echo "王 ";
//
function MM_findObj(n, d) { //v3.0
  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); 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];}
}
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];}}
}

//
// tooltip.js:
//
//
// show/hide tooltip:
// tooltips must be created as DIV elements named as tt<number>:
//
//  <div CLASS="classTooltip" ID="tt1">
//    On considÃ¨re une nouvelle visite pour <b>chaque arrivÃ©e</b>
//    d'un visiteur consultant une page et ne s'Ã©tant pas connectÃ©
//    dans les derniÃ¨res <b>60 mn</b>.
//  </div>
//
// On Netscape, pass event as argument.
//
//
var tooltipVerMajor = parseInt(navigator.appVersion);

//
// ttx: a number in tt<ttx>
//
var gstrTooltipPrefix = "tt";
//
var gstrDivNameTooltipGgtrans = gstrTooltipPrefix + "Ggtrans";
var gstrDivNameTooltipPhotos = gstrTooltipPrefix + "Photos";
var gstrttPhotosInitialInnerHTML = "";
//
// AJAX:
//
var gobjttxhr = null;
var gstrttPhotosImagePath = "";

//
// get tooltip object according to the div ID:
//
function ttGetTooltipObjectByID(strID)
{
  return document.getElementById(strID);
}

//
// get tooltip object according to the div ID:
//
function ttGetTooltipNameByNumber(ttx)
{
  return gstrTooltipPrefix + ttx;
}

//
// get tooltip object according to the div ID:
//
function ttGetTooltipObject(ttx)
{
  return ttGetTooltipObjectByID(ttGetTooltipNameByNumber(ttx));
}
 
//
// show tooltip object according to the number:
//
function ttShowTooltipByID(strID, evt)
{
  var tooltipOBJ = ttGetTooltipObjectByID(strID);
//
// nothing to do if no object:
//
  if(tooltipOBJ == null)
  {
    return;
  }
//
  var tooltipWidthMin = 200;
  var tooltipHeightMin = 200;
  var testLeft, tooltipAbsLft;
  var testTop, tooltipAbsTop;
  var xmax, IsXCorrected;
//
// Netscape: now we set false for Google Chrome, IE, true for Firefox:
//
//
// Google Chrome, Netscape, Firefox, Safari pass through here,
// IE9 also has .pageX:
//
//if(brwIsIso())
//
  if(evt.pageX)
  {
    tooltipAbsLft = evt.pageX + 1;
    tooltipAbsTop = evt.pageY + 1;
    tooltipOBJ.style.left = tooltipAbsLft + "px";
    tooltipOBJ.style.top = tooltipAbsTop + "px";
    tooltipOBJ.style.display = "block";
  }
//
// IE 4 or above, Google Chrome have this:
//
  else
  {
//
//  get .pageX and .pageY equivalences on old IE:
//
    tooltipAbsLft = document.body.scrollLeft + event.clientX + 1;
    tooltipAbsTop = document.body.scrollTop + window.event.clientY + 1;
    tooltipOBJ.style.posLeft = tooltipAbsLft;
    tooltipOBJ.style.posTop = tooltipAbsTop;
    tooltipOBJ.style.display = "block";
  }
//alert("ttShowTooltipByID() tooltipAbsTop="+tooltipAbsTop);
}

//
// show tooltip object according to the number:
//
function ttShowTooltip(ttx, evt)
{
  return ttShowTooltipByID(ttGetTooltipNameByNumber(ttx), evt);
}

//
// hide tooltip by ID:
//
function ttHideTooltipByID(strID)
{
  var tooltipOBJ = ttGetTooltipObjectByID(strID);
  return domHideObject(tooltipOBJ);
}

//
// hide tooltip by number:
//
function ttHideTooltip(ttx)
{
  return ttHideTooltipByID(ttGetTooltipNameByNumber(ttx));
}

/*
 * fnc001: replace contents of the sub-element txt2Replace:
 */
function ttReplaceContentsByID(strID, CountryRef, lang)
{
  var strMsg;
  var xobj;
  xobj = document.getElementById(strID)
  xobj = xobj.document.getElementById("txt2Replace")
//
//alert(xobj.firstChild.data);
//
  strMsg = locGetCountryInfoLocal(CountryRef, lang);
  xobj.firstChild.data = strMsg;
//
  return 1;
}

//
// fnc001: replace contents of the sub-element txt2Replace:
//
function ttReplaceContents(ttx, CountryRef, lang)
{
  return ttReplaceContentsByID(ttGetTooltipNameByNumber(ttx), CountryRef, lang);
}

//***********************************************************************
// Tooltip photos                                                       *
//***********************************************************************
//
// get tooltip object photos object:
//
function ttGetTooltipPhotosObject()
{
  return ttGetTooltipObjectByID(gstrDivNameTooltipPhotos);
}

//
// get tooltip object photos:
//
function ttGetTooltipPhotosInnerHTML()
{
  var tooltipOBJ = ttGetTooltipPhotosObject();
//
// nothing to do if no object:
//
  if(tooltipOBJ == null)
  {
    return "";
  }
//
  return tooltipOBJ.innerHTML;
}
//
// set tooltip object photos:
//
function ttSetTooltipPhotosInnerHTML(strHTML)
{
  var tooltipOBJ = ttGetTooltipPhotosObject();
//
// nothing to do if no object:
//
  if(tooltipOBJ == null)
  {
    return;
  }
//
  domSetElementContentsByObject(tooltipOBJ, strHTML);
  return true;
}

//
// fnc001: doXhrGetttPhotos():
//
function ttPhotosSetGlobal(strInnerHTML)
{
  gstrttPhotosInitialInnerHTML = strInnerHTML;
  return true;
}
//
// save tooltip object photos:
//
function ttSaveTooltipPhotosInnerHTML()
{
  ttPhotosSetGlobal(ttGetTooltipPhotosInnerHTML());
  return 1;
}
//
// restore tooltip object photos:
//
function ttRestoreTooltipPhotosInnerHTML()
{
  return ttSetTooltipPhotosInnerHTML(gstrttPhotosInitialInnerHTML);
}

//
// set tooltip object photos:
//
function ttSetTooltipPhotosImage(strUrl)
{
  doXhrGetttPhotos(strUrl);
  return 1;
}

//
// set tooltip object photos by TTF string:
//
function ttGetTooltipPhotosImageTTFImageUrl(strIn)
{
  return nvlPrependStoreDir("ttfimage.php") + "?q=" + strIn;
}

//
// set tooltip object photos by TTF string:
//
function ttSetTooltipPhotosImageByTTFString(strIn)
{
  var strUrl = ttGetTooltipPhotosImageTTFImageUrl(strIn);
  ttSaveTooltipPhotosInnerHTML();
  return ttSetTooltipPhotosImage(strUrl);
}

//
// show tooltip object photos:
//
function ttShowTooltipPhotos(strUrl, evt)
{
	ttSetTooltipPhotosImage(strUrl);
  return ttShowTooltipByID(gstrDivNameTooltipPhotos, evt);
}

//
// show tooltip object photos by TTF string:
//
function ttShowTooltipPhotosImageByTTFString(strIn, evt)
{
  var strUrl = ttGetTooltipPhotosImageTTFImageUrl(strIn);
  return ttShowTooltipPhotos(strUrl, evt);
}

//
// show tooltip object photos:
//
function ttShowTooltipPhotosInfoUrl(strUrl, evt)
{
	ajaxGetInfoUrl(strUrl);
  return ttShowTooltipByID(gstrDivNameTooltipPhotos, evt);
}

//
// show tooltip object photos by filling with innerHTML:
//
function ttShowTooltipPhotosInfoInnerHTML(strInnerHTML, evt)
{
	ttSetTooltipPhotosInnerHTML(strInnerHTML);
  return ttShowTooltipByID(gstrDivNameTooltipPhotos, evt);
}

//
// show tooltip object photos:
//
function ttShowTooltipPhotosInfoIFrameUrl(strUrl, evt)
{
	ttPhotosInit();
	domSetElementContentsById("ttPhotos",
	  "<iframe src=\"" + strUrl + "\" style=\"width: 650px; height: 500px;\"></iframe>");
  return ttShowTooltipByID(gstrDivNameTooltipPhotos, evt);
}
//
// show tooltip object photos:
//
function ttShowTooltipPhotosInfoIFrameUrlById(strID, evt)
{
	var strUrl;
	strUrl = nvlPrependGgtransDir("ggtapi.php");
	strUrl = appendUrlArg1(strUrl,
	  "ajaxcontentsonly=1&q=" + domGetElementContentsById(strID));
  return ttShowTooltipPhotosInfoIFrameUrl(strUrl, evt);
}

//
// show tooltip object photos:
//
function ttShowTooltipGgtransByText(strText, evt)
{
	ttShowTooltipByID(gstrDivNameTooltipGgtrans, evt);
  return ggtTranslateDirectFromDetect2All(strText);
}
//
// show tooltip object photos:
//
function ttShowTooltipGgtransByObject(xobj, evt)
{
  return ttShowTooltipGgtransByText(
   domGetElementContentsByObject(xobj), evt);
}
//
// show tooltip object photos:
//
function ttShowGSE(evt)
{
//alert("evt.srcElement=" + evt.srcElement+",evt.target="+evt.target);
  return ttShowTooltipGgtransByObject(winGetEventSrcElement(evt), evt);
}
//
// show tooltip object photos:
//
function ttShowTooltipGgtransById(strID, evt)
{
  return ttShowTooltipGgtransByText(
    domGetElementContentsById(strID), evt);
}

//
// hide tooltip ggtrans:
//
function ttHideTooltipGgtrans()
{
  return ttHideTooltipByID(gstrDivNameTooltipGgtrans);
}

//
// hide tooltip photos:
//
function ttHideTooltipPhotos()
{
  return ttHideTooltipByID(gstrDivNameTooltipPhotos);
}

//
// fnc001: handle HTTP response:
//
 function ttPhotosHandleHttpResponse()
 {
//
  if(gobjttxhr)
  {
//  if(gobjttxhr.readyState == 4 && gobjttxhr.status == 200)
    if(gobjttxhr.readyState == 4)
    {
//    var istatus = gobjttxhr.status;
//
//    alert(strText + " i=" + i);
//
      var strHTML = "<img src='" + gstrttPhotosImagePath + "' />";
      ttSetTooltipPhotosInnerHTML(strHTML);
//
    }
  }
}

//
// fnc001: doXhrGetttPhotos():
//
function ttPhotosInit()
{
  if(gstrttPhotosInitialInnerHTML == "")
  {
  	ttSaveTooltipPhotosInnerHTML();
  }
  return true;
}

//
// fnc001: doXhrGetttPhotos():
//
function doXhrGetttPhotos(strUrl)
{
//
  ttPhotosInit();
//
  gobjttxhr = getXhrObjectGlobal();
/*
 * gobjttxhr OK:
 */
  if(gobjttxhr)
  {
//
    gstrttPhotosImagePath = strUrl;
//
//  ttSetTooltipPhotosInnerHTML("Chargement...");
//
    ttRestoreTooltipPhotosInnerHTML();
/*
 * set callback:
 */
    gobjttxhr.onreadystatechange = ttPhotosHandleHttpResponse;
/*
 * reading:
 */
    gobjttxhr.open("GET", strUrl, true);
/*
 * go request:
 */
    gobjttxhr.send(null);
  }
}

//
// popto.js:
//
//poptoBackDir = new String(window.location);
//if(poptoBackDir.indexOf("http:") >= 0)
//{
//  poptoBackDir = "/";
//}
//else
//{
//  poptoBackDir = "../";
//}
poptoBackDir = "../";

poptoLocation = "logo.htm";

function poptoSlideUrl(url)
{
  if(top.frames["fraLogo"])
  {
    top.frames["fraLogo"].location = url;
  }
  return true;
}
function poptoDown()
{
  if(top.frames["fraLogo"])
  {
    top.frames["fraLogo"].location = poptoBackDir + poptoLocation;
  }
  return 1;
}
function poptoSlide(url)
{
  poptoLocation = "logo.htm";
  return poptoSlideUrl(url);
}
function poptoSlideCn()
{
  poptoLocation = "logo_cn.htm";
  return poptoSlideUrl("popslcn.htm");
}
function poptoSlideEn()
{
  poptoLocation = "logo_en.htm";
  return poptoSlideUrl("popslen.htm");
}
function poptoSlideFr()
{
  poptoLocation = "logo.htm";
  return poptoSlideUrl("popslfr.htm");
}

//
// popup.js:
//
/*
 * locationType: 0: top left corner at the mouse.
 * 3: right botton corner at the mouse.
 */

/*
 * locationType: 0: top left corner at the mouse.
 * 3: right botton corner at the mouse.
 */
function popupInfoLocation(evt, url, timeout, locationType)
{
  var x, y, width, height;
  width = 220;
  height = 300;

  if(brOK)
  {
    if(brwIsIE())
    {
      if(evt == null)
      {
        evt = window.event;
      }
    }
    if(evt)
    {
      x = evt.screenX;
      y = evt.screenY;
      if(locationType == 3)
      {
        x -= width;
        y -= height;
      }
    }
    else
    {
      x = screen.width - width - 10;
      y = 1;
    }
    x = "left=" + x + ",top=" + y + ",";
  }
  else
  {
    x = "";
  }
  x += "width=" + width + ",height=" + height;
  x += ",scrollbars=yes";
  winInfo = window.open(url, "winPopInfo", x);
  if(timeout != null)
  {
    setTimeout("winInfoClose()", timeout);
  }
  return true;
}

function popupInfo(evt, url, timeout)
{
  return popupInfoLocation(evt, url, timeout, 0);
}

function popupInfoRightBottom(evt, url, timeout)
{
  return popupInfoLocation(evt, url, timeout, 3);
}

//
// fnc001: get window.event.srcElement like under IE:
//   IE, Google Chrome have .srcElement, but not FireFox:
//
function winGetEventSrcElement(evt)
{
	var evtNow;
	if(evt)
	{
		evtNow = evt;
	}
	else
	{
	  evtNow = window.event;;
	}
	if(evtNow)
	{
	  if(evtNow.srcElement)
	  {
		  return evtNow.srcElement;
	  }
	  else
	  {
		  return evtNow.target;
	  }
  }
  else
  {
	  return null;
	}
}
//
// fnc001: get window.event.srcElement like under IE:
//   IE, Google Chrome have .srcElement, but not FireFox:
//
function winGetEventSrcElementID(evt)
{
	var eSrc = winGetEventSrcElement(evt);
	if(eSrc)
	{
		return eSrc.id;
	}
	else
	{
		return "";
	}
}

function winInfoClose()
{
  if(winInfo != null)
  {
    if(! winInfo.closed)
    {
      winInfo.close();
      winInfo = null;
    }
  }
  return;
}

function popdownInfo()
{
  return winInfoClose();
}

function popupSlideUrl(evt, url)
{
  var x, y, width, height;
  width = 150;
  height = 180;
  if(brOK)
  {
    if(brwIsIE())
    {
      if(evt == null)
      {
        evt = window.event;
      }
    }
    if(evt)
    {
      x = evt.screenX;
      y = evt.screenY;
    }
    else
    {
      x = screen.width - width - 50;
      y = 1;
    }
    x = "left=" + x + ",top=" + y + ",";
  }
  else
  {
    x = "";
  }
  x += "width=" + width + ",height=" + height;
  winPop = window.open(url, "winPopSlide", x);
  return true;
}
function popdownSlide()
{
  if(winPop != null)
  {
    if(! winPop.closed)
    {
      winPop.close();
    }
  }
  return 1;
}
function popupSlide(evt, url)
{
  return popupSlideUrl(evt, url);
}
function popupSlideCn(evt)
{
  return popupSlideUrl(evt, "popslcn.htm");
}
function popupSlideEn(evt)
{
  return popupSlideUrl(evt, "popslen.htm");
}
function popupSlideFr(evt)
{
  return popupSlideUrl(evt, "popslfr.htm");
}

// iPos: 0=mouse, 1=top-left, 2=top-right, 3=bottom-right, 4=bottom-left.
function msgBox(evt, strMsg, strTitle, strClose, iPos, width0, height0)
{
  var x, y, width, height;
  var w, d, winnam;
//
  if(width0 == null)
  {
    width = 250;
  }
  else
  {
    width = width0;
  }
//
  if(height0 == null)
  {
    height = 380;
  }
  else
  {
    height = height0;
  }
// 1=top-left:
  if(iPos == 1)
  {
    ;
  }
// 2=top-right:
  else if(iPos == 2)
  {
    x = screen.width - width - 10;
    x = "left=" + x + ",";
  }
//  3=bottom-right:
  else if(iPos == 3)
  {
    x = screen.width - width - 10;
    y = screen.height - height - 10;
    x = "left=" + x + ",top=" + y + ",";
  }
//  4=bottom-left:
  else if(iPos == 4)
  {
    y = screen.height - height - 10;
    x = "top=" + y + ",";
  }
// mouse:
  else
  {
    if(brOK)
    {
      // NS:
      if(isNS)
      {
      }
      // IE:
      else
      {
        evt = window.event;
      }
      //
      if(evt == null)
      {
        x = screen.width - width - 10;
        y = 0;
      }
      else
      {
        x = evt.screenX;
        y = evt.screenY;
      }
      //
      if(x + width > screen.width)
      {
        x = screen.width - width - 10;
      }
      //
      y -= height;
      y = y < 0 ? 0 : y;
      //
      x = "left=" + x + ",top=" + y + ",";
    }
    else
    {
      x = "";
    }
  }
//
  x += "width=" + width + ",height=" + height;
  x += ",scrollbars=yes";
  winnam = "msgBox";
  w = window.open("", winnam, x);
//
  if(strTitle == null)
  {
    strTitle = "Message Box";
  }
//
//w.resizeTo(800, 600);
//
// this does not work under Opera,
// as it does not returns the document object:
//
// d = w.document.open("text/html");
//
  w.document.open("text/html");
//
// so use this:
//
  d = w.document;
//
  if(strClose == null)
  {
    strClose = "Close";
  }
//
  d.write("<html>\n\
<head>\n\
<title>" + strTitle + "</title>\n\
<style type=\"text/css\">\n\
<!--\n\
body {background-color: #ffff00; font-size: 10pt;}\n\
form {text-align: center;}\n\
h1 {color: red; text-align: center;}\n\
input {font-size: 8pt;}\n\
.button {\n\
  border-right: #ffff99 1px solid;\n\
  border-top: #ffff99 1px solid;\n\
  border-left: #ff66dd 1px solid;\n\
  border-bottom: #ff66dd 1px solid;\n\
  background-color: #ff00cc;\n\
  color: #ffff00;\n\
  font-weight: bold;\n\
  font-size: 8pt;\n\
  cursor: hand;\n\
}\n\
-->\n\
</style>\n\
</head>\n\
<body>\n\
<h1>" + strTitle + "</h1>\n\
" + strMsg + "\n\
<form name=\"frmNavigate\">\n\
<input type=\"button\" name=\"cmdClose\" class=\"button\" value=\"" + strClose + "\" onclick=\"window.close()\" onmouseover=\"this.style.backgroundColor='#ff0000'\" onmouseout=\"this.style.backgroundColor=''\" />\n\
</form>\n\
</body>\n\
</html>\n\
");
//
  d.close();
//
  w.focus();
//
  if(d.frmNavigate.cmdClose)
  {
    d.frmNavigate.cmdClose.focus();
  }
//
  return w;
}

function msgBoxTopRight(evt, strMsg, strTitle, strClose)
{
  return msgBox(evt, strMsg, strTitle, strClose, 2);
}

 function msgBoxBgcolor(strMsg, strFore)
{
  var w, d, winnam, strBgcolor;
//
  strBgcolor = strMsg;
  winnam = "msgBox";
//alert("Window name: " + winnam);
  w = window.open("", winnam, "width=600,height=500");
//  w.resizeTo(600, 500);
  w.document.open("text/html");
  d = w.document;
  d.write("<html>\n\
<head>\n\
<title>Message Box</title>\n\
<style type=\"text/css\">\n\
<!--\n\
H1 {color: red; text-align: center}\n\
input {font-size: 8pt}\n\
.button {\n\
  border-right: #ffff99 1px solid;\n\
  border-top: #ffff99 1px solid;\n\
  border-left: #ff66dd 1px solid;\n\
  border-bottom: #ff66dd 1px solid;\n\
  background-color: #ff00cc;\n\
  color: #ffff00;\n\
  font-weight: bold;\n\
  font-size: 8pt;\n\
  cursor: hand;\n\
}\n\
-->\n\
</style>\n\
</head>\n\
<body text=\"" + strFore + "\" bgcolor=\"" + strBgcolor + "\">\n\
<h1 style=\"color: " + strFore + "\">Message Box</h1>\n\
" + strMsg + "\n\
<form name=\"frmNavigate\">\n\
<input type=\"button\" name=\"cmdBack\" class=\"button\" value=\"Back\" onclick=\"history.go(-1)\" onmouseover=\"this.style.backgroundColor='#ff0000'\" onmouseout=\"this.style.backgroundColor=''\" />\n\
<input type=\"button\" name=\"cmdClose\" class=\"button\" value=\"Close\" onclick=\"window.close()\" onmouseover=\"this.style.backgroundColor='#ff0000'\" onmouseout=\"this.style.backgroundColor=''\" />\n\
<input type=\"button\" name=\"cmdBlur\" class=\"button\" value=\"Blur\" onclick=\"window.blur()\" onmouseover=\"this.style.backgroundColor='#ff0000'\" onmouseout=\"this.style.backgroundColor=''\" />\n\
</form>\n\
</body>\n\
</html>\n\
");
//
  d.close();
  w.focus();
  return w;
}

//useless:
if(nsOK)
{
//document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
//document.onmouseover = routeEvent;
//document.onmouseout = routeEvent;
}

//
// BEGIN locale.js: automatically generated by genlocalejs.php: 06-APR-2011 14:56:35.
//
//
// echo "王 ";
//
function locGetCountryNameLocal(CountryRef, lang)
{
//
  if(lang == "fr")
  {
    var c = {
0:"Monde",
1:"Afghanistan",
2:"Albanie",
3:"Algérie",
4:"Samoa Americaines",
5:"Andorre",
6:"Angola",
7:"Anguilla",
8:"Antarctique",
9:"Antigua-et-Barbuda",
10:"Argentine",
11:"Arménie",
12:"Aruba",
13:"Iles d'Ashmore & Cartier",
14:"Australie",
15:"Autriche",
16:"Azerbaïdjan",
17:"Açores",
18:"Bahamas",
19:"Bahreïn",
20:"Ile Baker",
21:"Bangladesh",
22:"Barbade",
23:"Bassas da India",
24:"Biélorussie",
25:"Belgique",
26:"Belize",
27:"Bénin",
28:"Bermudes",
29:"Bhoutan",
30:"Bolivie",
31:"Bosnie-Herzégovine",
32:"Botswana",
33:"Ile Bouvet",
34:"Territoire Britanique Océan Indien",
35:"Brésil",
36:"Brunei",
37:"Bulgarie",
38:"Burkina Faso",
39:"Birmanie",
40:"Burundi",
41:"Cambodge",
42:"Cameroun",
43:"Canada",
44:"Canarie (îles)",
45:"Cap-Vert",
46:"Ils Caïmans",
47:"CentrAfricaine (République)",
48:"Tchad",
49:"Chili",
50:"Chine",
51:"Ile Christmas (Océan Indien)",
53:"Ile de Clipperton",
54:"Iles Cocos-Keeling",
55:"Colombie",
56:"Comores",
57:"Congo",
58:"Cook (îles)",
59:"Iles de la Mer Corail",
60:"Costa Rica",
61:"Côte d'Ivoire",
62:"Croatie",
63:"Cuba",
64:"Chypre",
65:"Tchèque (République)",
66:"Danemark",
67:"Djibouti",
68:"Dominique",
69:"Dominicaine (République)",
70:"Equateur",
71:"Egypte",
72:"El Salvador",
73:"Guinée équatoriale",
74:"Erythrée",
75:"Estonie",
76:"Ethiopie",
77:"Ile d'Europe",
78:"Falkland (îles Malouines)",
79:"Féroé (îles)",
80:"Fidji",
81:"Finlande",
82:"France",
83:"Guyane française",
84:"Polynésie française",
85:"Terres Australes et antarctiques françaises",
86:"Gabon",
87:"Gambie",
88:"Bande de Gaza",
89:"Géorgie",
90:"Allemagne",
91:"Ghana",
92:"Gibraltar",
93:"Iles Glorieuses",
94:"Grèce",
95:"Groënlande",
96:"Grenade",
97:"Guadeloupe",
98:"Guam",
99:"Guatemala",
100:"Guernsey",
101:"Guinée",
102:"Guinée-Bissau",
103:"Guyana",
104:"Haïti",
105:"Ile Heard & Iles McDonald",
106:"Honduras",
107:"Hong Kong",
108:"Ile Howland",
109:"Hongrie",
110:"Islande",
111:"Inde",
112:"Indonésie",
113:"Iran",
114:"Iraq",
116:"Irlande",
117:"Ile de Man",
118:"Israël",
119:"Italie",
120:"Jamaïque",
121:"Jan Mayen",
122:"Japon",
123:"Jersey",
124:"Atoll Johnston",
125:"Jordanie",
126:"Ile Juan de Nova",
127:"Kazakhstan",
128:"Kenya",
129:"Récif Kingman",
130:"Kiribati",
131:"Corée du Nord",
132:"Corée du Sud",
133:"Koweït",
134:"Kirghizstan",
135:"Laos",
136:"Lettonie",
137:"Liban",
138:"Lesotho",
140:"Liberia",
141:"Libye",
142:"Liechtenstein",
143:"Lituanie",
144:"Luxembourg",
145:"Macao",
146:"Macédoine",
147:"Madagascar",
148:"Madère",
149:"Malawi",
150:"Malaisie",
151:"Maldives",
152:"Mali",
153:"Malte",
154:"Marshall (îles)",
155:"Martinique",
156:"Mauritanie",
157:"Maurice (îles)",
158:"Mayotte",
159:"Mexique",
160:"Micronésie",
161:"Iles de Midway",
162:"Moldavie",
163:"Monaco",
164:"Mongolie",
165:"Montenégro",
166:"Montserrat",
167:"Maroc",
168:"Mozambique",
169:"Namibie",
170:"Nauru",
171:"Ile Navassa",
172:"Népal",
173:"Pays-Bas",
174:"Antilles néerlandaises",
175:"Nouvelle-Calédonie",
176:"Nouvelle-Zélande",
177:"Nicaragua",
178:"Niger",
179:"Nigeria",
180:"Niue",
181:"Norfolk Island",
182:"Irlande du Nord",
183:"Mariannes (îles de)",
184:"Norvège",
185:"Oman",
186:"Pakistan",
187:"Atoll Palmyra",
188:"Panama",
189:"Papouasie-Nouvelle-Guinée",
190:"Iles Paracel",
191:"Paraguay",
192:"Pérou",
193:"Philippines",
194:"Pitcairn Islands",
195:"Pologne",
196:"Portugal",
197:"Porto Rico",
198:"Qatar",
199:"O Té la Réunion",
200:"Roumanie",
201:"Russie",
202:"Rwanda",
203:"Sahara d'Ouest",
204:"Samoa Occidental",
205:"Saint-Marin",
206:"Sao Tomé-et-Principe",
207:"Arabie Saoudite",
208:"Sénégal",
209:"Serbie-et-Monténégro",
210:"Seychelles",
211:"Sierra Leone",
212:"Singapour",
213:"Slovaquie",
214:"Slovénie",
215:"Salomon",
216:"Somalie",
217:"Afrique du Sud",
218:"Georgie du Sud",
220:"Espagne",
221:"Iles de Spratly",
222:"Sri Lanka",
223:"Sainte Hélène",
224:"Saint-Christophe-et-Niévès",
225:"Sainte-Lucie",
226:"St. Pierre et Miquelon",
227:"Saint-Vincent-et-les Grenadines",
228:"Soudan",
229:"Suriname",
230:"Svalbard",
231:"Swaziland",
232:"Suède",
233:"Suisse",
234:"Syrie",
235:"Taïwan",
236:"Tadjikistan",
237:"Tanzanie",
238:"Thaïlande",
239:"Timor Oriental",
240:"Togo",
241:"Tokelau",
242:"Tonga",
243:"Trinité-et-Tobago",
244:"Ile de Tromelin",
245:"Trust Territory of Pacific Islands",
246:"Tunisie",
247:"Turquie",
248:"Turkménistan",
249:"Turks et Caicos  (îles)",
250:"Tuvalu",
251:"Ouganda",
252:"Ukraine",
253:"Emirats Arabes Unis",
254:"Royaume-Uni",
255:"Etats-Unis d'Amérique",
256:"Uruguay",
257:"Ouzbékistan",
258:"Vanuatu",
259:"Vatican",
260:"Venezuela",
261:"Vietnam",
262:"Vierges/Britanniques (îles)",
263:"Vierges/Américaines (îles)",
264:"Ile Wake",
265:"Wallis et Futuna",
266:"West Bank",
267:"Yémen",
268:"Congo (République Démocratique du)",
269:"Zambie",
270:"Zimbabwe",
271:"ZZZ Autre",
272:"Palaos",
273:"Paléstine",
274:"Somaliland",
275:"Tibet",
276:"Ile Jarvis",
277:"Tristan da Cunha",
278:"Iles Aaland",
401:"Sicile",
402:"Kosovo",
501:"Union Européenne",
502:"France Totale",
503:"Océan Boréal",
504:"Océan Pacific",
505:"Océan Indian",
506:"Océan Atlantic",
507:"Océan du Sud",
601:"Afrique"
    };
  }
  else if(lang == "cn")
  {
    var c = {
0:"全世界",
1:"阿富汗",
2:"阿尔巴尼亚",
3:"阿尔及利亚",
4:"美属萨摩亚",
5:"安道尔",
6:"安哥拉",
7:"安圭拉",
8:"南极大陆",
9:"安提瓜 和 巴布达",
10:"阿根廷",
11:"亚美尼亚",
12:"阿卢巴岛",
13:"阿什毛和卡提叶群岛",
14:"澳大利亚",
15:"奥地利",
16:"阿塞拜疆共和国",
17:"亚什群岛",
18:"巴哈马",
19:"巴林",
20:"贝克岛",
21:"孟加拉国",
22:"巴贝多",
23:"印度巴撒岛",
24:"白俄罗斯",
25:"比利时",
26:"伯了兹",
27:"贝宁",
28:"百慕达群岛",
29:"不丹",
30:"玻利维亚",
31:"波斯尼亚和黑塞哥维那",
32:"波扎那",
33:"布凡岛",
34:"英国印度洋领地",
35:"巴西",
36:"文莱达鲁萨兰国",
37:"保加利亚",
38:"布基纳法索",
39:"缅甸",
40:"蒲隆地",
41:"柬埔寨",
42:"喀麦隆",
43:"加拿大",
44:"卡那利群岛",
45:"佛得角",
46:"凯门群岛",
47:"中非共和国",
48:"乍得",
49:"智利",
50:"中国",
51:"印度洋耶稣岛",
53:"克里普顿岛",
54:"椰子群岛",
55:"哥伦比亚",
56:"克么罗群岛",
57:"刚果共和国",
58:"苦克群岛",
59:"珊瑚群岛",
60:"哥斯大黎加",
61:"科特迪瓦",
62:"克罗地亚",
63:"古巴",
64:"塞浦路斯",
65:"捷克共和国",
66:"丹麦",
67:"吉布提",
68:"多明尼加",
69:"多米尼加共和国",
70:"厄瓜多尔",
71:"埃及",
72:"萨尔瓦多",
73:"赤道几内亚",
74:"厄立特里亚",
75:"爱沙尼亚",
76:"埃塞俄比亚",
77:"欧罗巴岛",
78:"福克兰群岛",
79:"发雷群岛",
80:"斐濟",
81:"芬兰",
82:"法国",
83:"法属圭亚那",
84:"法属千岛群岛",
85:"法国南极领地",
86:"加蓬",
87:"冈比亚",
88:"加沙地带",
89:"格鲁吉亚",
90:"德国",
91:"加纳",
92:"及布罗陀",
93:"格罗所群岛",
94:"希腊",
95:"格陵兰",
96:"格林纳达",
97:"瓜得罗普岛",
98:"关岛",
99:"危地马拉",
100:"格西",
101:"几内亚",
102:"几内亚比绍",
103:"圭亚那",
104:"海地",
105:"何德和麦当劳群岛",
106:"洪都拉斯",
107:"香港",
108:"和兰岛",
109:"匈牙利",
110:"冰岛",
111:"印度",
112:"印度尼西亚",
113:"伊朗",
114:"伊拉克",
116:"爱尔兰",
117:"人岛",
118:"以色列",
119:"意大利",
120:"牙买加",
121:"江马因岛",
122:"日本",
123:"爵西岛",
124:"约翰逊岛",
125:"约旦",
126:"俊诺瓦岛",
127:"哈萨克斯坦",
128:"肯尼亚",
129:"王家岩石岛",
130:"基里巴斯",
131:"北朝鲜",
132:"韩国",
133:"科威特",
134:"吉尔吉斯斯坦",
135:"老挝",
136:"拉脫維亞",
137:"黎巴嫩",
138:"赖索托",
140:"利比里亚",
141:"利比亚",
142:"列支敦斯登",
143:"立陶宛",
144:"卢森堡",
145:"澳门",
146:"马其顿",
147:"马达加斯加",
148:"马得岛",
149:"马拉威",
150:"马来西亚",
151:"马尔代夫",
152:"马里",
153:"马耳他",
154:"元帅群岛",
155:"马丁尼克岛",
156:"毛利塔尼亚",
157:"毛里求斯",
158:"马要特",
159:"墨西哥",
160:"细岛群岛",
161:"中途岛",
162:"摩尔多瓦",
163:"摩纳哥",
164:"蒙古",
165:"黑山",
166:"蒙次拉",
167:"摩洛哥",
168:"莫桑比克",
169:"纳米比亚",
170:"瑙鲁",
171:"那瓦沙岛",
172:"尼泊尔 ",
173:"荷兰",
174:"荷属中美洲岛",
175:"新喀里多尼亚",
176:"新西兰",
177:"尼加拉瓜",
178:"尼日尔",
179:"尼日利亚",
180:"牛岛",
181:"诺福克岛",
182:"北爱尔兰",
183:"北玛丽亚娜群岛",
184:"挪威",
185:"阿曼 ",
186:"巴基斯坦 ",
187:"帕尔米拉岛",
188:"巴拿马",
189:"巴布亚新几内亚",
190:"小包群岛",
191:"巴拉圭",
192:"秘鲁",
193:"菲律宾",
194:"劈开群岛",
195:"波兰",
196:"葡萄牙",
197:"波多黎各",
198:"卡塔尔",
199:"团结岛",
200:"罗马尼亚",
201:"俄罗斯",
202:"卢旺达",
203:"西撒哈拉沙漠",
204:"萨摩亚",
205:"圣马力诺",
206:"圣多美和普林西比",
207:"沙特阿拉伯",
208:"塞内加尔",
209:"塞尔维亚及蒙特尼哥罗",
210:"塞舌尔",
211:"塞拉利昂",
212:"新加坡",
213:"斯洛伐克",
214:"斯洛文尼亚",
215:"所罗门群岛",
216:"索马里",
217:"南非 ",
218:"南乔治岛",
220:"西班牙",
221:"西沙群岛",
222:"斯里兰卡",
223:"圣海伦岛",
224:"圣基茨和尼维斯",
225:"圣卢西亚",
226:"圣皮尔岛",
227:"圣文森特和格林纳丁斯",
228:"苏丹",
229:"苏里南",
230:"斯瓦尔巴德岛",
231:"史瓦济兰",
232:"瑞典",
233:"瑞士",
234:"叙利亚",
235:"台湾",
236:"塔吉克斯坦",
237:"坦桑尼亚",
238:"泰国",
239:"东帝汶",
240:"多哥",
241:"托克罗",
242:"汤加",
243:"特立尼达和多巴哥",
244:"托姆林岛",
245:"信任地群岛",
246:"突尼斯",
247:"土耳其",
248:"土库曼",
249:"图克和凯可群岛",
250:"吐瓦鲁",
251:"乌干达",
252:"乌克兰",
253:"阿拉伯联合酋长国",
254:"英国",
255:"美国",
256:"乌拉圭",
257:"乌兹别克斯坦",
258:"瓦努阿图",
259:"梵帝冈",
260:"委内瑞拉",
261:"越南",
262:"英属处女群岛",
263:"美属处女群岛",
264:"旋涡岛",
265:"瓦利斯和福图纳岛",
266:"西岸",
267:"也门",
268:"刚果民主共和国",
269:"赞比亚",
270:"辛巴威",
271:"其他国家",
272:"帕罗",
273:"巴勒斯坦 ",
274:"索马里兰",
275:"西藏",
276:"佳维岛",
277:"特利斯坦.达.库纳岛",
278:"阿兰群岛",
401:"西西里",
402:"科索沃",
501:"欧盟",
502:"法国+海外领地",
503:"北冰洋",
504:"太平洋",
505:"印度洋",
506:"大西洋",
507:"南洋",
601:"非洲"
    };
  }
  else
  {
    var c = {
0:"World",
1:"Afghanistan",
2:"Albania",
3:"Algeria",
4:"American Samoa",
5:"Andorra",
6:"Angola",
7:"Anguilla",
8:"Antarctica",
9:"Antigua and Barbuda",
10:"Argentina",
11:"Armenia",
12:"Aruba",
13:"Ashmore and Cartier Islands",
14:"Australia",
15:"Austria",
16:"Azerbaijan",
17:"Azores",
18:"Bahamas, The",
19:"Bahrain",
20:"Baker Island",
21:"Bangladesh",
22:"Barbados",
23:"Bassas da India",
24:"Belarus",
25:"Belgium",
26:"Belize",
27:"Benin",
28:"Bermuda",
29:"Bhutan",
30:"Bolivia",
31:"Bosnia and Herzegovina",
32:"Botswana",
33:"Bouvet Island",
34:"British Indian Ocean Territory",
35:"Brazil",
36:"Brunei",
37:"Bulgaria",
38:"Burkina Faso",
39:"Myanmar",
40:"Burundi",
41:"Cambodia",
42:"Cameroon",
43:"Canada",
44:"Canary Islands",
45:"Cape Verde",
46:"Cayman Islands",
47:"Central African Republic",
48:"Chad",
49:"Chile",
50:"China",
51:"Christmas Island",
53:"Clipperton Island",
54:"Cocos (Keeling) Islands",
55:"Colombia",
56:"Comoros",
57:"Congo",
58:"Cook Islands",
59:"Coral Sea Islands",
60:"Costa Rica",
61:"Ivory Coast",
62:"Croatia",
63:"Cuba",
64:"Cyprus",
65:"Czech Republic",
66:"Denmark",
67:"Djibouti",
68:"Dominica",
69:"Dominican Republic",
70:"Ecuador",
71:"Egypt",
72:"El Salvador",
73:"Equatorial Guinea",
74:"Eritrea",
75:"Estonia",
76:"Ethiopia",
77:"Europa Island",
78:"Falkland Islands (Islas Malvinas)",
79:"Faroe Islands",
80:"Fiji",
81:"Finland",
82:"France",
83:"French Guiana",
84:"French Polynesia",
85:"French Southern and Antarctic Lands",
86:"Gabon",
87:"Gambia, The",
88:"Gaza Strip",
89:"Georgia",
90:"Germany",
91:"Ghana",
92:"Gibraltar",
93:"Glorioso Islands",
94:"Greece",
95:"Greenland",
96:"Grenada",
97:"Guadeloupe",
98:"Guam",
99:"Guatemala",
100:"Guernsey",
101:"Guinea",
102:"Guinea-Bissau",
103:"Guyana",
104:"Haiti",
105:"Heard Island and McDonald Islands",
106:"Honduras",
107:"Hong Kong",
108:"Howland Island",
109:"Hungary",
110:"Iceland",
111:"India",
112:"Indonesia",
113:"Iran",
114:"Iraq",
116:"Ireland",
117:"Man, Isle of",
118:"Israel",
119:"Italy",
120:"Jamaica",
121:"Jan Mayen",
122:"Japan",
123:"Jersey",
124:"Johnston Atoll",
125:"Jordan",
126:"Juan de Nova Island",
127:"Kazakhstan",
128:"Kenya",
129:"Kingman Reef",
130:"Kiribati",
131:"Korea, North",
132:"Korea, South",
133:"Kuwait",
134:"Kyrgyzstan",
135:"Laos",
136:"Latvia",
137:"Lebanon",
138:"Lesotho",
140:"Liberia",
141:"Libya",
142:"Liechtenstein",
143:"Lithuania",
144:"Luxembourg",
145:"Macau",
146:"Macedonia",
147:"Madagascar",
148:"Madeira",
149:"Malawi",
150:"Malaysia",
151:"Maldives",
152:"Mali",
153:"Malta",
154:"Marshall Islands",
155:"Martinique",
156:"Mauritania",
157:"Mauritius",
158:"Mayotte",
159:"Mexico",
160:"Micronesia, Federated States of",
161:"Midway Islands",
162:"Moldova",
163:"Monaco",
164:"Mongolia",
165:"Montenegro",
166:"Montserrat",
167:"Morocco",
168:"Mozambique",
169:"Namibia",
170:"Nauru",
171:"Navassa Island",
172:"Nepal",
173:"Netherlands",
174:"Netherlands Antilles",
175:"New Caledonia",
176:"New Zealand",
177:"Nicaragua",
178:"Niger",
179:"Nigeria",
180:"Niue",
181:"Norfolk Island",
182:"Northern Ireland",
183:"Northern Mariana Islands",
184:"Norway",
185:"Oman",
186:"Pakistan",
187:"Palmyra Atoll",
188:"Panama",
189:"Papua New Guinea",
190:"Paracel Islands",
191:"Paraguay",
192:"Peru",
193:"Philippines",
194:"Pitcairn Islands",
195:"Poland",
196:"Portugal",
197:"Puerto Rico",
198:"Qatar",
199:"Reunion",
200:"Romania",
201:"Russia",
202:"Rwanda",
203:"Western Sahara",
204:"Samoa",
205:"San Marino",
206:"Sao Tome and Principe",
207:"Saudi Arabia",
208:"Senegal",
209:"Serbia",
210:"Seychelles",
211:"Sierra Leone",
212:"Singapore",
213:"Slovakia",
214:"Slovenia",
215:"Solomon Islands",
216:"Somalia",
217:"South Africa",
218:"South Georgia and the South Sandwich Islands",
220:"Spain",
221:"Spratly Islands",
222:"Sri Lanka",
223:"Saint Helena",
224:"Saint Kitts and Nevis",
225:"Saint Lucia",
226:"Saint Pierre and Miquelon",
227:"Saint Vincent and the Grenadines",
228:"Sudan",
229:"Suriname",
230:"Svalbard",
231:"Swaziland",
232:"Sweden",
233:"Switzerland",
234:"Syria",
235:"Taiwan",
236:"Tajikistan",
237:"Tanzania",
238:"Thailand",
239:"East Timor",
240:"Togo",
241:"Tokelau",
242:"Tonga",
243:"Trinidad and Tobago",
244:"Tromelin Island",
245:"Trust Territory of Pacific Islands",
246:"Tunisia",
247:"Turkey",
248:"Turkmenistan",
249:"Turks and Caicos Islands",
250:"Tuvalu",
251:"Uganda",
252:"Ukraine",
253:"United Arab Emirates",
254:"United Kingdom",
255:"United States of America",
256:"Uruguay",
257:"Uzbekistan",
258:"Vanuatu",
259:"Vatican City",
260:"Venezuela",
261:"Vietnam",
262:"Virgin Islands (UK)",
263:"Virgin Islands",
264:"Wake Island",
265:"Wallis and Futuna",
266:"West Bank",
267:"Yemen",
268:"Congo, Democratic Republic of the",
269:"Zambia",
270:"Zimbabwe",
271:"ZZZ Other",
272:"Palau",
273:"Palestine",
274:"Somaliland",
275:"Tibet",
276:"Jarvis Island",
277:"Tristan da Cunha Island",
278:"Aaland Islands",
401:"Sicily",
402:"Kosovo",
501:"European Union",
502:"France Total",
503:"Arctic Ocean",
504:"Pacific Ocean",
505:"Indian Ocean",
506:"Atlantic Ocean",
507:"Southern Ocean",
601:"Africa"
    };
  }
//
  return c[CountryRef];
//
}

function locGetCountryInfoLocal(CountryRef, lang)
{
  return locGetCountryNameLocal(CountryRef, lang);
}

function locPopupCountryInfo(CountryRef, lang)
{
  var strTitle, strMsg, strClose;
//
  strTitle = "";
//
  if(lang == "fr")
  {
    strClose = "Fermer";
  }
  else if(lang == "cn")
  {
    strClose = "关闭";
  }
  else
  {
    strClose = "Close";
  }
//
  strMsg = locGetCountryInfoLocal(CountryRef, lang);
//
  return msgBox(event, strMsg, strTitle, strClose, 0, 230, 100);
}
//
// END locale.js.
//

//
// fnc001: get tag local:
//
function locGetTagAccount()
{
	if(locIsLangLocalFr())
	{
  	return "Mon Compte";
}
	else if(locIsLangLocalCn())
 	{
  	return "我的户头";
 	}
 	else
 	{
  	return "My Account";
 	}
}

//
// fnc001: get tag local:
//
function locGetTagAutomaticTranslation()
{
	if(locIsLangLocalFr())
	{
  	return "Traduction Automatique";
}
	else if(locIsLangLocalCn())
 	{
  	return "自动翻译";
 	}
 	else
 	{
  	return "Automatic Translation";
 	}
}

//
// fnc001: get tag local:
//
function locGetTagBy()
{
	if(locIsLangLocalFr())
	{
  	return "Par";
  }
	else if(locIsLangLocalCn())
 	{
  	return "由";
 	}
 	else
 	{
  	return "By";
 	}
}

//
// fnc001: get tag local:
//
function locGetTagCancel()
{
	if(locIsLangLocalFr())
	{
  	return "Annuler";
  }
	else if(locIsLangLocalCn())
 	{
  	return "取消";
 	}
 	else
 	{
  	return "Cancel";
 	}
}

//
// fnc001: get tag local:
//
function locGetTagClose()
{
	if(locIsLangLocalFr())
	{
  	return "Fermer";
  }
	else if(locIsLangLocalCn())
 	{
  	return "关闭";
 	}
 	else
 	{
  	return "Close";
 	}
}

//
// fnc001: get tag local:
//
function locGetTagLoadingOr()
{
	if(locIsLangLocalFr())
	{
  	return "En train de charger ou";
  }
	else if(locIsLangLocalCn())
 	{
  	return "正在下载或者";
 	}
 	else
 	{
  	return "Loading or";
 	}
}

//
// fnc001: get tag local:
//
function locGetTagLogin()
{
	if(locIsLangLocalFr())
	{
  	return "Connexion";
  }
	else if(locIsLangLocalCn())
 	{
  	return "登录";
 	}
 	else
 	{
  	return "Sign in";
 	}
}

//
// fnc001: get tag local:
//
function locGetTagLogout()
{
	if(locIsLangLocalFr())
	{
  	return "Déconnexion";
  }
	else if(locIsLangLocalCn())
 	{
  	return "退出";
 	}
 	else
 	{
  	return "Sign out";
 	}
}

//
// fnc001: get tag local:
//
function locGetTagZeroClipboardHasContents()
{
	if(locIsLangLocalFr())
	{
  	return "Zéro Clipboard a du Contenu pour Coller";
  }
	else if(locIsLangLocalCn())
 	{
  	return "零键盘已经有内容供您去粘贴了。";
 	}
 	else
 	{
  	return "Zero Clipboard has Contents to be Pasted";
 	}
}
//
// fnc001: get tag local:
//
function locGetTagZeroClipboardReady2Copy()
{
	if(locIsLangLocalFr())
	{
  	return "Zéro Clipboard est Prèt à Copier";
  }
	else if(locIsLangLocalCn())
 	{
  	return "零键盘已经准备好去拷贝了。";
 	}
 	else
 	{
  	return "Zero Clipboard is Ready to Copy";
 	}
}

//
// inet.js:
//
function getBadUrlWarning()
{ 
  if(locIsLangLocalFr())
  {
    return "un URL valide comme http://www.votredomaine.com/[SomePage.htm]. Veuillez enlever des espaces précédant ou suivant l'adresse qui ne sont pas admis.\n";
  }
  else if(locIsLangLocalCn())
  {
    return "一个有效的URL象 http://www.您的域名.com/[SomePage.htm]。 请您特别仔细查看在您的地址内有没有起头或者结尾的不被接纳的空格。\n";
  }
  else
  {
    return "a valid URL like http://www.yourdomain.com/[SomePage.htm]. Please check if there are heading or trailing spaces in the address string that are not admitted.\n";
  }
}

function validatePasswordByForm(frm)
{
  var strMsg;

  if(frm.password.value == "")
  {
    if(locIsLangLocalFr())
    {
      strMsg = "Erreur Mot de passe.";
    }
    else if(locIsLangLocalCn())
    {
      strMsg = "无效密码。";
    }
    else
    {
      strMsg = "Error password.";
    }
    alert("\n" + strMsg);
    frm.password.focus();
    return false;
  }

  if(frm.verify_password.value != frm.password.value )
  {
    if(locIsLangLocalFr())
    {
      strMsg = "Les deux saisies de mot de passe ne correspondent pas.";
    }
    else if(locIsLangLocalCn())
    {
      strMsg = "两次密码输入不相同。";
    }
    else
    {
      strMsg = "The two inputs of password d'ont correspond.";
    }
    alert("\n" + strMsg);
    frm.password.focus();
    return false;
  }
  return true;
}
function validateUsernamePassword()
{
// bypass check for some browsers
//  if (navigator.userAgent.indexOf("MSIE") > 0)
//  {
//    return true;
//  }
//if (navigator.appName == "Netscape")
//{
//  if (navigator.appVersion.substring(0, 1) <= "2") return true;
//}
//  else return true;
//
  var strMsg;
//
  if(document.master.username.value == "")
  {
    if(locIsLangLocalFr())
    {
      strMsg = "Erreur Pseudo.";
    }
    else if(locIsLangLocalCn())
    {
      strMsg = "无效帐户名。";
    }
    else
    {
      strMsg = "Error Username.";
    }
    alert("\n" + strMsg);
    document.master.username.focus();
    return false;
  }
  return validatePasswordByForm(document.master);
}

function validateEmail(strEmail)
{ 
  var i, v = new RegExp(); 
  var strUrlNow = trim(strEmail);
  v.compile("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$"); 
  i = v.test(strUrlNow);
  v = null;
  return i;
} 

function validateUrl(strUrl)
{ 
  var i, v = new RegExp(); 
  var strUrlNow = trim(strUrl);
  v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); 
  i = v.test(strUrlNow);
  v = null;
  return i;
} 

function validateFormMasterEmailUrl()
{
	var nBad, strMsg;
  var frm = getMaster();
  var bFr, bCn;
//
  bFr = false;
  bCn = false;
//
  if(locIsLangLocalFr())
  {
    bFr = true;
  }
  else if(locIsLangLocalCn())
  {
    bCn = true;
  }
//
  nBad = 0;
  strMsg = "";
//
  if(frm.URL)
  {
    if(! validateUrl(frm.URL.value))
    {
      nBad++;
      frm.URL.focus();
      strMsg += nBad + ". ";
      strMsg += "URL: " + getBadUrlWarning();
      strMsg += "\n";
    }
  }
//
  if(frm.email)
  {
    if(! validateEmail(frm.email.value))
    {
      nBad++;
      if(nBad == 1)
      {
      	frm.email.focus();
      }
      strMsg += nBad + ". ";
      if(bFr)
      {
        strMsg += "email: une adresse email valide comme superman@votredomaine.com.\n";
      }
      else if(bCn)
      {
        strMsg += "email: 一个有效的email象 superman@您的域名.com.\n";
      }
      else
      {
        strMsg += "email: a valid Email like superman@yourdomain.com.\n";
      }
      strMsg += "\n";
    }
  }
//
  if(frm.recipient)
  {
    if(! validateEmail(frm.recipient.value))
    {
      nBad++;
      if(nBad == 1)
      {
        frm.recipient.focus();
      }
      strMsg += nBad + ". ";
      if(bFr)
      {
        strMsg += "recipient: un email récipient valide comme superman@votredomaine.com.\n";
      }
      else if(bCn)
      {
        strMsg += "recipient: 一个有效的收集email象 superman@您的域名.com.\n";
      }
      else
      {
        strMsg += "recipient: a valid recipient email like superman@yourdomain.com.\n";
      }
      strMsg += "\n";
    }
  }
//
  if(frm.linkURL)
  {
    if(! validateUrl(frm.linkURL.value))
    {
      nBad++;
      if(nBad == 1)
      {
        frm.linkURL.focus();
      }
      strMsg += nBad + ". ";
      strMsg += "linkURL: " + getBadUrlWarning();
      strMsg += "\n";
    }
  }
//
  if(frm.foreignURL)
  {
    if(! validateUrl(frm.foreignURL.value))
    {
      nBad++;
      if(nBad == 1)
      {
        frm.foreignURL.focus();
      }
      strMsg += nBad + ". ";
      if(bFr)
      {
        strMsg += "foreignURL: une adresse URL de retour sans espaces dans votre site comme http://www.votredomaine.com/[VotrePage.htm] contenant un lien dur vers notre page d'accueil.\n";
      }
      else if(bCn)
      {
        strMsg += "foreignURL: 一个有效的在您的网站内的包含我们本页硬链接的惠赠无空格URL象 http://www.您的域名.com/[SomePage.htm]。\n";
      }
      else
      {
        strMsg += "foreignURL: a valid return URL without spaces on your site like http://www.yourdomain.com/[SomePage.htm] containing a hard link to our homepage.\n";
      }
      strMsg += "\n";
    }
  }
//
// check results:
//
  if(nBad == 0)
  {
    frm.submit();
  }
  else
  {
    if(bFr)
    {
      strMsg = "Il manque encore " + nBad + " element(s) requis suivants:\n\n" + strMsg;
    }
    else if(bCn)
    {
      strMsg = "还缺少以下" + nBad + "个必须的款项：\n\n" + strMsg;
    }
    else
    {
      strMsg = "There are missing yet following " + nBad + " required element(s):\n\n" + strMsg;
    }
    alert(strMsg);
  }
//
  return false;
}

//
// html.js:
//
//
// HtmlDecode http://lab.msdn.microsoft.com/annotations/htmldecode.js 
//   client side version of the useful Server.HtmlDecode method 
//   takes one string (encoded) and returns another (decoded) 
//
function htmldecode(s) 

{ 
  var out = ""; 
  if (s==null) return; 
  var l = s.length; 
  for (var i=0; i<l; i++) 
  { 
    var ch = s.charAt(i); 
    if (ch == '&') 
    { 
      var semicolonIndex = s.indexOf(';', i+1); 
      if (semicolonIndex > 0) 
      { 
        var entity = s.substring(i + 1, semicolonIndex); 
        if (entity.length > 1 && entity.charAt(0) == '#') 
        { 
           if (entity.charAt(1) == 'x' || entity.charAt(1) == 'X')
             ch = String.fromCharCode(eval('0'+entity.substring(1))); 
           else
             ch = String.fromCharCode(eval(entity.substring(1))); 
        } 
        else 
        { 
          switch (entity) 
          { 
            case 'quot': ch = String.fromCharCode(0x0022); break; 
            case 'amp': ch = String.fromCharCode(0x0026); break; 
            case 'lt': ch = String.fromCharCode(0x003c); break; 
            case 'gt': ch = String.fromCharCode(0x003e); break; 
            case 'nbsp': ch = String.fromCharCode(0x00a0); break; 
            case 'iexcl': ch = String.fromCharCode(0x00a1); break; 
            case 'cent': ch = String.fromCharCode(0x00a2); break; 
            case 'pound': ch = String.fromCharCode(0x00a3); break; 
            case 'curren': ch = String.fromCharCode(0x00a4); break; 
            case 'yen': ch = String.fromCharCode(0x00a5); break; 
            case 'brvbar': ch = String.fromCharCode(0x00a6); break; 
            case 'sect': ch = String.fromCharCode(0x00a7); break; 
            case 'uml': ch = String.fromCharCode(0x00a8); break; 
            case 'copy': ch = String.fromCharCode(0x00a9); break; 
            case 'ordf': ch = String.fromCharCode(0x00aa); break; 
            case 'laquo': ch = String.fromCharCode(0x00ab); break; 
            case 'not': ch = String.fromCharCode(0x00ac); break; 
            case 'shy': ch = String.fromCharCode(0x00ad); break; 
            case 'reg': ch = String.fromCharCode(0x00ae); break; 
            case 'macr': ch = String.fromCharCode(0x00af); break; 
            case 'deg': ch = String.fromCharCode(0x00b0); break; 
            case 'plusmn': ch = String.fromCharCode(0x00b1); break; 
            case 'sup2': ch = String.fromCharCode(0x00b2); break; 
            case 'sup3': ch = String.fromCharCode(0x00b3); break; 
            case 'acute': ch = String.fromCharCode(0x00b4); break; 
            case 'micro': ch = String.fromCharCode(0x00b5); break; 
            case 'para': ch = String.fromCharCode(0x00b6); break; 
            case 'middot': ch = String.fromCharCode(0x00b7); break; 
            case 'cedil': ch = String.fromCharCode(0x00b8); break; 
            case 'sup1': ch = String.fromCharCode(0x00b9); break; 
            case 'ordm': ch = String.fromCharCode(0x00ba); break; 
            case 'raquo': ch = String.fromCharCode(0x00bb); break; 
            case 'frac14': ch = String.fromCharCode(0x00bc); break; 
            case 'frac12': ch = String.fromCharCode(0x00bd); break; 
            case 'frac34': ch = String.fromCharCode(0x00be); break; 
            case 'iquest': ch = String.fromCharCode(0x00bf); break; 
            case 'Agrave': ch = String.fromCharCode(0x00c0); break; 
            case 'Aacute': ch = String.fromCharCode(0x00c1); break; 
            case 'Acirc': ch = String.fromCharCode(0x00c2); break; 
            case 'Atilde': ch = String.fromCharCode(0x00c3); break; 
            case 'Auml': ch = String.fromCharCode(0x00c4); break; 
            case 'Aring': ch = String.fromCharCode(0x00c5); break; 
            case 'AElig': ch = String.fromCharCode(0x00c6); break; 
            case 'Ccedil': ch = String.fromCharCode(0x00c7); break; 
            case 'Egrave': ch = String.fromCharCode(0x00c8); break; 
            case 'Eacute': ch = String.fromCharCode(0x00c9); break; 
            case 'Ecirc': ch = String.fromCharCode(0x00ca); break; 
            case 'Euml': ch = String.fromCharCode(0x00cb); break; 
            case 'Igrave': ch = String.fromCharCode(0x00cc); break; 
            case 'Iacute': ch = String.fromCharCode(0x00cd); break; 
            case 'Icirc': ch = String.fromCharCode(0x00ce ); break; 
            case 'Iuml': ch = String.fromCharCode(0x00cf); break; 
            case 'ETH': ch = String.fromCharCode(0x00d0); break; 
            case 'Ntilde': ch = String.fromCharCode(0x00d1); break; 
            case 'Ograve': ch = String.fromCharCode(0x00d2); break; 
            case 'Oacute': ch = String.fromCharCode(0x00d3); break; 
            case 'Ocirc': ch = String.fromCharCode(0x00d4); break; 
            case 'Otilde': ch = String.fromCharCode(0x00d5); break; 
            case 'Ouml': ch = String.fromCharCode(0x00d6); break; 
            case 'times': ch = String.fromCharCode(0x00d7); break; 
            case 'Oslash': ch = String.fromCharCode(0x00d8); break; 
            case 'Ugrave': ch = String.fromCharCode(0x00d9); break; 
            case 'Uacute': ch = String.fromCharCode(0x00da); break; 
            case 'Ucirc': ch = String.fromCharCode(0x00db); break; 
            case 'Uuml': ch = String.fromCharCode(0x00dc); break; 
            case 'Yacute': ch = String.fromCharCode(0x00dd); break; 
            case 'THORN': ch = String.fromCharCode(0x00de); break; 
            case 'szlig': ch = String.fromCharCode(0x00df); break; 
            case 'agrave': ch = String.fromCharCode(0x00e0); break; 
            case 'aacute': ch = String.fromCharCode(0x00e1); break; 
            case 'acirc': ch = String.fromCharCode(0x00e2); break; 
            case 'atilde': ch = String.fromCharCode(0x00e3); break; 
            case 'auml': ch = String.fromCharCode(0x00e4); break; 
            case 'aring': ch = String.fromCharCode(0x00e5); break; 
            case 'aelig': ch = String.fromCharCode(0x00e6); break; 
            case 'ccedil': ch = String.fromCharCode(0x00e7); break; 
            case 'egrave': ch = String.fromCharCode(0x00e8); break; 
            case 'eacute': ch = String.fromCharCode(0x00e9); break; 
            case 'ecirc': ch = String.fromCharCode(0x00ea); break; 
            case 'euml': ch = String.fromCharCode(0x00eb); break; 
            case 'igrave': ch = String.fromCharCode(0x00ec); break; 
            case 'iacute': ch = String.fromCharCode(0x00ed); break; 
            case 'icirc': ch = String.fromCharCode(0x00ee); break; 
            case 'iuml': ch = String.fromCharCode(0x00ef); break; 
            case 'eth': ch = String.fromCharCode(0x00f0); break; 
            case 'ntilde': ch = String.fromCharCode(0x00f1); break; 
            case 'ograve': ch = String.fromCharCode(0x00f2); break; 
            case 'oacute': ch = String.fromCharCode(0x00f3); break; 
            case 'ocirc': ch = String.fromCharCode(0x00f4); break; 
            case 'otilde': ch = String.fromCharCode(0x00f5); break; 
            case 'ouml': ch = String.fromCharCode(0x00f6); break; 
            case 'divide': ch = String.fromCharCode(0x00f7); break; 
            case 'oslash': ch = String.fromCharCode(0x00f8); break; 
            case 'ugrave': ch = String.fromCharCode(0x00f9); break; 
            case 'uacute': ch = String.fromCharCode(0x00fa); break; 
            case 'ucirc': ch = String.fromCharCode(0x00fb); break; 
            case 'uuml': ch = String.fromCharCode(0x00fc); break; 
            case 'yacute': ch = String.fromCharCode(0x00fd); break; 
            case 'thorn': ch = String.fromCharCode(0x00fe); break; 
            case 'yuml': ch = String.fromCharCode(0x00ff); break; 
            case 'OElig': ch = String.fromCharCode(0x0152); break; 
            case 'oelig': ch = String.fromCharCode(0x0153); break; 
            case 'Scaron': ch = String.fromCharCode(0x0160); break; 
            case 'scaron': ch = String.fromCharCode(0x0161); break; 
            case 'Yuml': ch = String.fromCharCode(0x0178); break; 
            case 'fnof': ch = String.fromCharCode(0x0192); break; 
            case 'circ': ch = String.fromCharCode(0x02c6); break; 
            case 'tilde': ch = String.fromCharCode(0x02dc); break; 
            case 'Alpha': ch = String.fromCharCode(0x0391); break; 
            case 'Beta': ch = String.fromCharCode(0x0392); break; 
            case 'Gamma': ch = String.fromCharCode(0x0393); break; 
            case 'Delta': ch = String.fromCharCode(0x0394); break; 
            case 'Epsilon': ch = String.fromCharCode(0x0395); break; 
            case 'Zeta': ch = String.fromCharCode(0x0396); break; 
            case 'Eta': ch = String.fromCharCode(0x0397); break; 
            case 'Theta': ch = String.fromCharCode(0x0398); break; 
            case 'Iota': ch = String.fromCharCode(0x0399); break; 
            case 'Kappa': ch = String.fromCharCode(0x039a); break; 
            case 'Lambda': ch = String.fromCharCode(0x039b); break; 
            case 'Mu': ch = String.fromCharCode(0x039c); break; 
            case 'Nu': ch = String.fromCharCode(0x039d); break; 
            case 'Xi': ch = String.fromCharCode(0x039e); break; 
            case 'Omicron': ch = String.fromCharCode(0x039f); break; 
            case 'Pi': ch = String.fromCharCode(0x03a0); break; 
            case ' Rho ': ch = String.fromCharCode(0x03a1); break; 
            case 'Sigma': ch = String.fromCharCode(0x03a3); break; 
            case 'Tau': ch = String.fromCharCode(0x03a4); break; 
            case 'Upsilon': ch = String.fromCharCode(0x03a5); break; 
            case 'Phi': ch = String.fromCharCode(0x03a6); break; 
            case 'Chi': ch = String.fromCharCode(0x03a7); break; 
            case 'Psi': ch = String.fromCharCode(0x03a8); break; 
            case 'Omega': ch = String.fromCharCode(0x03a9); break; 
            case 'alpha': ch = String.fromCharCode(0x03b1); break; 
            case 'beta': ch = String.fromCharCode(0x03b2); break; 
            case 'gamma': ch = String.fromCharCode(0x03b3); break; 
            case 'delta': ch = String.fromCharCode(0x03b4); break; 
            case 'epsilon': ch = String.fromCharCode(0x03b5); break; 
            case 'zeta': ch = String.fromCharCode(0x03b6); break; 
            case 'eta': ch = String.fromCharCode(0x03b7); break; 
            case 'theta': ch = String.fromCharCode(0x03b8); break; 
            case 'iota': ch = String.fromCharCode(0x03b9); break; 
            case 'kappa': ch = String.fromCharCode(0x03ba); break; 
            case 'lambda': ch = String.fromCharCode(0x03bb); break; 
            case 'mu': ch = String.fromCharCode(0x03bc); break; 
            case 'nu': ch = String.fromCharCode(0x03bd); break; 
            case 'xi': ch = String.fromCharCode(0x03be); break; 
            case 'omicron': ch = String.fromCharCode(0x03bf); break; 
            case 'pi': ch = String.fromCharCode(0x03c0); break; 
            case 'rho': ch = String.fromCharCode(0x03c1); break; 
            case 'sigmaf': ch = String.fromCharCode(0x03c2); break; 
            case 'sigma': ch = String.fromCharCode(0x03c3); break; 
            case 'tau': ch = String.fromCharCode(0x03c4); break; 
            case 'upsilon': ch = String.fromCharCode(0x03c5); break; 
            case 'phi': ch = String.fromCharCode(0x03c6); break; 
            case 'chi': ch = String.fromCharCode(0x03c7); break; 
            case 'psi': ch = String.fromCharCode(0x03c8); break; 
            case 'omega': ch = String.fromCharCode(0x03c9); break; 
            case 'thetasym': ch = String.fromCharCode(0x03d1); break; 
            case 'upsih': ch = String.fromCharCode(0x03d2); break; 
            case 'piv': ch = String.fromCharCode(0x03d6); break; 
            case 'ensp': ch = String.fromCharCode(0x2002); break; 
            case 'emsp': ch = String.fromCharCode(0x2003); break; 
            case 'thinsp': ch = String.fromCharCode(0x2009); break; 
            case 'zwnj': ch = String.fromCharCode(0x200c); break; 
            case 'zwj': ch = String.fromCharCode(0x200d); break; 
            case 'lrm': ch = String.fromCharCode(0x200e); break; 
            case 'rlm': ch = String.fromCharCode(0x200f); break; 
            case 'ndash': ch = String.fromCharCode(0x2013); break; 
            case 'mdash': ch = String.fromCharCode(0x2014); break; 
            case 'lsquo': ch = String.fromCharCode(0x2018); break; 
            case 'rsquo': ch = String.fromCharCode(0x2019); break; 
            case 'sbquo': ch = String.fromCharCode(0x201a); break; 
            case 'ldquo': ch = String.fromCharCode(0x201c); break; 
            case 'rdquo': ch = String.fromCharCode(0x201d); break; 
            case 'bdquo': ch = String.fromCharCode(0x201e); break; 
            case 'dagger': ch = String.fromCharCode(0x2020); break; 
            case 'Dagger': ch = String.fromCharCode(0x2021); break; 
            case 'bull': ch = String.fromCharCode(0x2022); break; 
            case 'hellip': ch = String.fromCharCode(0x2026); break; 
            case 'permil': ch = String.fromCharCode(0x2030); break; 
            case 'prime': ch = String.fromCharCode(0x2032); break; 
            case 'Prime': ch = String.fromCharCode(0x2033); break; 
            case 'lsaquo': ch = String.fromCharCode(0x2039); break; 
            case 'rsaquo': ch = String.fromCharCode(0x203a); break; 
            case 'oline': ch = String.fromCharCode(0x203e); break; 
            case 'frasl': ch = String.fromCharCode(0x2044); break; 
            case 'euro': ch = String.fromCharCode(0x20ac); break; 
            case 'image': ch = String.fromCharCode(0x2111); break; 
            case 'weierp': ch = String.fromCharCode(0x2118); break; 
            case 'real': ch = String.fromCharCode(0x211c); break; 
            case 'trade': ch = String.fromCharCode(0x2122); break; 
            case 'alefsym': ch = String.fromCharCode(0x2135); break; 
            case 'larr': ch = String.fromCharCode(0x2190); break; 
            case 'uarr': ch = String.fromCharCode(0x2191); break; 
            case 'rarr': ch = String.fromCharCode(0x2192); break; 
            case 'darr': ch = String.fromCharCode(0x2193); break; 
            case 'harr': ch = String.fromCharCode(0x2194); break; 
            case 'crarr': ch = String.fromCharCode(0x21b5); break; 
            case 'lArr': ch = String.fromCharCode(0x21d0); break; 
            case 'uArr': ch = String.fromCharCode(0x21d1); break; 
            case 'rArr': ch = String.fromCharCode(0x21d2); break; 
            case 'dArr': ch = String.fromCharCode(0x21d3); break; 
            case 'hArr': ch = String.fromCharCode(0x21d4); break; 
            case 'forall': ch = String.fromCharCode(0x2200); break; 
            case 'part': ch = String.fromCharCode(0x2202); break; 
            case 'exist': ch = String.fromCharCode(0x2203); break; 
            case 'empty': ch = String.fromCharCode(0x2205); break; 
            case 'nabla': ch = String.fromCharCode(0x2207); break; 
            case 'isin': ch = String.fromCharCode(0x2208); break; 
            case 'notin': ch = String.fromCharCode(0x2209); break; 
            case 'ni': ch = String.fromCharCode(0x220b); break; 
            case 'prod': ch = String.fromCharCode(0x220f); break; 
            case 'sum': ch = String.fromCharCode(0x2211); break; 
            case 'minus': ch = String.fromCharCode(0x2212); break; 
            case 'lowast': ch = String.fromCharCode(0x2217); break; 
            case 'radic': ch = String.fromCharCode(0x221a); break; 
            case 'prop': ch = String.fromCharCode(0x221d); break; 
            case 'infin': ch = String.fromCharCode(0x221e); break; 
            case 'ang': ch = String.fromCharCode(0x2220); break; 
            case 'and': ch = String.fromCharCode(0x2227); break; 
            case 'or': ch = String.fromCharCode(0x2228); break; 
            case 'cap': ch = String.fromCharCode(0x2229); break; 
            case 'cup': ch = String.fromCharCode(0x222a); break; 
            case 'int': ch = String.fromCharCode(0x222b); break; 
            case 'there4': ch = String.fromCharCode(0x2234); break; 
            case 'sim': ch = String.fromCharCode(0x223c); break; 
            case 'cong': ch = String.fromCharCode(0x2245); break; 
            case 'asymp': ch = String.fromCharCode(0x2248); break; 
            case 'ne': ch = String.fromCharCode(0x2260); break; 
            case 'equiv': ch = String.fromCharCode(0x2261); break; 
            case 'le': ch = String.fromCharCode(0x2264); break; 
            case 'ge': ch = String.fromCharCode(0x2265); break; 
            case 'sub': ch = String.fromCharCode(0x2282); break; 
            case 'sup': ch = String.fromCharCode(0x2283); break; 
            case 'nsub': ch = String.fromCharCode(0x2284); break; 
            case 'sube': ch = String.fromCharCode(0x2286); break; 
            case 'supe': ch = String.fromCharCode(0x2287); break; 
            case 'oplus': ch = String.fromCharCode(0x2295); break; 
            case 'otimes': ch = String.fromCharCode(0x2297); break; 
            case 'perp': ch = String.fromCharCode(0x22a5); break; 
            case 'sdot': ch = String.fromCharCode(0x22c5); break; 
            case 'lceil': ch = String.fromCharCode(0x2308); break; 
            case 'rceil': ch = String.fromCharCode(0x2309); break; 
            case 'lfloor': ch = String.fromCharCode(0x230a); break; 
            case 'rfloor': ch = String.fromCharCode(0x230b); break; 
            case 'lang': ch = String.fromCharCode(0x2329); break; 
            case 'rang': ch = String.fromCharCode(0x232a); break; 
            case 'loz': ch = String.fromCharCode(0x25ca); break; 
            case 'spades': ch = String.fromCharCode(0x2660); break; 
            case 'clubs': ch = String.fromCharCode(0x2663); break; 
            case 'hearts': ch = String.fromCharCode(0x2665); break; 
            case 'diams': ch = String.fromCharCode(0x2666); break; 
            default: ch = ''; break; 
          } 
        } 
        i = semicolonIndex; 
      } 
    } 
    out += ch; 
  } 
  return out; 
} 

//
// form.js:
//
//
// fnc001: test if it is a control element:
//
function iscontroltype(ctl)
{
//
  if((ctl.type == "button") || (ctl.type == "submit")
    || (ctl.type == "reset") || (ctl.type == "image"))
  {
    return true;
  }
  else
  {
    return false;
  }
}

//
// fnc001: test if it is a control element:
//
function iscontroltypetext(ctl)
{
//
  if(ctl.type == "text")
  {
    return true;
  }
  else
  {
    return false;
  }
}

//
// fnc001: empty a form:
//
function emptyform(frm)
{
  var i;
//
  if(! frm)
  {
    return 0;
  }
//
  for(i = 0; i < frm.elements.length; i++)
  {
    if(! iscontroltype(frm.elements[i]))
    {
      frm.elements[i].value = "";
    }
  }
//
  return i + 1;
}

//
// fnc001: empty a form:
//
function emptyformtext(frm)
{
  var i;
//
  if(! frm)
  {
    return 0;
  }
//
  for(i = 0; i < frm.elements.length; i++)
  {
    if(iscontroltypetext(frm.elements[i]))
    {
      frm.elements[i].value = "";
    }
  }
//
  return i + 1;
}

//
// bridewin.js:
//
//*****************************************************************************
// Do not remove this notice.
//
// Copyright 2001 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//*****************************************************************************

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

//=============================================================================
// Window Object
//=============================================================================

function Window(el) {

  var i, mapList, mapName;

  // Get window components.

  this.frame           = el;
  this.titleBar        = winFindByClassName(el, "titleBar");
  this.titleBarText    = winFindByClassName(el, "titleBarText");
  this.titleBarButtons = winFindByClassName(el, "titleBarButtons");
  this.clientArea      = winFindByClassName(el, "clientArea");

  // Find matching button image map.
/*
 * useMap name:
 *   IE: #mapName
 *   NS: #mapName
 *   Opera: FULL_URL#mapName 
 */
  var str1;
  str1 = this.titleBarButtons.useMap;
  mapName = str1.substr(str1.indexOf("#") + 1);
  mapList = document.getElementsByTagName("MAP");
  for (i = 0; i < mapList.length; i++)
  {
    if (mapList[i].name == mapName)
    {
      this.titleBarMap = mapList[i];
    }
  }

  // Save colors.

  this.activeFrameBackgroundColor  = this.frame.style.backgroundColor;
  this.activeFrameBorderColor      = this.frame.style.borderColor;
  this.activeTitleBarColor         = this.titleBar.style.backgroundColor;
  this.activeTitleTextColor        = this.titleBar.style.color;
  this.activeClientAreaBorderColor = this.clientArea.style.borderColor;
  if (browser.isIE)
    this.activeClientAreaScrollbarColor = this.clientArea.style.scrollbarBaseColor;

  // Save images.

  this.activeButtonsImage   = this.titleBarButtons.src;
  this.inactiveButtonsImage = this.titleBarButtons.getAttribute("lowsrc");

  // Set flags.

  this.isOpen      = false;
  this.isMinimized = false;

  // Set methods.

  this.open       = winOpen;
  this.close      = winClose;
  this.minimize   = winMinimize;
  this.restore    = winRestore;
  this.makeActive = winMakeActive;

  // Set up event handling.

  this.frame.parentWindow = this;
  this.frame.onmousemove  = winResizeCursorSet;
  this.frame.onmouseout   = winResizeCursorRestore;
  this.frame.onmousedown  = winResizeDragStart;

  this.titleBar.parentWindow = this;
  this.titleBar.onmousedown  = winMoveDragStart;

  this.clientArea.parentWindow = this;
  this.clientArea.onclick      = winClientAreaClick;

  for (i = 0; i < this.titleBarMap.childNodes.length; i++)
  {
    if (this.titleBarMap.childNodes[i].tagName == "AREA")
    {
      this.titleBarMap.childNodes[i].parentWindow = this;
    }
  }

  // Calculate the minimum width and height values for resizing
  // and fix any initial display problems.

  var initLt, initWd, w, dw;

  // Save the inital frame width and position, then reposition
  // the window.

  initLt = this.frame.style.left;
  initWd = parseInt(this.frame.style.width);
  this.frame.style.left = -this.titleBarText.offsetWidth + "px";

  // For IE, start calculating the value to use when setting
  // the client area width based on the frame width.

  if (browser.isIE) {
    this.titleBarText.style.display = "none";
    w = this.clientArea.offsetWidth;
    this.widthDiff = this.frame.offsetWidth - w;
    this.clientArea.style.width = w + "px";
    dw = this.clientArea.offsetWidth - w;
    w -= dw;     
    this.widthDiff += dw;
    this.titleBarText.style.display = "";
  }

  // Find the difference between the frame's style and offset
  // widths. For IE, adjust the client area/frame width
  // difference accordingly.

  w = this.frame.offsetWidth;
  this.frame.style.width = w + "px";
  dw = this.frame.offsetWidth - w;
  w -= dw;     
  this.frame.style.width = w + "px";
  if (browser.isIE)
    this.widthDiff -= dw;

  // Find the minimum width for resize.

  this.isOpen = true;  // Flag as open so minimize call will work.
  this.minimize();
  this.minimumWidth = this.frame.offsetWidth - dw;

  // Find the frame width at which or below the title bar text will
  // need to be clipped.

  this.titleBarText.style.width = "";
  this.clipTextMinimumWidth = this.frame.offsetWidth - dw;

  // Set the minimum height.

  this.minimumHeight = 1;

  // Restore window. For IE, set client area width.

  this.restore();
  this.isOpen = false;  // Reset flag.
  initWd = Math.max(initWd, this.minimumWidth);
  this.frame.style.width = initWd + "px";
  if (browser.isIE)
    this.clientArea.style.width = (initWd - this.widthDiff) + "px";

  // Clip the title bar text if needed.

  if (this.clipTextMinimumWidth >= this.minimumWidth)
    this.titleBarText.style.width = (winCtrl.minimizedTextWidth + initWd - this.minimumWidth) + "px";

  // Restore the window to its original position.

  this.frame.style.left = initLt;
}

//=============================================================================
// Window Methods
//=============================================================================

function winOpen() {

  if (this.isOpen)
    return;

  // Restore the window and make it visible.

  this.makeActive();
  this.isOpen = true;
  if (this.isMinimized)
    this.restore();
  this.frame.style.visibility = "visible";
}

function winClose() {

  // Hide the window.

  this.frame.style.visibility = "hidden";
  this.isOpen = false;
}

function winMinimize() {

  if (!this.isOpen || this.isMinimized)
    return;

  this.makeActive();

  // Save current frame and title bar text widths.

  this.restoreFrameWidth = this.frame.style.width;
  this.restoreTextWidth = this.titleBarText.style.width;

  // Disable client area display.

  this.clientArea.style.display = "none";

  // Minimize frame and title bar text widths.

  if (this.minimumWidth)
    this.frame.style.width = this.minimumWidth + "px";
  else
    this.frame.style.width = "";
  this.titleBarText.style.width = winCtrl.minimizedTextWidth + "px";

  this.isMinimized = true;
}

function winRestore() {

  if (!this.isOpen || !this.isMinimized)
    return;

  this.makeActive();

  // Enable client area display.

  this.clientArea.style.display = "";

  // Restore frame and title bar text widths.

  this.frame.style.width = this.restoreFrameWidth;
  this.titleBarText.style.width = this.restoreTextWidth;

  this.isMinimized = false;
}

function winMakeActive() {

  if (winCtrl.active == this)
    return;

  // Inactivate the currently active window.

  if (winCtrl.active) {
    winCtrl.active.frame.style.backgroundColor    = winCtrl.inactiveFrameBackgroundColor;
    winCtrl.active.frame.style.borderColor        = winCtrl.inactiveFrameBorderColor;
    winCtrl.active.titleBar.style.backgroundColor = winCtrl.inactiveTitleBarColor;
    winCtrl.active.titleBar.style.color           = winCtrl.inactiveTitleTextColor;
    winCtrl.active.clientArea.style.borderColor   = winCtrl.inactiveClientAreaBorderColor;
    if (browser.isIE)
      winCtrl.active.clientArea.style.scrollbarBaseColor = winCtrl.inactiveClientAreaScrollbarColor;
    if (browser.isNS && browser.version < 6.1)
      winCtrl.active.clientArea.style.overflow = "hidden";
    if (winCtrl.active.inactiveButtonsImage)
      winCtrl.active.titleBarButtons.src = winCtrl.active.inactiveButtonsImage;
  }

  // Activate this window.

  this.frame.style.backgroundColor    = this.activeFrameBackgroundColor;
  this.frame.style.borderColor        = this.activeFrameBorderColor;
  this.titleBar.style.backgroundColor = this.activeTitleBarColor;
  this.titleBar.style.color           = this.activeTitleTextColor;
  this.clientArea.style.borderColor   = this.activeClientAreaBorderColor;
  if (browser.isIE)
    this.clientArea.style.scrollbarBaseColor = this.activeClientAreaScrollbarColor;
  if (browser.isNS && browser.version < 6.1)
    this.clientArea.style.overflow = "auto";
  if (this.inactiveButtonsImage)
    this.titleBarButtons.src = this.activeButtonsImage;
  this.frame.style.zIndex = ++winCtrl.maxzIndex;
  winCtrl.active = this;
}

//=============================================================================
// Event handlers.
//=============================================================================

function winClientAreaClick(event) {

  // Make this window the active one.

  this.parentWindow.makeActive();
}

//-----------------------------------------------------------------------------
// Window dragging.
//-----------------------------------------------------------------------------

function winMoveDragStart(event) {

  var target;
  var x, y;

  if (browser.isIE)
    target = window.event.srcElement.tagName;
  if (browser.isNS)
    target = event.target.tagName;

  if (target == "AREA")
    return;

  this.parentWindow.makeActive();

  // Get cursor offset from window frame.

  if (browser.isIE) {
    x = window.event.x;
    y = window.event.y;
  }
  if (browser.isNS) {
    x = event.pageX;
    y = event.pageY;
  }
  winCtrl.xOffset = winCtrl.active.frame.offsetLeft - x;
  winCtrl.yOffset = winCtrl.active.frame.offsetTop  - y;

  // Set document to capture mousemove and mouseup events.

  if (browser.isIE) {
    document.onmousemove = winMoveDragGo;
    document.onmouseup   = winMoveDragStop;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", winMoveDragGo,   true);
    document.addEventListener("mouseup",   winMoveDragStop, true);
    event.preventDefault();
  }

  winCtrl.inMoveDrag = true;
}

function winMoveDragGo(event) {

  var x, y;

  if (!winCtrl.inMoveDrag)
    return;

  // Get cursor position.

  if (browser.isIE) {
    x = window.event.x;
    y = window.event.y;
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    x = event.pageX;
    y = event.pageY;
    event.preventDefault();
  }

  // Move window frame based on offset from cursor.

  winCtrl.active.frame.style.left = (x + winCtrl.xOffset) + "px";
  winCtrl.active.frame.style.top  = (y + winCtrl.yOffset) + "px";
}

function winMoveDragStop(event) {

  winCtrl.inMoveDrag = false;

  // Remove mousemove and mouseup event captures on document.

  if (browser.isIE) {
    document.onmousemove = null;
    document.onmouseup   = null;
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", winMoveDragGo,   true);
    document.removeEventListener("mouseup",   winMoveDragStop, true);
  }
}

//-----------------------------------------------------------------------------
// Window resizing.
//-----------------------------------------------------------------------------

function winResizeCursorSet(event) {

  var target;
  var xOff, yOff;

  if (this.parentWindow.isMinimized || winCtrl.inResizeDrag)
    return;

  // If not on window frame, restore cursor and exit.

  if (browser.isIE)
    target = window.event.srcElement;
  if (browser.isNS)
    target = event.target;
  if (target != this.parentWindow.frame)
    return;

  // Find resize direction.

  if (browser.isIE) {
    xOff = window.event.offsetX;
    yOff = window.event.offsetY;
  }
  if (browser.isNS) {
    xOff = event.layerX;
    yOff = event.layerY;
  }
  winCtrl.resizeDirection = ""
  if (yOff <= winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "n";
  else if (yOff >= this.parentWindow.frame.offsetHeight - winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "s";
  if (xOff <= winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "w";
  else if (xOff >= this.parentWindow.frame.offsetWidth - winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "e";

  // If not on window edge, restore cursor and exit.

  if (winCtrl.resizeDirection == "") {
    this.onmouseout(event);
    return;
  }

  // Change cursor.

  if (browser.isIE)
    document.body.style.cursor = winCtrl.resizeDirection + "-resize";
  if (browser.isNS)
    this.parentWindow.frame.style.cursor = winCtrl.resizeDirection + "-resize";
}

function winResizeCursorRestore(event) {

  if (winCtrl.inResizeDrag)
    return;

  // Restore cursor.

  if (browser.isIE)
    document.body.style.cursor = "";
  if (browser.isNS)
    this.parentWindow.frame.style.cursor = "";
}

function winResizeDragStart(event) {

  var target;

  // Make sure the event is on the window frame.

  if (browser.isIE)
    target = window.event.srcElement;
  if (browser.isNS)
    target = event.target;
  if (target != this.parentWindow.frame)
    return;

  this.parentWindow.makeActive();

  if (this.parentWindow.isMinimized)
    return;

  // Save cursor position.

  if (browser.isIE) {
    winCtrl.xPosition = window.event.x;
    winCtrl.yPosition = window.event.y;
  }
  if (browser.isNS) {
    winCtrl.xPosition = event.pageX;
    winCtrl.yPosition = event.pageY;
  }

  // Save window frame position and current window size.

  winCtrl.oldLeft   = parseInt(this.parentWindow.frame.style.left,  10);
  winCtrl.oldTop    = parseInt(this.parentWindow.frame.style.top,   10);
  winCtrl.oldWidth  = parseInt(this.parentWindow.frame.style.width, 10);
  winCtrl.oldHeight = parseInt(this.parentWindow.clientArea.style.height, 10);

  // Set document to capture mousemove and mouseup events.

  if (browser.isIE) {
    document.onmousemove = winResizeDragGo;
    document.onmouseup   = winResizeDragStop;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", winResizeDragGo,   true);
    document.addEventListener("mouseup"  , winResizeDragStop, true);
    event.preventDefault();
  }

  winCtrl.inResizeDrag = true;
}

function winResizeDragGo(event) {

 var north, south, east, west;
 var dx, dy;
 var w, h;

  if (!winCtrl.inResizeDrag)
    return;

  // Set direction flags based on original resize direction.

  north = false;
  south = false;
  east  = false;
  west  = false;
  if (winCtrl.resizeDirection.charAt(0) == "n")
    north = true;
  if (winCtrl.resizeDirection.charAt(0) == "s")
    south = true;
  if (winCtrl.resizeDirection.charAt(0) == "e" || winCtrl.resizeDirection.charAt(1) == "e")
    east = true;
  if (winCtrl.resizeDirection.charAt(0) == "w" || winCtrl.resizeDirection.charAt(1) == "w")
    west = true;

  // Find change in cursor position.

  if (browser.isIE) {
    dx = window.event.x - winCtrl.xPosition;
    dy = window.event.y - winCtrl.yPosition;
  }
  if (browser.isNS) {
    dx = event.pageX - winCtrl.xPosition;
    dy = event.pageY - winCtrl.yPosition;
  }

  // If resizing north or west, reverse corresponding amount.

  if (west)
    dx = -dx;
  if (north)
    dy = -dy;

  // Check new size.

  w = winCtrl.oldWidth  + dx;
  h = winCtrl.oldHeight + dy;
  if (w <= winCtrl.active.minimumWidth) {
    w = winCtrl.active.minimumWidth;
    dx = w - winCtrl.oldWidth;
  }
  if (h <= winCtrl.active.minimumHeight) {
    h = winCtrl.active.minimumHeight;
    dy = h - winCtrl.oldHeight;
  }

  // Resize the window. For IE, keep client area and frame widths in synch.

  if (east || west) {
    winCtrl.active.frame.style.width = w + "px";
    if (browser.isIE)
      winCtrl.active.clientArea.style.width = (w - winCtrl.active.widthDiff) + "px";
  }
  if (north || south)
    winCtrl.active.clientArea.style.height = h + "px";

  // Clip the title bar text, if necessary.

  if (east || west) {
    if (w < winCtrl.active.clipTextMinimumWidth)
      winCtrl.active.titleBarText.style.width = (winCtrl.minimizedTextWidth + w - winCtrl.active.minimumWidth) + "px";
    else
      winCtrl.active.titleBarText.style.width = "";
  }

  // For a north or west resize, move the window.

  if (west)
    winCtrl.active.frame.style.left = (winCtrl.oldLeft - dx) + "px";
  if (north)
    winCtrl.active.frame.style.top  = (winCtrl.oldTop  - dy) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function winResizeDragStop(event) {

  winCtrl.inResizeDrag = false;

  // Remove mousemove and mouseup event captures on document.

  if (browser.isIE) {
    document.onmousemove = null;
    document.onmouseup   = null;
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", winResizeDragGo,   true);
    document.removeEventListener("mouseup"  , winResizeDragStop, true);
  }
}

//=============================================================================
// Utility functions.
//=============================================================================

function winFindByClassName(el, className) {

  var i, tmp;

  if (el.className == className)
    return el;

  // Search for a descendant element assigned the given class.

  for (i = 0; i < el.childNodes.length; i++) {
    tmp = winFindByClassName(el.childNodes[i], className);
    if (tmp != null)
      return tmp;
  }

  return null;
}

//=============================================================================
// Initialization code.
//=============================================================================

var winList = new Array();
var winCtrl = new Object();

function bridewinInit() {

  var elList;

  // Initialize window control object.
  winCtrl.maxzIndex                        =   0;
  winCtrl.resizeCornerSize                 =  16;
  winCtrl.minimizedTextWidth               = 100;
  winCtrl.inactiveFrameBackgroundColor     = "#c0c0c0";
  winCtrl.inactiveFrameBorderColor         = "#f0f0f0 #505050 #404040 #e0e0e0";
  winCtrl.inactiveTitleBarColor            = "#808080";
  winCtrl.inactiveTitleTextColor           = "#c0c0c0";
  winCtrl.inactiveClientAreaBorderColor    = "#404040 #e0e0e0 #f0f0f0 #505050";
  winCtrl.inactiveClientAreaScrollbarColor = "";
  winCtrl.inMoveDrag                       = false;
  winCtrl.inResizeDrag                     = false;

  // Initialize windows and build list.

  elList = document.getElementsByTagName("DIV");
  for (var i = 0; i < elList.length; i++)
  {
    if (elList[i].className == "window")
    {
      winList[elList[i].id] = new Window(elList[i]);
    }
  }
}

/*
 * do this in the body tag:
 */
//window.onload = winInit;  // run initialization code after page loads.

//
// siret.js:
//

function sumupRightPart(strSiret, iEnd)
{
  var indice = 0; // indice de boucle
  var indice_rang = 0;              // indice pour position paire ou impaire.
  var total = 0;                    // somme de la multiplication par 1 ou 2 des chiffres du nÂ°
  var result_mult=0; 
// resultat multiplication en entier

  for(indice=iEnd, iRank=1; indice >= 0; indice--, iRank++)
  {
    if(iRank%2==0) 
    {
      result_mult = parseInt(strSiret.charAt(indice)) *2;
      if(result_mult>9)
      {
        result_mult=Math.round(parseInt(result_mult/10) + result_mult%10);
      }
    }
    else
    {
      result_mult = parseInt(strSiret.charAt(indice));
    }
    total = total + result_mult;
  }
  return total;
}

function controlSiretString(strSiret)
{
  var retval=0;

  if(strSiret.length != 14)
  {
    alert("Votre numÃ©ro SIRET doit Ãªtre composÃ© de 14 chiffres.");
  }
  else
  {
    if(parseFloat(strSiret)!= strSiret)
    {
      alert("Votre numÃ©ro SIRET ne doit Ãªtre composÃ© que de chiffres.");
    }
    else      
    {
      retval=sumupRightPart(strSiret,8);
      if(retval!=parseInt(retval/10)*10)
      {
        alert ("No. SIRET invalide");
        return false;
      }
      retval=sumupRightPart(strSiret,13);
      if(retval!=parseInt(retval/10)*10)
      {
      	alert ("No. SIRET invalide");
        return false;
      }
      else
      {
      	alert ("No. SIRET BON: " + strSiret + ".");
      	return true;
      }
    }
  }
  return false;
}

function verifySiret(objSiret)
{
  if(controlSiretString(objSiret.value))
  {
    return true;
  }
  else
  {
    return false;
  }
}

//
// clipboard.js:
//
//
// BEGIN:
//
//-- Free javascripts @ http://www.hscripts.com 
//http://www.hscripts.com/scripts/JavaScript/select-div-tag.php
//
function fnSelectObject(xobj)
{
  var range;
  fnDeSelect();
  if (document.selection) 
  {
    range = document.body.createTextRange();
    range.moveToElementText(xobj);
    range.select();
  }
  else if (window.getSelection) 
  {
    range = document.createRange();
    range.selectNode(xobj);
    window.getSelection().addRange(range);
  }
  return range;
}

function fnSelect(objId)
{
  return fnSelectObject(document.getElementById(objId));
}

function fnDeSelect() 
{
   if (document.selection)
             document.selection.empty();
   else if (window.getSelection)
              window.getSelection().removeAllRanges();
} 
//
// END:
//
function clpSelectObject(xobj)
{
	return fnSelectObject(xobj);
}

function clpSelectById(strID)
{
	return fnSelect(strID);
}

function clpSelect()
{
	return fnSelect("idresult");
}

function clpCopyObject(xobj)
{
  if(xobj.type == "text")
  {
  	clpCopyToClipboard(xobj.value);
  	return true;
  }
	var range;
  range = clpSelectObject(xobj);
  //range.execCommand("RemoveFormat");
	try {
    range.execCommand("Copy");
  } catch (e) {
	  alert("Cannot copy " + xobj.id + " into Clipboard under " + navigator.userAgent + " on JavaScript.");
  }
  fnDeSelect();
	return true;
}

function clpCopyById(strID)
{
	return clpCopyObject(document.getElementById(strID));
}

function clpCopy()
{
	return clpCopyById("idresult");
}

function clpCopyToClipboard(s)
{
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", s);
	}
	// not work for Google Chrome:
	else
	{
		// You have to sign the code to enable this or allow the action in about:config by changing
		user_pref("signed.applets.codebase_principal_support", true);
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

		var clip = Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;

		// create a transferable
		var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;

		// specify the data we wish to handle. Plaintext in this case.
		trans.addDataFlavor('text/unicode');

		// To get the data from the transferable we need two new objects
		var str = new Object();
		var len = new Object();

		var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString);

//  var copytext=meintext;
    var copytext=s;
		str.data=copytext;

		trans.setTransferData("text/unicode",str,copytext.length*[[[[2]]]]);

		var clipid=Components.interfaces.nsIClipboard;

		if (!clip) return false;

		clip.setData(trans,null,clipid.kGlobalClipboard);	   
	}
}

//
// BEGIN ZeroClipboard.js: 
//

// Simple Set Clipboard System
// Author: Joseph Huckaby

var ZeroClipboard = {
	
	version: "1.0.7",
	clients: {}, // registered upload clients on page, indexed by id
	moviePath: nvlPrependFlashDir("zeroclipboard.swf"), // URL to movie
	nextId: 1, // ID of next movie
	
	$: function(thingy) {
		// simple DOM lookup utility function
		if (typeof(thingy) == 'string') thingy = document.getElementById(thingy);
		if(! thingy) return null;
		if (!thingy.addClass) {
			// extend element with a few useful methods
			thingy.hide = function() { this.style.display = 'none'; };
			thingy.show = function() { this.style.display = ''; };
			thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
			thingy.removeClass = function(name) {
				var classes = this.className.split(/\s+/);
				var idx = -1;
				for (var k = 0; k < classes.length; k++) {
					if (classes[k] == name) { idx = k; k = classes.length; }
				}
				if (idx > -1) {
					classes.splice( idx, 1 );
					this.className = classes.join(' ');
				}
				return this;
			};
			thingy.hasClass = function(name) {
				return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
			};
		}
		return thingy;
	},
	
	setMoviePath: function(path) {
		// set path to ZeroClipboard.swf
		this.moviePath = path;
	},
	
	dispatch: function(id, eventName, args) {
		// receive event from flash movie, send to client		
		var client = this.clients[id];
		if (client) {
			client.receiveEvent(eventName, args);
		}
	},
	
	register: function(id, client) {
		// register new client to receive events
		this.clients[id] = client;
	},
	
	getDOMObjectPosition: function(obj, stopObj) {
		// get absolute coordinates for dom element
		var info = {
			left: 0, 
			top: 0, 
			width: obj.width ? obj.width : obj.offsetWidth, 
			height: obj.height ? obj.height : obj.offsetHeight
		};

		while (obj && (obj != stopObj)) {
			info.left += obj.offsetLeft;
			info.top += obj.offsetTop;
			obj = obj.offsetParent;
		}

		return info;
	},
	
	Client: function(elem) {
		// constructor for new simple upload client
		this.handlers = {};
		
		// unique ID
		this.id = ZeroClipboard.nextId++;
		this.movieId = 'ZeroClipboardMovie_' + this.id;
		
		// register client with singleton to receive flash events
		ZeroClipboard.register(this.id, this);
		
		// create movie
		if (elem) this.glue(elem);
	}
};

ZeroClipboard.Client.prototype = {
	
	id: 0, // unique ID for us
	ready: false, // whether movie is ready to receive events or not
	movie: null, // reference to movie object
	clipText: '', // text to copy to clipboard
	handCursorEnabled: true, // whether to show hand cursor, or default pointer cursor
	cssEffects: true, // enable CSS mouse effects on dom container
	handlers: null, // user event handlers
	
	glue: function(elem, appendElem, stylesToAdd) {
		// glue to DOM element
		// elem can be ID or actual DOM element object
		this.domElement = ZeroClipboard.$(elem);
		if(! this.domElement) return false;
		// float just above object, or zIndex 99 if dom element isn't set
		var zIndex = 99;
		if (this.domElement.style.zIndex) {
			zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
		}
		if (typeof(appendElem) == 'string') {
			appendElem = ZeroClipboard.$(appendElem);
		}
		else if (typeof(appendElem) == 'undefined') {
			appendElem = document.getElementsByTagName('body')[0];
		}
		
		// find X/Y position of domElement
		var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem);
		// 
		// a display: none element has width and height = 0:
		//
		if(box.width <= 0)
		{
			box.width = 55;
		}
		if(box.height <= 0)
		{
			box.height = 22;
		}
		
		// create floating DIV above element
		this.div = document.createElement('div');
		var style = this.div.style;
		style.position = 'absolute';
		style.left = '' + box.left + 'px';
		style.top = '' + box.top + 'px';
		style.width = '' + box.width + 'px';
		style.height = '' + box.height + 'px';
		style.zIndex = zIndex;
		
		if (typeof(stylesToAdd) == 'object') {
			for (addedStyle in stylesToAdd) {
				style[addedStyle] = stylesToAdd[addedStyle];
			}
		}
		
		// style.backgroundColor = '#f00'; // debug
		
		appendElem.appendChild(this.div);
		
		this.div.innerHTML = this.getHTML( box.width, box.height );
	},
	
	getHTML: function(width, height) {
		// return HTML for movie
		var html = '';
		var flashvars = 'id=' + this.id + 
			'&width=' + width + 
			'&height=' + height;
			
		if (navigator.userAgent.match(/MSIE/)) {
			// IE gets an OBJECT tag
			var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
			html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+protocol+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><param name="wmode" value="transparent"/></object>';
		}
		else {
			// all other browsers get an EMBED tag
			html += '<embed id="'+this.movieId+'" src="'+ZeroClipboard.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" wmode="transparent" />';
		}
		return html;
	},
	
	hide: function() {
		// temporarily hide floater offscreen
		if (this.div) {
			this.div.style.left = '-2000px';
		}
	},
	
	show: function() {
		// show ourselves after a call to hide()
		this.reposition();
	},
	
	destroy: function() {
		// destroy control and floater
		if (this.domElement && this.div) {
			this.hide();
			this.div.innerHTML = '';
			
			var body = document.getElementsByTagName('body')[0];
			try { body.removeChild( this.div ); } catch(e) {;}
			
			this.domElement = null;
			this.div = null;
		}
	},
	
	reposition: function(elem) {
		// reposition our floating div, optionally to new container
		// warning: container CANNOT change size, only position
		if (elem) {
			this.domElement = ZeroClipboard.$(elem);
			if (!this.domElement) this.hide();
		}
		
		if (this.domElement && this.div) {
			var box = ZeroClipboard.getDOMObjectPosition(this.domElement);
			var style = this.div.style;
			style.left = '' + box.left + 'px';
			style.top = '' + box.top + 'px';
		}
	},
	
	setText: function(newText) {
		// set text to be copied to clipboard
		this.clipText = newText;
		if (this.ready) this.movie.setText(newText);
	},
	
	addEventListener: function(eventName, func) {
		// add user event listener for event
		// event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel
		eventName = eventName.toString().toLowerCase().replace(/^on/, '');
		if (!this.handlers[eventName]) this.handlers[eventName] = [];
		this.handlers[eventName].push(func);
	},
	
	setHandCursor: function(enabled) {
		// enable hand cursor (true), or default arrow cursor (false)
		this.handCursorEnabled = enabled;
		if (this.ready) this.movie.setHandCursor(enabled);
	},
	
	setCSSEffects: function(enabled) {
		// enable or disable CSS effects on DOM container
		this.cssEffects = !!enabled;
	},
	
	receiveEvent: function(eventName, args) {
		// receive event from flash
		eventName = eventName.toString().toLowerCase().replace(/^on/, '');
				
		// special behavior for certain events
		switch (eventName) {
			case 'load':
				// movie claims it is ready, but in IE this isn't always the case...
				// bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function
				this.movie = document.getElementById(this.movieId);
				if (!this.movie) {
					var self = this;
					setTimeout( function() { self.receiveEvent('load', null); }, 1 );
					return;
				}
				
				// firefox on pc needs a "kick" in order to set these in certain cases
				if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
					var self = this;
					setTimeout( function() { self.receiveEvent('load', null); }, 100 );
					this.ready = true;
					return;
				}
				
				this.ready = true;
				this.movie.setText( this.clipText );
				this.movie.setHandCursor( this.handCursorEnabled );
				break;
			
			case 'mouseover':
				if (this.domElement && this.cssEffects) {
					this.domElement.addClass('hover');
					if (this.recoverActive) this.domElement.addClass('active');
				}
				break;
			
			case 'mouseout':
				if (this.domElement && this.cssEffects) {
					this.recoverActive = false;
					if (this.domElement.hasClass('active')) {
						this.domElement.removeClass('active');
						this.recoverActive = true;
					}
					this.domElement.removeClass('hover');
				}
				break;
			
			case 'mousedown':
				if (this.domElement && this.cssEffects) {
					this.domElement.addClass('active');
				}
				break;
			
			case 'mouseup':
				if (this.domElement && this.cssEffects) {
					this.domElement.removeClass('active');
					this.recoverActive = false;
				}
				break;
		} // switch eventName
		
		if (this.handlers[eventName]) {
			for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
				var func = this.handlers[eventName][idx];
			
				if (typeof(func) == 'function') {
					// actual function reference
					func(this, args);
				}
				else if ((typeof(func) == 'object') && (func.length == 2)) {
					// PHP style object + method, i.e. [myObject, 'myMethod']
					func[0][ func[1] ](this, args);
				}
				else if (typeof(func) == 'string') {
					// name of function
					window[func](this, args);
				}
			} // foreach event handler defined
		} // user defined handler for event
	}
	
};

//
// requires zclpcontainer and zclpbutton divs:
//
var zclp;
//
// initialize an instance:
//
function ZeroClipboardInit()
{
	zclp = new ZeroClipboard.Client();
	zclp.setHandCursor(true);

	zclp.addEventListener("load", function (client) {
		//debugstr("Flash movie loaded and ready.");
		domGetElementById("zclpcontainer").title =
		  locGetTagZeroClipboardReady2Copy();
	});

  zclp.addEventListener("complete", function (client, text) {
//
//  alert("complete, jQuery('zclpbutton').innerHTML=" + jQuery('#zclpbutton').get(0).id);
//  jQuery('#zclpbutton').get(0).innerHTML = "Ready to copy...";
//
    domGetElementById("zclpcontainer").title =
      locGetTagZeroClipboardHasContents();
  });

	zclp.addEventListener("mouseOver", function (client) {
		// update the text on mouse over
		zclp.setText(domGetElementContentsById("idresult"));
	});

	zclp.glue("zclpbutton", "zclpcontainer");
}

function zclpCopy()
{
  zclp.setText(domGetElementContentsById("idresult"));
}
//ZeroClipboardInit();
//domAddEventListener(window, "load", ZeroClipboardInit, false);
//
// END ZeroClipboard.js.
//

//
// usernotes ajax:
//
//
// fnc001: get script like PHP without search arguments:
//
function getScript()
{
  var strHref = window.location.href,
    strSearch = window.location.search;
  return strHref.substr(0, strHref.length - strSearch.length);
}
//
// fnc001: get script like PHP without search arguments:
//   strArg1: argument pair like name=value:
//
function appendUrlArg1(strUrl, strArg1)
{
//
  if(strArg1 == "")
  {
  	return strUrl;
  }
//
  var i, strHref = strUrl, strHref2 = "";
//
// #:
//
  i = strHref.indexOf("#");
  if(i > 0)
  {
  	strHref2 = strHref.substr(i);
  	strHref = strHref.substr(0, i);
  }
//
// ?:
//
  if(strHref.indexOf("?") < 0)
  {
  	strHref += "?";
  }
  else
  {
  	strHref += "&";
  }
//
  strHref += strArg1;
//
  if(i > 0)
  {
  	strHref += strHref2;
  }
//
  return strHref;
}
//
// fnc001: get script like PHP without search arguments:
//   strArg1: argument pair like name=value:
//
function getThisPageAppendUrlArg1(strArg1)
{
  return appendUrlArg1(window.location.href, strArg1);
}

//
// fnc001: get wait message:
//
function locGetWait()
{
	if(locIsLangLocalFr())
	{
		return "Veuillez patienter...";
  }
	else if(locIsLangLocalCn())
	{
		return "请耐心等待内容的到来...";
  }
	else
	{
		return "Please wait...";
  }
}

//
// fnc001: get wait marquee:
//
function locGetWaitMarquee()
{
  return "<center>"
    + "<marquee behavior=\"alternate\" direction=\"right\""
    + " scrollamount=\"1\""
    + " style=\"color: #008800; font-weight: bold; font-size: 18pt; width: 300px; height: 80px; vertical-align: middle;\">"
    + locGetWait() + "</marquee></center>";
}

//
// fnc001: toggle usernotes div:
//
function getdivusernotesinput(krenew)
{
	var bTodo, strDiv, strHref, strImage, strSolid;
	strDiv = "usernotesinput";
	var varObj = ajaxGetResultDiv(strDiv);
//
	if(varObj)
	{
    //
    // Googgle Chrome does not strip \r\n:
    //
    if(krenew)
    {
    	bTodo = true;
    }
    else
    {
      strSolid = trim(varObj.innerHTML);
      bTodo = (strSolid.length <= 2);
    }
    //
    if(bTodo)
    {
      //varObj.innerHTML = locGetWaitMarquee();
      strHref = getThisPageAppendUrlArg1("feedbackonly=1");
      if(krenew)
      {
        strHref += "&" + getTimeByDateObject(null);
      }
    	ajaxGet(strHref, true, strDiv, true);
    }
//
    if((! bTodo) && varObj.style.display == "block")
    {
    	strImage = "plus.gif";
  	  domHideObject(varObj);
    }
    else
    {
  	  strImage = "minus.gif";
  	  varObj.style.display = "block";
  	  //
  	  // set focus on user notes input textarea:
  	  //
  	  var xobj = document.getElementById("frmfeedback");
  	  if(xobj)
  	  {
    	  xobj = xobj.elements["notes"];
    	  if(xobj)
    	  {
      	  if(xobj.type != "hidden")
      	  {
  	  	    xobj.focus();
  	  	  }
  	  	}
    	}
    }
		var imgaddnotes = document.getElementById("imgaddnotes");
  	if(imgaddnotes)
	  {
	  	var	strImage0;
      if(strImage == "plus.gif")
      {
      	strImage0 = "minus.gif";
      }
      else
      {
      	strImage0 = "plus.gif";
      }
	  	imgaddnotes.src = imgaddnotes.src.replace(strImage0, strImage);
	  }
    return true;
  }
  else
  {
    return false;
  }
}
//
// fnc001: toggle usernotes div:
//
function toggledivusernotesinput()
{
	return getdivusernotesinput(false);
}
//
// fnc001: toggle usernotes div:
//
function renewdivusernotesinput()
{
	return getdivusernotesinput(true);
}

//
// fnc001: set politic side color:
//
function setPoliticSideColor()
{
  var ctl, ctlThis, strPoliticSide, strColorLabel;
//
  ctlThis = domGetElementById("politicside");
  strPoliticSide = ctlThis.value;
//
  if(strPoliticSide == "SECRET")
  {
    strPoliticSide = "gray";
    strColorLabel = "white";
  }
  else if(strPoliticSide == "XLEFT")
  {
    strPoliticSide = "#ff0000";
    strColorLabel = "yellow";
  }
  else if(strPoliticSide == "LEFT")
  {
    strPoliticSide = "#ff00ff";
    strColorLabel = "yellow";
  }
  else if(strPoliticSide == "CENTER")
  {
    strPoliticSide = "green";
    strColorLabel = "yellow";
  }
  else if(strPoliticSide == "RIGHT")
  {
    strPoliticSide = "gold";
    strColorLabel = "black";
  }
  else if(strPoliticSide == "XRIGHT")
  {
    strPoliticSide = "brown";
    strColorLabel = "white";
  }
  else
  {
    strPoliticSide = "";
    strColorLabel = "black";
  }
//
  ctlThis.style.color = strPoliticSide;
//
  ctl = domGetElementById("idtr2politiccolored");
  if(ctl != null)
  { 
    ctl.style.backgroundColor = strPoliticSide;
  }
//
  if(strColorLabel != "")
  {
    ctl = domGetElementById("idlabel2politiccolored");
    if(ctl != null)
    { 
      ctl.style.color = strColorLabel;
    }
  }
//
  return true;
}

//
// fnc001: get top directory:
//
function nvlGetTopDir()
{
	if(window.location.href.match(/webest/))
	{
		return "/webest/";
	}
	else
	{
		return "/";
	}
}
//
// fnc001: get flash directory:
//
function nvlGetFlashDir()
{
  return nvlGetTopDir() + "flash/";
}
//
// fnc001: prepend flash directory:
//
function nvlPrependFlashDir(strUrl)
{
  return nvlGetFlashDir() + strUrl;
}
//
// fnc001: get ggtrans directory:
//
function nvlGetGgtransDir()
{
  return nvlGetTopDir() + "ggtrans/";
}
//
// fnc001: prepend ggtrans directory:
//
function nvlPrependGgtransDir(strUrl)
{
  return nvlGetGgtransDir() + strUrl;
}
//
// fnc001: get store directory:
//
function nvlGetStoreDir()
{
  return nvlGetTopDir() + "store/";
}
//
// fnc001: prepend store directory:
//
function nvlPrependStoreDir(strUrl)
{
  return nvlGetStoreDir() + strUrl;
}

//
// fnc001: get logon username, store, then admin username by cookie:
//
function autGetUserLogon()
{
	var user_cookie;
	user_cookie = inetGetCookie("store_user_cookie");
	if(user_cookie == "")
	{
  	return inetGetCookie("admin_user_cookie");
	}
	return user_cookie;
}

//
// fnc001: get user account link:
//
function nvlGetUserAccountLink(linkClass)
{
	var strTitle, strClass, user_cookie
  strTitle = locGetTagAccount();
  user_cookie = autGetUserLogon();
  if(user_cookie == "")
  {
  	user_cookie = strTitle;
  }
  else
  {
  	strTitle += " =&gt; " + user_cookie;
  }
  if(linkClass == "")
  {
  	strClass = "";
  }
  else
  {
  	strClass = " class=\"" + linkClass + "\"";
  }
  return "<a href=\"" + nvlPrependStoreDir("admin/userinfo.php") + "\""
    + strClass
    + " title=\"" + strTitle + "\">"
    + user_cookie + "</a>";
}

//
// fnc001: replace link URL and anchor:
//
function nvlSetUserInfoLinkById(strID, strClass)
{
  var spn = domGetElementById(strID);
	if(spn)
	{
    spn.innerHTML = " | " + nvlGetUserAccountLink(strClass);
    return true;
	}
  return false;
}

//
// fnc001: get first link className in a div:
//
function nvlGetLink1ClassInDivById(strID)
{
  var spn = domGetElementById(strID);
	if(spn)
	{
    var xarr = spn.getElementsByTagName("a");
    if(xarr)
    {
    	return xarr[0].className;
    }
	}
  return "";
}

//
// fnc001: replace link URL and anchor:
//
function nvlReplaceUserLogoutLinkById(strID)
{
  var spn = domGetElementById(strID);
	if(spn)
	{
	 	var strHTML = new String(spn.innerHTML);
	 	if(! strHTML.match(/logout/i))
     {
       var regex = new RegExp("loginajax|login", "gi");
  	   strHTML = strHTML.replace(regex, "logout");
       regex = new RegExp(locGetTagLogin(), "gi");
	     strHTML = strHTML.replace(regex, locGetTagLogout());
		   spn.innerHTML = strHTML;
       return true;
		 }
	}
  return false;
}

//
// fnc001: replace link URL and anchor:
//
function nvlReplaceUserLogoutLinks()
{
	var user_cookie = autGetUserLogon();
	if(user_cookie != "")
	{
		var strClass;
		//
		nvlReplaceUserLogoutLinkById("spnlogin");
		strClass = nvlGetLink1ClassInDivById("spnlogin");
		nvlSetUserInfoLinkById("spnuserinfo", strClass);
    //
		nvlReplaceUserLogoutLinkById("spnlogin0");
		strClass = nvlGetLink1ClassInDivById("spnlogin0");
		nvlSetUserInfoLinkById("spnuserinfo0", strClass);
		//
    return true;
  }
  return false;
}

function htmLog(strHTML)
{
	var strHTMLNow = "";
	strHTMLNow = jQuery("#log").html() + strHTML;
  return jQuery("#log").html(strHTMLNow);
}

//
// globals:
//
// echo "王 ";
//
// Event:
//   IE: event
//   NS > 4.0: window.event
//   NS 3: no event
//
var brOK=false;
var isNS=false;
var isOPERA=false;
var nsOK=false;

var appVer = parseInt(navigator.appVersion.substring(0,1));
var ua = navigator.userAgent;

if(navigator.appName.indexOf("Internet Explorer") != -1)
{
  isIE=true;
  if(appVer >= 4)
  {
    brOK = navigator.javaEnabled();
  }
}

if(navigator.userAgent.indexOf("Opera") != -1)
{
  isOPERA=true;
  if(appVer >= 4)
  {
    brOK = navigator.javaEnabled();
  }
}

if(navigator.appName.indexOf("Netscape") !=-1 )
{
  isNS=true;
  if(appVer >= 4)
  {
    brOK = navigator.javaEnabled();
    nsOK=true;
  }
}

if(brOK)
{
  if(isNS)
  {
    event = window.event;
  }
}
//NS3 when using event as argument to handler.
else
{
  event = null;
}

var winPop = null, winInfo = null;
