﻿$(function () {
    setscrollImg("scrollbox", 3000);
    setformdatatextboxlength(50);
    BindTab();
});

function setscrollImg(boxid, delay) {
    var timer = 1;
    var turnShow = function (u, d) {
        u.fadeIn();
        timer = setTimeout(function () {
            u.fadeOut(200, function () {
                if (u.next().length > 0)
                    turnShow(u.next(), d);
                else
                    turnShow($("#scrollbox li:first"), d);
            });
        }, delay);
    };
    turnShow($("#" + boxid + " li:first"), delay);
    $("#" + boxid).hover(
    function () { clearTimeout(timer);},
    function () { turnShow($(this).children(":visible"), delay) }
);
}

function BindTab() {
    $(".tab").each(function () {
        $(this).hover(
        function () {
            var tabover = $(this).parent().children(".over");
            tabover.removeClass("over"); tabover.addClass("blur");
            $("#" + tabover.attr("contentid")).hide();
            $(this).removeClass("blur"); $(this).addClass("over");
            $("#" + $(this).attr("contentid")).show();
        }
        );
    });
}

function setformdatatextboxlength(l) {
    $(".FormTable input:text").each(function () { $(this).attr("maxlength", l); });
}

function checksearchbox(searchbox) {
    if ($.trim(searchbox.value) == searchbox.defaultValue || $.trim(searchbox.value) == "") return false;
}
function focussearch(searchbox) {
    if ($.trim(searchbox.value) == searchbox.defaultValue) $(searchbox).val("");
}
function blursearch(searchbox) {
    if ($.trim(searchbox.value) == "") $(searchbox).val(searchbox.defaultValue);
}

function ajaxsaveformdata() {
    if (checkinput_liuyan() != false) {
        $.post($("#WithoutSearchForm").attr("action"), $("#WithoutSearchForm").serialize(), function (data) {
            alert("信息提交成功，我们会及时回复，即将回到首页"); window.location = "/";
        });
    }
}

function checkinput_liuyan() {
    if ($("input[name='Contact1']").val() == "" || $("input[name='Contact2']").val() == "" || $("input[name='Content2']").val() == "") {
    alert("请填写完整必填项目");return false;
}
return confirm("确定填写完整并提交？");
}

function loadpage(refreshholderid, ajaxhref) {
    $("#" + refreshholderid).load(ajaxhref);
}
