﻿/// <reference path="/Js/jquery.pack.js" />

//滚动插件
(function($) {
    $.fn.extend({
        Scroll: function(opt, callback) {
            //参数初始化
            if (!opt) var opt = {};
            var _this = this.eq(0).find("ul:first");
            var lineH = _this.find("li:first").height(), //获取行高
                        line = opt.line ? parseInt(opt.line, 10) : parseInt(this.height() / lineH, 10), //每次滚动的行数，默认为一屏，即父容器高度
                        speed = opt.speed ? parseInt(opt.speed, 10) : 500, //卷动速度，数值越大，速度越慢（毫秒）
                        timer = opt.timer ? parseInt(opt.timer, 10) : 3000; //滚动的时间间隔（毫秒）
            if (line == 0) line = 1;
            var upHeight = 0 - line * lineH;
            //滚动函数
            scrollUp = function() {
                _this.animate({
                    marginTop: upHeight
                }, speed, function() {
                    for (i = 1; i <= line; i++) {
                        _this.find("li:first").appendTo(_this);
                    }
                    _this.css({ marginTop: 0 });
                });
            }
            var timerID = setInterval("scrollUp()", timer);
            //鼠标事件绑定
            _this.hover(function() {
                clearInterval(timerID);
            }, function() {
                timerID = setInterval("scrollUp()", timer);
            }).mouseout();
        }
    })
})(jQuery);

//检查车牌号的正确性
function CheckCarNo(id) {
    var reg = /^[川][a-zA-Z]{1}[0-9a-zA-Z]{5}$/;
    if (!reg.exec(id.value)) {
        alert("请输入正确的车牌号码！如川A00000");
        return false;
    }
    return true;
}




//检查手机号的正确性
function CheckMobileNo(id) {
    var reg = /^1[0-9]{10}$/;
    if (!reg.exec(id.value)) {
        alert("请输入正确的手机号码！");

        return false;
    }
    return true;
}

//检查驾驶证号的正确性
function CheckDriverNo(id) {
    var reg = /^[0-9a-zA-Z]{15,18}$/;
    if (!reg.exec(id.value)) {
        alert("请输入正确的驾驶证号码！");
        return false;
    }
    return true;
}

function CheckIsNull(id) {
    if (id.value == "") {
        alert("请输入查询条件！");

        return false;
    }
    return true;
}

//sso 违章
function SeachWZ(carno, cartype) {
    if (CheckCarNo(carno)) {
        window.open("/trafficquery/PeccancyInfoQueryStep1.aspx?action=n&vType=" +cartype.value  + "&vNumber=" + encodeURIComponent(carno.value));
        //window.open("/Seach/SeachMain.aspx?Query=0&Pay=" + paytype + "&CarNo=" + encodeURIComponent(carno.value) + "&CarType=" + cartype.value + "&MobileNo=" + mobileno.value, "违章查询");
    }
}

//sso 违章图片查询
function SeachWZimg(carno, mobileno, cartype) {
    if (CheckCarNo(carno) && CheckMobileNo(mobileno)) {
        window.open("/trafficquery/HighPeccancyInfoQuery.aspx?vNumber=" + encodeURIComponent(carno.value) + "&vType=" + cartype.value + "&vMobile=" + mobileno.value);
    }
}


//sso 驾证
function SeachJZ(derverno, mobileno, paytype) {
    if (CheckDriverNo(derverno) && CheckMobileNo(mobileno)) {
        window.open("/Seach/SeachMain.aspx?Query=jz&Pay=" + paytype + "&DriverNo=" + derverno.value + "&MobileNo=" + mobileno.value, "驾证查询");
    }
}

//车辆年检
function SeachNJ(carno, cartype) {
    if (CheckCarNo(carno)) {
        window.open("/seach/SeachResultPage.aspx?QueryType=clnj&CarNo=" + encodeURIComponent(carno.value) + "&CarType=" + cartype.value, "车辆年检");
    }
}

//驾证年审
function SeachJZNS(derverno) {
    if (CheckDriverNo(derverno)) {
        window.open("/seach/SeachResultPage.aspx?QueryType=jzns&DriverNo=" + derverno.value, "驾证年审");
    }
}

// 铁路查询
function SeachTLCX(TLCX_Go, TLCX_To) {
    if (CheckIsNull(TLCX_Go) && CheckIsNull(TLCX_To)) {
        window.open("/seach/SeachResultPage.aspx?QueryType=tlcx&go=" + encodeURIComponent(TLCX_Go.value) + "&to=" + encodeURIComponent(TLCX_To.value), "铁路查询");
    }
}



//////////////新闻评论部分用的函数 开始/////////////
var tip = "我来评两句！";

function reply_clearfield(cid) {
    
    if ($("#" + cid).val() == tip) {
        $("#" + cid).val().empty();
    }
}

function reply_checksubmit(cid) {
alert(cid);
    var reply_recontent = $("#" + cid);
    if (reply_recontent.val() == tip || (reply_recontent.val()).length == 0) {
        alert('请填写内容');
        return false;
    }
    return true;
}

//限定文本框的最大输入长度
function isMaxLen(o) {
    var Restlen = 0;
    var curlen = o.value.length;
    var nMaxLen = o.getAttribute ? parseInt(o.getAttribute("maxlength")) : "";
    if (o.getAttribute && o.value.length > nMaxLen) {
        o.value = o.value.substring(0, nMaxLen)
    } else {
        Restlen = nMaxLen - curlen;
    }
    return Restlen;
}


//////////////新闻评论部分用的函数  结束//////////////
function ChangeImgBorder(obj) {
    //this.style.border="solid 1px #999";
    obj.onmouseover = function() {
        this.style.border = "solid 1px #ffc000";
    }
    obj.onmouseout = function() {
        this.style.border = "solid 1px #999";
    }
}
 
 
 
 
 
 
