/*按比例生成缩略图*/
function DrawImage(ImgD,W,H){ 
  var flag=false; 
  var image=new Image(); 
  image.src=ImgD.src; 
  if(image.width>0 && image.height>0){ 
    flag=true; 
    if(image.width/image.height>= W/H){ 
      if(image.width>W){
        ImgD.width=W; 
        ImgD.height=(image.height*H)/image.width; 
      }
	  else{ 
        ImgD.width=image.width;
        ImgD.height=image.height; 
      } 
      ImgD.alt= ""; 
    } 
    else{ 
      if(image.height>H){
        ImgD.height=H; 
        ImgD.width=(image.width*W)/image.height; 
      }
	  else{ 
        ImgD.width=image.width;
        ImgD.height=image.height; 
      } 
      ImgD.alt=""; 
    } 
  }
}





function createIframe(){ 
//mask遮罩?
var newMask=document.createElement("div"); 
newMask.id="mDiv"; 
newMask.style.position="absolute"; 
newMask.style.zIndex="1"; 
_scrollWidth=Math.max(document.body.scrollWidth,document.documentElement.scrollWidth); 
_scrollHeight=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight); 
// _scrollHeight = Math.max(document.body.offsetHeight,document.documentElement.scrollHeight); 
newMask.style.width=_scrollWidth+"px"; 
newMask.style.height=_scrollHeight+"px"; 
newMask.style.top="0px"; 
newMask.style.left="0px"; 
newMask.style.background= "#33393C"; 
//newMask.style.background = "#FFFFFF"; 
newMask.style.filter="alpha(opacity=60)"; 
newMask.style.opacity="0.40"; 
newMask.style.display='none'; 
var objDiv=document.createElement("DIV"); 
objDiv.id="div1"; 
objDiv.name="div1"; 
objDiv.style.width="740px"; 
objDiv.style.height="400px"; 
//objDiv.style.top = "10%";
objDiv.style.left = "20%";

var h=document.body.scrollTop+document.body.clientHeight/6;
var w=document.body.clientWidth/7;

