function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/// <summary>
/// Change the DataGrid colour when the mouse Over
/// </summary>
/// <returns>bool</returns>
var currentcolor;
function onMouseOverChangeColor(objDataGrid)
{
	currentcolor = objDataGrid.style.backgroundColor;
	objDataGrid.style.backgroundColor='#F8E9A3';
}

/// <summary>
/// Change the DataGrid colour when the mouse Out
/// </summary>
/// <returns>bool</returns>
function onMouseOutChangeColor(objDataGrid)
{
	objDataGrid.style.backgroundColor = currentcolor;
}
/*
 * trim(strValue)
 *
*/
function trim(strValue)
{
    if(strValue==null || strValue.length == 0) return ("");
    var cr=String.fromCharCode(13);
    var oldstr="";

    while (oldstr.length!=strValue.length)
    {
        oldstr = strValue;
        strValue=b_trim(strValue," ");
        strValue=b_trim(strValue," ");
        strValue=b_trim(strValue,cr);
    }
    return strValue;
}

/*********************************************
  remove chr from left & right side of strValue
  b_trimleft('aaabcdaaa','a') = 'bcd'
*********************************************/

function b_trim(strValue,chr)
{
    return (b_trimleft(b_trimright(strValue,chr),chr));
}

/*********************************************
  remove chr from left side of strValue
    b_trimleft('aaabcde','a') = 'bcde'
*********************************************/

function b_trimleft(strValue,chr)
{
    if(strValue == null || strValue.length == 0) return ("");
    i = 0;
    if (chr==String.fromCharCode(13))
    {
        while(strValue.charAt(i) == chr) {i=i+2;}
    }
    else
    {
        while(strValue.charAt(i) == chr) {i=i+1;}
    }
  return (strValue.substring(i));
}

/*********************************************

  remove chr from right side of strValue

    b_trimleft('abcdeee','e') = 'abcd'

*********************************************/

function b_trimright(strValue,chr)
{
    if(strValue == null || strValue.length == 0) return ("");
    i = strValue.length-1;
    if (chr==String.fromCharCode(13))
    {
        while(strValue.charAt(i-1) == chr) {i=i-2;}
    }
    else
    {
        while(strValue.charAt(i) == chr) {i=i-1;}
    }
    return (strValue.substring(0,i+1));
}

/// <summary>
/// Check the Date,It will less than current date or (date-1)
/// </summary>
/// <returns>int</returns>
function CheckDateType( obj_date )
{
	var theArray = obj_date.split("/");
	var today = new Date();
	var year = parseInt(today.getFullYear());
	if  ( parseInt( 20 + theArray[2]) < ( year-1 ) )
	{
		alert( getErrMessage("910") );
		return false;
	}
	return true;
}

/// <summary>
/// Check the Date
/// </summary>
/// <returns>bool</returns>
function checkDate(	obj )
{
	var da = obj.value;
	var strs = da.split("/");
	if(strs.length != 3){
		return false;
	}
	if(isNaN(strs[0]) || isNaN(strs[1]) || isNaN(strs[2])){
		return false;
	}
	var year = parseFloat(strs[2]);
	var months = parseFloat(strs[0]);
	var day = parseFloat(strs[1]);
	if(year < 100){
		year = year + 2000;
	}
	if(months < 1 || months > 12){
		return false;
	}
	switch(months){
		case 1 :
		case 3 :
		case 5 :
		case 7 :
		case 8 :
		case 10 :
		case 12 :
		if(day > 31 || day < 1){
			return false;
		}
		break;
		case 4 :
		case 6 :
		case 9 :
		case 11 :
		if(day > 30 || day < 1){
			return false;
	
		}
		break;
		case 2 :
		if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0){
			if(day > 29 || day < 1){
				return false
			}
		}else{
			if(day > 28 || day < 1){
				return false
			}
		}
		break;		
	}

	obj.value = months + '/' + day + '/' + year;
	return true;		
}

/// <summary>
/// Check the Date,Will show message if it is more than
/// </summary>
/// <returns>int</returns>
function CheckDateMore(obj_date)
{
	var theArray = obj_date.split("/");
	
	var theMonth;
	var theDay;
	if ( parseInt(theArray[0]) < 10 )
	{
		theMonth = "0" + theArray[0];
	}else
	{
		theMonth = theArray[0]
	}
	if ( parseInt(theArray[1]) < 10 )
	{
		theDay = "0" + theArray[1];
	}else
	{
		theDay = theArray[1];
	}
	
	return (theArray[2] + theMonth + theDay);
}

/// <summary>
/// Check the Date,It will less than current date or (date-1)
/// </summary>
/// <returns>int</returns>
function CheckDateType( obj_date )
{
	var theArray = obj_date.split("/");
	var today = new Date();
	var year = parseInt(today.getFullYear());
	if  ( parseInt( 20 + theArray[2]) < ( year-1 ) )
	{
		alert( getErrMessage("910") );
		return false;
	}
	return true;
}

/// <summary>
/// Check the Date,It will less than current date
/// </summary>
/// <returns>int</returns>
function CheckDateTypeC( obj_date )
{
	var theArray = obj_date.split("/");
	var today = new Date();
	var year = parseInt(today.getFullYear());
	if  ( parseInt( 20 + theArray[2]) <  year )
	{
		alert( getErrMessage("910") );
		return false;
	}
	return true;
}

function isNumber( strNumber )
{
    strNumber = trim(strNumber);
    for (i=0; i < strNumber.length; i++)
    {
        var c = strNumber.substring(i, i + 1);
        if (!b_isDigit(c))
        {
            return false;
        }
    }
    return true;
}

function b_isDigit(c) { return (c >= '0' && c <= '9');}


/// <summary>
/// Only can input the Enligh Char
/// </summary>
function JHshNumberTextPlus()
{
     var keyPressed;
     if ( navigator.appName == "Netscape" )
     {
        keyPressed = arguments.callee.caller.arguments[0].which;
     }  
     else if ( navigator.appName == "Microsoft Internet Explorer" )
     {
        keyPressed = window.event.keyCode;
     }

     if ( !( ( keyPressed >= 48 ) && ( keyPressed <= 57 ) || ( keyPressed == 8 || keyPressed == 0 ) ))
     {
          var event = window.event|| arguments.callee.caller.arguments[0];
          if( navigator.appName == "Microsoft Internet Explorer" )
          {
            event.returnValue = false;
          }
          else if (navigator.appName == "Netscape" )
          {
            event.preventDefault();
          }
     }
}

function JHshTextPlus()
{
        var keyPressed;
        if ( navigator.appName == "Netscape" )
        {
            keyPressed = arguments.callee.caller.arguments[0].which;
        }
        else if ( navigator.appName == "Microsoft Internet Explorer" )
        {
            keyPressed = window.event.keyCode;
        }
 
    if ( !(  ( ( keyPressed >= 65 ) && ( keyPressed <= 90 ) 
    ||  ( keyPressed >= 97 ) && ( keyPressed <= 122 ) || ( keyPressed == 8  || keyPressed == 0 || keyPressed == 32 ) )))
    {
        var event = window.event || arguments.callee.caller.arguments[0];
        if( navigator.appName == "Microsoft Internet Explorer" )
        {
            event.returnValue = false;
        }
        else if (navigator.appName == "Netscape")
        {
            event.preventDefault();
        }
    }
}
