/* --- BoxOver ---
/* --- v 2.1 17th June 2006
By Oliver Bryant with help of Matthew Tagg
http://boxover.swazz.org */

if (typeof document.attachEvent != 'undefined') {
    window.attachEvent('onload', init);
    document.attachEvent('onmousemove', moveMouse);
    document.attachEvent('onclick', checkMove);
}
else {
    window.addEventListener('load', init, false);
    document.addEventListener('mousemove', moveMouse, false);
    document.addEventListener('click', checkMove, false);
}

var oDv = document.createElement("div");
var dvBdy = document.createElement("div");
var windowlock, boxMove, fixposx, fixposy, lockX, lockY, fixx, fixy, ox, oy, boxLeft, boxRight, boxTop, boxBottom, evt, mouseX, mouseY, boxOpen, totalScrollTop, totalScrollLeft;
boxOpen = false;
ox = 10;
oy = 10;
lockX = 0;
lockY = 0;

function init() {
    oDv.appendChild(dvBdy);
    oDv.style.position = "absolute";
    oDv.style.visibility = 'hidden';
    $("#worldMap").after(oDv);
}

function defBdyStyle() {
    dvBdy.style.borderTop = '1px solid #A5CFE9';
    dvBdy.style.borderBottom = '1px solid #A5CFE9';
    dvBdy.style.borderLeft = '1px solid #A5CFE9';
    dvBdy.style.borderRight = '1px solid #F00';
    dvBdy.style.width = '200px';
    dvBdy.style.fontFamily = 'arial';
    dvBdy.style.fontSize = '11';
    dvBdy.style.padding = '4';
    dvBdy.style.color = '#1B4966';
    dvBdy.style.background = '#FFFFFF';
    dvBdy.style.filter = 'alpha(opacity=85)'; // IE
    dvBdy.style.opacity = '0.85'; // FF
    dvBdy.style.cursor = "pointer";
}

function checkElemBO(txt) { //alterar isto para caso n�o reba header o border do body n�o ficar marado!
    if (!txt || typeof (txt) != 'string') return false;
    if ((txt.indexOf('body') > -1) && (txt.indexOf('[') > -1) && (txt.indexOf('[') > -1)) {
        return true;
    } else {
        return false;
    }
}

function scanBO(curNode) {
    var content_box = curNode.getAttribute('hoverbox');
    if (checkElemBO(content_box)) {
        curNode.boHDR = getParam('header', content_box);
        curNode.boBDY = getParam('body', content_box);
        curNode.boCSSBDY = getParam('cssbody', content_box);
        curNode.boCSSHDR = getParam('cssheader', content_box);
        curNode.IEbugfix = (getParam('hideselects', content_box) == 'on') ? true : false;
        curNode.fixX = parseInt(getParam('fixedrelx', content_box));
        curNode.fixY = parseInt(getParam('fixedrely', content_box));
        curNode.absX = parseInt(getParam('fixedabsx', content_box));
        curNode.absY = parseInt(getParam('fixedabsy', content_box));
        curNode.offY = (getParam('offsety', content_box) != '') ? parseInt(getParam('offsety', content_box)) : 10;
        curNode.offX = (getParam('offsetx', content_box) != '') ? parseInt(getParam('offsetx', content_box)) : 10;
        curNode.fade = (getParam('fade', content_box) == 'on') ? true : false;
        curNode.fadespeed = (getParam('fadespeed', content_box) != '') ? getParam('fadespeed', content_box) : 0.04;
        curNode.delay = (getParam('delay', content_box) != '') ? parseInt(getParam('delay', content_box)) : 0;
        if (getParam('requireclick', content_box) == 'on') {
            curNode.requireclick = true;
            document.all ? curNode.attachEvent('onclick', showHideBox) : curNode.addEventListener('click', showHideBox, false);
            document.all ? curNode.attachEvent('onmouseover', hideBox) : curNode.addEventListener('mouseover', hideBox, false);
        }
        else {// Note : if requireclick is on the stop clicks are ignored   			
            if (getParam('doubleclickstop', content_box) != 'off') {
                document.all ? curNode.attachEvent('ondblclick', pauseBox) : curNode.addEventListener('dblclick', pauseBox, false);
            }
            if (getParam('singleclickstop', content_box) == 'on') {
                document.all ? curNode.attachEvent('onclick', pauseBox) : curNode.addEventListener('click', pauseBox, false);
            }
        }
        curNode.windowLock = getParam('windowlock', content_box).toLowerCase() == 'off' ? false : true;
        content_box = '';
        curNode.hasbox = 1;
    }
    else
        curNode.hasbox = 2;
}


