﻿/// <reference path="yahoo.js" />
/// <reference path="yahoo-dom-event.js" />
/// <reference path="yahoo.js" />
/// <reference path="container-min.js" />

if(typeof w3Labs == 'undefined' || !w3Labs)
{
    var w3Labs = { };
}

w3Labs.QueryString = {
    GetParameterValue: function(paraName)
    {
        hu = window.location.search.substring(1);
        gy = hu.split("&");
        for (i=0;i<gy.length;i++) {
            ft = gy[i].split("=");
            if (ft[0] == paraName) {
                return ft[1];
            }
        }
    }
};


w3Labs.CommonFunction = {
    
    DisplayProcessingPanel: function (processingPanelId, parentId)
    {
        procPanel = document.getElementById(processingPanelId);
        multipagePanel = document.getElementById(parentId);
        procPanel.style.display = 'block';
        procPanel.style.left = w3Labs.CommonFunction._getClientLeft(parentId) + "px";
        procPanel.style.top = w3Labs.CommonFunction._getClientTop(parentId) + "px";
        procPanel.style.width = multipagePanel.clientWidth + "px";
        procPanel.style.height = (multipagePanel.clientHeight + 10) + "px";
        multipagePanel.style.opacity = 0.7
    },
    
    HideProcessingPanel:function(processingPanelId, parentId)
    {
        document.getElementById(processingPanelId).style.display = 'none';
        document.getElementById(parentId).style.opacity = '1';
    },
    

    _getClientLeft:function(id)
    {
        var left = 0;
        left = document.getElementById(id).offsetLeft;
        var parent = document.getElementById(id).offsetParent;
        while (parent != null) {
            left = left + parent.offsetLeft;
            parent = parent.offsetParent;
        }
        return left;
    },
    
    _getClientTop:function(id)
    {
        var top = 0;
        top = document.getElementById(id).offsetTop;
        var parent = document.getElementById(id).offsetParent;
        while (parent != null) {
            top = top + parent.offsetTop;
            parent = parent.offsetParent;
        }
        return top;
    }
    
};

w3Labs.Dialog = {
    __clientYesHandler: null,
    __clientNoHandler: null,
    __dialogYesHandler: function() {
        this.hide();
        if (w3Labs.Dialog.__clientYesHandler != null)
            w3Labs.Dialog.__clientYesHandler();
    },

    __dialogNoHandler: function() {
        this.hide();
        if (w3Labs.Dialog.__clientNoHandler != null)
            w3Labs.Dialog.__clientNoHandler();
    },

    Confirm: function(title, message, yesHandler, noHandler) {
        w3Labs.Dialog.__clientYesHandler = yesHandler;
        w3Labs.Dialog.__clientNoHandler = noHandler;

        dialog1 = new YAHOO.widget.SimpleDialog("simpleDialog1", { width: "300px", zIndex: 5, fixedcenter: true, visible: false, draggable: false, close: true, modal: true,
            text: message, icon: YAHOO.widget.SimpleDialog.ICON_HELP, constraintoviewport: true,
            buttons: [{ text: "Yes", handler: w3Labs.Dialog.__dialogYesHandler, isDefault: true },
                                                                    { text: "No", handler: w3Labs.Dialog.__dialogNoHandler}]
        });
        dialog1.setHeader(title);
        dialog1.render("dialogContainer");
        dialog1.show();
    },

    //    Alert: function(title, message, okHandler) {
    //        w3Labs.Dialog.__clientYesHandler = okHandler;
    //        dialog1 = new YAHOO.widget.SimpleDialog("simpleDialog1", { width: "300px", zIndex: 5, fixedcenter: true, visible: false, draggable: false, close: true, modal: true,
    //            text: message, icon: YAHOO.widget.SimpleDialog.ICON_ALARM, constraintoviewport: true,
    //            buttons: [{ text: "OK", handler: w3Labs.Dialog.__dialogYesHandler, isDefault: true}]
    //        });
    //        dialog1.setHeader(title);
    //        dialog1.render("dialogContainer");
    //        dialog1.show();
    //    },

    Alert: function(title, message, okHandler, dialogWidth) {
        if (typeof(dialogWidth) == 'undefined' || dialogWidth == null || dialogWidth == "")
            dialogWidth = "300px";
        w3Labs.Dialog.__clientYesHandler = okHandler;
        dialog1 = new YAHOO.widget.SimpleDialog("simpleDialog1", { width: dialogWidth, zIndex: 5, fixedcenter: true, visible: false, draggable: false, close: true, modal: true,
            text: message, icon: YAHOO.widget.SimpleDialog.ICON_ALARM, constraintoviewport: true,
            buttons: [{ text: "OK", handler: w3Labs.Dialog.__dialogYesHandler, isDefault: true}]
        });
        dialog1.setHeader(title);
        dialog1.render("dialogContainer");
        dialog1.show();
    }
};