function reSize(params){
	//Check element
	var element = (typeof(params.element) == 'object') ? params.element : document.getElementById(params.element);
	if(!element){
		if(DEBUG){
			alert('reSize: no element');
		}
		return false;
	}
	
	//Check sizes
	if(!params.sizeStart){
		if(DEBUG){
			alert('reSize: no sizeStart');
		}
		return false;
	}
	if(!params.sizeEnd){
		if(DEBUG){
			alert('reSize: no sizeEnd');
		}
		return false;
	}
	if('number' == typeof(params.sizeStart)){
		var sizeStart = params.sizeStart;
	}else{
		if(DEBUG){
			alert('reSize: wrong value sizeStart');
		}
		return false;
	}
	if('number' == typeof(params.sizeEnd)){
		var sizeEnd = params.sizeEnd;
	}else{
		if(DEBUG){
			alert('reSize: wrong value sizeEnd');
		}
		return false;
	}
	
	//Check count
	var count = 0;
	if(params.count){
		if('number' == typeof(params.count)){
			count = params.count;
		}else{
			if(DEBUG){
				alert('reSize: count - wrong value');
			}
		}
	}
	
	//Check mode
	var mode = 'reverse';
	if(params.mode){
		if('repeat' == params.mode){
			var mode = 'repeat';
		}
	}
	
	//Check delay
	var delay = 10;
	if(params.delay){
		if('number' == typeof(params.delay)){
			delay = params.delay;
		}else{
			if(DEBUG){
				alert('reSize: delay - wrong value');
			}
		}
	}
	
	//Check style
	var style = 'fontSize';
	if(params.style){
		style = params.style;
	}
	
	
	//Go
	var diff = Math.abs(sizeStart-sizeEnd);
	element.style[style] = sizeStart+'px';
	var ccount = count;
	var c=0;
	var i=0;
	var intervalID = window.setInterval(function(){
		if(1>sizeStart-sizeEnd){
			var p = 1;
		}else{
			var p = -1;
		}
		var nS = p*i + sizeStart;
		var nSize = nS+'px';
		element.style[style] = nSize;
		//test(nSize);
		i++;
		//
		if(i>=(diff)){
			i=0;
			element.style[style] = sizeEnd;
			//Revers
			if('reverse' == mode){
				var s = sizeStart;
				var e = sizeEnd;
				sizeEnd = s;
				sizeStart = e;
			}
			c++;
			if(count){
				if(c>=ccount){
					window.clearInterval(intervalID);
					return true;
				}
			}
		}
	}, delay);
	
}


function reColor(params){
	
	//Check element
	var element = (typeof(params.element) == 'object') ? params.element : document.getElementById(params.element);
	if(!element){
		if(DEBUG){
			alert('reColor: no element');
		}
		return false;
	}
	
	//Check colors
	var colorStart = (6 == params.colorStart.length) ? params.colorStart : false;
	var colorEnd = (6 == params.colorEnd.length) ? params.colorEnd : false;
	if(!colorStart){
		if(DEBUG){
			alert('reColor: no colorStart');
		}
		return false;
	}
	if(!colorEnd){
		if(DEBUG){
			alert('reColor: no colorEnd');
		}
		return false;
	}
	
	//Partition colors
	var RStart, GStart, BStart, REnd, GEnd, BEnd;
	partitionColors();
	
	//Check
	var quantum = 1;
	if(params.quantum){
		if('number' == typeof(params.quantum)){
			quantum = params.quantum;
		}else{
			if(DEBUG){
				alert('reColor: quantum - wrong value');
			}
		}
	}
	
	//Create quanta
	var maxDifference = 0;
	var t = RStart - REnd; if(t<0){t = t*(-1);}
	if(maxDifference < t){maxDifference = t;}
	t = GStart - GEnd; if(t<0){t = t*(-1);}
	if(maxDifference < t){maxDifference = t;}
	t = BStart - BEnd; if(t<0){t = t*(-1);}
	if(maxDifference < t){maxDifference = t;}
	var quanta = maxDifference/quantum;
	
	//Check count
	var count = 0;
	if(params.count){
		//test('count...');
		if('number' == typeof(params.count)){
			count = params.count;
		}else{
			if(DEBUG){
				alert('reColor: count - wrong value');
			}
		}
	}
	
	//Check mode
	var mode = 'reverse';
	if(params.mode){
		if('repeat' == params.mode){
			var mode = 'repeat';
		}
	}
	
	//Check style
	style = 'color';
	if(params.style){
		if('backgroundColor' == params.style){
			style = 'backgroundColor';
		}else if('borderColor' == params.style){
			style = 'borderColor';
		}
	}
	
	//Go
	element.style[style] = '#'+colorStart;
	var ccount = count;
	var c=0;
	var i=0;
	var intervalID = window.setInterval(function(){
		
		
		var nR = parseInt((REnd-RStart)/quanta*i + RStart);
			//nR = d2h(parseInt(nR)).toString();
		var nG = parseInt((GEnd-GStart)/quanta*i + GStart);
			//nG = d2h(parseInt(nG)).toString();
		var nB = parseInt((BEnd-BStart)/quanta*i + BStart);
			//nB = d2h(parseInt(nB)).toString();
		//
		//var nColor = '#'+nR+nG+nB;
		var nColor = 'rgb('+nR+','+nG+','+nB+')';
		element.style[style] = nColor;
		//test(nR+','+nG+','+nB);
		//test(nColor);//test
		//alert(nColor);
		if(i>=quanta){
			//element.style[style] = '#'+colorEnd;
			element.style[style] = nColor;
			//window.clearInterval(iID);
		}
		
		
		i++;
		
		//
		if(i>=quanta){
			i=0;
			//Revers
			if('reverse' == mode){
				var s = colorStart;
				var e = colorEnd;
				colorEnd = s;
				colorStart = e;
				partitionColors();
			}
			c++;
			if(count){
				if(c>=ccount){
					window.clearInterval(intervalID);
					element.style[style] = nColor;
				}
			}
		}
	}, 10);
	
	function partitionColors(){
		RStart = h2d(colorStart.substr(0, 2));
		GStart = h2d(colorStart.substr(2, 2));
		BStart = h2d(colorStart.substr(4, 2));
		REnd = h2d(colorEnd.substr(0, 2));
		GEnd = h2d(colorEnd.substr(2, 2));
		BEnd = h2d(colorEnd.substr(4, 2));
	}
	
	function d2h(d) {return d.toString(16);} function h2d(h) {return parseInt(h,16);}
	
}






















