// author:原草随云
// version:0.2
// date:2008/11/5
// http://hi.baidu.com/ycsy520
var showDialog=function(){var l,c,d,j,g,f,m,k,h;return{show:function(a,b,i,n){if(!document.createElement){return false}g=showDialog.pageWidth();f=showDialog.pageHeight();showDialog.showOverlay();if(showDialog.isIE()){showDialog.createIfra()}if((/([a-z0-9-]+\.)+[a-z0-9]{2,4}.*$/.test(a))){var o="<iframe src='"+a+"' width = '"+b+"' height = '"+i+"' scrolling = '"+n+"' frameborder = '0'></iframe>";d=document.createElement('div');d.setAttribute('id','wrap__');c.parentNode.insertBefore(d,c);d.innerHTML=o;d.style.width=b+"px";d.style.height=i+"px";showDialog.posWindow(d)}else if(id__(a)){j=id__(a);j.style.display="block";showDialog.posWindow(j)}else{return false}},showOverlay:function(){var a=document.body;showDialog.setStyle(a,{padding:'0px',margin:'0px',overflowX:'hidden'});c=document.createElement('div');c.setAttribute('id','overlay__');k=showDialog.windowWidth();h=showDialog.windowHeight();showDialog.setStyle(c,{width:(g>k?g:k)+'px',height:(f>h?f:h)+'px',backgroundColor:'#000000',position:'absolute',top:'0px',left:'0px',zIndex:'998'});showDialog.setOpacity(c,30);return a.appendChild(c)},setOpacity:function(a,b){if(showDialog.isIE()){a.style.filter='Alpha(opacity='+b+')'}else{a.style.opacity=b/100}},createIfra:function(){if(!document.createElement("iframe")){return false};try{var a=document.createElement("iframe");a.setAttribute("id","ifrbg__");a.setAttribute("src","javascript:void(0);");a.setAttribute("scrolling","no");a.setAttribute("frameborder","0");a.setAttribute("allowtransparency","true");showDialog.insertAfter(a,c);showDialog.setStyle(a,{height:c.style.height,width:c.style.width,backgroundColor:'#FFFFFF',filter:'Alpha(opacity=0)',zIndex:'997',top:'0px',left:'0px',position:'absolute'});a.style.backgroundColor="transparency"}catch(e){}},hide:function(a){try{var b=document.body;b.style.overflowX='auto';if(id__(a)){id__(a).style.display='none'}if(c){b.removeChild(c)}if(showDialog.isIE()&&id__('ifrbg__')){b.removeChild(id__('ifrbg__'));l=null}if(d){b.removeChild(d)}c=null;d=null;j=null;g=null;f=null;m=null;k=null;h=null}catch(e){}},setStyle:function(a,b){for(var i in b){a.style[i]=b[i]}},adjust:function(){h=showDialog.windowHeight();g=showDialog.pageWidth();f=showDialog.pageHeight();c=id__('overlay__');l=id__('ifrbg__');c.style.height=(f>h?f:h)+'px';c.style.width=g+'px';if(j){showDialog.posWindow(j)}if(d){showDialog.posWindow(d)}if(l){l.style.height=c.style.height;l.style.width=c.style.width}},posWindow:function(a){var b=id__(a)||a;try{m=document.body.scrollTop||document.documentElement.scrollTop;k=showDialog.windowWidth(),h=showDialog.windowHeight();if(showDialog.isIE()){f=showDialog.pageHeight()}b.style.position="absolute";b.style.zIndex="999";b.style.marginLeft="-"+b.clientWidth/2+"px";b.style.marginTop="-"+b.clientHeight/2+"px";b.style.left=k/2+"px";b.style.top=h/2+m+15+"px";b=null}catch(e){}},pageHeight:function(){if(window.innerHeight&&window.scrollMaxY){f=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){f=document.body.scrollHeight}else{f=document.body.offsetHeight}return f},pageWidth:function(){if(window.innerWidth&&window.scrollMaxX){g=window.innerWidth+window.scrollMaxX}else if(document.body.scrollWidth>document.body.offsetWidth){g=document.body.scrollWidth}else{g=document.body.offsetWidth}return g},windowHeight:function(){return(window.innerHeight)?window.innerHeight:(document.documentElement&&document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.offsetHeight},windowWidth:function(){return(window.innerWidth)?window.innerWidth:(document.documentElement&&document.documentElement.clientWidth)?document.documentElement.clientWidth:document.body.offsetWidth},isIE:function(){var a=navigator.userAgent;return a.indexOf("compatible")>-1&&a.indexOf("MSIE")>-1&&!(a.indexOf("Opera")>-1)},insertAfter:function(a,b){var i=b.parentNode;if(i.lastChild==b){i.appendChild(a)}else{i.insertBefore(a,b.nextSibling)}}}}();function id__(a){return document.getElementById(a)}(function(){setInterval(function(){if(id__('overlay__')){try{showDialog.adjust()}catch(e){}}},10)})();