function openImageSizedWindow(src) {
    var i = new Image();
    i.onload = function() {
        var pop_win = window.open("", "_blank", "width=" + i.width + ",height=" + i.height + ",scrollbars=no,resizable=yes");
        if (pop_win) {
            pop_win.window.document.open();
            pop_win.window.document.write('<html>' + '<head><title>' + i.alt + '</title></head>' + '<body style="margin:0;padding:0;border:0;">' + '<img src="' + i.src + '" width="100%" alt="" />' + '</body>' + '</html>');
            pop_win.window.document.close();
        } else {
            location.href = i.src;
        }
        i.onload = function() {};
    }
    i.src = src;
}

var FitWidth = 146;
var FitHeight = 150

function Fit(targetimg) {
			var newImgH;
    if (targetimg.width > FitWidth) {
        var old_w = targetimg.width;
        var dis = FitWidth / old_w;
        targetimg.width = FitWidth;
        targetimg.height = FitHeight * dis;
								targetimg.style.width = FitWidth + "px";
								targetimg.style.height = Math.round(FitHeight * dis) + "px";
								newImgH = targetimg.style.height;
    }
				else
				{
					targetimg.height = FitHeight;
					targetimg.style.height = FitHeight + "px";
					newImgH = targetimg.style.height;
				}
				if(newImgH == "51px")
				{
					targetimg.height = FitHeight;
					targetimg.style.height = FitHeight + "px";
				}
    var addimg = document.createElement("img");
    addimg.src = "/common/img/icon_plus.gif";
    addimg.style.position = "absolute";
    addimg.style.top = (targetimg.height - 15) + "px";
    addimg.style.left = (targetimg.width - 15) + "px";
    targetimg.parentNode.parentNode.style.position = "relative";
    targetimg.parentNode.appendChild(addimg);
}

function selectWrap() {
    var checkStr = document.getElementById("disk").firstChild.nodeValue;
    var targetWrap = document.getElementById("selectWrap");
    tdArray = targetWrap.getElementsByTagName('td');
    for (i = 0; i < tdArray.length; i++) {
        var target = tdArray[i];
        if (target.hasChildNodes()) {
            var CN = target.firstChild;
            if (CN.nodeType == 3) {
                var Vtext = CN.nodeValue;
                var vl = Vtext.length;
                var last = Vtext.slice(vl - 1, vl);
                if (last == checkStr) {
                    Str = Vtext.slice(0, vl - 1);
                    CN.parentNode.innerHTML = Str + "<span>" + checkStr + "</span>";
                    //CN.nodeValue = last;
                }
            }
            else if (CN.nodeType == 1) {
                Ctarget = target.firstChild;
                if (Ctarget.tagName != "BR") {
                    var Vtext = Ctarget.firstChild.nodeValue;
                    var vl = Vtext.length;
                    var last = Vtext.slice(vl - 1, vl);
                    if (last == checkStr) {
                        Str = Vtext.slice(0, vl - 1);
                        Ctarget.innerHTML = Str + "<span>" + checkStr + "</span>";
                        //Ctarget.firstChild.nodeValue = last;
                    }
                }
            }
        }
    }
}


function limitWord()
{
	var Tlimit = lmt;
	var pNode =	document.getElementById("limit");
	var limitP = pNode.getElementsByTagName("p")[0];
	var limitText = limitP.firstChild.nodeValue;
	check = limitText.length;
	var newText = limitText.slice(0,Tlimit);
	limitP.firstChild.nodeValue = newText;
}


