﻿// Declaring class "Timer"
var Timer = function() {
    // Property: Frequency of elapse event of the timer in millisecond
    this.Interval = 1000;

    // Property: Whether the timer is enable or not
    this.Enable = new Boolean(false);

    // Event: Timer tick
    this.Tick;

    // Member variable: Hold interval id of the timer
    this.timerId = 0;

    // Function: Start the timer
    this.Start = function() {
        if (this.Enable == false) {
            this.Enable = new Boolean(true);
            // Member variable: Hold instance of this class
            var thisObject;
            thisObject = this;
            if (thisObject.Enable) {
                thisObject.timerId = setInterval(
                                            function() {
                                                thisObject.Tick();
                                            }, thisObject.Interval * 1);
            }
        }
    };

    // Function: Stops the timer
    this.Stop = function() {
        this.Enable = new Boolean(false);
        clearInterval(this.timerId);
    };

};

//<![CDATA[
var GlvDelayedNextPageNo;

function WebForm_CallbackComplete_SyncFixed() {
    // the var statement ensure the variable is not global
    for (var i = 0; i < __pendingCallbacks.length; i++) {
        callbackObject = __pendingCallbacks[i];
        if (callbackObject && callbackObject.xmlRequest &&
			(callbackObject.xmlRequest.readyState == 4)) {
            // SyncFixed: line move below // WebForm_ExecuteCallback(callbackObject);
            if (!__pendingCallbacks[i].async) {
                __synchronousCallBackIndex = -1;
            }
            __pendingCallbacks[i] = null;
            var callbackFrameID = "__CALLBACKFRAME" + i;
            var xmlRequestFrame = document.getElementById(callbackFrameID);
            if (xmlRequestFrame) {
                xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
            }
            // SyncFixed: the following statement has been moved down from above;
            WebForm_ExecuteCallback(callbackObject);
        }
    }
}

var OnloadWithoutSyncFixed = window.onload;

window.onload = function Onload() {
    if (typeof (WebForm_CallbackComplete) == "function") {
        // Set the fixed version
        WebForm_CallbackComplete = WebForm_CallbackComplete_SyncFixed;
        // CallTheOriginal OnLoad
        if (OnloadWithoutSyncFixed != null) OnloadWithoutSyncFixed();
    }
}

if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(elt /*, from*/) {
        var len = this.length;

        var from = Number(arguments[1]) || 0;
        from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
        if (from < 0)
            from += len;

        for (; from < len; from++) {
            if (from in this &&
          this[from] === elt)
                return from;
        }
        return -1;
    };
}

//var prm;
//$(document).ready(function() {
//    prm = Sys.WebForms.PageRequestManager.getInstance();
//});

//]]>
//------------------COOKIES-----//
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}

//-----------------------GENERALS--------------------------//
String.prototype.trim = function() { return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, "")) }
String.prototype.startsWith = function(str) { return (this.match("^" + str) == str) }
String.prototype.endsWith = function(str){ return (this.match(str + "$") == str) }

function FnArray() {
    this.funcs = new Array;
}

FnArray.prototype.add = function(f) {
    if (typeof f != "function") {
        f = new Function(f);
    }
    this.funcs[this.funcs.length] = f;
}

FnArray.prototype.execute = function(group) {
    if (!group) { group = '' }
    for (var i = 0; i < this.funcs.length; i++) {
        var rt = this.funcs[i](group);
        if (rt == false) { return false }
    }
    return true
}

function getURLParam(strParamName) {
    var strReturn = "";
    var strHref = window.location.href;
    if (strHref.indexOf("?") > -1) {
        var strQueryString = strHref.substr(strHref.indexOf("?")+1);
        var aQueryString = strQueryString.split("&");
        for (var iParam = 0; iParam < aQueryString.length; iParam++) {
            if (aQueryString[iParam].indexOf(strParamName + "=") == 0) {
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                break;
            }
        }
    }
    return strReturn;
}

