
function trim(sString) 
{
   while (sString.substring(0,1) == ' ')
   {
      sString = sString.substring(1,sString.length);
   }
   while (sString.substring(sString.length-1, sString.length) == ' ')
   {
      sString = sString.substring(0,sString.length-1);
   }

   return sString;
}

function wopen(url,w,h)
{
   x=(screen.width-w)/2;
   y=(screen.height-h)/2;
   win=window.open(url,'mywin','width='+w+',height='+h+',left='+x+',top='+y+',location=no,menbar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes');
   //win.resizeTo(w,h);
   win.focus();
}

function isNumber(Value)
{
   for(j=0;j<Value.length;j++)
   {
      if("0123456789.".indexOf(Value.charAt(j))==-1 || Value.indexOf(".")!=Value.lastIndexOf(".") || Value==".")
      {
         return false;
      }
   }
   return true;
}

function isLetter(Value)
{
   Value=Value.toUpperCase();
   for(j=0;j<Value.length;j++)
   {
      if("ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(Value.charAt(j))==-1 || Value.indexOf(".")!=Value.lastIndexOf(".") || Value==".")
      {
         return false;
      }
   }
   return true;
}

function isFilename(Value)
{
   checkStr="\\ :_-0123456789.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   for(j=0;j<Value.length;j++)
   {
      if(checkStr.indexOf(Value.charAt(j))==-1 || Value.indexOf(".")!=Value.lastIndexOf(".") || Value==".")
      {
         return false;
      }
   }
   return true;
}

function isSelected(Multi_dropMenu)
{
   for(i=0;i<Multi_dropMenu.length;i++)
   {
      if(Multi_dropMenu.options[i].selected)
      return true;
   }
   return false;
}

function printPage()
{
    if (typeof(window.print) != 'undefined')
    {
        window.print();
    }
}

function checkAll(C1,C2)
{
    if (C1.checked==true)
    {
        for (i=0;i<C2.length;i++)
       {
           C2[i].checked=true;
       }
    }
    else
    {
        for (i=0;i<C2.length;i++)
       {
           C2[i].checked=false;
       }
    }
}

function validateCheck(C2)
{
    for (i=0;i<C2.length;i++)
    {
		if (C2[i].checked==true)
		{
    	    return true;
		}
    }
	return false;
}

function sort2D(A)
{
    L=A.length;
    for (segment=0;segment<=L-2;segment++)
    {
       for (loop=L-2;loop>=segment;loop--)
       {
          if(A[loop+1][1]<A[loop][1])
          {
             temp=A[loop];
             A[loop]=A[loop+1];
             A[loop+1]=temp;
          }
       }
    }
	return A;
}

function validateRadio(R_name)
{
    R=document.getElementsByName(R_name);

    for (i=0;i<R.length;i++)
    {
		if (R[i].checked)
		{
    	    return true;
		}
    }
	return false;
}

function validateRadioCheck(R,numbers)
{
    for (i=0;i<numbers;i++)
    {
       result=false;

       obj=document.getElementsByName(R + '[' + i + ']');

       for (j=0;j<obj.length;j++)
       {
		  if (obj[j].checked==true)
		  {
		     result=true;
    	     break;
		  }
       }
    
       if(result==false)
	   break;
	}
	return result;
}

