﻿<!--
var _web =
{
    DefaultPage: 'default.aspx',
    AppPath: (typeof AppPath == 'undefined') ? '/' : AppPath
};

var _app =
{
    SID: function() {
        var tdt = new Date();

        return tdt.getTime().toString() + (1 + Math.floor((Math.random() * 9999999999))).toString();
    },
    Domain: window.location.host,
    SitePath: function() {
        var sp = (window.location.href.indexOf(_web.AppPath) > -1) ? window.location.protocol + '//' + window.location.host + _web.AppPath : window.location.protocol + '//' + window.location.host + '/';

        sp = sp.toLowerCase();

        return sp;
    },
    CDir: window.location.pathname.replace(window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1), '').substring(1),
    CPage: (window.location.pathname.replace(_web.AppPath, '') == '') ? _web.DefaultPage : (window.location.pathname.replace(_web.AppPath, '').charAt(0) == '/') ? window.location.pathname.replace(_web.AppPath, '').substring(1) : window.location.pathname.replace(_web.AppPath, ''),
    dt: function() {
        var tdt = new Date();

        return tdt.getMonth() + 1 + '/' + tdt.getDate() + '/' + tdt.getFullYear();
    },
    TDY: function() {
        var tdt = new Date();

        return tdt.getMonth() + 1 + '/' + tdt.getDate() + '/' + tdt.getFullYear() + ' ' + tdt.getHours() + ':' + tdt.getMinutes() + ':' + tdt.getSeconds();
    },
    MonthsARR: new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
    DaysARR: new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')
};

var _cookie =
{
    Get: function(Name) {
        try {
            var start = document.cookie.indexOf(Name + '=');
            var len = start + Name.length + 1;

            if ((!start) && (Name != document.cookie.substring(0, Name.length))) { return null; }
            if (start == -1) { return null; }

            var end = document.cookie.indexOf(';', len);

            if (end == -1) end = document.cookie.length;

            return unescape(document.cookie.substring(len, end));
        }
        catch (e) {
            return null;
        }
    },

    Set: function(Name, Value, Expires, Path, Domain, Secure) {
        try {
            var today = new Date();

            today.setTime(today.getTime());

            if (Expires) { Expires = Expires * 1000 * 60 * 60 * 24; }

            var expires_date = new Date(today.getTime() + (Expires));

            document.cookie = Name + '=' + escape(Value) + ((Expires) ? ';expires=' + expires_date.toGMTString() : '') + ((Path) ? ';path=' + Path : '') + ((Domain) ? ';domain=' + Domain : '') + ((Secure) ? ';secure' : '');
        }
        catch (e) {
        }
    }
};

var _text = 
{
	isAlpha: function(sText) {
		var regEx = new RegExp(/^[a-zA-Z]+$/);
		
		return regEx.test(sText);
	},

	isNumeric: function(sText) {
		var regEx = new RegExp(/^[\d\.]+$/);
		
		return regEx.test(sText);
	},

	isAlphaNumeric: function(sText) {
		var regEx = new RegExp(/^[a-zA-Z0-9]+$/);
		
		return regEx.test(sText);
	},
	
	Limit: function(OBJ, Cap)
	{
		if (OBJ.value.length > Cap) {
			OBJ.value = OBJ.value.substr(0, Cap);
		}
	},
	
	Encode: function(Data)
	{
		Data = Data.replace(/</g, '&lt;');
		Data = Data.replace(/>/g, '&gt;');

		return encodeURIComponent(Data);
	},
	
	Decode: function(Data)
	{
		Data = decodeURIComponent(Data);
		Data = Data.replace(/&lt;/g, '<');
		Data = Data.replace(/&gt;/g, '>');

		return Data;
	}
};

