function LoadPage(PageName){
  parent.location.href = PageName;
}

function OpenPage(url,popup){
    if (popup) window.open(url,"");
    else parent.location.href = url;
}

function SubmitForm(form,method,url)
{
  if (arguments[3] == null) document.all[form].target = '_self';
  else document.all[form].target = arguments[3];

  document.all[form].method = method;
  document.all[form].action = url;
  document.all[form].submit();
}

// indicates if the form could be submitted
//var isSubmitable_SubmitAndDisable = true;

function SubmitAndDisable (formName, method, url) {
    // ignore double submit
    //if (!isSubmitable_SubmitAndDisable) return;
    //isSubmitable_SubmitAndDisable = false;

    // submit the form
    SubmitForm(formName, method, url);

    // make all controls on the form disabled
    for (i=0;i<document.all[formName].elements.length;i++)
        document.all[formName].elements[i].disabled = true;
}

function getCurrentDate(){
   var d, s = "";
   d = new Date();
   s += d.getYear() + "/";
   s += (d.getMonth() + 1) + "/";
   s += d.getDate();
   return(s);
}

function CheckPassword(password,repassword){
	if (document.all[password].value == document.all[repassword].value) return true;
	alert("The passwords you typed do not match. Type the new password in both text boxes.");
	return false;
}

function checkStringLen(name,strlen)
{
    var fval = document.all[name].value;
    if (fval.length > strlen)
    {
      alert("The maximum number of characters exceeds limit of " + strlen)
      document.all[name].value = document.all[name].value.substr(0,strlen-1);
    }
}

function OpenModalWnd(url,features){
   window.showModalDialog(url,"",features);
}


function SubmitIntoPopup(form,method,url,feature)
{
    if (feature == null) feature = 'height=300,width=400,left=50,top=50,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes';
    else feature = feature + ',left=50,top=50,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes';

    window.open('','_trimapPopup', feature);
    document.all[form].target = '_trimapPopup';
    document.all[form].method = method;
    document.all[form].action = url;
    document.all[form].submit();
}

function submitSmartLookup (formName, controlName, controlValue, actionUrl) {
    window.opener.document.all[controlName].value = controlValue;

    window.opener.document.all[formName].target = window.opener.name;
    window.opener.document.all[formName].method = 'post';
    window.opener.document.all[formName].action = actionUrl;
    window.opener.document.all[formName].submit();
    window.close();
}

function submitSmartLookupNew (formName,controlName, controlValue, actionUrl) {
	alert(window.opener.document.documentElement.form);
    window.close();
}

function SubmitAndClose(form,method,url)
{
  if (arguments[3] == null) document.all[form].target = '_self';
  else document.all[form].target = arguments[3];

  document.all[form].method = method;
  document.all[form].action = url;
  document.all[form].submit();
  window.close();
}

function setFocus(input){
	document.all[input].focus();
	document.all[input].setActive();
}

function closeWindow () {
    window.close();
}

function load2Opener(actionUrl)
{
    window.opener.open (actionUrl, window.opener.name);
}
