﻿// JScript 文件
//<td colspan="3" style="height: 21px">中间显示图片的div<div id="mmpic"></div></td>这是网友上使用的代码
function ViewPhoto(id){
 var mmpictitle=arrUrlTitle[id];
 var mmclick=arrUrlClick[id];
 var PhotoUrl=arrUrl[id];
 var ImgaddTime=arrUrlAddTime[id];
 var strHtml;
  var FileExt=PhotoUrl.substr(PhotoUrl.lastIndexOf('.')+1).toLowerCase();
  if(FileExt=='gif'||FileExt=='jpg'||FileExt=='png'||FileExt=='bmp'||FileExt=='jpeg'){
    strHtml="<a href='"+PhotoUrl+"'target='_blank'><img src='"+PhotoUrl+"' border='0' onload='resizePhoto(this);' ></a>";
  }
  else 
  {
    strHtml=PhotoUrl;
    }
  document.getElementById("ImageTitle").innerHTML=mmpictitle;
  document.getElementById("ImgAddTime").innerHTML=ImgaddTime;
  document.getElementById("mmpic").innerHTML=strHtml; 
}
function ShowUrlList(page){
  if(arrUrl.length<=1) return false;
  var dTotalPage=arrUrl.length/4;
  var TotalPage;
  var MaxPerPage=4;
  if(arrUrl.length%MaxPerPage==0){TotalPage=Math.floor(dTotalPage);}else{TotalPage=Math.floor(dTotalPage)+1;}
  if(page<1) page=1;
  if(page>TotalPage) page=TotalPage;
  var strPage;
  if(TotalPage>1)
  {
  strPage="<table  width='98%' border='1' align='center' cellpadding='0' cellspacing='1' bordercolor='#D7D7D7' style='border-collapse:collapse;'><tr><td  bgcolor='#F3F3F3' style='padding-bottom:5px;'><div class='sImg_left'><a href='#Title' onclick=ShowUrlList(1)><img src='images/home.jpg' alt='第一页' width='28' height='25' border='0' /></a><a href='#Title' onclick=ShowUrlList("+(page-1)+")><img src='images/pre.jpg' alt='上一页' width='28' height='25' border='0' /></a></div><div id='PhotoUrlList4' class='sImg_center'>";
    for(var j=(page-1)*MaxPerPage;j<arrUrl.length&&j<page*MaxPerPage;j++){
    strPage+="<a href='#' onclick=ViewPhoto("+j+")><img src='"+arrUrl[j]+"' height='80' width='94' style='margin-left:6px;'></a>";

    }
  
  strPage+="</div><div class='sImg_right'><a href='#Title' onclick=ShowUrlList("+(page+1)+")><img src='images/next.jpg' alt='下一页' width='28' height='25' border='0' /></a><a href='#Title' onclick=ShowUrlList("+TotalPage+")><img src='images/end.jpg' alt='尾页' width='28' height='25' border='0' /></a></div></td></tr></table>";
  }
  else
  {
    strPage="<table  width='98%' border='1' align='center' cellpadding='0' cellspacing='1' bordercolor='#D7D7D7' style='border-collapse:collapse;'><tr><td  bgcolor='#F3F3F3' style='padding-bottom:5px;'><div class='sImg_left'><img src='images/home.jpg' alt='第一页' width='28' height='25' border='0' /><img src='images/pre.jpg' alt='上一页' width='28' height='25' border='0' /></div><div id='PhotoUrlList4' class='sImg_center'>";
    for( var vark=(page-1)*MaxPerPage;vark<arrUrl.length&&vark<page*MaxPerPage;vark++){
    strPage+="<a href='#Title' onclick=ViewPhoto("+vark+")><img src='"+arrUrl[vark]+"' height='80' width='100' style='margin-left:6px;'></a>";
    }
  strPage+="</div><div class='sImg_right'><img src='images/next.jpg' alt='下一页' width='28' height='25' border='0' /><img src='images/end.jpg' alt='尾页' width='28' height='25' border='0' /></div></td></tr></table>";
  }
  document.getElementById("ImageTop").innerHTML=strPage;
}

	function resizePhoto(img)
	{
		if (img.width >500)
		{
			img.width =500;
		}
}
