﻿// JScript File 

function changeCSS(elem, cls)
{
	var e;
	try
	{
		e = document.getElementById(client_id + elem);
		e.className = cls;
	}
	catch(ex)
	{
		e = document.getElementById(elem);
		e.className = cls;
	}
	
}


function clickButton(e, button_id)
{
    var bt;
	try
	{
		bt = document.getElementById(client_id + button_id);
	}
	catch(ex)
	{
		bt = document.getElementById(button_id);
	}

	if (typeof bt == 'object')
	{
		if(navigator.appName.indexOf("Netscape") > (-1))
		{
			  if (e.keyCode == 13)
			  {
					bt.click();
					return false;
			  }
		}
		if (navigator.appName.indexOf("Microsoft Internet Explorer") > (-1))
		{
			  if (event.keyCode == 13)
			  {
					bt.click();
					return false;
			  }
		}
	}
} 



function openNewWindow(url, caption, width, height)
{
	var features = '';
    var top = (window.screen.height - height) / 2;
	var left = (window.screen.width - width ) / 2;
	if(width == '0' && height == '0')
	{
		width = window.screen.width - 100;
		height = window.screen.height - 100;
		features = 'menubar=0,resizable=1,scrollbars=1,status=no,toolbar=1,center=1,top=' + top + ',left=' + left + ',width=' + width + ',height=' + height;
	}
	else
	{
		features = 'menubar=0,resizable=0,scrollbars=0,status=no,toolbar=0,center=1,top=' + top + ',left=' + left + ',width=' + width + ',height=' + height;
	}
	window.open(url, caption, features);
}

function LTrim(str)
{
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(0)) != -1) {
    // We have a string with leading blank(s)...

    var j=0, i = s.length;

    // Iterate from the far left of string until we
    // don't have any more whitespace...
    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
    j++;


    // Get the substring from the first non-whitespace
    // character to the end of the string...
    s = s.substring(j, i);
  }

  return s;
}

function RTrim(str)
{
  // We don't want to trip JUST spaces, but also tabs,
  // line feeds, etc.  Add anything else you want to
  // "trim" here in Whitespace
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    // We have a string with trailing blank(s)...

    var i = s.length - 1;       // Get length of string

    // Iterate from the far right of string until we
    // don't have any more whitespace...
    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
      i--;


    // Get the substring from the front of the string to
    // where the last non-whitespace character is...
    s = s.substring(0, i+1);
  }

  return s;
}

function Trim(str)
{
  return RTrim(LTrim(str));
}
