var $app = {
	keepHeightEquality : function(blocks){
		var maxHeight = 0;
		$array.each(blocks,function(n,i){
			maxHeight = maxHeight<n.offsetHeight?n.offsetHeight:maxHeight;
		});
		$array.each(blocks,function(n,i){
			if(n.offsetHeight<maxHeight){
				n.style.minHeight = maxHeight+'px';
				if(Browser.IE)
					n.style.height = maxHeight+'px';
			}
		});
	},

	openWindow : function(url,name,attrs){
		var xy = $uiBase.getCenterXY({width:window.screen.width,height:window.screen.height},attrs);
		if(!isNaN(xy.x))
			attrs.left = xy.x;
		if(!isNaN(xy.y))
			attrs.top = xy.y;

		var str = '';
		for(var n in attrs){
			str += n+'='+attrs[n]+','
		}
		return window.open(url, name, str);
	},

	turnCaptcha : function(on, input){
		var captcha = $("___captcha_img___");
		if(captcha){
			captcha.style.display = on ? "block" : "none";
			if(on){
				if(captcha.alt!=""){
					captcha.src = captcha.alt;
					captcha.alt = "";
				}
				var position = $uiBase.getPos(input);
				captcha.style.left = (position.left - captcha.offsetWidth) + 'px';
				captcha.style.top = position.top + "px";
			}
		}
	},

	showErrorInfo:function(errorObj){
		if(errorObj){
			for(var v in errorObj){
				var input = $name(v);
				input = input[input.length-1];
				if(input){
					var panel = this.getErrorPanel(v);
					panel.innerHTML = errorObj[v];
					var position = $uiBase.getPos(input);
					panel.style.left = (position.left + position.offsetWidth + 3) + 'px';
					panel.style.top = position.top + "px";
					panel.style.display="inline";
				}
			}
		}
	},

	getInforPanel:function(fieldName){
		var id = fieldName+'InforPanel';
		var panel = $(id)||$uiBase.genNode("<span id='"+id+"'class='info' style='position:absolute;'></span>");
		document.body.appendChild(panel);
		return panel;
	},

	getErrorPanel:function(fieldName){
		var id = fieldName+'ErrorPanel';
		var panel = $(id)||$uiBase.genNode("<span id='"+id+"'class='error' style='position:absolute;'></span>");
		document.body.appendChild(panel);
		return panel;
	},
	
	isOverlap:function(node1, node2){
		var pos1 = $uiBase.getPos(node1);
		var pos2 = $uiBase.getPos(node2);
		var horDiff = Math.abs(pos1.left-pos2.left);
		var verDiff = Math.abs(pos1.top-pos2.top);
		return horDiff < (pos1.left<pos2.left ? pos1.width : pos2.width)&&
				verDiff < (pos1.top<pos2.top?pos1.height:pos2.height);
	},
	
	hideOverSelect:function(node){
		var selects = $tag("select");
		$array.each(selects, function(select){
			if($app.isOverlap(select, node)){
				$object.setAttr(select, "byHidden", true);
				select.style.visibility = "hidden";
			}
		});
	},
	
	showOverSelect:function(node){
		var selects = $tag("select");
		$array.each(selects, function(select){
			if($object.getAttr(select, "byHidden") == true){
				$object.delAttr(select, "byHidden");
				select.style.visibility = "visible";
			}
		});
	}
}

