﻿//REQUIRED GLOBAL ARRAYS
var daysArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var daysArray1 = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
var monthsArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var monthsArray1 = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var alColor = "#d2d6f8";
var spColor = "#fecec7";
var maColor = "#ffebcc";
var meColor = "#f9dabe";
var coColor = "#b7dba7";
var cyColor = "#c3d9f8";
var blColor = "#fed4b7";
var laColor = "#f3d5e6";
var keColor = "#e2edd0";
var teColor = "#dfb8ea";
var fuColor = "#fdc8d7";
var rhColor = "#9ffcec";
var crColor = "#77f0fc";

var alLightColor = "#edeef9";
var spLightColor = "#fff2ef";
var maLightColor = "#fef6e9";
var meLightColor = "#fdf6f0";
var coLightColor = "#eff6ec";
var cyLightColor = "#eef4fd";
var blLightColor = "#fff6f0";
var laLightColor = "#fcf0f7";
var keLightColor = "#f4fbea";
var teLightColor = "#f6e5fb";
var fuLightColor = "#ffeff3";
var rhLightColor = "#e6fdf9";
var crLightColor = "#e0fbfc";

var alDarkColor = "#4d5389";
var spDarkColor = "#cf533e";
var maDarkColor = "#faa21c";
var meDarkColor = "#f58422";
var coDarkColor = "#68944b";
var cyDarkColor = "#4a8bbb";
var blDarkColor = "#e4701e";
var laDarkColor = "#98597c";
var keDarkColor = "#88b840";
var teDarkColor = "#72497e";
var fuDarkColor = "#C25775";
var rhDarkColor = "#07816c";
var crDarkColor = "#009aaa";

var vID = "";  //Variable used in js_controller_searchTile() function when user type manually vill name

//THIS JS FILE WILL CONTAIN ONLY SUPPORT JS FUNCTIONS THAT CAN BE REUSED ANYWHERE
function ClearDropDown(ddownControlName) {
  //REMOVING EXISTING ELEMENTS FROM THE DROP DOWN
  if (eval("document.forms[0]." + ddownControlName + ".options.length") > 0) {
    for (i = eval("document.forms[0]." + ddownControlName + ".options.length-1"); i >= 0; i--) {
      eval("document.forms[0]." + ddownControlName + ".remove(i)");
    }
  }
}

function LTrim(str) {
  for (var i = 0; str.charAt(i) == " "; i++);
  return str.substring(i, str.length);
}
function RTrim(str) {
  for (var i = str.length - 1; str.charAt(i) == " "; i--);
  return str.substring(0, i + 1);
}
function Trim(str) {
  return LTrim(RTrim(str));
}

function getUrl(villaId, arrayObject) {
  var centreCode = "";
  var arr = arrayObject;
  if (isInteger(villaId)) {
    for (var ctr = 0; ctr <= arr.length - 1; ctr++) {
      if (parseInt(villaId) == parseInt(arr[ctr][1])) {
        centreCode = Trim(arr[ctr][2].toLowerCase());
        break;
      }
    }
  }
  else {
    var villaName;
    for (var ctr = 0; ctr <= arr.length - 1; ctr++) {
      villaName = arr[ctr][0].toLowerCase();
      var arryFrmUser = Trim(villaId).split("(");
      var villaFrmUser = arryFrmUser[0].toLowerCase();
      if (Trim(villaFrmUser) == Trim(villaName)) {
        centreCode = Trim(arr[parseInt(ctr)][2].toLowerCase());
        vID = parseInt(arr[ctr][1]);
        break;
      }
    }
  }

  if (centreCode == "al") return "http://" + serverName + "/algarve/";
  if (centreCode == "sp") return "http://" + serverName + "/costadelsol/";
  if (centreCode == "ma") return "http://" + serverName + "/mallorca/";
  if (centreCode == "la") return "http://" + serverName + "/lanzarote/";
  if (centreCode == "ke") return "http://" + serverName + "/kefalonia/";
  if (centreCode == "cy") return "http://" + serverName + "/cyprus/";
  if (centreCode == "bl") return "http://" + serverName + "/costablanca/";
  if (centreCode == "me") return "http://" + serverName + "/menorca/";
  if (centreCode == "co") return "http://" + serverName + "/corfu/";
  if (centreCode == "te") return "http://" + serverName + "/tenerife/";
  if (centreCode == "fu") return "http://" + serverName + "/fuerteventura/";
  if (centreCode == "cr") return "http://" + serverName + "/crete/";
  if (centreCode == "rh") return "http://" + serverName + "/rhodes/";
}

function getCentreName(centreCode, arrayObject) {
  var centreCode;
  var arr = arrayObject;
  for (var ctr = 0; ctr <= arr.length - 1; ctr++) {
    if (centreCode.toLowerCase() == arr[ctr][2].toLowerCase()) {
      centreCode = Trim(arr[ctr][2].toLowerCase());
      break;
    }
  }
  if (centreCode == "al") return "The Algarve";
  if (centreCode == "sp") return "Costa del Sol";
  if (centreCode == "ma") return "Mallorca";
  if (centreCode == "la") return "Lanzarote";
  if (centreCode == "ke") return "Kefalonia";
  if (centreCode == "cy") return "Cyprus";
  if (centreCode == "bl") return "Costa Blanca";
  if (centreCode == "me") return "Menorca";
  if (centreCode == "co") return "Corfu";
  if (centreCode == "te") return "Tenerife";
  if (centreCode == "fu") return "Fuerteventura";
  if (centreCode == "cr") return "Crete";
  if (centreCode == "rh") return "Rhodes";
}

function GetCentreCode(stringCentreName) {
  switch (Trim(stringCentreName.toLowerCase())) {
    case "algarve":
      return "al";
      break;
    case "the algarve":
      return "al";
      break;
    case "costa del sol":
      return "sp";
      break;
    case "the costa del sol":
      return "sp";
      break;
    case "mallorca":
      return "ma";
      break;
    case "menorca":
      return "me";
      break;
    case "corfu":
      return "co";
      break;
    case "cyprus":
      return "cy";
      break;
    case "costa blanca":
      return "bl";
      break;
    case "lanzarote":
      return "la";
      break;
    case "kefalonia":
      return "ke";
      break;
    case "tenerife":
      return "te";
      break;
    case "fuerteventura":
      return "fu";
      break;
    case "crete":
      return "cr";
      break;
    case "rhodes":
      return "rh";
      break;
  }
}

function GetCentreName_2(centreCode) {
  if (Trim(centreCode.toLowerCase()) == "al") return "Algarve";
  if (Trim(centreCode.toLowerCase()) == "sp") return "Costa del Sol";
  if (Trim(centreCode.toLowerCase()) == "ma") return "Mallorca";
  if (Trim(centreCode.toLowerCase()) == "la") return "Lanzarote";
  if (Trim(centreCode.toLowerCase()) == "ke") return "Kefalonia";
  if (Trim(centreCode.toLowerCase()) == "cy") return "Cyprus";
  if (Trim(centreCode.toLowerCase()) == "bl") return "Costa Blanca";
  if (Trim(centreCode.toLowerCase()) == "me") return "Menorca";
  if (Trim(centreCode.toLowerCase()) == "co") return "Corfu";
  if (Trim(centreCode.toLowerCase()) == "te") return "Tenerife";
  if (Trim(centreCode.toLowerCase()) == "fu") return "Fuerteventura";
  if (Trim(centreCode.toLowerCase()) == "cr") return "Crete";
  if (Trim(centreCode.toLowerCase()) == "rh") return "Rhodes";
}

