/*
   Copyright 2009 Cory J. Geesaman (http://cory.geesaman.com/)
   http://www.inetgui.org/
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
var eCWState = { Normal:1, Minimized:2, Collapsed:4, Docked:8, Maximized:16 };
var eCWStyle = { Normal:1, Tool:2, Popout:4, Menu:8 };
//  eCWSide and eCDPosition values (Top, Right, Bottom, Left) must match
var eCWSide = { Top:1, Right:2, Bottom:4, Left:8 };
var eCDPosition = { Float:0, Top:1, Right:2, Bottom:4, Left:8, All:15 };
////////////////////////////////////////////
var eCCDirection = { None:0, Up:1, Right:2, Down:4, Left:8 };
var eCDUType = { Unknown:0, String:2, Number:4, Currency:8, DateTime:16, Color:32, Font:64 };
var eCDCType = { Unknown:0, Multiple:1, String:2, Number:4, Currency:8, DateTime:16, Color:32, Font:64, Enumeration:128, Selection:256 };
var eCDOType = { Undefined:0, Database:1, Hashfile:2, Table:4, Pattern:8, MetaPattern:16, Trend:32, Report:64 };
var eCCOrientation = { Float:0, Horizontal:1, Vertical:2 };
var eCCAlign = { Default:0, Left:1, Center:2, Right:4, Stretch:8, Float:16 };
var eCCAlignCalc = { Horizontal:1, Vertical:2, Both:3 };
var eCCVAlign = { Default:0, Top:1, Middle:2, Bottom:4, Stretch:8, Float:16 };
var eCCScaleOn = { Default:0, Low:1, High:2, Horizontal:4, Vertical:8 };
var eCBState = { Normal:1, Hover:2, Down:4 };
var eCMIType = { Header:1, Normal:2, Separator:4, Radio:8, Check:16 };
var eCCBorderStyle = { Solid:0, Raised:1, Lowered:2, LoweredBevel:6, RaisedBevel: 5, LoweredOutline:10, RaisedOutline:9, Inset:16, Sizeable:32 };
var bufferChars = new Array('#', '|', '~', '[', ']', '(', ')', ';', ':', '!', '@', '$', '^', '*', '(', ')', '-', '_');//, '/', '?', '+');
var eCObjectType = { None:0, Browser:1, Session:2, Window:4, Control:8, Layer:16, Float:32 };
var eCDataObjectType = { Undefined:0, Database:1, Index:2, Hashfile:4, Table:8, Transformation:16, Pattern:32, MetaPattern:64, Object:128 };
var eCColorShade = { Unknown:0, White:1, Grey:2, Blue:4, Green:8, Purple:16, Yellow:32, Orange:64, Pink:128, Red:256, Brown:512 };

    //         number, number
function cWCord(x, y) {
    if(isNaN(x)) { if((x.indexOf('%') >= 0) || (x.toLowerCase() == 'auto')) { this.X = x; } else { this.X = 0; } } else { this.X = x - 0; }
    if(isNaN(y)) { if((y.indexOf('%') >= 0) || (y.toLowerCase() == 'auto')) { this.Y = y; } else { this.Y = 0; } } else { this.Y = y - 0; }
}
function BufferAsArray(data, level) {
    if(data.indexOf(BufferChar(level)) >= 0) { return(true); }
    if(level >= bufferChars.length - 2) {
        if(data.indexOf(bufferChars[bufferChars.length - 2]) >= 0) { return(true); }
        if(data.indexOf(bufferChars[bufferChars.length - 1]) >= 0) { return(true); }
    } else {
        for(var i = level; i < bufferChars.length; i++) {
            if(data.indexOf(bufferChars[i]) >= 0) { return(true); }
        }
    }
    return(false);
}
function BufferChar(level) {
	if(level >= (this.bufferChars.length - 2)) {
		return(bufferChars[bufferChars.length - 2] + (level - (bufferChars.length - 2)) + bufferChars[bufferChars.length - 1]);
	} else {
		return(bufferChars[level]);
	}
}
function BufferIn(data) {
    return(RealBufferIn(data, 1));
}
function BufferOut(data) {
    return(RealBufferOut(data, 1));
}
function RealBufferIn(data, level) {
	var ret;
	if(BufferAsArray(data, level)) {
		ret = data.split(BufferChar(level));
		if(ret.length > 0) {
			for(var i = 0; i < ret.length; i++) {
				ret[i] = RealBufferIn(ret[i], level + 1);
			}
		}
	} else {
	    data = data+'';
		for(var i = (bufferChars.length - 1); i >= 0; i--) {
			data.replace(bufferChars[0] + i, bufferChars[i]);
		}
		ret = base64_decode(data)+'';
	}
	return(ret);
}
function RealBufferOut(data, level) {
	var ret = '';
	if((typeof(data) == 'object') && (data instanceof Array)) {
		if(data.length > 0) {
			for(var i = 0; i < data.length; i++) {
				data[i] = RealBufferOut(data[i], level + 1);
			}
		}
		ret = data.join(BufferChar(level));
	} else {
		ret = base64_encode(data+'');
		for(var i = 0; i < bufferChars.length; i++) {
			ret.replace(bufferChars[i], bufferChars[0] + i);
		}
	}
	return(ret);
}
function ControlsAreEqual(control1, control2) {
    if((control1 == null) && (control2 == null)) { return(true); }
    if((control1 == null) || (control2 == null)) { return(false); }
    if(control1.TypeOf != control2.TypeOf) { return(false); }
    if(control1.BaseType != control2.BaseType) { return(false); }
    switch(control1.BaseType) {
        case "Browser":
            return(true);
            break;
        case "Session":
            if(control1.ID == control2.ID) { return(true); }
            break;
        case "Float":
        case "Layer":
        case "Window":
            if((control1.Parent.ID == control2.Parent.ID) && (control1.ID == control2.ID)) { return(true); }
            break;
        case "Control":
            if((control1.ParentWindow.Parent.ID == control2.ParentWindow.Parent.ID) && (control1.ParentWindow.ID == control2.ParentWindow.ID) && (control1.ID == control2.ID)) { return(true); }
            break;
    }
    return(false);
}
function GetPosition(obj) {
    var output = new Object();
    var mytop=0, myleft=0;
    output.Width = obj.offsetWidth;
    output.Height = obj.offsetHeight;
    while( obj) {
        mytop+= obj.offsetTop;
        myleft+= obj.offsetLeft;
        obj= obj.offsetParent;
    }
    output.X = myleft;
    output.Y = mytop;
    return(output);
}
function ObjectReference(obj) {
    var a = new Array();
    switch(obj.BaseType) {
        case "Browser":
            return(new cReference(obj.BaseType, a));
            break;
        case "Session":
            a.push(obj.ID);
            return(new cReference(obj.BaseType, a));
            break;
        case "Float":
            a.push(obj.Parent.ID);
            a.push(obj.ID);
            return(new cReference(obj.BaseType, a));
            break;
        case "Layer":
            a.push(obj.Parent.ID);
            a.push(obj.ID);
            return(new cReference(obj.BaseType, a));
            break;
        case "Window":
            a.push(obj.Parent.ID);
            a.push(obj.ID);
            return(new cReference(obj.BaseType, a));
            break;
        case "Control":
            a.push(obj.ParentWindow.Parent.ID);
            a.push(obj.ParentWindow.ID);
            a.push(obj.ID);
            return(new cReference(obj.BaseType, a));
            break;
    }
}
function ReverseObjectType(type) {
    switch(type) {
        case "Browser":
            return(eCObjectType.Browser);
        case "Session":
            return(eCObjectType.Session);
        case "Float":
            return(eCObjectType.Float);
        case "Layer":
            return(eCObjectType.Layer);
        case "Window":
            return(eCObjectType.Window);
        case "Control":
            return(eCObjectType.Control);
        case eCObjectType.Browser:
            return("Browser");
        case eCObjectType.Session:
            return("Session");
        case eCObjectType.Float:
            return("Float");
        case eCObjectType.Layer:
            return("Layer");
        case eCObjectType.Window:
            return("Window");
        case eCObjectType.Control:
            return("Control");
    }
}
function EventObj(e) {
    if(!e) { e = event; }
    return e.target || e.srcElement;
}
function EventReference(e) {
    try {
        if(!e) { e = event; }
        var obj = e.target || e.srcElement;
        if (obj.nodeType == 3) obj = obj.parentNode;
        var aID = obj.id.split('_');
        var SessionID = parseInt(aID[aID.length - 3]);
        var SubID = aID[aID.length - 2];
        var ControlID = parseInt(aID[aID.length - 1]);
        var Ses = Browser.GetSession(SessionID);
        if(Ses != null) {
            var Sub = Ses.GetSub(SubID);
            if(Sub != null) {
                return(Sub.Controls.Get(ControlID));
            }
        }
    } catch(e) {}
    return(null);
}
function GetAlignmentCords(calcon, align, valign, defaultalign, defaultvalign, fixed, position, size, prefsize, minsize, allowposition, allowsize, aspectratio) {
//Browser.Console.WriteLine(position.X + ", " + size.X + ", " + prefsize.X + ", " + minsize.X + ", " + allowposition.X + ", " + allowsize.Width);
//Browser.Console.WriteLine(position.Y + ", " + size.Y + ", " + prefsize.Y + ", " + minsize.Y + ", " + allowposition.Y + ", " + allowsize.Height);
    var ret = new Object();
    var co = calcon;
    if(align == eCCAlign.Default) { align = defaultalign; }
    if(valign == eCCVAlign.Default) { valign = defaultvalign; }
    if((align == eCCAlign.Stretch) || (valign == eCCVAlign.Stretch)) { co = eCCAlignCalc.Both; }
    
    if(calcon & eCCAlignCalc.Horizontal) {
        var pw = prefsize.X; var w = size.X; var mw = minsize.X; var aw = allowsize.Width;
        if((pw+'').toLowerCase() == 'auto') { pw = aw; }    if((w+'').toLowerCase() == 'auto') { w = pw; }
        if((mw+'').toLowerCase() == 'auto') { mw = pw; }    if((aw+'').toLowerCase() == 'auto') { aw = pw; }
        if((w+'').indexOf('%') >= 0) { w = (parseInt(w.replace('%', '')) / 100) * aw; }
        if((mw+'').indexOf('%') >= 0) { mw = (parseInt(mw.replace('%', '')) / 100) * aw; }
        if(isNaN(pw)) { pw = aw; }
        if((!isNaN(pw)) && (pw < 0)) { if(!isNaN(w)) { pw = w; } else { pw = aw; } }
        if(fixed == true) { mw = w; }
        if(isNaN(mw)) { if(w < prefsize.X) { if(w < aw) { mw = w; } else { mw = aw; } } else { if(pw < aw) { mw = pw; } else { mw = aw; } } }
        if(size.X < mw) { size.X = mw; }
        ret.X = allowposition.X; ret.Width = aw; ret.MinWidth = mw; ret.FixedWidth = 0; ret.StretchWidth = 0; ret.StretchPreCalcWidth = 0;
    }
    if(calcon & eCCAlignCalc.Vertical) {
        var ph = prefsize.Y; var h = size.Y; var mh = minsize.Y; var ah = allowsize.Height;
        if((ph+'').toLowerCase() == 'auto') { ph = ah; }    if((h+'').toLowerCase() == 'auto') { h = ph; }
        if((mh+'').toLowerCase() == 'auto') { mh = ph; }    if((ah+'').toLowerCase() == 'auto') { ah = ph; }
        if((h+'').indexOf('%') >= 0) { h = (parseInt(h.replace('%', '')) / 100) * ah; }
        if((mh+'').indexOf('%') >= 0) { mh = (parseInt(mh.replace('%', '')) / 100) * ah; }
        if(isNaN(ph)) { ph = ah; }
        if((!isNaN(ph)) && (ph < 0)) { if(!isNaN(h)) { ph = h; } else { ph = ah; } }
        if(fixed == true) { mh = h; }
        if(isNaN(mh)) { if(h < prefsize.Y) { if(h < ah) { mh = h; } else { mh = ah; } } else { if(ph < ah) { mh = ph; } else { mh = ah; } } }
        if(size.Y < mh) { size.Y = mh; }
        ret.Y = allowposition.Y; ret.Height = ah; ret.MinHeight = mh; ret.FixedHeight = 0; ret.StretchHeight = 0; ret.StretchPreCalcHeight = 0;
    }
    
    if(calcon & eCCAlignCalc.Horizontal) {
        if(align == eCCAlign.Float) {
            if((position.X + w) <= aw) { ret.X = allowposition.X + position.X; ret.Width = w; }
            else if(w <= aw) { ret.X = (allowposition.X + aw) - w; ret.Width = w; }
        } else {
            if(w <= aw) {
                switch(align) {
                    case eCCAlign.Left:
                        if((position.X + w) > aw) {                         ret.X = (allowposition.X + aw) - w;                             }
                        else if(position.X < 0) {                           ret.X = allowposition.X;                                        }
                        else {                                              ret.X = allowposition.X + position.X;                           }
                        break;
                    case eCCAlign.Center:
                        if((position.X + ((aw / 2) + (w / 2))) > aw) {      ret.X = (allowposition.X + aw) - w;                             }
                        else if((position.X + ((aw / 2) - (w / 2))) < 0) {  ret.X = allowposition.X;                                        }
                        else {                                              ret.X = allowposition.X + position.X + ((aw / 2) - (w / 2));    }
                        break;
                    case eCCAlign.Right:
                        if((aw - position.X) > aw) {                        ret.X = (allowposition.X + aw) - w;                             }
                        else if((aw - (position.X + w)) < 0) {              ret.X = allowposition.X;                                        }
                        else {                                              ret.X = allowposition.X + (aw - (position.X + w));              }
                        break;
                }
                ret.Width = w;
            }
        }
        if(fixed == true) { ret.MinWidth = ret.Width; ret.FixedWidth = ret.Width; }
        else { ret.StretchWidth = ret.Width; ret.StretchPreCalcWidth = pw; }
    }
    if(calcon & eCCAlignCalc.Vertical) {
        if(valign == eCCVAlign.Float) {
            if((position.Y + h) <= ah) { ret.Y = allowposition.Y + position.Y; ret.Height = h; }
            else if(h <= ah) { ret.Y = (allowposition.Y + aH) - h; ret.Height = h; }
        } else {
            if(h <= ah) {
                switch(valign) {
                    case eCCVAlign.Top:
                        if((position.Y + h) > ah) {                         ret.Y = (allowposition.Y + ah) - h;                             }
                        else if(position.Y < 0) {                           ret.Y = allowposition.Y;                                        }
                        else {                                              ret.Y = allowposition.Y + position.Y;                           }
                        break;
                    case eCCVAlign.Middle:
                        if((position.Y + ((ah / 2) + (h / 2))) > ah) {      ret.Y = (allowposition.Y + ah) - h;                             }
                        else if((position.Y + ((ah / 2) - (h / 2))) < 0) {  ret.Y = allowposition.Y;                                        }
                        else {                                              ret.Y = allowposition.Y + position.Y + ((ah / 2) - (h / 2));    }
                        break;
                    case eCCVAlign.Bottom:
                        if((ah - position.Y) > ah) {                        ret.Y = (allowposition.Y + ah) - h;                             }
                        else if((ah - (position.Y + h)) < 0) {              ret.Y = allowposition.Y;                                        }
                        else {                                              ret.Y = allowposition.Y + (ah - (position.Y + h));              }
                        break;
                }
                ret.Height = h;
            }
        }
        if(fixed == true) { ret.MinHeight = ret.Height; ret.FixedHeight = ret.Height; }
        else { ret.StretchHeight = ret.Height; ret.StretchPreCalcHeight = ph; }
    }
    if((calcon & eCCAlignCalc.Both) && (aspectratio.X > 0) && (aspectratio.Y > 0)) {
        if(align == eCCAlign.Stretch) {
            ret.X = 0;
            ret.Width = allowsize.Width;
            if(valign == eCCVAlign.Stretch) {
                ret.Y = 0;
                ret.Height = allowsize.Height;
            } else {
                ret.Height = allowsize.Width * (aspectratio.Y / aspectratio.X);
                if(ret.Height > ah) { ret.Height = ah; }
                switch(valign) {
                    case eCCVAlign.Top:
                        if((position.Y + ret.Height) > ah) {                        ret.Y = (allowposition.Y + ah) - ret.Height;            }
                        else if(position.Y < 0) {                                   ret.Y = allowposition.Y;                                }
                        else {                                                      ret.Y = allowposition.Y + position.Y;                   }
                        break;
                    case eCCVAlign.Middle:
                        if((position.Y + ((ah / 2) + (ret.Height / 2))) > ah) {     ret.Y = (allowposition.Y + ah) - ret.Height;            }
                        else if((position.Y + ((ah / 2) - (ret.Height / 2))) < 0) { ret.Y = allowposition.Y;                                }
                        else {                                     ret.Y = allowposition.Y + position.Y + ((ah / 2) - (ret.Height / 2));    }
                        break;
                    case eCCVAlign.Bottom:
                        if((ah - position.Y) > ah) {                                ret.Y = (allowposition.Y + ah) - ret.Height;            }
                        else if((ah - (position.Y + ret.Height)) < 0) {             ret.Y = allowposition.Y;                                }
                        else {                                              ret.Y = allowposition.Y + (ah - (position.Y + ret.Height));     }
                        break;
                }
            }
        } else if(valign == eCCVAlign.Stretch) {
            ret.Y = 0;
            ret.Height = allowsize.Height;
            ret.Width = allowsize.Height * (aspectratio.X / aspectratio.Y);
            if(ret.Width > aw) { ret.Width = aw; }
            switch(align) {
                case eCCAlign.Left:
                    if((position.X + ret.Width) > aw) {                        ret.X = (allowposition.X + aw) - ret.Width;                  }
                    else if(position.X < 0) {                                   ret.X = allowposition.X;                                    }
                    else {                                                      ret.X = allowposition.X + position.X;                       }
                    break;
                case eCCAlign.Center:
                    if((position.X + ((aw / 2) + (ret.Width / 2))) > aw) {     ret.X = (allowposition.X + aw) - ret.Width;                  }
                    else if((position.X + ((aw / 2) - (ret.Width / 2))) < 0) { ret.X = allowposition.X;                                     }
                    else {                                     ret.X = allowposition.X + position.X + ((aw / 2) - (ret.Width / 2));         }
                    break;
                case eCCAlign.Right:
                    if((aw - position.X) > aw) {                                ret.X = (allowposition.X + aw) - ret.Width;                 }
                    else if((aw - (position.X + ret.Width)) < 0) {             ret.X = allowposition.X;                                     }
                    else {                                              ret.X = allowposition.X + (aw - (position.X + ret.Width));          }
                    break;
            }
        }
    }
    if((position.X+'').indexOf('%') >= 0) {
        var fpx = (parseInt(position.X.replace('%', '')) / 100) * aw;
        switch(align) {
            case eCCAlign.Left:
                if(ret.Width >= aw) {                                           ret.X = 0; ret.Width = aw;                                  }
                else if((fpx + ret.Width) <= aw) {                              ret.X = fpx;                                                }
                else {                                                          ret.X = aw - ret.Width;                                     }
                break;
            case eCCAlign.Center:
                if(ret.Width >= aw) {                                           ret.X = 0; ret.Width = aw;                                  }
                else if((fpx - (ret.Width / 2)) >= 0) {
                    if((fpx + (ret.Width / 2)) <= aw) {                         ret.X = fpx - (ret.Width / 2);                              }
                    else {                                                      ret.X = aw - ret.Width;                                     }
                }
                else {                                                          ret.X = 0;                                                  }
                break;
            case eCCAlign.Right:
                if(ret.Width >= aw) {                                           ret.X = 0; ret.Width = aw;                                  }
                else if((fpx - ret.Width) >= 0) {                               ret.X = fpx - ret.Width;                                    }
                else {                                                          ret.X = 0;                                                  }
                break;
        }
    }
    if((position.Y+'').indexOf('%') >= 0) {
        var fpy = (parseInt(position.Y.replace('%', '')) / 100) * ah;
        switch(valign) {
            case eCCVAlign.Top:
                if(ret.Height >= ah) {                                          ret.Y = 0; ret.Height = ah;                                 }
                else if((fpy + ret.Height) <= ah) {                             ret.Y = fpy;                                                }
                else {                                                          ret.Y = ah - ret.Height;                                    }
                break;
            case eCCVAlign.Middle:
                if(ret.Height >= ah) {                                          ret.Y = 0; ret.Height = ah;                                 }
                else if((fpy - (ret.Height / 2)) >= 0) {
                    if((fpy + (ret.Height / 2)) <= ah) {                        ret.Y = fpy - (ret.Height / 2);                             }
                    else {                                                      ret.Y = ah - ret.Height;                                    }
                }
                else {                                                          ret.Y = 0;                                                  }
                break;
            case eCCVAlign.Bottom:
                if(ret.Height >= ah) {                                          ret.Y = 0; ret.Height = ah;                                 }
                else if((fpy - ret.Height) >= 0) {                              ret.Y = fpy - ret.Height;                                   }
                else {                                                          ret.Y = 0;                                                  }
                break;
        }
    }
    //Browser.Console.WriteLine(dump(ret));
    return(ret);
}
function GetAlignmentFromString(align) {
    var ret = eCCAlign.Default;
    if(align.length > 0) {
        switch(align.substring(0, 1).toLowerCase()) {
            case 'l':
                ret = eCCAlign.Left;
                break;
            case 'c':
                ret = eCCAlign.Center;
                break;
            case 'r':
                ret = eCCAlign.Right;
                break;
            case 's':
                ret = eCCAlign.Stretch;
                break;
            case 'f':
                ret = eCCAlign.Float;
                break;
        }
    }
    return(ret);
}
function GetBorderStyleFromString(borderstyle) {
    var ret = new Object();
    ret.Style = eCCBorderStyle.None;
    ret.Size = 0;
    ret.Color = '#000000';
    if(borderstyle.length > 1) {
        var tA = borderstyle.split(' ');
        switch(borderstyle.substring(0, 2).toLowerCase()) {
            case 'so':
                ret.Style = eCCBorderStyle.Solid;
                if(tA.length > 1) {
                    ret.Size = parseInt(tA[1]);
                    if(tA.length > 2) { ret.Color = tA[2]; }
                }
                break;
            case 'rn':
                ret.Style = eCCBorderStyle.Raised;
                break;
            case 'ln':
                ret.Style = eCCBorderStyle.Lowered;
                break;
            case 'lb':
                ret.Style = eCCBorderStyle.LoweredBevel;
                break;
            case 'rb':
                ret.Style = eCCBorderStyle.RaisedBevel;
                break;
            case 'lo':
                ret.Style = eCCBorderStyle.LoweredOutline;
                break;
            case 'ro':
                ret.Style = eCCBorderStyle.RaisedOutline;
                break;
            case 'in':
                ret.Style = eCCBorderStyle.Inset;
                break;
            case 'sz':
                ret.Style = eCCBorderStyle.Sizeable;
                break;
        }
    }
    return(ret);
}
function GetDockPositionFromString(position) {
    var ret = eCDPosition.Float;
    position = position.toLowerCase();
    if(position.indexOf('all') >= 0) {
        ret = eCDPosition.All;
    } else {
        if(position.indexOf('top') >= 0) { ret = ret + eCDPosition.Top; }
        if(position.indexOf('right') >= 0) { ret = ret + eCDPosition.Right; }
        if(position.indexOf('bottom') >= 0) { ret = ret + eCDPosition.Bottom; }
        if(position.indexOf('left') >= 0) { ret = ret + eCDPosition.Left; }
    }
    return(ret);
}
function GetFirstDefined(num1, num2) {
    if(typeof(num1) != "undefined") {
        return(num1);
    } else {
        return(num2);
    }
}
function GetOrientationFromString(orientation) {
    var ret = eCCOrientation.Float;
    if(orientation.length > 0) {
        switch(orientation.substring(0, 1).toLowerCase()) {
            case 'h':
                ret = eCCOrientation.Horizontal;
                break;
            case 'v':
                ret = eCCOrientation.Vertical;
                break;
        }
    }
    return(ret);
}
function GetScaleOnFromString(scaleon) {
    var ret = eCCScaleOn.Default;
    if((scaleon+'').length > 0) {
        switch((scaleon+'').toLowerCase()) {
            case 'low':
                ret = eCCScaleOn.Low;
                break;
            case 'high':
                ret = eCCScaleOn.High;
                break;
            case 'h':
            case 'x':
            case 'horizontal':
                ret = eCCScaleOn.Horizontal;
                break;
            case 'v':
            case 'y':
            case 'vertical':
                ret = eCCScaleOn.Vertical;
                break;
        }
    }
    return(ret);
}
function GetSizeOfMax(size, max) {
    if(size == 'auto') {
        return(max);
    } else {
        if((size+'').indexOf('%') >= 0) {
            return((parseInt(size.replace('%', '')) / 100) * max);
        } else {
            return(size);
        }
    }
}
function GetSizeOfPrefMax(size, pref, max) {
    if(size == 'auto') {
        return(pref);
    } else {
        if((size+'').indexOf('%') >= 0) {
            return((parseInt(size.replace('%', '')) / 100) * max);
        } else {
            return(size);
        }
    }
}
/*function GetVerticalAlignmentCords(valign, defaultvalign, fixed, y, height, prefheight, minheight, allowy, allowheight) {
    var ret = new Object();
    var ph = prefheight; var h = height; var mh = minheight; var ah = allowheight;
    if((ph+'').toLowerCase() == 'auto') { ph = ah; }
    if((h+'').toLowerCase() == 'auto') { h = ph; }
    if((mh+'').toLowerCase() == 'auto') { mh = ph; }
    if((ah+'').toLowerCase() == 'auto') { ah = ph; }
    if(valign == eCCVAlign.Default) { valign = defaultvalign; }
    if((h+'').indexOf('%') >= 0) { h = (parseInt(h.replace('%', '')) / 100) * ah; }
    if((mh+'').indexOf('%') >= 0) { mh = (parseInt(mh.replace('%', '')) / 100) * ah; }
    if(isNaN(ph)) { ph = ah; }
    if((!isNaN(ph)) && (ph < 0)) { if(!isNaN(h)) { ph = h; } else { ph = ah; } }
    if(fixed == true) { mh = h; }
    if(isNaN(mh)) {
        if(h < ph) {
            if(h < ah) {
                mh = h;
            } else {
                mh = ah;
            }
        } else {
            if(ph < ah) {
                mh = ph;
            } else {
                mh = ah;
            }
        }
    }
    if(h < mh) { h = mh; }
    ret.Y = allowy; ret.Height = ah; ret.MinHeight = mh; ret.FixedHeight = 0; ret.StretchHeight = 0; ret.StretchPreCalcHeight = 0;
    if(valign == eCCVAlign.Float) {
        if((y + h) <= ah) {
            ret.Y = allowy + y;
            ret.Height = h;
        } else {
            if(h <= ah) {
                ret.Y = (allowy + ah) - h;
                ret.Height = h;
            }
        }
    } else {
        if(h <= ah) {
            switch(valign) {
                case eCCVAlign.Top:
                    if((y + h) > ah) {
                        ret.Y = (allowy + ah) - h;
                    } else if(y < 0) {
                        ret.Y = allowy;
                    } else {
                        ret.Y = allowy + y;
                    }
                    break;
                case eCCVAlign.Middle:
                    if((y + ((ah / 2) + (h / 2))) > ah) {
                        ret.Y = (allowy + ah) - h;
                    } else if((y + ((ah / 2) - (h / 2))) < 0) {
                        ret.Y = allowy;
                    } else {
                        ret.Y = allowy + y + ((ah / 2) - (h / 2));
                    }
                    break;
                case eCCVAlign.Bottom:
                    if((ah - y) > ah) {
                        ret.Y = (allowy + ah) - h;
                    } else if((ah - (y + h)) < 0) {
                        ret.Y = allowy;
                    } else {
                        ret.Y = allowy + (ah - (y + h));
                    }
                    break;
            }
            ret.Height = h;
        }
    }
    if(fixed == true) { ret.MinHeight = ret.Height; ret.FixedHeight = ret.Height; } else { ret.StretchHeight = ret.Height; ret.StretchPreCalcHeight = ph; }
    return(ret);
}*/
function GetVerticalAlignmentFromString(valign) {
    var ret = eCCVAlign.Default;
    if(valign.length > 0) {
        switch(valign.substring(0, 1).toLowerCase()) {
            case 't':
                ret = eCCVAlign.Top;
                break;
            case 'm':
                ret = eCCVAlign.Middle;
                break;
            case 'b':
                ret = eCCVAlign.Bottom;
                break;
            case 's':
                ret = eCCVAlign.Stretch;
                break;
            case 'f':
                ret = eCCVAlign.Float;
                break;
        }
    }
    return(ret);
}
function GetWindowStateFromString(state) {
    var ret = eCWState.Normal;
    if(state.length > 0) {
        switch(state.substring(1, 1).toLowerCase()) {
            case 'm':
                if(state.length > 1) {
                    switch(state.substring(0, 1).toLowerCase()) {
                        case 'i':
                            ret = eCWState.Minimized;
                            break;
                        case 'a':
                            ret = eCWState.Maximized;
                            break;
                    }
                }
                break;
            case 'c':
                ret = eCWState.Collapsed;
                break;
            case 'd':
                ret = eCWState.Docked;
                break;
        }
    }
    return(ret);
}
function GetWindowStyleFromString(style) {
    var ret = eCWStyle.Normal;
    if(style.length > 0) {
        switch(style.substring(0, 1).toLowerCase()) {
            case 't':
                ret = eCWStyle.Tool;
                break;
            case 'p':
                ret = eCWStyle.Popout;
                break;
            case 'm':
                ret = eCWStyle.Menu;
                break;
        }
    }
    return(ret);
}

