﻿var loding = "<div class='load'/>";

var OnLogin;
var OnLoginOut;
var Login = function() {
    user = $("#Username").val();
    pwd = $("#Password").val();
    save = $("#isSave")[0].checked;
    if (user == '' || pwd == '' || user == '网校号或邮箱') {
        alert("用户名或密码不能为空");
        return;
    } else {
        $("#login_form").html(loding);
        $.post("/User.data", { 'Username': user, 'Password': pwd, 'isSave': save }, function(data) { if (OnLogin != undefined) { OnLogin(data); } else { $("#login_form").html(data) } });
    }
}

var LoginOut = function() {
    $("#login_form").html(loding);
    $.post("/User.data", { 'LoginOut': 'true' }, function(data) { if (OnLoginOut != undefined) { OnLoginOut(data); } else { $("#login_form").html(data) } });
}


var TimeSpan = $("#Time");
var Now;
function showTime() {
    Now = new Date();
    TimeSpan.html(Now.format("今天是 yyyy年MM月dd日 星期" + week[Now.getDay()] + " hh:mm "));
    window.setTimeout("showTime()", 60000);
}
showTime();

$(document).ready(function() {
    $("#login_form").html(loding);
    $("#login_form").load("/User.data");
    Logo();
    menusss();
    $("#Log").load("/Log.data");
});

function getID(swfID) { return window[swfID] || document[swfID]; }
var Variable = {};
function Write() {
    var Logo = new SWFObject("/flash/LogoS.swf", "Logo", "960", "200", "9.0.0", "/flash/expressInstall.swf");
    $.each(Variable, function(k, v) { Logo.addVariable(k, v) });
    Logo.addParam("wmode", "transparent");
    Logo.write('LogoDiv');
}

function Logo() {
    if ($("#LogoDiv").length != 0) {
        $.getJSON("/Logo.GetInfo.data", function(data) {
            Variable = data;
            $.each(Variable, function(k, v) { $("#" + k).val(v); })
            Write();
        })
    }
}

/*主导航*/
var time = null;
var menuobj;
function menu() {
    $("#top_nav > li").removeClass("hover");
    $(menuobj).addClass("hover");
    $(menuobj).children("ul").show()
}



function menusss() {

    $("#top_nav > li").hover(
	function() {
	    menuobj = this;
	    time = window.setTimeout("menu()", 500);
	},
	function() {
	    if (time != null) window.clearTimeout(time);
	    $(this).removeClass("hover");
	    $("#top_nav ul").hide();
	});

    $("#top_nav ul").hover(function() { $(this).show() }, function() { $(this).hide() });

}

function tovote(id) {
    //1.3.2
    if ($('input[name=VoteOption]:checked').length < 1) {
        alert('请选择投票项');
    }
    else {
        var v = '';
        $('input[name=VoteOption]:checked').each(function() { if (v != '') { v += ',' } v += $(this).val() });

        window.open('/vote.data?id=' + id + '&vote=' + v, '', 'height=300, width=520, top=100, left=200, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no')
    }

    //1.2.6
    /*
    if($('input[@name=VoteOption][@checked]').length<1)
    {
    alert('请选择投票项');
    }
    else
    {
    var v='';
    $('input[@name=VoteOption][@checked]').each(function(){if(v!=''){v+=','} v+=$(this).val()});
        
    window.open('/vote.data?id='+id+'&vote='+v,'','height=300, width=520, top=100, left=200, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no')
    }
    */
}

function vote() {
    window.open('/vote.data?vote=-1', '', 'height=300, width=520, top=100, left=200, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no');
}


function validCategoryPsw(info) {
    info.PSW = $("#txtPsw").val();
    debugger;
    $.post("/Categorys.ValidePassword.data", info, function(data) {
        debugger;
        if (data == "error") {
            alert("密码错误");
        } else {
            if (data == "") {
                callbackFun();                
            }
            else {
                eval(data);
            }
        }
    })
}
function callbackFun() { location.reload(); };

Page = {};
Page.Server = {
    SetActiveAnchor: function() {
            var url = window.location.href.toLowerCase();
            var atag = url.substr(url.lastIndexOf("#"));
            $("ul.kf li").each(function(i) {
                $(this).removeClass("active");
                if ($(this).find('a').attr("href").toLowerCase() == atag) {
                    $(this).addClass("active");
                }
            })
        }
    }
document.write('<scr' + 'ipt type="text/javascript" src="http://tongji.30edu.com/JS.aspx" onerror="alert(\'Error loading \' + this.src);"><\/scr' + 'ipt>');