function select() 
{ 
	with(document.forms["SpeedSites"].prov) 
	{ 
		var sProvice = options[selectedIndex].value; 
	} 
	for(i = 0;i < Province.length;i ++) 
	{ 
		if (Province[i].P == sProvice) 
		{ 
			Citys = (Province[i].C).split("|"); 
			with(document.forms["SpeedSites"].city) 
			{ 
				length = Citys.length; 
				for(j = 0;j < length;j++) 
				{ 
					strACity = Citys[j].split(","); 
					options[j].text  = LeftTrim(strACity[0],24); 
					options[j].value = strACity[1]; 
                    options[j].title = strACity[0]; 
				} 
				//options[selectedIndex].text  =""; 
				//options[selectedIndex].value = ""; 
			} 
			break; 
		} 
	}
	SetSpeedId();
} 

function init() 
{ 
	with(document.forms["SpeedSites"].prov) 
	{ 
		length = Province.length; 
		var k ;
		for(k = 0;k < Province.length; k++) 
		{ 
			options[k].text = Province[k].P; 
			options[k].value = Province[k].P; 
			//document.write("case \""+options[k].text +"\",\""+options[k].text +"\"<br>  retStr = \"\"<br>")
			//document.write(options[k].text+",");
		} 
		options[selectedIndex].text = Province[0].P; 
		options[selectedIndex].value = Province[0].P; 
	} 
	with(document.forms["SpeedSites"].city) 
	{ 
		Citys = (Province[0].C).split("|"); 
		length = Citys.length; 
		var l;
		for(l=0;l<length;l++) 
		{ 
			strACity = Citys[l].split(","); 
			options[l].text  = LeftTrim(strACity[0],24); 
			options[l].value = strACity[1]; 
		    options[l].title = strACity[0]; 
		} 
		options[selectedIndex].text  =""; 
		options[selectedIndex].value = ""; 
	} 
} 

function SetSpeedId()
 {
   var strProvince,strCity,sSpeedUserId;
    with(document.forms["SpeedSites"].prov) 
	{
	    strProvince =  options[selectedIndex].text;
		strProvince = (strProvince == "ÇëÑ¡Ôñ" )?"":strProvince;
	}
	with(document.forms["SpeedSites"].city) 
	{
	    strCity =  options[selectedIndex].text; 
		strCity = (strCity == "ÇëÑ¡Ôñ" )?"":strCity;
		sSpeedUserId = options[selectedIndex].value; 
	}
    with(document.forms["SpeedSites"].SpeedUserId)
	{ 
		value = sSpeedUserId ;	
    }      
	//alert(strProvince + strCity);
}

function CheckSpeedSitesSubform(theForm)
{
   if (theForm.SpeedUserId.value == "" || isNaN(theForm.SpeedUserId.value))            
  {            
    alert("ÇëÑ¡Ôñ²âÊÔµã¡£");            
    return (false);            
  }        

  return (true);            

}

function LeftTrim(str,length)
{    
   var strLength;
   var strCount = 0;
   var strLeft="";
   var strRight="";

   strLength =  str.length;       
   for(var i = 0 ; i < strLength ; i++)
   {
      if(str.charCodeAt(i)>255)
      {
          strCount +=2;   
      }
      else
      {
          strCount +=1;     
      }

      if(strCount <= (length - 3) )
      {            
         strLeft = strLeft + str.charAt(i);
      }
      else
      {
        if(strCount <= length && strCount >(length - 3))
        {
            strRight = strRight + str.charAt(i);
        }
        else
        {
            break;
        }
      }
   }

   if(strCount > length )
   {
        return strLeft+"...";
   }
   else
   {
        return strLeft+strRight;
   }       
}

init();