﻿function DisableButtonAndSubmit(Button, Text)
{
    Button.disabled = true;
    Button.value = Text;
    Button.style.backgroundColor = "#AAAAAA";
    Button.form.submit();
    
}

function JSTest() {
    alert("Test");
}

function TRonmouseover(row) 
{
    row.style.backgroundColor = "#E0E0E0";
}

function TRonmouseout(row) 
{
   row.style.backgroundColor = "";
}

function UserNavImgSwap(Name, What)
{
  if (What == "on") {
    document.images["img" + Name].src = "/images/design/usernav/" + Name + ".gif";
  } else {
    document.images["img" + Name].src = "/images/design/usernav/" + Name + "-grey.gif";
  }
}

function CheckTextBox(txt, ProperName, AllowBlank, MinLength, MaxLength)
{
    var s = txt.value;
    var len = s.length;
    if (len == 0 && AllowBlank == false) 
    {
      alert(ProperName + " cannot be blank.");
      txt.focus();
      return;
    }
    
    if (len > 0) {
        if ((len > MaxLength) || (len < MinLength)) {
            alert(ProperName + " must be between " + MinLength + " and " + MaxLength + " characters.");
            txt.focus();
            return;
         }
     }
}

function ConfirmDelete(GUID, Name)
{
    var callBackFn = function(arg) {
        if (arg) location.href = "/MyAccount/MyFiles/Delete.aspx?GUID=" + GUID;
        return;
    };
  
  var NameToShow = Name;
  if (NameToShow.length > 40) NameToShow = NameToShow.substring(0, 40) + "...";
  radconfirm("<span class=PopupText>Are you sure you want to delete:<br>\n<b>" + NameToShow + "</b></span>?", callBackFn, 400, 150);
  return false;
}

function ConfirmDeleteAdmin(GUID, Name)
{
    var callBackFn = function(arg) {
        if (arg) location.href = "Delete.aspx?GUID=" + GUID;
        return;
    };
  
  var NameToShow = Name;
  if (NameToShow.length > 40) NameToShow = NameToShow.substring(0, 40) + "...";
  radconfirm("<span class=PopupText>Are you sure you want to delete:<br>\n<b>" + NameToShow + "</b></span>?", callBackFn, 400, 150);
  return false;
}

function TDCSS(row, CssStyle) 
{
    if ((row.className != "NavCurrent") && (row.className != "AdminNavCurrent")) {
        row.className = CssStyle;
    }
}

function TDNAV(Name, CssStyle) {
    var x = document.getElementById(Name);
    if (x == null) return;
    TDCSS(x, CssStyle);
}


var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
 browserType= "gecko"
}

function HideElement(ElementName) {
  if (ElementName == null || ElementName == "") return;
  
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("' + ElementName + '")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("' + ElementName + '")');
  else
     document.poppedLayer =   
        eval('document.layers["' + ElementName + '"]');
  document.poppedLayer.style.display = "none";
}

function ShowElement(ElementName) {
  if (ElementName == null || ElementName == "") return;
  
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("' + ElementName + '")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("' + ElementName + '")');
  else
     document.poppedLayer = 
         eval('document.layers["' + ElementName + '"]');
  document.poppedLayer.style.display = "inline";
}


// global flag
var isIE = false;

// global request and XML document objects
var req;

// retrieve XML document (reusable generic function);
// parameter is URL string (relative or complete) to
// an .xml file whose Content-Type is a valid XML
// type, such as text/xml; XML source must be from
// same domain as HTML file
function loadXMLDoc(url, func) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = func;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = func;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function EnterClick(ButtonID,e)
{
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;

if (keycode == 13)
{
   var x = document.getElementById(ButtonID);
   if (x != null) x.click();
   return false;
   }
else
   return
}
   
   
function CreditCardAutoHide()
{
    var accountarray = document.getElementsByName("chkAccountTypeID");
    var divCreditCardArea = document.getElementById("divCreditCardArea");
    if (accountarray != null) 
    {
        for (var i = 0; i < accountarray.length; i++)
        {
            if (accountarray[i].checked && parseInt(accountarray[i].value) < 0) 
            {
                divCreditCardArea.style.display="none";
            }
        }
    }
}