// This file was dynamicaly created for
// JavaScript Document
/**
* @version 2020-02-26
*/
function explore_object(obj /* [, return_result] */)
{
var _args = explore_object.arguments;
var return_result = (_args.length > 1) ? _args[1] : false;
var txt = '';
for(i in obj)
{
try
{
if(typeof obj[i] != 'function')
{
txt += i + ' = ' + obj[i] + '\n';
}
else
{
txt += i + ' = function(){}\n';
}
}
catch(ex)
{
txt += i + ' = [UNABLE TO ACCESS THIS PROPERTY]\n';
}
}
if(return_result) return txt;
else alert(txt);
}
// displaying "Loading Framework..." message
document.writeln('
');
// Definitions
var framework_location = 'https://vitaminxp.com/framework/JavaScript/';
// Framework Start
var VitaminXP = window.VitaminXP || {};
// Detect Web browser
VitaminXP.DetectBrowser = function()
{
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}
var Browser = VitaminXP.DetectBrowser();
var loaded_modules = 0;
// Creates (if doesn't exist) and returns the namespace passed
VitaminXP.Namespace = function(ns)
{
if (!ns || !ns.length)
{
return null;
}
var levels = ns.split(".");
var nsobj = VitaminXP;
// "VitaminXP" is implied, so it is ignored if it is included
for (var i = (levels[0] == "VitaminXP") ? 1 : 0; i < levels.length; ++i)
{
nsobj[levels[i]] = nsobj[levels[i]] || {};
nsobj = nsobj[levels[i]];
}
loaded_modules++;
document.getElementById("loaded_modules").innerHTML = "Loaded Modules: " + loaded_modules;
return nsobj;
};
// Load prerequisit namespace
VitaminXP.Import = function(ns)
{
var levels = ns.split(".");
var nsobj = VitaminXP;
var exists = true;
// check if this namespace is already imported
for (var i = (levels[0] == "VitaminXP") ? 1 : 0; i < levels.length; ++i)
{
if(nsobj[levels[i]])
{
nsobj = nsobj[levels[i]];
}
else
{
exists = false;
i = levels.length;
}
}
if(!exists)
{
document.writeln('');
}
};
VitaminXP.Exception = function(error, func)
{
var message = (typeof error == 'object') ? error.message : error;
alert("JavaScript Error Occured: ''" + message + "'' in function " + func + "()");
};
// String of javascript to execute when page loads
VitaminXP.StartupScript = new Array();
// Adds passed script to variable and will be executed when page loads
VitaminXP.StartUp = function(script)
{
VitaminXP.StartupScript.push(script);
}
VitaminXP.RunStartupScript = function()
{
while(VitaminXP.StartupScript.length > 0)
{
try
{
if(typeof VitaminXP.StartupScript[0] == 'string')
{
eval(VitaminXP.StartupScript[0]);
}
else
{
VitaminXP.StartupScript[0]();
}
}
catch(ex)
{
window.status = ex.message;
}
VitaminXP.StartupScript.shift();
}
}
// On Page Load
window.onload = function()
{
VitaminXP.RunStartupScript();
}
// Returns Element that has ID same as passed
function element(el)
{
return VitaminXP.Element.Get(el);
}
function $(el)
{
return VitaminXP.Element.Get(el);
}
// Opens a new pop up window
VitaminXP.OpenWindow = function(url,id,width,height)
{ // Additional args: 5) left, 6) top.
var args = open_window.arguments
var left = (args.length > 4)? args[4] : (screen.availWidth/2)-(width/2)
var top = (args.length > 5)? args[5] : (screen.availHeight/2)-(width/2)
setup = 'toolbar=no,location=no,directories=no,left='+left+',top='+top+',menubar=no,width='+width+',height='+height
setup += 'scrollbars=no,resizable=no'
window.open(url,id,setup)
}
// Reloads page (not just refreshes)
VitaminXP.ReloadPage = function()
{
if(Browser == "Internet Explorer"){
history.go(0)
}else{
window.location.reload(true)
}
}
// hide "loading..." message
VitaminXP.HideLoadingStatusMessage = function()
{
VitaminXP.Animation.Animate($('loading_message'), {opacity:{to:0}}, 1, 'EaseBoth');
// just hide it in case animation failed
setTimeout('$(\'loading_message\').style.display = \'none\'', 1000);
}
VitaminXP.StartUp("VitaminXP.HideLoadingStatusMessage()");
// Detects players/browser/OS and other stuff
VitaminXP.Namespace("VitaminXP.System");
VitaminXP.System.isPlayerInstalled = function(player_name)
{
var result = undefined;
// Check if can detect player
if(VitaminXP.System.IECompatible || (navigator.plugins && navigator.plugins.length > 0))
{
// Do nothing
}
else
{
return result; // undefined (because can not check)
}
switch(player_name)
{
case "windows_media":
result = VitaminXP.System.DetectPlugin('Windows Media', 'Pl');
if(!result && VitaminXP.System.IECompatible)
{
result = VitaminXP.System.DetectActiveXControl('MediaPlayer.MediaPlayer.1');
}
break;
case "real":
result = VitaminXP.System.DetectPlugin('RealPlayer');
if(!result && VitaminXP.System.IECompatible)
{
result = (VitaminXP.System.DetectActiveXControl('rmocx.RealPlayer G2 Control') ||
VitaminXP.System.DetectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
VitaminXP.System.DetectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
}
break;
case "quicktime":
result = VitaminXP.System.DetectPlugin('QuickTime');
if(!result && VitaminXP.System.IECompatible)
{
try
{
var QTChecker = new ActiveXObject("QuickTimeCheckObject.QuickTimeCheck.1");
result = QTChecker.IsQuickTimeAvailable(0);
}
catch(ex)
{
result = false;
}
}
break;
case "flip":
result = VitaminXP.System.DetectPlugin('Flip4Mac WMV Web Plugin');
break;
case "flash":
result = VitaminXP.System.DetectPlugin('Shockwave','Flash');
if(!result && VitaminXP.System.IECompatible)
{
result = VitaminXP.System.DetectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
}
break;
case "director":
result = VitaminXP.System.DetectPlugin('Shockwave','Director');
if(!result && VitaminXP.System.IECompatible)
{
result = VitaminXP.System.DetectActiveXControl('SWCtl.SWCtl.1');
}
break;
case "html5":
try
{
var obj = new Audio();
_mp3_mime_types = ['audio/mpeg; codecs="mp3"','audio/mpeg','audio/mp3','audio/MPA','audio/mpa-robust'];
for(var i = 0; i < _mp3_mime_types.length; i++)
{
var answer = obj.canPlayType(_mp3_mime_types[i]);
if(answer != '' && 'probably maybe yes'.indexOf(answer) > -1)
{
result = true;
break;
}
}
}
catch(ex)
{
result = false;
}
break;
}
return result;
}
VitaminXP.System.DetectPlugin = function()
{
var pluginFound = false;
// allow for multiple checks in a single pass
var daPlugins = VitaminXP.System.DetectPlugin.arguments;
// consider pluginFound to be false until proven true
var pluginFound = false;
// if plugins array is there and not fake
if (navigator.plugins && navigator.plugins.length > 0)
{
var pluginsArrayLength = navigator.plugins.length;
// for each plugin...
for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ )
{
// loop through all desired names and check each against the current plugin name
var numFound = 0;
for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++)
{
// document.writeln((navigator.plugins[pluginsArrayCounter].name) + '
');
// document.writeln((navigator.plugins[pluginsArrayCounter].description) + '
');
// if desired plugin name is found in either plugin name or description
if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) )
{
// this name was found
numFound++;
}
}
// now that we have checked all the required names against this one plugin,
// if the number we found matches the total number provided then we were successful
if(numFound == daPlugins.length)
{
pluginFound = true;
// if we've found the plugin, we can stop looking through at the rest of the plugins
break;
}
}
}
return pluginFound;
}
VitaminXP.System.DetectActiveXControl = function(activeXControlName)
{
try
{
return (typeof new ActiveXObject(activeXControlName) == 'object');
}
catch(ex)
{
return false;
}
}
VitaminXP.System.DetectBrowser = function()
{
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) return 'Opera';
if (agt.indexOf("staroffice") != -1) return 'Star Office';
if (agt.indexOf("webtv") != -1) return 'WebTV';
if (agt.indexOf("beonex") != -1) return 'Beonex';
if (agt.indexOf("chimera") != -1) return 'Chimera';
if (agt.indexOf("netpositive") != -1) return 'NetPositive';
if (agt.indexOf("phoenix") != -1) return 'Phoenix';
if (agt.indexOf("firefox") != -1) return 'Firefox';
if (agt.indexOf("safari") != -1) return 'Safari';
if (agt.indexOf("skipstone") != -1) return 'SkipStone';
if (agt.indexOf("msie") != -1) return 'Internet Explorer';
if (agt.indexOf("netscape") != -1) return 'Netscape';
if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
if (agt.indexOf('\/') != -1) {
if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
return navigator.userAgent.substr(0,agt.indexOf('\/'));}
else return 'Netscape';} else if (agt.indexOf(' ') != -1)
return navigator.userAgent.substr(0,agt.indexOf(' '));
else return navigator.userAgent;
}
VitaminXP.System.DetectOperatingSystem = function()
{
var OSName="Unknown";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
if (navigator.appVersion.indexOf("iPhone")!=-1) OSName="iPhone";
if (navigator.appVersion.indexOf("iPad")!=-1) OSName="iPad";
if (navigator.appVersion.indexOf("iPod")!=-1) OSName="iPod";
return OSName;
}
VitaminXP.System.DetectOperatingSystemVersion = function()
{
var version="Unknown";
if (navigator.userAgent.toLowerCase().indexOf("win98")!=-1) version="98";
if (navigator.userAgent.toLowerCase().indexOf("windows 98")!=-1) version="2000";
if (navigator.userAgent.toLowerCase().indexOf("nt 5.0")!=-1) version="2000";
if (navigator.userAgent.toLowerCase().indexOf("nt 5.1")!=-1) version="XP";
if (navigator.userAgent.toLowerCase().indexOf("nt 6.0")!=-1) version="Vista";
if (navigator.userAgent.toLowerCase().indexOf("ppc")!=-1) version="Power PC";
if (navigator.userAgent.toLowerCase().indexOf("powerpc")!=-1) version="Power PC";
if (navigator.userAgent.toLowerCase().indexOf("68k")!=-1) version="68000";
return version;
}
VitaminXP.System.Browser = VitaminXP.System.DetectBrowser();
VitaminXP.System.OS = VitaminXP.System.DetectOperatingSystem();
VitaminXP.System.OSVersion = VitaminXP.System.DetectOperatingSystemVersion();
VitaminXP.System.IECompatible = document.all ? true : false;
VitaminXP.System.getFlashVersion = function()
{
var version = '0,0,0';
// ie
try
{
try
{
var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
try
{
axo.AllowScriptAccess = 'always';
}
catch(e)
{
version = '6,0,0';
}
}
catch(e)
{
// do nothing
}
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
}
catch(e)
{
// other browsers
try
{
if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
{
version = (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
}
}
catch(e)
{
// do nothing
}
}
return version.split(',').shift();
}
// JavaScript Document
VitaminXP.Namespace("VitaminXP.Array");
// This class extends Array class adding following functions to it
// Adds an element to array
// Optional Parameter [key] (ex: array[key] = value (if omited array.push(value) id used)
Array.prototype.Add = function(value)
{
var _args = Array.prototype.Add.arguments
var key = (_args.length > 1) ? _args[1] : null;
if(key == null)
{
this.push(value);
}
else
{
this["'" + key + "'"] = value;
}
}
// Removes all elements which values are same as passed as Value
// Optional Parameter [Limit] decides how many elements will be deleted. 0 = No limit
Array.prototype.Remove = function(value)
{
var _args = Array.prototype.Remove.arguments
var limit = (_args.length > 1) ? _args[1] : 0;
var count = 0;
for(i = 0; i < this.length; i++)
{
if(this[i] == value)
{
this.splice(i, 1)
i--;
count++;
if(count >= limit && limit != 0)
{
i = this.length;
}
}
}
}
Array.prototype.Max = function()
{
var max = undefined;
for(i = 0; i < this.length; i++)
{
if(this[i] > max || max == undefined) max = this[i];
}
return max;
}
Array.prototype.Min = function()
{
var min = undefined;
for(i = 0; i < this.length; i++)
{
if(this[i] < min || min == undefined) min = this[i];
}
return min;
}
Array.prototype.HasElement = function(el)
{
for(i = 0; i < this.length; i++) if(this[i] == el) return true;
return false;
}
// JavaScript Document
VitaminXP.Import("VitaminXP.Event");
VitaminXP.Namespace("VitaminXP.Element");
VitaminXP.Namespace("Element.Style");
VitaminXP.Namespace("VitaminXP.Select"); // This namespace is not to be used. Only to copy it's methods to every Select element on page load
VitaminXP.Namespace("VitaminXP.TextArea");
VitaminXP.Namespace("VitaminXP.Form");
VitaminXP.Element.property_cache = {}; // to cache case conversion for set/getStyle
VitaminXP.Element.patterns = { // cached for performance
noNegatives: /width|height|opacity|padding/i, // keep at zero or above
offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default
defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default
offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i, // IE may return these, so convert these to offset
simpleAttribute: /scrollTop|scrollLeft|/i // simple attribute (ex: element.scrollTop)
};
// improve performance by only looking up once
VitaminXP.Element.cacheConvertedProperties = function(property)
{
VitaminXP.Element.property_cache[property] = {
camel: VitaminXP.Element.toCamel(property),
hyphen: VitaminXP.Element.toHyphen(property)
};
};
// Converts style attribute from padding-left to paddingLeft
VitaminXP.Element.toCamel = function(property)
{
if(VitaminXP.Element.property_cache[property])
{
return VitaminXP.Element.property_cache[property]['camel'];
}
var convert = function(prop) {
var test = /(-[a-z])/i.exec(prop);
return prop.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase());
};
while(property.indexOf('-') > -1) {
property = convert(property);
}
// cache converted property names
VitaminXP.Element.property_cache[property] = {
camel: property,
hyphen: VitaminXP.Element.toHyphen(property)
};
return property;
//return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
};
// Converts style attribute from paddingLeft to padding-left
VitaminXP.Element.toHyphen = function(property)
{
if (property.indexOf('-') > -1) // assume hyphen
{
return property;
}
var converted = '';
for (var i = 0, len = property.length;i < len; ++i)
{
if (property.charAt(i) == property.charAt(i).toUpperCase())
{
converted = converted + '-' + property.charAt(i).toLowerCase();
}
else
{
converted = converted + property.charAt(i);
}
}
return converted;
//return property.replace(/([a-z])([A-Z]+)/g, function(m0, m1, m2) {return (m1 + '-' + m2.toLowerCase())});
};
if (document.defaultView && document.defaultView.getComputedStyle) // W3C DOM method
{
VitaminXP.Element.GetStyle = function(el, property)
{
el = VitaminXP.Element.Get(el);
var value = null;
if (property == 'float') // fix reserved word
{
property = 'cssFloat';
}
var computed = document.defaultView.getComputedStyle(el, '');
if (computed) // test computed before touching for safari
{
value = computed[VitaminXP.Element.toCamel(property)];
}
value = el.style[property] || value;
if(property == 'opacity') value = value * 100;
return value;
};
}
else if (document.documentElement.currentStyle && Browser == "Internet Explorer") // IE method
{
VitaminXP.Element.GetStyle = function(el, property)
{
el = VitaminXP.Element.Get(el);
switch( VitaminXP.Element.toCamel(property))
{
case 'opacity' :// IE opacity uses filter
var val = 100;
try
{ // will error if no DXImageTransform
val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
}
catch(e)
{
try
{ // make sure its in the document
val = el.filters('alpha').opacity;
}
catch(e)
{}
}
return parseInt(val);
case 'float': // fix reserved word
property = 'styleFloat'; // fall through
default:
// test currentStyle before touching
var value = el.currentStyle ? el.currentStyle[property] : null;
value = ( el.style[property] || value );
return value;
};
};
}
else // default to inline only
{
VitaminXP.Element.GetStyle = function(el, property)
{
el = VitaminXP.Element.Get(el);
var value = el.style[property];
if(property == 'opacity') value = value * 100;
return value;
};
}
VitaminXP.Element.GetAttribute = function(el, attr)
{
el = VitaminXP.Element.Get(el);
if(VitaminXP.Element.patterns.simpleAttribute.exec(attr) != '')
{
val = parseFloat(el[attr]);
if(val == NaN) val = 0;
return val;
}
var val = VitaminXP.Element.GetStyle(el, attr);
if(val !== 'auto' && !VitaminXP.Element.patterns.offsetUnit.test(val))
{
return parseFloat(val);
}
var a = VitaminXP.Element.patterns.offsetAttribute.exec(attr) || [];
var pos = !!( a[3] ); // top or left
var box = !!( a[2] ); // width or height
// use offsets for width/height and abs pos top/left
if( box || (VitaminXP.Element.GetStyle(el, 'position') == 'absolute' && pos))
{
val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
}
else
{ // default to zero for other 'auto'
val = 0;
}
return val;
}
// Sets any style to any element
VitaminXP.Element.SetStyle = function(el, property, val)
{
el = VitaminXP.Element.Get(el);
if(VitaminXP.Element.patterns.simpleAttribute.exec(property) != '')
{
el[property] = val;
}
var camel = VitaminXP.Element.toCamel(property);
try
{
switch(property)
{
case 'opacity' :
if (Browser == "Internet Explorer" && typeof el.style.filter == 'string') { // in case not appended
el.style.filter = 'alpha(opacity=' + val + ')';
if (!el.currentStyle || !el.currentStyle.hasLayout) {
el.style.zoom = 1; // when no layout or cant tell
}
} else {
el.style.opacity = val/100;
el.style['-moz-opacity'] = val/100;
el.style['-khtml-opacity'] = val/100;
}
break;
default :
if(VitaminXP.Element.patterns.defaultUnit.exec(camel) != null)
{
el.style[camel] = (typeof val == 'number') ? val+'px' : (val.indexOf('px') == -1 ? val+'px' : val);
}
else
{
el.style[camel] = val;
}
break;
}
}
catch(ex)
{
VitaminXP.Exception(ex, 'VitaminXP.Element.SetStyle');
}
}
VitaminXP.Element.Style.HasStyle = function(style_name)
{
style_name = VitaminXP.Element.toCamel(style_name);
for(style in this.style)
{
if(style.toString() == style_name) has = true;
return true;
}
return false;
}
// Returns a reference to an ellement passed. Either ID of element or reference to element can be passed
VitaminXP.Element.Get = function(el)
{
if (!el || el.tagName || el.item || (typeof el == 'object')) // null, HTMLElement, or HTMLCollection
{
return el;
}
if (typeof el == 'string') // HTMLElement or null
{
return document.getElementById(el);
}
if (el.splice) // Array of HTMLElements/IDs
{
var c = [];
for (var i = 0, len = el.length; i < len; ++i)
{
c[c.length] = VitaminXP.Element.Get(el[i]);
}
return c;
}
return el; // some other object, just pass it back
}
VitaminXP.Element.GetParent = function(el)
{
try
{
if(typeof el.parentElement == 'object')
{
return el.parentElement;
}
else
{
return el.parentNode;
}
}
catch(ex)
{
VitaminXP.Exception(ex, "VitaminXP.Element.GetParent");
}
return false;
}
VitaminXP.Element.GetChildren = function(el)
{
var children = new Array();
var _children = new Array();
if(el.childNodes)
{
children = el.childNodes
}
else if(el.children)
{
children = el.children;
}
if(typeof children.length == 'number')
{
for(child in children)
{
_children.Add(child);
}
}
else
{
_children = new Array(children);
}
return _children;
}
// Retruns Left position of the element on the page
VitaminXP.Element.offsetX = function(elm)
{
var mOffsetLeft = elm.offsetLeft;
var mOffsetParent = elm.offsetParent;
while(mOffsetParent){
mOffsetLeft += mOffsetParent.offsetLeft;
mOffsetParent = mOffsetParent.offsetParent;
}
return mOffsetLeft;
}
// Returns Top position of element on the page
VitaminXP.Element.offsetY = function(elm)
{
var mOffsetTop = elm.offsetTop;
var mOffsetParent = elm.offsetParent;
while (mOffsetParent)
{
mOffsetTop += mOffsetParent.offsetTop;
mOffsetParent = mOffsetParent.offsetParent;
}
return mOffsetTop;
}
VitaminXP.Element.AddEvent = function(obj, eventType, func, useEventCapture)
{
VitaminXP.Event.AddHandler(obj, eventType, func, useEventCapture);
}
VitaminXP.Element.RemoveEvent = function(obj, eventType, func, useEventCapture)
{
VitaminXP.Event.RemoveHandler(obj, eventType, func, useEventCapture);
}
VitaminXP.Element.GetScreenX = function(e)
{
return VitaminXP.Event.ScreenX(e);
}
VitaminXP.Element.GetScreenY = function(e)
{
return VitaminXP.Event.ScreenY(e);
}
VitaminXP.Element.GetScrollDeltaFromEvent = function(e)
{
return VitaminXP.Event.ScrollDelta(e);
}
VitaminXP.Element.BlockEvent = function(e)
{
VitaminXP.Event.Block(e);
}
// Returns a random string valid to be an ID of element
VitaminXP.Element.RandomID = function()
{
var ID = Math.random();
ID = "ID" + ID;
ID.replace(".", "");
return ID;
}
// Returns a length of properties of object. (does not count methods, only properties)
Object.prototype.properties = function()
{
var count = 0;
for(attr in this)
{
if(typeof(this[attr]) != "function")
{
count++;
}
}
return count;
}
// Adds an Ooption to the end of Select element
VitaminXP.Select.AddElement = function(text, value)
{
var _args = this.AddElement.arguments;
var opt = new Option(text, value);
(Browser == "Internet Explorer")? this.add(opt) : this.add(opt, null);
// only IE version works everywhere, but I think it would be faster in big loops
if(_args.length > 2) (Browser == "Internet Explorer")? this.options[this.options.length - 1].selected = _args[2] : opt.selected = _args[2];
}
// Removes all Option elements from Select element
VitaminXP.Select.ClearElements = function(el)
{
while(el.length > 0)
{
el.remove(0);
}
}
// Returns an array of elements found by [element_name] in a form (frm)
VitaminXP.Form.GetElements = function(frm, element_name)
{
var _els = frm.elements[element_name];
// Fix Browsers problem
if(typeof(_els) == undefined) // if no elements
{
return new Array();
}
else if(_els.length == undefined) // if one element
{
return new Array(_els);
}
else
{
var _arr = new Array();
for(i = 0; i < _els.length; i++)
{
_arr.push(_els[i]);
}
return _arr;
}
}
//Returns an array of only checked elements found by [element_name] in [form]
VitaminXP.Form.GetCheckedElements = function(frm, element_name)
{
var _els = VitaminXP.Form.GetElements(frm, element_name);
for(i = 0; i < _els.length; i++)
{
if(!_els[i].checked)
{
_els.splice(i, 1);
i--;
}
}
return _els;
}
// Returns a string array of IDs of check boxes or radio boxes that have name [element_name]
VitaminXP.Form.GetCheckedElementIDs = function(element_name)
{
var _ids = new Array();
var _els = this.GetCheckedElements(element_name);
for(i = 0; i < _els.length; i++)
{
_ids.push(_els[i].id);
}
return _ids;
}
// Finds and checks all checkboxes that have same name as passed
VitaminXP.Form.SelectAll = function(element_name, bool)
{
var _els = this.GetElements(element_name);
for(i = 0; i < _els.length; i++)
{
_els[i].checked = bool;
}
return _els;
}
// Finds radio boxed that have same name as passe, and returns a value of the one that is checked.
// If no boxes are checked, [undefined] is returned.
VitaminXP.Form.GetRadioValue = function(frm, element_name)
{
for(var i = 0; i < frm.elements[element_name].length; i++)
{
if(frm.elements[element_name][i].checked)
{
return frm.elements[element_name][i].value;
}
}
return undefined;
}
// Finds all radio input boxes that have passed name, and checks the one that has same value as passed
VitaminXP.Form.SetRadioValue = function(frm, element_name, value)
{
var _els = VitaminXP.Form.GetElements(frm, element_name);
for(i = 0; i < _els.length; i++)
{
if(_els[i].value == value)
{
_els[i].checked = true;
return true
}
}
return false
}
// If vertical scroll is more than 0 zero, it will make the textarea taller untill vertical scroll is 0 zero
VitaminXP.TextArea.ExpendHeight = function(el)
{
var _args = VitaminXP.TextArea.ExpendHeight.arguments
var max_height = (_args.length > 1)? parseFloat(_args[1]) : 0
if(el.scrollHeight > el.offsetHeight)
{
if(max_height == 0 || el.offsetHeight < max_height)
{
el.rows = parseInt(el.rows) + 1;
VitaminXP.TextArea.ExpendHeight(el, max_height);
}
}
}
// If horisontal scroll is more than 0 zero, it will make the textarea wider untill horisontal scroll is 0 zero
VitaminXP.TextArea.ExpendWidth = function(el)
{
var _args = VitaminXP.TextArea.ExpendHeight.arguments
var max_width = (_args.length > 1)? parseFloat(_args[1]) : 0
if(el.scrollWidth > el.offsetWidth)
{
if(max_width == 0 || el.offsetWidth < max_width)
{
el.cols = parseInt(el.cols) + 1;
VitaminXP.TextArea.ExpendWidth(el, max_width);
}
}
}
VitaminXP.Element.SizeTo = function(el, width, height)
{
el.style.width = width + 'px';
el.style.height = height + 'px';
}
VitaminXP.Element.MoveTo = function(el, x, y)
{
el.style.left = x + 'px';
el.style.top = y + 'px';
el.style.position = 'absolute';
}
VitaminXP.Element.Hide = function(el)
{
el.style.display = 'none';
}
VitaminXP.Element.Show = function(el)
{
el.style.display = '';
}
VitaminXP.Element.All = function()
{
return (Browser == "Internet Explorer") ? document.all : document.getElementsByTagName('*');
}
//===================================================
//===== Do not put any code below this line =========
//===================================================
// Loops through passed namespace and copies methods and properties to every passed element type found on page
VitaminXP.Element.ApplyPrototypesToElements = function(Namespace, TagName)
{
var _els = document.getElementsByTagName(TagName)
for(i = 0; i < _els.length; i++)
{
for(method in Namespace)
{
if(!_els[i][method])
{
_els[i][method] = Namespace[method];
}
}
}
}
// Create NameSpaces
VitaminXP.Namespace("VitaminXP.Animation");
VitaminXP.Animation.FramesPerSecond = 200;
VitaminXP.Animation.FrameLength = 1000 / VitaminXP.Animation.FramesPerSecond; // In miliseconds
VitaminXP.Animation.Timer = null; // Container of the timer
VitaminXP.Animation._animations = new Array();
// Adds an instanse of new animation to an array of currently running animations
VitaminXP.Animation.RegisterAnimation = function(animation)
{
// If [animation] instance is working on same element as currently running instances and works on same attributes,
// the attributes has to be deleted from currently running instances so only last added instance works on one instance for that element
// Loop through every instance that is registered
for(i = 0; i < VitaminXP.Animation._animations.length; i++)
{
// Check if that instance is using same element as the new instance that is currently registering
if(VitaminXP.Animation._animations[i].element == animation.element)
{
// Loop through every attribute in a new instance that is about to be registered
for(new_attribute in animation._attributes)
{
// Remove matching attribute so only new instance would have those attributes
if(VitaminXP.Animation._animations[i]._attributes.hasOwnProperty(new_attribute))
{
delete VitaminXP.Animation._animations[i]._attributes[new_attribute];
}
}
// If the instance doesn't have any more atributes, then remove it
if(VitaminXP.Animation._animations[i]._attributes.properties() == 0)
{
VitaminXP.Animation.UnregisterAnimation(VitaminXP.Animation._animations[i]);
delete VitaminXP.Animation._animations[i];
}
}
}
VitaminXP.Animation._animations.push(animation);
if(VitaminXP.Animation._animations.length == 1) VitaminXP.Animation.Timer = setInterval(VitaminXP.Animation.AnimateFrame, VitaminXP.Animation.FrameLength);
}
// Removes passed instance of animation from an array of running animations
VitaminXP.Animation.UnregisterAnimation = function(animation)
{
VitaminXP.Animation._animations.Remove(animation);
if(VitaminXP.Animation._animations.length == 0)
{
clearInterval(VitaminXP.Animation.Timer);
}
}
// Loops through list of running animations and executes one frame for each animation
VitaminXP.Animation.AnimateFrame = function()
{
for(i = 0; i < VitaminXP.Animation._animations.length; i++)
{
try
{
VitaminXP.Animation._animations[i].ExecuteFrame();
}
catch(ex)
{
VitaminXP.Exception(ex, "VitaminXP.Animation.AnimateFrame");
}
}
}
// Creates a new instance of Animation, starts it, and then returns it
VitaminXP.Animation.Animate = function(element, _attributes, seconds, method)
{
try
{
if(element && _attributes && seconds > 0 && method != "")
{
var NewAnimation = new VitaminXP.Animation.InitializeAnimation(element, _attributes, seconds, method);
NewAnimation.Start();
return NewAnimation;
}
}
catch(ex)
{
VitaminXP.Exception(ex, "VitaminXP.Animation.Animate");
}
}
// Creates a new instance of Animation and returns it
VitaminXP.Animation.InitializeAnimation = function(element, _attributes, seconds, method)
{
this.element = VitaminXP.Element.Get(element)
this._attributes = _attributes || {};
this.seconds = seconds;
this.method = VitaminXP.Animation.Method(method);
this.current_frame = 0;
this.total_frames = Math.ceil(this.seconds / (1 / VitaminXP.Animation.FramesPerSecond));
this._value = new Array(this.total_frames);
this.start_time = new Date();
this.last_frame_execution_time = new Date();
// Set values for each attribute for each frame
for(attribute in this._attributes)
{
if(attribute != 'properties') // because object has properties that is not needed in this case
{
if(this._attributes[attribute].from == null)
{
this._attributes[attribute].from = parseFloat(VitaminXP.Element.GetAttribute(this.element, attribute));
}
for(this.current_frame = 1; this.current_frame <= this.total_frames; this.current_frame++)
{
if(!this._value[this.current_frame]) this._value[this.current_frame] = new Array(this._attributes.length)
this._value[this.current_frame][attribute] = Math.round(this.method(this.current_frame, this._attributes[attribute].from, this._attributes[attribute].to - this._attributes[attribute].from, this.total_frames));
}
this._attributes[attribute]['unit'] = VitaminXP.Animation.GetUnitByAttribute(attribute);
}
}
// Reset Frame Number
this.current_frame = 0;
// This function sets the value to the property
this.ExecuteFrame = function()
{
try
{
// Figure out what frame should be executed next
var next_frame = parseInt(((this.last_frame_execution_time.valueOf() - this.start_time.valueOf()) / VitaminXP.Animation.FrameLength) + 1);
if(next_frame > this.total_frames)
{
// If last frame was going to be droped, then just execute last frame
this.current_frame = this.total_frames;
}
else if(next_frame > this.current_frame + 1)
{
// Drop Frames (skip frames)
this.current_frame = next_frame;
}
else
{
// Next frame
this.current_frame++;
}
// Loop through each attribute and...
for(attribute in this._attributes)
{
if(attribute != 'properties') // because object has properties that is not needed in this case
{
if(this._value[this.current_frame] != undefined)
{
// check if element is an instance of VitaminXP.Forms.Control
if((attribute == 'top' || attribute == 'left') && typeof this.element.MoveTo == 'function' && typeof this.element.location == 'object')
{
switch(attribute)
{
case 'left':
this.element.MoveTo(this._value[this.current_frame][attribute], this.element.location.y);
break;
case 'top':
this.element.MoveTo(this.element.location.x, this._value[this.current_frame][attribute]);
break;
}
}
else
{
// ... set style of elemnt
VitaminXP.Element.SetStyle(this.element, attribute, this._value[this.current_frame][attribute] + this._attributes[attribute]['unit']);
}
}
}
}
// Detect end of animation
if(this.current_frame >= this.total_frames)
{
this.Stop();
this.Dispose();
}
// Log last execution time
this.last_frame_execution_time = new Date();
}
catch(ex)
{
VitaminXP.Exception(ex, 'VitaminXP.Animation.Animate.ExecuteFrame');
}
}
// Starts animation
this.Start = function()
{
VitaminXP.Animation.RegisterAnimation(this);
this.start_time = new Date();
}
// Stops animation, but does not dispose it, so it can be started again to continue
this.Stop = function()
{
VitaminXP.Animation.UnregisterAnimation(this);
}
this.Dispose = function()
{
this.Stop();
//delete this;
}
return this;
}
VitaminXP.Animation.Method = function(method)
{
switch(method)
{
case "EaseNone":
return function (t, b, c, d) {
return c*t/d + b;
}
break;
case "EaseIn":
return function(c, s, e, t)
{
return e*(c/=t)*c + s;
}
break;
case "EaseOut":
return function(c, s, e, t)
{
return -e *(c/=t)*(c-2) + s;
}
break;
case "EaseBoth":
return function(c, s, e, t)
{
if ((c/=t/2) < 1) {
return e/2*c*c + s;
}
return -e/2 * ((--c)*(c-2) - 1) + s;
}
break;
case "EaseInStrong":
return function(c, s, e, t)
{
return e*(c/=t)*c*c*c + s;
}
break;
case "EaseOutStrong":
return function(c, s, e, t)
{
return -e * ((c=c/t-1)*c*c*c - 1) + s;
}
break;
case "EaseBothStrong":
return function(c, s, e, t)
{
if ((c/=t/2) < 1) return e/2*c*c*c*c + s;
return -e/2 * ((c-=2)*c*c*c - 2) + s;
}
break;
case "BackIn":
return function (t, b, c, d, s) {
if (typeof s == 'undefined') {
s = 1.70158;
}
return c*(t/=d)*t*((s+1)*t - s) + b;
}
break;
case "BackOut":
return function(c, s, e, t, o)
{
if (typeof o == 'undefined') o = 1.70158;
return e*((c=c/t-1)*c*((o+1)*c + o) + 1) + s;
}
break;
case "BackBoth":
return function(c, s, e, t, o)
{
if (typeof o == 'undefined') o = 1.70158;
if ((c/=t/2) < 1) return e/2*(c*c*(((o*=(1.525))+1)*c - o)) + s;
return e/2*((c-=2)*c*(((o*=(1.525))+1)*c + o) + 2) + s;
}
break;
case "BounceOut":
return function(c, s, e, t)
{
if ((c/=t) < (1/2.75)) {
return e*(7.5625*c*c) + s;
} else if (c < (2/2.75)) {
return e*(7.5625*(c-=(1.5/2.75))*c + .75) + s;
} else if (c < (2.5/2.75)) {
return e*(7.5625*(c-=(2.25/2.75))*c + .9375) + s;
} else {
return e*(7.5625*(c-=(2.625/2.75))*c + .984375) + s;
}
}
break;
case "BounceIn":
return function(c, s, e, t)
{
c = t-c;
s = 0;
if ((c/=t) < (1/2.75)) {
return e - (e*(7.5625*c*c) + s) + s;
} else if (c < (2/2.75)) {
return e - (e*(7.5625*(c-=(1.5/2.75))*c + .75) + s) + s;
} else if (c < (2.5/2.75)) {
return e - (e*(7.5625*(c-=(2.25/2.75))*c + .9375) + s) + s;
} else {
return e - (e*(7.5625*(c-=(2.625/2.75))*c + .984375) + s) + s;
}
}
break;
case "ElasticIn":
return function (t, b, c, d, a, p) {
if (t == 0) {
return b;
}
if ( (t /= d) == 1 ) {
return b+c;
}
if (!p) {
p=d*.3;
}
if (!a || a < Math.abs(c)) {
a = c;
var s = p/4;
}
else {
var s = p/(2*Math.PI) * Math.asin (c/a);
}
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
}
break;
case "ElasticOut":
return function (t, b, c, d, a, p) {
if (t == 0) {
return b;
}
if ( (t /= d) == 1 ) {
return b+c;
}
if (!p) {
p=d*.3;
}
if (!a || a < Math.abs(c)) {
a = c;
var s = p / 4;
}
else {
var s = p/(2*Math.PI) * Math.asin (c/a);
}
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
}
break;
default:
// This is same as EaseIn
return function(c, s, e, t)
{
return e*(c/=t)*c + s;
}
break;
}
}
VitaminXP.Animation.GetUnitByAttribute = function(attribute)
{
attribute = VitaminXP.Element.toHyphen(attribute);
switch(attribute)
{
case "opacity":
return "";
break;
case "scroll-top":
return "";
break;
case "scroll-left":
return "";
break;
default:
return "px";
break;
}
}