﻿// Array
// add Array.push if needed
if(Array.prototype.push == null){
Array.prototype.push = function(item) {this[this.length] = item; return this.length;}
}
// String
// trim's: trim, ltrim, rtrim
String.prototype.trim = function(){
return this.replace(/^\s+|\s+$/g,'');
};
String.prototype.ltrim = function(){
return this.replace(/^\s+/,'');
};
String.prototype.rtrim = function(){
return this.replace(/\s+$/,'');
};
// replaceAll
String.prototype.replaceAll = function(strTarget, strSubString){
var strText=this;
var intIndexOfMatch = strText.indexOf(strTarget);
while(intIndexOfMatch != -1){
strText = strText.replace(strTarget, strSubString);
intIndexOfMatch = strText.indexOf(strTarget);
}
return strText;
};
// TheGamingLib
if(typeof TheGamingLib=="undefined"){
var TheGamingLib={};
};
// TheGamingLib.Cookies
/* 
   Property 	Description 	Example
	name = value 	This sets both the cookie's name and its value. username = matt
	expires = date 	This optional value sets the date that the cookie will expire on. The date should be in the format returned by the toGMTString() method of the Date object.
					If the expires value is not given, the cookie will be destroyed the moment the browser is closed. expires=13/06/2003 00:00:00
	path = path 	This optional value specifies a path within the site to which the cookie applies. Only documents in this path will be able to retrieve the cookie.
					Usually this is left blank, meaning that only the path that set the cookie can retrieve it. path=/tutorials/
	domain =domain 	This optional value specifies a domain within which the cookie applies. Only websites in this domain will be able to retrieve the cookie.
					Usually this is left blank, meaning that only the domain that set the cookie can retrieve it. domain=elated.com
	secure 			This optional flag indicates that the browser should use SSL when sending the cookie to the server. This flag is rarely used. secure

*/
// Methods
TheGamingLib.Cookies=function(){};
// Create Cookie
TheGamingLib.Cookies.CreateCookie = function(){
this.cName=new String();
this.cValue=new String();
this.cExpires=null;
this.cPath=new String();
this.cDomain=new String();
this.cSecure=new Boolean(false);
};
var TCCC = TheGamingLib.Cookies.CreateCookie.prototype;
TCCC.Name=function(value){if(typeof value != 'undefined') this.cName = value;return this.cName};
TCCC.Value=function(value){if(typeof value != 'undefined') this.cValue = value;return this.cValue};
TCCC.Expires=function(value){if(typeof value != 'undefined') this.cExpires = value;return this.cExpires};
TCCC.ExpireDays=function(value){
var exdate=new Date();
if((typeof value != 'undefined') && (value != null) && (value != '')){
exdate.setTime(exdate.getTime() + (new Number(value) * 1000 * 60 * 60 * 24));
this.cExpires = exdate;
return value;
}
var dt = this.cExpires.getTime();
dt = (dt / 1000 / 60 / 60 / 24);
var nw = exdate.getTime();
nw = (nw / 1000 / 60 / 60 / 24);
return (dt-nw);
};
TCCC.ExpireMonths=function(value){
var exdate=new Date();
if((typeof value != 'undefined') && (value != null) && (value != '')){
var yr = new Number(exdate.getFullYear());
var mt = new Number(exdate.getMonth());
var yrs = new Number(0);
var mts = new Number(value);
while(mts > 11){
yrs += 1;
mts -= 12;
}
if((mt+mts) > 12){
yrs += 1;
mt = ((mt + mts) - 12);
}else{
mt = (mt + mts);
}
exdate.setFullYear((yr + yrs), mt, exdate.getDate());
this.cExpires = exdate;
return value;
}
var yrs = new Number(this.ExpireYears());
var mts = new Number(this.cExpires.getMonth() - exdate.getMonth());
mts += new Number(yrs * 12);
return mts;
};
TCCC.ExpireYears=function(value){
var exdate=new Date();
if((typeof value != 'undefined') && (value != null) && (value != '')){
exdate.setFullYear((exdate.getFullYear() + new Number(value)), exdate.getMonth(), exdate.getDate());
this.cExpires = exdate;
return value;
}
return new Number(this.cExpires.getFullYear() - exdate.getFullYear());
};
TCCC.Path=function(value){if(typeof value != 'undefined') this.cPath = value;return this.cPath};
TCCC.Domain=function(value){if(typeof value != 'undefined') this.cDomain = value;return this.cDomain};
TCCC.Secure=function(value){if(typeof value != 'undefined') this.cSecure = value;return this.cSecure};
TCCC.setCookie=function(){
if((this.cName != '') && (this.cValue != '')){
var cok = (this.cName + "=" + escape(this.cValue));
if((typeof this.cExpires != 'undefined') && (this.cExpires != null) && (this.cExpires != '')) {cok += '; expires=' + this.cExpires.toGMTString();}
if((typeof this.cPath != 'undefined') && (this.cPath != null) && (this.cPath != '')) {cok += '; path=' + this.cPath;}
if((typeof this.cDomain != 'undefined') && (this.cDomain != null) && (this.cDomain != '')) {cok += '; domain=' + this.cDomain;}
if(this.cSecure == true) {cok += '; secure'}
try{
document.cookie=cok;
return true;
}catch(e){
}
}
return false;
};
// End Create Cookie
TheGamingLib.Cookies.getCookie = function(name, def){
if(typeof name == 'undefined') return def;
name = name.trim();
if(name.length == 0){
return def;
}
var acok = document.cookie.split(';'); // All cookies to Array
var csep = new Number();
var cnam = new String(); // Cookie Name String
var cval = ''; // Cookie Value String
var bcok = new Boolean(false); // Set Boolean t/f default f
for(var i=0;i < acok.length;i++){
// split apart each name=value pair
csep = acok[i].indexOf("=");
if(csep > -1){
// and trim left/right whitespace
cnam = acok[i].substring(0,csep).trim();
if(cnam == name){
bcok = true;
csep += 1;
// handle case where cookie has no value but exists (no = sign, that is);
if(csep >= acok[i].length){
break;
}
cval = unescape(acok[i].substring(csep,acok[i].length).trim());
}
}
}
if(bcok == false){
return def;
}
return cval;
};
TheGamingLib.Cookies.getCookieValue = function(cname,vname,vsep,defval){
if(typeof name == 'undefined') return null;
if(typeof vname == 'undefined') return null;
if(typeof vsep == 'undefined') return null;
var cokval = TheGamingLib.Cookies.getCookie(cname);
if(cokval != null){
vname = vname.trim();
var aval = cokval.split(vsep);
var tval = new Array();
var vnam = '';
for(var i=0;i < aval.length;i++){
// split apart each name=value pair
tval = aval[i].split('=');
vnam = tval[0].trim();
if(vnam == vname){
// handle case where cookie has no value but exists (no = sign, that is):
if(tval.length > 1){
return unescape(tval[1].trim());
}
// cases where cookie is initialized but no value, null is returned
return null;
break;
}
}
}
// No Cookie value or null;
if(typeof defval != 'undefined'){
return defval;
}
return cokval;
};
TheGamingLib.Cookies.checkCookie = function(name){
if(TheGamingLib.Cookies.getCookie(name) != null){
return true;
}
return false;
};
TheGamingLib.Cookies.deleteCookie = function(name, path, domain){
var del = new TheGamingLib.Cookies.CreateCookie();
del.cName = name;
del.cPath = path;
del.cDomain = domain;
del.cExpires = new Date().setFullYear(2000,1,1);
return del.setCookie();
};
// End TheGamingLib.Cookies

