var dir = "";
var qListPopupRH = new Image(); qListPopupRH.src = "../images/qList/qList_Popup_Right_H.GIF"
var qListPopupRN = new Image(); qListPopupRN.src = "../images/qList/qList_Popup_Right_N.GIF"
var qListPopupLN = new Image(); qListPopupLN.src = "../images/qList/qList_Popup_Left_N.GIF"
var qListPopupLH = new Image(); qListPopupLH.src = "../images/qList/qList_Popup_Left_H.GIF"

var icon_user_n = new Image(); icon_user_n.src = "../images/user.gif";
var icon_user_h = new Image(); icon_user_h.src = "../images/user_h.gif";


if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};


function ShowMnu(Img, Mnu) {
  setX(Img);
  setY(Img);
  HM_f_PopUp(Mnu, event);
}

function Null(){}

if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;

function ReloadBrowser()
{
  parent.opener.location.reload()
  parent.close()
}

//==========================================================================//
//  Function: searchSelectBox(in_sFormName, in_sInputName, in_sSelectName)
//  Purpose: Acts as a "searchable" input for a given select box.
//  Parameters:
//    in_sFormName  - The form name where the elements live
//    in_sInputName   - The "search input element name.
//    in_sSelectName  - The select box to search against.
//
//==========================================================================//
function searchSelectBox(in_sFormName, in_sInputName, in_sSelectName) {
  sSearchString = document.forms[in_sFormName].elements[in_sInputName].value.toUpperCase();
  iSearchTextLength = sSearchString.length;

  for (j=0; j < document.forms[in_sFormName].elements[in_sSelectName].options.length; j++) {
    sOptionText = document.forms[in_sFormName].elements[in_sSelectName].options[j].text;
    sOptionComp = sOptionText.substr(0, iSearchTextLength).toUpperCase();

    if(sSearchString == sOptionComp) {
      document.forms[in_sFormName].elements[in_sSelectName].selectedIndex = j;
      break;
    }
  }
}


//=====================================================================
//         When changing the value in Edit FORM
//----------------------------------------------------------------------
function ChangeFormVal() {
  var Form = document.forms['qEditForm'];
  var Select = Form.linkid;
  var selectedIndex = Select.selectedIndex;
  var CurVal = Form.CategoryName.value;

  if (CurVal.length == 0)
    Form.CategoryName.value = Select[selectedIndex].text;
}
//=====================================================================


//--Delete Conformation
function ConfirmDel(NavURL) {
  if(window.confirm("You are about to delete the selected record permenently\n\n"+
  "Are you Sure?"))
    window.location.href = NavURL;
  return false;
}

//--Delete Conformation
function ConfirmRemove(NavURL) {
  if(window.confirm("You are about to Remove the record\n\n"+
  "Are you Sure?"))
    window.location.href = NavURL;
  return false;
}
function ConfirmDelTree(NavURL) {
  if(window.confirm("You are about to Remove the record\n\n"+
  "Are you Sure?"))
    window.location.href = NavURL;
  return false;
}

function TopLeft(Width, Height) {
  var winWidth, winHeight;
  winWidth = (screen.availwidth - Width)/2;
  winHeight = (screen.availheight  - Height)/2;
  var T =  "top=" + winHeight + ",left=" + winWidth + 
  ",width=" + Width + ",height=" + Height;
  return T;
}

function OpenEX(URL) {
  var MyWindow = window.open(URL, 'MyWindow', TopLeft(780,420) + ",status=yes,resizable=yes,scrollbars=yes");
  MyWindow.focus();
}



function OpenPlan(URL, Width, Height) {
  var MyWindow = window.open(URL, 'MyWindow', TopLeft(Width, Height) + ",status=yes,resizable=yes,scrollbars=yes");
  MyWindow.focus();
}


function OpenPopup(URL) {
  var MyWindow = window.open(URL, 'MyWindow', ",resizable=no,scrollbars=0");
  MyWindow.focus();
}

function OpenPopupScroll(URL) {
  var MyWindow = window.open(URL, 'MyWindow', ",resizable=no,scrollbars=yes");
  MyWindow.focus();
}
function OpenWin(URL) {
  var Win = window.open(URL);
  Win.focus();
}

