//载入导航层控制
//window.onerror = function(){return true;}

//跳转页面显示
function ShowPage(n,TotalPage,topage,url){
if (TotalPage<=1)return;
if (topage<(n+1)/2){PageLong=n+1-topage;}
else
if (TotalPage-topage<(n+1)/2){PageLong=n-(TotalPage-topage)}
else{PageLong=(n+1)/2;}

document.write("<div class=abut>");
if (topage>1)document.write("<a href=?page="+(topage-1).toString()+url+">上一页<\/a>");
for (var i=1; i <= TotalPage; i++) {
if (i < topage+PageLong && i > topage-PageLong || i==1 || i==TotalPage){
if (topage==i){document.write("<b>"+ i +"<\/b>");}else{document.write("<a href=?page="+i+url+">"+ i +"<\/a>");}
}
}
if (topage<TotalPage)document.write("<a href=?page="+(topage+1).toString()+url+">下一页<\/a>");
document.write("<\/div>");
}

function CheckAll(form)
{
  for (var i=0;i<form.elements.length;i++)    {
	var e = form.elements[i];
	if (e.name != 'chkall') e.checked = form.chkall.checked; 
   }
}

function openwin( url, width, height,n)  
{ 
xposition=0; yposition=0; 
if ((parseInt(navigator.appVersion) >= 4 )) 
{ 
xposition = (screen.width - width) / 2; 
yposition = (screen.height - height) / 2; 
} 
theproperty= "width=" + width + ","  
+ "height=" + height + ","  
+ "location=0,"  
+ "menubar=0," 
+ "resizable=1," 
+ "scrollbars="+(n==1?1:0)+"," 
+ "status=0,"  
+ "titlebar=0," 
+ "toolbar=0," 
+ "hotkeys=0," 
+ "screenx=" + xposition + "," //仅适用于Netscape 
+ "screeny=" + yposition + "," //仅适用于Netscape 
+ "left=" + xposition + "," //IE 
+ "top=" + yposition; //IE  
window.open( url,"yabbsmessage",theproperty ); 
} 

function checkimgW(ImgD,s){
 var t=new Image(); 
 t.src=ImgD.src; 
 if(t.width>s)ImgD.width=s;
   else ImgD.width=t.width;
 ImgD.style.border=0;
}


//图片按比例缩放#1
var flag=false; 
function DrawImage(ImgD,iwidth,iheight){ 
 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
 flag=true; 
 if(image.width/image.height>= iwidth/iheight){ 
  if(image.width>iwidth){   
  ImgD.width=iwidth; 
  ImgD.height=(image.height*iwidth)/image.width; 
  }else{ 
  ImgD.width=image.width;   
  ImgD.height=image.height; 
  } 
  } 
 else{ 
  if(image.height>iheight){   
  ImgD.height=iheight; 
  ImgD.width=(image.width*iheight)/image.height;   
  }else{ 
  ImgD.width=image.width;   
  ImgD.height=image.height; 
  } 
  }
  ImgD.style.border=0; 
 }
}

//图片按比例缩放#4-强制长宽
function DrawImagee(ImgD,iwidth,iheight,i){
 var id="im";
 if(i!=null)id+=i;
 var image=new Image(); 
 image.src=ImgD.src;
Obj(id).style.marginLeft="0px";
Obj(id).style.marginTop="0px";
 if(image.width>=iwidth && image.height>=iheight){ 
   flag=true;
   if(image.width/image.height>= iwidth/iheight){ 
     ImgD.height=iheight; 
     ImgD.width=(image.width*iheight)/image.height;
     Obj(id).style.left=-1*(ImgD.width-iwidth)/2;
     }
   else{ 
     ImgD.width=iwidth; 
     ImgD.height=(image.height*iwidth)/image.width;
     Obj(id).style.top=-1*(ImgD.height-iheight)/2;
    }
  }
}

//图片按比例缩放#4-强制长宽
function DrawImageq(ImgD,iwidth,iheight){
 var image=new Image(); 
 image.src=ImgD.src;
 if(image.width>=iwidth && image.height>=iheight){ 
   flag=true;
   if(image.width/image.height>= iwidth/iheight){ 
     ImgD.height=iheight; 
     ImgD.width=(image.width*iheight)/image.height;
     }
   else{ 
     ImgD.width=iwidth; 
     ImgD.height=(image.height*iwidth)/image.width;
    }
  }
}

