﻿
/***************领导图片轮显*****************/
function reapply(){
		setTimeout("slideit()",2000)
		return true
}
window.onerror=reapply
var image1=new Image()
image1.src="../imgnew/郭有明.jpg"
var image2=new Image()
image2.src="../imgnew/张建一.jpg"
var image4=new Image()
image4.src="../imgnew/周厚贵.jpg"
var image5=new Image()
image5.src="../imgnew/艾苍松.jpg"
var image6=new Image()
image6.src="../imgnew/吴开保.jpg"
var image7=new Image()
image7.src="../imgnew/谭春玉.jpg"
var image8=new Image()
image8.src="../imgnew/邹正金.jpg"
var image9=new Image()
image9.src="../imgnew/谢永和.jpg"

////change number of images below 
var number_of_images = 9
//change speed below (in seconds)
var speed = 20
var step = 1
var whichimage = 1
function slideit() {
    if (!document.images)
        return
    if (document.all)
        //document.getElementById("slide").filters.blendTrans.apply()
        document.getElementById("slide").src = eval("image" + step + ".src")
    if (document.all)
        //document.getElementById("slide").filters.blendTrans.play()
    whichimage = step
    if (step < number_of_images)
        step++
    else
        step = 1
    if (document.all)
        setTimeout("slideit()", speed * 1000 + 3000)
    else
        setTimeout("slideit()", speed * 1000)
}
function slidelink() {
    if (whichimage == 1)
        window.open("http://www.yichang.gov.cn/col/col249/index.html");
    else if (whichimage == 2)
        window.open("http://www.yichang.gov.cn/col/col262/index.html")
    else if (whichimage == 3)
        window.open("http://www.yichang.gov.cn/col/col263/index.html")
    else if (whichimage == 4)
        window.open("http://www.yichang.gov.cn/col/col264/index.html")
    else if (whichimage == 5)
        window.open("http://www.yichang.gov.cn/col/col265/index.html")
    else if (whichimage == 6)
        window.open("http://www.yichang.gov.cn/col/col266/index.html")
    else if (whichimage == 7)
        window.open("http://www.yichang.gov.cn/col/col267/index.html")
    else if (whichimage == 8)
        window.open("http://www.yichang.gov.cn/col/col268/index.html")
    else if (whichimage == 9)
        window.open("http://www.yichang.gov.cn/col/col14605/index.html")
}
/**************领导图片轮显结束**************/


/**************中间图片轮显**************/
function $(id) { return document.getElementById(id); }

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

var s = function() {
    var interv = 2000; //切换间隔时间
    var interv2 = 10; //切换速速
    var opac1 = 80; //文字背景的透明度
    var source = "fade_focus" //焦点轮换图片容器的id名称
    //获取对象
    function getTag(tag, obj) {
        if (obj == null) {
            return document.getElementsByTagName(tag)
        }
        else {
            return obj.getElementsByTagName(tag)
        }
    }
    function getid(id) {
        return document.getElementById(id)
    };
    var opac = 0, j = 0, t = 63, num, scton = 0, timer, timer2, timer3;
    var id = getid(source);
    id.removeChild(getTag("div", id)[0]);
    var li = getTag("li", id);
    var div = document.createElement("div");
    var title = document.createElement("div");
    var span = document.createElement("span");
    var button = document.createElement("div");
    button.className = "button";
    for (var i = 0; i < li.length; i++) {
        var a = document.createElement("a");
        a.innerHTML = i + 1;
        a.onclick = function() {
            clearTimeout(timer);
            clearTimeout(timer2);
            clearTimeout(timer3);
            j = parseInt(this.innerHTML) - 1;
            scton = 0; t = 63; opac = 0; fadeon();
        };
        a.className = "b1";
        a.onmouseover = function() { this.className = "b2" };
        a.onmouseout = function() { this.className = "b1"; sc(j) };
        button.appendChild(a);
    }
    //控制图层透明度
    function alpha(obj, n) {
        if (document.all) {
            obj.style.filter = "alpha(opacity=" + n + ")";
        }
        else {
            obj.style.opacity = (n / 100);
        }
    }
    //控制焦点按钮
    function sc(n) {
        for (var i = 0; i < li.length; i++) {
            button.childNodes[i].className = "b1"
        };
        button.childNodes[n].className = "b2";
    }
    title.className = "num_list";
    title.appendChild(span);
    alpha(title, opac1);
    id.className = "d1";
    div.className = "d2";
    id.appendChild(div);
    id.appendChild(title);
    id.appendChild(button);
    //渐显
    var fadeon = function() {
        opac += 5; div.innerHTML = li[j].innerHTML; span.innerHTML = getTag("img", li[j])[0].alt; alpha(div, opac);
        if (scton == 0) {
            sc(j);
            num = -2;
            scrolltxt();
            scton = 1
        };
        if (opac < 100) {
            timer = setTimeout(fadeon, interv2)
        }
        else {
            timer2 = setTimeout(fadeout, interv);
        };
    }
    //渐隐
    var fadeout = function() {
        opac -= 5; div.innerHTML = li[j].innerHTML; alpha(div, opac);
        if (scton == 0) {
            num = 2; scrolltxt(); scton = 1
        };
        if (opac > 0) {
            timer = setTimeout(fadeout, interv2)
        }
        else {
            if (j < li.length - 1) {
                j++
            }
            else {
                j = 0
            };
            fadeon()
        };
    }
    //滚动文字
    var scrolltxt = function() {
        t += num; span.style.marginTop = t + "px";
        if (num < 0 && t > 3) {
            timer3 = setTimeout(scrolltxt, interv2)
        }
        else if (num > 0 && t < 62) {
            timer3 = setTimeout(scrolltxt, interv2)
        }
        else {
            scton = 0
        }
    };
    fadeon();
}
//初始化
window.onload = s;

