﻿//强制等高 by Self
function $(obj){
	return document.getElementById(obj);
}

String.prototype.camelCase = function(){
	return this.replace(/-\D/g,function(match){
			return match.charAt(1).toUpperCase();
		});
}

String.prototype.hyphenate = function(){
		return this.replace(/[A-Z]/g,function(match){
				return ('-' + match.charAt(0).toLowerCase());
				});
}

var _getComputedStyle = function(property){
		if(this.currentStyle) return this.currentStyle[property.camelCase()];
		var computed = document.defaultView.getComputedStyle(this,null);
		return (computed) ? computed.getPropertyValue([property.hyphenate()]) : null;
	}



function EqualHeight(obj,clear){
	function $(obj){
		return document.getElementById(obj);
		}

	function $each(iterable,fn,fn_sub){
				for(i = 0;i < iterable.length;i++){
						fn.apply(null,[iterable,i]);
					}
	}

	function _nodeFix(obj){
	var arr = new Array();
	var cl = new RegExp("\\b"+clear+"\\b\\s*","");
	for(i = 0;i < obj.childNodes.length;i++){
			if(obj.childNodes[i] && obj.childNodes[i].nodeType == 1 && !(cl.test(obj.childNodes[i].className))){
					arr.push(obj.childNodes[i]);
					
				}
			}
			return arr;
	}	

	function calc(h,obj){
			
				try{ var _t = parseInt(_getComputedStyle.call(obj,"paddingTop"));}
				catch(e){
						throw new Error("获取padding值时出现错误!!");
						alert(e);
						
						}

				var _b = parseInt(_getComputedStyle.call(obj,"paddingBottom"));
				return (h - (_t + _b))	;
		}
	//window.alert("断点-改变前");		
	var arr = _nodeFix($(obj)),_H = 0;

	$each(arr,function(arr,i){	
							var _h = arr[i].offsetHeight;
							_H = (_h > _H ? _h : _H);
							});
	$each(arr,function(arr,j){
											arr[j].style.height = calc(_H,arr[i]) + 'px';
											});
	
};