function ReturnVirDirectory(centreCode) {
  if (Trim(centreCode.toLowerCase()) == "al") return "algarve";
  if (Trim(centreCode.toLowerCase()) == "sp") return "costadelsol";
  if (Trim(centreCode.toLowerCase()) == "ma") return "mallorca";
  if (Trim(centreCode.toLowerCase()) == "la") return "lanzarote";
  if (Trim(centreCode.toLowerCase()) == "ke") return "kefalonia";
  if (Trim(centreCode.toLowerCase()) == "cy") return "cyprus";
  if (Trim(centreCode.toLowerCase()) == "bl") return "costablanca";
  if (Trim(centreCode.toLowerCase()) == "me") return "menorca";
  if (Trim(centreCode.toLowerCase()) == "co") return "corfu";
  if (Trim(centreCode.toLowerCase()) == "sn") return "spain";
  if (Trim(centreCode.toLowerCase()) == "pt") return "portugal";
  if (Trim(centreCode.toLowerCase()) == "te") return "tenerife";
  if (Trim(centreCode.toLowerCase()) == "fu") return "fuerteventura";
  if (Trim(centreCode.toLowerCase()) == "cr") return "crete";
  if (Trim(centreCode.toLowerCase()) == "rh") return "rhodes";
  if (Trim(centreCode.toLowerCase()) == "vp") return "";
}
//REQUIRE THIS FUNCTION AS JAVASCRIPT ONLY REPLACES FIRST OCCURANCE OF A CHAR IN THE REPLACE FUNCTION
function customReplace(stringToSearch, oldChar, newChar) {
  var str = stringToSearch.toLowerCase();
  var returnStr = null;
  for (var ctr = 0; ctr <= str.length - 1; ctr++) {
    if (str.charAt(ctr) != oldChar) {
      if (returnStr == null) {
        returnStr = str.charAt(ctr);
      }
      else {
        returnStr = returnStr + str.charAt(ctr);
      }
    }
  }
  return returnStr;
}

function swapImage(showImageObject, hideImageObject) {
  SwapImageShowHide(showImageObject, hideImageObject);
}

function swapImagesOnOff(imgPath, imgObject) {
  var swapImg = imgObject;
  swapImg.src = imgPath;
}
function SwapImageShowHide(showImageObject, hideImageObject) {
  try {
    with (showImageObject) {
      style.display = "";
      style.visibility = "visible";
    }
    with (hideImageObject) {
      style.display = "none";
      style.visibility = "hidden";
    }
  }
  catch (ex) {
  }
}

function SetDropDownDefault(selectedVal, ddViewObj) {
  try {
    var obj = document.getElementById(ddViewObj);
    for (var ctr = 0; ctr <= obj.options.length - 1; ctr++) {
      if (Trim(obj.options[ctr].value.toString().toLowerCase()) == Trim(selectedVal.toString().toLowerCase())) {
        obj.options[ctr].selected = true;
        break;
      }
    }
  }
  catch (e) {
  }
}

//THIS FUNCTION ADDS OPTIONS TO A DROP DOWN CONTROL
//PARAMS: THE CONTROL NAME, TEXT, VALUE, IF THE OPTION HAS TO BE THE DEFAULT OPTION OR NOT
function AddOptionsToDrowDown(dropDownName, optionText, optionValue, optionSelected) {
  var optn = document.createElement("OPTION");
  optn.text = optionText;
  optn.value = optionValue;
  optn.selected = optionSelected == true ? true : false;
  eval("document.forms[0]." + dropDownName + ".options.add(optn)");
}

function getAirportName(airportCode, airportArray) {
  var arrAllCenterAirports = airportArray.split('|');
  for (var ctr = 0; ctr <= arrAllCenterAirports.length - 1; ctr++) {
    var arrCentreAirports = arrAllCenterAirports[ctr].split('=');
    var arrAllAirports = arrCentreAirports[1].split(',');
    for (var i = 0; i <= arrAllAirports.length - 1; i++) {

      if (arrAllAirports[i].split('-')[0].toLowerCase() == airportCode.toLowerCase()) {
        return arrAllAirports[1];
        break;
      }
    }

  }
}
function getDestinationAirport(destinationCentreCode) {

  var arrAllDestinations = arrDestinations.split('|');
  for (var ctr = 0; ctr <= arrAllDestinations.length - 1; ctr++) {
    if (arrAllDestinations[ctr].split('=')[0].toLowerCase() == destinationCentreCode.toLowerCase()) {
      return arrAllDestinations[ctr].split('=')[1];
      break;
    }
  }
}
//SHOWS A LAYER