/*objDiv.style.left = w;*/
objDiv.style.top = h;
//objDiv.style.display = 'block';
//objDiv.style.left=(_scrollWidth-480)/2+"px"; 
//objDiv.style.top=(_scrollHeight-900)/2+"px"; 
objDiv.style.position="absolute"; 
objDiv.style.zIndex="2"; //加了这个语句让objDiv浮在newMask之上 
objDiv.style.display="none"; //让objDiv预先隐藏 
objDiv.innerHTML=' <div id="drag" style="position:absolute;height:20px;width:100%;z-index:10001;top:0;background-color:#f26c63";><span style="font-size:12px;color:white;font-weight:bold;margin-left:20px;line-height:19px;width:40%;">㷢ӡˢ޹˾ͼ </span><span style="margin-left:650px;color:white;font-size:12px;font-weight:bold;cursor:hand;width:60%;" onclick="HideIframe(document.getElementById(\'mDiv\'),document.getElementById(\'div1\'));" />رմ </span></div>';
//更改了X按钮为触发关闭事件?
//objDiv.style.border="solid red 3px;"; 
var frm=document.createElement("iframe"); 
frm.id="ifrm"; 
frm.name="ifrm"; 
frm.style.position="absolute"; 
frm.style.width="100%"; 
frm.style.height="100%";//500; 
frm.style.top= 20; 
frm.style.display=''; 
frm.frameborder=0; 
frm.scrolling = 'no';
objDiv.appendChild(frm); 
// newMask.appendChild(objDiv); //问题出在这里：你把frame所在的div变成?newMask的子元素，当newMask透明度更改时，当然会影响到frame 
document.body.appendChild(newMask); 
document.body.appendChild(objDiv); 
/*var objDrag=document.getElementById("drag"); 
var drag=false; 
var dragX=0; 
var dragY=0; 
objDrag.attachEvent("onmousedown",startDrag); 
function startDrag(){ 
if(event.button==1&&event.srcElement.tagName.toUpperCase()=="DIV"){ 
objDrag.setCapture(); 
objDrag.style.background="#0000CC"; 
drag=true; 
dragX=event.clientX; 
dragY=event.clientY; 
} 
}; 
objDrag.attachEvent("onmousemove",Drag); 
function Drag(){ 
if(drag){ 
var oldwin=objDrag.parentNode; 
oldwin.style.left=oldwin.offsetLeft+event.clientX-dragX; 
oldwin.style.top=oldwin.offsetTop+event.clientY-dragY; 
oldwin.style.left=event.clientX-100; 
oldwin.style.top=event.clientY-10; 
dragX=event.clientX; 
dragY=event.clientY; 
} 
}; 
objDrag.attachEvent("onmouseup",stopDrag); 
function stopDrag(){ 
objDrag.style.background="#0033FF"; 
objDrag.releaseCapture(); 
drag=false; 
}; */
} 
function htmlEditor(){ 
var frm=document.getElementById("ifrm"); 
var objDiv=document.getElementById("div1"); 
var mDiv=document.getElementById("mDiv"); 
mDiv.style.display=''; 
var iframeTextContent=''; 
iframeTextContent+=' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'; 
iframeTextContent+=' <html xmlns="http://www.w3.org/1999/xhtml">'; 
iframeTextContent+=' <head>'; 
iframeTextContent+=' <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />'; 
iframeTextContent+=' </head>'; 
iframeTextContent+=' <body style="margin-left:0;">'; 
iframeTextContent+=' <div>'; 
iframeTextContent+='<iframe width="740" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=23.159814,113.276467&amp;spn=0.007891,0.015857&amp;z=16&amp;output=embed"></iframe><br /><small>ڽϴĵͼв鿴<a href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=23.159814,113.276467&amp;spn=0.007891,0.015857&amp;z=16&amp;source=embed" style="color:#0000FF;text-align:left">ݹ㷢ӡˢ޹˾</a></small>'; 
iframeTextContent+=' </div>'; 
iframeTextContent+=' </body>'; 
iframeTextContent+=' </html>'; 
frm.contentWindow.document.designMode='off'; 
frm.contentWindow.document.open(); 
frm.contentWindow.document.write(iframeTextContent); 
frm.contentWindow.document.close(); 
objDiv.style.display = ""; //显示浮动的div 
var objGo=frm.contentWindow.document.getElementById("btGo"); 
objGo.attachEvent("onclick",function (){ 
HideIframe(mDiv,objDiv); 
}); 


} 

function HideIframe(mDiv,objDiv){ 
mDiv.style.display='none'; 
objDiv.style.display = "none"; //隐藏浮动的div 
} 




function showdiv()
{
	/*alert("滚动条高"+document.body.scrollTop);
	alert("屏幕?+document.body.clientHeight);*/
	var h=document.body.scrollTop+ document.body.clientHeight/6;
	
	//alert("屏幕?+document.body.clientWidth);
	
	var w=document.body.clientWidth/7;
	
	
	//document.getElementById("div1").style.display="block";
	document.getElementById("div1").style.top=  h;
	document.getElementById("div1").style.left= "20%";//w;
}


function lookdivd()
{
	//判断lookdiv是否显示?
	/*if(document.getElementById("div1").style.display=="block")
	{*/
		showdiv();
		//alert(document.getElementById("div1").style.display);
	//}
}
//滚动条滑动时
window.onscroll=lookdivd;   








