
var active_map_region = '';
function activateRegionPopup(target){
    var container = document.getElementById("city_list_show_area");

    if (!!container && active_map_region == '' ){
        container.style.display = 'block';
        var t = document.getElementById(target) ;
        if (!!t){
            t.className = "cityListPanel_show";
            active_map_region =  t;
            adjust();
        }

    }
}

function deActivateRegionPopup(){
    var container = document.getElementById("city_list_show_area");
    var box = document.getElementById("lightbox_overlay");
    if (container.style.display == 'block'){
            container.style.display = "none";
            box.style.display = 'none';
            active_map_region.className = "cityListPanel";
            active_map_region = '';
    }

}
// Get a style property (name) of a specific element (elem)
function getStyle( elem, name ) {
    // If the property exists in style[], then it’s been set recently (and is current)
    if (elem.style[name])
        return elem.style[name];

    // Otherwise, try to use IE’s method
    else if (elem.currentStyle)
        return elem.currentStyle[name];

    // Or the W3C’s method, if it exists
    else if (document.defaultView && document.defaultView.getComputedStyle) {
        // It uses the traditional ‘text-align’ style of rule writing, instead of textAlign
        name = name.replace(/([A-Z])/g,"-$1");
        name = name.toLowerCase();

        // Get the style object and get the value of the property (if it exists)
        var s = document.defaultView.getComputedStyle(elem,"");
        return s && s.getPropertyValue(name);

    // Otherwise, we’re using some other browser
    } else
        return null;
}


function getHeight(elem){
     return parseInt(getStyle(elem,'height'));

}
function getWidth(elem){
     return parseInt(getStyle(elem,'width'));

}
// A function for setting the horizontal position of an element
function setX(elem, pos) {
    // Set the ‘left’ CSS property, using pixel units
    elem.style.left = pos + 'px';
}

// A function for setting the vertical position of an element
function setY(elem, pos) {
    // Set the ‘left’ CSS property, using pixel units
    elem.style.top = pos + 'px';
}
// A function for determining how far horizontally the browser is scrolled
function scrollX() {
    // A shortcut, in case we’re using Internet Explorer 6 in Strict Mode
    var de = document.documentElement;
    return self.pageXOffset || ( de && de.scrollLeft ) ||  document.body.scrollLeft;
}

// A function for determining how far vertically the browser is scrolled
function scrollY() {
    // A shortcut, in case we’re using Internet Explorer 6 in Strict Mode
    var de = document.documentElement;
    // If the pageYOffset of the browser is available, use that
    return self.pageYOffset ||  ( de && de.scrollTop ) ||  document.body.scrollTop;
}

// Find the height of the viewport
function windowHeight() {
    // A shortcut, in case we’re using Internet Explorer 6 in Strict Mode
    var de = document.documentElement;

    // If the innerHeight of the browser is available, use that
    return self.innerHeight || ( de && de.clientHeight ) ||  document.body.clientHeight;
}

// Find the width of the viewport
function windowWidth() {
    // A shortcut, in case we’re using Internet Explorer 6 in Strict Mode
    var de = document.documentElement;

    // If the innerWidth of the browser is available, use that
    return self.innerWidth || ( de && de.clientWidth ) || document.body.clientWidth;
}


// Reposition the gallery to be at the center of the page
// even when the page has been scrolled
function adjust(){
    // Locate the gallery
    var obj = document.getElementById("city_list_show_area");
    var status  = getStyle(obj,'display');
    var box = document.getElementById("lightbox_overlay");
    box.style.height = pageHeight()+"px";
    box.style.width = pageWidth()+"px";
    if(status == 'block'){
        box.style.display = "block";
    }
  //  setOpacity(box,65);
    box.setOpacity(.65);
    // Make sure that the gallery exists
    if ( !obj ) return;

    // Find its current height and width
    var w = getWidth( obj );
    var h = getHeight( obj );

    // Position the box, vertically, in the middle of the window

    var t = scrollY() + ( windowHeight() / 2 ) - ( h / 2 );
    // But no heigher than the top of the page
    if ( t < 0 ) t = 0;

    // Position the box, horizontally, in the middle of the window

    var l = scrollX() + ( windowWidth() / 2 ) - ( w / 2 );
    // But no less than the left of the page
    if ( l < 0 ) l = 0;

    // Set the adjusted position of the element
    setY( obj, t );
    setX( obj, l );
   //    var box = document.getElementById("lightbox_overlay");
};

// Readjust the position of the gallery every time
// the user scrolls the page or resizes the browser
window.onresize = document.onscroll = adjust;




// Returns the height of the web page
// (could change if new content is added to the page)
function pageHeight() {
  //  return document.body.scrollHeight;
     var de = document.documentElement;
     return self.innerHeight || ( de && de.clientHeight ) ||  document.body.clientHeight;
}

// Returns the width of the web page
function pageWidth() {
    return document.body.scrollWidth;
}











 



       


