//srcStr 数字
//nAfterDot 位数
function numberFormat(srcStr,nAfterDot)   
  {   
  　　var   srcStr,nAfterDot;   
  　　var   resultStr,nTen;   
  　　srcStr   =   ""+srcStr+"";   
  　　strLen   =   srcStr.length;   
  　　dotPos   =   srcStr.indexOf(".",0);   
  　　if   (dotPos   ==   -1){   
  　　　　resultStr   =   srcStr+".";   
  　　　　for   (i=0;i<nAfterDot;i++){   
  　　　　　　resultStr   =   resultStr+"0";   
  　　　　}   
  　　　　return   resultStr;   
  　　}   
  　　else{   
  　　　　if   ((strLen   -   dotPos   -   1)   >=   nAfterDot){   
  　　　　　　nAfter   =   dotPos   +   nAfterDot   +   1;   
  　　　　　　nTen   =1;   
  　　　　　　for(j=0;j<nAfterDot;j++){   
  　　　　　　　　nTen   =   nTen*10;   
  　　　　　　}   
  　　　　　　resultStr   =   Math.round(parseFloat(srcStr)*nTen)/nTen;   
  　　　　　　return   resultStr;   
  　　　　}   
  　　　　else{   
  　　　　　　resultStr   =   srcStr;   
  　　　　　　for   (i=0;i<(nAfterDot   -   strLen   +   dotPos   +   1);i++){   
  　　　　　　　　resultStr   =   resultStr+"0";   
  　　　　　　}   
  　　　　　　return   resultStr;   
  　　　　}   
  　　}   
  } 

//--------------------------------------
function _pTip(s,o)//提示信息
{
var oo=o.offsetParent;
oo.innerHTML=o.outerHTML+"<span style='font-size:14px;color:#ff0000;font-weight:bold;'>"+s+"</span>";
}
//--------------------------------------
// Description: Valid check for JavaScript
// Usage: <script type=text/javascript src=/check.js></script>
// Function Listing:
//  function chkdate(yearStr, monthStr, dayStr)
//  function chkdatestr(checkStr)
//  function chkemail(checkStr)
//  function chkfloat(checkStr)
//  function chkinteger(checkStr)
//  function chklength(checkStr)
//  function chkname(checkStr)
//  function chknegative(checkStr)
//  function chknostring(checkStr, forbidStr)
//  function chknumber(checkStr)
//  function chkpasswd(checkStr)
//  function chkphone(checkStr)
//  function chkquot(checkStr)
//  function chksafe(checkStr)
//  function chkspace(checkStr)
//  function chkstring(checkStr, checkOK)
//  function trim(w)
//  function trimform(TheForm)


//函数名：chkdate
//功能介绍：检查是否为合法日期
//参数说明：要检查的字符串年、月、日
//返 回 值：false:不是  true:是
function chkdate(yearStr, monthStr, dayStr) {
  var checkOK = "1234567890";
  if ( !chkstring(yearStr, checkOK) ||
       !chkstring(monthStr, checkOK) ||
       !chkstring(dayStr, checkOK) )
    return(false);

  testday = new Date();
  testday.setFullYear(yearStr, monthStr-1, dayStr);
  var tmpy = testday.getFullYear();
  var tmpm = testday.getMonth() + 1;
  var tmpd = testday.getDate();
  if (tmpy == yearStr && tmpm == monthStr && tmpd == dayStr) {
    return(true);
  } else {
    return(false);
  }
}


