/* Library: Gainsborough - web client framework Component: common functions Hextra Digital http://www.hextra-digital.com */ // Cross-browser implementation of element.addEventListener() function addListener( element, type, expression, bubbling ){ bubbling = bubbling || false; if( element.addEventListener ) { // Standard element.addEventListener( type, expression, bubbling ); return true; } else if( element.attachEvent ) { // IE element.attachEvent( 'on' + type, expression ); return true; } return false; } function hx_image_preloader( _img_src, _callback, _notify ) { this.source = _img_src; this.notify = ''; this.notifyID = _notify; this.callback = _callback; this.notify = ge( this.notifyID ); re( this.notify, '= 0 ){ var p1 = str.slice( 0, pos ); var p2 = str.slice( pos + 2, str.length ); str = p1 + sprintf.arguments[ count ] + p2; count++; } return str; } function capitalize( _string ) { if( _string.length == 0 ) return ''; return _string.slice( 0, 1 ).toUpperCase() + _string.slice( 1, _string.length ); } /* var trunc = p.innerHTML; if (trunc.length> len) { // Truncate the content of the P, then go back to the end of the // previous word to ensure that we don't truncate in the middle of // a word trunc = trunc.substring(0, len); trunc = trunc.replace(/\w+$/, ''); // Add an ellipses to the end and make it a link that expands // the paragraph back to its original size trunc += '' + '...<\/a>'; p.innerHTML = trunc; } } */ function gt( _el ) { if( document.all ) return _el.innerText; else return _el.textContent; } function st( _el, _v ) { if( document.all ) _el.innerText = _v; else _el.textContent = _v; } function gp( _e ) { var l = 0; var t = 0; while( _e.offsetParent ){ l += _e.offsetLeft; t += _e.offsetTop; /*var ml = parseInt( _e.style.marginLeft, 10 ); var mt = parseInt( _e.style.marginTop, 10 ); if( !isNaN( ml ) ) l -= ml; if( !isNaN( mt ) ) t -= mt;*/ _e = _e.offsetParent; } l += _e.offsetLeft; t += _e.offsetTop; return { x: l, y: t }; } /* chn ( _o, _n, _m ) Chain( object, name, method ) */ function chn( _object, _methodName, _newMethod ) { var previous_handler = _object[ _methodName ]; if( typeof _object[ _methodName ] != 'function') _object[ _methodName ] = _newMethod; else _object[ _methodName ] = function( _args ) { previous_handler( _args ); _newMethod( _args ); } } function isset( _var ) { return( typeof( _var ) != 'undefined' && _var != null ); } function insertScript( _script ) { var headID = document.getElementsByTagName( 'head' )[ 0 ]; var newScript = document.createElement( 'script' ); newScript.type = 'text/javascript'; newScript.src = _script; headID.appendChild( newScript ); } Array.prototype.clear = function() { this.length = 0; }