function QueryString()
{//构造参数对象并初始化
    var name,value,i;
    var str=location.href;//获得浏览器地址栏URL串
    
    str = decodeURIComponent(str);
    
    var num=str.indexOf("?")
    str=str.substr(num+1);//截取“?”后面的参数串
    
    if(str.indexOf("&") == -1 && str.indexOf("%26") != -1)
    {
        str = str.replace(/%26/g,"&");
    }
    
    var arrtmp=str.split("&");//将各参数分离形成参数数组
    
    for(i=0;i < arrtmp.length;i++)
    {
        num=arrtmp[i].indexOf("=");
        if(num>0)
        {
            name=arrtmp[i].substring(0,num);//取得参数名称
            value=arrtmp[i].substr(num+1);//取得参数值
            this[name]=value;//定义对象属性并初始化
        }
    }
}
var Request=new QueryString();//使用new运算符创建参数对象实例

var _uuid = "";
if(Request["uuid"] != null)
{
	_uuid = Request["uuid"];
}

var url1 = "http://www.yxybb.com/Yxybb/DynamicNews/2012/10/07/331417841a694189a6815668cf97b376.html";
var url2 = "http://xueli.yxybb.com/hgedu_webmap/hgedu_online/";
var url3 = "http://www.yxybb.com/Yxybb/DynamicNews/2012/11/06/4eaf6268f9b4464b8b96be8a0c9069e5.html";
var url4 = "http://www.yxybb.com/AuditoriumDetailSub?coursetypeid=f93afc2fdc454b12aaea00ba35767202&courseid=55b2001426234b4fb9f48bf3cdc5adbb&coursewareid=CW20120801140427046";

url1=url1+"?uuid=" + _uuid;
url2=url2+"?uuid=" + _uuid;
url3=url3+"?uuid=" + _uuid;
url4=url4+"?uuid=" + _uuid;

var width = 714;//宽
var height = 114;//高
var pictureCount = 4;//图片数量
var href = [url1, url2, url3, url4, "#"];//链接地址
var time = 5000;//10秒
var now = 0;//0:默认显示第一个
var blockCount = 4;//分10块移动
var defer = 1;//块延迟基数
var order = 0;// 0(从上到下) 1(从下到上) 2(随机顺序) 3(随机出现012)
var blockHeight = Math.floor(height/blockCount);
var remain = new Array(pictureCount);
var direct;
var list = [];
document.write("<div class=\"scroller\" id=\"scroller\" style=\"width:"+width+"px\">");
document.write("<div class=\"flat\"><a style=\"width:"+width+"px;height:"+height+"px;margin-top:0\" id=\"flat\" href=\""+href[now]+"\"  target=\"_blank\" ></a></div>");
document.write("<div class=\"guide\" id=\"guide\" style=\"margin-top:"+(height-23)+"px;margin-left:"+(width-28 * pictureCount)+"px\">");
for(var i=0;i<pictureCount;i++)document.write("<p onclick=\"changeItem("+i+")\">"+parseInt(i+1)+"</p>");
document.write("</div>");
for(var i=0;i<blockCount;i++){
	document.write("<div class=\"block\" id=\"item"+i+"\" style=\"height:"+blockHeight+"px\">");
	for(var j=0;j<pictureCount;j++){
		document.write("<a href=\""+href[j]+"\" target=\"_blank\" style=\"background:url(ad.jpg) 0 "+(j+now)*height+"px;height:"+height+"px\"></a>");
	}
	document.write("</div>");
	if(i>0)$("item"+i).scrollTop = i*blockHeight;
}
document.write("</div>");
for(var i=0;i<blockCount;i++)list[i] = i;
Array.prototype.chaos = function(){
	var randomNumber,temp;
	for(var i=0;i<this.length;i++){
		randomNumber = getRandom(0,this.length-1);
		temp = this[i];
		this[i] = this[randomNumber];
		this[randomNumber] = temp;
	}
}
Array.prototype.total = function(){
	var count=0;
	for(var i=0;i<this.length;i++){
		count += this[i];
	}
	return count;
}
function getRandom(start,end){
	var number = parseInt(Math.random()*(end-start+1));
	if(start>0)number++;
	return number;
}
function sortList(o){
	if(o==undefined)o=order;
	switch(o){
		case 0:
			list.sort();
			break;
		case 1:
			list.sort();
			list.reverse();
			break;
		case 2:
			list.chaos();
			break;
		case 3:
			sortList(getRandom(0,2));
			break;
	}
}
function $(element){return document.getElementById(element)}
function $$(parent,element){return parent.getElementsByTagName(element)}
function offset(i){
	var step = Math.ceil(remain[i]/10);
	if(step > 0){
		if(direct){
			$("item"+i).scrollTop += step;
		}else{
			$("item"+i).scrollTop -= step;
		}
		remain[i] -= step;
		setTimeout("offset("+i+")",10);
	}
}
function changeStyle(index,type){
	$$($("guide"),"p")[index].className = type?"now":"";
}
function changeItem(index){
	if(remain.total()>0)return;
	changeStyle(now,false);
	if(index==undefined){
		if(++now>=pictureCount)now=0;
	}else{
		if(index==now){
			changeStyle(now,true);
			return false;
		}else{
			now = index;
		}
	}
	changeStyle(now,true);
	$("flat").href = href[now];
	var offsetSize = now*height-$("item0").scrollTop;
	direct = offsetSize>0?1:0;
	if(order>1)sortList();
	for(var i=0;i<blockCount;i++){
		remain[list[i]] = Math.abs(offsetSize);
		setTimeout("offset("+list[i]+")",i*defer);
	}
}
changeStyle(now,true);
if(order>0)sortList();
$("flat").onmouseover = function(){clearInterval(auto)}
$("flat").onmouseout = function(){auto = setInterval("changeItem()",time);}
$("guide").onmouseover = function(){clearInterval(auto)}
var auto = setInterval("changeItem()",time);