﻿////////////////////microajax//////////////////////////
function microAjax(B, A) { this.bindFunction = function (E, D) { return function () { return E.apply(D, [D]) } }; this.stateChange = function (D) { if (this.request.readyState == 4) { this.callbackFunction(this.request.responseText) } }; this.getRequest = function () { if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP") } else { if (window.XMLHttpRequest) { return new XMLHttpRequest() } } return false }; this.postBody = (arguments[2] || ""); this.callbackFunction = A; this.url = B; this.request = this.getRequest(); if (this.request) { var C = this.request; C.onreadystatechange = this.bindFunction(this.stateChange, this); if (this.postBody !== "") { C.open("POST", B, true); C.setRequestHeader("X-Requested-With", "XMLHttpRequest"); C.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); C.setRequestHeader("Connection", "close") } else { C.open("GET", B, true) } C.send(this.postBody) } };
/////////////////导航菜单//////////////////////
var indexsupportmenu = 0;
$(document).ready(function () {

    $("ul.topnav li a").mouseover(function () { //When trigger is clicked...

        //Following events are applied to the subnav itself (moving subnav up and down)
        $(this).parent().find("DIV.divSubNav").slideDown('fast').show(); //Drop down the subnav on click

        $(this).parent().hover(function () {
        }, function () {
            $(this).parent().find("DIV.divSubNav").hide(); //When the mouse hovers out of the subnav, move it back up
        });

        //Following events are applied to the trigger (Hover events for the trigger)
    }).parent().hover(function () {

        if ($(this).find("div.divSubNav").length > 0) {
            if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style)
                $(this).addClass("ie6subhover"); //On hover over, add class "subhover"
            else
                $(this).addClass("subhover");
        }
        else {
            if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style)
                $(this).addClass("ie6subhoverone"); //On hover over, add class "subhover"
            else
                $(this).addClass("subhoverone");
        }
    }, function () {
        if ($(this).find("div.divSubNav").length > 0) {
            if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style)
                $(this).removeClass("ie6subhover"); //On hover over, add class "subhover"
            else
                $(this).removeClass("subhover");
        }
        else {
            if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style)
                $(this).removeClass("ie6subhoverone"); //On hover over, add class "subhover"
            else
                $(this).removeClass("subhoverone");
        }
    });



    var list = $("DIV.divSubNav");

    var pathArray = [140, 140, 140];

    for (var i = 0; i < list.length; i++) {
        list[i].style.width = pathArray[i];

        $(list[i]).addClass("divSubNavie6");
    }


    //左侧菜单
    $(".l_menuleft .l_menu").hover(function () {
        $(this).addClass("l_menuover");
    }, function () {
        $(this).removeClass("l_menuover");
    });

    //左侧菜单子菜单
    var subtitle = $(".questiontype .divsubmenutitle");
    $(subtitle[indexsupportmenu]).addClass("divsubmenutitleover");

    $(".questiontype .divsubmenutitle").click(function () {



        var link = $(this).attr('data_link');
        if (link)
            window.location.href = "/" + link;
        else {
            var listmenu = $(".questiontype .divsubmenutitle");
            for (var i = 0; i < listmenu.length; i++) {
                if (i == indexsupportmenu)
                    $(listmenu[i]).addClass("divsubmenutitleover");
                else
                    $(listmenu[i]).removeClass("divsubmenutitleover");
            } 
        }
    }).hover(function () {
        
          var listmenu = $(".questiontype .divsubmenutitle");
          for (var i = 0; i < listmenu.length; i++) 
            $(listmenu[i]).removeClass("divsubmenutitleover");

        $(this).addClass("divsubmenutitleover");
    }, function () {
        var listmenu = $(".questiontype .divsubmenutitle");
        for (var i = 0; i < listmenu.length; i++) {
            if (i == indexsupportmenu)
                $(listmenu[i]).addClass("divsubmenutitleover");
            else
                $(listmenu[i]).removeClass("divsubmenutitleover");
        }

//        if ($(this)[0].id != "divsupportmenu_" + indexsupportmenu)
//            $(this).removeClass("divsubmenutitleover");
    });

});


function ChangeBg(obj) {
    if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style)
        obj.style.background = 'url(/Content/Img/navsubtitlearror.gif) no-repeat 6px 4px';
    else
        obj.style.background = 'url(/Content/Img/navsubtitlearror.png) no-repeat 6px 0px';

    getFirstChild(obj).style.color = "#FF8522";
}
function ChangeBack(obj) {
    obj.style.background = '';
    getFirstChild(obj).style.color = "#5b5b5b";
}

//////////////////首页播放图片控件//////////////////////
var _c = _h = 0;
$(function () {
    $('#play > a').click(function () {
        var i = $(this).attr('alt') - 1;
        clearInterval(_h);
        _c = i;
        play();
        change(i);
    })
    $("#pic img").hover(function () { clearInterval(_h) }, function () { play() });

    var imgSrc = $("#pic img").eq(0).attr('data-src');
    $("#pic img").eq(0).attr('src', imgSrc);

    play();
})
function play() {
    _h = setInterval("auto()", 10000);
}
function change(i) {
    if ($('#play > a').get(i) == null) 
        _c = i = 0;


    var Src = $("#pic img").eq(i).attr('src');
    if (Src == "" || Src == undefined) {
        var imgSrc = $("#pic img").eq(i).attr('data-src');
        $("#pic img").eq(i).attr('src', imgSrc);
    }


    $('#play > a').css('background-color', '#fff').eq(i).css('background-color', '#cdcdcd').blur();
    $("#pic img").hide().eq(i).fadeIn('slow');
}
function auto() {    
    _c =  _c + 1;
    change(_c);
}


//服务支持
function getFirstChild(obj) {
    var result = obj.firstChild;
    while (!result.tagName) {
        result = result.nextSibling;
    }
    return result;
} 


function getCookie(objName) {
    var arrStr = document.cookie.split("; ");
    for (var i = 0; i < arrStr.length; i++) {
        var temp = arrStr[i].split("=");
        if (temp[0] == objName) return unescape(temp[1]);
    }
}

function navshow(id) {
    var sub = document.getElementById("submenu" + id);
    if (sub)
        sub.style.display = "block";
    document.getElementById("menu" + id).style.backgroundImage = 'url(/Content/Img/navback.jpg)';
}

function navhidden(id) {
    var sub = document.getElementById("submenu" + id);
    if (sub)
        sub.style.display = "none";
    document.getElementById("menu" + id).style.backgroundImage = '';
}


function getRadioBoxValue(radioName) {
    var obj = document.getElementsByName(radioName);             //这个是以标签的name来取控件 
    for (i = 0; i < obj.length; i++) {

        if (obj[i].checked) {
            return obj[i].value;
        }
    }
    return "undefined";
}  