function InArray(arr, val) {
	if((typeof(arr) == 'object') && (arr instanceof Array)) {
        if(arr.length > 0) {
            for(var i = arr.length - 1; i >= 0; i--) {
                if(arr[i] == val) { return(true); }
            }
        }
    } else { if(arr == val) { return(true); } }
    return(false);
}
function LastInArray(arr, val, arrall) {
	if((typeof(arr) == 'object') && (arr instanceof Array)) {
        if(arr.length > 0) {
            for(var i = arr.length - 1; i >= 0; i--) {
                if(arr[i] == val) { return(true); }
                if(InArray(arrall, arr[i]) == true) { return(false); }
            }
        }
    } else { if(arr == val) { return(true); } }
    return(false);
}
function WithInArray(arr, val) {
	if((typeof(arr) == 'object') && (arr instanceof Array)) {
        if(arr.length > 0) {
            for(var i = arr.length - 1; i >= 0; i--) {
                if(arr[i] == val) { return(i + 1); }
            }
        }
    } else { if(arr == val) { return(0); } }
    return(-1);
}

var base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';

function base64_encode(data) {
   var ret = ""; var c1, c2, c3; var e1, e2, e3, e4;
   var i = 0;
   do {
      c1 = data.charCodeAt(i++); c2 = data.charCodeAt(i++); c3 = data.charCodeAt(i++);
 
      e1 = c1 >> 2; e2 = ((c1 & 3) << 4) | (c2 >> 4); e3 = ((c2 & 15) << 2) | (c3 >> 6); e4 = c3 & 63;
 
      if (isNaN(c2)) {
         e3 = e4 = 64;
      } else if (isNaN(c3)) {
         e4 = 64;
      }
      ret = ret + base64Chars.charAt(e1) + base64Chars.charAt(e2) + base64Chars.charAt(e3) + base64Chars.charAt(e4);
   } while (i < data.length);
   return ret;
}
 