function getUrlVars() {
    var vars = [], hash;
    if (window.location.href.indexOf('?') > 0) {
        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        for (var i = 0; i < hashes.length; i++) {
            hash = hashes[i].split('=');
            vars.push(hash[0]);
            vars[hash[0]] = hash[1];
        }
    }
    return vars;
}

function IsNumeric(sText) {
    var ValidChars = "0123456789.";
    var IsNumber = true;
    var Char;

    for (i = 0; i < sText.length && IsNumber == true; i++) {
        Char = sText.charAt(i);
        if (ValidChars.indexOf(Char) == -1) {
            IsNumber = false;
        }
    }
    return IsNumber;
}

function IsNumericNotNULL(sText) {
    if (!sText) { return false };
    if (sText.length == 0) { return false};
    return IsNumeric(sText);  
}

function Trim(str, chr) {
    if (!chr) { chr = " " }
    while (str.charAt(0) == (chr)) {
        str = str.substring(1);
    }
    while (str.charAt(str.length - 1) == chr) {
        str = str.substring(0, str.length - 1);
    }
    return str;
}

function FormatVbToNum(str) {
    return str.replace(/,/, ".")
}

function rgbToHex(str) {
    str = str.replace(/rgb\(|\)/g, "").split(",");
    str[0] = parseInt(str[0], 10).toString(16).toLowerCase();
    str[1] = parseInt(str[1], 10).toString(16).toLowerCase();
    str[2] = parseInt(str[2], 10).toString(16).toLowerCase();
    str[0] = (str[0].length == 1) ? '0' + str[0] : str[0];
    str[1] = (str[1].length == 1) ? '0' + str[1] : str[1];
    str[2] = (str[2].length == 1) ? '0' + str[2] : str[2];
    return ('#' + str.join(""));
}

function GetWindowHeight() {
    myHeight = 0;
    if (typeof (window.innerHeight) == 'number') {
        //Non-IE
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myHeight = document.body.clientHeight;
    }
    return myHeight
}

function GetWindowWidth() {
    var myWidth = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
    }
    return myWidth;
}

/////////////////////////dropdowns
function clearboxoptions(obj) {
    while (obj.options.length) {
        obj.remove(0);
    }
}

function returnSelectboxtext(obj) {
    var selectedArray = new Array();
    var selObj = obj
    var i;
    var count = 0;
    for (i = 0; i < selObj.options.length; i++) {
        if (selObj.options[i].selected) {
            selectedArray[count] = selObj.options[i].text;
            count++;
        }
    }
    if (selectedArray[0] == "")
        return 0;
    else
        return selectedArray;
}

function returnSelectboxValue(obj) {
    var selectedArray = new Array();
    var selObj = obj
    var i;
    var count = 0;
    for (i = 0; i < selObj.options.length; i++) {
        if (selObj.options[i].selected) {
            selectedArray[count] = selObj.options[i].value;
            count++;
        }
    }
    if (selectedArray[0] == "")
        return 0;
    else
        return selectedArray;
}

function getIndex(obj) {
    for (var i = 0; i < obj.parentNode.children.length; i++)
        if (obj.parentNode.children[i].id == obj.id)
        return i;
    return -1;
}

/////////////////////////dropdowns
//-------------------------------------------------------TELERIC GRID---------------------
var RadGridClientID;
var MsgNOT_SELECTED_RECORD;
var MsgCHOOSE_ONLY_1;

function checkSelected() {
    var grid = $find(RadGridClientID);
    var selectedRows = grid.get_selectedItems();
    if (selectedRows.length > 0) {
        return true
    }
    alert(MsgNOT_SELECTED_RECORD)
    return false;
}

function checkSelectedonlyOne() {
    var grid = $find(RadGridClientID);
    var selectedRows = grid.get_selectedItems();
    if (selectedRows.length == 1) {
        return true;
    }
    alert(MsgCHOOSE_ONLY_1)
    return false;
}


