/*
  --  对图片进行大小比列的缩略
*/
// 自动缩放图片
function AutoSetImgSize(_element, _maxWidth, _maxHeight, _alignBottom)
 {
    var _o = document.createElement("img");
	_element.style.display = "block";
    _o.onload = function () {
		var _ratio = this.height / this.width;
		if (this.height >= this.width && this.height > _maxHeight) {
			_element.style.height = _maxHeight + "px";
			_element.style.width = "auto";
			return;
		}
		if (this.width > this.height && this.width > _maxWidth) {
			_element.style.width = _maxWidth + "px";
			_element.style.height = "auto";
			_elementHeight = _maxWidth * _ratio;
		} else {
			_element.style.width = this.width + "px";
			_element.style.height = "auto";
			_elementHeight = this.height;
		}
		if (_elementHeight < _maxHeight) {
			if (_alignBottom) {
				_element.style.marginTop = _maxHeight - _elementHeight + "px"
			}
		}
    }
    _o.src = _element.src;
}

// 	flash播放器 -- 功能： 图片的自动轮播			
function flashMedia(pics,links,texts,flasrc)
	{		
		var focus_width=229; 
		var focus_height=150; 
		var text_height=0;
		var swf_height = focus_height+text_height;
		
		var flaMediaText = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
		flaMediaText+=' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height ;
		flaMediaText+= '">' ;
		flaMediaText+= '<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="'+flasrc+'"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">' ;
		flaMediaText+= '<param name="menu" value="false"><param name="wmode" value="opaque">' ;
		flaMediaText+= '<param name="FlashVars" value="pics='+pics+'&links='+links+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">' ;
		flaMediaText+= '</object>' ;
		
		return flaMediaText ;
	}
// 播放视频
function PlayMediaVideo(videosrc)
{
   var vsrc = videosrc ;
   var width = 550 ;
   var height = 470 ; //406
   document.writeln("<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab\" width=\""+width+"\" height=\""+height+"\">");
   document.writeln("<param name=\"FileName\" value=\""+vsrc+"\">");
   document.writeln("<param name=\"AutoStart\" value=\"true\">");
   document.writeln("<param name=\"ShowTracker\" value=\"true\">");
   document.writeln("<param name=\"ShowControls\" value=\"true\">");
   document.writeln("<param name=\"ShowGotoBar\" value=\"false\">");
   document.writeln("<param name=\"ShowDisplay\" value=\"false\">");
   document.writeln("<param name=\"ShowStatusBar\" value=\"true\">");
   document.writeln("<param name=\"AutoSize\" value=\"false\">");
   document.writeln("<embed src=\""+vsrc+"\" AutoStart=\"true\" ShowTracker=\"true\" ShowControls=\"true\"  ShowGotoBar=\"false\" ShowDisplay=\"false\" ShowStatusBar=\"false\" AutoSize=\"false\" pluginspage=\"http://www.microsoft.com/windows/windowsmedia/download/\" width=\""+width+"\" height=\""+height+"\"></embed>");
   document.writeln("</object>");
}
					