﻿
function titleCateMouseOver(id)
{
    $("DlC" + id).className = "li_over";
}

function titleCateMouseOut(id)
{
    var val = $("DlCateDiv").getAttribute("va");
    if (val == id.toString()) //当前选中的类别
    {
        $("DlC" + id).className = "li_select";
    }
    else
    {
        $("DlC" + id).className = "li_span";
    }
}

function changeCate(id)
{
    var val = $("DlCateDiv").getAttribute("va");
    $("DlC" + val).className = "li_span"; //这里设置颜色是为了区分，添加className后去掉
    $("DlC" + id).className = "li_select";
    $("DlCateDiv").setAttribute("va", id);
    
    if (id == "0")
    {
        ResList.v.CategoryID = "0";
        ResList.v.ColorID = null;
        ResList.render();

        CateView.v.InfoID = null;
//        CateView.render();
    }
    else
    {
        ResList.v.CategoryID = id.toString();
        ResList.v.ColorID = null;
        ResList.render();

        CateView.v.InfoID = id.toString();
//        CateView.render();
    }
}

function searchResource()
{
    window.open("Search.aspx?TypeID=" + $("S_Cate").getAttribute("val") + ($V("S_Key").trim() != "" ? ("&Key=" + escape($V("S_Key").trim())) : ""));
}

ResList.doAction = function(actionIndex, actionName, index, id)
{
    if (actionIndex == 0)
    {
        if (id == "0")
        {
            ResList.v.CategoryID = "0";
            ResList.v.ColorID = null;
            ResList.render();

            CateView.v.InfoID = null;
//            CateView.render();
        }
        else
        {
            ResList.v.CategoryID = id.toString();
            ResList.v.ColorID = null;
            ResList.render();

            CateView.v.InfoID = id.toString();
//            CateView.render();
        }
    }
}

function clickFirCate(id)
{
    ResList.v.CategoryID = id.toString();
    ResList.v.ColorID = null;
    ResList.render();

    CateView.v.InfoID = id.toString();
//    CateView.render();
}

function cliclSecCate(fid, sid)
{
    ResList.v.CategoryID = fid.toString();
    ResList.v.ColorID = sid.toString();
    ResList.render();
}

function initPage()
{
    var old = $("InitCate").value;
    var tar = $("DlC" + old);
    if (old != null && old != "" && tar)
    {
        var val = $("DlCateDiv").getAttribute("va");
        $("DlC" + val).className = "li_span";
        tar.className = "li_select";
        $("DlCateDiv").setAttribute("va", old);
    }
}

function setLocation()
{
    var expdate = new Date();
    expdate = expdate.addDays(7);
    Cookies.setValue("LastLocation", window.location.href, expdate);
}

function onKeyEnterDown(event)
{
    event = window.event || event;
    if (event.keyCode == 13)
    {
        event.keyCode = 9;
        searchResource();
    }
}

/////////////////////////////

function SetAlpha()
{
    if (document.all)
    {
        if (oi.filters && oi.filters.Alpha) oi.filters.Alpha.opacity = opacity;
    }
    else
    {
        oi.style.opacity = ((opacity >= 100) ? 99 : opacity) / 100;
    }
}

function ImgSwitch(id, p)
{
    if (p)
    {
        pause = true;
        opacity = 100;
        SetAlpha();
    }
    oi.src = imgs[id].src;
    document.getElementById("dlink").href = links[id];
    document.getElementById("it" + lastid).className = "off";
    document.getElementById("it" + id).className = "on";
    document.getElementById("titnv").innerHTML = "<b>" + tits[id] + "</b>";
    curid = lastid = id;
}

function ScrollImg(direc)
{
    if (pause && opacity >= 100) return;
    if (sw == 0)
    {
        opacity += 2;
        if (opacity > delay) { opacity = 100; sw = 1; }
    }
    if (sw == 1)
    {
        opacity -= 3;
        if (opacity < 10) { opacity = 10; sw = 3; }
    }
    SetAlpha();
    if (sw != 3) return;
    sw = 0;
    if (direc)
    {
        curid--;
    }
    else
    {
        curid++;
    }

    if (curid >= links.length) curid = 0;
    if (curid <0 ) curid = links.length - 1;
    ImgSwitch(curid, false);
}

function Pause(s)
{
    pause = s;
}

function StartScroll()
{
    setInterval(ScrollImg, speed);
}

function CheckLoad()
{
    if (imgs[0].complete == true && imgs[1].complete == true)
    {
        clearInterval(checkid);
        setTimeout(StartScroll, 5000);
    }
}


function pagePicPreOver()
{
    $("PicPre").className = "pre_page_over";
}

function pagePicPreOut()
{
    $("PicPre").className = "next_page";
}

function pagePicNextOver()
{
    $("PicNext").className = "next_page_over";
}

function pagePicNextOut()
{
    $("PicNext").className = "next_page";
}

function pagePicPreClick()
{
    ScrollImg(true);
}

function pagePicNextClick()
{
    ScrollImg();
}

var oi = $("dimg");   
var pause = false;   
var curid = 0;   
var lastid = 0;   
var sw = 1;   
var opacity = 100;   
var speed = 30;   
var delay = (document.all)? 400:400;

var checkid = setInterval(CheckLoad, 10); 

initPage();