function htmlEditor2(){ 
var frm=document.getElementById("ifrm"); 
var objDiv=document.getElementById("div1"); 
var mDiv=document.getElementById("mDiv"); 
mDiv.style.display=''; 
var iframeTextContent=''; 
iframeTextContent+=' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'; 
iframeTextContent+=' <html xmlns="http://www.w3.org/1999/xhtml">'; 
iframeTextContent+=' <head>'; 
iframeTextContent+=' <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />'; 
iframeTextContent+=' </head>'; 
iframeTextContent+=' <body style="margin-left:0;">'; 
iframeTextContent+=' <div>'; 
iframeTextContent+='<iframe width="740" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=22.694249,114.128551&amp;spn=0.015837,0.031757&amp;z=15&amp;output=embed"></iframe><br /><small>ڽϴĵͼв鿴<a href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=22.694249,114.128551&amp;spn=0.015837,0.031757&amp;z=15&amp;source=embed" style="color:#0000FF;text-align:left">ݹ㷢ӡˢ޹˾</a></small>'; 
iframeTextContent+=' </div>'; 
iframeTextContent+=' </body>'; 
iframeTextContent+=' </html>'; 
frm.contentWindow.document.designMode='off'; 
frm.contentWindow.document.open(); 
frm.contentWindow.document.write(iframeTextContent); 
frm.contentWindow.document.close(); 
objDiv.style.display = ""; //显示浮动的div 
var objGo=frm.contentWindow.document.getElementById("btGo"); 
objGo.attachEvent("onclick",function (){ 
HideIframe(mDiv,objDiv); 
}); 


} 



function htmlEditor3(){ 
var frm=document.getElementById("ifrm"); 
var objDiv=document.getElementById("div1"); 
var mDiv=document.getElementById("mDiv"); 
mDiv.style.display=''; 
var iframeTextContent=''; 
iframeTextContent+=' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'; 
iframeTextContent+=' <html xmlns="http://www.w3.org/1999/xhtml">'; 
iframeTextContent+=' <head>'; 
iframeTextContent+=' <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />'; 
iframeTextContent+=' </head>'; 
iframeTextContent+=' <body style="margin-left:0;">'; 
iframeTextContent+=' <div>'; 
iframeTextContent+='<iframe width="740" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=23.251283,113.296165&amp;spn=0.063088,0.126858&amp;z=13&amp;output=embed"></iframe><br /><small>ڽϴĵͼв鿴<a href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=23.251283,113.296165&amp;spn=0.063088,0.126858&amp;z=13&amp;source=embed" style="color:#0000FF;text-align:left">ݹ㷢ӡˢ޹˾</a></small>'; 
iframeTextContent+=' </div>'; 
iframeTextContent+=' </body>'; 
iframeTextContent+=' </html>'; 
frm.contentWindow.document.designMode='off'; 
frm.contentWindow.document.open(); 
frm.contentWindow.document.write(iframeTextContent); 
frm.contentWindow.document.close(); 
objDiv.style.display = ""; //显示浮动的div 
var objGo=frm.contentWindow.document.getElementById("btGo"); 
objGo.attachEvent("onclick",function (){ 
HideIframe(mDiv,objDiv); 
}); 


} 









function htmlEditor4(){ 
var frm=document.getElementById("ifrm"); 
var objDiv=document.getElementById("div1"); 
var mDiv=document.getElementById("mDiv"); 
mDiv.style.display=''; 
var iframeTextContent=''; 
iframeTextContent+=' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'; 
iframeTextContent+=' <html xmlns="http://www.w3.org/1999/xhtml">'; 
iframeTextContent+=' <head>'; 
iframeTextContent+=' <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />'; 
iframeTextContent+=' </head>'; 
iframeTextContent+=' <body style="margin-left:0;">'; 
iframeTextContent+=' <div>'; 
iframeTextContent+='<iframe width="740" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=39.850984,116.354098&amp;spn=0.013179,0.031757&amp;z=15&amp;output=embed"></iframe><br /><small>ڽϴĵͼв鿴<a href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=39.850984,116.354098&amp;spn=0.013179,0.031757&amp;z=15&amp;source=embed" style="color:#0000FF;text-align:left">ݹ㷢ӡˢ޹˾</a></small>'; 
iframeTextContent+=' </div>'; 
iframeTextContent+=' </body>'; 
iframeTextContent+=' </html>'; 
frm.contentWindow.document.designMode='off'; 
frm.contentWindow.document.open(); 
frm.contentWindow.document.write(iframeTextContent); 
frm.contentWindow.document.close(); 
objDiv.style.display = ""; //显示浮动的div 
var objGo=frm.contentWindow.document.getElementById("btGo"); 
objGo.attachEvent("onclick",function (){ 
HideIframe(mDiv,objDiv); 
}); 


} 




