﻿///时间日期函数
function JHdatetime()
{       
today=new Date();
function initArray(){
this.length=initArray.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=initArray.arguments[i]  }
var d=new initArray(
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六");
document.write(
"<font color=#111111 style='font-size:9pt;font-family: 宋体'> ",
today.getYear(),"年",
today.getMonth()+1,"月",
today.getDate(),"日",
"</font>",
"<font color=blue style='font-size:9pt;font-family: 宋体'> ",
d[today.getDay()+1],
"</font>" ); 
}
function openScript(url, width, height){
	var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=no' );
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=500,left = 250,top = 100');");
}
//下拉菜单相关代码
 var h;
 var w;
 var l;
 var t;
 var topMar = 1;
 var leftMar = -2;
 var space = 1;
 var isvisible;
 var MENU_SHADOW_COLOR='#999999';//定义下拉菜单阴影色
 var global = window.document
 global.fo_currentMenu = null
 global.fo_shadows = new Array

function HideMenu() 
{
 var mX;
 var mY;
 var vDiv;
 var mDiv;
	if (isvisible == true)
{
		vDiv = document.all("menuDiv");
		mX = window.event.clientX + document.body.scrollLeft;
		mY = window.event.clientY + document.body.scrollTop;
		if ((mX < parseInt(vDiv.style.left)) || (mX > parseInt(vDiv.style.left)+vDiv.offsetWidth) || (mY < parseInt(vDiv.style.top)-h) || (mY > parseInt(vDiv.style.top)+vDiv.offsetHeight)){
			vDiv.style.visibility = "hidden";
			isvisible = false;
		}
}
}

function ShowMenu(vMnuCode,tWidth) {
	vSrc = window.event.srcElement;
	vMnuCode = "<table id='submenu' cellspacing=1 cellpadding=3 style='width:"+tWidth+"' class=menuskin onmouseout='HideMenu()'>" + vMnuCode + "</table>";

	h = vSrc.offsetHeight;
	w = vSrc.offsetWidth;
	l = vSrc.offsetLeft + leftMar+4;
	t = vSrc.offsetTop + topMar + h + space-2;
	vParent = vSrc.offsetParent;
	while (vParent.tagName.toUpperCase() != "BODY")
	{
		l += vParent.offsetLeft;
		t += vParent.offsetTop;
		vParent = vParent.offsetParent;
	}

	menuDiv.innerHTML = vMnuCode;
	menuDiv.style.top = t;
	menuDiv.style.left = l;
	menuDiv.style.visibility = "visible";
	isvisible = true;
    makeRectangularDropShadow(submenu, MENU_SHADOW_COLOR, 4)
}

function makeRectangularDropShadow(el, color, size)
{
	var i;
	for (i=size; i>0; i--)
	{
		var rect = document.createElement('div');
		var rs = rect.style
		rs.position = 'absolute';
		rs.left = (el.style.posLeft + i) + 'px';
		rs.top = (el.style.posTop + i) + 'px';
		rs.width = el.offsetWidth + 'px';
		rs.height = el.offsetHeight + 'px';
		rs.zIndex = el.style.zIndex - i;
		rs.backgroundColor = color;
		var opacity = 1 - i / (i + 1);
		rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
		el.insertAdjacentElement('afterEnd', rect);
		global.fo_shadows[global.fo_shadows.length] = rect;
	}
}
//文章内容字体控制
var initial_fontsize    = 12;
var initial_lineheight  = 18;
function adjust_fontsize(type,objname){
	var whichEl = document.getElementById(objname);
	if (whichEl!=null) {
		if (type==1){
			if(initial_fontsize<64){
				whichEl.style.fontSize=(initial_fontsize+3)+'px';
				whichEl.style.lineHeight=(initial_lineheight+3)+'px';
			}
		}else {
			if(initial_fontsize>8){
				whichEl.style.fontSize=(initial_fontsize)+'px';
				whichEl.style.lineHeight=(initial_lineheight)+'px';
			}
		}
	}
}

//图片按比列缩放
function setimgzoom(img, zoom,delay) {   
  setTimeout(function() {    
	  img.style.zoom=zoom+'%';
  }, delay);   
}

function imgzoom(img,zoom) {
	var oldzoom=parseInt(img.style.zoom, 10)||100;
	if (zoom>oldzoom)
	{
		for (i=oldzoom;i<=zoom ;i++ )
		{
			setimgzoom(img,i,10*(i-oldzoom));
		}
	}
	else
	{
      for (i=oldzoom;i>=zoom ;i-- )
      {
		  setimgzoom(img,i,10*(oldzoom-i));
      }
	}
}
function changeimg(img,source,width,height) {
img.src=source;
img.style.width=width;
img.style.height=height;
}
function setZoom(img, dir, width, height, margin, zIndex, delay) {   
  setTimeout(function() {    
      if (img.dir==dir) {
	  img.style.width=width;   
      img.style.height=height;   
      //img.style.margin=margin;   
      img.style.zIndex=zIndex;   
      img.parentNode.parentNode.style.zIndex=zIndex;
	  }
  }, delay);   
}   
  
function larger(img, width, height) {   
  img.dir='rtl';   
  now=parseInt(img.style.zIndex);   
  for (i=now+1; i<=10; i++) {   
    w=(width*(10+i))/20+'px';   
    h=(height*(10+i))/20+'px';   
    m=(-i)+'px 0 0 '+(-width*i/40)+'px';   
    setZoom(img, 'rtl', w, h, m, i, 20*(i-now));   
  }   
}   
 
function smaller(img, width, height) {   
  img.dir='ltr';   
  now=parseInt(img.style.zIndex);   
  for (i=now-1; i>=0; i--) {   
    w=(width*(10+i))/20+'px';   
    h=(height*(10+i))/20+'px';   
    m=(-i)+'px 0 0 '+(-width*i/40)+'px';   
    setZoom(img, 'ltr', w, h, m, i, 20*(now-i));   
  }   
}   

//图片等比例缩放
function DrawImage(ImgD, iwidth, iheight) { 
//参数(图片,允许的宽度,允许的高度)
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 >= 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; 
} 
ImgD.alt = image.width + "×" + 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.alt = image.width + "×" + image.height; 
} 
} 
} 

function resizepic(picname,width_v,height_v){
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
var backw=width_v;
var backh=height_v;
}else
{
var backw=width_v+8;
var backh=height_v+8;
}
var i = String(Math.floor(Math.random()*10000)+1);  
document.writeln("<div style='width:"+backw+"px;height:"+backh+"px;padding:3px;border:1px solid #a1a1a1;background:#fff;'>");
document.writeln("<div style='width:"+width_v+"px;height:"+height_v+"px;overflow:hidden;'>");
document.writeln("<img src='"+picname+"' id='img"+i+"'/></div></div>");
var pic=document.getElementById("img"+i);
if((width_v/height_v)>(pic.offsetWidth/pic.offsetHeight)){
pic.width=width_v;
}else
{
pic.height=height_v;
}
}