var _AJAX =
{
    /**************************
    Response Data
    ***************************
    status
    responseText
    responseXML
    statusText
    **************************/

	Request: function() {
		var reqObject = null;
		var XMLHTTP = new Array(
			'Msxml2.XMLHTTP.5.0',
			'Msxml2.XMLHTTP.4.0',
			'Msxml2.XMLHTTP.3.0',
			'Msxml2.XMLHTTP',
			'Microsoft.XMLHTTP');
		
		for (i = 0; i < XMLHTTP.length; i++)
		{
			try {
				reqObject = new ActiveXObject(XMLHTTP[i]);
			}
			catch (e) {
				reqObject = null;
			}
		}

		if (!reqObject && typeof XMLHttpRequest != "undefined") {
			reqObject = new XMLHttpRequest(); 
		} 
        
		return reqObject;
	},

	Post: function(Request, URL, Data, CallBack, Asynch) {
		try {
			if (typeof CallBack == 'undefined') CallBack = null;
			if (typeof Asynch == 'undefined') Asynch = false;

			/**********************************************************************
			Verifies ALL parameters required are provided.
			**********************************************************************/
			if (typeof Request == 'undefined' || typeof URL == 'undefined' || typeof Data == 'undefined') {
				return false;
			}

			if (Request != null) {
				Request.open('POST', URL, Asynch);
				Request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
				Request.setRequestHeader('Content-length', Data.length);
				Request.setRequestHeader('Connection', 'close');

				if (Asynch) {
					Request.onreadystatechange = function() {
						if (Request.readyState == 4 && Request.status == 200) {
							if (CallBack != null) { CallBack(Request); }
						}
					}
				}

				Request.send(Data);

				if (!Asynch) {
					if (Request.status == 200) {
						if (CallBack != null) { CallBack(Request); }
					}
				}
			}
		}
		catch (e) {
		}
	},

    Get: function(Reqeuest, URL, CallBack, Asynch) {
        try {
            if (typeof CallBack == 'undefined') CallBack = null;
            if (typeof Asynch == 'undefined') Asynch = true;

            /**********************************************************************
            Verifies ALL parameters required are provided.
            **********************************************************************/
            if (typeof Reqeuest == 'undefined' || typeof URL == 'undefined') {
                return false;
            }

            if (Reqeuest != null) {
//                if (URL.indexOf('?') > -1) {
//                    URL = URL.replace('?', '?_sid=' + _app.SID() + '&dt=' + _app.TDY() + '&');
//                }
//                else {
//                    URL += '?_sid=' + _app.SID() + '&dt=' + _app.TDY();
//                }

                if (URL.indexOf('?') > -1) {
                    URL = URL.replace('?', '?_sid=' + _app.SID() + '&');
                }
                else {
                    URL += '?_sid=' + _app.SID();
                }

                Reqeuest.open('GET', URL, Asynch);
                Reqeuest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                Reqeuest.setRequestHeader('Content-length', '0');

                if (Asynch) {
                    Reqeuest.onreadystatechange = function() {
                        if (Reqeuest.readyState == 4 && Reqeuest.status == 200) {
                            if (CallBack != null) { CallBack(Reqeuest); }
                        }
                    }
                }

                Reqeuest.send(null);

                if (!Asynch) {
                    if (Reqeuest.status == 200) {
                        if (CallBack != null) { CallBack(Reqeuest); }
                    }
                }
            }
        }
        catch (e) {
        }
    }
};

function nav2(Page, NewWindow) {
	if (typeof NewWindow == 'undefined') NewWindow = false;

	if (NewWindow) {
		var wtop = (screen.height / 2) - (600 / 2);
		var wleft = (screen.width / 2) - (800 / 2);

		window.open(Page, 'NewWindow', 'top=' + wtop + ',left=' + wleft + ',width=800,height=600,resizable=yes,scrollbars=yes,menubar=yes,toolbar=yes,location=yes,status=yes');
	}
	else {
		document.location = Page;
	}
}

function w3c(Page) {
    window.open(Page);
}

function isAlpha(sText) {
	var regEx = new RegExp(/^[a-zA-Z]+$/);
	
	return regEx.test(sText);
}

function isNumeric(sText) {
	var regEx = new RegExp(/^\d+$/);
	
	return regEx.test(sText);
}

function isAlphaNumeric(sText) {
	var regEx = new RegExp(/^[a-zA-Z0-9]+$/);
	
	return regEx.test(sText);
}

function setButton(ID, Background, Color)
{
	var obj = document.getElementById(ID);
	
	if (obj.disabled == '') {
		obj.style['background'] = Background;
		obj.style['color'] = Color;
	}
}

function setButtonImage(ID, Border)
{
	var obj = document.getElementById(ID);
	
	if (Border == 'on') {
		obj.style['border'] = 'solid 1px #990000';
	}
	if (Border == 'off') {
		obj.style['border'] = 'solid 1px #ffffff';
	}
}
//-->