//函数名：chkdateStr
//功能介绍：检查是否为合法日期
//参数说明：要检查的字符串YYYY-MM-DD
//返 回 值：false:不是  true:是
function chkdatestr(checkStr) {
  var tmpy = "";
  var tmpm = "";
  var tmpd = "";
  var checkCode = 0;
  for (i=0; i<checkStr.length ;i++) {
    ch = checkStr.charAt(i);
    if (ch == '-') checkCode++;
    if (checkCode > 2) return(false);
    else if (checkCode == 0 && ch != '-') tmpy += ch;
    else if (checkCode == 1 && ch != '-') tmpm += ch;
    else if (checkCode == 2 && ch != '-') tmpd += ch;
  }
  if (chknumber(tmpy) && tmpy.length == 2) {
    if (tmpy > 70) tmpy = "19" + tmpy;
    else tmpy = "20" + tmpy;
  }
  return(chkdate(tmpy, tmpm, tmpd));
}

function chkletterAndnumber(checkStr) {
  var checkOK = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
  return(chkstring(checkStr, checkOK));
}



//函 数 名：chkemail
//功能介绍：检查是否为合法的Email Address
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
//校验规则：不能以.或@开头和/或结尾，不能包含1个以上@，形如*@(*.)*
/*
function chkemail(checkStr) {
  var checkOK = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@._-";
  var allValid = false;
  var checkCode = 0;
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    if (ch == "@") {
      if (checkCode == 0 && i > 0) {
        checkCode = 1;
      } else {
        break;
      }
    }
    if (ch == ".") {
      if (i == 0 || i == checkStr.length - 1) {
        break;
      } else if (checkStr.charAt(i+1) == '.') {
        break;
      } else if (checkCode == 0) {
        if (checkStr.charAt(i+1) == '@') {
          break;
        }
      } else if (checkCode == 1) {
        if (checkStr.charAt(i-1) == '@') {
          break;
        } else {
          checkCode = 2;
        }
      }
    }
    chValid = false;
    for (j = 0; j < checkOK.length; j++) {
      if (ch == checkOK.charAt(j)) {
        chValid = true;
        break;
      }
    }
    if (!chValid) break;
    if (i == checkStr.length - 1 && checkCode == 2) {
      allValid = true;
      break;
    }
  }
  return(allValid);
}
*/
function chkemail(checkStr)
{
	var regExp=new RegExp("^([a-z0-9A-Z_]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$","i");
	if(regExp.test(checkStr))
	    return true;
    else
	    return false;
}
//函 数 名：chkfloat
//功能介绍：检查是否为小数
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
function chkfloat(checkStr) {
  if (chknumber(checkStr) && checkStr.indexOf(".") >= 0) {
    return(true);
  } else {
    return(false);
  }
}


//函 数 名：chkinteger
//功能介绍：检查是否为数字
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
function chkinteger(checkStr) {
  var checkOK = "0123456789+-";
  var allValid = true;
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    if (checkOK.indexOf(ch) == -1) {
      allValid = false;
      break;
    }
    if ((ch == '+' || ch == '-') && i > 0) {
      allValid = false;
      break;
    }
  }
  return(allValid);
}


//函 数 名：chklength
//功能介绍：检查字符串的长度
//参数说明：要检查的字符串
//返 回 值：字节长度值
function chklength(checkStr) {
  var n = 0;
  for(i=0; i<checkStr.length; i++) {
    chcode = checkStr.charCodeAt(i);
    if (chcode >=0  && chcode <= 255) {
      n++;
    } else {
      n += 2;
    }
  }
  return(n);
}


//函 数 名：chkname
//功能介绍：检查是否符合名称要求
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
function chkname(checkStr) {
  var forbidStr = "`~!@#$%^&*()_+=|\\{}[];:,<>?/\"\'";
  return(!chknostring(checkStr, forbidStr));
}


//函 数 名：chknegative
//功能介绍：检查是否为负数
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
function chknegative(checkStr) {
  if (chknumber(checkStr) && checkStr.charAt(0) == '-') {
    return(true);
  } else {
    return(false);
  }
}


//函 数 名：chknostring
//功能介绍：检查是否含非法字符
//参数说明：要检查的字符串，合法的字符串集合
//返 回 值：false:不是  true:是
function chknostring(checkStr, forbidStr) {
  var allValid = false;
  if (typeof(checkStr) != "string" || typeof(forbidStr) != "string") return(false);
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    if (forbidStr.indexOf(ch) >= 0) {
      allValid = true;
      break;
    }
  }
  return(allValid);
}