//图片按比例缩放#5
function DrawImages(i,ImgD,iwidth,iheight){

 var image=new Image(); 
 image.src=ImgD.src; 
 if(image.width>=iwidth && image.height>=iheight){ 
 flag=true;
 if(image.width/image.height>= iwidth/iheight){ 
  ImgD.height=iheight; 
  ImgD.width=(image.width*iheight)/image.height;
  document.getElementById("im"+i).style.left=-1*(ImgD.width-iwidth)/2;
//  document.getElementById("im"+i).style.top=-5;
  }
 else{ 
  ImgD.width=iwidth; 
  ImgD.height=(image.height*iwidth)/image.width;
  document.getElementById("im"+i).style.top=-1*(ImgD.height-iheight)/2;
//  document.getElementById("im"+i).style.left=-5;
 }
 }
 //else{errimg()}
}


//图片引用错误提示
function errimg(ImgD){
ImgD.alt="图片引用错误,原图片地址"+ImgD.src;
ImgD.src="../img/errpic4.jpg";
}

//图片引用错误提示
function errimg2(ImgD,s){
if (ImgD.src.indexOf(s+"_")==-1){
ImgD.alt+="|"+"图片引用错误,原图片地址"+ImgD.src;
ImgD.src="img/err2.jpg";
}else{
ImgD.src=ImgD.src.replace(s+"_","");
}
}

function home()
{
top.location="./";
}

//网站收藏
function bookmarkit(){
window.external.addFavorite('http://www.yawin.cn/','永安之窗（www.yawin.cn)')
}

function showflash(w,h,u){
var str="<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width="+w+" height="+h+"><PARAM NAME=movie VALUE='"+u+"'><PARAM NAME=quality VALUE=high><param name='wmode' value='transparent'><embed src='"+u+"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width="+w+" height="+h+" menu='false' wmode='transparent'></embed></OBJECT>";
document.write (str);
}


function userstatus(u)
{
var s;
s = '<div class="t2">';
if (u==""||u==null){
	s+= '<form action="../user/logins.do" method="post" onsubmit="CHKlog(this)">帐号：<input class=t name="username" type="text"> 密码：<input class=t name="password" type="password"><input type="submit" name="SubMit" value="登录" class=s></from><a href=../user/prereg.do target=_blank>注册</a>/<a href=../user/getkey.do target=_blank>忘记密码</a></div>';
}else{
	s+= '您好！<b><a href="user_index.asp">'+u+'</a></b>';
	s+= '[<a target=_blank href="../ssby/m_index.do">登陆后台</a>]';
	s+= '[<a href="../ssby/m_out.do">退出</a>][<a href="../mymail/" target=_blank>我的信箱</a>]</div>';
//	s+= '<div class="t2"><ul><li id="linobg"><a href="../mymail/">我的信箱</a></li>';
}
Obj("userstatus").innerHTML = s;
}

function CHKlog(f){
if (hFrm()){
f.target="hiddenframe";
return true;
}
}

function MMlog(u){
if (hFrm())Obj("hiddenframe").src=u;
}

function Obj(i, win) {
try {return ( win || window ).document.getElementById(i);}
catch( e ) {return null;}
}

function hFrm(){
var h=Obj("hiddenframe");
if (!h){
var d = document.createElement("div");
d.innerHTML = '<iframe style="border:0px none;width:0px;height:0px;" name="hiddenframe" id="hiddenframe"></iframe>';
d.style.display="none";
Obj("wrap").insertBefore(d,Obj("info"));
}
return true;
}

function makead(fl,f,u,w,h){
document.write('<div class=winad style="position:relative;float:'+fl+';width:'+w+'px;height:'+h+'px;">');
if (u!=""){
  if(u=="1")document.write('<div style="Z-INDEX:5;POSITION: absolute;width:'+(w-2)+'px;height:'+(h-2)+'px;border:1px solid #ccd;overflow:hidden"></div>');
  else if(u.length<10)document.write('<div style="Z-INDEX:5;POSITION: absolute;width:'+(w-2)+'px;height:'+(h-2)+'px;border:1px solid '+u+';overflow:hidden"></div>');
  else document.write('<a href='+u+' target=_blank><img style="Z-INDEX:5;POSITION: absolute;" class=b src=../img/blank.gif width='+(w-2)+' height='+(h-2)+'></a>');
  }
if (f.indexOf(".swf")>0)showflash(w,h,f);
else document.write('<img src='+f+' width='+w+' height='+h+'>');
document.write('</div>');
}