var mouseX = 0;
var mouseY = 0;
function showLayer(lyrName, anchorObject) {
  // Implementing Search Tile in ASp Page ---- Starts
  var IsAsp = false; //To check if ASP page
  try {
    var myRegExp = /searchtile.aspx/;
    var matchPos1 = js_url.toLowerCase().search(myRegExp);

    if (matchPos1 != -1) {
      var objShowLayer = parent.document.getElementById("ifrmHelp");
      IsAsp = true;
    }
  }
  catch (e) {
    var objShowLayer = document.getElementById(lyrName);
  }
  // Implementing Search Tile in ASP Page ---- Ends

  if (anchorObject == "search_closeHelp")          //THIS IS BECAUSE IN THE DEFAULT PAGE IT IS CALLED  search_closeHelp & SEARCH RESULTS IT IS CALLED search1_closeHelp
  {
    try {
      var anchorPos = getAnchorPosition(helpImgId);
    }
    catch (e) {
      var anchorPos = getAnchorPosition("search1_helpImg");
    }
    // Implementing Search Tile in ASP Page ---- Starts
    if (IsAsp == true) {
      if (screen.width == 1024) {
        objShowLayer.style.top = parseInt(anchorPos.y) + 100 + "px";
        objShowLayer.style.left = parseInt(anchorPos.x) + 30 + "px";
      }
      else {
        objShowLayer.style.top = parseInt(anchorPos.y) + 100 + "px";
        objShowLayer.style.left = parseInt(anchorPos.x) + 160 + "px";
      }
      objShowLayer.style.display = "";
      objShowLayer.style.visibility = "visible";
    }
    else {
      objShowLayer.style.top = parseInt(anchorPos.y) - 140 + "px";
      objShowLayer.style.left = parseInt(anchorPos.x) + 20 + "px";
      objShowLayer.style.display = "";
      objShowLayer.style.visibility = "visible";
    }
    // Implementing Search Tile in ASp Page ---- Ends
  }
  else if (anchorObject.indexOf('frillTypeHelp') >= 0 || anchorObject.indexOf('CharteredTypeHelp') >= 0) {

    var anchorPos = getAnchorPosition(anchorObject);
    objShowLayer.style.top = parseInt(mouseY) + 20 + "px";
    objShowLayer.style.left = parseInt(anchorPos.x) - 90 + "px";
    objShowLayer.style.display = "";
    objShowLayer.style.visibility = "visible";
  }
  else {
    var anchorPos = getAnchorPosition(anchorObject);
    objShowLayer.style.top = parseInt(anchorPos.y) + 20 + "px";
    objShowLayer.style.left = parseInt(anchorPos.x) - 90 + "px";
    objShowLayer.style.display = "";
    objShowLayer.style.visibility = "visible";
  }
}
var IE = document.all ? true : false;
if (!IE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;

function getMouseXY(e) {

  try {
    if (IE) { // grab the x-y pos.s if browser is IE
      mouseX = event.clientX + document.body.scrollLeft;
      mouseY = event.clientY + document.body.scrollTop;
    } else {  // grab the x-y pos.s if browser is NS
      mouseX = e.pageX;
      mouseY = e.pageY;
    }
    if (mouseX < 0) { mouseX = 0 }
    if (mouseY < 0) { mouseY = 0 }
  }
  catch (ex) {
  }

  return true;
}

//Function to show hover box
function showHoverLayer(lyrName, anchorObject, centreCode, y, x) {
  var objShowLayer = document.getElementById(lyrName);
  var anchorPos = getAnchorPosition(anchorObject);
  objShowLayer.style.top = parseInt(anchorPos.y) - y + "px";
  objShowLayer.style.left = parseInt(anchorPos.x) - x + "px";

  var imageUrl = "../../imgs/" + centreCode + "/common/";

  var img = document.getElementById("imgCornerTopLeft");
  img.src = imageUrl + "CornerTopLeft.gif";
  img = document.getElementById("imgCornerTopRight");
  img.src = imageUrl + "CornerTopRight.gif";
  img = document.getElementById("imgCornerBottomLeft");
  img.src = imageUrl + "CornerBottomLeft.gif";
  img = document.getElementById("imgCornerBottomRight");
  img.src = imageUrl + "CornerBottomRight.gif";

  var td = document.getElementById("tdMarginLeft");
  td.style.background = "url(" + imageUrl + "MarginLeftBG.gif)";
  td = document.getElementById("tdMarginRight");
  td.style.background = "url(" + imageUrl + "MarginRightBG.gif)";
  td = document.getElementById("tdBottomBG");
  td.style.background = "url(" + imageUrl + "BottomBG.gif)";
  td = document.getElementById("tdTop");
  td.bgColor = eval(centreCode.toLowerCase() + "DarkColor");
  td = document.getElementById("tdBottom");
  td.bgColor = eval(centreCode.toLowerCase() + "LightColor");

  objShowLayer.style.display = "";
  objShowLayer.style.visibility = "visible";

}
//Function to show hover box
function showNewHoverLayer(lyrName, anchorObject, y, x, title, message) {
  var objShowLayer = document.getElementById(lyrName);
  var anchorPos = getAnchorPosition(anchorObject);
  objShowLayer.style.top = parseInt(anchorPos.y) - y + "px";
  objShowLayer.style.left = parseInt(anchorPos.x) - x + "px";
  var objTitleSpan = document.getElementById('hoverTitle');
  var objMsgSpan = document.getElementById('hoverMsg');
  objTitleSpan.innerHTML = "<b>&nbsp;" + title + "</b>";
  objMsgSpan.innerHTML = message;

  try {
    if ((lyrName == 'dvVillaExtraHoverBox') || (lyrName == 'dvNewVillaExtraHoverBox')) {
      var objIframe = parent.document.getElementById('amendVillaExtrasSelection');
      if (parseInt(anchorPos.y) > 210) {
        objShowLayer.style.top = (parseInt(anchorPos.y) - 100) + "px";
      }

      objTitleSpan = document.getElementById('hoverTitleOther');
      objMsgSpan = document.getElementById('hoverMsgOther');
      objTitleSpan.innerHTML = "<b>&nbsp;" + title + "</b>";
      objMsgSpan.innerHTML = message;
    }
  }
  catch (e) {
  }
  objShowLayer.style.display = "Block";
  objShowLayer.style.visibility = "visible";
}

//HIDES A LAYER
//param: THE ID OF NAME OF THE OBJ TO BE HIDDEN
function hideLayer(lyrName) {
  // Implementing Search Tile in ASP Page ---- Starts
  try {
    //NEED TO HOOK TO CHECK IF THE HELPBOX NEEDS TO BE HIDDEN OR THE VILLAS LIST DROP DOWN
    if (lyrName == "selVillas") {
      var hideObj = parent.document.getElementById("selVillas");
    }
    else if (lyrName == "dvHoverBox") {
      var hideObj = document.getElementById(lyrName);
    }
    else {
      var hideObj = parent.document.getElementById("ifrmHelp");
    }
    hideObj.style.display = "none";
    hideObj.style.visibility = "hidden";
  }
  catch (ex) {
    try {
      var hideObj = document.getElementById(lyrName);
      hideObj.style.display = "none";
      hideObj.style.visibility = "hidden";
    }
    catch (ex) {
    }
  }
  // Implementing Search Tile in ASP Page ---- Ends   
}

//ADDS A COMMA TO A NUMERIC VALUE FIRST AFTER 3 DIGITS THEN AFTER EVERY 2 DIGITS
function addNumericComma(numericVal) {
  return numericVal;
}

//PARAMS: THE TEXT TO BE DISPLAYED, THE ID OF THE TD OR DIV IN WHICH THE TEXT NEEDS TO BE DISPLAYED
function SetText(txt, strTd) {
  var obj = document.getElementById(strTd);
  obj.innerHTML = txt;
}

//ENABLES OR DISABLES A CONTROL
//PARAMS: THE CONTROL AS AN OBJECT, THE STATUS IE. 1 = CONTROL TO BE ACTIVE, 0 = CONTROL TO BE INACTIVE I.E. DISABLED
function EnableControl(objControl, status) {
  var controlObject = objControl;
  if (status == 0) {
    controlObject.disabled = true;
    if (controlObject.type == "checkbox") controlObject.checked = false;
  }
  else {
    controlObject.disabled = false;
  }
}

//RETURNS AN ARRAY CONTAINING UNIQUE VALUES FOR A CENTRE AND COUNTER POSITION
//PARMAS: THE ARRAY TO BE USED, CENTRE CODE, ARRAY POSITION ON WHICH TO RETURN VALUES, POSITION OF THE CENTRE CODE IN THE ARRAY
function GetUniqueArray(arrayObject, centreCode, counterPosition, counterPositionForCentreCode) {
  var oldVal = "";
  var currentVal = "";
  var returnUniqueArray = new Array();
  var intCtr = 0;
  var arrayToUse = arrayObject;
  var stp = arrayToUse.length;
  for (var ctr = 0; ctr < stp; ctr++) {
    if (Trim(centreCode).toLowerCase() != "any") {
      if (Trim(arrayToUse[ctr][counterPositionForCentreCode]).toLowerCase() == Trim(centreCode).toLowerCase()) {
        oldVal = currentVal;
        currentVal = arrSearchResults[ctr][counterPosition];
        if (currentVal != oldVal) {
          returnUniqueArray[intCtr] = currentVal;
          intCtr++;
        }
      }
    }
    else {
      oldVal = currentVal;
      currentVal = arrSearchResults[ctr][counterPosition];
      if (currentVal != oldVal) {
        returnUniqueArray[intCtr] = currentVal;
        intCtr++;
      }
    }
  }
  return returnUniqueArray;
}

function GetUniqueCentreCodes(arrayObject, counterPositionForCentreCode) {
  var oldCentre = "";
  var currentCentre = "";
  var returnArrayCentreCodes = new Array();
  var intCtr = 0;
  var arrToUse = arrayObject;
  for (var ctr = 0; ctr <= arrToUse.length - 1; ctr++) {
    oldCentre = currentCentre.toLowerCase();
    currentCentre = arrToUse[ctr][counterPositionForCentreCode].toLowerCase();
    if (currentCentre != oldCentre) {
      returnArrayCentreCodes[intCtr] = currentCentre;
      intCtr++;
    }
  }
  return returnArrayCentreCodes;
}

function RemoveDuplicatesAndGetUniqueArray(arrayObject) {
  var uniqueArray = new Array();
  var uniqueCtr = 0;
  var foundFlag;
  for (var ctr = 0; ctr < arrayObject.length; ctr++) {
    foundFlag = 0;
    for (var ctr1 = 0; ctr1 < uniqueArray.length; ctr1++) {
      if (arrayObject[ctr] == uniqueArray[ctr1]) {
        foundFlag = 1;
        break;
      }
    }
    if (foundFlag == 0) {
      uniqueArray[uniqueCtr] = arrayObject[ctr];
      uniqueCtr++;
    }
  }
  return uniqueArray;
}

//THIS FUNCTION CHECKS IF AN IMAGE EXISTS AND RETURN TRUE OR FALSE
function CheckImageExisits(url) {
  var req;
  try {
    req = new XMLHttpRequest();
  }
  catch (e) {
    //IE6 AND LOWER
    req = new ActiveXObject("MSXML2.XMLHTTP.3.0");
  }

  try {
    req.open("HEAD", url, false);
    req.send(null);
    if (req.status == 200) {
      return true;
    }
    else {
      return false;
    }
  }
  catch (e) {
    //alert("Could not connect to the villa plus site.");
    return false;
  }
}

function alertDetails() {
  var a;
  var popUpWidth = 402;
  var popUpHeight = 165;
  var leftPos = (screen.Width - popUpWidth) / 2;
  var topPos = (screen.Height - popUpHeight) / 2;
  var popUpProperties;
  popUpProperties = "width=" + popUpWidth + " height=165, top=" + topPos + ", left=" + leftPos;
  try 
  {
      a = window.open("http://" + serverName + '/code/info/versioninfo.asp', 'versionInfo', popUpProperties);
  }
  catch (exp)
  { }

  try 
  {
      a = window.open("http://" + js_serverName + '/code/info/versioninfo.asp', 'versionInfo', popUpProperties);
  }
  catch (ex) {}

  try {
      a = window.open("http://" + ServerName + '/code/info/versioninfo.asp', 'versionInfo', popUpProperties);
  }
  catch (ex) {}
  a.focus();
}
//Bookmark functions
function bookmark(url, title) {
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
    window.external.AddFavorite(url, title);
  }
  else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title, url, "");
  }
}

