// JavaScript Document

function sl_heightSet(pre_id, cols){
	var count=0;
	var max_height=new Array();
	var max_inline_height=new Array();
	var obj_list = new Array();
	while(true){
		
		var y=Math.floor(count / 2);
		var max_height_temp = 0;
		var max_inline_height_temp = 0;
		obj_list[y] = new Array();
		
		var id = pre_id + '_' + count;
		var id_obj = document.getElementById(id);
		if(!id_obj){
			break;
		}
		
		while(true){
			
			x = count % cols;
			
			var id = pre_id + '_' + count;
			//alert(id);
			var id_obj = document.getElementById(id);
			if(!id_obj){
				break;
			}
			var this_height = id_obj.offsetHeight;
			if(this_height > max_height_temp){
				max_height_temp = this_height;
				var id_obj_inline = document.getElementById(id + '_inline');
				
				if(id_obj_inline){
					max_inline_height_temp = id_obj_inline.offsetHeight;
				}
			}
			//alert(id);
			obj_list[y][x]=id;
			
			
			
			if(x == (cols - 1)){
				break;	
			}
			
			//alert('count:'+count);
			//alert('x:'+x);
			//alert('y:'+y);
			
			count++;
		}
		
		max_height[y] = max_height_temp;
		max_inline_height[y] = max_inline_height_temp;
		
		//alert(max_height[y]);
		//alert('list y:'+y);
		count++;
		
	}
	//alert('run!!!');
		
	var regPattern = new RegExp('px');
	//alert(obj_list.length);
	for(y = 0; y < obj_list.length; y++){
		temp_obj = obj_list[y];
		//alert(obj_list[y]);
		//alert(temp_obj.length);
		for(x = 0; x < obj_list[y].length; x++){
			
			var obj = document.getElementById(obj_list[y][x]);
			//alert(obj_list[y][x]);
			obj.style.height = max_height[y] + 'px';
			var obj_inline = document.getElementById(obj_list[y][x]+'_inline');
			if(obj_inline){
				var paddingTop = getElementStyle(obj_list[y][x]+'_inline','paddingTop','padding-top');
				var paddingBottom = getElementStyle(obj_list[y][x]+'_inline','paddingBottom','padding-bottom');
				var borderTopWidth = getElementStyle(obj_list[y][x]+'_inline','borderTopWidth','border-top-width');
				var borderBottomWidth = getElementStyle(obj_list[y][x]+'_inline','borderBottomWidth','border-bottom-width');
				paddingTop = paddingTop.replace(regPattern, '');
				paddingBottom = paddingBottom.replace(regPattern, '');
				borderTopWidth = borderTopWidth.replace(regPattern, '');
				borderBottomWidth = borderBottomWidth.replace(regPattern, '');
				//alert('paddingTop:'+paddingTop);
				//alert('paddingBottom:'+paddingBottom);
				//alert('borderTopWidth:'+borderTopWidth);
				//alert('borderBottomWidth:'+borderBottomWidth);
				/*
				if (typeof document.body.style.maxHeight != "undefined") { 
					// IE 7, mozilla, safari, opera 9 
					alert('IE7');
					obj_inline.style.height = max_inline_height[y] + 'px';
				} else { 
					// IE6, older browsers
					alert('IE6');
					max_inline_height_tmp = max_inline_height[y] - paddingTop - paddingBottom - borderWidth;
					obj_inline.style.height = max_inline_height_tmp + 'px';
				} 
				*/
				max_inline_height_tmp = max_inline_height[y] - paddingTop - paddingBottom - borderTopWidth - borderBottomWidth;
				obj_inline.style.height = max_inline_height_tmp + 'px';

				//obj_inline.style.height = max_inline_height + 'px';
			}
		}
	}
}

function getElementStyle(elemID, IEStyleProp, CSSStyleProp){
  var elem;
  if(typeof(elemID) == "string"){
    elem = document.getElementById(elemID);
  }else{
    elem = elemID;
  }
  if(elem.currentStyle){
    return elem.currentStyle[IEStyleProp];
  }else if(window.getComputedStyle){
    var compStyle = window.getComputedStyle(elem, "");
    return compStyle.getPropertyValue(CSSStyleProp);
  }
  return "";
}