function OpenFiles(URL) {

   var MyWindow = window.open(URL , 'MyWindow', TopLeft(650,370) + ",status=yes,resizable=yes,scrollbars=yes");
   MyWindow.focus(); 

}


function Wizard(URL)
{
  var WizardWindow = window.open(URL, 'WizardWindow', TopLeft(700,480) + ",status=yesresizable=yes,scrollbars=no");
  WizardWindow.focus();
}


//----------------------------------------------------------------------------
function hideOthers(ID) {
  for (i=1; i<=10; i++) {
    if (ID != i) {
      var M = document.getElementById('M_elMenu' + i);
      if (M)
        M.className = 'MenuBar_Normal';
     }
  }
}

/*
==============================================================================
Additions done by ADT:
==============================================================================
*/

if(window.event + "" == "undefined") event = null;
function HM_f_PopUp(){return false};
function HM_f_PopDown(){return false};
popUp = HM_f_PopUp;
popDown = HM_f_PopDown;

var xpos = 0;
var ypos = 0;

//---------------------------------------------------------------------
//Setting up the X location of
//---------------------------------------------------------------------
function setX(Item) {
  if (document.all) {
    xpos = getOffsetLeftX(document.images[Item]);
  } else {
       xpos = document.images[Item].x;
  }
  xpos = xpos + 7 ;//'+ 35;
}

//---------------------------------------------------------------------
// Setting up Y location
//---------------------------------------------------------------------
function setY(Item) {
  if (document.all) {
    ypos = getOffsetTopX(document.images[Item]) ;
  } else {
    ypos = document.images[Item].y;
  }
  ypos = ypos + document.images[Item].height;
}

//---------------------------------------------------------------------
// Reading the X Position
//---------------------------------------------------------------------
function getX() {
  return  xpos;
}

//---------------------------------------------------------------------
// Reading the Y Position
//---------------------------------------------------------------------
function getY() {
  return ypos;
}

//---------------------------------------------------------------------
//Brower setup for Netscape
//---------------------------------------------------------------------
function getOffsetLeftX (el) {
    var ol = el.offsetLeft;
    while ((el = el.offsetParent) != null)
        ol += el.offsetLeft;
    return ol;
}
function getOffsetTopX (el) {
    var ot = el.offsetTop;
    while((el = el.offsetParent) != null)
        ot += el.offsetTop;
    return ot;
}

/*-----------------------------------------------------------------------
Show or Hide Search form on the bar
-----------------------------------------------------------------------*/
var LeftIcon_none = new Image(); LeftIcon_none.src = "../images/LeftIcon_none.gif";
var LeftIcon_block = new Image(); LeftIcon_block.src = "../images/LeftIcon_block.gif";

function ShowHide(IDName) {
  if (!document.all) return;
  var TR = eval(IDName);
  var Img = eval('document.images["' + IDName +'_img"]');

  if (!TR) return;

  var Style = TR.style.display;
  if (Style == "none") {
    Style = "block"
    if (Img) Img.src = LeftIcon_block.src
  } else {
    Style = "none"
    if (Img) Img.src = LeftIcon_none.src
  }
  TR.style.display = Style;



}


var M_Array;
function setActiveMenu(MenuID)
{
  M_Array = eval('M_Array' + MenuID);
}

function ShowMenu(HM_MenuID, Menu_ID) {
  var MyURL = M_Array[Menu_ID];
  var jScript = /^JavaScript:/i
  if(MyURL.search(jScript) >= 0 ) {
    eval(MyURL)
  } else {
    document.location.href = MyURL;
  }
}

minYearList = 2000;
maxYearList = 2020;


function PopulateDays() {
  var ListBox = document.forms['frmEventCalender'].EventMonth
  var sValue = ListBox.options[ListBox.selectedIndex].value;
  if (ListBox.selectedIndex == 0) {
    var ListBox1 = document.forms['frmEventCalender'].EventDays
    ListBox1.length = 0;
    ListBox1.options[0] = new Option('Select');
  } else {
    eval('getDaysOf' + sValue + '();');
  }
}


function CheckCalender() {
  var Form = document.forms['frmEventCalender'];
  var M = Form.EventMonth.selectedIndex
  if (M==0) {
    window.alert('Please choose a month...');
    return false;
  }
  return true;
}



