﻿// JScript 文件

//选择产品尺寸,单品页
function chooseThisSize(obj)
{
    OperStyle(obj);    
    document.getElementById("sizeSpan1").innerHTML = obj.innerHTML;
    document.getElementById('HiddenField1').value = obj.innerHTML; 
}

//操作样式
var OperStyle = function(obj)
{
    for(var i=0;i<obj.parentNode.childNodes.length;i++)
    {
        if(obj.parentNode.childNodes[i].className == 'current')
        {
            obj.parentNode.childNodes[i].className = '';
        }
    }    
//    $('#sizeSpan1').html(obj.innerHTML);
    obj.className = "current";     
}

//写评论,参数为产品号
function WriteComment(proCode) {
//    debugger;

    $.blockUI({
        message: $('#addComment'), css: {
            top: ($(window).height() - 300) / 2 + 'px',
            left: ($(window).width() - 400) / 2 + 'px',
            width: '400px', height: '240px'
        }
    });
    $('#yes').click(function() {
        var tempName = escape($("#UserName").val());
        var tempTitle = escape($("#Title").val());
        var tempText = escape($("#Text").html());
        if (tempName.length < 2 || tempName.length > 150) {
            alert("姓名长度在2个到150个字符之间");
            return false;
        }
        if (tempTitle.length < 2 || tempTitle.length > 150) {
            alert("标题长度在2个到50个字符之间");
            return false;
        }
        if (tempText.length > 1000) {
            alert("内容字符在1000个以内");
            return false;
        }
        this.disabled = "disabled";
        this.value = '您已经评论过了';
        var UpStr = "ProCode=" + escape(proCode);
        UpStr += "&UserName=" + tempName;
        UpStr += "&Title=" + tempTitle;
        UpStr += "&Content=" + tempText;
        // update the block message 
        $.ajax({
            url: '/Product/ProductCommentAdd.ashx?' + UpStr,
            cache: false,
            success: function(data, textStatus) {
                $("#UserName").val("");
                $("#Title").val("");
                $("#Text").html("");
                $.blockUI({ message: "<h3>您的评论已经发布成功！</h3><div style=\"width:100%; text-align:center;\"><input type=\"button\" value=\" 确定 \" onclick=\"$.unblockUI();\" ></div>", css: { width: '400px', height: '120px', textAlign: 'left'} });
                GuestBook(proCode);
            },
            error: function() {
                $.blockUI({ message: "<h3>出现服务器错误,管理员会解决这个问题的！</h3><div style=\"width:100%; text-align:center;\"><input type=\"button\" value=\" 确定 \" onclick=\"$.unblockUI();\" ></div>", css: { width: '400px', height: '120px', textAlign: 'left'} });
            }
        });
    });

    $('#no').click(function() {
        $.unblockUI();
        return false;
    });
}

function $(e) { return document.getElementById(e); }
function String.prototype.trim() { return this.replace(/(^\s*)|(\s*$)/g, ""); }

var s_GridView_CurrenPage = '0';
var xmlHttp;
var xmlHttpGet;
function GetXmlHttpObject() {
    var xmlHttpNew = null;
    try {
        xmlHttpNew = new XMLHttpRequest();
    }
    catch (e) {
        try {
            xmlHttpNew = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttpNew = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttpNew;
}
function clearall() {
    $("txtname").value = "";
    $("txtemail").value = "";
    $("txtBook").value = "";
    $("txttel").value = "";
    $("txtTitle").value = "";
    $("txtverify").value = "";
    $("txtcountry").selectedIndex = 0;

}

function GuestBook(_pid) {
    xmlHttpGet = GetXmlHttpObject();
    if (xmlHttpGet == null) {
        alert("浏览器不支持 AJAX!");
        return;
    }
    var url = '/feedback.aspx?productid='+_pid;
    url = url + "&SID=" + Math.random();
    url = url + "&PageIndex=" + s_GridView_CurrenPage;
    xmlHttpGet.onreadystatechange = BookGetOK;
    xmlHttpGet.open("GET", url, true);
    xmlHttpGet.send(null);
}

function BookGetOK() {
    if (xmlHttpGet.readyState == 4) {
        var gustBookDiv = document.getElementById("middle3");
        gustBookDiv.innerHTML = xmlHttpGet.responseText;

    }
}

function Paging(s_Param_PageNumber) {
    s_GridView_CurrenPage = s_Param_PageNumber;
    GuestBook();
}





      