var allowImageWheel = false;	//是否允许滚轮缩放图片
var allowImagePopUp = true;		//是否允许点击图片打开新窗口
var allowImageLoadSize = true;	//是否允许使用正文图片载入大小限制
var maxImageWidth = 500;		//图片的最大宽度
	
//正文图片载入大小限制
function ImageLoad(obj)
{
	obj = document.getElementById(obj);
	if(obj == null)
		return;

	if(allowImageLoadSize)
	{
		for(var i = 0 ; i < obj.getElementsByTagName("img").length ; i++)
		{
			var imageObj = obj.getElementsByTagName("img")[i];
			imageObj.style.border = "1px solid #000000";

			if (imageObj.width > maxImageWidth)
			{
				if (imageObj.style.width)
					imageObj.style.width = "";

				imageObj.resized = 1;
				imageObj.width = maxImageWidth;
				imageObj.removeAttribute("height");

				if(!allowImagePopUp)
				{
					if(imageObj.parentElement.tagName == "A")
						imageObj.parentElement.removeAttribute("href","",0);
				}
				else
					imageObj.alt = "点击查看大图";

				if(allowImageWheel)
					imageObj.onmousewheel = ImageWheel;
			}
		}
	}
}

//图片滚轮缩放
function ImageWheel()
{	
	var zoom = parseInt(this.style.zoom, 10)||100;
	zoom += event.wheelDelta/12;
	if ( zoom>0 )
		this.style.zoom = zoom + '%';
	return false;
}

/*
//正文点击图片打开新窗口
function ImagePopUp()
{
	if (this.resized == 1 && this.parentElement.tagName != "A")
		window.open(this.src);
}
*/

//加载FLASH播放器
function FlashPlayer(url,width,height)
{
	var playerType = 1;

	if(playerType == 0)
	{
		document.write ("<div style=\"margin-top:20px;margin-bottom:20px;text-align:center\">");
		document.write ("<HTML xmlns:flash8>");
		document.write ("<import namespace=\"flash8\" implementation=\"" + ApplicationPath + "Library/Script/Player.htc\" />");
		document.write ("<flash8:player src=\"" + url + "\" width=\"500\" height=\"400\" />");
		document.write ("</div>");
	}
	else if(playerType == 1)
	{
		if(width == null)
			width = 500;
		if(height == null)
			height = 400;

		document.write ('<div style="margin-top:20px;margin-bottom:20px;text-align:center">');
		document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">');
		document.write ('  <param name="movie" value="' + url + '">');
		document.write ('  <param name="quality" value="high">');
		document.write ('  <embed src="' + url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');
		document.write ('</object>');
		document.write ('</div>');
	}
}

function RealPlayer(url,width,height,autostart)
{
	document.write ('<div style="margin-top:20px;margin-bottom:20px;text-align:center">');
	document.write ('<OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=' + width + ' height=' + height + '>');
	document.write ('	<PARAM NAME=AUTOSTART VALUE=' + autostart + '>');
	document.write ('	<PARAM NAME=SRC VALUE=' + url + '>');
	document.write ('	<PARAM NAME=CONSOLE VALUE=Clip1>');
	document.write ('	<PARAM NAME=CONTROLS VALUE=imagewindow>');
	document.write ('	<PARAM NAME=AUTOSTART VALUE=true>');
	document.write ('</OBJECT>');
	document.write ('<br/>');
	document.write ('<OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=32 id=video2 width=' + width + '>');
	document.write ('	<PARAM NAME=SRC VALUE=' + url + '>');
	document.write ('	<PARAM NAME=CONTROLS VALUE=controlpanel>');
	document.write ('	<PARAM NAME=CONSOLE VALUE=Clip1>');
	document.write ('</OBJECT>');
	document.write ('</div>');
}

function MediaPlayer(url,width,height,autostart)
{
	document.write ('<div style="margin-top:20px;margin-bottom:20px;text-align:center">');
	document.write ('<object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=' + width + ' height=' + height + '>');
	document.write ('	<param name=AUTOSTART value=' + autostart + '>');
	document.write ('	<param name=ShowStatusBar value=-1>');
	document.write ('	<param name=Filename value=' + url + '>');
	document.write ('	<embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src=' + url + ' width=' + width + ' height=' + height + '></embed>');
	document.write ('</object>');
	document.write ('</div>');
}

//内容字体大小调整
function ChangeSize(size,obj)
{
	var objSize = document.getElementById(obj);
	objSize.style.fontSize = size+"px";
}

//双击滚屏
var currentpos,timer; 
function initializeScroll()
{
	timer = setInterval("scrollwindow()",50);
}

function scrollclear()
{
	clearInterval(timer);
}

function scrollwindow() 
{
	currentpos=document.body.scrollTop;window.scroll(0,++currentpos);
	if (currentpos != document.body.scrollTop) sc();
} 
document.onmousedown=scrollclear
document.ondblclick=initializeScroll
