
function resize(obj,width,height,funcao,effect){
	var rect = obj.getBoundingClientRect();
	function getSignal(n){
		if(n>0)return 1;
		else if(n<0) return -1;
		return 0;
	}
	if(!effect) effect="none";
	function process(obj,widthatual,heightatual,width,height,wincrement,hincrement,time,funcao,effect){
		if(obj.fxResizeEffect){
			if(width != "none" && (widthatual + wincrement < width && wincrement > 0) || (widthatual + wincrement > width && wincrement < 0)){
				
				obj.style.width = widthatual + wincrement + "px" ;
				if(effect=="reverse" || effect=="reversewidth"){
					obj.style.left = parseInt(obj.style.left) - wincrement + "px";
				}
				else if(effect=="center"){
					var r = obj.getBoundingClientRect();
					obj.style.left = r.left - (wincrement)/1.25 + "px";
				}
				setTimeout(function(){
					process(obj,widthatual + wincrement, heightatual + hincrement, width,height,wincrement,hincrement,time,funcao,effect);
				},time);
			}
			else if(height != "none" && (heightatual + hincrement < height && hincrement >0) || (heightatual + hincrement > height && hincrement <0)){
				if(effect=="reverse" || effect=="reverseheight"){
					obj.style.top = parseInt(obj.style.top) - hincrement + "px";
				}
				else if(effect=="center"){
					var r = obj.getBoundingClientRect();
					obj.style.top = r.top - (hincrement)/1.25 + "px";
				}
				obj.style.height = heightatual + hincrement + "px";	
				setTimeout(function(){
					process(obj,widthatual + wincrement, heightatual + hincrement, width,height,wincrement,hincrement,time,funcao,effect);
				},time);
			} 
			else{
				if(height !="none"){
					if(effect=="reverse" || effect=="reverseheight")
						obj.style.top = parseInt(obj.style.top) + parseInt(obj.style.height) - height + "px";
					obj.style.height = height + "px";
				}
				if(width !="none"){
					if(effect=="reverse" || effect=="reversewidth")
						obj.style.left = parseInt(obj.style.left) + parseInt(obj.style.width) - width + "px";
					obj.style.width = width + "px";
				}
				if(funcao)funcao(obj);
			}
		}
	}
	
	var wincrement = 1;
	var hincrement = 1;
	if(rect.right - rect.left > width){
		wincrement *= -1;
	}
	if(rect.bottom - rect.top > height){
		hincrement *= -1;
	}
	
	if(width != "none"){
		var tw = parseInt(obj.style.borderLeftWidth);tw=isNaN(tw)?0:tw;
		var bw = parseInt(obj.style.borderRightWidth);bw=isNaN(bw)?0:bw;
		width += tw + bw;
		
	}
	if(height != "none"){
		var tw = parseInt(obj.style.borderTopWidth);tw=isNaN(tw)?0:tw;
		var bw = parseInt(obj.style.borderBottomWidth);bw=isNaN(bw)?0:bw;
		height += tw + bw;
	}
	
	setTimeout(function(){
		obj.fxResizeEffect = true;
		process(obj,rect.right - rect.left,rect.bottom - rect.top,width,height,wincrement*6,hincrement*6,10,funcao,effect);
	},10);
}

function stopResize(obj){
	obj.fxResizeEffect = false;	
}


var myFxMask = document.createElement("div");
myFxMask.status = "stop";
myFxMask.style.width = "100%";
myFxMask.style.height = "140%";
myFxMask.style.position = "absolute";
myFxMask.style.top = "0px";
myFxMask.style.left = "0px";
myFxMask.style.zIndex = 0;
myFxMask.style.background = "#000000";
myFxMask.style.opacity = "0.4";
myFxMask.style.filter = "alpha(opacity=40)";

myFxMask.start = function(){
	myFxMask.style.display = "block";	
}
myFxMask.stop = function(){
	myFxMask.style.display = "none";
}

var myInvisibleMask = document.createElement("div");
myInvisibleMask.status = "stop";
myInvisibleMask.style.width = "100%";
myInvisibleMask.style.height = "140%";
myInvisibleMask.style.position = "absolute";
myInvisibleMask.style.top = "0px";
myInvisibleMask.style.left = "0px";
myInvisibleMask.style.zIndex = 1000;
myInvisibleMask.style.background = "#FFFFFF";
myInvisibleMask.style.opacity = "0";
myInvisibleMask.style.filter = "alpha(opacity=0)";

myInvisibleMask.start = function(){
	this.style.visibility = "visible";	
};
myInvisibleMask.stop = function(){
	this.style.visibility = "hidden";	
};

myInvisibleMask.stop();
myFxMask.stop();


document.body.appendChild(myFxMask);
document.body.appendChild(myInvisibleMask);
