/**
	* Get the web component by name
	* author:Henry Hou
	* Date: 2005-6-2 11:49
	* Demo: var text = MM_findObj_("username")
 */
function MM_findObj_(n, d)
{
	var p,i,x;

	if(!d)
		d=document;

	if((p=n.indexOf("?"))>0&&parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if( !(x=d[n]) && d.all )
		x=d.all[n];

	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];

	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=MM_findObj_(n,d.layers[i].document);

	return x;
}

	// JavaScript library for form field validation
	function jmpUrl(fileName)
	{
		location.href = fileName;
	}	

	function jmpUrlParent(fileName)
	{
		parent.location.href = fileName;
	}	

	function BrowserCheck()
	{
		var b = navigator.appName
		if (b=="Netscape") this.b = "ns"
		else if (b=="Microsoft Internet Explorer") this.b = "ie"
		else this.b = b
		this.v = parseInt(navigator.appVersion)
		this.ns = (this.b=="ns" && this.v>=4)
		this.ns4 = (this.b=="ns" && this.v==4)
		this.ns5 = (this.b=="ns" && this.v==5)
		this.ie = (this.b=="ie" && this.v>=4)
		this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
		this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
		if (this.ie5) this.v = 5
		this.min = (this.ns||this.ie)
	}
	// automatically create the "is" object
	is = new BrowserCheck();
	
	function getProperties( obj)
	{
		var pps="$$$$$$$$$$$$$\n";
		for (p in obj ) pps+=(p + "===" + obj[p] + "\n");
		return pps;
	}
	function CheckIsChar( str )
	{
		Val = str;
		myRegExp = /^([A-Z0-9a-z]+)$/;
		return (myRegExp.test(Val)) 
	}	
	function CheckIsEmpty( str )
	{
		
		return( (str==null)||(str == "") )
	}
	function CheckIsUpper( str )
	{
		Val = str;
		myRegExp = /^([A-Z0-9;:!@#%&_=<>,"'\-\/\`\~\$\^\*\(\)\+\|\\\?\.\{\}\[\] ]+)$/;
		return (myRegExp.test(Val)) 
	}
	function CheckIsLower( str )
	{
		Val = str;
		myRegExp = /^([a-z0-9;:!@#%&_=<>,"'\-\/\`\~\$\^\*\(\)\+\|\\\?\.\{\}\[\] ]+)$/;
		return (myRegExp.test(Val)) 
	}
	function CheckIsLetter( str )
	{
		Val = str;
		myRegExp = /^([A-z0-9;:!@#%&_=<>,"'\-\/\`\~\$\^\*\(\)\+\|\\\?\.\{\}\[\] ]+)$/;
		return (myRegExp.test(Val)) 
	}	
	function CheckIsInteger( str )
	{	
		Val = str;
		myRegExp = /^[-+]?([0-9]+)$/;
		return (myRegExp.test(Val)) 
	}
	function CheckIsPhone( str )
	{	
		Val = str;
		myRegExp = /^([0-9]+)(([0-9]|[-])+)([0-9]+)$/;		
		return (myRegExp.test(Val)) 
	}
	function CheckIsFloat( str )
	{	
		Val = str;
		myRegExp = /^[-+]?([0-9]+)([.]?[0-9]*)([eE]?[1-9]*)$/;
		return (myRegExp.test(Val)) 
	}
	function CheckIsEMail( str )
	{	
		Val = str;
		myRegExp = /^([a-zA-Z0-9_.]+)([@])([a-zA-Z0-9._]+)$/;
		return (myRegExp.test(Val)) 
	}	
	function CheckIsValidDate(AYear,AMonth,ADay)  
	{
		return (ADay>0 && ADay<=GetDaysOfMonth(AMonth,AYear));
	}
	function GetDaysOfMonth(AMonth,AYear)  
	{
		monthdays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30,31, 30, 31)
		days = -1;
		if ( AMonth>=1 && AMonth<=12 )	days = monthdays[AMonth -1 ];	
		if (AMonth==2 && IsLeapYear(AYear) ) days=29;
		return (days);
	}
	
	function IsLeapYear(AYear) 
	{
		b = ((AYear % 4)==0) && ((AYear % 100)!=0) || ((AYear % 400)==0) ; 
		return (b); 
	}

	function GetIntegerValue(Str, pos, len )
	{
		result = 0;
		astr = Str.substring(pos, pos+len)
		if ( CheckIsInteger( astr ) )
		{
			result = astr ;
		} else { result = -1 }
		return result;
	}
	function IsDigital( achar )
	{
		return( achar >="0" && achar <="9")
	}
	function CheckIsDateTime( ADtStr , FmtStr )
	{
		res=true;
		if ( ADtStr=="" || FmtStr=="")  return false
		
		fstr = FmtStr.toUpperCase();
		i =0 ; p = 0; Li = 0; Lp = 0;
		y = -1 ; m = -1; d = -1; h= -1; mi= -1; s=-1;
		while( i < fstr.length )
		{
			fmtch = fstr.substring(i,i+1);		// current
			fmtchn = fstr.substring(i+1,i+2);	// next
			adtch = ADtStr.substring(p, p+1);	// current
			adtchn = ADtStr.substring(p+1, p+2);	// next
			if ( fmtch=="Y" )			// get year
			{	
				if ( fmtchn=="Y" )
				{
					y3=fstr.substring(i+2,i+3);	// next
					y4=fstr.substring(i+3,i+4);	// next
					if ( y3 =="Y" && y4 =="Y" ){ Li = 4; Lp = 4; }
					else { Li=2; Lp=2; }
					y = GetIntegerValue( ADtStr, p, Lp );
					if ( !( y>=0 && y<=9999 ) ) res = false;
				}else
				{
					if ( fmtch == adtch ) { Li=1; Lp=1 }
					else{	res =false; }
				}
			}else // get m .d . h .mi s
			{
				if ( fmtchn == fmtch ) Li = 2; else Li = 1;
				if ( IsDigital( adtchn ) ) Lp = 2 ;else Lp = 1;	
				avalue = GetIntegerValue( ADtStr, p, Lp);

				if ( fmtch=="M" )
				{
					if ( fmtchn=="I" )	// Minute
					{
						Li=2;		// special
						mi = avalue;
						if ( !( mi>=0 && mi<=59 ) ) res = false;
					}else // default is as Month 
					{
						m = avalue;
						if ( !( m>=1 && m<=12 ) ) res = false;
					}
				}else
				if ( fmtch=="D" )
				{
					d = avalue;
					if ( !( d>=1 && d<=31 ) ) res = false;
				}else
				if ( fmtch=="H" )
				{
					h = avalue;
					if ( !( h>=0 && h<=23 ) ) res = false;
				}else
				if ( fmtch=="S" )
				{
					s = avalue;
					if ( !( s>=0 && s<=59 ) ) res = false;
				}else
				{
					if ( fmtch == adtch ) { Li=1; Lp=1 }
					else{	res =false; }
				}
			}
			i += Li; p+=Lp;	//==================>>>!!!
			if (! res ) return res;
		}
		if ( res && i != fstr.length || p != ADtStr.length ) res = false;
		if ( ! ( res &&  m!=-1 && d!=-1 && d<=GetDaysOfMonth(m, y ) ) )  res = false;
		return res;
	}
	function getDateTime( ADtStr , FmtStr )
	{
		res=true;
		if ( ADtStr=="" || FmtStr=="")  return null
		
		fstr = FmtStr.toUpperCase();
		i =0 ; p = 0; Li = 0; Lp = 0;
		y = -1 ; m = -1; d = -1; h= -1; mi= -1; s=-1;
		while( i < fstr.length )
		{
			fmtch = fstr.substring(i,i+1);		// current
			fmtchn = fstr.substring(i+1,i+2);	// next
			adtch = ADtStr.substring(p, p+1);	// current
			adtchn = ADtStr.substring(p+1, p+2);	// next
			if ( fmtch=="Y" )			// get year
			{	
				if ( fmtchn=="Y" )
				{
					y3=fstr.substring(i+2,i+3);	// next
					y4=fstr.substring(i+3,i+4);	// next
					if ( y3 =="Y" && y4 =="Y" ){ Li = 4; Lp = 4; }
					else { Li=2; Lp=2; }
					y = GetIntegerValue( ADtStr, p, Lp );
					if ( !( y>=0 && y<=9999 ) ) res = false;
				}else
				{
					if ( fmtch == adtch ) { Li=1; Lp=1 }
					else{	res =false; }
				}
			}else // get m .d . h .mi s
			{
				if ( fmtchn == fmtch ) Li = 2; else Li = 1;
				if ( IsDigital( adtchn ) ) Lp = 2 ;else Lp = 1;	
				avalue = GetIntegerValue( ADtStr, p, Lp);

				if ( fmtch=="M" )
				{
					if ( fmtchn=="I" )	// Minute
					{
						Li=2;		// special
						mi = avalue;
						if ( !( mi>=0 && mi<=59 ) ) res = false;
					}else // default is as Month 
					{
						m = avalue;
						if ( !( m>=1 && m<=12 ) ) res = false;
					}
				}else
				if ( fmtch=="D" )
				{
					d = avalue;
					if ( !( d>=1 && d<=31 ) ) res = false;
				}else
				if ( fmtch=="H" )
				{
					h = avalue;
					if ( !( h>=0 && h<=23 ) ) res = false;
				}else
				if ( fmtch=="S" )
				{
					s = avalue;
					if ( !( s>=0 && s<=59 ) ) res = false;
				}else
				{
					if ( fmtch == adtch ) { Li=1; Lp=1 }
					else{	res =false; }
				}
			}
			i += Li; p+=Lp;	//==================>>>!!!
			if (! res ) return null;
		}
		if ( res && i != fstr.length || p != ADtStr.length ) return null;
		if ( ! ( res &&  m!=-1 && d!=-1 && d<=GetDaysOfMonth(m, y ) ) )  return null;
		if (h==-1) h=0;
		if (mi==-1) mi=0;
		if (s==-1) s=0;
		return new Date(y,m-1,d,h,mi,s,0);
	}
	// compare two dates, 
	// @param dt1Str - String
	// @param dt1St2 - String
	// @param fmtStr - String -- like "YYYY-MM-DD", "MM/DD/YYYY", "DD/MM/YYYY"
	// @return int 
	//			0 : equals
	//			1 : dt1 > dt2
	//			-1: dt1 < dt2
	function compareDateTime(dt1Str, dt2Str, fmtStr)
	{
		dt1 = getDateTime(dt1Str , fmtStr )
		dt2 = getDateTime(dt2Str , fmtStr )
		res=-2;
		if (dt1==null && dt2 == null ) res= 0
		else
		if (dt1==null && dt2 != null ) res= -1
		else
		if (dt1!=null && dt2 == null ) res= 1
		else
		if (dt1.getTime()==dt2.getTime()) res=0
		else
		if (dt1.getTime()<dt2.getTime()) res=-1
		else
			res= 1
		return res;
	}	
	<!-------------------------Client Input Check-------------------------------->
	// aField	: is the filed name , and is a object
	// aFlag	: true if is the must have avlue , false is not necessary 
	// aMessage	: if not pass then show the message , if you don't want , just only an empty string.
	// aMethod	: the method to test whether the value is right or not .
	//		  and the method must return aboolean value , and the input param is only a string.
			  
	// return	: if ok then return true, else false.
	//
	// NOTE this version surpport Netscape (>4 ) and IE (>4)
	//
	
	<!---------------------------------------------------------------------------->
	
	function CheckAFiled( aField , aFlag, aMethod, aMessage )
	{
		var m_sTmp="";
		var m_sType=aField.type;
		//alert("==========>>"+m_sType + "-----" +m_sType.indexOf('select'))
		if (m_sType.indexOf('text')>=0)
		{
			aField.value=remove_XS_whitespace(aField.value)
			m_sTmp=aField.value;
		}else
		if (m_sType.indexOf('select')>=0)
		{
			m_sTmp=aField.options[aField.selectedIndex].value;
		}else
		{
			m_sTmp=aField.value;
		}
		var b = CheckIsEmpty( m_sTmp );
		
		if ( b && aFlag )			// input nothing , but must input at this filed
		{
			b = false;
		}else					// chenk the input correctly or not.
		{
			if (!b && aMethod != null  )
			{
				b = eval( aMethod + "('" + m_sTmp + "' )" );
			
			} else
			{
				b = true;
			}
		}
		if (!b)
		{
			if (is.ie)
				aField.style.background="lime";
			else if (is.ns4)
			{
				//aField.style.bgcolor="lime";
			}
			if (m_sType.indexOf('hidden')==-1)
				aField.focus();
			if (!CheckIsEmpty(aMessage)) 	// check if any messge to show.
				alert(aMessage);
		}
		if (is.ie)
			aField.style.background="#FFFFFF";
		return b;
	}
	
	function CheckAFiled_old( aField , aFlag, aMethod, aMessage )
	{
		aField.value=remove_XS_whitespace(aField.value)
				
		var b = CheckIsEmpty( aField.value );
		
		if ( b && aFlag )			// input nothing , but must input at this filed
		{
			b = false;
		}else					// chenk the input correctly or not.
		{
			if (!b && aMethod != null  )
			{
				b = eval( aMethod + "('" + aField.value + "' )" );
			
			} else
			{
				b = true;
			}
		}
		if (!b)
		{
			if (is.ie)
				aField.style.background="lime";
			aField.focus();
			if (!CheckIsEmpty(aMessage)) 	// check if any messge to show.
				alert(aMessage);
		}
		if (is.ie)
			aField.style.background="#FFFFFF";
		return b;
	}
	
	function CheckAFieldOnBlur( aField , aFlag, aMethod, aMessage )
	{
		var b = CheckIsEmpty( aField.value );
		if ( !b )				// input nothing , but must input at this filed
		{
			str = aField.value;
			aField.value = str.toUpperCase();
			if ( aMethod != null )
			{
				b = eval( aMethod + "('" + aField.value + "' )" );
			} else
			{
				b = true;
			}
		}
		if (!b)
		{
			aField.focus();
			aField.style.background="lime";
			if (!CheckIsEmpty(aMessage)) 	// check if any messge to show.
				alert(aMessage);
			aField.style.background="#FFFFFF";
		}
		return b;
	}	
	
	function CheckAllOnSubmit( fields )
	{
		for ( var i=0; i < fields.length; i++ )
		{
			afield = fields[i];
			form = document.forms[ afield[0] ];
			field = form[ afield[1] ];
			b = CheckAFiled( field, afield[2], afield[3], afield[4]) ;
			if ( !b ) 
			{
				return false;
			}
		}
		
		return true;
	}
	
	function CheckOnBlur(obj, fields)
	{
		if ( ( obj== null ) || (obj.name=="") )  return false;
		
		StrName = obj.name;
		afield = null;
		for ( var i=0; i < fields.length; i++ )
		{
			afield = fields[i];
			if ( StrName == afield[1]  ) break;
			afield = null;
			continue;
		}
		if ( afield == null) return false;
		bb = CheckAFieldOnBlur( document.forms[ afield[0] ][afield[1]], afield[2], afield[3], afield[4]);
		return bb;
	}

	function CheckDate( year,month,day,obj )
	{	
		if ((!CheckIsEmpty(year.value))||(!CheckIsEmpty(month.value))||(!CheckIsEmpty(day.value)))	
		{
			
			return CheckAllOnSubmit(obj);
		}else
		{
			return true;
		}
	}
	function CheckDateTimeYMD(val)
    {
    	return CheckIsDateTime(val, "YYYY-MM-DD");	    	
    } 
	function compareCheckValue(str,str2)
	{
		var m_str = getInt(str);
		var m_str2 = getInt(str2);
		var res = -2;
		if(m_str > m_str2) res = 1
		else 
		if(m_str == m_str2)  res = 0
		else
			res = -1
		return res;
	}
	
	function getInt(tmp)
	{
		  var i,j;
		  var len=tmp.length;
		  var str;
		  j=-1;
		  for(i=0;i<len;i++)
		  {
		    if (tmp.charAt(i) != '0') 
		    {
		     j=i;
		     break;
		    } 
		  }
		  if (j> -1)
		  {
		    str=tmp.substring(j,len)
		  }
		  else
		  {
		    str=tmp;
		  }
		  var _r=parseInt(str)
		  return _r;
	}
	
	function changeDays(m_oYear,m_oMonth,m_oDay)  
	{  
	   var len = m_oDay.length
	   var m_sYear=  m_oYear.options[m_oYear.selectedIndex].value;
	   var m_sMonth = m_oMonth.options[m_oMonth.selectedIndex].value;
	   var i
	   var str
	   for( i=len ; i>0;i-- )
	     m_oDay.options[i-1]=null; 
	        
	   var m_str=GetDaysOfMonth( m_sMonth,m_sYear);	
	   for(var j=1;j<= m_str;j++)
			{
				if ( j < 10) str="0" + j;
				else str=j
				m_oDay.options[j]=new Option(j,str);
				
			}
	//	m_oDay.options[1].selected=true;	
	}  
	 
	
	function remove_XS_whitespace(p_sValue)
	{
	  var tmp = "";
	  var item_length =p_sValue.length;
	  var item_length_minus_1 =p_sValue.length - 1;
	  for (index = 0; index < item_length; index++)
	  {
	    if (p_sValue.charAt(index) != ' ')
	    {
	      tmp += p_sValue.charAt(index);
	    }
	    else
	    {
	      if (tmp.length > 0)
	      {
	        if (p_sValue.charAt(index+1) != ' ' && index != item_length_minus_1)
	        {
	          tmp += p_sValue.charAt(index);
	        }
	      }
	    }
	  }
	  return tmp
	}
//check o'clock time,24:00 is not valid according to followed check function,please 
	//change to 00:00
	//time range: 00:00-23:59
	function checkTime(str)
	{
		Val = str;
		if (str.substring(0,1)=="2")
		{
			myRegExp = /^2([0-3]?):[0-5][0-9]$/;
		}
		else
		{
			myRegExp = /^([0-1]?)[0-9]:[0-5][0-9]$/;
		}
		return (myRegExp.test(Val))
	}	
	
	function getDate(m_oYear,m_oMonth,m_oDay)
	{
		var m_sYear  =  "";
	   	var m_sMonth =  "";
	   	var m_sDay   =  "";
	   	
	   	if (m_oYear.selectedIndex > -1)
		    m_sYear  =  m_oYear.options[m_oYear.selectedIndex].value;
		if (m_oMonth.selectedIndex > -1)
	   		m_sMonth =  m_oMonth.options[m_oMonth.selectedIndex].value;
	   	if (m_oDay.selectedIndex > -1)	
	   	 	m_sDay   =  m_oDay.options[m_oDay.selectedIndex].value;
	   	var m_sReuslt="";
	   	if ((m_sYear == "" ) || (m_sMonth == "") || (m_sDay =="") )
	   	{
	   		m_oYear.selectedIndex=0;
	   		m_oMonth.selectedIndex=0;
	   		m_oDay.selectedIndex=0;
	   		return "";
	   	}
	   	
	   	m_sReuslt = m_sYear + "-" + m_sMonth + "-" + m_sDay;
	   	
	   	return m_sReuslt;
	}
	function returnList(){
		back.history();
	}