function getParam(param, list) {
    var reg = new RegExp('([^a-zA-Z]' + param + '|^' + param + ')\\s*=\\s*\\[\\s*(((\\[\\[)|(\\]\\])|([^\\]\\[]))*)\\s*\\]');
    var res = reg.exec(list);
    var returnvar;
    if (res)
        return res[2].replace('[[', '[').replace(']]', ']');
    else
        return '';
}

function Left(elem) {
    var x = 0;
    if (elem.calcLeft)
        return elem.calcLeft;
    var oElem = elem;
    while (elem) {
        if ((elem.currentStyle) && (!isNaN(parseInt(elem.currentStyle.borderLeftWidth))) && (x != 0))
            x += parseInt(elem.currentStyle.borderLeftWidth);
        x += elem.offsetLeft;
        elem = elem.offsetParent;
    }
    oElem.calcLeft = x;
    return x;
}

function Top(elem) {
    var x = 0;
    if (elem.calcTop)
        return elem.calcTop;
    var oElem = elem;
    while (elem) {
        if ((elem.currentStyle) && (!isNaN(parseInt(elem.currentStyle.borderTopWidth))) && (x != 0))
            x += parseInt(elem.currentStyle.borderTopWidth);
        x += elem.offsetTop;
        elem = elem.offsetParent;
    }
    oElem.calcTop = x;
    return x;

}

var ah, ab;
function applyStyles() {
    if (ab)
        oDv.removeChild(dvBdy);
    dvBdy = document.createElement("div");

    CBE.boCSSBDY ? dvBdy.className = CBE.boCSSBDY : defBdyStyle();

    dvBdy.innerHTML = CBE.boBDY;
    ah = false;
    ab = false;
    if (CBE.boBDY != '') {
        oDv.appendChild(dvBdy);
        ab = true;
    }
}

var CSE, iterElem, LSE, CBE, LBE, totalScrollLeft, totalScrollTop, width, height;
var ini = false;

// Customised function for inner window dimension
function SHW() {
    if (document.body && (document.body.clientWidth != 0)) {
        width = document.body.clientWidth;
        height = document.body.clientHeight;
    }
    if (document.documentElement && (document.documentElement.clientWidth != 0) && (document.body.clientWidth + 20 >= document.documentElement.clientWidth)) {
        width = document.documentElement.clientWidth;
        height = document.documentElement.clientHeight;
    }
    return [width, height];
}


