var $img = function(){
	var ini = function(){
		this.speed = 5000;
		this.imgW = 310;
		this.imgH = 220;
		this.$ = function(id){return document.getElementById(id);};
		this.show = function(msgStr){
			this.createBox();
			var val = new Array("pics=","links=","texts=","borderwidth=","borderheight=","textheight=");
			var pic = msgStr.split(val[0])[1].split("&"+val[1])[0].split("|");
			var lin = msgStr.split(val[1])[1].split("&"+val[2])[0].split("|");
			var pnum = msgStr.split(val[2])[1].split("&"+val[3])[0].split("|");
			for(i=0;i<pic.length;i++){
				this.createImg(pic[i],lin[i]);
			}
			this.action();
		};
		this.createBox = function(){
			document.write('<div id="imgBox"></div>');
			var imgBoxObj=this.$("imgBox");
			imgBoxObj.style.zIndex=-100;
			imgBoxObj.style.width=(this.imgW+2)+"px";
			imgBoxObj.style.height=(this.imgH+2)+"px";
			imgBoxObj.style.border="1px solid #EE7908"; 
		};
		this.createImg = function(imgSrc,imgHref){
			var d = document.createElement("div");
			d.innerHTML = "<a href='"+imgHref+"' target='_blank' ><img src='"+imgSrc+"' width='"+this.imgW+"' height='"+this.imgH+"' border='0' /></a>";
			d.style.position="absolute";
			d.style.margin="1px";
			d.style.filter="alpha(opacity=100)";
			d.style.opacity="1.0";
			this.$("imgBox").appendChild(d);
		};
		this.action = function(){
			var imn = new Array("http://images.120ask.com/images/sjc1.gif",
								"http://images.120ask.com/images/sjc2.gif",
								"http://images.120ask.com/images/sjc3.gif",
								"http://images.120ask.com/images/sjc4.gif",
								"http://images.120ask.com/images/sjc5.gif",
								"http://images.120ask.com/images/sjc6.gif",
								"http://images.120ask.com/images/sjc7.gif");
			var mBox = this.$("imgBox").childNodes;
			var startN = 0;
			var nn = this.$("imgBox").childNodes.length;
			var dn = document.createElement("div");
				for(i=0;i<nn;i++){
					mBox[0].style.visibility="visible";
					if(nn>1){
						mBox[i].style.visibility="hidden";
						createImgBtn(dn,imn[i],i);
					}
				}
			dn.style.position="absolute";
			dn.style.marginTop=(this.imgH-16)+"px";
			dn.style.marginLeft=(this.imgW-140)+"px";
			dn.style.width="140px";
			dn.style.height="16px";
			dn.style.zIndex="0";
			dn.style.textAlign="right";
			this.$("imgBox").appendChild(dn);
			setInterval(
				function ac(){
					if(nn>1){
						alpha0(mBox[startN]);
						if(startN+1<nn){
							alpha100(mBox[startN+1]);
							startN+=1;
						}else{
							alpha100(mBox[0]);
							startN=0;
						}
					}else{
						return false;
					}
				}
			,this.speed);
			function createImgBtn(pO,imgSrc,imgN){
				var img = document.createElement("img");
					img.src = imgSrc
					img.style.padding="3px";
					img.style.cursor="pointer";
					img.onclick=function(){
						for(i=0;i<nn;i++){
							if(mBox[i].style.visibility=="visible"){
								if(i==imgN){
									return false;
								}else{
									mBox[i].style.opacity=0
									mBox[i].style.filter="alpha(opacity=0)";
									mBox[i].style.visibility="hidden";
								}
							}
						}
						mBox[imgN].style.visibility="visible";
						mBox[imgN].style.opacity=1
						mBox[imgN].style.filter="alpha(opacity=100)";
						startN = imgN
					}
					pO.appendChild(img);
			}
			function alpha100(o){
				opa = o.style.opacity ? Number(o.style.opacity) : 0;
				opa=opa+(10/100);
				o.style.visibility="visible";
				o.style.filter="alpha(opacity="+opa*100+")";
				o.style.opacity=opa;
				if(opa<=100/100){setTimeout(function(){alpha100(o)},30);}
			}
			function alpha0(o){
				opa = o.style.opacity ? Number(o.style.opacity) : 1;
				opa=opa-(10/100);
				o.style.filter="alpha(opacity="+opa*100+")";
				o.style.opacity=opa;
				if(opa>=0){
					setTimeout(function(){alpha0(o)},30);
				}else{
					o.style.visibility="hidden";
				}
			}		
		}
	};
	return new ini();
}();

