var alertLay = function(){
		var d = document,dd = d.documentElement,
			ua = navigator.userAgent.toLowerCase(),ie = !(ua.indexOf("opera") > -1),
			$ = function(id){return d.getElementById(id)},
			ie6=  !(ua.indexOf("opera") > -1) && ua.indexOf("msie") > -1,
			getWH = function(){
				return {h:Math.max(d.body.scrollHeight,dd.clientHeight),w:Math.max(dd.scrollWidth,dd.clientWidth)} 
			},
			getTL = function(e){
				var t=0,l=0;
				do{
					t += e.offsetTop||0;
					l += e.offsetLeft||0;
				}while(e = e.offsetParent);
				return {t:t,l:l}
			},
			extend = function(t,s){
				for(var p in s){
					t[p] = s[p]
				}
				return t;
			},
			rycDiv,selects,options,sDiv;
		return {
			show:function(o){
				if(!rycDiv){
					rycDiv = d.createElement('div');
					rycDiv.style.display='none';
					d.body.insertBefore(rycDiv,d.body.firstChild);
				};
				options = extend({
					buttons:{"È·¶¨":function(){alertLay.clear()}}
				},o||{});
				var div = d.createElement('div'),wh = getWH();
				if(ie6){
					d.body.insertAdjacentHTML('afterBegin','<iframe id="layiframe" style="filter:alpha(opacity=0);position:absolute;top:0;left:0;width:'+wh.w+'px;height:'+wh.h+'px;z-index:99" ></iframe>');
					selects = d.getElementsByTagName('select');
					//alert(ie6)
					var container = $(options.id);
					for(var i=0,ci;ci=selects[i];i++){
						if(container&&container.contains(ci)||ci.style.display=='none'){
							continue;
						}
					    var tl = getTL(ci),w = ci.offsetWidth,h = ci.offsetHeight;
						ci.style.visibility = 'hidden'
						d.body.insertAdjacentHTML('afterBegin','<div id=layselect'+i+' style="padding:1px 1px 0 2px; position:absolute;top:'+tl.t+'px;left:'+tl.l+'px;width:'+(w-4)+'px;height:'+(h-2)+'px;border:1px solid #c0c0c0;z-index:99;no-repeat 2px right;">'+ci.options[ci.selectedIndex].text+'</div>');
						
					}
					container = null;
				}
				//wh.h
				div.style.cssText = "z-index:100;border:0;position:absolute;top:0;left:0;filter:alpha(opacity=0);opacity:0;width:"+wh.w+"px;height:"+wh.h+"px;background:#000000";
				div.id = 'layDiv'
				d.body.insertBefore(div,d.body.firstChild);
				div.style.filter ="alpha(opacity=30)"
				div.style.opacity = 0.3;
				options.beforeFn&&options.beforeFn.call(options.context||window);
				sDiv = d.createElement('div');
				sDiv.id = 'laySdiv';
				var cont = '';
				sDiv.style.cssText = 'border:0;position:absolute;z-index:200;top:50%;left:50%;';
				cont ='<div class="div_04_c" id="content" style="width:511px"><div class="div_04_c1" id="sDiv_title" onmousedown="alertLay.move(event,this)" ></div> \
						<div class="div_04_ex" onclick="alertLay.clear()"></div><div class="div_04_c2"></div>'+'<div class="div_04_c1">www.xiaozhuren.com/disney</div>'+' \
	<div class="div_04_c3">';
				for(var p in options.buttons){
					cont += '<div class="button" id="sDiv_btn_'+p+'" onclick="alertLay._link()"></div>';
				}
				sDiv.innerHTML = cont +'</div></div>';
				d.body.insertBefore(sDiv,d.body.firstChild);
				sDiv.style.width=511 + 'px'
				//sDiv.style.width = $('content').offsetWidth + 'px';
				sDiv.style.cssText += ';margin:'+(-sDiv.offsetHeight/2+dd.scrollTop-200)+'px '+(-511/2+dd.scrollLeft)+'px;';
				sDiv.style.cssText += ';'+'+'+'margin:'+(-sDiv.offsetHeight/2+dd.scrollTop-200)+'px '+(-511/2+dd.scrollLeft)+'px;';
				sDiv.style.cssText += ';'+'_'+'margin:'+(-sDiv.offsetHeight/2+dd.scrollTop)+'px '+(-511/2+dd.scrollLeft)+'px;';
				//sDiv.style.cssText += '*margin:'+(-sDiv.offsetHeight/2+dd.scrollTop-200)+'px '+(-511/2+dd.scrollLeft)+'px'+'!important;';
				//sDiv.style.cssText += '*margin:'+(-sDiv.offsetHeight/2+dd.scrollTop)+'px '+(-511/2+dd.scrollLeft)+'px;';				
				window.onresize = function(){
					if(div&&sDiv){
						div.style.width = getWH().w + 'px';
						div.style.height = getWH().h + 'px';
						sDiv.style.cssText +=';margin:'+(-sDiv.offsetHeight/2+dd.scrollTop-200)+'px '+(-sDiv.offsetWidth/2+dd.scrollLeft)+'px;';
				sDiv.style.cssText += ';'+'+'+'margin:'+(-sDiv.offsetHeight/2+dd.scrollTop-200)+'px '+(-511/2+dd.scrollLeft)+'px;';
				sDiv.style.cssText += ';'+'_'+'margin:'+(-sDiv.offsetHeight/2+dd.scrollTop)+'px '+(-511/2+dd.scrollLeft)+'px;';
					}
				}
			},
			_link:function(){
             //  window.open (options._link,'newWindow','scrollbars=yes,resizable=yes') ;
	 window.open (options._link,'newWindow','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes') ;
	   //alert(options._link)
	 alertLay.clear()
			},
			clear:function(){
				if(ie6){
					for(var i = 0,ci;ci=selects[i];i++){
						var o = $('layselect'+i);
						if(!o)continue;
						rycDiv.appendChild(o);
						ci.style.visibility = 'visible'
					}
					rycDiv.appendChild($('layiframe'));
				}
				rycDiv.appendChild(d.getElementById('layDiv'));
				rycDiv.appendChild(d.getElementById('laySdiv'));
				rycDiv.innerHTML = '';
				options.afterFn&&options.afterFn();
				sDiv =  null;
			}
		}
	}()