// TheGamingLib.QueryString
// Methods
TheGamingLib.QueryString={
enableQueryString:function(){
// Set QueryString Url
var url = new String(window.location);
var iqs = url.indexOf('?');
if(iqs > -1){
TheGamingLib.QueryString.ToString = new String(url.substring((iqs+1),url.length));
url = TheGamingLib.QueryString.ToString;
// Set QueryStrings
try{
TheGamingLib.QueryString.Count=0;
var iItm = url.indexOf('=');
var iKey;
while(iItm != -1){
TheGamingLib.QueryString.Keys[TheGamingLib.QueryString.Count] = url.substr(0,iItm);
url = url.substr((iItm+1),url.length);
iKey = url.indexOf('&');
if(iKey > -1){
TheGamingLib.QueryString.Items[TheGamingLib.QueryString.Count] = url.substr(0,iKey);
url = url.substr((iKey+1),url.length);
iItm = url.indexOf('=');
}else{
TheGamingLib.QueryString.Items[TheGamingLib.QueryString.Count] = url;
iItm = -1;
}
TheGamingLib.QueryString.Count += 1;
}
}catch(e){
TheGamingLib.QueryString.Keys=new Array();
TheGamingLib.QueryString.Items=new Array();
TheGamingLib.QueryString.Count=0;
}
}
TheGamingLib.QueryString.Enable=true;
return TheGamingLib.QueryString.Enable;
},
KeyName:function(index, defValue){
if(typeof defValue=='undefined') defValue = '';
if(TheGamingLib.QueryString.Enable == true){
return TheGamingLib.QueryString.Keys[index];
}
return defValue;
},
KeyItem:function(index, defValue){
if(typeof defValue=='undefined') defValue = '';
if(TheGamingLib.QueryString.Enable == true){
return TheGamingLib.QueryString.Items[index];
}
return defValue;
},
Item:function(name, defValue){
if(typeof defValue=='undefined') defValue = '';
if(TheGamingLib.QueryString.Enable == true){
name = name.toLowerCase();
for(var i=0;i<TheGamingLib.QueryString.Count;i++){
if(TheGamingLib.QueryString.Keys[i].toLowerCase() == name){
return TheGamingLib.QueryString.Items[i];
}
}
}
return defValue;
}
};
// Fields
TheGamingLib.QueryString.Enable=new Boolean(false);
TheGamingLib.QueryString.Count=new Number();
TheGamingLib.QueryString.Keys=new Array();
TheGamingLib.QueryString.Items=new Array();
TheGamingLib.QueryString.ToString=new String();
// End TheGamingLib.QueryString