//函 数 名：chknumber
//功能介绍：检查是否为数字
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
function chknumber(checkStr) {
  var checkOK = "0123456789.+-";
  var allValid = true;
  var checkCode = 0;
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    if (checkOK.indexOf(ch) == -1) {
      allValid = false;
      break;
    }
    if ((ch == '+' || ch == '-') && i > 0) {
      allValid = false;
      break;
    }
    if (ch == '.') {
      checkCode += 1;
      if (checkCode > 1) {
        allValid = false;
        break;
      }
    }
  }
  return(allValid);
}


//函 数 名：chkpasswd
//功能介绍：检查是否符合密码要求
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
function chkpasswd(checkStr) {
  var checkOK ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
  return(chkstring(checkStr, checkOK));
}


//函 数 名：checkphone
//功能介绍：检查是否为电话号码
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
function chkphone(checkStr) {
  var checkOK = "0123456789-()# ,;:";
  return(chkstring(checkStr, checkOK));
}


//函 数 名：chkquot
//功能介绍：检查是否含有引号（单引号和/或双引号）
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
function chkquot(checkStr) {
  var allValid = false;
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    if (ch == "'" || ch == '"') {
      allValid = true;
      break;
    }
  }
  return(allValid);
}


//函 数 名：chksafe
//功能介绍：检查是否含有&;`'\"|*?~<>^()[]{}$\n\r
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
function chksafe(checkStr) {
  var allValid = true;
  var forbidStr = new Array ("&", ";", "`", "'", "\"", "|", "*", "?", "~", "<", ">", "^", "(", ")", "[", "]", "{", "}", "$", "\n", "\r");
  m = forbidStr.length;
  n = checkStr.length;
  for (i=0; i<m; i++) {
    for (j=0; j<n; j++) {
      ch1 = checkStr.charAt(j);
      ch2 = forbidStr[i];
      if (ch1 == ch2) {
        allValid = false;
        break;
      }
    }
  }
  return(allValid);
}


//函 数 名：chkspace
//功能介绍：检查是否含有空格
//参数说明：要检查的字符串
//返 回 值：false:不是  true:是
function chkspace(checkStr) {
  var allValid = false;
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    if (ch == " " || ch == "　") {
      allValid = true;
      break;
    }
  }
  return(allValid);
}


//函 数 名：chkstring
//功能介绍：检查是否全部合法
//参数说明：要检查的字符串，合法的字符串集合
//返 回 值：false:不是  true:是
function chkstring(checkStr, checkOK) {
  var allValid = true;
  if (typeof(checkStr) != "string" || typeof(checkOK) != "string") return(false);
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    if (checkOK.indexOf(ch) == -1) {
      allValid = false;
      break;
    }
  }
  return(allValid);
}


//函 数 名：trim
//功能介绍：删除两端的空格符号（全角和／或半角）
//参数说明：要处理的字符串
//返 回 值：处理后的字符串
function trim(w) {
  while (w.length>0 && (w.substr(0,1)==' ' || w.substr(0,1)=='　')) w=w.substr(1);
  while (w.length>0 && (w.substr(w.length-1)==' ' || w.substr(w.length-1)=='　')) w=w.substr(0,w.length-1);
  return(w);
}


//函 数 名：trimform
//功能介绍：对表单内所有text类型做trim操作
//参数说明：要处理的表单名
//返 回 值：false:失败  true:成功
function trimform(TheForm) {
  if (typeof(TheForm) != "object") return(false);
  for (var i=0; i<TheForm.elements.length; i++) {
    var e = TheForm.elements[i];
    if (e.type == 'text') {
      e.value = trim(e.value);
    }
  }
  return(true);
}
//申明表单不合法
function alert2(obj,str){
alert(str);
obj.focus();
return false;
}
//------------------------------------保存，加载客户端表单数据 需要IE5.0支持