var ID = null;
function moveMouse(e) {
    //boxMove=true;
    e ? evt = e : evt = event;

    CSE = evt.target ? evt.target : evt.srcElement;

    if (!CSE.hasbox) {
        // Note we need to scan up DOM here, some elements like TR don't get triggered as srcElement
        iElem = CSE;
        while ((iElem.parentNode) && (!iElem.hasbox)) {
            scanBO(iElem);
            iElem = iElem.parentNode;
        }
    }

    if ((CSE != LSE) && (!isChild(CSE, dvBdy))) {
        if (!CSE.boxItem) {
            iterElem = CSE;
            while ((iterElem.hasbox == 2) && (iterElem.parentNode))
                iterElem = iterElem.parentNode;
            CSE.boxItem = iterElem;
        }
        iterElem = CSE.boxItem;
        if (CSE.boxItem && (CSE.boxItem.hasbox == 1)) {
            LBE = CBE;
            CBE = iterElem;
            if (CBE != LBE) {
                applyStyles();
                if (!CBE.requireclick)
                    if (CBE.fade) {
                    if (ID != null)
                        clearTimeout(ID);
                    ID = setTimeout("fadeIn(" + CBE.fadespeed + ")", CBE.delay);
                }
                else {
                    if (ID != null)
                        clearTimeout(ID);
                    COL = 1;
                    ID = setTimeout("oDv.style.visibility='visible';ID=null;", CBE.delay);
                }
                if (CBE.IEbugfix) { hideSelects(); }
                fixposx = !isNaN(CBE.fixX) ? Left(CBE) + CBE.fixX : CBE.absX;
                fixposy = !isNaN(CBE.fixY) ? Top(CBE) + CBE.fixY : CBE.absY;

                lockX = 0;
                lockY = 0;
                boxMove = true;
                ox = CBE.offX ? CBE.offX : 10;
                oy = CBE.offY ? CBE.offY : 10;
            }
        }
        else if (!isChild(CSE, dvBdy) && (boxMove)) {
            // The conditional here fixes flickering between tables cells.
            if ((!isChild(CBE, CSE)) || (CSE.tagName != 'TABLE')) {
                CBE = null;
                if (ID != null)
                    clearTimeout(ID);
                fadeOut();
                showSelects();
            }
        }
        LSE = CSE;
    }
    else if (((isChild(CSE, dvBdy)) && (boxMove))) {
        totalScrollLeft = 0;
        totalScrollTop = 0;

        iterElem = CSE;
        while (iterElem) {
            if (!isNaN(parseInt(iterElem.scrollTop)))
                totalScrollTop += parseInt(iterElem.scrollTop);
            if (!isNaN(parseInt(iterElem.scrollLeft)))
                totalScrollLeft += parseInt(iterElem.scrollLeft);
            iterElem = iterElem.parentNode;
        }
        if (CBE != null) {
            boxLeft = Left(CBE) - totalScrollLeft;
            boxRight = parseInt(Left(CBE) + CBE.offsetWidth) - totalScrollLeft;
            boxTop = Top(CBE) - totalScrollTop;
            boxBottom = parseInt(Top(CBE) + CBE.offsetHeight) - totalScrollTop;
            doCheck();
        }
    }

    if (boxMove && CBE) {
        // This added to alleviate bug in IE6 w.r.t DOCTYPE
        bodyScrollTop = document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
        bodyScrollLet = document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft;
        mouseX = evt.pageX ? evt.pageX - bodyScrollLet : evt.clientX - document.body.clientLeft;
        mouseY = evt.pageY ? evt.pageY - bodyScrollTop : evt.clientY - document.body.clientTop;
        if ((CBE) && (CBE.windowLock)) {
            mouseY < -oy ? lockY = -mouseY - oy : lockY = 0;
            mouseX < -ox ? lockX = -mouseX - ox : lockX = 0;
            mouseY > (SHW()[1] - oDv.offsetHeight - oy) ? lockY = -mouseY + SHW()[1] - oDv.offsetHeight - oy : lockY = lockY;
            mouseX > (SHW()[0] - dvBdy.offsetWidth - ox) ? lockX = -mouseX - ox + SHW()[0] - dvBdy.offsetWidth : lockX = lockX;
        }

        oDv.style.left = ((fixposx) || (fixposx == 0)) ? fixposx + "px" : bodyScrollLet + mouseX + ox + lockX + "px";

        oDv.style.top = ((fixposy) || (fixposy == 0)) ? fixposy + "px" : bodyScrollTop + mouseY + oy + lockY + "px";

    }
}

function doCheck() {


    if ((mouseX < boxLeft) || (mouseX > boxRight) || (mouseY < boxTop) || (mouseY > boxBottom)) {
        if (!CBE.requireclick)
        //fadeOut();
            if (CBE.IEbugfix) { showSelects(); }

        CBE = null;

    }

}

function pauseBox(e) {

    e ? evt = e : evt = event;
    boxMove = false;
    evt.cancelBubble = true;
}

function showHideBox(e) {

    oDv.style.visibility = (oDv.style.visibility != 'visible') ? 'visible' : 'hidden';

}

function hideBox(e) {

    oDv.style.visibility = 'hidden';
}

var COL = 0;
var stopfade = false;
function fadeIn(fs) {
    ID = null;
    COL = 0;
    oDv.style.visibility = 'visible';
    fadeIn2(fs);
}

function fadeIn2(fs) {
    COL = COL + fs;
    COL = (COL > 1) ? 1 : COL;
    oDv.style.filter = 'alpha(opacity=' + parseInt(100 * COL) + ')';
    oDv.style.opacity = COL;
    if (COL < 1)
        setTimeout("fadeIn2(" + fs + ")", 20);
}


function fadeOut() {
    oDv.style.visibility = 'hidden';

}

function isChild(s, d) {
    while (s) {
        if (s == d)
            return true;
        s = s.parentNode;
    }
    return false;
}

