/*  lightBox.js, version 1.5.0
*  @author Seiji Yamaguchi
/*--------------------------------------------------------------------------*/
var lightBox = Class.create();
lightBox.prototype = {
    initialize: function(url, width, height, color, alpha){
        this.selects = document.getElementsByTagName('select');
        this.actLightBox(url, width, height, color, alpha);
    },
    actLightBox: function(url, width, height, color, alpha) {
        this.deleteSelect();
        this.insertIframe(url, width, height, color, alpha);
    },
    insertIframe : function(url, width, height, color, alpha) {
        this.sizeGet();
        var top = (this.innerHeight/2) - (Math.round(height/2)) + this.windowHeight;
        var left = (this.innerWidth/2) - (Math.round(width/2)) + this.windowWidth;
        var html = '<iframe src="'+url+'" ';
        html += 'id="lightBox"  name="lightBox" ';
        html += 'style="position:absolute; z-Index:10; top:'+top+'px; left:'+left+'px; background-color:white; width:'+width+'px; height:'+height+'px;">Now Loading...</iframe><div id="mapCover" style="position:absolute;height:'+this.innerHeight+'px; width:'+this.innerWidth+'px; z-Index:9; background-color:'+color+'; top:'+this.windowHeight+'px; left:'+this.windowWidth+'px;"></div>';
        var body = document.getElementsByTagName('body');
        new Insertion.Bottom(body[0], html);
        var mapCover = $('mapCover');
        mapCover.style.filter = 'alpha(opacity='+alpha+')';
        var alpha2 = alpha/100;
        mapCover.style.mozopacity = alpha2;
        mapCover.style.opacity = alpha2;
        if(navigator.userAgent.indexOf("Opera") > -1) window.scrollBy(0, height/2 + 50);
        Element.observe(window, 'resize', this.resizeWindow.bindAsEventListener(this));
        Element.observe(window, 'scroll', this.resizeWindow.bindAsEventListener(this));
    },
    sizeGet : function() {
        if(document.all) {
            this.windowWidth = document.documentElement.scrollLeft;
            this.windowHeight = document.documentElement.scrollTop;
            this.innerHeight = document.documentElement.clientHeight;
            this.innerWidth = document.documentElement.clientWidth;
        }
        else {
            this.windowWidth = window.pageXOffset;
            this.windowHeight = window.pageYOffset;
            this.innerHeight = window.innerHeight;
            this.innerWidth = window.innerWidth;
        }
    },
    resizeWindow : function() {
        if($('lightBox')) {
            this.sizeGet();
            Element.setStyle($('mapCover'),
            {
            'height' : this.innerHeight + 'px',
            'width'  : this.innerWidth + 'px',
            'top'    : this.windowHeight + 'px',
            'left'   : this.windowWidth + 'px'
            });
        }
    },
    deleteSelect : function() {
        for(i=0; i<this.selects.length; i++) Element.setStyle(this.selects[i], {visibility : 'hidden'
});
    }
}
var closeIframe = function() {
    var lightBox = document.getElementById('lightBox');
    var mapCover = document.getElementById('mapCover');
    lightBox.parentNode.removeChild(lightBox);
    mapCover.parentNode.removeChild(mapCover);
    var selects = document.getElementsByTagName('select');
    for(i=0; i<selects.length; i++) selects[i].style.visibility = 'visible';
}