function saveForm(formObj,fileName)
{
	if(!formObj) return;
	try{if(formObj.tagName!="FORM") return;}catch(e){return;}
	for(var i=0;i<formObj.elements.length;i++)
	  {
		   var e=formObj.elements(i);
		   
		   if(e.tagName!="INPUT"&&e.tagName!="TEXTAREA"&&e.tagName!="SELECT")
		     continue;
		   
		   if(e.tagName=="TEXTAREA")
		   {
			   try{
				   e.expires=getExpires();
				   e.setAttribute(e.name,e.value);
				   e.save(e.name+"_"+fileName);
				   }catch(e){}
			   continue;
		   }
		   if(e.tagName=="SELECT")
		   {
			   try{
				   e.expires=getExpires();
				   e.setAttribute(e.name+"_value",e.value);
				   e.setAttribute(e.name+"_index",e.selectedIndex);
				   e.setAttribute(e.name+"_name",e.options[e.selectedIndex].text);
				   e.save(e.name+"_"+fileName);
			   }catch(e){
			   }
			   continue;
		   }
		   
		   if(e.type=="hidden"||e.type=="password"||e.type=="submit"||e.type=="button"||e.type=="reset")
		     continue;
		   //text,radio,checkbox
		   if(e.type=="text"){
			   try{
				   e.expires=getExpires();
				   e.setAttribute(e.name,e.value);
				   e.save(e.name+"_"+fileName);
				   }catch(e){}
		   }
		   
		   if(e.type=="radio"){
              eval("var radioObj=document.all."+formObj.name+"."+e.name+";");
		   for(var ii=0;ii<radioObj.length;ii++)
		     {
				  if(radioObj[ii].checked)
				    {
						try{
						radioObj[ii].expires=getExpires();
						radioObj[ii].setAttribute(e.name,radioObj[ii].value);
						radioObj[ii].setAttribute(e.name+"_index",ii+"");
						radioObj[ii].save(e.name+"_"+fileName);
						}catch(e){}
						break;
					}
			 }
		   }
		   
		   if(e.type=="checkbox"){
		    var valueList="";
			var indexList="";
			eval("var checkObj=document.all."+formObj.name+"."+e.name+";");
			for(var iii=0;iii<checkObj.length;iii++)
			  {
				   var ee=checkObj[iii];
				   if(ee.checked){
				     valueList=valueList+"|||||"+ee.value;
					 indexList=indexList+"|||||"+iii+"";
				   }
			  }
			 if(valueList!=""){
			   valueList=valueList.substring(5);
			   indexList=indexList.substring(5);
			 }
			try{
				ee.expires=getExpires();
				ee.setAttribute(e.name,valueList);
			    ee.setAttribute(e.name+"_index",indexList);
				ee.save(e.name+"_"+fileName);
				}catch(e){}
		   }

	  }
}

