//本页iframe打开网页

var imgloader='/fangchan/images/fangchan/indicator.gif';
var isie;
if(navigator.appName=='Microsoft Internet Explorer')isie=true;
else isie=false;

function $(obj)
{
	return document.getElementById(obj);
}

function openathere(url,width,height){
	if(!$('divbackgroud')) {
		div = document.createElement('div');div.id = 'divbackgroud';
		div.style.position = 'absolute';
		div.style.left = div.style.top = '0px';
		div.style.width = '100%';
		div.style.height = document.body.scrollHeight + 'px';
		div.style.backgroundColor = '#000';
		div.style.display = 'none';
		div.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=50,finishOpacity=100,style=40)';
		div.style.opacity = 0.5;
		document.body.appendChild(div);
		
		div = document.createElement('div');div.id = 'divshow';
		div.style.position = 'absolute';
		div.style.backgroundColor='#FFF';
		div.style.padding = 0;
		document.body.appendChild(div);

		div = document.createElement('div');
		div.style.height='25px';
		div.style.backgroundColor='#EEE';
		div.innerHTML='<table width="100%" border="0"><tr><td align="right"><a href="javascript:closethis();">关闭</a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>';
		$('divshow').appendChild(div);

		div = document.createElement('div');
		div.id='loader';
		div.style.display='none';
		div.style.height='150px';
		div.style.backgroundColor='#FFF';
		div.innerHTML='<table width="100%" border="0"><tr><td align="center"><img src="'+imgloader+'" /></td></tr></table>';
		$('divshow').appendChild(div);

		iframe=document.createElement('iframe');
		iframe.id='mainiframe';
		iframe.style.display='none';
		iframe.width='100%';
		$('divshow').appendChild(iframe);
		$('mainiframe').attachEvent("onload",showiframe);
	}

		//计算显示位置及大小		
		var r = width / height;
		var w = document.body.clientWidth * 0.95;
		w = width > w ? w : width;
		var h = w / r;
		var clientHeight;
		if(isie)clientHeight= document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight;
		else clientHeight= document.body.clientHeight?document.body.clientHeight:document.documentElement.clientHeight ;
		var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;

		if(h > clientHeight) {
			h = clientHeight;
			w = h * r;
		}
		var l = (document.body.clientWidth - w) / 2;
		var t = h < clientHeight ? (clientHeight - h) / 2 : 0;
		t += + scrollTop;

		$('divshow').style.left=l;
		$('divshow').style.top=t;
		$('divshow').style.width=w;
		$('divshow').style.height=h;
		
		$('mainiframe').height=h-25;
		$('mainiframe').style.border='none';
		$('mainiframe').src=url;
		
		$('divbackgroud').style.display='block';
		$('divshow').style.display='block';
		$('loader').style.display='block';
		$('mainiframe').style.display='none';

}

function showiframe(){
	$('loader').style.display='none';
	$('mainiframe').style.display='block';
}

function closethis(){
	if($('divbackgroud')){
		$('divbackgroud').style.display='none';
		$('divshow').style.display='none';
		$('mainiframe').src='';
	}
}

  
