function refreshPortalHome()
{
  window.location.reload();
}
		
/*
==================================================================
LTrim(string) : Returns a copy of a string without leading spaces.
==================================================================
*/
function LTrim(str)
/*
  PURPOSE: Remove leading blanks from our string.
  IN: str - the string we want to LTrim
*/
{
  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;
}

/*
===================================================================
RTrim(string) : Returns a copy of a string without trailing spaces.
===================================================================
*/
function RTrim(str)
/*
  PURPOSE: Remove trailing blanks from our string.
  IN: str - the string we want to RTrim
*/
{
  // 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;
}

/*
=============================================================
Trim(string) : Returns a copy of a string without leading or trailing spaces
=============================================================
*/
function Trim(str)
/*
  PURPOSE: Remove trailing and leading blanks from our string.
  IN: str - the string we want to Trim
  RETVAL: A Trimmed string!
*/
{
  return RTrim(LTrim(str));
}

function popUp(theURL,iHeight,iWidth,scroll)
// onclick="popUp('/','500','500','no'); return false;"
{
  var top;
  var left;
  top = (screen.height - iHeight) / 2;
  left = (screen.width - iWidth) / 2;
  window.open(theURL,'test', 'width=' + iWidth + ',height=' + iHeight + ',top=' + top + ',left=' + left + ',scrollbars=' + scroll + ',resizable=yes');
}

function searchAll()
{
  if (document.getElementById("qry").value == "") 
  {
    alert('please enter keywords');
    document.getElementById("qry").focus;
    return false;
  }
  document.getElementById("reqPtlId").value = 'N';
  return true;
} 	
	
function ikewPortalJump(intPtlId) 
{
  document.cookie="PTLID=" + intPtlId + "; path=/";
  window.location = "/kewi/portalfuncs/portalhome.asp";
}

function trimString (str) 
{
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
			 
function setDisp(the_sub,minus)
{
  var vartemp = getCookie('showNews');
  if(vartemp == '0')
  {
    //alert(value);
    document.getElementById(the_sub).style.display = "none";
    document.getElementById(minus).src='/images/plus.gif';
    document.getElementById(minus).alt='Maximize';
  }
  //return null;
}
		
/*
var bikky = document.cookie;
var today = new Date();
var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000); // plus 28 days
//alert(expiry);
//alert(getCookie('showNews'));

function displaySubs(the_sub, minus)
{
  if (document.getElementById(the_sub).style.display=="")
  {
    setCookie('showNews','0');
    document.getElementById(the_sub).style.display = "none"
    document.getElementById(minus).src='/images/plus.gif';
    document.getElementById(minus).alt='Maximize';
    //return;
  }
  else 
  {
    setCookie('showNews','1');
	document.getElementById(the_sub).style.display = "";
	document.getElementById(minus).src='/images/minus.gif';
  }
}

function getCookie(name) 
{
  // use: getCookie("name");
  var index = bikky.indexOf(name + "=");
  if (index == -1) return null;
  index = bikky.indexOf("=", index) + 1;
  var endstr = bikky.indexOf(";", index);
  if (endstr == -1) endstr = bikky.length;
  return unescape(bikky.substring(index, endstr));
}

function setCookie(name, value) 
{
  // use: setCookie("name", value);	
  if (value != null && value != "")
  document.cookie=name + "=" + escape(value) + "; path=/";
  ////document.cookie=name + "=" + escape(value) + "; expires=" + expiry.toGMTString() + "; path=/";
  bikky = document.cookie; // update bikky
}
*/

function internalValidDate(m, d, y) 
{
  with (new Date(y, m, d)) 
  {
    return ((getDate()==d) && (getMonth()==m)) 
  }
}
		
function ValidateDate(Q)
{
  if (Q.search(/^\d\d?\x2F\d\d?\x2F\d\d\d\d$/)!=0) 
  {
    return -2; // bad format
  }
  var j, T = Q.split('/')
  for (j=0; j<=2; j++) 
  {
    T[j] = parseInt(T[j], 10)
  }
  if (!internalValidDate(T[0]-1, T[1], T[2])) 
  {
    return -1;
  } // bad value
  return 0;
}

function isNumericNoDots(val)
{
  var dp = false;
  for (var i=0; i < val.length; i++) 
  {
    if (!isDigit(val.charAt(i))) 
    {
      return false;
    }
  }
  return true;
}
	
function isDigit(num) 
{
  var string="1234567890";
  if (string.indexOf(num) != -1) 
  {
    return true;
  }
  return false;
}