function loadForm(formObj,fileName)
{
	if(!formObj){
		alert("debug:formObj null");
		return;
	}
	try{if(formObj.tagName!="FORM") return;}catch(e){ alert("debug:formObj null");return;}
	for(var i=0;i<formObj.elements.length;i++)
	  {
		  var e=formObj.elements(i);
		  if(e.tagName!="INPUT"&&e.tagName!="TEXTAREA"&&e.tagName!="SELECT")
		    continue;
		  if(e.tagName=="TEXTAREA")
		  {
			 var content=null;
			 try{
			 e.load(e.name+"_"+fileName);
			 content=e.getAttribute(e.name);
			 e.value=content;
			 }catch(e){}
			 continue;
		   }
		   
		  if(e.tagName=="SELECT")
		  {
			  try{
				  e.load(e.name+"_"+fileName);
				  var selectedIndex=e.getAttribute(e.name+"_index");
				  if(selectedIndex!="")
				    e.selectedIndex=parseInt(selectedIndex,10);
			  }catch(e){}
			  continue;
		  }
		  if(e.type=="hidden"||e.type=="password"||e.type=="submit"||e.type=="button"||e.type=="reset")
		     continue;
		  
		  if(e.type=="text")
		   {
			   try{
				   e.load(e.name+"_"+fileName);
				   var cc=e.getAttribute(e.name);
				   e.value=cc;
			   }catch(e){}
			   continue;
		   }
		   
		  if(e.type=="radio")
		  {
			  try{
				  e.load(e.name+"_"+fileName);
				  var ii=e.getAttribute(e.name+"_index");
				  eval("var radioObj=document.all."+formObj.name+"."+e.name+";");
				  if(ii!="")
				  radioObj[parseInt(ii,10)].checked=true;
			  }catch(e){}
			  continue;
		  }
		  
		  if(e.type=="checkbox")
		  {
			  try{
				  e.load(e.name+"_"+fileName);
				  var indexList=e.getAttribute(e.name+"_index");
				  if(indexList=="")
				  continue;
				  var sList=indexList.split("|||||");
			     eval("var checkObj=document.all."+formObj.name+"."+e.name+";");
				  for(var iii=0;iii<sList.length;iii++)
				   {
					   var oo=-1;
					   try{
						   oo=parseInt(sList[iii],10);
						   checkObj[oo].checked=true;
					   }catch(e){continue;}
				   }
			  }catch(e){}
		  }
	  }
}

//
function getExpires()
{
	 var d=new Date();
	 d.setHours(d.getHours()+1);
	 return d.toUTCString();
}
//-----------------------------------------------12.15添加
//选中下拉列表某一项
function selectValue(selectObj,value)
{
 if(!selectObj) return;
 if(selectObj.tagName!="SELECT") return;
 for(var i=0;i<selectObj.options.length;i++)
  {
    var e=selectObj.options[i];
    if(e.value==value){
    selectObj.selectedIndex=i;
    break;
    }  
   }
}
function setRadioValue(selectObj,value){
if(!selectObj) return;
if(selectObj.tagName!="INPUT"&&selectObj.type=="radio") return;
for(var i=0;i<selectObj.length;i++)
 {
	 var e=selectObj[i];
	 if(e.value==value){
	 e.checked=true;
	 return;
	 }
 }
}
function setCheckboxValue(selectObj,value){
	for(var i=0;i<selectObj.length;i++)
	 {
		 
		 var e=selectObj[i];
		 if(!e) return;
		 if(e.tagName!="INPUT"&&e.type!="checkbox") return;
		 //value = value.replace(/\s+/g,"");
		 var splitStr = value.split(", ");
		 for(var j=0;j<value.length;j++){
			 if(e.value==splitStr[j]){
			 	e.checked=true;
			 }
		 }
	 }
}

function maketFormState(formObj,disabled)//make a form disabled
{
	if(!formObj){
	return;
	}
	for(var i=0;i<formObj.elements.length;i++)
	{
		 var e=formObj.elements(i);
		 if(typeof(e.disabled)=="boolean")
		  e.disabled=disabled;
	}
}
function getCheckNum(formObj,checkName)//get checkBoxes num
{
	if(!formObj){
	return;
	}
	var checkNum=0;
	for(var i=0;i<formObj.elements.length;i++)
	 {
		 var e=formObj.elements(i);
		 if(e.tagName=="INPUT"&&e.type=="checkbox"&&e.name==checkName&&e.checked)
		  checkNum++;
	 }
	 return checkNum;
}
function isChecked(formObj,checkName) //for checkBox
{
	var checkNum=getCheckNum(formObj,checkName);
	if(checkNum>0)
	 return true;
	else
	 return false;
}
function isChecked2(formObj,radioName)//for radio
{
	if(!formObj) return;
	for(var i=0;i<formObj.elements.length;i++)
	 {
		 var e=formObj.elements(i);
		 if(e.tagName=="INPUT"&&e.type=="radio"&&e.name==radioName&&e.checked)
		   return true;
	 }
	 return false;
}



