
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];}
}

// cutomised by nods //
function toggleNLayer(NLayer)
{
   var obj = document.layers ? document.layers[NLayer] :
   document.getElementById ?  document.getElementById(NLayer).style :
   document.all[NLayer].style;
   obj.display = obj.display? "":"block";
}

/// <summary>
/// Only can input the numeric or Point
/// </summary>
function JHshNumberTextPlusSlanting()
{
    if ( !( ( window.event.keyCode >= 48 ) && ( window.event.keyCode <= 57 ) )  )
	{
		if ( window.event.keyCode != 47 )
		{
			window.event.keyCode = 0 ;
		}
	}
}
/// <summary>
/// Only can input the Enligh Char
/// </summary>
function JHshNumberTextPlus()
{
	if ( !((window.event.keyCode >= 48) && (window.event.keyCode <= 57)))
	{
	  window.event.keyCode = 0 ;	
	}
}


function JHshTextPlus()
{
	if ( !(  ( (window.event.keyCode >= 65) && (window.event.keyCode <= 90) 
		||  (window.event.keyCode >= 97) && (window.event.keyCode <= 122) ) ))
	{
	  window.event.keyCode = 0 ;	
	}
}


	/// <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;
		}
		else if (year > 9999){
			return false;
		}
		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>
/// 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,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" + parseInt(theArray[0]);
	}else
	{
		theMonth = theArray[0]
	}
	if ( parseInt(theArray[1]) < 10 )
	{
		theDay = "0" + parseInt(theArray[1]);
	}else
	{
		theDay = theArray[1];
	}
	
	return (theArray[2] + theMonth + theDay);
}

//**********************
//×ªµ½´óÐ´
//**********************
function UpperCase(obj)
{
	obj.value = obj.value.toUpperCase();
}

/// <summary>
/// Round the price
/// </summary>
function round(v,e) 
{ 
	var  t = 1; 
	for(;e > 0; t *= 10,e--); 
	for(;e < 0; t /= 10,e++); 
	return Math.round( v*t )/ t; 
} 	