function base64_decode(data) {
   var ret = ""; var c1, c2, c3; var e1, e2, e3, e4;
   var i = 0;
   data = data.replace(/[^A-Za-z0-9\+\/\=]/g, "");
   do {
      e1 = base64Chars.indexOf(data.charAt(i++)); e2 = base64Chars.indexOf(data.charAt(i++));
      e3 = base64Chars.indexOf(data.charAt(i++)); e4 = base64Chars.indexOf(data.charAt(i++));
 
      c1 = (e1 << 2) | (e2 >> 4); c2 = ((e2 & 15) << 4) | (e3 >> 2); c3 = ((e3 & 3) << 6) | e4;
 
      ret = ret + String.fromCharCode(c1);
 
      if (e3 != 64) { ret = ret + String.fromCharCode(c2); }
      if (e4 != 64) { ret = ret + String.fromCharCode(c3); }
   } while (i < data.length);
   return ret;
}

function eventPop(obj, e, handler) {
  if (obj.addEventListener && (!window.opera)) {
    obj.removeEventListener(e, function(ev) { handler(ev); }, false);
  } else if (obj.attachEvent && (!window.opera)) {
    obj.detachEvent('on'+e, function(ev) { handler(ev); });
  } else {
    switch(e) {
        case 'blur':
            obj.onblur = null;
            break;
        case 'click':
            obj.onclick = null;
            break;
        case 'dblclick':
            obj.ondblclick = null;
            break;
        case 'focus':
            obj.onfocus = null;
            break;
        case 'load':
            obj.onload = null;
            break;
        case 'mousedown':
            obj.onmousedown = null;
            break;
        case 'mousemove':
            obj.onmousemove = null;
            break;
        case 'mouseout':
            obj.onmouseout = null;
            break;
        case 'mouseover':
            obj.onmouseover = null;
            break;
        case 'mouseup':
            obj.onmouseup = null;
            break;
    }
  }
}
function eventPush(obj, e, handler) {
  if (obj.addEventListener && (!window.opera)) {
    obj.addEventListener(e, function(ev) { handler(ev); }, false);
  } else if (obj.attachEvent && (!window.opera)) {
    obj.attachEvent('on'+e, function(ev) { handler(ev); });
  } else {
    switch(e) {
        case 'blur':
            obj.onblur = handler;
            break;
        case 'click':
            obj.onclick = handler;
            break;
        case 'dblclick':
            obj.ondblclick = handler;
            break;
        case 'focus':
            obj.onfocus = handler;
            break;
        case 'load':
            obj.onload = handler;
            break;
        case 'mousedown':
            obj.onmousedown = handler;
            break;
        case 'mousemove':
            obj.onmousemove = handler;
            break;
        case 'mouseout':
            obj.onmouseout = handler;
            break;
        case 'mouseover':
            obj.onmouseover = handler;
            break;
        case 'mouseup':
            obj.onmouseup = handler;
            break;
    }
  }
}
/*
   Copyright 2009 Cory J. Geesaman (http://cory.geesaman.com/)
   http://www.inetgui.org/
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
function cStyleInfo() {
    this.PreCacheImages = new Array('style/default/img/bullets.png', 'style/default/img/expandcollapsebullet.png', 'style/default/img/hovericon.png', 'style/default/img/menuglyphs.png', 'style/default/img/menuitem.png', 'style/default/img/sessionbutton.png', 'style/default/img/textbox_gradient.png', 'style/default/img/vheadertext.png', 'style/default/img/window/1_buttons.png', 'style/default/img/window/2_buttons.png', 'style/default/img/window/4_buttons.png', 'style/default/img/window/bl_br.png', 'style/default/img/window/bt_bb.png', 'style/default/img/window/corners.png', 'style/default/img/window/header.png', 'style/default/img/window/vheader.png');
    this.BorderStyleData = {
        Solid:{ Click:{BT:1, BR:1, BB:1, BL:1}, NoClick:{BT:1, BR:1, BB:1, BL:1}, CTL:{ X:0, Y:0 }, CTR:{ X:0, Y:0 }, CBL:{ X:0, Y:0 }, CBR:{ X:0, Y:0 } },
        Raised:{ Click:{BT:2, BR:2, BB:2, BL:2}, NoClick:{BT:2, BR:2, BB:2, BL:2}, CTL:{ X:2, Y:2 }, CTR:{ X:2, Y:2 }, CBL:{ X:2, Y:2 }, CBR:{ X:2, Y:2 } },
        Lowered:{ Click:{BT:3, BR:1, BB:1, BL:3}, NoClick:{BT:2, BR:2, BB:2, BL:2}, CTL:{ X:3, Y:3 }, CTR:{ X:2, Y:2 }, CBL:{ X:2, Y:2 }, CBR:{ X:1, Y:1 } },
        LoweredBevel:{ Click:{BT:3, BR:3, BB:3, BL:3}, NoClick:{BT:3, BR:3, BB:3, BL:3}, CTL:{ X:3, Y:3 }, CTR:{ X:3, Y:3 }, CBL:{ X:3, Y:3 }, CBR:{ X:3, Y:3 } },
        RaisedBevel:{ Click:{BT:3, BR:3, BB:3, BL:3}, NoClick:{BT:3, BR:3, BB:3, BL:3}, CTL:{ X:3, Y:3 }, CTR:{ X:3, Y:3 }, CBL:{ X:3, Y:3 }, CBR:{ X:3, Y:3 } },
        LoweredOutline:{ Click:{BT:3, BR:3, BB:3, BL:3}, NoClick:{BT:3, BR:3, BB:1, BL:3}, CTL:{ X:3, Y:3 }, CTR:{ X:3, Y:3 }, CBL:{ X:3, Y:3 }, CBR:{ X:3, Y:3 } },
        RaisedOutline:{ Click:{BT:3, BR:3, BB:3, BL:3}, NoClick:{BT:3, BR:3, BB:1, BL:3}, CTL:{ X:3, Y:3 }, CTR:{ X:3, Y:3 }, CBL:{ X:3, Y:3 }, CBR:{ X:3, Y:3 } },
        Inset:{ Click:{BT:2, BR:2, BB:2, BL:2}, NoClick:{BT:2, BR:2, BB:2, BL:2}, CTL:{ X:2, Y:2 }, CTR:{ X:2, Y:2 }, CBL:{ X:2, Y:2 }, CBR:{ X:2, Y:2 } },
        Sizeable:{ Click:{BT:3, BR:3, BB:3, BL:3}, NoClick:{BT:3, BR:3, BB:3, BL:3}, CTL:{ X:16, Y:16 }, CTR:{ X:16, Y:16 }, CBL:{ X:16, Y:16 }, CBR:{ X:16, Y:16 } }
    };
    this.BrowserStyleData = {
        IE:{
            Window:{
                Normal:{ Icon:{ Margin:'3px 3px 3px 1px' } },
                Tool:{ Icon:{ Margin:'3px 3px 3px -1px' } },
                Popout:{ Icon:{ Margin:'3px 3px 3px 1px' } }
            },
            WindowList:{
                Height:27
            },
            WindowListButton:{
                TABHeader:{Height:'14px', Margin:'-1px 0px 0px 0px'},
                SPANButton:{Height:'20px'},
                SPANIcon:{Margin:'0px 0px 0px -1px'},
                SPANCaption:{Margin:'-1px 0px 0px 0px', Padding:'0px 0px 0px 0px'}
            },
            MenuItem:{
                TextSizeAdjustment:{X:18},
                Header:{
                    LeftIndent:{ Position:'absolute' },
                    Icon:{ Margin:{ Left:2, Top:-1 } },
                    Text:{ Position:'relative', Left: -4, Margin:{ Left:0, Top:-1 } },
                    Glyph:{ Margin:{ Right:4, Top:-1 } },
                    RightIndent:{ Position:'absolute', Right:0 }
                },
                Normal:{
                    LeftIndent:{ Position:'absolute' },
                    Icon:{ Margin:{ Left:2, Top:-2 } },
                    Text:{ Position:'relative', Left: -4, Margin:{ Left:0, Top:-2 } },
                    Glyph:{ Margin:{ Right:4, Top:-1 } },
                    RightIndent:{ Position:'absolute', Right:0 }
                },
                Separator:{
                    LeftIndent:{ Position:'absolute' },
                    Icon:{ Margin:{ Left:2, Top:-2 } },
                    Text:{ Position:'relative', Left: -4, Margin:{ Left:0, Top:-2 } },
                    Glyph:{ Margin:{ Right:4, Top:-2 } },
                    RightIndent:{ Position:'absolute', Right:0 }
                },
                Radio:{
                    LeftIndent:{ Position:'absolute' },
                    Icon:{ Position:'relative', Top:-2, Margin:{ Left:11, Top:0 } },
                    Text:{ Position:'relative', Left: -4, Top:-3, Margin:{ Left:0 } },
                    Glyph:{ Position:'relative', Top:-3, Margin:{ Right:4, Top:-4 } },
                    RightIndent:{ Position:'absolute', Right:0 }
                },
                Check:{
                    LeftIndent:{ Position:'absolute' },
                    Icon:{ Margin:{ Left:2, Top:-2 } },
                    Text:{ Position:'relative', Left: -4, Margin:{ Left:0, Top:-2 } },
                    Glyph:{ Margin:{ Right:4, Top:-2 } },
                    RightIndent:{ Position:'absolute', Right:0 }
                }
            }
        },
        FF:{
            Window:{
                Normal:{ Icon:{ Margin:'3px 1px 3px 2px' } },
                Tool:{ Icon:{ Margin:'3px 3px 3px 2px' } },
                Popout:{ Icon:{ Margin:'3px 1px 3px 2px' } }
            },
            WindowList:{
                Height:27
            },
            WindowListButton:{
                TABHeader:{Height:'16px', Margin:'2px 0px 0px 0px'},
                SPANButton:{Height:'18px'},
                SPANIcon:{Margin:'0px 0px 0px 0px'},
                SPANCaption:{Margin:'0px 0px 0px 0px', Padding:'0px 0px 0px 5px'}
            },
            MenuItem:{
                TextSizeAdjustment:{X:18},
                Header:{
                    LeftIndent:{ Position:'inherit' },
                    Icon:{ Margin:{ Left:0, Top:0 } },
                    Text:{ Position:'inherit', Left: 0, Margin:{ Left:5, Top:0 } },
                    Glyph:{ Margin:{ Right:0, Top:0 } },
                    RightIndent:{ Position:'inline', Right:-1 }
                },
                Normal:{
                    LeftIndent:{ Position:'inherit' },
                    Icon:{ Margin:{ Left:0, Top:0 } },
                    Text:{ Position:'inherit', Left: 0, Margin:{ Left:5, Top:0 } },
                    Glyph:{ Margin:{ Right:0, Top:0 } },
                    RightIndent:{ Position:'inherit', Right:-1 }
                },
                Separator:{
                    LeftIndent:{ Position:'inherit' },
                    Icon:{ Margin:{ Left:0, Top:0 } },
                    Text:{ Position:'inherit', Left: 0, Margin:{ Left:5, Top:0 } },
                    Glyph:{ Margin:{ Right:0, Top:0 } },
                    RightIndent:{ Position:'inherit', Right:-1 }
                },
                Radio:{
                    LeftIndent:{ Position:'inherit' },
                    Icon:{ Position:'inherit', Top:0, Margin:{ Left:0, Top:0 } },
                    Text:{ Position:'inherit', Left: 0, Top:0, Margin:{ Left:5, Top:0 } },
                    Glyph:{ Position:'inherit', Top:0, Margin:{ Right:0, Top:0 } },
                    RightIndent:{ Position:'inherit', Right:-1 }
                },
                Check:{
                    LeftIndent:{ Position:'inherit' },
                    Icon:{ Margin:{ Left:0, Top:0 } },
                    Text:{ Position:'inherit', Left: 0, Margin:{ Left:5, Top:0 } },
                    Glyph:{ Margin:{ Right:0, Top:0 } },
                    RightIndent:{ Position:'inherit', Right:-1 }
                }
            }
        },
        Default:{
            Window:{
                Normal:{ Icon:{ Margin:'3px 1px 3px 2px' } },
                Tool:{ Icon:{ Margin:'4px 2px 2px 3px' } },
                Popout:{ Icon:{ Margin:'3px 1px 3px 2px' } }
            },
            WindowList:{
                Height:27
            },
            WindowListButton:{
                TABHeader:{Height:'16px', Margin:'2px 0px 0px 0px'},
                SPANButton:{Height:'18px'},
                SPANIcon:{Margin:'0px 0px 0px 0px'},
                SPANCaption:{Margin:'0px 0px 0px 0px', Padding:'0px 0px 0px 5px'}
            },
            MenuItem:{
                TextSizeAdjustment:{X:18},
                Header:{
                    LeftIndent:{ Position:'inherit' },
                    Icon:{ Margin:{ Left:4, Top:0 } },
                    Text:{ Position:'inherit', Left: 0, Margin:{ Left:5, Top:0 } },
                    Glyph:{ Margin:{ Right:4, Top:0 } },
                    RightIndent:{ Position:'inherit', Right:-1 }
                },
                Normal:{
                    LeftIndent:{ Position:'inherit' },
                    Icon:{ Margin:{ Left:4, Top:0 } },
                    Text:{ Position:'inherit', Left: 0, Margin:{ Left:5, Top:0 } },
                    Glyph:{ Margin:{ Right:4, Top:0 } },
                    RightIndent:{ Position:'inherit', Right:-1 }
                },
                Separator:{
                    LeftIndent:{ Position:'inherit' },
                    Icon:{ Margin:{ Left:4, Top:0 } },
                    Text:{ Position:'inherit', Left: 0, Margin:{ Left:5, Top:0 } },
                    Glyph:{ Margin:{ Right:4, Top:0 } },
                    RightIndent:{ Position:'inherit', Right:-1 }
                },
                Radio:{
                    LeftIndent:{ Position:'inherit' },
                    Icon:{ Position:'inherit', Top:0, Margin:{ Left:4, Top:0 } },
                    Text:{ Position:'inherit', Left: 0, Top:0, Margin:{ Left:5, Top:0 } },
                    Glyph:{ Position:'inherit', Top:0, Margin:{ Right:4, Top:0 } },
                    RightIndent:{ Position:'inherit', Right:-1 }
                },
                Check:{
                    LeftIndent:{ Position:'inherit' },
                    Icon:{ Margin:{ Left:4, Top:0 } },
                    Text:{ Position:'inherit', Left: 0, Margin:{ Left:5, Top:0 } },
                    Glyph:{ Margin:{ Right:4, Top:0 } },
                    RightIndent:{ Position:'inherit', Right:-1 }
                }
            }
        }
    };
    
    this.MenuItemStyleData = {
        Header:{
            Height:24,
            Normal:{
                Font:{Family:'Verdana', Size:12, Bold:true, Decoration:'none', Style:'normal'}
            },
            Disabled:{
                Font:{Family:'Verdana', Size:12, Bold:true, Decoration:'none', Style:'italic'}
            },
            Icon:{Size:16},
            Glyph:{Size:11},
            Indent:{Left:5, Right:6},
            Spacing:{Left:4, Right:12}
        },
        Normal:{
            Height:20,
            Normal:{
                Font:{Family:'Verdana', Size:11, Bold:false, Decoration:'none', Style:'normal'}
            },
            Disabled:{
                Font:{Family:'Verdana', Size:11, Bold:false, Decoration:'none', Style:'italic'}
            },
            Icon:{Size:16},
            Glyph:{Size:11},
            Indent:{Left:3, Right:3},
            Spacing:{Left:4, Right:4}
        },
        Separator:{
            Height:4,
            Normal:{
                Font:{Family:'Verdana', Size:0, Bold:false, Decoration:'none', Style:'normal'}
            },
            Disabled:{
                Font:{Family:'Verdana', Size:0, Bold:false, Decoration:'none', Style:'italic'}
            },
            Icon:{Size:0},
            Glyph:{Size:0},
            Indent:{Left:4, Right:4},
            Spacing:{Left:0, Right:0}
        },
        Radio:{
            Height:15,
            Normal:{
                Font:{Family:'Verdana', Size:7, Bold:false, Decoration:'none', Style:'normal'}
            },
            Disabled:{
                Font:{Family:'Verdana', Size:7, Bold:false, Decoration:'none', Style:'italic'}
            },
            Icon:{Size:11},
            Glyph:{Size:0},
            Indent:{Left:14, Right:3},
            Spacing:{Left:4, Right:0}
        },
        Check:{
            Height:20,
            Normal:{
                Font:{Family:'Verdana', Size:11, Bold:false, Decoration:'none', Style:'normal'}
            },
            Disabled:{
                Font:{Family:'Verdana', Size:11, Bold:false, Decoration:'none', Style:'italic'}
            },
            Icon:{Size:11},
            Glyph:{Size:0},
            Indent:{Left:3, Right:3},
            Spacing:{Left:4, Right:4}
        }
    };
    this.HoverIconStyleData = {
        s8:{X:-2, Y:-2, Width: 15, Height: 13,
            Icon:{
                Normal:{X: 2, Y: 2, Width:8, Height:8},
                Hover:{X: 2, Y: 2, Width:8, Height:8},
                Down:{X: 3, Y: 3, Width:8, Height:8}
            }
        },
        s10:{X:-2, Y:-2, Width: 17, Height: 15,
            Icon:{
                Normal:{X: 2, Y: 2, Width:10, Height:10},
                Hover:{X: 2, Y: 2, Width:10, Height:10},
                Down:{X: 3, Y: 3, Width:10, Height:10}
            }
        },
        s12:{X:-2, Y:-2, Width: 20, Height: 17,
            Icon:{
                Normal:{X: 2, Y: 2, Width:12, Height:12},
                Hover:{X: 2, Y: 2, Width:12, Height:12},
                Down:{X: 3, Y: 3, Width:12, Height:12}
            }
        },
        s14:{X:-2, Y:-2, Width: 22, Height: 19,
            Icon:{
                Normal:{X: 2, Y: 2, Width:14, Height:14},
                Hover:{X: 2, Y: 2, Width:14, Height:14},
                Down:{X: 3, Y: 3, Width:14, Height:14}
            }
        },
        s16:{X:-2, Y:-2, Width: 25, Height: 21,
            Icon:{
                Normal:{X: 2, Y: 2, Width:16, Height:16},
                Hover:{X: 2, Y: 2, Width:16, Height:16},
                Down:{X: 3, Y: 3, Width:16, Height:16}
            }
        }
    };
    this.CooldownOverlayStyleData = {
        s18:{X:0, Y:0, Width: 18, Height: 18, Image:'img/icons/odd/18cooldown_76.png', Count:76 }
    };
    this.WindowStyleData = {
        Normal:{
            Normal:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:21},
                Header:{Focus:{Color:'#009900'},Unfocused:{Color:'#669966'}},
                
                Client:{Left:4, Top:27, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:8, Close:'X', Maximize:'M', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:16, Margin:4}
            },
            Minimized:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:21},
                Header:{Focus:{Color:'#009900'},Unfocused:{Color:'#669966'}},
                
                Client:{Left:4, Top:27, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:8, Close:'X', Maximize:'M', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:16, Margin:4}
            },
            Collapsed:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:21},
                Header:{Focus:{Color:'#009900'},Unfocused:{Color:'#669966'}},
                
                Client:{Left:4, Top:27, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:8, Close:'X', Maximize:'M', Collapse:'R', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:16, Margin:4}
            },
            Docked:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:21},
                Header:{Focus:{Color:'#009900'},Unfocused:{Color:'#669966'}},
                
                Client:{Left:4, Top:27, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:8, Close:'X', Maximize:'M', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'none', Visibility:'hidden', Icon:{Size:14, Margin:2}},
                Icon:{Size:16, Margin:4}
            },
            Maximized:{
                BorderTop:{Height:0},
                BorderRight:{Width:0},
                BorderBottom:{Height:0},
                BorderLeft:{Width:0},
                
                BorderTopLeft:{Width:0, Height:0},
                BorderTopRight:{Width:0, Height:0},
                BorderBottomLeft:{Width:0, Height:0},
                BorderBottomRight:{Width:0, Height:0},
                
                Title:{Height:21},
                Header:{Focus:{Color:'#009900'},Unfocused:{Color:'#669966'}},
                
                Client:{Left:0, Top:22, Right:0, Bottom:0, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:4, Close:'X', Maximize:'R', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:16, Margin:4}
            }
        },
        Tool:{
            Normal:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:16},
                Header:{Focus:{Color:'#006699'},Unfocused:{Color:'#669999'}},
                
                Client:{Left:4, Top:22, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:5, Close:'X', Maximize:'M', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:12, Margin:4}
            },
            Minimized:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:16},
                Header:{Focus:{Color:'#006699'},Unfocused:{Color:'#669999'}},
                
                Client:{Left:4, Top:22, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:5, Close:'X', Maximize:'M', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:12, Margin:4}
            },
            Collapsed:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:16},
                Header:{Focus:{Color:'#006699'},Unfocused:{Color:'#669999'}},
                
                Client:{Left:4, Top:22, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:5, Close:'X', Maximize:'M', Collapse:'R', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:12, Margin:4}
            },
            Docked:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:16},
                Header:{Focus:{Color:'#006699'},Unfocused:{Color:'#669999'}},
                
                Client:{Left:4, Top:22, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:5, Close:'X', Maximize:'M', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'none', Visibility:'hidden', Icon:{Size:14, Margin:2}},
                Icon:{Size:12, Margin:4}
            },
            Maximized:{
                BorderTop:{Height:0},
                BorderRight:{Width:0},
                BorderBottom:{Height:0},
                BorderLeft:{Width:0},
                
                BorderTopLeft:{Width:0, Height:0},
                BorderTopRight:{Width:0, Height:0},
                BorderBottomLeft:{Width:0, Height:0},
                BorderBottomRight:{Width:0, Height:0},
                
                Title:{Height:16},
                Header:{Focus:{Color:'#006699'},Unfocused:{Color:'#669999'}},
                
                Client:{Left:0, Top:17, Right:0, Bottom:0, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:1, Close:'X', Maximize:'R', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:12, Margin:4}
            }
        },
        Popout:{
            Normal:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:17},
                Header:{Focus:{Color:'#009900'},Unfocused:{Color:'#669966'}},
                
                Client:{Left:4, Top:21, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:8, Close:'X', Maximize:'M', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:16, Margin:4}
            },
            Minimized:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:17},
                Header:{Focus:{Color:'#009900'},Unfocused:{Color:'#669966'}},
                
                Client:{Left:4, Top:21, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:8, Close:'X', Maximize:'M', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:16, Margin:4}
            },
            Collapsed:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:17},
                Header:{Focus:{Color:'#009900'},Unfocused:{Color:'#669966'}},
                
                Client:{Left:4, Top:21, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:8, Close:'X', Maximize:'M', Collapse:'R', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:16, Margin:4}
            },
            Docked:{
                BorderTop:{Height:4},
                BorderRight:{Width:4},
                BorderBottom:{Height:4},
                BorderLeft:{Width:4},
                
                BorderTopLeft:{Width:8, Height:8},
                BorderTopRight:{Width:8, Height:8},
                BorderBottomLeft:{Width:8, Height:8},
                BorderBottomRight:{Width:8, Height:8},
                
                Title:{Height:17},
                Header:{Focus:{Color:'#009900'},Unfocused:{Color:'#669966'}},
                
                Client:{Left:4, Top:21, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:8, Close:'X', Maximize:'M', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'none', Visibility:'hidden', Icon:{Size:14, Margin:2}},
                Icon:{Size:16, Margin:4}
            },
            Maximized:{
                BorderTop:{Height:0},
                BorderRight:{Width:0},
                BorderBottom:{Height:0},
                BorderLeft:{Width:0},
                
                BorderTopLeft:{Width:0, Height:0},
                BorderTopRight:{Width:0, Height:0},
                BorderBottomLeft:{Width:0, Height:0},
                BorderBottomRight:{Width:0, Height:0},
                
                Title:{Height:17},
                Header:{Focus:{Color:'#009900'},Unfocused:{Color:'#669966'}},
                
                Client:{Left:4, Top:21, Right:4, Bottom:4, BGColor:'#D4D0C8'},
                
                Button:{Width:16, Height:14, Spacing:2, Top:8, Close:'X', Maximize:'R', Collapse:'C', Minimize:'I'},
                WindowListButton:{Display:'block', Visibility:'visible', Icon:{Size:14, Margin:2}},
                Icon:{Size:16, Margin:4}
            }
        }
    };
}
function cStyleInfo_GetBorderStyleSet(borderstyle) {
    switch(borderstyle) {
        case eCCBorderStyle.Solid:
            return(this.BorderStyleData.Solid);
            break;
        case eCCBorderStyle.Raised:
            return(this.BorderStyleData.Raised);
            break;
        case eCCBorderStyle.Lowered:
            return(this.BorderStyleData.Lowered);
            break;
        case eCCBorderStyle.LoweredBevel:
            return(this.BorderStyleData.LoweredBevel);
            break;
        case eCCBorderStyle.RaisedBevel:
            return(this.BorderStyleData.RaisedBevel);
            break;
        case eCCBorderStyle.LoweredOutline:
            return(this.BorderStyleData.LoweredOutline);
            break;
        case eCCBorderStyle.RaisedOutline:
            return(this.BorderStyleData.RaisedOutline);
            break;
        case eCCBorderStyle.Inset:
            return(this.BorderStyleData.Inset);
            break;
        case eCCBorderStyle.Sizeable:
            return(this.BorderStyleData.Sizeable);
            break;
    }
    return(null);
}
function cStyleInfo_GetBrowserSet(browser) {
    if(browser.isIE == true) {
        return(this.BrowserStyleData.IE);
    } else if (browser.isFF) {
        return(this.BrowserStyleData.FF);
    } else {
        return(this.BrowserStyleData.Default);
    }
}
function cStyleInfo_GetCooldownOverlaySet(size) {
    switch(size) {
        case '18':
            return(this.CooldownOverlayStyleData.s18);
            break;
    }
    return(null);
}
function cStyleInfo_GetHoverIconSet(size) {
    switch(size) {
        case '8':
            return(this.HoverIconStyleData.s8);
            break;
        case '10':
            return(this.HoverIconStyleData.s10);
            break;
        case '12':
            return(this.HoverIconStyleData.s12);
            break;
        case '14':
            return(this.HoverIconStyleData.s14);
            break;
        case '16':
            return(this.HoverIconStyleData.s16);
            break;
    }
    return(null);
}
function cStyleInfo_GetMenuItemSet(type) {
    switch(type) {
        case eCMIType.Header:
            return(this.MenuItemStyleData.Header);
            break;
        case eCMIType.Normal:
            return(this.MenuItemStyleData.Normal);
            break;
        case eCMIType.Separator:
            return(this.MenuItemStyleData.Separator);
            break;
        case eCMIType.Radio:
            return(this.MenuItemStyleData.Radio);
            break;
        case eCMIType.Check:
            return(this.MenuItemStyleData.Check);
            break;
    }
    return(null);
}
function cStyleInfo_GetWindowSet(wStyle, wState) {
    switch(wStyle) {
        case eCWStyle.Normal:
            switch(wState) {
                case eCWState.Normal:
                    return(this.WindowStyleData.Normal.Normal);
                    break;
                case eCWState.Minimized:
                    return(this.WindowStyleData.Normal.Minimized);
                    break;
                case eCWState.Collapsed:
                    return(this.WindowStyleData.Normal.Collapsed);
                    break;
                case eCWState.Docked:
                    return(this.WindowStyleData.Normal.Docked);
                    break;
                case eCWState.Maximized:
                    return(this.WindowStyleData.Normal.Maximized);
                    break;
            }
            break;
        case eCWStyle.Tool:
            switch(wState) {
                case eCWState.Normal:
                    return(this.WindowStyleData.Tool.Normal);
                    break;
                case eCWState.Minimized:
                    return(this.WindowStyleData.Tool.Minimized);
                    break;
                case eCWState.Collapsed:
                    return(this.WindowStyleData.Tool.Collapsed);
                    break;
                case eCWState.Docked:
                    return(this.WindowStyleData.Tool.Docked);
                    break;
                case eCWState.Maximized:
                    return(this.WindowStyleData.Tool.Maximized);
                    break;
            }
            break;
        case eCWStyle.Popout:
            switch(wState) {
                case eCWState.Normal:
                    return(this.WindowStyleData.Popout.Normal);
                    break;
                case eCWState.Minimized:
                    return(this.WindowStyleData.Popout.Minimized);
                    break;
                case eCWState.Collapsed:
                    return(this.WindowStyleData.Popout.Collapsed);
                    break;
                case eCWState.Docked:
                    return(this.WindowStyleData.Popout.Docked);
                    break;
                case eCWState.Maximized:
                    return(this.WindowStyleData.Popout.Maximized);
                    break;
            }
            break;
    }
    return(null);
}
cStyleInfo.prototype.GetBorderStyleSet = cStyleInfo_GetBorderStyleSet;
cStyleInfo.prototype.GetBrowserSet = cStyleInfo_GetBrowserSet;
cStyleInfo.prototype.GetCooldownOverlaySet = cStyleInfo_GetCooldownOverlaySet;
cStyleInfo.prototype.GetHoverIconSet = cStyleInfo_GetHoverIconSet;
cStyleInfo.prototype.GetMenuItemSet = cStyleInfo_GetMenuItemSet;
cStyleInfo.prototype.GetWindowSet = cStyleInfo_GetWindowSet;/*
   Copyright 2009 Cory J. Geesaman (http://cory.geesaman.com/)
   http://www.inetgui.org/
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
function cFont(fontArray, color, family, size, weight, decoration, style, scale) {
    if((typeof(fontArray) == 'object') && (fontArray instanceof Array)) {
        if(fontArray.length > 0) { this.BGColor = fontArray[0]; } else { this.BGColor = ''; }
        if(fontArray.length > 1) { this.Color = fontArray[1]; } else { this.Color = ''; }
        if(fontArray.length > 2) { this.Family = fontArray[2]; } else { this.Family = ''; }
        if(fontArray.length > 3) { this.BaseSize = fontArray[3]; } else { this.BaseSize = ''; }
        if(fontArray.length > 4) { this.Weight = fontArray[4]; } else { this.Weight = ''; }
        if(fontArray.length > 5) { this.Decoration = fontArray[5]; } else { this.Decoration = ''; }
        if(fontArray.length > 6) { this.Style = fontArray[6]; } else { this.Style = ''; }
        if(fontArray.length > 7) {
            if((typeof(fontArray[7]) == 'object') && (fontArray[7] instanceof Array)) { this.Scale = new cScale(fontArray[7]); }
            else { this.Scale = new cScale(fontArray[7], -1, 0); }
        } else { this.Scale = new cScale(-1, -1, 0); }
    } else {
        if(arguments.length > 0) { this.BGColor = arguments[0]; } else { this.BGColor = ''; }
        if(arguments.length > 1) { this.Color = arguments[1]; } else { this.Color = ''; }
        if(arguments.length > 2) { this.Family = arguments[2]; } else { this.Family = ''; }
        if(arguments.length > 3) { this.BaseSize = arguments[3]; } else { this.BaseSize = ''; }
        if(arguments.length > 4) { this.Weight = arguments[4]; } else { this.Weight = ''; }
        if(arguments.length > 5) { this.Decoration = arguments[5]; } else { this.Decoration = ''; }
        if(arguments.length > 6) { this.Style = arguments[6]; } else { this.Style = ''; }
        if(arguments.length > 7) {
            if((typeof(arguments[7]) == 'object') && (arguments[7] instanceof Array)) { this.Scale = new cScale(arguments[7]); }
            else { this.Scale = new cScale(arguments[7], -1, 0); }
        } else { this.Scale = new cScale(-1, -1, 0); }
    }
    this.Size = this.BaseSize;
}
function cFont_Dispose() {
    
}
function cFont_CalculateScaleSize(displayrect) {
    if((this.Scale.X > 0) || (this.Scale.Y > 0)) {
        var fS = this.BaseSize.toLowerCase().replace('px', '');
        if((this.Scale.On == eCCScaleOn.Vertical) && (this.Scale.Y > 0)) {
            this.Size = (displayrect.Height * (parseInt(fS) / this.Scale.Y)) + 'px';
        } else if((this.Scale.On == eCCScaleOn.Horizontal) && (this.Scale.X > 0)) {
            this.Size = (displayrect.Width * (parseInt(fS) / this.Scale.X)) + 'px';
        } else {
            var x = displayrect.Width * (parseInt(fS) / this.Scale.X);
            var y = displayrect.Height * (parseInt(fS) / this.Scale.Y);
            if(this.Scale.On == eCCScaleOn.Low) {
                if(x < y) {                 this.Size = x + 'px';               } else {                this.Size = y + 'px';               }
            } else if(this.Scale.On == eCCScaleOn.High) {
                if(x > y) {                 this.Size = x + 'px';               } else {                this.Size = y + 'px';               }
            } else {
                if((x > 0) && (y > 0)) {
                    this.Size = ((x + y) / 2) + 'px';
                } else if(x > 0) {
                    this.Size = x + 'px';
                } else if(y > 0) {
                    this.Size = y + 'px';
                }
            }
        }
    }
    return(this.Size);
}
cFont.prototype.Dispose = cFont_Dispose;
cFont.prototype.CalculateScaleSize = cFont_CalculateScaleSize;
/*
   Copyright 2009 Cory J. Geesaman (http://cory.geesaman.com/)
   http://www.inetgui.org/
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
function cFloatMenuStrip(id, parentobj, x, y, height, right, container) {
    this.ParentObj = parentobj;
    this.ID = id;
    this.x = x;
    this.y = y;
    this.Height = height;
    this.Right = right;
    this.Container = container;
    this.Buttons = new Array();
    this.ButtonID = 0;
}
function cFloatMenuStrip_AddButton(indentation, text, tip, action, selected) {
    this.Buttons.push(new cFloatMenuStripButton(this, this.ButtonID, indentation, text, tip, action, selected));
    this.ButtonID++;
}
function cFloatMenuStrip_Render(s_x, s_y, sx, sy, l, h, sl, sh) {
    if(this.Buttons.length > 0) {
        var mW = 0;
        var mY = 0;
        var iX = 0;
        var iY = s_y * (this.y / 1280);
        if(this.Height >= 0) { iY = this.y; }
        var w = 0;
        for(var i = this.Buttons.length - 1; i >= 0; i--) {
            this.Buttons[i].Render(s_x, s_y, sx, sy, l, h, sl, sh);
            mW = mW + this.Buttons[i].DIVBUTTON.offsetWidth;
            if(this.Buttons[i].SPNBUTTONTEXT.offsetHeight > mY) { mY = this.Buttons[i].SPNBUTTONTEXT.offsetHeight; }
        }
        mY = mY + 8;
        if(this.Height > 0) { mY = this.Height; }
        if(this.Right == 0) {
            iX = (s_x * (this.x / 1280)) - (mW / 2);
        } else if(this.Right < 0) {
            if(this.Container != '') {
                var o = document.getElementById(this.Container);
                var output = new Object();
                var myleft=0;
                output.Width = o.offsetWidth;
                while( o) {
                    myleft+= o.offsetLeft;
                    o= o.offsetParent;
                }
                output.X = myleft;
                iX = output.X - this.Right;
            } else {
                iX = s_x - this.Right;
            }
        } else {
            if(this.Container != '') {
                var o = document.getElementById(this.Container);
                var output = new Object();
                var myleft=0;
                output.Width = o.offsetWidth;
                while( o) {
                    myleft+= o.offsetLeft;
                    o= o.offsetParent;
                }
                output.X = myleft;
                iX = (output.X + output.Width) - (mW + this.Right);
            } else {
                iX = s_x - (mW + this.Right);
            }
        }
        for (var i = 0; i < this.Buttons.length; i++) {
            this.Buttons[i].DIVBUTTON.style.left = parseInt(iX) + "px";
            this.Buttons[i].DIVBUTTON.style.top = parseInt(iY - (mY / 2)) + "px";
            w = this.Buttons[i].SPNBUTTONTEXT.offsetWidth + 8;
            this.Buttons[i].DIVBUTTON.style.width = parseInt(w) + "px";
            this.Buttons[i].DIVBUTTON.style.height = parseInt(mY) + "px";
            this.Buttons[i].IEAdjust(mY);
            this.Buttons[i].SPNBUTTONTEXT.style.left = parseInt(4) + "px";
            this.Buttons[i].SPNBUTTONTEXT.style.top = parseInt(4) + "px";
            iX = iX + w;
        }
    }
}
function cFloatMenuStrip_Resize() {
    this.Render();
}
cFloatMenuStrip.prototype.AddButton = cFloatMenuStrip_AddButton;
cFloatMenuStrip.prototype.Render = cFloatMenuStrip_Render;
cFloatMenuStrip.prototype.Resize = cFloatMenuStrip_Resize;
/*
   Copyright 2009 Cory J. Geesaman (http://cory.geesaman.com/)
   http://www.inetgui.org/
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
function cFloatMenuStripButton(parent, id, indent, text, tip, action, selected) {
    this.Parent = parent;
    this.ID = id;
    this.SuffixID = this.Parent.ID + '.' + id;
    this.Indent = indent;
    this.Text = text;
    this.Tip = tip;
    this.Action = action;
    this.Down = false;
    this.Hovering = false;
    this.Selected = selected;
    this.ParentObj = null;
    this.SPNBUTTONTEXT = null;
    this.s__s_x = 0;
    this.s__s_y = 0;
    this.s__sx = 0;
    this.s__sy = 0;
    this.s__l = 0;
    this.s__h = 0;
    this.s__sl = 0;
    this.s__sh = 0;
    if(this.Parent.Height >= 0) {
        this.Render();
    }
}
function cFloatMenuStripButton_onMouseDown(event) {
    var o = EventObj(event);
    var aID = o.id.split('_');
    if(aID.length > 1) {
        var b = null;
        for(var j = MenuStrip.length - 1; j >= 0; j--) { for(var i = MenuStrip[j].Buttons.length - 1; i >= 0; i--) { if(MenuStrip[j].Buttons[i].SuffixID == aID[1]) { b = MenuStrip[j].Buttons[i]; } } }
        if(b != null) {
            b.Down = true;
            b.Render();
        }
    }
}
function cFloatMenuStripButton_onMouseOut(event) {
    var o = EventObj(event);
    var aID = o.id.split('_');
    if(aID.length > 1) {
        var b = null;
        for(var j = MenuStrip.length - 1; j >= 0; j--) { for(var i = MenuStrip[j].Buttons.length - 1; i >= 0; i--) { if(MenuStrip[j].Buttons[i].SuffixID == aID[1]) { b = MenuStrip[j].Buttons[i]; } } }
        if(b != null) {
            b.Hovering = false;
            b.Render();
        }
    }
}
function cFloatMenuStripButton_onMouseOver(event) {
    var o = EventObj(event);
    var aID = o.id.split('_');
    if(aID.length > 1) {
        var b = null;
        for(var j = MenuStrip.length - 1; j >= 0; j--) { for(var i = MenuStrip[j].Buttons.length - 1; i >= 0; i--) { if(MenuStrip[j].Buttons[i].SuffixID == aID[1]) { b = MenuStrip[j].Buttons[i]; } } }
        if(b != null) {
            b.Hovering = true;
            b.Render();
        }
    }
}
function cFloatMenuStripButton_onMouseUp(event) {
    var o = EventObj(event);
    var aID = o.id.split('_');
    if(aID.length > 1) {
        var b = null;
        for(var j = MenuStrip.length - 1; j >= 0; j--) { for(var i = MenuStrip[j].Buttons.length - 1; i >= 0; i--) { if(MenuStrip[j].Buttons[i].SuffixID == aID[1]) { b = MenuStrip[j].Buttons[i]; } } }
        if(b != null) {
            if (b.Down == true) {
                if(b.Action.length > 0) {
                    var tA = b.Action.split(':');
                    if(tA.length > 0) {
                        switch(tA[0].toUpperCase()) {
                            case "LOCATION":
                                if(tA.length > 1) {
                                    document.location = tA[1];
                                }
                                break;
                        }
                    }
                }
            }
            b.Down = false;
            b.Render();
        }
    }
}
function cFloatMenuStripButton_IEAdjust(h) {
    this.BOTTOM.style.top = parseInt(h - 4) + 'px';
    this.CBL.style.top = parseInt(h - 4) + 'px';
    this.CBR.style.top = parseInt(h - 4) + 'px';
}
function cFloatMenuStripButton_PreRender() {
    if ((this.ParentObj == null) || (this.SPNBUTTONTEXT == null)) {
        this.ParentObj = document.getElementById(this.Parent.ParentObj);
        this.DIVBUTTON = document.createElement("div");
        this.DIVBUTTON.setAttribute('id', 'divFMSB_' + this.SuffixID);
        this.DIVBUTTON.style.display = "block";
        this.DIVBUTTON.style.position = "absolute";
        this.DIVBUTTON.style.visibility = "visible";
        this.DIVBUTTON.title = this.Tip;
        this.SPNBUTTONTEXT = document.createElement("span");
        this.SPNBUTTONTEXT.setAttribute('id', 'divFMSBS_' + this.SuffixID);
        this.SPNBUTTONTEXT.style.display = "block";
        this.SPNBUTTONTEXT.style.position = "absolute";
        this.SPNBUTTONTEXT.style.visibility = "visible";
        this.SPNBUTTONTEXT.style.left = "0px";
        this.SPNBUTTONTEXT.style.top = "0px";
        if(this.Parent.Height < 0) {
            this.SPNBUTTONTEXT.style.padding = "2px 8px 2px 8px";
        } else {
            this.SPNBUTTONTEXT.style.padding = "0px 8px 0px 8px";
        }
        this.SPNBUTTONTEXT.title = this.Tip;
        this.SPNBUTTONTEXT.setAttribute('unselectable', 'on');
        this.SPNBUTTONTEXT.innerHTML = this.Text;
        
        this.TOP = document.createElement("span");
        this.DIVBUTTON.setAttribute('id', 'divFMSBT_' + this.SuffixID);
        this.TOP.style.display = "block"; this.TOP.style.position = "absolute"; this.TOP.style.visibility = "visible";
        this.TOP.style.backgroundImage = "url(style/default/img/menu/bt_bb.png)"; this.TOP.style.backgroundPosition = "0px 0px";
        this.TOP.style.backgroundRepeat = "repeat-x";
        this.TOP.style.fontSize = '0px';
        this.TOP.style.left = "0px"; this.TOP.style.top = "0px"; this.TOP.style.width = "100%"; this.TOP.style.height = "4px";
        
        this.BOTTOM = document.createElement("span");
        this.DIVBUTTON.setAttribute('id', 'divFMSBB_' + this.SuffixID);
        this.BOTTOM.style.display = "block"; this.BOTTOM.style.position = "absolute"; this.BOTTOM.style.visibility = "visible";
        this.BOTTOM.style.backgroundImage = "url(style/default/img/menu/bt_bb.png)"; this.BOTTOM.style.backgroundPosition = "0px -4px";
        this.BOTTOM.style.backgroundRepeat = "repeat-x";
        this.BOTTOM.style.left = "0px"; this.BOTTOM.style.bottom = "0px"; this.BOTTOM.style.width = "100%"; this.BOTTOM.style.height = "4px";
        
        this.LEFT = document.createElement("span");
        this.DIVBUTTON.setAttribute('id', 'divFMSBL_' + this.SuffixID);
        this.LEFT.style.display = "block"; this.LEFT.style.position = "absolute"; this.LEFT.style.visibility = "visible";
        this.LEFT.style.backgroundImage = "url(style/default/img/menu/bl_br.png)"; this.LEFT.style.backgroundPosition = "0px 0px";
        this.LEFT.style.backgroundRepeat = "repeat-y";
        this.LEFT.style.left = "0px"; this.LEFT.style.top = "0px"; this.LEFT.style.width = "4px"; this.LEFT.style.height = "100%";
        
        this.RIGHT = document.createElement("span");
        this.DIVBUTTON.setAttribute('id', 'divFMSBR_' + this.SuffixID);
        this.RIGHT.style.display = "block"; this.RIGHT.style.position = "absolute"; this.RIGHT.style.visibility = "visible";
        this.RIGHT.style.backgroundImage = "url(style/default/img/menu/bl_br.png)"; this.RIGHT.style.backgroundPosition = "-4px 0px";
        this.RIGHT.style.backgroundRepeat = "repeat-y";
        this.RIGHT.style.right = "0px"; this.RIGHT.style.bottom = "0px"; this.RIGHT.style.width = "4px"; this.RIGHT.style.height = "100%";
        
        this.CTL = document.createElement("span");
        this.DIVBUTTON.setAttribute('id', 'divFMSBCTL_' + this.SuffixID);
        this.CTL.style.display = "block"; this.CTL.style.position = "absolute"; this.CTL.style.visibility = "visible";
        this.CTL.style.backgroundImage = "url(style/default/img/menu/corners.png)"; this.CTL.style.backgroundPosition = "0px 0px";
        this.CTL.style.backgroundRepeat = "no-repeat";
        this.CTL.style.fontSize = '0px';
        this.CTL.style.left = "0px"; this.CTL.style.top = "0px"; this.CTL.style.width = "4px"; this.CTL.style.height = "4px";
        
        this.CTR = document.createElement("span");
        this.DIVBUTTON.setAttribute('id', 'divFMSBCTR_' + this.SuffixID);
        this.CTR.style.display = "block"; this.CTR.style.position = "absolute"; this.CTR.style.visibility = "visible";
        this.CTR.style.backgroundImage = "url(style/default/img/menu/corners.png)"; this.CTR.style.backgroundPosition = "-4px 0px";
        this.CTR.style.backgroundRepeat = "no-repeat";
        this.CTR.style.fontSize = '0px';
        this.CTR.style.right = "0px"; this.CTR.style.top = "0px"; this.CTR.style.width = "4px"; this.CTR.style.height = "4px";
        
        this.CBL = document.createElement("span");
        this.DIVBUTTON.setAttribute('id', 'divFMSBCBL_' + this.SuffixID);
        this.CBL.style.display = "block"; this.CBL.style.position = "absolute"; this.CBL.style.visibility = "visible";
        this.CBL.style.backgroundImage = "url(style/default/img/menu/corners.png)"; this.CBL.style.backgroundPosition = "0px -4px";
        this.CBL.style.backgroundRepeat = "no-repeat";
        this.CBL.style.left = "0px"; this.CBL.style.bottom = "0px"; this.CBL.style.width = "4px"; this.CBL.style.height = "4px";
        
        this.CBR = document.createElement("span");
        this.DIVBUTTON.setAttribute('id', 'divFMSBCBR_' + this.SuffixID);
        this.CBR.style.display = "block"; this.CBR.style.position = "absolute"; this.CBR.style.visibility = "visible";
        this.CBR.style.backgroundImage = "url(style/default/img/menu/corners.png)"; this.CBR.style.backgroundPosition = "-4px -4px";
        this.CBR.style.backgroundRepeat = "no-repeat";
        this.CBR.style.right = "0px"; this.CBR.style.bottom = "0px"; this.CBR.style.width = "4px"; this.CBR.style.height = "4px";
        
        this.DIVBUTTONE = document.createElement("div");
        this.DIVBUTTONE.setAttribute('id', 'divFMSBE_' + this.SuffixID);
        this.DIVBUTTONE.style.width = "100%";
        this.DIVBUTTONE.style.height = "100%";
        this.DIVBUTTONE.style.display = "block";
        this.DIVBUTTONE.style.position = "absolute";
        this.DIVBUTTONE.style.visibility = "visible";
        this.DIVBUTTONE.title = this.Tip;
        this.DIVBUTTONE.style.cursor = 'pointer';
        this.SPNBUTTONTEXT.style.cursor = 'pointer';
        
        this.DIVBUTTON.appendChild(this.SPNBUTTONTEXT);
        this.DIVBUTTON.appendChild(this.TOP);
        this.DIVBUTTON.appendChild(this.BOTTOM);
        this.DIVBUTTON.appendChild(this.LEFT);
        this.DIVBUTTON.appendChild(this.RIGHT);
        this.DIVBUTTON.appendChild(this.CTL);
        this.DIVBUTTON.appendChild(this.CTR);
        this.DIVBUTTON.appendChild(this.CBL);
        this.DIVBUTTON.appendChild(this.CBR);
        this.DIVBUTTON.appendChild(this.DIVBUTTONE);
        this.ParentObj.appendChild(this.DIVBUTTON);
        this.DIVBUTTON.style.width = parseInt(this.SPNBUTTONTEXT.offsetWidth) + 'px';
        
        eventPush(this.DIVBUTTONE, "mousedown", this.onMouseDown); eventPush(this.DIVBUTTONE, "mouseout", this.onMouseOut);
        eventPush(this.DIVBUTTONE, "mouseover", this.onMouseOver); eventPush(this.DIVBUTTONE, "mouseup", this.onMouseUp);
        eventPush(this.SPNBUTTONTEXT, "mousedown", this.onMouseDown); eventPush(this.SPNBUTTONTEXT, "mouseout", this.onMouseOut);
        eventPush(this.SPNBUTTONTEXT, "mouseover", this.onMouseOver); eventPush(this.SPNBUTTONTEXT, "mouseup", this.onMouseUp);
    }
}
function cFloatMenuStripButton_Render(s_x, s_y, sx, sy, l, h, sl, sh) {
    this.PreRender();
    if(typeof(s_x) == "undefined") { s_x = this.s__s_x;} else { this.s__s_x = s_x; }
    if(typeof(s_y) == "undefined") { s_y = this.s__s_y;} else { this.s__s_y = s_y; }
    if(typeof(sx) == "undefined") { sx = this.s__sx;} else { this.s__sx = sx; }
    if(typeof(sy) == "undefined") { sy = this.s__sy;} else { this.s__sy = sy; }
    if(typeof(l) == "undefined") { l = this.s__l;} else { this.s__l = l; }
    if(typeof(h) == "undefined") { h = this.s__h;} else { this.s__h = h; }
    if(typeof(sl) == "undefined") { sl = this.s__sl;} else { this.s__sl = sl; }
    if(typeof(sh) == "undefined") { sh = this.s__sh;} else { this.s__sh = sh; }
    if(this.Parent.Height < 0) {
        this.SPNBUTTONTEXT.style.fontSize = parseInt(h * 18 / 1280) + "px";
    } else {
        if(this.Indent < 1) {
            this.SPNBUTTONTEXT.style.fontSize = parseInt((this.Parent.Height / 34) * 22) + "px";
        } else if(this.Indent < 2) {
            this.SPNBUTTONTEXT.style.fontSize = parseInt((this.Parent.Height / 34) * 20) + "px";
        } else if(this.Indent < 3) {
            this.SPNBUTTONTEXT.style.fontSize = parseInt((this.Parent.Height / 34) * 18) + "px";
        }
    }
    this.SPNBUTTONTEXT.className = "mainmenu_button";
    if(this.Indent > 0) { this.SPNBUTTONTEXT.className = this.SPNBUTTONTEXT.className + "_" + this.Indent; }
    if(this.Selected == true) {
        if(this.Down == true) { this.SPNBUTTONTEXT.className = this.SPNBUTTONTEXT.className + "_s_d"; }
        else if(this.Hovering == true) { this.SPNBUTTONTEXT.className = this.SPNBUTTONTEXT.className + "_s_h"; }
    } else {
        if(this.Down == true) { this.SPNBUTTONTEXT.className = this.SPNBUTTONTEXT.className + "_d"; }
        else if(this.Hovering == true) { this.SPNBUTTONTEXT.className = this.SPNBUTTONTEXT.className + "_h"; }
    }
    this.DIVBUTTON.className = this.SPNBUTTONTEXT.className;
}
cFloatMenuStripButton.prototype.onMouseDown = cFloatMenuStripButton_onMouseDown;
cFloatMenuStripButton.prototype.onMouseOut = cFloatMenuStripButton_onMouseOut;
cFloatMenuStripButton.prototype.onMouseOver = cFloatMenuStripButton_onMouseOver;
cFloatMenuStripButton.prototype.onMouseUp = cFloatMenuStripButton_onMouseUp;
cFloatMenuStripButton.prototype.IEAdjust = cFloatMenuStripButton_IEAdjust;
cFloatMenuStripButton.prototype.PreRender = cFloatMenuStripButton_PreRender;
cFloatMenuStripButton.prototype.Render = cFloatMenuStripButton_Render;

