﻿function imgCut(obj) {
    var maxHeight = 300, maxWidth = 350;
    var imgWidth = obj.width, imgHeight = obj.height;
    var tempWidth, tempHeight;
    var percentHeight = obj.height / maxHeight;
    var percentWidth = obj.width / maxWidth;
    if (percentHeight > percentWidth) {
        obj.style.width = maxWidth + "px";
        tempHeight = (maxWidth / imgWidth) * imgHeight;
        obj.style.marginTop = -(tempHeight / 2 - 112) + "px";
    } else if (percentHeight < percentWidth) {
        obj.style.height = maxHeight + "px";
        tempWidth = (maxHeight / imgHeight) * imgWidth;
        obj.style.marginLeft = -(tempWidth / 2 - 150) + "px"; //obj.width
    } else {
        obj.style.height = maxHeight + "px";
        obj.style.width = maxWidth + "px";
    }
}
function imgCutV2(obj, maxHeight, maxWidth) {
    //var maxHeight = 300, maxWidth = 350;
    var imgWidth = obj.width, imgHeight = obj.height;
    var tempWidth, tempHeight;
    var percentHeight = obj.height / maxHeight;
    var percentWidth = obj.width / maxWidth;
    if (percentHeight > percentWidth) {
        obj.style.width = maxWidth + "px";
        tempHeight = (maxWidth / imgWidth) * imgHeight;
        obj.style.marginTop = -(tempHeight / 2 - 112) + "px";
    } else if (percentHeight < percentWidth) {
        obj.style.height = maxHeight + "px";
        tempWidth = (maxHeight / imgHeight) * imgWidth;
        obj.style.marginLeft = -(tempWidth / 2 - 150) + "px"; //obj.width
    } else {
        obj.style.height = maxHeight + "px";
        obj.style.width = maxWidth + "px";
    }
}
/*滑动JS*/
function nTabs(thisObj, num) {
    if (thisObj.className == "active") return;
    var tabObj = thisObj.parentNode.id;
    var tabList = document.getElementById(tabObj).getElementsByTagName("li");
    for (i = 0; i < tabList.length; i++) {
        if (i == num) {
            thisObj.className = "active";
            document.getElementById(tabObj + "_Content" + i).style.display = "block";
        } else {
            tabList[i].className = "normal";
            document.getElementById(tabObj + "_Content" + i).style.display = "none";
        }
    }
}