function moveElement(elementID, final_x, final_y, interval) {
    if (!document.getElementById) return false;
    if (!document.getElementById(elementID)) return false;
    var elem = document.getElementById(elementID);
    if (elem.movement) {
        clearTimeout(elem.movement);
    }
    if (!elem.style.left) {
        elem.style.left = "0px";
    }
    if (!elem.style.top) {
        elem.style.top = "0px";
    }
    var xpos = parseInt(elem.style.left);
    var ypos = parseInt(elem.style.top);
    if (xpos == final_x && ypos == final_y) {
        return true;
    }
    if (xpos < final_x) {
        var dist = Math.ceil((final_x - xpos) / 10);
        xpos = xpos + dist;
    }
    if (xpos > final_x) {
        var dist = Math.ceil((xpos - final_x) / 10);
        xpos = xpos - dist;
    }
    if (ypos < final_y) {
        var dist = Math.ceil((final_y - ypos) / 10);
        ypos = ypos + dist;
    }
    if (ypos > final_y) {
        var dist = Math.ceil((ypos - final_y) / 10);
        ypos = ypos - dist;
    }
    elem.style.left = xpos + "px";
    elem.style.top = ypos + "px";
    var repeat = "moveElement('" + elementID + "'," + final_x + "," + final_y + "," + interval + ")";
    elem.movement = setTimeout(repeat, interval);
}

function classNormal(iFocusBtnID, iFocusTxID) {
    var iFocusBtns = $(iFocusBtnID).getElementsByTagName('li');
    var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
    for (var i = 0; i < iFocusBtns.length; i++) {
        iFocusBtns[i].className = 'normal';
        iFocusTxs[i].className = 'normal';
    }
}

function classCurrent(iFocusBtnID, iFocusTxID, n) {
    var iFocusBtns = $(iFocusBtnID).getElementsByTagName('li');
    var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
    iFocusBtns[n].className = 'current';
    iFocusTxs[n].className = 'current';
}

function iFocusChange() {
    if (!$('ifocus')) return false;
    $('ifocus').onmouseover = function() { atuokey = true };
    $('ifocus').onmouseout = function() { atuokey = false };
    var iFocusBtns = $('ifocus_btn').getElementsByTagName('li');
    var listLength = iFocusBtns.length;
    iFocusBtns[0].onmouseover = function() {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
    if (listLength >= 2) {
        iFocusBtns[1].onmouseover = function() {
            moveElement('ifocus_piclist', 0, -225, 5);
            classNormal('ifocus_btn', 'ifocus_tx');
            classCurrent('ifocus_btn', 'ifocus_tx', 1);
        }
    }
    if (listLength >= 3) {
        iFocusBtns[2].onmouseover = function() {
            moveElement('ifocus_piclist', 0, -450, 5);
            classNormal('ifocus_btn', 'ifocus_tx');
            classCurrent('ifocus_btn', 'ifocus_tx', 2);
        }
    }
    if (listLength >= 4) {
        iFocusBtns[3].onmouseover = function() {
            moveElement('ifocus_piclist', 0, -675, 5);
            classNormal('ifocus_btn', 'ifocus_tx');
            classCurrent('ifocus_btn', 'ifocus_tx', 3);
        }
    }
}

setInterval('autoiFocus()', 5000);
var atuokey = false;
function autoiFocus() {
    if (!$('ifocus')) return false;
    if (atuokey) return false;
    var focusBtnList = $('ifocus_btn').getElementsByTagName('li');
    var listLength = focusBtnList.length;
    for (var i = 0; i < listLength; i++) {
        if (focusBtnList[i].className == 'current') var currentNum = i;
    }
    if (currentNum == 0 && listLength != 1) {
        moveElement('ifocus_piclist', 0, -225, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 1);
    }
    if (currentNum == 1 && listLength != 2) {
        moveElement('ifocus_piclist', 0, -450, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 2);
    }
    if (currentNum == 2 && listLength != 3) {
        moveElement('ifocus_piclist', 0, -675, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 3);
    }
    if (currentNum == 3) {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
    if (currentNum == 1 && listLength == 2) {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
    if (currentNum == 2 && listLength == 3) {
        moveElement('ifocus_piclist', 0, 0, 5);
        classNormal('ifocus_btn', 'ifocus_tx');
        classCurrent('ifocus_btn', 'ifocus_tx', 0);
    }
}
addLoadEvent(iFocusChange);
addLoadEvent(slideit);



