﻿var $j = jQuery.noConflict();
$j(document).ready(function() {
    init();
});

function HeadtabDiv(n) {
    if (n == 1) {
        $j("#headlist1").addClass("current");
        $j("#headlist2").removeClass("current");
        $j("#heada_1").show();
        $j("#heada_2").hide();
    }
    if (n == 2) {
        $j("#headlist1").removeClass("current");
        $j("#headlist2").addClass("current");
        $j("#heada_1").hide();
        $j("#heada_2").show();
    }
}

var HoverLiId = null;
function init() {
    if (CheckURL("index") != -1) {
        HoverLiId = "nav" + 0;
        setclass(HoverLiId);
    }
    else if (CheckURL("advsearch.aspx") != -1) {
        HoverLiId = "nav" + 2;
        setclass(HoverLiId);
    }
    else if (CheckURL("currentnews.aspx") != -1) {
        HoverLiId = "nav" + 2;
        setclass(HoverLiId);
    }
    else if (CheckURL("newlist.aspx") != -1) {
        HoverLiId = "nav" + 2;
        setclass(HoverLiId);
    }
    else if (CheckURL("present.aspx") != -1) {
        HoverLiId = "nav" + 1;
        setclass(HoverLiId);
    }
    else if (CheckURL("createaccount.aspx") != -1) {
        HoverLiId = "nav" + 3;
        setclass(HoverLiId);
    }
    else if (CheckURL("modifyaccount.aspx") != -1) {
        HoverLiId = "nav" + 3;
        setclass(HoverLiId);
    }
    else if (CheckURL("confirmmail.aspx") != -1) {
        HoverLiId = "nav" + 3;
        setclass(HoverLiId);
    }
    else {
        HoverLiId = null;
        setclass(HoverLiId);
    }
}
function setclass(id) {
    jQuery("#Navigate").find("LI").removeClass("current");
    if (id != null) {
        document.getElementById(id).className = "current";
    }

}

//匹配字符串
function CheckURL(urlname) {
    var url = window.location.toString();
    var i = url.lastIndexOf("/");
    return url.substring(i + 1, url.length).toString().toLowerCase().indexOf(urlname)
}


///同域名下IFRAME自适应高度
function SetCwinHeight(id) {
    var iframeid = document.getElementById(id); //iframe id
    if (document.getElementById) {
        if (iframeid && !window.opera) {
            if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight) { iframeid.height = iframeid.contentDocument.body.offsetHeight; }
            else if (iframeid.Document && iframeid.Document.body.scrollHeight) { iframeid.height = iframeid.Document.body.scrollHeight; }
        }
    }
}