//Open help page popup
function popUpHelp(pageName) {
  var wnd = window.open(pageName, "help", "width=720,height=500,top=0,left=0,scrollbars=yes");
  wnd.focus();
}

function showAlert(title, msg, button, width, height, anchorObject, fnCallback, showWhere) {
  //anchorObject WILL BE AN OBJECT CONTAINING THE X AND Y POSTIONS FOR THE CONTROL FOR WHICH THE MSG BOX NEEDS TO BE SHOWN
  if (showWhere == 'undefined') { showWhere = 'left'; } //Showwhere will decide where to show the alert. 

  var IsAsp;
  var ifrmBehindCustomeAlert;
  //for SearchTile we need to use the ASP AlertBox else the alertbox is restricted by width of the ifrmSearch
  // hence check if alert is for searchTile
  try {
    var myRegExp = /searchtile.aspx/;
    var matchPos1 = js_url.toLowerCase().search(myRegExp);

    if (matchPos1 != -1) {
      var objShowLayer = parent.document.getElementById("ifrmHelp");
      IsAsp = true;
    }
  }
  catch (ex) {

  }

  try {
    if (IsAsp) {
      var objalertTitle = parent.document.getElementById("asp_alertTitle");
      var objalertMsg = parent.document.getElementById("asp_alertMsg");
      var objcmdOk = parent.document.getElementById("asp_cmdOk");
      objcmdOk.style.display = "none";
      objcmdOk.style.visibility = "hidden";
      var objlblOk = parent.document.getElementById("asp_lblOK");
      objlblOk.style.display = "none";
      objlblOk.style.visibility = "hidden";
      var objcmdYes = parent.document.getElementById("asp_cmdYes");
      objcmdYes.style.display = "none";
      objcmdYes.style.visibility = "hidden";
      var objcmdNo = parent.document.getElementById("asp_cmdNo");
      objcmdNo.style.display = "none";
      objcmdNo.style.visibility = "hidden";
      var objdvDisableParent = parent.document.getElementById("asp_dvDisableParent");
      var objdvAlertBox = parent.document.getElementById("asp_dvAlertBox");
      var pgHt = getAnchorPosition(aspAnchorId);
      ifrmBehindCustomeAlert = document.getElementById("asp_IfrmBehindCustomeAlert");
    }
    else {
      var pgHt = getAnchorPosition("pgHeight");
      var objalertTitle = document.getElementById("alertTitle");
      var objalertMsg = document.getElementById("alertMsg");
      var objcmdOk = document.getElementById("cmdOk");
      objcmdOk.style.display = "none";
      objcmdOk.style.visibility = "hidden";
      var objlblOk = document.getElementById("lblOK");
      objlblOk.style.display = "none";
      objlblOk.style.visibility = "hidden";
      var objcmdYes = document.getElementById("cmdYes");
      objcmdYes.style.display = "none";
      objcmdYes.style.visibility = "hidden";
      var objcmdNo = document.getElementById("cmdNo");
      objcmdNo.style.display = "none";
      objcmdNo.style.visibility = "hidden";
      var objcmdCloseAlert = document.getElementById("cmdCloseAlert");
      objcmdCloseAlert.style.display = "";
      objcmdCloseAlert.style.visibility = "visible";
      var objdvDisableParent = document.getElementById("dvDisableParent");
      var objdvAlertBox = document.getElementById("dvAlertBox");
    }
  }
  catch (e) {
    //Code for ASP Page Alert
    var objalertTitle = parent.document.getElementById("asp_alertTitle");
    var objalertMsg = parent.document.getElementById("asp_alertMsg");
    var objcmdOk = parent.document.getElementById("asp_cmdOk");
    objcmdOk.style.display = "none";
    objcmdOk.style.visibility = "hidden";
    var objlblOk = parent.document.getElementById("asp_lblOK");
    objlblOk.style.display = "none";
    objlblOk.style.visibility = "hidden";
    var objcmdYes = parent.document.getElementById("asp_cmdYes");
    objcmdYes.style.display = "none";
    objcmdYes.style.visibility = "hidden";
    var objcmdNo = parent.document.getElementById("asp_cmdNo");
    objcmdNo.style.display = "none";
    objcmdNo.style.visibility = "hidden";
    var objdvDisableParent = parent.document.getElementById("asp_dvDisableParent");
    var objdvAlertBox = parent.document.getElementById("asp_dvAlertBox");
    var pgHt = getAnchorPosition("search_aspAnchor");
    ifrmBehindCustomeAlert = document.getElementById("asp_IfrmBehindCustomeAlert");
    IsAsp = true;
  }
  objalertTitle.innerHTML = "<b><font class=\"verdana9\" color=\"#FFFFFF\">" + title + "</font></b>";
  objalertMsg.innerHTML = "<b>" + msg + "</b>";
  switch (button) {
    case "OK":
      with (objcmdOk) {
        if (IsAsp) {
          if (ifrmBehindCustomeAlert != null) {
            ifrmBehindCustomeAlert.style.display = "";
            ifrmBehindCustomeAlert.style.visibility = "visible";
          }
        }
        style.display = "";
        style.visibility = "visible";
        objlblOk.style.display = "";
        objlblOk.style.visibility = "visible";

        try {
          document.getElementById("hidCallbackFunction").value = fnCallback;
        }
        catch (e) {
        }
      }
      break;
    case "YESNO":
      with (objcmdYes) {
        style.display = "";
        style.visibility = "visible";
      }
      with (objcmdNo) {
        style.display = "";
        style.visibility = "visible";
      }
      try {
        document.getElementById("hidCallbackFunction").value = fnCallback;
      }
      catch (e) {
      }
      break;
  }
  var scrWdth = screen.availWidth;
  var xPos = (scrWdth - width) / 2;
  var scrHeight = screen.height;
  var scrWidth = screen.width;
  with (objdvDisableParent) {
    style.display = "";
    style.visibility = "visible";
    style.height = parseInt(pgHt.y) + 25 + "px";
    style.width = (scrWidth - 30) + "px";
    setOpacity(objdvDisableParent, "#ffffff", "0.6");
    if (parent.document.getElementById("ifrmSearch") != null) {
      style.zIndex = parent.document.getElementById("ifrmSearch").style.zIndex + 1;
    }
    try {
      var top = 0;
      if (IsAsp == true) {
        if (window.parent.screenTop > 0)
          top = window.parent.screenTop;
        style.height = window.parent.parent.document.body.clientHeight + top + "px";
        if (window.parent.parent.document.body.scrollHeight > window.parent.parent.document.body.clientHeight)
          style.height = window.parent.parent.document.body.scrollHeight + top + "px";

        style.width = (scrWidth - 30) + "px";
      }
    }
    catch (e) {
    }
  }

  with (objdvAlertBox) {

    if (anchorObject != null) {
      if (showWhere == 'left') { style.left = anchorObject.x + 'px'; }
      if (showWhere == 'right') { style.left = (anchorObject.x - width) + 'px'; }
      style.top = (anchorObject.y - 105) + "px";
      if (showWhere == 'top') { style.top = (anchorObject.y - height) + 'px'; style.left = (anchorObject.x - height) + 'px'; }
      if (showWhere == 'righttop') {
        style.top = (anchorObject.y - 16) - height + 'px';
        style.left = (anchorObject.x - width) + 'px'; ;
      }
      if (showWhere == 'leftbottom') {
        style.top = (anchorObject.y + 20) + 'px';
        style.left = (anchorObject.x - 5) + 'px'; ;
      }
    }
    else {
      style.left = xPos + "px";
      style.top = 350 + "px";
    }
    style.visibility = 'visible';
    style.display = "";
    style.width = width + "px";
    //specific for FixeFox
    style.zIndex = objdvDisableParent.style.zIndex + 1;

    //Set position of Irame behind custome alert box. Iframe is used behind custome alert box to hide drop down box which overlaps on it in IE6.0.
    try {
      if (IsAsp == true) {
        style.left = (anchorObject.x + 165) + "px";
        style.top = (anchorObject.y + 115) + "px";
        if (ifrmBehindCustomeAlert != null && anchorObject != null) {
          ifrmBehindCustomeAlert.style.left = (anchorObject.x + 170) + "px";
          ifrmBehindCustomeAlert.style.top = (anchorObject.y + 125) + "px";
          ifrmBehindCustomeAlert.style.width = (parseInt(width) - 10) + "px";
          ifrmBehindCustomeAlert.style.height = (objdvAlertBox.offsetHeight - 12) + "px";
        }
      }
    }
    catch (e)
        { }
  }
  // DECLARED ON VILLAINDIVIDUAL PAGE.  
  var objDisableParent_ASP = parent.window.document.getElementById("dvDisableParent_ASP");
  if (objDisableParent_ASP != null) {
    with (objDisableParent_ASP) {
      style.display = "";
      style.visibility = "visible";
      style.height = parent.window.document.body.clientHeight + "px";
      style.width = parent.window.document.body.clientWidth + "px";
      style.top = "0px";
      style.left = "0px";
      setOpacity(objDisableParent_ASP, "#ffffff", "0.6");
    }
  }
}

