﻿// JScript File

var current;

window.onload = function() {
  var list = document.getElementsByTagName('div');
  var len = list.length;

  for (var i = 0; i < len; i++) {
   if (list[i].className.indexOf('current') > -1) {
    current = list[i];
    break;
   }
  }
}

function openPanel(node) {
  if (current) {
   current.className = 'category';
   var panel = current.getElementsByTagName('p')[0];
   panel.childNodes[1].innerHTML = '(expand)';
  }

  if (current == node.parentNode) {
    current = null;
    return;
  }

  current = node.parentNode;
  current.className += ' current';
  node.childNodes[1].innerHTML = '(collapse)';
}

/*ofir*/
function fnDisplayMessage(myMsg, type) 
{
    if ( type==1)
    {
        var ans;
        ans = confirm(myMsg);
    }
    else
    {
        alert(myMsg);
    }
}

function CheckOwner()
{
    var txtOwnerCode = document.getElementById("ctl00_ContentPlaceHolder1_txtOwnerCode");
    
  if ( txtOwnerCode.value == "")
   {
    alert("You must enter owner code to continue !");
    return false;
   }
   else
   {
       bdVisitorWebsrvc.CheckIfOwnerExists(txtOwnerCode.value, onOwnerExist);
   }
}

function onOwnerExist(result)
{
    if ( result != "" )//check of owner website was returned.
    {
        window.open(result,"LogIn","scrollbars=1,toolbar=0,status=1,resizable=1,menubar=0,location=0","true");
    }
    else
    {
        alert("Owner Code Is Incorrect, please try again.");
        var txtOwnerCode = document.getElementById("txtOwnerCode").value="";
    }
}


function setHomepage() 
{
    if (document.all) 
    {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage('http://www.diningbutler.com/dbhome.aspx');

    }
    else if (window.sidebar) 
    {
        if (window.netscape) 
        {
            try 
            {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', 'http://www.diningbutler.com/dbhome.aspx');
    }
}


function addBookmarkForBrowser() 
{
  if (document.all)
  {
    window.external.AddFavorite(document.location.href, document.title);
  } else 
  {
    var ea = document.createEvent("MouseEvents");
    ea.initMouseEvent("mousedown",1,1,window,1,1,1,1,1,0,0,0,0,1,null);
    var eb = document.getElementsByTagName("head")[0];
    eb.ownerDocument.getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
    eb.dispatchEvent(ea);
  }
}