function __globalErrorHandler(sMsg,sUrl,sLine){
//handle Error
alert("页面错误!\n错误描述:"+sMsg+"\n+URL:+"+sUrl+"\n行:"+sLine);
if(confirm("是否重新刷新页面？"))
 location.reload(true);

}

function __showObj(objId,targetObjId)//show Obj
{
  var obj=document.getElementById(objId);
  var _showObj=document.getElementById(targetObjId);
  if(!obj||!_showObj) return;
  var targetObj=obj;
  var offLeft=0;
  var offTop=0;
  if(obj==null)
     return;
	 do{
	 targetObj=targetObj.offsetParent;
	 offLeft=offLeft+targetObj.offsetLeft;
	 offTop=offTop+targetObj.offsetTop;
	 }while(targetObj.tagName!="BODY")
	 
	 offTop=offTop+obj.offsetHeight+obj.offsetTop;
	 offLeft=offLeft+obj.offsetLeft;
	 _showObj.style.display="none";
	 _showObj.filters[0].Apply();
	 _showObj.style.top=offTop;
	 _showObj.style.left=offLeft;
	 _showObj.filters[0].Play(duration=0.5);
	 _showObj.style.display="";
	 event.cancelBubble=true;
}
function __hideObj(idList,objId)//hide obj
{
  if(!document.getElementById(objId)) return;

  var t=event.srcElement;    
  var i=false;
  do{
  if(__checkHasId(idList,t.id))
    {
	  i=true;
	  break;
	}
	t=t.offsetParent;
  }while(t&&t.tagName!="BODY")
  if(i)
   return;
   else{
	var divObj=document.getElementById(objId);
	divObj.filters[0].Apply();
	divObj.filters[0].Play(duration=0.5);
    divObj.style.display="none";
   }
}
function __checkHasId(idList,id)
{
	var ids=idList.split(",");
	for(var i=0;i<ids.length;i++)
	  if(ids[i]==id) return true;
	return false;
}

function __attachEvent(eventName,funcName)
{
  if(typeof(funcName)!="function") return;
  try{document.attachEvent(eventName,funcName);}catch(e){alert(e);}
  
}

 function __autoResize(obj)
 {
  try
  {
  eval("var t=document.all."+obj+".style.height;");
  eval("document.all."+obj+".style.height="+obj+".document.body.scrollHeight;");
  }
  catch(e)
  {
  }
 }
 
 //-----------image util------------------------------
 function DrawImage(ImgD,iwidth,iheight){
	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 limitImage(limitw,limith){
	  	var image = new Image();
		var imgTag = event.srcElement;
		image.src=imgTag.src;
		w = image.width;
		h = image.height;
		//alert("w:"+w+"h:"+h);
		if (w>limitw||h>limith){
			if (limitw/w >= limith/h)
				imgTag.height = limith;
			else
				imgTag.width = limitw;
		}
  }
  
  function   limitImagesize(limitw,limith){  
  		  var   tmp=new   Image(); 
		  var   tp=event.srcElement     
		  tmp.src=tp.src;   
		  var   pw=parseInt(tmp.width)   
		  var   ph=parseInt(tmp.height)   
		  if(pw>limitw   &&   pw!=0){   
		  ph=Math.floor(ph/pw*limitw)   
		  pw=limitw   
		  }   
		  if(ph>limith   &&   ph!=0){   
		  pw=Math.floor(pw/ph*limith)   
		  ph=limith   
		  }   
		  if(pw==0   ||   ph==0){   
		  pw=limitw;   
		  ph=limith;   
		  }   
		  tp.width=pw;   
		  tp.height=ph;   
	  }