function hideAlert(msgBoxVal) {
  try {
    var ifrmBehindCustomeAlert = document.getElementById("asp_IfrmBehindCustomeAlert");
    var objASPdvDisableParent = document.getElementById("asp_dvDisableParent");
    var objDisableParent_ASP = parent.window.document.getElementById("dvDisableParent_ASP");  // DECLARED ON VILLAINDIVIDUAL PAGE.  
    var objASPAlertBox = parent.document.getElementById("asp_dvAlertBox");
    //Start: Bug 7124
    try { IsAnyAmendPopUpOpen = false; }
    catch (ex) { }
    //End: Bug 7124
    if (objdvDisableParent == null) {
      objdvDisableParent = document.getElementById("dvDisableParent");
    }
    if (ifrmBehindCustomeAlert != null) {
      ifrmBehindCustomeAlert.style.display = "none";
      ifrmBehindCustomeAlert.style.visibility = "hidden";
    }
    if (objAlertBox == null) {
      objAlertBox = document.getElementById("dvAlertBox");
    }
  }
  catch (e) {
    var objdvDisableParent = document.getElementById("dvDisableParent");
    var objAlertBox = document.getElementById("dvAlertBox");
  }

  try {
    if (msgBoxVal.toString().length > 0) {
      var objhdnHoldStatus = document.getElementById("hdnHoldStatus");
      if (objhdnHoldStatus.value == "notclicked") {
        var obhdnCurrentRecord = document.getElementById("hdnCurrentRecord");
        obhdnCurrentRecord.value = parseInt(obhdnCurrentRecord.value) - 1;
        objhdnHoldStatus.value = "";
      }
    }
  }
  catch (e) {

  }
  if (objdvDisableParent != null) {
    with (objdvDisableParent) {
      style.display = "none";
      style.visibility = "hidden";
    }
  }
  if (objASPdvDisableParent != null) {
    with (objASPdvDisableParent) {
      style.display = "none";
      style.visibility = "hidden";
    }
  }
  if (objDisableParent_ASP != null) {
    objDisableParent_ASP.style.display = "none";
    objDisableParent_ASP.style.visibility = "hidden";
  }
  if (objAlertBox != null) {
    with (objAlertBox) {
      style.display = "none";
      style.visibility = "hidden";
    }
  }
  if (objASPAlertBox != null) {
    with (objASPAlertBox) {
      style.display = "none";
      style.visibility = "hidden";
    }
  }
}

