﻿function DrawImage(ImgD, width_s, height_s) {
    var image = new Image();
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0) {
        flag = true;
        if (image.width / image.height >= width_s / height_s) {
            if (image.width > width_s) {
                ImgD.width = width_s;
                ImgD.height = (image.height * width_s) / image.width;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
        else {
            if (image.height > height_s) {
                ImgD.height = height_s;
                ImgD.width = (image.width * height_s) / image.height;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
    }
}

function p$(string) {
    document.write(string);
}
function getObjectById(id) {
    return document.getElementById(id);
}
function change_menu(id, content_id, num, total_ztc_menu, menu_on, menu_off) {
    for (var i = 1; i <= total_ztc_menu; i++) {
        getObjectById(id + i).className = menu_off;
        getObjectById(content_id + i).style.display = 'none';
    }
    getObjectById(id + num).className = menu_on;
    getObjectById(content_id + num).style.display = 'block';
}
//可修改区域
var imgWidth = 260;
var imgHeight =210;
var _timeOut_ = 5000;
var show_text = true; //是否显示焦点文字
var timeOut = _timeOut_;
var timeOut2 = _timeOut_ / 50; //onmouseout img后需要切换的时间
var now = 0;              //第一张图
var target = "_blank";   //打开方式
var button_on = 'on'; //当前焦点对应按钮的样式名
var button_off = ''; //非当前焦点对应按钮的样式名
//不可修改区域
var imgUrl = new Array();
var imgText = new Array();
var imgLink = new Array();
var imgAlt = new Array();
var menuList = new Array(); //菜单menu
var ver = 2; //兼容浏览器版本 默认2 为非ie
var firstTime = true;
var n = -1;

//    public string Images { get; set; }
//    public string NewsIds { get; set; }
//    public string NewsTitles { get; set; }
//    public string newCategories { get; set; }
var images = getObjectById("ctl01_MainContentPlaceHolder_HiddenImages").value;

var newsIds = getObjectById("ctl01_MainContentPlaceHolder_HiddenNewsIds").value;
var newsTitle = getObjectById("ctl01_MainContentPlaceHolder_HiddenNewsTitles").value; 
//var newsCategroy = '<%=newCategories %>';
var imageList =  images.split('|');
var newsIdList = newsIds.split('|');
var newsTitleList = newsTitle.split('|');

//var newsCategoryList = newsCategroy.split('|');

for (var i = 0; i < imageList.length - 1; i++) {
    menuList[++n] = newsTitle[i];
   //本机
  // imgUrl[n] = "/ExamCenterWeb" + imageList[i];
   imgUrl[n] =   imageList[i];
  // alert(imageList[i]);
   //   imgText[n] = '<ul style="list-style-type:none;margin:0;"><li style="font-size:12px;margin-left:20px;"><a href="~/Articles/article.aspx?c='+ newsCategoryList[i]+'&id='+ newsIdList[i] +'" ></a></li></ul>'
   //   imgLink[n] = '"~/Articles/article.aspx?c=' + newsCategoryList[i] + '&id=' + newsIdList[i] + '"';
   //imgText[n] = '<ul style="list-style-type:none;margin:0;"><li style="font-size:12px;margin-left:20px;"><a href="/Articles/imagenews.aspx?id=' + newsIdList[i] + '" ></a></li></ul>'
   imgText[n] = newsTitleList[i];
   imgLink[n] = '/Articles/ImageNews.aspx?id=' + newsIdList[i];
}
/*
//菜单menu
menuList[++n] = 'XX';
imgUrl[n] = 'Images/1297760505375.JPG';
imgText[n] = '<ul style="list-style-type:none;margin:0;"><li style="font-size:12px;margin-left:20px;"><a href="NewsMessage/News1.aspx"></a></li></ul>'
imgLink[n] = 'NewsMessage/News2.aspx';

//菜单menu
menuList[++n] = 'XX';
imgUrl[n] = 'Images/1232145816421.jpg';
imgText[n] = '<ul style="list-style-type:none;margin:0;"><li style="font-size:12px;margin-left:20px;"><a href="NewsMessage/News1.aspx"></a></li></ul>'
imgLink[n] = 'NewsMessage/News3.aspx';

//菜单menu
menuList[++n] = 'XX';
imgUrl[n] = 'Images/img9.jpg';
imgText[n] = '<ul style="list-style-type:none;margin:0;"><li style="font-size:12px;margin-left:20px;"><a href="NewsMessage/News1.aspx"></a></li></ul>'
imgLink[n] = 'NewsMessage/News4.aspx';

//菜单menu
menuList[++n] = 'XX';
imgUrl[n] = 'Images/img10.jpg';
imgText[n] = '<ul style="list-style-type:none;margin:0;"><li style="font-size:12px;margin-left:20px;"><a href="NewsMessage/News1.aspx"></a></li></ul>';
imgLink[n] = 'NewsMessage/News5.aspx';


//菜单menu
menuList[++n] = 'XX';
imgUrl[n] = 'Images/img11.jpg';
imgText[n] = '<ul style="list-style-type:none;margin:0;"><li style="font-size:12px;margin-left:20px;"><a href="NewsMessage/News1.aspx"></a></li></ul>'
imgLink[n] = 'NewsMessage/News6.aspx';
*/

var count = 0;
for (var i = 0; i < imgUrl.length; i++) {
    if ((imgUrl[i] != "") && (imgText[i] != "") && (imgLink[i] != "")) {
        count++;
    } else {
        break;
    }
}
//重写css
var each_width = Math.ceil((imgWidth - (count - 1)) / count);
var last_width = imgWidth - each_width * (count - 1) - (count) + 1;
function change() {
    if (ver == 1) {
        with (getObjectById('f_img').filters[0]) {
            Transition = 1;
            apply();
            play();
            //alert(imgText[now]);
        }
    }
    if (firstTime) { firstTime = false; timeOut = _timeOut_ / 2; }
    else {
        getObjectById('f_img').src = imgUrl[now];
        getObjectById('f_img').alt = imgText[now];//标题显示
        
        //当点击当前图片时
        getObjectById('f_imgLink').href = imgLink[now];
        //getObjectById('f_imgText').value = menuList[now];
        for (var i = 0; i < count; i++) {
            getObjectById('b' + i).className = "button";
            //getObjectById('f_menu' + i).className = "";
                   }
        getObjectById('b' + now).className = "on";
       // getObjectById('f_menu'+now).className="on";
        now = (now >= imgUrl.length - 1) ? 0 : now + 1;
        timeOut = _timeOut_;
    }
    theTimer = setTimeout("change()", timeOut);
}

//滚动文字
//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 } 
//};

function b_change(num) {

    window.clearInterval(theTimer);
    now = num;
    firstTime = false;
    change();
}
//draw 渐变line （即css:f_line)
function draw_line() {
    var div = document.createElement("div");
    div.id = 'f_line';
    getObjectById('f_infoDiv').insertBefore(div, getObjectById('f_infoDiv').childNodes.item(0));
}
//表现层 start
//图片
var a = document.createElement("a");
a.id = "f_imgLink";
a.target = target;
a.href = imgLink[now];


getObjectById('f_imgDiv').appendChild(a);
var img = document.createElement("img");
img.id = "f_img";
img.width = imgWidth;
img.height = imgHeight;
img.src = imgUrl[now];
img.alt = imgText[now];
DrawImage(img, 260, 210);
a.appendChild(img);
//数字按钮
for (var i = count - 1; i >= 0; i--) {
    var div_bg = document.createElement("div");
    div_bg.id = 'div_bg' + i;
    div_bg.className = 'bg';
    getObjectById('f_buttonDiv').appendChild(div_bg);
    var a = document.createElement("a");
    a.id = 'b' + i;
    a.className = (i == now + 1) ? "button_on" : "button_off";
    a.innerHTML = i + 1;
    a.href = 'javascript:b_change(' + i + ')';
    getObjectById('div_bg' + i).appendChild(a);
    var div = document.createElement("div");
    getObjectById('f_buttonDiv').appendChild(div);
}
try {  //滤镜版本
    new ActiveXObject("DXImageTransform.Microsoft.Fade");
    getObjectById('f_img').filters[0].play();
    ver = 1;
    draw_line();
}
catch (e) { ver = 2; }
var theTimer = setTimeout("change()", _timeOut_ / 1000);
//表现层 end
getObjectById('f_img').onmouseover = function() { window.clearInterval(theTimer); }
getObjectById('f_img').onmouseout = function() { theTimer = setTimeout("change()", timeOut2); }















