// JavaScript Document
/**
 * 去除字符串头尾的空格
 * @param str 被TRIM的字符串
 */
function trim(str){
   return(trimExt(str,' '));	
}

//设为首页
function setHP(obj,url){
	if(document.all){
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(url);
	}
	else alert("提示：\n\t对不起,您的浏览器不支持！\n\t请手工从 工具 > 选项 中设置。");
}
//加入收藏夹
function bookmark(url){
	var title=document.title;
	if (window.sidebar) window.sidebar.addPanel(title, url,"");
	else if( window.opera && window.print ){
	var mbm = document.createElement('a');
	mbm.setAttribute('rel','sidebar');
	mbm.setAttribute('href',url);
	mbm.setAttribute('title',title);
	mbm.click();}
	else if( document.all ) window.external.AddFavorite( url, title);
	return false;
}

//MSN在线聊天
function addMSN (address) {
/*	var obj=document.createElement("object");
	obj.setAttribute("id","MsgrUIA");
	obj.setAttribute("height",'0');
	obj.setAttribute("width",'0');
	obj.setAttribute("codeType","application/x-oleobject");
	obj.setAttribute("classid","clsid:B69003B3-C55E-4b48-836C-BC5946FC3B28");*/
	var strMSN="<object id='MsgrUIA' height='0' codeType='application/x-oleobject' width='0' classid='clsid:B69003B3-C55E-4b48-836C-BC5946FC3B28'></object>";
	document.getElementById("MSN").innerHTML=strMSN;
	//alert(address);
	if (MsgrUIA.MyStatus == 1)
	{
		alert('Your MSNmessager is off line, please log on.');
	}
	else if(MsgrUIA.MyStatus == 2 || MsgrUIA.MyStatus == 10 || MsgrUIA.MyStatus == 14 || MsgrUIA.MyStatus == 34 || MsgrUIA.MyStatus == 50 || MsgrUIA.MyStatus == 66 || MsgrUIA.MyStatus == 6) {   //2,10, 14, 34, 50,66,6
		MsgrUIA.InstantMessage(address);
	}
	else if (MsgrUIA.MyStatus == 512 || MsgrUIA.MyStatus == 768)
	{
		alert('Logging on, please wait......');
	}
	else {
		alert('If you haven t installed MSNmessager or your browser isn t internet explorer  please install MSNmessager and add manually'+ address  );
	}
	//alert(emailaddr);
}
var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)

{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }

  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
return false;
}

//email验证格式
function isEmail(email)   
  {   
	var reEmail = /^([A-Za-z0-9])(\w)+@(\w)+(\.)(com|com\.cn|net|cn|net\.cn|org|biz|info|gov|gov\.cn|edu|edu\.cn)/;   
	if (!email.match(reEmail)&&email!="")   
	{     
		return   false;   
	}   
	else   return   true;   
  }   


function changeImg(ImgD,width,height) {
   var flag=false;
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= 1){
     if(image.width>width){ 
		  if ((image.height*width/image.width)<height)
		  {
             ImgD.width=width;
	         ImgD.height=(image.height*width)/image.width;

		  }
          else{
			 ImgD.height=height;
			 ImgD.width=(image.width*height)/image.height;     
		  }
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }

     }
    else{
     if(image.height>height)
	 {  
         if ((image.width*height/image.height)<width)
         {
            ImgD.height=height;
            ImgD.width=(image.width*height)/image.height;     
         }
		 else{
             ImgD.width=width;
	         ImgD.height=(image.height*width)/image.width;
		 }
     }
	 else
	 {
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     }
    }
   }

