function plpost() {
    var username = document.getElementById("plUserName");
    var plEmail = document.getElementById("plEmail");
    var plTele = document.getElementById("plTele");
    var plPcontent = document.getElementById("plPcontent");
    if (username.value == '') {
        alert("请输入您的姓名");
    } else {
        if (plEmail.value == '' && plTele.value == '') {
            alert("电话号码和邮箱必须输入一项");
        } else {
            if (plPcontent.value == '') {
                alert("请输入评论内容");
            }
        }
    }
}

var FitWidth = 300; //图片宽度 
var FitHeight = 250; //图片高度 
var FitWidth2 = 50; //图片宽度 
var FitHeight2 = 50; //图片高度 
function ResizePic(ImgTag) {
    var image = new Image();
    image.src = ImgTag.src;
    if (image.width > 0 && image.height > 0) {
        if (image.width / image.height >= FitWidth / FitHeight) {
            if (image.width > FitWidth) {
                ImgTag.width = FitWidth;
                ImgTag.height = (image.height * FitWidth) / image.width;
            } else {
                ImgTag.width = image.width;
                ImgTag.height = image.height;
            }
        } else {
            if (image.height > FitHeight) {
                ImgTag.height = FitHeight;
                ImgTag.width = (image.width * FitHeight) / image.height;
            } else {
                ImgTag.width = image.width;
                ImgTag.height = image.height;
            }
        }
    }
}

function ResizePic2(ImgTag) {
    var image = new Image();
    image.src = ImgTag.src;
    if (image.width > 0 && image.height > 0) {
        if (image.width / image.height >= FitWidth2 / FitHeight2) {
            if (image.width > FitWidth2) {
                ImgTag.width = FitWidth2;
                ImgTag.height = (image.height * FitWidth2) / image.width;
            } else {
                ImgTag.width = image.width;
                ImgTag.height = image.height;
            }
        } else {
            if (image.height > FitHeight2) {
                ImgTag.height = FitHeight2;
                ImgTag.width = (image.width * FitHeight2) / image.height;
            } else {
                ImgTag.width = image.width;
                ImgTag.height = image.height;
            }
        }
    }
}

function showImage(source) {
    var img = document.getElementById("ProductDetails_img_Common_ViewProduct_Image");
    var url = source.attributes["src"].nodeValue;
    if (img.src == url) {
        return;
    }
    var img1 = new Image();
    img1.src = url;
    $(".jqzoom").attr("href", url);
    if (img1.width > 300 || img1.height > 300) {
        _w = img1.width / 300;
        _h = img1.height / 300;

        if (_h > _w) {
            _w = _h;
        }
        img1.width = img1.width / _w;
        img1.height = img1.height / _w;
        img.src = url;
    }
    if (img1.width > 0 && img1.height > 0) {
        img.style.width = img1.width + "px";
        img.style.height = img1.height + "px";
        img.src = url;
    }
}
//商品详细页多图
function ProductSwapImages(thisObject) {
    var upperID = thisObject.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("div");
    for (var i = 0; i < upperID.length; i++) {
        upperID[i].className = "Product_WareSmall_1";
    }

    thisObject.className = "Product_WareSmall";
}

$(function() {
    var options = {
        zoomWidth: 250,
        zoomHeight: 250,
        title: false
    };
    $(".jqzoom").attr("href", $(".jqzoom img").attr("src"));
    $(".jqzoom").jqzoom(options);
});