// TheGamingLib.Interaction
// Methods
TheGamingLib.Interaction={
IIf:function(Expression,TruePart,FalsePart){
if(Expression){
return TruePart;
}
return FalsePart;
}
};
// TheGamingLib.DHTMLTooltip
// Methods
TheGamingLib.DHTMLTooltip={
Title:function(doc){
if((TheGamingLib.DHTMLTooltip.enableDHTMLTooltip == false) || (navigator.userAgent.indexOf("MSIE") > -1)){
return false;
}
var tgs = new Array('a','img');
var onc = new Array('onmouseover', 'onmouseout', 'onclick');
var cmd = new Array('glib_dhtmltooltipshow(\'ezwinningspage\',boxTitle);', 'glib_dhtmltooltiphide();', 'glib_dhtmltooltiphide();');
var att = 'false';
var tal = false;
var avl;
var scm;
var tag;
var box;
for(var itg=0;itg<tgs.length;itg++){
tag=doc.getElementsByTagName(tgs[itg]);
for(var iel=0;iel<tag.length;iel++){
box=tag[iel];
try{
att = box.getAttribute('odhtmlttallow');
if(att == null) att = 'true';
}catch(e){
att = 'true';
}
try{
tal = box.getAttribute('odhtmlttalttext');
if((tal == 'true') || (tal == 'yes')){
tal = true;
}else{
tal = false;
}
}catch(e){
tal = false;
}
if((typeof att != null) && (att != 'no') && (att != 'false')){
if((typeof box.title != 'undefined') && (box.title != '')){
if(tal==true) box.setAttribute('alt',box.title);
for(var iat=0;iat<onc.length;iat++){
scm = ('javascript:'+cmd[iat].replace('boxTitle',TheGamingLib.Interaction.IIf((tal==true),'this.alt',("'"+box.getAttribute('title')+"'"))));
if((box.getAttribute(onc[iat]) == 'undefined') || ((box.getAttribute(onc[iat]) == null) || (box.getAttribute(onc[iat]) == ''))){
box.setAttribute(onc[iat],scm);
}else{
avl=box.getAttribute(onc[iat]);
if(avl.substring((avl.length-1),avl.length) != ';'){
scm = (';' + scm);
}
box.setAttribute(onc[iat],(avl+scm));
}
}
box.setAttribute('title','');
}
}
}
tag=null;
}
return true;
}
};
TheGamingLib.DHTMLTooltip.enableDHTMLTooltip = new Boolean(false);