var cSrc;
function checkMove(e) {

    try {
        var cssClass = $(CSE).attr("class");

        if ((cssClass == "pnlAngola") || (cssClass=="pnlBrasil") || (cssClass=="pnlPortugal")) {
            SetSearchControlTab(cssClass);
        }
        e ? evt = e : evt = event;
        cSrc = evt.target ? evt.target : evt.srcElement;
        if ((!boxMove) && (!isChild(cSrc, oDv))) {

            fadeOut();
            if (CBE && CBE.IEbugfix) { showSelects(); }
            boxMove = true;
            CBE = null;

        }
        else {

        }
    }
    catch (errr) {

    }
}

function showSelects() {
    var elements = document.getElementsByTagName("select");
    for (i = 0; i < elements.length; i++) {
        elements[i].style.visibility = 'visible';
    }

}

function hideSelects() {
    var elements = document.getElementsByTagName("select");
    for (i = 0; i < elements.length; i++) {
        elements[i].style.visibility = 'hidden';
    }
}


/* Mapper.js ==========================================*/
var canvascheck = document.createElement('canvas');
var isIE = window.navigator.systemLanguage ? 1 : 0;
var isVM = 0;
var isJG = 0;
var isCV = canvascheck.getContext ? 1 : 0;
var jg = new Array();

try {
    if (document.namespaces) {
        isVM = 1
    }
}
catch (ex) { };

if (isVM) {
    if (document.namespaces['v'] == null) {
        var e = ["shape", "shapetype", "group", "background", "path", "formulas", "handles", "fill", "stroke", "shadow", "textbox", "textpath", "imagedata", "line", "polyline", "curve", "roundrect", "oval", "rect", "arc", "image"],
			s = document.createStyleSheet();
        for (var i = 0; i < e.length; i++) {
            s.addRule("v\\:" + e[i], "behavior: url(#default#VML); antialias: true;");
        }
        document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
    }
}

function showCoords(map, ele, x, y, w, h) { }

function getClasses(classes, string) {
    var temp = '';
    for (var j = 0; j < classes.length; j++) {
        if (classes[j] != string) {
            if (temp) {
                temp += ' ';
            }
            temp += classes[j];
        }
    }
    return temp;
}

function getClassValue(classes, string) {
    var temp = 0;
    var pos = string.length;
    for (var j = 0; j < classes.length; j++) {
        if (classes[j].indexOf(string) == 0) {
            temp = Math.min(classes[j].substring(pos), 100);
            break;
        }
    }
    return Math.max(0, temp);
}

function getClassRGBColor(classes, string, color) {
    var temp, val = color, pos = string.length;
    for (var j = 0; j < classes.length; j++) {
        if (classes[j].indexOf(string) == 0) {
            temp = classes[j].substring(pos);
            val = temp.toLowerCase();
            break;
        }
    }
    if (!val.match(/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i)) {
        val = color || '000000';
    }
    if (!isCV) {
        return val;
    }
    else {
        function hex2dec(hex) {
            return (Math.max(0, Math.min(parseInt(hex, 16), 255)));
        }
        var cr = hex2dec(val.substr(0, 2)),
			cg = hex2dec(val.substr(2, 2)),
			cb = hex2dec(val.substr(4, 2));
        return cr + ',' + cg + ',' + cb;
    }
}

function getClassAttribute(classes, string) {
    var temp = 0;
    var pos = string.length;
    for (var j = 0; j < classes.length; j++) {
        if (classes[j].indexOf(string) == 0) {
            temp = 1;
            break;
        }
    }
    return temp;
}

function getMaps(className) {
    var children = document.getElementsByTagName('img');
    var elements = new Array();
    var i = 0;
    var mapname = '';
    var child;
    var classNames;
    var j = 0;
    var mapid = '';
    for (i = 0; i < children.length; i++) {
        child = children[i];
        classNames = child.className.split(' ');
        for (j = 0; j < classNames.length; j++) {
            if (classNames[j] == className) {
                mapname = child.useMap.split("#");
                if (mapname[1] != '' && mapname[1].length >= 1) {
                    mapid = document.getElementsByName(mapname[1]);
                    if (mapid) {
                        elements.push(child);
                        break;
                    }
                }
            }
        }
    }
    return elements;
}

