﻿function setPageSize() {
    setTimeout('setPageSizeForce(false);', 1);
}
function resizePage() {
    BizElement.Element.main1.setStyle({ 'height': '' });
    BizElement.Element.main2.setStyle({ 'height': '' });
    BizElement.initializeForce();
    setPageSizeForce(true);
}
function checkPageResizable() {
    setPageSize();
    Event.observe(window, "resize", setPageSize, false);
}
function setPageSizeForce(force) {
    if (force || BizElement.checkPageSize()) {
        BizElement.resizeElement(BizElement.Element.content, BizElement.Size.contentHeight);
        BizElement.resizeElement(BizElement.Element.leftborder, BizElement.Size.contentHeight);
        BizElement.resizeElement(BizElement.Element.rightborder, BizElement.Size.contentHeight);
        BizElement.resizeElement(BizElement.Element.contentLine, BizElement.Size.lineHeight);
        BizElement.resizeElement(BizElement.Element.main1, BizElement.Size.mainHeight);
        BizElement.resizeElement(BizElement.Element.main2, BizElement.Size.mainHeight);
        BizElement.resizable.height.each(function(A) { var o = $(A.key); if (o.style.height != (BizElement.Size.mainHeight - A.value + 'px')) { o.setStyle({ 'height': BizElement.Size.mainHeight - A.value + 'px' }); } });
        BizElement.resizable.width.each(function(A) { var o = $(A.key); var curWidth = BizElement.getViewPort().width; o.setStyle({ 'width': (curWidth < A.value) ? A.value + 'px' : curWidth + 'px' }); });
    }
}
var layerBackCount = 0;
function layerOn(width, height, url, top, left, isLayerbackOff, customID, scrolling) {
    var layerID = customID ? customID : 'layer';
    var layerFrameID = layerID + 'frame';

    if ($(layerID)) { layerOff(layerID); }

    var layers = $('layers');
    var layer = new Element('div', { 'id': layerID, 'class': 'layer' });
    var layerFrame = new Element('iframe', { 'id': layerFrameID, 'frameBorder': '0', 'class': 'layerframe' });
    if(scrolling) layerFrame.setAttribute("scrolling", scrolling);

    layer.insert(layerFrame);
    layers.insert(layer);

    var layerTop;
    var layerLeft;
    var layerMarginTop;
    var layerMarginLeft;

    if (!isLayerbackOff) {
        layerbackOn(0.25);
    }

    if (top && left) {
        layerTop = top + 'px';
        layerMarginTop = '0px';
        layerLeft = left + 'px';
        layerMarginLeft = '0px';
    }
    else {
        var isOverHeight = (BizElement.viewport.height|| BizElement.getViewPort().height) > height;
        layerTop = (isOverHeight) ? '50%' : '20px';
        layerLeft = '50%';
        layerMarginTop = (isOverHeight) ? 0 - Math.floor(height / 2) + 'px' : '0px';
        layerMarginLeft = 0 - Math.floor(width / 2) + 'px';
    }
    width += 'px';
    height += 'px';

    layer.setStyle({ 'top': layerTop, 'left': layerLeft, 'width': width, 'height': height, 'marginTop': layerMarginTop, 'marginLeft': layerMarginLeft, 'display': 'block', 'zIndex': 2000 });
    layerFrame.setStyle({ 'width': width, 'height': height });
    layerFrame.setAttribute('src', url);
}
function layerOff(customID) {
    var layerID = customID ? customID : 'layer';
    if ($(layerID)) { $(layerID).remove(); }
    layerbackOff();
}
function layerbackOn(opacity) {
    var height = BizElement.viewport.height;
    if (!height) { height = BizElement.getViewPort().height; }
    $('layerback').setStyle({ 'height': height + 'px', 'zIndex': 1000 });
    new Effect.Appear('layerback', { duration: 0, from: opacity, to: opacity });
    layerBackCount++;
}
function layerbackOff() {
    if (layerBackCount == 1) {
        $('layerback').setStyle({ 'height': '0px', 'zIndex': -1 });
    }
    if (layerBackCount > 0) { layerBackCount--; }
}
function layerResize(widthAdd, heightAdd, isExtend) {
    var layer = $('layer');
    var layerFrame = $('layerframe');
    var layerWidth = layer.getWidth() + widthAdd;
    var layerHeight = layer.getHeight() + heightAdd;

    var layerTop;
    var layerLeft;
    var layerMarginTop;
    var layerMarginLeft;

    if (!isExtend) {
        layerTop = '50%';
        layerLeft = '50%';
        layerMarginTop = 0 - Math.floor(layerHeight / 2) + 'px';
        layerMarginLeft = 0 - Math.floor(layerWidth / 2) + 'px';
    }
    layerWidth += 'px';
    layerHeight += 'px';

    layer.setStyle({ 'top': layerTop, 'left': layerLeft, 'width': layerWidth, 'height': layerHeight, 'marginTop': layerMarginTop, 'marginLeft': layerMarginLeft });
    layerFrame.setStyle({ 'width': layerWidth, 'height': layerHeight });
}
function redirectMenu(url) {
    location.href = url;
}
function loadingLayerOn(msg, cancelCode) {
    var loadingURL = 'layout/layer/loading.aspx';

    if (msg) { loadingURL += '?work=' + encodeURIComponent(msg); }
    if (cancelCode) { loadingURL += '&cancel=' + encodeURIComponent(cancelCode); }
    
    layerOn(272, 120, loadingURL, false, false, false, 'loading');
}
function loadingLayerOff() {
    parent.layerOff('loading');
}
function setTooltip(tooltipSet) {
    for (var i = 0; i < tooltipSet.length; i++) {
        try {
            document.getElementById(tooltipSet[i][0]).setAttribute('title', tooltipSet[i][1]);
        } catch (e) { }
    }
}

