//加入收藏
function AddFav()
{
	window.external.addFavorite(window.document.location.href,document.title);
}

function Trim(strValue)
{
	return strValue.replace(/^\s*|\s*$/g,"");
}

function SetCookie(sName, sValue)
{
  document.cookie = sName + "=" + escape(sValue);
}

function GetCookie(sName)
{
  var aCookie = document.cookie.split(";");
  for (var i=0; i < aCookie.length; i++)
  {
    var aCrumb = aCookie[i].split("=");
    if (sName == Trim(aCrumb[0])) 
    {
    	return unescape(aCrumb[1]);
    }
  }

  return null;
}

function openWindow(url, width, height){
	var Win = window.open(url,"openWin",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no,status=yes' );
}

function Request(strName)
{
	var strHref = window.document.location.href;
	var intPos = strHref.indexOf("?");
	var strRight = strHref.substr(intPos + 1);

	var arrTmp = strRight.split("&");
	for(var i = 0; i < arrTmp.length; i++)
	{
		var arrTemp = arrTmp[i].split("=");

		if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
	}
	return "";
}

function SelectAll(form) {
	for (var i=0; i < document.forms[0].elements.length; i++)
		document.forms[0].elements[i].checked = !document.forms[0].elements[i].checked;
}

function bbimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}

function changeImgSize(obj)
{
	if(obj.width>screen.width-400)obj.style.width=screen.width-400;
}

function getByID(StringID)
{
	try
	{
		return document.getElementById(StringID);
	}
	catch (e){}	
}

//前台缩略图按比例缩放函数
//传入参数分别为,图片路径,显示宽度,图片替换文字,图片的Style,图片的CSS类,自动按比例设置大小
function ShowPreviewImg(imageSrc,dispWidth,dispHeight,useAutoSize,Tips,Style,CssClass)
{
	//By Lhstudio.Com
	var newWidth = dispWidth;
	var newHeight = dispHeight;
	var sourceWidth;	//源图片的宽度
	var sourceHeight;	//源图片的高度
	useAutoSize = eval(useAutoSize.toLowerCase());
	var outString = '<IMG Src="{Src}" Width="{Width}" Height="{Height}" Border="0" Alt="{Alt}" {Style} {CssClass}>';
	//使用自动按比例缩放
	if (useAutoSize)
	{
		imageOriginal = new Image() ;
		imageOriginal.src = imageSrc ;
		sourceWidth = imageOriginal.width;
		sourceHeight = imageOriginal.height;
		newHeight = ((newWidth / 4) * 3);
		if (sourceWidth == 0)
		{
			sourceWidth = newWidth;
			sourceHeight = newHeight;
		}
		if (( Math.round(sourceWidth) / Math.round(sourceHeight)) >= 1.3333333333333333)
		{
			newHeight = ((sourceHeight * newWidth) / sourceWidth); 
		}
		else
		{
			newWidth = ((sourceWidth * newHeight) / sourceHeight); 
		}
	}
	outString = outString.replace("{Src}",imageSrc);
	outString = outString.replace("{Width}",newWidth);
	outString = outString.replace("{Height}",newHeight);
	outString = outString.replace("{Alt}",Tips);
	outString = outString.replace("{Style}",Style);
	outString = outString.replace("{CssClass}",CssClass);
	document.write(outString);
}

function ShowNavMenu(ID,NavMenuCount)
{
	for ( var i = 0; i < NavMenuCount; i++ )
	{
		try
		{
			document.all['NavMenu_' + i].style.display = "none";
			if ( i == ID)
			{
				document.all['NavMenu_' + ID].style.display = "inline";
			}
		}
		catch(e){}
	}
}


function stopme(chipname){
	if(brOK){
		eval("chip="+chipname);
		if(chip.timer1!=null){
			clearTimeout(chip.timer1)
		}
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}