﻿
function fnFirstClass(targetclass, addClassName)
{	
	$("."+targetclass+":first").addClass(addClassName);
}


function fnLastClass(targetclass, addClassName)
{		
	$("."+targetclass+":last").addClass(addClassName);
}


function fnLastTrStyle(targetid, addClassName)
{		
	$("#"+targetid+" tr:last").addClass(addClassName);
}

function fnremoveClass(ObjId, targetTag, removeClassName)
{
	$("#"+ObjId+" "+targetTag).removeClass(removeClassName);
}

function fnResizeImgByClass(className, width)
{   
    // width 값이 변한 정도 값을 저장 하는 변수
    var factor      = 0.0;
    // 태그나 속성값에 width나 height 값이 없을 경우 width 값 조절시 자동으로 height 값을 조정한다.
    // 그래서, 자동으로 height 값이 조절이 되었을 경우, width값이 변화된 정도에 따라 height 값을 조절 하는 과정을
    // 거치지 않기 위해서 사용 한다.
    var isChange    = false;        
    var height      = 0;
    $.each($("." + className + " img,."+className + " embed"), function (name, value) {
        
        if ($(this).width() > width) {
            height = $(this).height();
            factor = width / $(this).width();
            $(this).css("width", width);
            isChange = height == $(this).height() ? false : true;
        } else if ($(this).width() == 0) {
            $(this).css("width", width);
        }
        
        if ($(this).attr("width") > width) {
            height = $(this).height();
            factor = width / $(this).attr("width");
            $(this).attr("width", width);
            isChange = height == $(this).height() ? false : true;
        } else if ($(this).attr("width") == 0) {
            $(this).attr("width", width);
        }
        
        if (factor != 0.0 && !isChange)
        {
            $(this).css("height", $(this).height() * factor);
            $(this).attr("height", $(this).attr("height") * factor);
            
            factor = 0.0;
        }
    });
}