function clear(idob){
	if('object' == typeof(idob)){
		element = idob;
	}else{
		var element = document.getElementById(idob);
	}
	while(element.firstChild){
		element.removeChild(element.firstChild);
	}
}

function setListeners(id, event, func){
	var debug = true;
	if('object' == typeof(id)){
		element = id;
	}else{
		var element = document.getElementById(id);
	}
	if(!element){
		if(debug){alert('function setListeners: no element');}
		return false;
	}
	//Set listener
	if(element.addEventListener){
		element.addEventListener(event, func, false);
	}else if(element.attachEvent){
		element.detachEvent('on'+event, func);
		element.attachEvent('on'+event, func);
	}
}

function test(val,last){
	var div = document.createElement('div');
	div.style.backgroundColor = 'red';
	div.style.fontSize = '30px';
	div.style.textAlign = 'center';
	div.style.fontWeight = 'bold';
	if(val){
		var txt = document.createTextNode(val);
	}else{
		var txt = document.createTextNode('Åìïòè!!');
	}
	div.appendChild(txt);
	last?document.body.appendChild(div):document.body.insertBefore(div, document.body.firstChild);
	//document.body.appendChild(div);
	//document.body.insertBefore(div, document.body.firstChild);
}

function list(obj){
	var table = document.createElement('table');
	var tbody = document.createElement('tbody');
	var tr, td, txt;
	for(var name in obj){
		tr = document.createElement('tr');
		td = document.createElement('td');
		td.style.borderStyle = "solid";
		td.style.borderColor = "green";
		txt = document.createTextNode(name);
		td.appendChild(txt); tr.appendChild(td);
		td = document.createElement('td');
		td.style.borderStyle = "solid";
		td.style.borderColor = "green";
		txt = document.createTextNode(obj[name]);
		td.appendChild(txt); tr.appendChild(td);
		tbody.appendChild(tr);
	}
	table.appendChild(tbody);
	table.style.backgroundColor = "#c0ffc0";
	table.style.fontSize = "30px";
	document.body.appendChild(table);
}

/*
var test = document.createElement('div');
test.style.fontSize = '30px';
test.style.backgroundColor = 'red';
test.style.textAlign = 'center';
test.appendChild(document.createTextNode('JS-OK!'));
document.body.appendChild(test);
*/

function createTableFromMatrix(o, h){
	var t = document.createElement('table');
	var tb = document.createElement('tbody');
	t.appendChild(tb);
	for(var i in o){
		if((0 == i) && ('h' == h)){
			var tr = document.createElement('tr');
			tb.appendChild(tr);
			for(var ii in o[0]){
				var th = document.createElement('th');
				tr.appendChild(th);
				th.appendChild(document.createTextNode(ii));
			}
		}
		//
		var tr = document.createElement('tr');
		tb.appendChild(tr);
		for(var ii in o[i]){
			var td = document.createElement('td');
			tr.appendChild(td);
			td.appendChild(document.createTextNode(o[i][ii]));
		}
	}
	return t;
}
function table(o){
	var t = createTableFromMatrix(o, 'h');
	t.id = 'testTable';
	document.getElementsByTagName('body')[0].appendChild(t);
}
