
// абсолютные координаты элемента
function getATop (oNode, oPrn)       {var C=oNode;var T=0;while(C!=oPrn){T += C.offsetTop; C=C.offsetParent;}return T;}
function getALeft(oNode, oPrn)       {var C=oNode;var L=0;while(C!=oPrn){L += C.offsetLeft;C=C.offsetParent;}return L;}
function getAScrollTop (oNode, oPrn) {var C=oNode;var T=0;while(C!=oPrn){T += C.scrollTop; C=C.offsetParent;}return T;}
function getAScrollLeft(oNode, oPrn) {var C=oNode;var L=0;while(C!=oPrn){L += C.scrollLeft;C=C.offsetParent;}return L;}


// Преобразования
String.prototype.lpad=function(ch,length){var s=this; for (var i=this.length;i<length-this.length+1;i++) {s=ch+s;} return s;}
Number.prototype.lpad=function(ch,length){return this.toString().lpad(ch,length);}

//String.trim
String.prototype.trim = function() {return this.replace(/^\s+|\s+$/g,"");}
String.prototype.ltrim = function(){return this.replace(/^\s+/g,"");}
String.prototype.rtrim = function(){return this.replace(/\s+$/g,"");}

//copyToClipboard
function copyToClipboard(s)	{if( window.clipboardData && clipboardData.setData ){clipboardData.setData("Text", s);}
	else {netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');	  var clip = Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard);
	if (!clip) return; var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable);
	if (!trans) return; trans.addDataFlavor('text/unicode'); var str = new Object(); var len = new Object();var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString);
	var copytext=meintext;str.data=copytext;trans.setTransferData("text/unicode",str,copytext.length*[[[[2]]]]); var clipid=Components.interfaces.nsIClipboard;
	if (!clip) return false;clip.setData(trans,null,clipid.kGlobalClipboard);}}

	
//date
Date.prototype.dateFormat= function(f){var result="";for(var i=0;i<f.length;++i) {result+=this.dateToString(f.charAt(i));}return result;}
Date.prototype.dateToString= function(c){switch(c){case "F": switch (this.getMonth()+1) {case 1: return 'Января';case 2: return 'Февраля';
case 3: return 'Марта';case 4: return 'Апреля';case 5: return 'Мая';case 6: return 'Июня';case 7: return 'Июля';case 8: return 'Августа';
case 9: return 'Сентября';case 10: return 'Октября';case 11: return 'Ноября';case 12: return 'Декабря'; default:return '???';}   break; 
case "D":return (this.getDate()<10?"0":"")+this.getDate();case "M":return (this.getMonth()+1<10?"0":"")+ (this.getMonth()+1);case "Y":return this.getFullYear();
case "d":return this.getDate();case "m":return this.getMonth()+1;case "y":return String(this.getFullYear()).substr(-2);default:return c;}}	
Date.prototype.timeFormat= function(f){var result="";for(var i=0;i<f.length;++i) {result+=this.timeToString(f.charAt(i));}return result;}
Date.prototype.timeToString= function(c){switch(c){case "I":return (this.getMinutes()<10?"0":"")+this.getMinutes();case "G":return (this.getHours()<10?"0":"")+ this.getHours();case "S":return (this.getSeconds()<10?"0":"")+this.getSeconds();case "i":return this.getMinutes();case "g":return this.getHours()+1;case "s":return this.getSeconds();default:return c;}}
function zoned(dt,m){switch (m){case 1:document.write('<img src="/bitrix/templates/.default/images/icon_date_mini.gif" width="12" height="12" border="0" alt="Дата публикации сообщения" align="absmiddle"> ');break;}
 d=new Date(dt);switch ((Date.parse((new Date).toDateString())-Date.parse(d.toDateString()))/86400000) 
 {case -2: document.write('Послезавтра');	break;case -1: document.write('Завтра');break;case 0: document.write('Сегодня');break; case 1: document.write('Вчера');break;
 case 2: document.write('Позавчера');break; default: if (d.getFullYear()!=(new Date).getFullYear()) document.write(d.dateFormat('d F Y')+','); else document.write(d.dateFormat('d F')+',');break;}document.write(" "+d.timeFormat("G:I"));}
