1/**
2 *  $Id: helpers.js 130 2006-11-30 20:44:53Z wingedfox $
3 *  $HeadURL: https://svn.debugger.ru/repos/jslibs/BrowserExtensions/tags/BrowserExtensions.001/helpers.js $
4 *
5 *  File contains differrent helper functions
6 *
7 * @author Ilya Lebedev <ilya@lebedev.net>
8 * @license LGPL
9 * @version $Rev: 130 $
10 */
11function isUndefined(i){return(typeof i=='undefined');}function isFunction(i){return(typeof i=='function');}function isString(i){return(typeof i=='string');}function isNumber(i){return(typeof i=='number');}function isNumeric(i){return isNumber(i)&&!isNaN(i)&&isFinite(i);}function isArray(i){return(i instanceof Array);}function isRegExp(i){return(i instanceof RegExp);}function isBoolean(i){return('boolean'==typeof i);}function isScalar(i){return isNumeric(i)||isString(i);}function isEmpty(i){if(isBoolean(i))return false;if(isRegExp(i)&&new RegExp("").toString()==i.toString())return true;if(isString(i)||isNumber(i))return!i;if(Boolean(i)&&false!=i){for(var I in i)if(i.hasOwnProperty(I))return false}return true}function dump(i,I){var l=[];if(!I)I=0;if(I>2)return"***********8Recursion*************";var o="";for(var O=0;O<I;O++)o+="    ";for(var O in i){var Q=[o,O,': '];try{if(!isScalar(i[O])&&!isFunction(i[O])){Q[Q.length]='{';l[l.length]=Q.join("");l[l.length]=dump(i[O],I+1);l[l.length]='}'}else{Q[Q.length]=i[O];l[l.length]=Q.join("");}}catch(err){}}return l.join("\n");}function gluePath(){var i=arguments.length,I=i-2,l=arguments[i-1];for(;I>=0;I--)l=((!isString(arguments[I])&&!isNumber(arguments[I]))||isEmpty(arguments[I])?l:arguments[I]+'\x00'+l);return l?l.replace(/\/*\x00+\/*/g,"/"):""}function findPath(i){var I=document.getElementsByTagName('script'),l=new RegExp('^(.*/|)('+i+')([#?]|$)');for(var o=0,O=I.length;o<O;o++){var Q=String(I[o].src).match(l);if(Q){if(Q[1].match(/^((https?|file)\:\/{2,}|\w:[\\])/))return Q[1];if(Q[1].indexOf("/")==0)return Q[1];b=document.getElementsByTagName('base');if(b[0]&&b[0].href)return b[0].href+Q[1];return(document.location.pathname.match(/(.*[\/\\])/)[0]+Q[1]).replace(/^\/+(?=\w:)/,"");}}return null}function getParent(i,I,l){if(i==null)return null;else if(i.nodeType==1&&((!isUndefined(l)&&i[I]==l)||('string'==typeof I&&hasTagName(i,I))||i==I))return i;else return getParent(i.parentNode,I,l);}function hasTagName(i,I){if(isString(I))I=[I];if(!isArray(I)||isEmpty(I)||isUndefined(i)||isEmpty(i.tagName))return false;var l=i.tagName.toLowerCase();for(var o=0,O=I.length;o<O;o++){if(I[o].toLowerCase()==l)return true}return false}function table2array(i,I,l,o){if(isString(i))i=document.getElementById(i);if(!i||!hasTagName(i,['table','tbody,','thead','tfoot']))return null;if(!isEmpty(l)&&(!isString(l)||!(i=i.getElementsByTagName(l))))return null;if(!isEmpty(o)&&(!isNumber(o)||o<0||!(i=i[o])))return null;if(isUndefined(i.rows))return null;var O=[];for(var Q=0,_=i.rows.length;Q<_;Q++){var c=[];if(isArray(I)){for(var C=0,e=I.length;C<e;C++)if(i.rows[Q].cells[I[C]])c[c.length]=i.rows[Q].cells[I[C]].innerHTML.replace(/<[^>]*?>/g,"");}else{for(var v=0,V=i.rows[Q].cells.length;v<V;v++)c[c.length]=i.rows[Q].cells[v].innerHTML.replace(/<[^>]*?>/g,"");}if(!isEmpty(c))O[O.length]=c}return O}document.createElementExt=function(i,I){var l,o,O,Q=document.createElement(i);if(!Q)return null;for(o in I){if(!I.hasOwnProperty(o))continue;switch(o){case"class":Q.setAttribute('className',I[o]);Q.setAttribute('class',I[o]);break;case"style":for(O in I[o]){if(!I[o].hasOwnProperty(O))continue;Q.style[O]=I[o][O]}break;case"event":for(O in I[o]){if(!I[o].hasOwnProperty(O))continue;Q.attachEvent(O,I[o][O]);}break;case"child":l=I[o].length;for(O=0;O<l;O++)Q.appendChild(I[o][O]);break;case"param":for(O in I[o]){if(!I[o].hasOwnProperty(O))continue;try{Q[O]=I[o][O]}catch(e){}}break}}return Q};function playInterval(i,I,l){return setInterval(function(){(l instanceof Array)?i.apply(this,l):i.call(this,l)},I)}function playTimeout(i,I,l){return setTimeout(function(){(l instanceof Array)?i.apply(this,l):i.call(this,l)},I)}
12