// This file was dynamicaly created for https://vitaminxp.com/ // 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()"); // VitaminXP Javascript Framework // Module: Ajax // Copyright: www.VitaminXP.com // Author: Dmitriy Kulikovskiy // Create NameSpaces VitaminXP.Namespace("Ajax"); // Create a Blank request instence which will be used everytime the request is made VitaminXP.Ajax.Request = function(obj, url){ this.Document = null; this.TargetObject = obj; this.SuccessAction = "html"; this.Method = "GET"; this.URL = url; this.Parameters = ""; this.ExecuteFunction = ""; this.Asynchronous = true; this.MicrosoftProgramIDs = ""; this.States = new Array("uninitialized","loading","loaded","interacting","complete") this.MicrosoftProgramIDs = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]; }; // Requests a URL and passes the request to aother function to handle the state change event VitaminXP.Ajax.RequestUrl = function(obj,url){ // Object,URL,Parameters,Method,Action,Function Name // Create a copy of blank request var Request = new VitaminXP.Ajax.Request(obj, url); // Optinal arguments var args = VitaminXP.Ajax.RequestUrl.arguments; if(args.length > 2) Request.Parameters = args[2]; if(args.length > 3) Request.Method = args[3].toUpperCase() if(args.length > 4) Request.SuccessAction = args[4].toLowerCase() if(args.length > 5) Request.ExecuteFunction = args[5]; // Try to create an HTTP Request object try { if (window.XMLHttpRequest) // Mozilla, Safari,... Request.Document = new XMLHttpRequest(); else if (window.ActiveXObject) // IE { while (!Request.Document && Request.MicrosoftProgramIDs.length) { try { Request.Document = new ActiveXObject(Request.MicrosoftProgramIDs[0]); } catch (e) { Request.Document = null; } if (!Request.Document) Request.MicrosoftProgramIDs.splice(0, 1); } } } catch (e) { Request.Document = null; } if(!Request.Document) return false; // Initialize request Request.Document.onreadystatechange = function(){VitaminXP.Ajax.ProcessStateChange(Request)}; Request.Document.open(Request.Method, Request.URL, Request.Asynchronous); Request.Document.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); Request.Document.setRequestHeader("Content-length", Request.Parameters.length); Request.Document.setRequestHeader("Connection", "close"); Request.Document.send(Request.Parameters); return true; }; // Handles state change event of the request passed to this function VitaminXP.Ajax.ProcessStateChange = function(Request){ window.status = 'Ajax: ' + Request.States[Request.Document.readyState]; if(Request.Document.readyState == 4){ // Complete if(Request.Document.status == 200 || Request.Document.status == 0){ // OK response if(Request.SuccessAction == "html") { Request.TargetObject.innerHTML = Request.Document.responseText; } else if(Request.SuccessAction == "text") { Request.TargetObject.innerText = Request.Document.responseText; } else if(Request.SuccessAction == "function") { eval(Request.ExecuteFunction)(Request.Document.responseText, Request.TargetObject) } else if(Request.SuccessAction == "value") { Request.TargetObject.value = Request.Document.responseText } else if(Request.SuccessAction == "link") { if(Request.Document.responseText.toUpperCase() == "OK") { window.location = Request.ExecuteFunction } else { alert(Request.Document.responseText) } } else if(Request.SuccessAction.toLowerCase() == "ok") { if(Request.Document.responseText.toUpperCase() == "OK") { if(Request.ExecuteFunction != "") { eval(Request.ExecuteFunction)(Request.TargetObject) } } else { alert(Request.Document.responseText) } } Request = null } else { window.status = 'Ajax: problem ' + Request.Document.statusText + ', status: ' + Request.Document.status } } }; // 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; } } // 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.Namespace("VitaminXP.Cookie"); VitaminXP.Cookie.Get = function(name) { var _cookies = document.cookie.split(";"); for(var i = 0; i < _cookies.length; i++) { if(_cookies[i].substring(0, 1) == " ") _cookies[i] = _cookies[i].substring(1); if(_cookies[i].substring(0, name.length + 1) == name + "=") return unescape(_cookies[i].substring(name.length + 1)); } return undefined; } VitaminXP.Cookie.Set = function(name, value) { try { var _args = VitaminXP.Cookie.Set.arguments; var daysToExpire = (_args.length > 2) ? _args[2] : 365; var path = (_args.length > 3) ? _args[3] : "/"; var domain = (_args.length > 4) ? _args[4] : null; var secure = (_args.length > 5) ? _args[5] : false; var date = new Date(); date.setTime(date.getTime() + (daysToExpire * 24 * 60 * 60 * 1000)); var cookie = name + "=" + escape(value) + ";expires=" + date.toString() + "; path=" + path + ";"; if(domain != null) cookie += " domain=" + domain + ";"; if(secure) cookie += " secure=" + secure + ";"; document.cookie = cookie; } catch(err){ return false;} return true; } // JavaScript Document VitaminXP.Namespace("VitaminXP.DateTime"); VitaminXP.DateTime.GetTimezoneOffset = function() { var tz = getStandardTimezoneOffset() / 60; var sign = (tz < 0) ? '-' : '+'; var tz = Math.abs(tz); var hours = parseInt(tz); var minutes = tz - hours; if(hours < 10) hours = '0' + hours; if(minutes < 10) minutes = '0' + minutes; return sign + hours + ':' + minutes; } // converts integer seconds to string time (0:0:12:59) - days, hours, minutes,seconds VitaminXP.DateTime.SecondsToTime = function(seconds) { var sign = (seconds >= 0) ? '' : '-'; seconds = Math.abs(seconds); var minutes = Math.floor(seconds / 60); seconds = seconds % 60; var hours = Math.floor(minutes / 60); minutes = minutes % 60; var days = Math.floor(hours / 24); hours = hours % 24; // generate time string if(seconds < 10) seconds = "0" + seconds; minutes = (hours > 0 && minutes < 10) ? "0" + minutes + ":" : minutes + ":"; hours = (hours > 0) ? ((days > 0 && hours < 10) ? "0" + hours + ":" : hours + ":") : ""; days = (days > 0) ? days + ":" : ""; return days + hours + minutes + seconds; } // JavaScript Document VitaminXP.Namespace("VitaminXP.Directory"); VitaminXP.Directory.Domain = function(){return document.domain;} // Create NameSpaces VitaminXP.Namespace("VitaminXP.Effect"); VitaminXP.Effect.Fade = function(obj, from, to, seconds){ this.element = obj this.from = from this.to = to this.current = from this.seconds = seconds this.step = Math.abs(from - to) / (seconds / (1 / VitaminXP.Timeline.FramesPerSecond)) // Methods VitaminXP.Timeline.AddScene(this); VitaminXP.Effect.SetOpacity(this.element, this.current); if(document.getElementById(this.element).style.display == 'none') document.getElementById(this.element).style.display = ''; this.ExecuteFrame = function(){ if(this.current != to && document.getElementById(this.element).style.display != 'none'){ this.current += (to > from)? this.step : this.step * -1; if(this.current > 100) this.current = 100; if(this.current < 0) this.current = 0; VitaminXP.Effect.SetOpacity(this.element, this.current); }else{ this.Stop(); } } this.Stop = function(){ VitaminXP.Timeline.RemoveScene(this); } }; VitaminXP.Effect.FadeIn = function(obj, seconds){ return new VitaminXP.Effect.Fade(obj, 0, 100, seconds); }; VitaminXP.Effect.FadeOut = function(obj, seconds){ return new VitaminXP.Effect.Fade(obj, 100, 0, seconds); }; VitaminXP.Effect.Show = function(id){ if(document.getElementById(id).style.visibility.toLowerCase() == 'hidden') document.getElementById(id).style.visibility = 'visible'; document.getElementById(id).style.display = ''; }; VitaminXP.Effect.Hide = function(id){ document.getElementById(id).style.display = 'none'; }; VitaminXP.Effect.SetOpacity = function(obj, val){ this.element = document.getElementById(obj) if (Browser == "Internet Explorer" && typeof this.element.style.filter == 'string') { this.element.style.filter = 'alpha(opacity='+val+')' if (!this.element.currentStyle || !this.element.currentStyle.hasLayout) { obj.style.zoom = 1; // when no layout or cant tell } }else{ this.element.style.opacity = val/100; this.element.style['-moz-opacity'] = val/100; this.element.style['-khtml-opacity'] = val/100; } }; VitaminXP.Effect.GetOpacity = function(obj){ this.element = document.getElementById(obj); if(Browser == "Internet Explorer" && typeof this.element.style.filter == 'string'){ filter = this.element.style.filter filter = filter.replace("alpha(","") filter = filter.replace(")","") filters = str2arr(filter,",") opacity = filters['opacity'] opacity = (opacity == undefined)? 100 : opacity }else{ try{ opacity = this.element.style.MozOpacity * 100; }catch(ex){ try{ opacity = this.element.style.KhtmlOpacity * 100; }catch(ex){ try{ opacity = this.element.style.opacity * 100; }catch(ex){ opacity = 100 } } } } return Math.round(parseFloat(opacity)) }; // Change of property value from Slow to Fast (Slow->Fast) VitaminXP.Effect.EasyOut = function(obj, property, from, to, seconds) { this.element = document.getElementById(obj); this.property = property; this._value = new Array(); // Value for each frame this.value[i] = int this.percentage_completed = 0; this.seconds = seconds; this.frames = this.seconds / (1 / VitaminXP.Timeline.FramesPerSecond); this.frame = 0; this.from = from; this.to = to; this.average_acceleration = ((this.to - this.from) * 2) / Math.pow(this.frames, 2);; this.initial_acceleration = this.average_acceleration * 1; this.final_acceleration = 0; this.current_acceleration = 0; // Methods VitaminXP.Timeline.AddScene(this); // Calculate values for each frame for(i = 1; i <= this.frames; i++) { this.percentage_completed = (i / this.frames) * 100; this.current_acceleration = ((this.initial_acceleration - this.final_acceleration) / 100) * this.percentage_completed; this._value[i] = ((0.5 * this.current_acceleration) * Math.pow(i, 2)); // Displacement } // Execute Frame this.ExecuteFrame = function() { this.frame++; document.getElementById('cube2').style.left = this._value[this.frame] + 'px'; if(this.frame >= this.frames) { this.Stop(); } } this.Stop = function(){ VitaminXP.Timeline.RemoveScene(this); } } // Change of property value from Fast to Slow (Fast->Slow) VitaminXP.Effect.EasyIn = function(obj, property, from, to, seconds) { this.element = document.getElementById(obj); this.property = property; this._value = new Array(); // Value for each frame this.value[i] = int this.percentage_completed = 0; this.seconds = seconds; this.frames = this.seconds / (1 / VitaminXP.Timeline.FramesPerSecond); this.frame = 0; this.from = from; this.to = to; //this.average_acceleration = ((this.to - this.from) * 2) / Math.pow(this.frames, 2); //this.initial_acceleration = 0; //this.final_acceleration = this.average_acceleration * 1; this.current_acceleration = ((this.to - this.from) * 2) / Math.pow(this.frames, 2); // Methods VitaminXP.Timeline.AddScene(this); // Calculate values for each frame for(i = 1; i <= this.frames; i++) { //this.percentage_completed = (i / this.frames) * 100; //this.current_acceleration = ((this.initial_acceleration - this.final_acceleration) / 100) * this.percentage_completed; this._value[this.frames - i] = (this.to - this.from) - ((0.5 * this.current_acceleration) * Math.pow(i, 2)); // Displacement } // Execute Frame this.ExecuteFrame = function() { this.frame++; document.getElementById('cube2').style.left = this._value[this.frame] + 'px'; if(this.frame >= this.frames) { this.Stop(); } } this.Stop = function(){ VitaminXP.Timeline.RemoveScene(this); } } // 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]; } } } } // JavaScript Document // This class extends Math class adding following functions to it // Rounds a number to a specified number of decimal places // Optional parameter [Decimal Places] default is 1 Number.prototype.roundTo = function() { num = parseFloat(this) var _args = Number.prototype.roundTo.arguments var dec = (_args.length > 0)? Math.pow(10,parseInt(_args[0])) : 1 return Math.round(num*dec)/dec; } // returns boolean stating if number is valid integer Number.prototype.isInt = function() { return (this === parseInt(this)); } // returns boolean stating if number is valid decimal Number.prototype.isDecimal = function() { return (this !== parseInt(this) && this === parseFloat(this)); } // Converts number to an Integer Number.prototype.toInteger = function() { return parseInt(this); } Number.prototype.Add = function(number) { return this + parseFloat(number); } Number.prototype.Random = function() { return Math.floor(Math.random() * this); } Number.prototype.similarTo = function(number, offset) { var from = this - offset; var to = this + offset; return (from <= number && number <= to); } // JavaScript Document VitaminXP.Namespace("VitaminXP.String"); // Returns the Amount of occurences String.prototype.Find = function(string) { var position = 0; var results = 0; for(i = 0; i < this.length; i++) { position = this.indexOf(string, i); if(position >= 0) { results++; i = position + string.length - 1; }else{ i = this.length; } } return results; } // Returns true if string is in valid eMail format String.prototype.isValidEmail = function() { if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(this)){ return true }else{ return false } } String.prototype.EncodeURL = function() { url = this.replace(RegExp("\\\\","g"),"/"); return encodeURI(url); } // returns an array of strings that are seperated by passed seperator string String.prototype.toArray = function(seperator) { var _arr = new Array(); var _items = this.split(seperator) var temp; for(r = 0; r < _items.length; r++){ temp = _items[r].split("="); _arr[temp[0]] = temp[1]; } return _arr } // returns boolean stating if number is valid integer String.prototype.isInt = function() { return (this == parseInt(this)); } // returns boolean stating if number is valid decimal String.prototype.isDecimal = function() { return (this == parseFloat(this)); } // Converts number to an Integer String.prototype.toInteger = function() { return parseInt(this); } // Converts number to an Decimal String.prototype.toDecimal = function() { return parseFloat(this); } // Converts number to an number (Decimal) String.prototype.toNumber = function() { return parseFloat(this); } // Adds or replaces existing value for variable String.prototype.BuildQuery = function(name, value) { var url = (this.length > 0)? this : window.location.search; //if(url.substr(0,1) == "?") url = url.substr(1, url.length); var start = [url.indexOf("?" + name), url.indexOf("&" + name)].Max(); if(start > -1) { start += 1 + name.length var end = url.indexOf("&", start); url = url.substring(0, start) + "=" + escape(value) + ((end > -1)? url.substring(end, url.length) : ""); } else { url += ((url.length <= 1)? name + "=" + escape(value) : "&" + name + "=" + escape(value)); } return url; } String.prototype.Trim = function() { var _args = String.prototype.Trim.arguments; var _characters = (_args.length > 0) ? _args[0] : " "; var trim = { right:true, left:true }; var string = this; if(_args.length > 1) { switch(_args[1]) { case "right": trim.left = false; break; case "left": trim.right = false; break; } } if(typeof _characters == 'string') { _characters = new Array(_characters); } for(var i = 0; i < _characters.length; i++) { if(trim.left) { while(string.charAt(0) == _characters[i]) string = string.substring(1, string.length); } if(trim.right) { while(string.charAt(string.length - 1) == _characters[i]) string = string.substring(0, string.length - 1); } } return string; } String.prototype.RightTrim = function() { var _args = String.prototype.RightTrim.arguments; var _characters = (_args.length > 0) ? _args[0] : " "; return this.Trim(_characters, "right"); } String.prototype.LeftTrim = function() { var _args = String.prototype.LeftTrim.arguments; var _characters = (_args.length > 0) ? _args[0] : " "; return this.Trim(_characters, "left"); } String.prototype.replaceString = function(from, to) { var str = this.toString(); var p = str.indexOf(from); while(p >= 0) { str = str.replace(from, to); p = str.indexOf(from, p + to.length); } return str; } // 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(); }