﻿//当前显示的
var showed=0;
var paused=0;
//当前选择的
var selected=0;
//图片数量
var arr_length=0;
//数字顶部到图片底部的距离，越大越靠上。
var num_bottom="23";
//数字距离图片右边的距离，越大越靠左。
var num_right="5";
//数字模块高度
var num_height="30";
//数字的大小
var num_font_size="12"; 
//数字的颜色
var num_color="#D94B01";
//数字的底色
var num_background_color="#FCF2CF";
//鼠标经过高亮
var num_background_highlight="#FFB442";

/*
displaye
显示轮播图片模块

	cycle：时间间隔
	height：高度
	width：宽度
	image：包含图片路径的字符串数组
	description：包含表述文字的字符串数组
	link：包含链接地址的字符串数组
	target：包含打开方式的字符串数组

*/
function showad(cycle,height,width,image,link,target){
	arr_length=image.length;
	r_cycle=cycle;
	document.write("<div id=\"cycle_image\" style=\"width:"+width+"px; height:"+height+"px; position:relative;\">");
		if(undefined==target){
			target="_blank";
		}
		//图片模块
		for(var i=0;i<image.length;i++){
			document.write("<div id=\"img"+i+"\" style=\"display:none;filter:alpha(opacity=0);opacity:0;overflow:hidden; width:"+width+"px;height:"+height+"px; top:0px;left:0px;position:absolute;\">");
				document.write("<a href=\""+link[i]+"\" target=\""+target+"\">");
				document.write("<img src=\""+image[i]+"\" id=\"imgs"+i+"\" border=0 />");
				document.write("</a>");
			document.write("</div>");
		}
		//数字模块
		document.write("<div id=\"num\" style=\"height:"+num_height+"px; top:"+(height-num_bottom)+"px;right:"+num_right+"px; position:absolute;\">");
			for(var i=0;i<image.length;i++){
				document.write("<span id=\""+i+"\" style=\"font-size:"+num_font_size+"px; border:1px "+num_color+" solid ;cursor:pointer;background-color:"+num_background_color+";color:"+num_color+";display:block;float:left;margin-bottom:2px;padding:1px 5px;margin-left:3px;\" onclick=\"mClick(this)\" onMouseOver=\"mOver(this);\" onMouseOut=\"mOut(this);\">");
					document.write(i+1);
				document.write("</span> ");
			}
		document.write("</div>");
	document.write("</div>");
	//初始化
	document.getElementById("img"+showed).style.filter="alpha(opacity=100)";
	document.getElementById("img"+showed).style.opacity=1;
	document.getElementById("img"+showed).style.display="block";
	//document.getElementById("description"+showed).style.opacity=des_opacity;
	//document.getElementById("description"+showed).style.filter="alpha(opacity="+des_filter+")";
	document.getElementById(showed).style.color=num_background_color;
	document.getElementById(showed).style.background=num_color;
	document.getElementById(showed).style.border="1px "+num_background_color+" solid";
	//延时
	setInterval("timeout()",r_cycle*1000);
}

/* mOver鼠标经过加亮*/
function mOver(object){	paused=1;mClick(object); }

/* mOut 鼠标经过恢复 */
function mOut(object){	paused = 0;
	if(showed!=object.id){

	object.style.background=num_background_color;
	object.style.color=num_color;
	}
}

/* mClick 鼠标点击 */
function mClick(object){
	selected=object.id;
	if(showed!=selected){
	//隐藏当前显示的内容
	document.getElementById(showed).style.border="1px "+num_color+" solid";
	document.getElementById(showed).style.background=num_background_color;
	document.getElementById(showed).style.color=num_color;
	document.getElementById("img"+showed).style.opacity=0;
	document.getElementById("img"+showed).style.filter="alpha(opacity=0)";
	document.getElementById("img"+showed).style.display="none";
	//document.getElementById("description"+showed).style.opacity=0;
	//document.getElementById("description"+showed).style.filter="alpha(opacity=0)";
	//显示当前选择的内容	
	document.getElementById("img"+selected).style.opacity=1;
	document.getElementById("img"+selected).style.filter="alpha(opacity=100)";
	document.getElementById("img"+selected).style.display="block";
	//document.getElementById("description"+selected).style.filter="alpha(opacity="+des_filter+")";
	//document.getElementById("description"+selected).style.opacity=des_opacity;
	document.getElementById(selected).style.background=num_color;
	document.getElementById(selected).style.color=num_background_color;
	document.getElementById(selected).style.border="1px "+num_background_color+" solid";
	//置换当前显示为当前选择
	showed=selected;
	}
}
/* timeout 定时执行的动作 */
function timeout(){
	if(paused == 1)
		return;
	if(selected<arr_length-1){
	selected++;
	mClick(document.getElementById(selected));
	}else{
	selected=0;
	mClick(document.getElementById(selected));
	}
}