function htmlEditor5(){ 
var frm=document.getElementById("ifrm"); 
var objDiv=document.getElementById("div1"); 
var mDiv=document.getElementById("mDiv"); 
mDiv.style.display=''; 
var iframeTextContent=''; 
iframeTextContent+=' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'; 
iframeTextContent+=' <html xmlns="http://www.w3.org/1999/xhtml">'; 
iframeTextContent+=' <head>'; 
iframeTextContent+=' <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />'; 
iframeTextContent+=' </head>'; 
iframeTextContent+=' <body style="margin-left:0;">'; 
iframeTextContent+=' <div>'; 
iframeTextContent+='<iframe width="740" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=38.995707,116.558075&amp;spn=0.426925,1.016235&amp;z=10&amp;output=embed"></iframe><br /><small>ڽϴĵͼв鿴<a href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=38.995707,116.558075&amp;spn=0.426925,1.016235&amp;z=10&amp;source=embed" style="color:#0000FF;text-align:left">ݹ㷢ӡˢ޹˾</a></small>'; 
iframeTextContent+=' </div>'; 
iframeTextContent+=' </body>'; 
iframeTextContent+=' </html>'; 
frm.contentWindow.document.designMode='off'; 
frm.contentWindow.document.open(); 
frm.contentWindow.document.write(iframeTextContent); 
frm.contentWindow.document.close(); 
objDiv.style.display = ""; //显示浮动的div 
var objGo=frm.contentWindow.document.getElementById("btGo"); 
objGo.attachEvent("onclick",function (){ 
HideIframe(mDiv,objDiv); 
}); 


} 








function htmlEditor6(){ 
var frm=document.getElementById("ifrm"); 
var objDiv=document.getElementById("div1"); 
var mDiv=document.getElementById("mDiv"); 
mDiv.style.display=''; 
var iframeTextContent=''; 
iframeTextContent+=' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'; 
iframeTextContent+=' <html xmlns="http://www.w3.org/1999/xhtml">'; 
iframeTextContent+=' <head>'; 
iframeTextContent+=' <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />'; 
iframeTextContent+=' </head>'; 
iframeTextContent+=' <body style="margin-left:0;">'; 
iframeTextContent+=' <div>'; 
iframeTextContent+=' <iframe width="740" height="400" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=22.358748,114.131384&amp;spn=0.007938,0.015879&amp;z=16&amp;output=embed"></iframe><br /><small>ڽϴĵͼв鿴<a href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=zh-CN&amp;msa=0&amp;msid=115090803926828440758.00048b51f1a109f0c59c9&amp;ll=22.358748,114.131384&amp;spn=0.007938,0.015879&amp;z=16&amp;source=embed" style="color:#0000FF;text-align:left">ݹ㷢ӡˢ޹˾</a></small>'; 
iframeTextContent+=' </div>'; 
iframeTextContent+=' </body>'; 
iframeTextContent+=' </html>'; 
frm.contentWindow.document.designMode='off'; 
frm.contentWindow.document.open(); 
frm.contentWindow.document.write(iframeTextContent); 
frm.contentWindow.document.close(); 
objDiv.style.display = ""; //显示浮动的div 
var objGo=frm.contentWindow.document.getElementById("btGo"); 
objGo.attachEvent("onclick",function (){ 
HideIframe(mDiv,objDiv); 
}); 


} 


function showDiv(){
document.getElementById('popDiv').style.display='block';
document.getElementById('bg').style.display='block';
}

function closeDiv(){
document.getElementById('popDiv').style.display='none';
document.getElementById('bg').style.display='none';
}