var PopManager = {
    open: function(type, url) {
        switch (type) {
            case "GUIDE":
                var g = window.open(
                    'http://www.bizhard.com/Guide/Default.aspx',
                    'FlashGuide',
                    'location=0,status=0,scrollbars=0,resizable=0,width=902,height=625,top=20,left=20');
                g.focus();
                break;
            case "HELP":
                var h = window.open(
                    (!url) ? 'http://www.bizhard.com/Manual/Startup/Join.aspx' : url,
                    'Guide',
                    'location=0,status=0,scrollbars=0,resizable=0,width=902,height=625,top=20,left=20');
                h.focus();
                break;

            case "BILL":
                layerOn(904, 512, "/Bill/Default.aspx", null, null, false, "Bill", "no");
                break;

            case "CALC":
                layerOn(904, 512, "/Bill/Default.aspx?mode=calc", null, null, false, "Bill", "no");
                break;

            case "CONSULTING":
                layerOn(574, 645, "/Center/Pop/ConsultingList.aspx", null, null, false, "ConsultingList");
                return false;

            case "PACKAGE":
                location.href = "http://advert.estsoft.com/?event=200910231012555";
                break;

            case "EXPLORER":
                location.href = "http://advert.estsoft.com/?event=200807311616948";
                break;

            case "MESSENGER":
                location.href = "http://advert.estsoft.com/?event=200807311450939";
                break;

            case "WID":
                location.href = "http://advert.estsoft.com/?event=200905113610240";
                break;

            case "ACTIVEX":
                location.href = "http://advert.estsoft.com/?event=200901161482524";
                break;

            case "MOBILE":
                location.href = "http://advert.estsoft.com/?event=200911112051281";
                break;
                
            case "COMPARERATES":
                layerOn(624, 417, "/Center/Pop/CompareRates.aspx", null, null, false, "CompareRates");
                return false;

            case "USERATES":
                layerOn(574, 904, "/Center/Pop/UseRates.aspx", null, null, false, "UseRates");
                return false;

            case "BIZHARDJP":
                layerOn(449, 406, "/Center/Pop/CultureCheck.aspx", null, null, false, "BizHardJP");
                return false;

            case "RECOMMEND":
                layerOn(524, 488, "/Center/Pop/Recommendation.aspx", null, null, false, "Recommendation");
                return false;

            case "RECOMMENDPREVIEW":
                var w = window.open("/Center/Pop/RecommenderMailPreview.aspx", "RecommendPreview");
                w.focus();
                return false;

            case "SUGGEST":
                layerOn(732, 285, "/User/Pop/pop_suggest.aspx", null, null, false, "Suggest");
                break;

            case "MAILUS":
                var w = window.open('/User/Support/MailUs.aspx', 'mailus', 'width=652,height=545');
                w.focus();
                break;
        }
    }
}

function LoadFlash(id, src, width, height, wmode)
{
    if(!wmode) wmode = "opaque";
    document.write("<object id=\"" + id + "\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"" + location.protocol.toLowerCase() + "//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" width=\"" + width + "\" height=\"" + height + "\" align=\"middle\">");
    document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
    document.write("<param name=\"allowFullScreen\" value=\"false\" />");
    document.write("<param name=\"wmode\" value=\"" + wmode + "\" />");
    document.write("<param name=\"movie\" value=\"" + src + "\" />");
    document.write("<param name=\"quality\" value=\"high\" />");
    document.write("<param name=\"bgcolor\" value=\"#ffffff\" />");
    document.write("<embed id=\"" + id + "\" src=\"" + src + "\" wmode=\"" + wmode + "\" quality=\"high\" bgcolor=\"#ffffff\" width=\"" + width + "\" height=\"" + height + "\" align=\"middle\" allowscriptaccess=\"sameDomain\" allowfullscreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />");
    document.write("</object>");
}