function GetSelectedIds() {
    var grid = $find(RadGridClientID);

    var selectedRows = grid.get_selectedItems();
    var cell = new Array();
    for (var i = 0; i < selectedRows.length; i++) {
        var row = selectedRows[i];
        cell[i] = row.getDataKeyValue("ID");
        //here cell.innerHTML holds the value of the cell
    }
    return cell
}
//----------------------------------------------------------------------------
            function checkEnter(e){ //e is event object passed from function invocation
                return checkKey(e, 13);
             }

            function checkUp(e) { //e is event object passed from function invocation
                return checkKey(e, 38);
            }

            function checkDown(e) { //e is event object passed from function invocation
                return checkKey(e, 40);
            }

            function checkKey(e,AsciiCode) { //e is event object passed from function invocation
                var characterCode //literal character code will be stored in this variable

                if (e && e.which) { //if which property of event object is supported (NN4)
                    e = e
                    characterCode = e.which //character code is contained in NN4's which property
                }
                else {
                    e = e
                    characterCode = e.keyCode //character code is contained in IE's keyCode property
                }

                if (characterCode == AsciiCode) { //if generated character code is equal to ascii 13 (if enter key)
                    return true
                }
                else {
                    return false
                }

            }

            function getAsciiKey(e) { //e is event object passed from function invocation
                var characterCode //literal character code will be stored in this variable

                if (e && e.which) { //if which property of event object is supported (NN4)
                    e = e
                    characterCode = e.which //character code is contained in NN4's which property
                }
                else {
                    e = e
                    characterCode = e.keyCode //character code is contained in IE's keyCode property
                }

                return characterCode 
            }

//---------------------TEXT BOX------------------------------//

function onTextBox_onfocus(txt,label) {
    if (txt.value == label) {
        txt.value = '';
        txt.className = 'textbox_inputFocus';
    }
}

function onTextBox_onblur(txt, label) {
    if (txt.value == '') {
        txt.value = label;
        txt.className = 'textbox_input';
    }
}

function ValidateInteger(e) {
    var evtobj = window.event ? event : e //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
    var unicode = evtobj.charCode ? evtobj.charCode : evtobj.keyCode
    var actualkey = String.fromCharCode(unicode)
    if (actualkey == "1" || actualkey == "2" || actualkey == "3" || actualkey == "4" || actualkey == "5" || actualkey == "6" || actualkey == "7" || actualkey == "8" || actualkey == "9" || actualkey == "0"
                || actualkey == "*" || actualkey == "+" || actualkey == "-" || actualkey == "/" || actualkey == ")" || actualkey == "(" || unicode == 32 || unicode == 8 || unicode == 46 || unicode == 37 || unicode == 39 || unicode == 9)
        return true

    return false
}

function ValidateDouble(e) {
    var evtobj = window.event ? event : e //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
    var unicode = evtobj.charCode ? evtobj.charCode : evtobj.keyCode
    var actualkey = String.fromCharCode(unicode)
    if (actualkey == "1" || actualkey == "2" || actualkey == "3" || actualkey == "4" || actualkey == "5" || actualkey == "6" || actualkey == "7" || actualkey == "8" || actualkey == "9" || actualkey == "0"
                || actualkey == "," || unicode == 32 || unicode == 8 || unicode == 46 || unicode == 37 || unicode == 39 || unicode == 9)
        return true

    return false
}

function ValidateIntegerStrict(e) {
    var evtobj = window.event ? event : e //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
    var unicode = evtobj.charCode ? evtobj.charCode : evtobj.keyCode
    var actualkey = String.fromCharCode(unicode)
    if (actualkey == "1" || actualkey == "2" || actualkey == "3" || actualkey == "4" || actualkey == "5" || actualkey == "6" || actualkey == "7" || actualkey == "8" || actualkey == "9" || actualkey == "0" || unicode == 32 || unicode == 8 || unicode == 46 || unicode == 37 || unicode == 39 || unicode == 9)
        return true

    return false
}

