function main(){
	var aeInput = document.getElementsByTagName( 'input' );
	for( var i = 0 ; i < aeInput.length ; i++ ){
		if( aeInput[i].getAttribute( 'placeholder' ) ){
			placeholder( aeInput[i], aeInput[i].getAttribute( 'placeholder' ), 'empty' );
		}
	}
}

function placeholder( eThis, sText, sClass_on_empty ){
	eThis.onfocus = function(){ if( eThis.value.length && eThis.value == sText ){ eThis.value = ''; } Common.Class.remove( this, sClass_on_empty ); eThis.select(); document.getElementsByTagName( 'body' )[0].className += ''; }
	eThis.onblur = function(){ if( !this.value.length ){ Common.Class.add( this, sClass_on_empty ); this.value = sText; document.getElementsByTagName( 'body' )[0].className += ''; } }
	if( !eThis.value.length ){ eThis.onblur(); }
	if( !eThis.getAttribute( 'placeholder' ) ){ eThis.setAttribute( 'placeholder', sText ); }
}


Common.Object.extend(
	Common.Dom,
	{
		setOpacity : function(oElement, iValue) {
			oElement.style.opacity = iValue;
			oElement.style.filter = 'alpha(opacity=' + Math.round(iValue * 100) + ')';
		}
	}
);


Common.Object.extend(
	Number.prototype,
	{
		between : function(iStart, iEnd, bNoInclude) {
			var iVal = this.valueOf();
			if(bNoInclude)
				return ( iVal > iStart && iVal < iEnd );
			else
				return ( iVal >= iStart && iVal <= iEnd );
		},

		/* возвращает красиво оформленное число: 1234567.0981 => 1 234 567.10 */
		nice : function(iRoundBase) {
			var re=/^(\d+)([\.,](\d+))?$/
			var iNum=Number(this);
			var sNum=String(iNum);
			var aMatches;
			var sDecPart='';
			var sTSeparator=' ';
			if((aMatches = sNum.match(re))){
				var sIntPart=aMatches[1];
				var iDecPart=(aMatches[3]) ? Number('0.'+aMatches[3]) : 0;
				if(iDecPart){
					var iRF=Math.pow(10, (iRoundBase) ? iRoundBase : 2);
					iDecPart=Math.round(iDecPart*iRF);
					sDecPart=(iDecPart) ? ','+iDecPart : '';
				}
				if(Number(sIntPart) < 10000)
					return sIntPart+sDecPart;
				else{
					var sNewNum='';
					var i;
					for(i=1; i*3<sIntPart.length; i++)
						sNewNum=sTSeparator+sIntPart.substring(sIntPart.length - i*3, sIntPart.length - (i-1)*3)+sNewNum;
					return sIntPart.substr(0, 3 - i*3 + sIntPart.length)+sNewNum+sDecPart;
				}
			}
			else{    //нам что-то не то подсунули
				return sNum;
			}
		},

		toDegree : function() {
			return this.valueOf() / Math.PI * 180;
		}
	}
);


Common.Object.extend(
	String.prototype,
	{
		toNumber : function() {
			return Number(this.replace(/[^\d\.]/g,''));
		}
	}
);

