﻿function $(o){return document.getElementById(o);}
function err(o){o.src="/img/nopic.gif";o.width=80;o.height=80;}
function showdiv(){
	return;
	//$("loaddiv2").style.background="";
	$("loaddiv2").style.background="url(/img/load.gif) no-repeat center 70px #F2FAFD";
	$("loaddiv").style.display="block";
}
function LoadImg(o,w,h){
	var pw=o.width;
	var ph=o.height;
	if(pw>w){o.width=w;o.height=w*ph/pw;}
	if(o.height>h){o.height=h;o.width=h*pw/ph;}
	if(pw>160){o.style.margin=(h-o.height)/2+"px "+(w-o.width)/2+"px";}
}
function LoadImg2(o,w,h){
	var pw=o.width;
	var ph=o.height;
	o.width=w;
	o.height=w*ph/pw;
	if(o.height>h){o.height=h;o.width=h*pw/ph;}
	//if(pw>w){o.width=w;o.height=w*ph/pw;}
	//if(o.height>h){o.height=h;o.width=h*pw/ph;}
	//if(pw>160){o.style.margin=(h-o.height)/2+"px "+(w-o.width)/2+"px";}
}

//Cookie
function SetCookie(sName, sValue,iExpireDays) {
	if (iExpireDays){
		var dExpire = new Date();
		dExpire.setTime(dExpire.getTime()+parseInt(iExpireDays*24*60*60*1000));
		document.cookie = sName + "=" + escape(sValue) + "; expires=" + dExpire.toGMTString();
	}
	else{
		document.cookie = sName + "=" + escape(sValue);
	}
}
function GetCookie(sName) {

	var arr = document.cookie.match(new RegExp("(^| )"+sName+"=([^;]*)(;|$)"));
	if(arr !=null){return unescape(arr[2])};
	return null;

}

//doPrint
function doPrint() { 
	bdhtml=window.document.body.innerHTML; 
	sprnstr="<!--startprint-->"; 
	eprnstr="<!--endprint-->"; 
	prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); 
	prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); 
	prnhtml=prnhtml+"<a href=\"http://china.53trade.com/\">中国外贸通</a>http://china.53trade.com"
	window.document.body.innerHTML=prnhtml; 
	window.print(); 
}

//cmscontents
function SetFontSize(size)
{
  var divBody = $("cmscontents");
  if(!divBody)
  {
	  return;
  }
  SetCookie("fontSize",size,30)
  divBody.style.fontSize = size + "px";
  divBody.style.lineHeight="180%";
  return;
  
  var divChildBody = divBody.childNodes;
  for(var i = 0; i < divChildBody.length; i++)
  {
	  if (divChildBody[i].nodeType==1)
	  {
		  divChildBody[i].style.fontSize = size + "px";
	  }
  }
}


function gurl(o,u){
	o.href=u;
}
