/** * Copyright (c)2005-2007 Matt Kruse (javascripttoolbox.com) * * Dual licensed under the MIT and GPL licenses. * This basically means you can use this code however you want for * free, but don't claim to have written it yourself! * Donations always accepted: http://www.JavascriptToolbox.com/donate/ * * Please do not link to the .js files on javascripttoolbox.com from * your site. Copy the files locally to your server instead. * */ /* ******************************************************************* */ /* UTIL FUNCTIONS */ /* ******************************************************************* */ var Util = {'$VERSION':1.06}; // Util functions - these are GLOBAL so they // look like built-in functions. // Determine if an object is an array function isArray(o) { return (o!=null && typeof(o)=="object" && typeof(o.length)=="number" && (o.length==0 || defined(o[0]))); }; // Determine if an object is an Object function isObject(o) { return (o!=null && typeof(o)=="object" && defined(o.constructor) && o.constructor==Object && !defined(o.nodeName)); }; // Determine if a reference is defined function defined(o) { return (typeof(o)!="undefined"); }; // Iterate over an array, object, or list of items and run code against each item // Similar functionality to Perl's map() function function map(func) { var i,j,o; var results = []; if (typeof(func)=="string") { func = new Function('$_',func); } for (i=1; i>>=4; } while(hex.length<6) { hex='0'+hex; } return "#" + hex; }; // Convert hyphen style names like border-width to camel case like borderWidth css.hyphen2camel = function(property) { if (!defined(property) || property==null) { return null; } if (property.indexOf("-")<0) { return property; } var str = ""; var c = null; var l = property.length; for (var i=0; i0) { return bodies[0]; } } return null; }; // Get the amount that the main document has scrolled from top // -------------------------------------------------------------------- screen.getScrollTop = function() { if (document.documentElement && defined(document.documentElement.scrollTop) && document.documentElement.scrollTop>0) { return document.documentElement.scrollTop; } if (document.body && defined(document.body.scrollTop)) { return document.body.scrollTop; } return null; }; // Get the amount that the main document has scrolled from left // -------------------------------------------------------------------- screen.getScrollLeft = function() { if (document.documentElement && defined(document.documentElement.scrollLeft) && document.documentElement.scrollLeft>0) { return document.documentElement.scrollLeft; } if (document.body && defined(document.body.scrollLeft)) { return document.body.scrollLeft; } return null; }; // Util function to default a bad number to 0 // -------------------------------------------------------------------- screen.zero = function(n) { return (!defined(n) || isNaN(n))?0:n; }; // Get the width of the entire document // -------------------------------------------------------------------- screen.getDocumentWidth = function() { var width = 0; var body = screen.getBody(); if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { var rightMargin = parseInt(CSS.get(body,'marginRight'),10) || 0; var leftMargin = parseInt(CSS.get(body,'marginLeft'), 10) || 0; width = Math.max(body.offsetWidth + leftMargin + rightMargin, document.documentElement.clientWidth); } else { width = Math.max(body.clientWidth, body.scrollWidth); } if (isNaN(width) || width==0) { width = screen.zero(self.innerWidth); } return width; }; // Get the height of the entire document // -------------------------------------------------------------------- screen.getDocumentHeight = function() { var body = screen.getBody(); var innerHeight = (defined(self.innerHeight)&&!isNaN(self.innerHeight))?self.innerHeight:0; if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { var topMargin = parseInt(CSS.get(body,'marginTop'),10) || 0; var bottomMargin = parseInt(CSS.get(body,'marginBottom'), 10) || 0; return Math.max(body.offsetHeight + topMargin + bottomMargin, document.documentElement.clientHeight, document.documentElement.scrollHeight, screen.zero(self.innerHeight)); } return Math.max(body.scrollHeight, body.clientHeight, screen.zero(self.innerHeight)); }; // Get the width of the viewport (viewable area) in the browser window // -------------------------------------------------------------------- screen.getViewportWidth = function() { if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { return document.documentElement.clientWidth; } else if (document.compatMode && document.body) { return document.body.clientWidth; } return screen.zero(self.innerWidth); }; // Get the height of the viewport (viewable area) in the browser window // -------------------------------------------------------------------- screen.getViewportHeight = function() { if (!window.opera && document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) { return document.documentElement.clientHeight; } else if (document.compatMode && !window.opera && document.body) { return document.body.clientHeight; } return screen.zero(self.innerHeight); }; return screen; })();var Sort = (function(){ var sort = {}; sort.AlphaNumeric = function(a,b) { if (a==b) { return 0; } if (a