var issue;
var sid;
$(document).ready(function() {
    $('.doConfirm').click(function(){
         issue=$(this).parent().find('[@name=issue]').val();
         sid=$(this).parent().find('[@name=sid]').val();
        $('#showChangeStatus').popup({width:'350px',height:'250px',top:'100',popupHead:'ChangeStatusHead',btnClose:'ChangeStatusClose'});
    });
    $('#btnCancel').click(function(){
        $('#showChangeStatus').hide();
    });
    $('#btnConfirm').click(function(){
        BtnConfirm();
    });
    
    $("#txtStartTime").datepicker().click(function(){$(this).blur()});
    $("#txtEndTime").datepicker().click(function(){$(this).blur()});
    $("#btnReset").click(function(){
        var len = document.Form1.elements.length;
        alert(len);
        for(i = 0 ; i < len ; i++){
        alert(document.Form1.elements[i].value);
//          if(document.Form1.elements[i].type == 'text'){
//            document.Form1.elements[i].value = '';
//          }else if(document.Form1.elements[i].type == 'select-one'){
//            document.Form1.elements[i].options[0].selected=true;
//          }
        }
        return false;
      })
    
   	//给跳转按钮绑定onclick事件
	$("#go").bind("click",function(){
		var pageNum = $("#gopage").val();
		var totalpage =  parseInt($("#totalpage").text());
		if(pageNum.replace(new RegExp("(^[\\s]*)|([\\s]*$)", "g"), "") != "" ){
            if(pageNum != "0"){
                if(pageNum > totalpage){
                    alert("输入的数字大于总页数");
                    $("#gopage").attr("value","");
                    return false;
                }
//                else{
//					window.location.href='OrderPayList.aspx?page='+$("#gopage").attr("value");
//                }
            }
            else{  
                alert("输入错误！");
                $("#gopage").attr("value","");
                return false;
            }
        }
        else{
            alert("请输入要跳转到的页面");
            $("#gopage").attr("value","");
            return false;
        }
	});
});

function BtnConfirm()
{
    var serialNumber=$("#serialNumber").val();
    var remark=$("#remark").val();    
    var postdata = 'NoCopyRight=1&type=ajax&Action=UpdateStatus&issue='+issue + '&sid='+sid+'&serialNumber='+serialNumber+'&remark='+remark;
    $.ajax({
        url:'FinanceStatistics.aspx',
        type:'POST',
        data:postdata,
        success:function(data){
            if(data==='ok'){
                alert('操作成功');
                window.location.reload();
            }else{
                alert(data);
            }
        },
        error:function(XMLHttpRequest,textStatus){if(textStatus=='parsererror'){alert('身份已过期,请重新登陆!')}else{alert('error')};}
    });
}