//Feeyo.com
var FyLightBox={
	$:function(d){return document.getElementById(d)},
	move:0,
	eventStartX:0,
	eventStartY:0,
	wndStartX:0,
	wndStartY:0,
	d:{a:'fylightbox',b:'fylightboxtitle',c:'fylightboxchild',d:'fylightboxstatus',e:'fylightboxiframe',g:'fylightboxcanvas',w:'FyLightBox'},
	e:null,
	x:function(){return FyLightBox.e.clientX;},
	y:function(){return FyLightBox.e.clientY;},
	drag_start:function(e){
		FyLightBox.e=e;
		FyLightBox.move=1;
		FyLightBox.eventStartX=FyLightBox.x();
		FyLightBox.eventStartY=FyLightBox.y();
		FyLightBox.wndStartX=FyLightBox.$(FyLightBox.d.a).offsetLeft;
		FyLightBox.wndStartY=FyLightBox.$(FyLightBox.d.a).offsetTop;
	},
	drag_stop:function(e){
		FyLightBox.e=e;
		FyLightBox.move=0;
	},
	drag:function(e){
		FyLightBox.e=e;
		if(FyLightBox.move){
			FyLightBox.$(this.d.a).style.left=FyLightBox.wndStartX+(FyLightBox.x()-FyLightBox.eventStartX)+'px';
			FyLightBox.$(this.d.a).style.top=FyLightBox.wndStartY+(FyLightBox.y()-FyLightBox.eventStartY)+'px';
			try{document.selection.empty();}catch(er){}
		}
	},
	close:function(){
		FyLightBox.$(FyLightBox.d.a).style.display='none';FyLightBox.$(FyLightBox.d.g).style.display='none';
		var a=document.body;a.removeChild(FyLightBox.$(FyLightBox.d.a));//a.removeChild(FyLightBox.$(FyLightBox.d.g));
	},
	onfocus:function(){
		FyLightBox.flash(2);
	},
	flash:function(n){
		FyLightBox.$(FyLightBox.d.b).className='fylightboxfocus';
		setTimeout(function(){FyLightBox.$(FyLightBox.d.b).className='fylightboxtitle';},50);
		if(n>1){setTimeout(function(){FyLightBox.flash(n-1);},100);}
	},
	open:function(){
		var de=document.documentElement;
		var w=window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
		var ch=window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
		if (self.pageYOffset) {
			var st=self.pageYOffset;
		} else if (de&&de.scrollTop){	 // Explorer 6 Strict
			var st=de.scrollTop;
		} else if (document.body) {// all other Explorers
			var st=document.body.scrollTop;
		}
		if (window.innerHeight && window.scrollMaxY) {	
			var sh=window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			var sh=document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			var sh=document.body.offsetHeight;
		}
		var a=arguments;
		FyLightBox.title=a[0]||'信息窗口';
		FyLightBox.para=a[1];//网址或者要显示的内容
		FyLightBox.width=a[2]||300;
		FyLightBox.height=a[3]||200;
		FyLightBox.type=null==a[4]?1:a[4];//1-框架,2-直接显示内容
		FyLightBox.canvas=a[5]||{bgc:'#fff',opa:0.1};
		FyLightBox.left=a[6]||(w-FyLightBox.width)/2+'px';
		FyLightBox.top=a[7]||(ch-(FyLightBox.height||200))/2+st+'px';
		var dc=document,s='';
		var o=dc.createElement("div");
		o.id=FyLightBox.d.a;
		o.className='fylightbox';
		o.style.width=FyLightBox.width+'px';
		o.style.height=FyLightBox.height+'px';
		o.style.left=FyLightBox.left;
		o.style.top=FyLightBox.top;
		s+='<div id="'+FyLightBox.d.b+'" class="fylightboxtitle" onmousedown="'+FyLightBox.d.w+'.drag_start(event)" onmouseup="'+FyLightBox.d.w+'.drag_stop(event)" onmousemove="'+FyLightBox.d.w+'.drag(event)">';
		s+='<span style="float:right"><a href="javascript:'+FyLightBox.d.w+'.close();" class="fylightboxclose" target="_self"><font color=white>×</font></a></span>'+FyLightBox.title;
		s+='</div>';
		s+='<div id="'+FyLightBox.d.c+'" class="fylightboxchild">';
		s+=1==FyLightBox.type?('<iframe id="'+FyLightBox.d.e+'" name="'+FyLightBox.d.e+'" src="about:blank"  style="width:100%;height:'+(FyLightBox.height-40)+'px;" frameborder="0" hspace="0"></iframe>'):('<div style="padding:10px;">'+FyLightBox.para+'</div>');
		s+='</div>';
		o.innerHTML=s;
		dc.body.appendChild(o);
		var f=0;
		o=FyLightBox.$(FyLightBox.d.g);
		if(!o){f=1;o=dc.createElement("div");}
		o.id=FyLightBox.d.g;
		o.className='fylightboxcanvas';
		o.style.height=(sh>ch?sh:ch)+'px';
		o.style.width=w+'px';
		s=FyLightBox.canvas;
		o.style.backgroundColor=s.bgc;
		o.style.filter='alpha(opacity='+(s.opa*100)+')';
		o.style.display='block';
		if(f){o.onclick=function(){FyLightBox.onfocus()};dc.body.appendChild(o)};
		if(1==FyLightBox.type){FyLightBox.$(FyLightBox.d.e).src=FyLightBox.para;}
	}
}