var isOkClicked = false;
function AlertButtonClick(btn) {
  hideAlert('');
  switch (btn.toLowerCase()) {
      case "yes":
          if (document.getElementById("hdn_fncallback_params").value != "") {
              eval(document.getElementById("hidCallbackFunction").value + "(" + document.getElementById("hdn_fncallback_params").value + ")");
          }
          else
              eval(document.getElementById("hidCallbackFunction").value + "('YES')");
          break;

    case "no":
      eval(document.getElementById("hidCallbackFunction").value + "('NO')");
      break;

    case "ok":
      if (document.getElementById("hidCallbackFunction").value != null && document.getElementById("hidCallbackFunction").value.replace(/^\s+|\s+$/g, '') != "" && document.getElementById("hidCallbackFunction").value != "null") {
        if (document.getElementById("hdn_fncallback_params").value != "") {
          eval(document.getElementById("hidCallbackFunction").value + "(" + document.getElementById("hdn_fncallback_params").value + ")");
        }
        isOkClicked = true;
      }
      break;
  }
}

function isInteger(s) {
  var i;

  if (isEmpty(s))
    if (isInteger.arguments.length == 1) return 0;
  else return (isInteger.arguments[1] == true);

  for (i = 0; i < s.length; i++) {
    var c = s.charAt(i);

    if (!isDigit(c)) return false;
  }

  return true;
}
function isEmpty(s) {
  return ((s == null) || (s.length == 0));
}

function isDigit(c) {
  return ((c >= "0") && (c <= "9"));
}

//This function returns whether the search is specific centre search or group search
function GetSearchType(centreCode) {
  var arrGroups = js_Groups.split('|');
  for (i = 0; i < arrGroups.length; i++) {
    var arrGroup = arrGroups[i].split('-');
    if (arrGroup.length > 0) {
      if (Trim(arrGroup[0].toUpperCase()) == Trim(centreCode.toUpperCase())) {
        return "GROUP";
      }
    }
  }
  return "CENTRE";
}

function getSelectedIndex(select, strValue) {
  var objSelect = document.getElementById(select);
  var intSelectedIndex = 0;
  for (var intIndex = 0; intIndex < objSelect.options.length; intIndex++) {
    if (objSelect.options[intIndex].value == strValue) {
      intSelectedIndex = intIndex;
      break;
    }
  }
  return intSelectedIndex;
}
function DisableParent() {
  try {
    var asp_dv = parent.document.getElementById("asp_dvDisableParent");
    if (asp_dv != null) {
      // for ASP pages
      var pgHt = getAnchorPosition("asp_pgHeight");
      with (parent.document.getElementById("asp_dvDisableParent")) {
        style.display = "";
        style.visibility = "visible";
        style.width = parent.document.body.offsetWidth;
        if (parent.document.body.offsetHeight > pgHt.y) {
          style.height = parseInt(parent.document.body.offsetHeight) + "px";
        }
        else {
          style.height = parseInt(pgHt.y) + "px";
        }
        //for Centre ASP pages,the IFRAME style default values are not retrived
        // need to set these values
        setOpacity(parent.document.getElementById("asp_dvDisableParent"), "#ffffff", "0.6");
      }
      var aspAlertBox = document.getElementById("asp_dvAlertBox");
      if (aspAlertBox != null) {
        with (aspAlertBox) {
          style.display = "none";
          style.visibility = "hidden";
        }
      }
      var alertBox = document.getElementById("dvAlertBox");
      if (alertBox != null) {
        with (alertBox) {
          style.display = "none";
          style.visibility = "hidden";
        }
      }
      var dvDisableParent = document.getElementById("dvDisableParent");
      if (dvDisableParent != null) {
        with (dvDisableParent) {
          style.display = "";
          style.visibility = "visible";
          if (parent.document.body.offsetHeight > pgHt.y) {
            style.height = parseInt(parent.document.body.offsetHeight) + "px";
          }
          else {
            style.height = parseInt(pgHt.y) + "px";
          }
          style.width = document.body.offsetWidth + "px";
          setOpacity(dvDisableParent, "#ffffff", "0.6");
        }
      }
    }
    else {
      var pgHt = getAnchorPosition("pgHeight");
      with (document.getElementById("dvDisableParent")) {
        style.display = "";
        style.visibility = "visible";
        if (parent.document.body.offsetHeight > pgHt.y) {
          style.height = parseInt(parent.document.body.offsetHeight) + "px";
        }
        else {
          style.height = parseInt(pgHt.y) + "px";
        }
        style.width = parent.document.body.offsetWidth + "px";
        setOpacity(document.getElementById("dvDisableParent"), "#ffffff", "0.6");
      }
      with (document.getElementById("dvAlertBox")) {
        style.display = "none";
        style.visibility = "hidden";
      }
    }

  }
  catch (e) {

  }
}

