﻿// JScript File

function openwindow(PageRef, PageName)
{
    window.open(PageRef, PageName,"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, left=0, top=0, width=800, height=600")
}

function goToURL(link) 
{
    window.location = link;
}

function changeImage(imgID,newImg) 
{
    document.images[imgID].src=newImg;
}

function setElementFocus(elemID)
{
    if (document.getElementById(elemID) != null)
        document.getElementById(elemID).focus();
}

function changeElementVisibility(id, val)
{
    if (document.getElementById(id) != null)
        document.getElementById(id).style.visibility = val;
}

function isDateFn(dateStr) { 
            var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/; 
            var matchArray = dateStr.match(datePat); 

            if (matchArray == null) 
                return false; 

            month = matchArray[1]; 
            day = matchArray[3]; 
            year = matchArray[5]; 

            if (month < 1 || month > 12) 
                return false; 
            
            if (day < 1 || day > 31) 
                return false; 
            
            if ((month==4 || month==6 || month==9 || month==11) && day==31) 
                return false; 
            
            if (month == 2) { 
                var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); 
                if (day > 29 || (day==29 && !isleap)) 
                    return false;   
            } 
            return true;         

} 

function getCookieValue(cookieName) 
{
  var exp = new RegExp (escape(cookieName) + "=([^;]+)");
  if (exp.test (document.cookie + ";")) 
  {
    exp.exec (document.cookie + ";");
    return unescape(RegExp.$1);
  }
  else 
  {
    return false;
  }
}

function checkSessionCookie() 
{
  document.cookie = "CheckSessionCookie=ok";
  if (getCookieValue("CheckSessionCookie") != "ok")
  {
    return false;
  }
  return true;
}

