// JavaScript Document
//****************************************************
// Author: Vagrant
// Email: hunan_cs@hotmail.com . QQ:59746171
// Web: http://www.Vagnet.Net
//****************************************************
function jtrim(str)
{     while ((str.charAt(0)==" ")||(str.charAt(0)=="　"))
          {str=str.substr(1);}      
     while (str.charAt(str.length-1)==" ")
         {str=str.substr(0,str.length-1);}
     return(str);
}

function chkLength(strTemp)
{
	var i,sum;
	sum=0;
	for(i=0;i<strTemp.length;i++)
	{
		if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
			sum=sum+1;
		else
			sum=sum+2;
	}
	return sum;
}

function $(e)
{
	return document.getElementById(e);
}
function $v(e)
{
	return document.getElementById(e).value;		
}

	

//函数名：fucCheckTel
//功能介绍：检查是否为电话号码
//参数说明：要检查的电话号码
//返回值：1为是电话号码，0为不是电话号码
function fucCheckTel(Tel)
{
	var i,j,strTemp;
	strTemp="0123456789-#() ";
	if (Tel.length < 7 )
	{
	 return 0;
	 }
	for (i=0;i<Tel.length;i++)
	{
		j=strTemp.indexOf(Tel.charAt(i));	
		if (j==-1)
		{
		//说明不是电话号码
			return 0;
		}
	}
	//说明是电话号码
	return 1;
}

function chkIntegral(NUM){
	var i,j,strTemp;
	var PointNum;
	PointNum=0
	strTemp="0123456789";
	if(NUM=="")return 0;
	for (i=0;i<NUM.length;i++){
		j=strTemp.indexOf(NUM.charAt(i));	
		if (j==-1){
			return 0;
		}
		if(j==10){
			PointNum=PointNum+1;
		}
		
	}
	if(PointNum>1){
		return 0;
	}
	return 1;
}

function email(str)
{
    var email = str;
    if (email.length < 8)
    {
        return false;
    }
    else
    {
        if (email.indexOf(".") <=1 || email.indexOf("@") == -1)
        {
            return false;
        }    
    }
	return true;
}

var flag=false;
function DrawImage(ImgD,x,y){
   var image=new Image();
   image.src=ImgD.src;
   if(image.width>0 && image.height>0){
    flag=true;
    if(image.width/image.height>= x/y){
     if(image.width>x){  
     ImgD.width=x;
     ImgD.height=(image.height*x)/image.width;
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     //ImgD.alt=image.width+"×"+image.height;
     }
    else{
     if(image.height>y){  
     ImgD.height=y;
     ImgD.width=(image.width*y)/image.height;     
     }else{
     ImgD.width=image.width;  
     ImgD.height=image.height;
     }
     //ImgD.alt=image.width+"×"+image.height;
     }
    }
} 


function setHomepage()
{
	var hostname="http://"+location.hostname;
 if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(hostname);
 
    }
    else if (window.sidebar)
    {
    if(window.netscape)
    {
         try
   {  
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
         }  
         catch (e)  
         {  
    alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );  
         }
    } 
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage',hostname);
 }
} 

function addCookie()
{
 if (document.all)
    {
       window.external.addFavorite(location.href,document.title);
    }
    else if (window.sidebar)
    {
       window.sidebar.addPanel(document.title, location.href, "");
 }
}

//MSN即时交谈代码开始 
function SendMSNMessage(name)
{
 //Send a message through MSN , only for IE
 //and you must have installed MSN or Window Message
 MsgrObj.InstantMessage(name); 
}
function AddMSNContact(name)
{
 //Add a people to MSN , only for IE
 //and you must have installed MSN or Window Message
 MsgrObj.AddContact(0, name);
}

function doclose(){
	self.close();
}
function doMPocx(){
	eval('MPWindow.DisplaySize=3');
}
function doRPocx(){
	document.getElementById('RPWindow').SetFullScreen();
}