function ValidateEmail(email,alertMsg) {

    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var address = email;
    if (reg.test(address) == false) {
        alert(alertMsg);
        return false;
    }
    return true 
}

//--------------------MENU BUTTON------------------------//
       function MenuButton_Object(){
            this.pnlMainID="";
            this.DivMenuArrowID="";
            this.ClientID = "";
            this.pnl;
            this.button;
            this.DefaultStyle="DivMenuArrowCss";
            this.OpenPanel = function() {
                if (this.active) {
                    pnl = document.getElementById(this.pnlMainID);
                    button = document.getElementById(this.DivMenuArrowID);

                    if (pnl.style.display == '') {                        
                        if (this.Timer.Enable == false) {
                            this.ClosePanel();
                        }
                        this.TimerFlag = 0;
                    } else {
                        if (this.active) {
                            pnl.style.display = '';
                            this.getPosition();
                            pnl.style.display = 'none';
                            CollapseDiv(this.pnlMainID, this.expand);
                            pnl.style['opacity'] = 1;
                            pnl.style['-moz-opacity'] = 1;
                            if (pnl.filters) pnl.filters.alpha['opacity'] = 100;
                            //$('#' + this.DivMenuArrowID).css("z-index", "100");
                            button.style.zIndex = parseInt(this.zIndex) + 2;
                            //setTimeout(this.ClientID + ".StartTheTimer()", 4000)
                            this.StartTheTimer();
                        }
                    }
                }
            };
            this.ClosePanel = function() {
                 if (this.active && document.getElementById(this.pnlMainID).style.display == '' && LockAnimation==false) {
                    this.Timer.Stop();
                    this.active = false;
                    var PaddingTop = $("#" + this.pnlMainID).css("paddingTop").replace("px", "") * 1;
                    var PaddingBottom = $("#" + this.pnlMainID).css("paddingBottom").replace("px", "") * 1;
                    var goFrom = $("#" + this.pnlMainID).innerHeight() - PaddingTop - PaddingBottom;
                    var CurrentObject = this;
                    var obj = this;
                    var t1 = new Tween(document.getElementById(this.pnlMainID).style, 'height', Tween.regularEaseIn, goFrom, 0, 0.3, 'px');
                    t1.onMotionFinished = function() { document.getElementById(CurrentObject.pnlMainID).style.height = goFrom + 'px'; document.getElementById(CurrentObject.DivMenuArrowID).className = CurrentObject.DefaultStyle; CurrentObject.active = true; document.getElementById(CurrentObject.pnlMainID).style.display = 'none'; document.getElementById(CurrentObject.DivMenuArrowID).style.zIndex = obj.zIndex; CurrentObject.onPanelClose(); };
                    if (this.expand == "up") {
                        var t2 = new Tween(document.getElementById(this.pnlMainID).style, 'marginTop', Tween.regularEaseIn, (document.getElementById(this.pnlMainID).style.marginTop.replace("px", "") * 1), (this.DefaultMarginTop.replace("px", "") * 1), 0.3, 'px');
                        t2.start();
                    }
                    t1.start();
                }
            };
            this.StartTheTimer = function() {
                if (this.active) {
                    if (this.Timer.Enable == false) {
                        var CurrentObject = this;
                        this.Timer.Tick = function() {
                            if (CurrentObject.TimerFlag == 0) {
                                CurrentObject.ClosePanel();
                            }
                        };
                        this.Timer.Start();
                    }
                }
            };        
            this.TimerFlag=0;
            this.active=true;
            this.expand="down";
            this.DefaultMarginTop="0px";
            this.getPosition;
            this.Timer = new Timer();
            this.onPanelClose = function() { return null };
            this.zIndex = 23;
        }

        //----------------------------------------------DROP DOWN MENU----------//
      function DropDownMenu_Object(){
            this.pnlMainID="";
            this.divButtonID="";
            this.ClientID = "";
            this.pnl;
            this.button;
            this.OpenPanel = function() {
                if (this.active) {
                     pnl = document.getElementById(this.pnlMainID);
                     button = document.getElementById(this.divButtonID);

                    if (pnl.style.display == '') {
                        this.TimerFlag = 0;
                    } else {
                        pnl.style.display = '';
                        pnl.style['opacity'] = 1;
                        pnl.style['-moz-opacity'] = 1;
                        if (pnl.filters) pnl.filters.alpha['opacity'] = 100;

                        this.getPosition();

                        button.className = 'DropDownMenuIn';
                        setTimeout(this.ClientID + ".StartTheTimer()", 2000)
                    }
                }
            };
            this.ClosePanel = function() {
                this.active = false;
                var CurrentObject = this;
                opacityTween = new OpacityTween(document.getElementById(this.pnlMainID), Tween.strongEaseOut, 100, 0, 1);
                opacityTween.onMotionFinished = function() { document.getElementById(CurrentObject.pnlMainID).style.display = 'none'; document.getElementById(CurrentObject.divButtonID).className = 'GeneralBorderColorFlat GeneralBgColorFlat DropDownMenu'; CurrentObject.active = true; };
                opacityTween.start();
            };
            this.StartTheTimer = function() {
                if (this.TimerFlag == 0) {
                    this.ClosePanel();
                } else {
                    setTimeout(this.ClientID + ".StartTheTimer()", 2000)
                }
            };
            this.TimerFlag = 0;
            this.active=true;
            this.getPosition;
        }


        //HTML CONTAINER
        var IframeWindow;
        function openIframeWindow(Title, URL, Width, Height) {
            IframeWindow = document.createElement('div');
            IframeWindow.id = "HtmlIframe";

            var HtmlWindow = '<div class="ModalTransparent"></div>';
            HtmlWindow += '<div style="width: 100%; position: fixed; left: 0; top: 0; z-index: 10001;">';
            HtmlWindow += '<center><div class="ModalWindow" Style="margin-top: 15%;min-height: 100px;display:inline-block;">';
            HtmlWindow += '<div class="CloseDiv"><a href="#" class="buttonSimple2" onclick="document.body.removeChild(IframeWindow);return false;">X</a></div>';
            HtmlWindow += '<div class="HeaderDiv">' + Title + '</div>';
            HtmlWindow += '<div class="ContentDiv"><IFRAME src="' + URL + '" width="' + Width + '" height="' + Height + '" scrolling="auto" frameborder="0"></IFRAME></div></div>';
            HtmlWindow += '</center></div>';

            IframeWindow.innerHTML = HtmlWindow;
            document.body.appendChild(IframeWindow);
        }
        //HTML ALERT
        var AlertMessager;
        function openAlertMessager(Message, MessageType) {
            if (document.getElementById("HtmlAlertMessager")) { document.body.removeChild(AlertMessager) };
            
            AlertMessager = document.createElement('div');
            AlertMessager.id = "HtmlAlertMessager";
            var HtmlWindow = "";

            if (MessageType == "success") {
                HtmlWindow = "<div class='ResultsSuccess'"
            } else if (MessageType == "failed") {
                HtmlWindow = "<div class='ResultsFailed'"
            } else {
                HtmlWindow = "<div class='AlertMessager'"
            }

            HtmlWindow += " style='position:fixed; top:200px; right:-410px; max-width:400px; min-width:200px;cursor:pointer;' onclick=\"$('#HtmlAlertMessager>div').animate({ right: '-430' }, 1200, function() { document.body.removeChild(AlertMessager)});\">" + Message + "</div>"
            AlertMessager.innerHTML = HtmlWindow;
            document.body.appendChild(AlertMessager);

            $("#HtmlAlertMessager>div").animate({
                right: '-10'
            }, 1200, 'easeOutBounce');            
            //$("#HtmlAlertMessager>div").effect('Slide', {}, 1500, function() { alert(1) });
        }

        //------------------------------------------CubeRotator-----------------//
        function Cube_Object() {
            this.ID;
            this.URL;
            this.ImageURL;
            this.Title;
            this.Description;
        }

        function CubeRotator_Object() {
            this.CubeContainer;
            this.HiddenContainer;
            this.ClientID = "";
            this.DefaultStyle = "CubeRotatorMain";
            this.Cubes = new Array();
            this.NextButton;
            this.PreviousButton;
            this.CubesHeight = 100;
            this.CubesWidth = 150;
            this.tc1 = null;
            this.Page = 0;
            this.PageSize = 5;
            this.CubeStyle = "CubeStyle";
            this.ExpandType = "Vertical";
            this.ExpandTime = 1;
            this.MaxImageWidth = "50%";
            this.FillContainer = function() {
                this.HiddenContainer.innerHTML = '';
                if (this.tc1) { this.tc1.stop(); }
                if (this.Page == 0) { this.ResetButtons() };
                this.FillCube(0);
            };
            this.FillCube = function(i) {
                var CubIndex = (this.Page * this.PageSize) + i
                var MaxItem = (this.Page + 1) * this.PageSize;
                if (MaxItem > this.Cubes.length) { MaxItem = this.Cubes.length };
                if (CubIndex < MaxItem) {
                    if (this.ExpandType == "Vertical") {
                        this.HiddenContainer.innerHTML += '<div id="sq' + this.ClientID + i + '" style="width:' + this.CubesWidth + 'px;height:' + this.CubesHeight + 'px;position:relative;top:-' + (i + 1) * this.CubesHeight + 'px;">' + this.GetCubeHTML(this.Cubes[CubIndex]) + '</div>';
                        var Distance = this.CubeContainer.clientHeight - (i * this.CubesHeight) - ((i + 1) * this.CubesHeight)
                        var obj = this;
                        this.tc1 = new Tween(document.getElementById('sq' + obj.ClientID + i).style, 'top', Tween.elasticEaseOut, -((i + 1) * this.CubesHeight), Distance, this.ExpandTime, 'px');
                        this.tc1.onMotionFinished = function() { obj.FillCube(i + 1) };
                        this.tc1.start();
                    } else {
                        var Distance = this.CubeContainer.clientWidth;
                        this.HiddenContainer.innerHTML += '<div id="sq' + this.ClientID + i + '" style="float:left;width:' + this.CubesWidth + 'px;height:' + this.CubesHeight + 'px;position:relative;left:' + Distance + 'px;">' + this.GetCubeHTML(this.Cubes[CubIndex]) + '</div>';
                        var obj = this;
                        this.tc1 = new Tween(document.getElementById('sq' + obj.ClientID + i).style, 'left', Tween.elasticEaseOut, Distance, 0, this.ExpandTime, 'px');
                        this.tc1.onMotionFinished = function() { obj.FillCube(i + 1) };
                        this.tc1.start();
                    }
                }
            };
            this.AddCube = function(url, title, description, image, ID) {
                var cb = new Cube_Object();
                cb.Title = title;
                cb.URL = url;
                cb.ImageURL = image;
                cb.Description = description;
                cb.ID = ID;
                this.Cubes.push(cb);
            };
            this.GetCubeHTML = function(cb) {
            var htm = "<div class='" + this.CubeStyle + "' style='height:" + ((this.CubesHeight * 1) - 10) + "px;overflow:hidden;'>";
                htm += "<div style='margin:5px; height:100%; overflow:hidden;'>"
                if (cb.URL.length > 0) { htm += "<a href='" + cb.URL + "'>"; }
                if (cb.ImageURL.length > 0) { htm += "<img src='" + cb.ImageURL + "' style='max-height:" + ((this.CubesHeight * 1) - 27) + "px; max-width:" + this.MaxImageWidth + ";' hspace='4' vspace='2' align='left'/>"; }
                htm += "<b>" + cb.Title + "</b>";
                htm += "<br/>" + cb.Description;
                if (cb.URL.length > 0) { htm += "</a>" };
                htm += "</div>"
                htm += "</div>"
                return htm
            };
            this.TotalPages = function() {return (this.Cubes.length / this.PageSize)}
            this.NextPage = function() {
                if (((this.Page * 1) + 2) >= this.TotalPages()) { $("#" + this.NextButton.id).css("opacity", "0.40").css("filter", "alpha(opacity=40)"); };

                if (((this.Page * 1) + 1) < this.TotalPages()) {
                    this.Page = (this.Page * 1) + 1;
                    $("#" + this.PreviousButton.id).css("filter", "alpha(opacity=100)").css("opacity", "1");
                    this.FillContainer();
                }
            };
            this.PreviousPage = function() {
            if ((this.Page * 1) - 2 < 0) { $("#" + this.PreviousButton.id).css("opacity", "0.40").css("filter", "alpha(opacity=40)"); };
                
                if ((this.Page * 1) - 1 >= 0) {
                    this.Page = (this.Page * 1) - 1;
                    $("#" + this.NextButton.id).css("filter", "alpha(opacity=100)").css("opacity", "1");
                    this.FillContainer();
                }
            };
            this.ResetButtons = function() {
                if(this.PreviousButton)$("#" + this.PreviousButton.id).css("opacity", "0.40").css("filter", "alpha(opacity=40)");
                if (this.NextButton)$("#" + this.NextButton.id).css("filter", "alpha(opacity=100)").css("opacity", "1");
            }
        }


        //-------------------------------Global Expand Panel------------------------------//
           
            function ExpandPanel_Object(){
            this.OpenedBy;
            this.TargetControlID;
            this.TriggerControlID;
            this.EnableTimer=false;
            this.ExpandType = 1;  //"0-Horizontal , 1-Vertical"
            this.ClientID;
            this.OpenPanel = function() {
                if (this.active) {
                    var pnl = document.getElementById(this.TargetControlID);
                    var button = document.getElementById(this.TriggerControlID);

                    if (pnl.style.display == '') {
                        this.TempDisable = true;
                        if (this.OpenedBy == this.TriggerControlID) {
                            if (this.EnableTimer) {
                                this.TimerFlag = 0;
                            } else {
                                this.ClosePanel();
                            }
                        } else {
                            this.OpenedBy = this.TriggerControlID;
                        }
                    } else {
                        //pnl.style.display='';
                        if (this.ExpandType == 0) {
                            CollapseDivHor(this.TargetControlID);
                        } else {
                            CollapseDiv(this.TargetControlID);
                        }
                        //pnl.style['opacity'] = 1;
                        //pnl.style['-moz-opacity'] = 1;
                        //pnl.style.filter = 'alpha(opacity=100)'
                        //if (pnl.filters) { pnl.filters.alpha['opacity'] = 100 };
                        this.OpenedBy = this.TriggerControlID;
                        if (this.EnableTimer) {
                            var obj = this;
                            setTimeout(function() { obj.StartTheTimer() }, 2000);
                        }
                        this.onOpenPanel();
                        this.TempDisable = true;
                        if (this.HideOnOutsideClick) {
                            var obj = this;
                            $('html').click(function() {
                                if (obj.TempDisable == true) { obj.TempDisable = false; return }
                                obj.ClosePanel()
                            });
                            $('#' + this.TargetControlID).click(function(event) {
                                event.stopPropagation();
                            });
                            $('#' + this.TriggerControlID).click(function(event) {
                                event.stopPropagation();
                            });
                        }
                    }
                }
            };
            this.ClosePanel = function() {
                var pnl = document.getElementById(this.TargetControlID);
                if (this.active && pnl.style.display == '') {
                    this.active = false;
                    if (this.ExpandType == 0) {
                        CollapseDivHor(this.TargetControlID);
                    } else {
                        CollapseDiv(this.TargetControlID);
                    }
                    var obj = this;
                    obj.active = true;
                    //opacityTween = new OpacityTween(document.getElementById(this.TargetControlID), Tween.strongEaseOut, 100, 0, 1);
                    //opacityTween.onMotionFinished = function() { document.getElementById(obj.TargetControlID).style.display = 'none';  };
                    //opacityTween.start();
                    this.onClosePanel();
                }
            };
            this.StartTheTimer=function(){          
                        if(this.TimerFlag==0){
                            this.ClosePanel();
                        }else{
                            var obj=this;
                            setTimeout(function(){obj.StartTheTimer()}, 2000);
                        }
                    };        
            this.TimerFlag=0;
            this.active=true;
            this.onOpenPanel = function() { return null };
            this.onClosePanel = function() { return null };
            this.TempDisable=false;
            this.HideOnOutsideClick = true;
        }


        //--------------------------------BetweenValidator----------------------------------------//
        function BetweenValidator_Object() {
            this.FromControlID;
            this.ToControlID;

            this.Init = function() {
                var _FromControlID = this.FromControlID;
                var _ToControlID = this.ToControlID;
                $("select[id$=" + this.FromControlID + "]").change(function() {
                    var FromSelection = $("select[id$=" + _FromControlID + "] option:selected").val() * 1;
                    $("select[id$=" + _ToControlID + "] option").each(function() {
                        var Selection = $(this).val() * 1;
                        if (Selection < FromSelection && Selection > 0 && FromSelection > 0) {
                            $(this).attr("disabled", "disabled");
                            $(this).removeAttr("selected");
                        } else {
                            $(this).removeAttr("disabled");
                        }
                    });
                });
                $("select[id$=" + this.ToControlID + "]").change(function() {
                    var ToControlID = $("select[id$=" + _ToControlID + "] option:selected").val() * 1;
                    $("select[id$=" + _FromControlID + "] option").each(function() {
                        var Selection = $(this).val() * 1;
                        if (Selection > ToControlID && Selection > 0 && ToControlID > 0) {
                            $(this).attr("disabled", "disabled");
                            $(this).removeAttr("selected");
                        } else {
                            $(this).removeAttr("disabled");
                        }
                    });
                });
            }
        }

        //------------------Pager---------------//
            function PagerObject(){
                this.onPageClick = function(pagenum) { return true };
            }

       //-------------MODAL WINDOW----------//
            function ModalWindow_Object() {
                this.WindowClientID;
                this.open = function() {
                    $('#' + this.WindowClientID).fadeIn('slow');
                };

                this.hide = function() {
                    $('#' + this.WindowClientID).fadeOut('slow');
                };
            }

            //--------------CHARTS-----//
            function Chart_Object() {
                this.AxisType = "numeric"; //numeric,date;
                this.Plot = new Array; //Example [[1, 2], [3, 5.12], [5, 13.1], [7, 33.6], [9, 85.9], [11, 219.9]]
                this.Title = "";
                this.ChartDivID;
                this.RenderChart = function() {
                    var MaxYaxis = 0;
                    $.each(this.Plot, function(index, value) {
                        if (value[1] > MaxYaxis) { MaxYaxis = value[1] };
                    });
                    MaxYaxis = parseInt(MaxYaxis) + 1;

                    if (this.AxisType == "numeric") {
                        $.jqplot(this.ChartDivID, [this.Plot],
                            { title: this.Title,
                                axes: { yaxis: { min: 0, max: MaxYaxis} }
                            });
                    } else if (this.AxisType == "date") {
                        $.jqplot(this.ChartDivID, [this.Plot], {
                            title: this.Title,
                            axes: {
                                xaxis: {
                                    renderer: $.jqplot.DateAxisRenderer,
                                    tickOptions: {
                                        formatString: '%b&nbsp;%#d'
                                    }
                                }, yaxis: { min: 0, max: MaxYaxis }
                            },
                            highlighter: {
                                show: true,
                                sizeAdjust: 7.5
                            }
                        });
                    }
                }
            }
