﻿/*
    An amalgamation of two script files and the extraction of some common functionality
    The script files are Wireless/java/Common.js and Ecom/scripts/Library.js
    with the following functions be extracted as common
*/

function ErrorDialog(msg) {
  alert(msg);
}

// used by CCollapseLiteralControl and ShowHelp.ascx
function Collapse(id) {
	var ele = document.getElementById(id);
	if (ele.style.display != 'block') {
		ele.style.display = 'block';
	}
	else {
		ele.style.display = 'none';
	}
}

function NI() {
  alert('Not implemented for demo version');
}

// msg Dialog Message
// id	 id of an asp:HiddenField control which has a server event set up for ValueChanged
//     if the dialog is confirmed then fire the server event
//		 the server event must clear the value ready for next time
function ConfirmDialog(msg, id) {
  var ele = document.getElementById(id);
  ele.value = window.confirm(msg);
  if (ele.value == 'true')
    aspnetForm.submit(); // cause a PostBack. <form id="aspnetForm" .../>
}

// Open dialog
function OpenDialog(url, args) {
  var sFeatures = 'center:yes;status:no;resizable:no;scroll:no;help:no;dialogHeight:250px;dialogWidth:380px';
  var retVal = window.showModalDialog(url, args, sFeatures);
  if (retVal >= 0) {
    var ele = document.getElementById('hdnReturnValue'); // 'thisForm's hidden return value
    if (ele) ele.value = retVal;

    ele = document.getElementById('aspnetForm'); // 'aspnetForm'is id of parent Form
    ele.submit();
    return true;
  }
  return false;
}

// Close dialog
function CloseDialog(value) {
  window.returnValue = value;
  window.close();
}


function DeleteBooking() {
  return window.confirm('Do you really want to delete this booking?');
}

function ProcessBooking() {
  return window.confirm('The on-line system will now process your bookings');
}

function ClearBasket() {
  return window.confirm('Do you really want to delete all bookings?');
}

function NewBasket() {
  return window.confirm('Any uncompleted basket will be cleared!');
}

function ConfirmBooking() {
  return window.confirm('Do you really want to confirm this booking?');
}

function ConfirmSubmitForLocationsList() {
  return window.confirm('This will send an email asking us to consider adding this site to our Location List. \n Before submitting, please edit the place name to accurately identify the site! \n \n Do you want to continue to send the email now?');
}

function RelinquishBooking() {
  return window.confirm('Do you really want to relinquish this booking?');
}

function CancelChallenge() {
  return window.confirm('Do you really want to cancel this challenge?');
}

function SetStage(stage) {
  //parent.TopMenu.SetStage(stage);
  top.frames('TopMenu').SetStage(stage);
}

function BuyTokens(msg) {
  alert(msg);
}


/* Added by R Mason 13 Sep 2007* */
/* Modified by R Mason 23 Oct 2007 to deal with two buttons */
/* Used to hide the print button and print the report */
function HideMeAndPrint(btnTop, btnBottom) {

  var id1 = document.getElementById(btnTop);
  var id2 = document.getElementById(btnBottom);

  if (id1 != null && id2 != null) {
    id1.style.visibility = 'hidden';
    id2.style.visibility = 'hidden';
    window.print();
    id1.style.visibility = 'visible';
    id2.style.visibility = 'visible';
  }
}