// JavaScript Document
var tl={
	$			: function(objid){
	    return document.getElementById(objid);
	},
	isNull		: function(obj){
		if (obj == null || obj == 'undefined') return true;
		else return false;
	}
}

function tlr(objid, stopval, direct){
	this.startx = 0;
	this.starty = 0;
	this.subx = 0;
	this.suby = 0;
	this.subChild = 1;
	this.symbolx = '';
	this.symboly = '';
	this.stopval = stopval;
	this.direct = direct;
	
	this.iTime = 60;
	this.iResume = 4000;
	
	this.objrolling = null;
	this.objtimeout = null;
	this.rollobj = tl.$(objid).getElementsByTagName('UL')[0];
}
tlr.prototype.setup = function(config){
	if (typeof(config.subChild) != 'undefined'){
		this.subChild = config.subChild;
	}
	if (typeof(config.iTime) != 'undefined'){
		this.iTime = config.iTime;
	}
	if (typeof(config.iResume) != 'undefined'){
		this.iResume = config.iResume;
	}
}
tlr.prototype.initroll = function(){
	this.stoproll();
	if (this.direct == 'LEFT') {this.symbolx='-';this.subx=Math.ceil(this.stopval/12);}
	if (this.direct == 'RIGHT') {this.subx=2;}
	if (this.direct == 'TOP') {this.symboly='-';this.suby=Math.ceil(this.stopval/12);}
	if (this.direct == 'BOTTOM') {this.suby=2;}
	var o = this;
	this.rollobj.onmouseover = function(){
	    o.stoproll();
	};
	this.rollobj.onmouseout = function(){
	    o.playroll(o);
	};
	this.objtimeout = setTimeout(function(){o.playroll(o)}, this.iResume);
}
tlr.prototype.playroll = function(o){
	this.objrolling = setInterval(function(){o.rollPlaying();}, this.iTime);
}
tlr.prototype.stoproll = function(){
	clearTimeout(this.objtimeout);
	clearInterval(this.objrolling);
}
tlr.prototype.pauseroll = function(o){
	this.stoproll();
	this.objtimeout = setTimeout(function(){o.rollReset()}, this.iResume);
}
tlr.prototype.rollPlaying = function(){
	this.startx = this.startx + this.subx;
	this.starty = this.starty + this.suby;
	this.rollobj.style.marginLeft = this.symbolx + String(this.startx) + 'px';
	this.rollobj.style.marginTop = this.symboly + String(this.starty) + 'px';
	if (this.startx >= this.stopval || this.starty >= this.stopval){
	    if (this.subx == 0) this.rollobj.style.marginLeft = this.symbolx + this.startx + 'px';
	    else this.rollobj.style.marginLeft = this.symbolx + this.stopval + 'px';
	    if (this.suby == 0) this.rollobj.style.marginTop = this.symboly + this.starty + 'px';
	    else this.rollobj.style.marginTop = this.symboly + this.stopval + 'px';
		this.pauseroll(this);
	}
}
tlr.prototype.rollReset = function(){
	for (var i = 0; i < this.subChild; i++){
		var rollul = this.rollobj.firstChild;
		while (rollul.nodeType != 1){
			rollul = rollul.nextSibling;
		}
		this.rollobj.removeChild(rollul);
		this.rollobj.appendChild(rollul);
	}
	this.startx = 0;
	this.starty = 0;
	this.rollobj.style.marginLeft = '0';
	this.rollobj.style.marginTop = '0';
	this.playroll(this);
}

window.onload = function(){
    //var tips = new tlr('rollTips', 28, 'TOP');
	//tips.initroll();
}

showNotice = function(){
    popup = document.createElement('div');
	popup.className =  'popup';
	popup.style.height = document.body.offsetHeight + 'px';
    obj = document.createElement('div');
	obj.className =  'popupMsg';
	obj.style.left = (screen.availWidth - 500) / 2 + 'px';
	obj.style.top = (screen.availHeight - 400) / 2 + 'px';
    cobj = document.createElement('div');
    cobj.innerHTML = '功能即将开放，敬请期待！';
    iobj = document.createElement('input');
    iobj.setAttribute('type', 'button');
    iobj.setAttribute('value', '关闭窗口');
    iobj.onclick = function(){
        document.body.removeChild(popup);
        document.body.removeChild(obj);
    }
    obj.appendChild(cobj);
    obj.appendChild(iobj);
    document.body.appendChild(popup);
    document.body.appendChild(obj);
}