function fadeCanvas(id, opac) {
    var obj = document.getElementById(id);
    if (obj.fading == 1 && opac <= 100) {
        obj.style.opacity = opac / 100;
        opac += 10;
        window.setTimeout("fadeCanvas('" + id + "'," + opac + ")", 10);
    }
}
function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent)
        while (1) {
        curleft += obj.offsetLeft;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent)
        while (1) {
        curtop += obj.offsetTop;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

function getCoords(e, n, a, i, x, y, w, h, pw, ph) {
    var t, o, ox, oy, ex, ey, cx, cy, px = 0, py = 0;
    if (!e) {
        e = window.event;
    }
    if (e.pageX || e.pageY) {
        px = e.pageX;
        py = e.pageY;
    }
    ex = e.clientX;
    ey = e.clientY;
    if (self.pageXOffset || self.pageYOffset) {
        ox = self.pageXOffset;
        if (ox > 0 && px == ex) {
            ex -= ox;
        }
        oy = self.pageYOffset;
        if (oy > 0 && py == ey) {
            ey -= oy;
        }
    }
    else if (document.documentElement) {
        ox = document.documentElement.scrollLeft;
        oy = document.documentElement.scrollTop;
    }
    else if (document.body) {
        ox = document.body.scrollLeft;
        oy = document.body.scrollTop;
    }
    if (document.body.scrollHeight != ph || document.body.scrollWidth != pw) {
        var o = document.getElementById(i);
        var t = findPosXY(o);
        x = t.x;
        y = t.y;
    }
    cx = Math.min(Math.max(ex + ox - x, 0), w);
    cy = Math.min(Math.max(ey + oy - y, 0), h);
    showCoords(n, a, cx, cy, w, h);
}

function findPosXY(ele) {
    var t;
    var d = {
        x: ele.offsetLeft,
        y: ele.offsetTop
    };
    if (ele.offsetParent) {
        t = findPosXY(ele.offsetParent);
        d.x += t.x;
        d.y += t.y;
    }
    return d;
}

function roundedRect(ctx, x, y, width, height, radius, nopath) {
    if (!nopath) ctx.beginPath();
    ctx.moveTo(x, y + radius);
    ctx.lineTo(x, y + height - radius);
    ctx.quadraticCurveTo(x, y + height, x + radius, y + height);
    ctx.lineTo(x + width - radius, y + height);
    ctx.quadraticCurveTo(x + width, y + height, x + width, y + height - radius);
    ctx.lineTo(x + width, y + radius);
    ctx.quadraticCurveTo(x + width, y, x + width - radius, y);
    ctx.lineTo(x + radius, y);
    ctx.quadraticCurveTo(x, y, x, y + radius);
    if (!nopath) ctx.closePath();
}

function getRadius(radius, width, height) {
    var part = (Math.min(width, height) / 100);
    radius = Math.max(Math.min(100, radius / part), 0);
    return radius + '%';
}

function addMapper() {
    var themaps = getMaps('mapper');
    var image, object, bgrnd, canvas, blind, context, mapid, mname, ele, atr;
    var classes = '', newClasses = '', func = '', tmp, i, j, o, b, c, d, r, t, n, f, x, y, w, h, pw, ph;
    for (i = 0; i < themaps.length; i++) {
        image = themaps[i];
        object = image.parentNode;
        if (image.id == '') {
            image.id = "gmipam_" + i;
        }
        object.style.position = (object.style.position == 'static' || object.style.position == '' ? 'relative' : object.style.position);
        object.style.height = image.height + 'px';
        object.style.width = image.width + 'px';
        object.style.padding = 0 + 'px';
        object.style.MozUserSelect = "none";
        object.style.KhtmlUserSelect = "none";
        object.unselectable = "on";
        r = 0;
        n = 0;
        f = 0;
        b = '0000ff';
        c = '000000';
        o = 50;
        if (isCV) {
            canvas = document.createElement('canvas');
        }
        else if (isVM) {
            canvas = document.createElement(['<var style="zoom:1;overflow:hidden;display:block;width:' + image.width + 'px;height:' + image.height + 'px;padding:0;">'].join(''));
        }
        else {
            canvas = document.createElement('div');
        }
        canvas.id = image.id + '_canvas';
        classes = image.className.split(' ');
        r = getClassValue(classes, "iradius");
        o = getClassValue(classes, "iopacity");
        b = getClassRGBColor(classes, "iborder", '243407');
        c = getClassRGBColor(classes, "icolor", 'daff4a');
        n = getClassAttribute(classes, "noborder");
        f = getClassAttribute(classes, "nofade");
        d = getClassAttribute(classes, "showcoords");
        o = o == 0 ? 0.50 : o / 100;
        r = parseInt(Math.min(Math.min(image.width / 4, image.height / 4), r));
        newClasses = getClasses(classes, "mapper");
        image.className = newClasses;
        mname = image.useMap.split("#");
        mname = mname[1];
        mapid = document.getElementsByName(mname);
        if (mapid.length > 0) {
            for (j = 0; j < mapid[0].areas.length; j++) {
                if (mapid[0].areas[j].shape.match(/(rect|poly|circle)/i)) {
                    if (window.opera || mapid[0].areas[j].coords != '') {
                        if (mapid[0].areas[j].id == '') {
                            mapid[0].areas[j].id = mname + '_' + j;
                        }
                        if (isVM || isIE) {
                            func = mapid[0].areas[j].onmouseover;
                            if (func != null) {
                                tmp = String(func);
                                func = tmp.substr(23, tmp.length - 25);
                            }
                            mapid[0].areas[j].onmouseover = new Function('setAreaOver(this,"' + canvas.id + '","' + b + '","' + c + '","' + o + '",' + n + ',' + f + ',' + i + ');' + func);
                            func = mapid[0].areas[j].onmouseout;
                            if (func != null) {
                                tmp = String(func);
                                func = tmp.substr(23, tmp.length - 25);
                            }
                            mapid[0].areas[j].onmouseout = new Function('setAreaOut(this,"' + canvas.id + '",' + f + ',' + i + ');' + func);
                        }
                        else {
                            func = mapid[0].areas[j].getAttribute("onmouseover");
                            mapid[0].areas[j].setAttribute("onmouseover", "setAreaOver(this,'" + canvas.id + "','" + b + "','" + c + "','" + o + "'," + n + "," + f + "," + i + ");" + func);
                            func = mapid[0].areas[j].getAttribute("onmouseout");
                            mapid[0].areas[j].setAttribute("onmouseout", "setAreaOut(this,'" + canvas.id + "'," + f + "," + i + ");" + func);
                        }
                    }
                }
            }
        }
        canvas.style.height = image.height + 'px';
        canvas.style.width = image.width + 'px';
        canvas.height = image.height;
        canvas.width = image.width;
        canvas.left = 0;
        canvas.top = 0;
        canvas.style.position = 'absolute';
        canvas.style.left = 0 + 'px';
        canvas.style.top = 0 + 'px';
        canvas.fading = 0;
        image.className = '';
        image.style.cssText = '';
        image.left = 0;
        image.top = 0;
        image.style.position = 'absolute';
        image.style.height = image.height + 'px';
        image.style.width = image.width + 'px';
        image.style.left = 0 + 'px';
        image.style.top = 0 + 'px';
        image.style.MozUserSelect = "none";
        image.style.KhtmlUserSelect = "none";
        image.unselectable = "on";
        if (isIE) {
            image.style.filter = "Alpha(opacity=" + (o * 100) + ")";
        }
        else {
            image.style.opacity = 0;
            image.style.MozOpacity = 0;
            image.style.KhtmlOpacity = 0;
        }
        if (isCV && r > 0) {
            bgrnd = document.createElement('canvas');
        }
        else if (isVM && r > 0) {
            bgrnd = document.createElement(['<var style="zoom:1;overflow:hidden;display:block;width:' + image.width + 'px;height:' + image.height + 'px;padding:0;">'].join(''));
        }
        else {
            bgrnd = document.createElement('img');
            bgrnd.src = image.src;
        }
        bgrnd.id = image.id + '_image';
        bgrnd.left = 0;
        bgrnd.top = 0;
        bgrnd.style.position = 'absolute';
        bgrnd.style.height = image.height + 'px';
        bgrnd.style.width = image.width + 'px';
        bgrnd.style.left = 0 + 'px';
        bgrnd.style.top = 0 + 'px';
        object.insertBefore(canvas, image);
        blind = document.createElement('div');
        blind.id = mname + '_blind';
        blind.className = "blind_area";
        blind.left = 0;
        blind.top = 0;
        blind.style.position = 'absolute';
        blind.style.height = image.height + 'px';
        blind.style.width = image.width + 'px';
        blind.style.left = 0 + 'px';
        blind.style.top = 0 + 'px';
        blind.innerHTML = " ";
        object.insertBefore(blind, image);
        if (isCV) {
            context = canvas.getContext("2d");
            context.clearRect(0, 0, canvas.width, canvas.height);
        }
        else if (!isVM && !isCV) {
            if (isIE) {
                if ($.browser.version.substr(0, 1) >= '8') {
                    canvas.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + (o * 100) + ")";
                }
                else {
                    canvas.style.filter = "Alpha(opacity=" + (o * 100) + ")";
                }
            }
            else {
                canvas.style.opacity = o;
                canvas.style.MozOpacity = o;
                canvas.style.KhtmlOpacity = o;
            }
            if (typeof (window['jsGraphics']) !== 'undefined') {
                jg[i] = new jsGraphics(canvas);
                isJG = 1;
            }
        }
        object.insertBefore(bgrnd, canvas);
        if (isCV && r > 0) {
            bgrnd.height = image.height;
            bgrnd.width = image.width;
            context = bgrnd.getContext("2d");
            context.clearRect(0, 0, bgrnd.width, bgrnd.height);
            roundedRect(context, 0, 0, bgrnd.width, bgrnd.height, r);
            context.clip();
            context.fillStyle = 'rgba(0,0,0,0)';
            context.fillRect(0, 0, bgrnd.width, bgrnd.height);
            context.drawImage(image, 0, 0, bgrnd.width, bgrnd.height);
        }
        else if (isVM && r > 0) {
            bgrnd.height = image.height;
            bgrnd.width = image.width;
            r = getRadius(r, bgrnd.width, bgrnd.height);
            bgrnd.innerHTML = '<v:roundrect arcsize="' + r + '" strokeweight="0" filled="t" stroked="f" fillcolor="#ffffff" style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:0px;top:0px;width:' + bgrnd.width + 'px;height:' + bgrnd.height + 'px;"><v:fill src="' + image.src + '" type="frame" /></v:roundrect>';
        }
        if (d > 0) {
            ele = document.getElementById(image.id);
            w = parseInt(image.width);
            h = parseInt(image.height);
            t = findPosXY(ele);
            x = t.x;
            y = t.y;
            ph = document.body.scrollHeight;
            pw = document.body.scrollWidth;
            if (isVM || isIE) {
                func = image.onmousemove;
                if (func != null) {
                    tmp = String(func);
                    func = tmp.substr(23, tmp.length - 25);
                }
                image.onmousemove = new Function('getCoords(event,"' + mname + '",0,"' + image.id + '",' + x + ',' + y + ',' + w + ',' + h + ',' + pw + ',' + ph + ');' + func);
            }
            else {
                func = image.getAttribute("onmousemove");
                image.setAttribute("onmousemove", "getCoords(event,'" + mname + "',0,'" + image.id + "'," + x + "," + y + "," + w + "," + h + "," + pw + "," + ph + ");" + func);
            }
            if (mapid.length > 0) {
                for (j = 0; j < mapid[0].areas.length; j++) {
                    if (mapid[0].areas[j].shape.match(/(rect|poly|circle)/i)) {
                        if (window.opera || mapid[0].areas[j].coords != '') {
                            atr = mapid[0].areas[j].id;
                            if (isVM || isIE) {
                                func = mapid[0].areas[j].onmousemove;
                                if (func != null) {
                                    tmp = String(func);
                                    func = tmp.substr(23, tmp.length - 25);
                                }
                                mapid[0].areas[j].onmousemove = new Function('getCoords(event,"' + mname + '","' + atr + '","' + image.id + '",' + x + ',' + y + ',' + w + ',' + h + ',' + pw + ',' + ph + ');' + func);
                            }
                            else {
                                func = mapid[0].areas[j].getAttribute("onmousemove");
                                mapid[0].areas[j].setAttribute("onmousemove", "getCoords(event,'" + mname + "','" + atr + "','" + image.id + "'," + x + "," + y + "," + w + "," + h + "," + pw + "," + ph + ");" + func);
                            }
                        }
                    }
                }
            }
        }
    }
}

var mapperOnload = window.onload;
window.onload = function() {
    if (mapperOnload) mapperOnload();
    addMapper();
}