function EnableParent() {
  try {
    if (document.getElementById("dvDisableParent") != null) {
      with (document.getElementById("dvDisableParent")) {
        style.display = "none";
        style.visibility = "hidden";
        style.height = 1 + "px";
      }
    }
    if (document.getElementById("dvAlertBox") != null) {
      with (document.getElementById("dvAlertBox")) {
        style.display = "";
        style.visibility = "hidden";
      }
    }
    // for asp pages
    var asp_dvDisableParent = parent.document.getElementById("asp_dvDisableParent");
    if (asp_dvDisableParent != null) {
      with (asp_dvDisableParent) {
        style.display = "none";
        style.visibility = "hidden";
        style.height = 1 + "px";
      }
    }
    var asp_dvAlertBox = parent.document.getElementById("asp_dvAlertBox");
    if (asp_dvAlertBox != null) {
      with (asp_dvAlertBox) {
        style.display = "";
        style.visibility = "hidden";
      }
    }
  }
  catch (e) {
  }

}
// Function to Disable Parent (HS) Page
function DisableParentPage() {
  var pgHt = getAnchorPosition("pgHeight");
  with (document.getElementById("dvDisableParentPage")) {
    style.display = "";
    style.visibility = "visible";
    style.height = parseInt(pgHt.y) + 30 + "px";
  }

}
// Function to Enable Parent (HS) Page
function EnableParentPage() {
  try {
    var objDivDisableParentPage = document.getElementById("dvDisableParentPage");
    //4554 START: Added this hook to work for asp pages
    if (objDivDisableParentPage == null) objDivDisableParentPage = document.getElementById("asp_dvDisableParent"); //HOOK FOR ASP PAGES
    if (objDivDisableParentPage == null) objDivDisableParentPage = document.getElementById("dvDisableParent"); //HOOK FOR SEARCH RESULTS 
    objDivDisableParentPage.style.display = "none";
    objDivDisableParentPage.style.visibility = "hidden";
    objDivDisableParentPage.style.height = 1 + "px";
  }
  catch (ex) {
    alert(ex);
  }

}
//Function to show help iFrame
var timerRemvPoolFence = 0;
function showHelpIFrame(iFrame, anchorObject, y, x, width, height, title, message) {
    try {
        var iFrmHelp = document.getElementById(iFrame);
        var anchorPos = getAnchorPosition(anchorObject);
        iFrmHelp.style.top = parseInt(anchorPos.y) - y + "px";
        iFrmHelp.style.left = parseInt(anchorPos.x) - x + "px";
        iFrmHelp.style.width = (16 + width) + "px";
        iFrmHelp.style.height = (33 + height) + "px";

        iFrmHelp.contentWindow.document.getElementById('hoverTitle').style.width = width + "px";
        iFrmHelp.contentWindow.document.getElementById('hoverMsg').style.width = width + "px";
        iFrmHelp.contentWindow.document.getElementById('hoverMsg').style.height = (height - 1) + "px";
        iFrmHelp.contentWindow.document.getElementById('tdMarginLeft').style.height = (height - 8) + "px";
        iFrmHelp.contentWindow.document.getElementById('tdMarginRight').style.height = (height - 8) + "px";
        iFrmHelp.contentWindow.document.getElementById('tblBottom').style.width = (width) + "px";

        iFrmHelp.contentWindow.document.getElementById('hoverTitle').innerHTML = "<b>&nbsp;" + title + "</b>";
        var txtMessage = "";
        if (title == "Removable Pool Fences") {
            txtMessage = "<div style='position:absolute; top:30px; width:318px;height:170px;overflow-y:scroll;overflow-X:hidden; left:8px; padding-right: 5px; vertical-align:top;' onmouseout='javascript:window.parent.HideRemvPoolFences();' onmouseover='javascript:window.parent.ClearTime();'>" + message + "</div>";
        }
        else {
            txtMessage = message
        }
        iFrmHelp.contentWindow.document.getElementById('hoverMsg').innerHTML = txtMessage;
        iFrmHelp.style.visibility = 'visible';
        iFrmHelp.style.display = 'block';
    }
    catch (e)
  { }
}

//Hide help iFrame
function hideHelpIFrame(iFrame, source) {
    var iFrmHelp = null;
    try {
        iFrmHelp = document.getElementById(iFrame);
        if (source == "Removable Pool Fences") {
            timerRemvPoolFence = setTimeout("HideRemvPoolFences()", 2000);
        }
        else {
            iFrmHelp.style.visibility = 'hidden';
            iFrmHelp.style.display = 'none';
        }
    }
    catch (e)
    { }
}
//Function is used to clear timer for removable pool fences tooltip
function ClearTime() {
    try {
        clearTimeout(timerRemvPoolFence);
    }
    catch (e)
    { }
}
//Function is used to hide removable pool fences tooltip
function HideRemvPoolFences() {
    try {
        document.getElementById('iFrmHelp').style.visibility = 'hidden';
        document.getElementById('iFrmHelp').style.display = 'none';
    }
    catch (e)
    { }
}
//Function to show carOnRequest iFrame
function showOnRequestIFrame(iFrame, anchorObject, y, x, width, height, title, message) {
    try {
        var iFrmHelp = document.getElementById(iFrame);
        iFrmHelp.style.top = "400px";
        iFrmHelp.style.left = "530px";
        iFrmHelp.style.width = (16 + width) + "px";
        iFrmHelp.style.height = (33 + height) + "px";

        iFrmHelp.contentWindow.document.getElementById('hoverTitle').style.width = width + "px";
        iFrmHelp.contentWindow.document.getElementById('hoverMsg').style.width = width + "px";
        iFrmHelp.contentWindow.document.getElementById('hoverMsg').style.height = (height - 1) + "px";
        iFrmHelp.contentWindow.document.getElementById('tdMarginLeft').style.height = (height - 8) + "px";
        iFrmHelp.contentWindow.document.getElementById('tdMarginRight').style.height = (height - 8) + "px";
        iFrmHelp.contentWindow.document.getElementById('tblBottom').style.width = (width) + "px";

        iFrmHelp.contentWindow.document.getElementById('hoverTitle').innerHTML = "<b>&nbsp;" + title + "</b>";
        iFrmHelp.contentWindow.document.getElementById('hoverMsg').innerHTML = message;

        iFrmHelp.style.visibility = 'visible';
        iFrmHelp.style.display = 'block';
    }
    catch (e) {

    }
}

