function mapZoomedDiv_MouseOver(event) {
    canClickClose = 'no';
    if (mapDisappearTimeout) {
        clearTimeout(mapDisappearTimeout);
        canOpen = 'yes'; 
    }
}

function mapZoomedDiv_MouseOut(event) {
    canClickClose = 'yes';
    if (canOpen == 'yes') {
        canOpen = 'no';
        mapDisappearTimeout = setTimeout('hideAfterFade(\'mapZoomedDiv\', 100, 0, 400); if ( ttHide == 0) { tt_HideInit(); }', 500); 
    }
}

function zoomedMap_XMouseOver(event) {
    $('mapZoomedDiv').style.display = '';
    document.body.style.cursor = 'pointer';
    $('ContentPlaceHolder1_imgMapZoomedClose').style.display = 'block';
    $('ContentPlaceHolder1_imgMapZoomed').style.display = 'none';
}

function zoomedMap_XMouseOut(event) {
    document.body.style.cursor = 'default';
    $('ContentPlaceHolder1_imgMapZoomed').style.display = 'block';
    $('ContentPlaceHolder1_imgMapZoomedClose').style.display = 'none';
}

function zoomedMap_XClick(event) {
    if (canOpen == 'yes') {
        canOpen = 'no';
        document.body.style.cursor = 'default';
        hideAfterFade('mapZoomedDiv', 100, 0, 400);

        if (ttHide == 0) {
            tt_HideInit();
        }
    }
}

function zoomedMap_MouseOver(addX, addY, loc, event) {
    document.body.style.cursor = 'pointer';
    var pos = findPosition(addX, addY, $('mapZoomedDiv'));
    TagToTip('zoom' + loc + 'Div', STICKY, true, BORDERWIDTH, '1', WIDTH, '180px', FIX, [pos[0], pos[1]])
}

function zoomedMap_MouseOut(event) {
    document.body.style.cursor = 'default';
}








window.onresize = function() { onResizeHelper(); }
var mapPositioned;
var canOpen = 'yes';
function onResizeHelper()
{
    if ( $('mapZoomedDiv') )
    {
        if (navigator.appVersion.indexOf("MSIE")!=-1)
        {
            temp = navigator.appVersion.split("MSIE");
            version = parseFloat(temp[1]);
            
            if (version>7)
            {
                var pos = findPosition(234, 20, $('body')); 
                $('mapZoomedDiv').style.position = 'absolute';
                $('mapZoomedDiv').style.left = pos[0] + 'px';
                $('mapZoomedDiv').style.top = pos[1] + 'px';
                mapPositioned = true;
            }
            else
            {
                var pos = findPosition(233, 19, $('body')); 
                $('mapZoomedDiv').style.position = 'absolute';
                $('mapZoomedDiv').style.left = pos[0] + 'px';
                $('mapZoomedDiv').style.top = pos[1] + 'px';
                mapPositioned = true;
            }
        }
        else
        {
            var pos = findPosition(234, 41, $('body')); 
            $('mapZoomedDiv').style.position = 'absolute';
            $('mapZoomedDiv').style.left = pos[0] + 'px';
            $('mapZoomedDiv').style.top = pos[1] + 'px';
            mapPositioned = true;
        }
    }

    $("contentWrapper").style.minHeight = $("leftDivI").offsetHeight + $("mainFormI").offsetHeight + "px";
    var parsedCW = parseInt($("contentWrapper").style.minHeight);
    var dummyOT = $("dummy").offsetTop;
    var heightCW;
    if ( navigator.appVersion.indexOf("MSIE") != -1 )
    {
            if (dummyOT - 87 > parsedCW)
                heightCW = dummyOT - 87 + "px";
            else
                heightCW = parsedCW  + "px";
    }
    else
    {
            if (dummyOT - 110 > parsedCW)
                heightCW = dummyOT - 94 + "px";
            else
                heightCW = parsedCW + 25 + "px";
    }
    $("contentWrapper").style.height = heightCW;
}

function onResizeHelperCIS()
{
    window.onresize = function() { onResizeHelperCIS(); }
    
    $("contentWrapper").style.minHeight = $("leftDivI").offsetHeight + $("mainFormI").offsetHeight + "px";
    var parsedCW = parseInt($("contentWrapper").style.minHeight);
    var dummyOT = $("dummy").offsetTop;
    var heightCW;
    if ( navigator.appVersion.indexOf("MSIE") != -1 )
    {
        if (dummyOT - 87 > parsedCW)
            heightCW = dummyOT - 70 + "px";
        else
            heightCW = parsedCW  + "px";
    }
    else
    {
        if (dummyOT - 110 > parsedCW)
            heightCW = dummyOT - 94 + "px";
        else
            heightCW = parsedCW + 25 + "px";
    }
    $("contentWrapper").style.height = heightCW;
}

function onLoadHelper()
{
    onResizeHelper();
    
    if ( $('mapZoomedDiv') ) 
    { 
        // Preload zoom hover image for close button
        var hoverImg = new Image(); 
        hoverImg.src = '/App_Themes/Default/Images/sw-map-zoom-hover.png'; 
    }
}

function findPosition(x, y, imgMap )
{
    if (imgMap == null)
        return [x,y];
    var curleft = curtop = 0;
    if (imgMap.offsetParent)
    {
        curleft = imgMap.offsetLeft;
        curtop = imgMap.offsetTop;
        while (imgMap = imgMap.offsetParent)
        {
            curleft += imgMap.offsetLeft;
            curtop += imgMap.offsetTop;
        }
    }
    return [curleft + x,curtop + y];
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(var i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(var i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}

function hideAfterFade(id, opacStart, opacEnd, millisec)
{
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd)
    { 
        for(var i = opacStart; i >= opacEnd; i--)
        {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++;
        } 
        setTimeout( "$('mapZoomedDiv').style.visibility = 'hidden'; canOpen = 'yes';", (timer * speed) );
    }
    else if(opacStart < opacEnd)
    { 
        for(var i = opacStart; i <= opacEnd; i++) 
        { 
            if( i == 0)
            {
                $('mapZoomedDiv').style.visibility = 'hidden';
            }
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++;
        } 
    } 
}

function $(ctrl)
{
    if ( typeof ctrl == 'string' )
        return document.getElementById( ctrl );
    else if ( typeof ctrl=== 'object' )
        return ctrl;
    
    return null;
}