//anchorObject WILL BE AN OBJECT CONTAINING THE X AND Y POSTIONS FOR THE CONTROL FOR WHICH THE MSG BOX NEEDS TO BE SHOWN
//Showwhere will decide where to show the alert. 
function showAlertIFrame(title, msg, button, width, height, anchorObject, fnCallback, showWhere) {
  var iFrmAlert = null;
  var objalertTitle = null;
  var objalertMsg = null;
  var objcmdOk = null;
  var objlblOk = null;
  var objcmdOkOn = null;
  var objcmdYes = null;
  var objcmdNo = null;
  var objdvDisableParent = null;
  var pgHt = null;
  var objdvAlertBox = null;

  iFrmAlert = document.getElementById('iFrmCustomAlert');
  if (iFrmAlert == null)//IN THE LANDING PAGE IT iFrmAlert will be null
  {
    iFrmAlert = window.parent.document.getElementById('iFrmCustomAlert');
    objdvDisableParent = window.parent.document.getElementById("dvDisableParentFrame");
    pgHt = window.parent.getAnchorPosition("pgHeightFrame");
    anchorObject.y = anchorObject.y + 233;
    if (screen.availWidth > 800) anchorObject.x = (screen.availWidth - 975) / 2;
  }
  else {
    objdvDisableParent = document.getElementById("dvDisableParentFrame");
    pgHt = getAnchorPosition("pgHeightFrame");
  }
  objalertTitle = iFrmAlert.contentWindow.document.getElementById("alertTitle");
  objalertMsg = iFrmAlert.contentWindow.document.getElementById("alertMsg");
  objcmdOk = iFrmAlert.contentWindow.document.getElementById("cmdOk");
  objlblOk = iFrmAlert.contentWindow.document.getElementById("lblOK");
  objcmdOkOn = iFrmAlert.contentWindow.document.getElementById("cmdOkOn");
  objcmdYes = iFrmAlert.contentWindow.document.getElementById("cmdYes");
  objcmdNo = iFrmAlert.contentWindow.document.getElementById("cmdNo");

  //SET THE TITLE AND MESSAGE       
  objalertTitle.innerHTML = "<b><font class=\"Verdana11BoldWhite\" color=\"#FFFFFF\">" + title + "</font></b>";
  objalertMsg.innerHTML = "<b>" + msg + "</b>";

  //SET THE APPROPRIATE BUTTON VISIBILITY DEPENDING ON WHETHER TO SHOW YES/NO OR OK BUTTON
  objcmdOk.style.display = "none";
  objcmdOk.style.visibility = "hidden";
  objlblOk.style.display = "none";
  objlblOk.style.visibility = "hidden";
  objcmdOkOn.style.display = "none";
  objcmdOkOn.style.visibility = "hidden";
  objcmdYes.style.display = "none";
  objcmdYes.style.visibility = "hidden";
  objcmdNo.style.display = "none";
  objcmdNo.style.visibility = "hidden";
  switch (button) {
    case "OK":
      with (objcmdOk) {
        style.display = "";
        style.visibility = "visible";
        objlblOk.style.display = "";
        objlblOk.style.visibility = "visible";
      }
      break;
    case "YESNO":
      with (objcmdYes) {
        style.display = "";
        style.visibility = "visible";
      }
      with (objcmdNo) {
        style.display = "";
        style.visibility = "visible";
      }
      try {
        iFrmAlert.contentWindow.document.getElementById("hidCallbackFunction").value = fnCallback;
      }
      catch (e) {
      }
      break;
  }

  //MAKE THE dvDisableParent AS VISIBLE IN ORDER TO DISABLE THE PARENT WHEN POP-UP IS OPEN
  with (objdvDisableParent) {
    style.display = "";
    style.visibility = "visible";
    style.height = parseInt(pgHt.y) + 30 + "px";
    style.width = (screen.width - 30) + "px";
    setOpacity(objdvDisableParent, "#ffffff", "0.6");
  }

  //SET THE PROPERTIES OF THE MAIN DIV TAG INSIDE IFRAME
  objdvAlertBox = iFrmAlert.contentWindow.document.getElementById("dvAlertBox");
  if (showWhere == 'undefined') { showWhere = 'left'; }
  var frmWidth = width;
  var frmHeight = height;
  with (iFrmAlert) {
    if (anchorObject != null) {
      if (showWhere == 'left') { style.left = anchorObject.x + 'px'; }
      if (showWhere == 'right') { style.left = (anchorObject.x - frmWidth) + 'px'; }

      style.top = (anchorObject.y - 105) + "px";
      if (showWhere == 'top') { style.top = (anchorObject.y - frmHeight) + 'px'; style.left = (anchorObject.x - frmHeight) + 'px'; }
      if (showWhere == 'righttop') { style.top = (anchorObject.y - frmHeight) + 'px'; style.left = (anchorObject.x - frmHeight) + 'px'; }
    }
    else {
      style.left = xPos + "px";
      style.top = 350 + "px";
    }
    style.width = frmWidth + "px";
    frmHeight = parseInt(frmHeight) + 20;
    style.height = frmHeight + "px";
    objdvAlertBox.style.height = frmHeight + "px";
  }

  //SHOW THE IFRAME
  iFrmAlert.style.visibility = 'visible';
  iFrmAlert.style.display = 'block';

}

function hideAlertIFrame() {
  var objdvDisableParent = parent.document.getElementById("dvDisableParentFrame");
  with (objdvDisableParent) {
    style.display = "none";
    style.visibility = "hidden";
    style.height = "1px";
  }

  var iFrmAlert = parent.document.getElementById('iFrmCustomAlert');
  iFrmAlert.style.visibility = 'hidden';
  iFrmAlert.style.display = 'none';
}

function SetIframeWidth(val) {
  try {
    var objParent = window.parent;
    var anyIFrameOpen = false;

    var objIframe = parent.document.getElementById("ifrmSearch");
    if ((objIframe != undefined) && (objIframe != null)) {
      var objifrmCentres = document.getElementById("ifrmCentres");
      if ((objifrmCentres != undefined) && (objifrmCentres != null)) {
        if (objifrmCentres.style.visibility == 'visible') {
          anyIFrameOpen = true;
        }
      }

      var objifrmEnews = document.getElementById("ifrmEnews");
      if ((objifrmEnews != undefined) && (objifrmEnews != null)) {
        if (objifrmEnews.style.visibility == 'visible') {
          anyIFrameOpen = true;
        }
      }

      var objifrmincompleteBooking = document.getElementById("incompleteBooking");
      if ((objifrmincompleteBooking != undefined) && (objifrmincompleteBooking != null)) {
        if ((objifrmincompleteBooking.style.display == 'block') || (objifrmincompleteBooking.style.display == "")) {
          anyIFrameOpen = true;
        }
      }
      if (anyIFrameOpen == true) {
        objIframe.style.width = parseInt(800) + "px";
      }
      else {
        objIframe.style.width = parseInt(val) + "px";
      }
    }

  }
  catch (e) {

  }
}

function setOpacity(obj, bgColor, valOpacity) {
  with (obj) {
    style.background = bgColor;
    style.filter = "alpha(opacity=" + (valOpacity * 100) + ")"; // For IE6
    style.opacity = valOpacity; //  for browsers supporting CSS3 opacity
    style.KHTMLOpacity = valOpacity; // Safari
    style.MozOpacity = valOpacity; // Old Mozilla and Firefox           
  }
}

function RemoveWhiteSpace(inStr) {
  var arrInStr = inStr.split(" ");
  var cleanString = "";
  for (var i = 0; i < arrInStr.length; i++) {
    cleanString += arrInStr[i];
  }
  return cleanString;
}

function getPagenameFromURL(urlString) {
  var slash;
  var queryString;

  slash = urlString.lastIndexOf("/");
  queryString = urlString.lastIndexOf("?");
  if (queryString < 0) {
    queryString = urlString.length;
  }
  urlString = urlString.substr(slash + 1, queryString - slash - 1);
  return urlString;
}
//FUNCTION IS USED TO DISABLE/ENABLE MOUSE RIGHT CLICK
// MODEFLAG = 1 DISABLE
// MODEFLAG = 0 ENABLE

function DisableEnableRightClick(modeFlag) {
  document.oncontextmenu = mischandler;
  document.onmousedown = mousehandler;
  document.onmouseup = mousehandler;
  var isNS = (navigator.appName == "Netscape") ? 1 : 0;

  if (navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
  function mischandler() {
    if (modeFlag == "1") {
      return false;
    }
    else {
      return true;
    }
  }
  function mousehandler(e) {
    var myevent = (isNS) ? e : event;
    var eventbutton = (isNS) ? myevent.which : myevent.button;
    if ((eventbutton == 2) || (eventbutton == 3)) {
      if (modeFlag == "1") {
        return false;
      }
      else {
        return true;
      }
    }
  }
}

