
function paymark_verify(merchant) {
window.open('http://www.paymark.co.nz/dart/darthttp.dll?etsl&tn=verify&merchantid='
+merchant,'verify', 'scrollbars=yes, width=400, height=400');
}

function showreceipt(invoice, hostel, base){
    var url=base+'/receipt.aspx?iid='+invoice+'&hid='+hostel;
    window.open(url, "receipt", "width=690,height=600,toolbar=no,header=no,location=no,resizable=0,scrollbars=yes");	
}

function openWinRoomTypes(){
 	window.open("help_roomtypes.htm", "Help", "width=720,height=200,scrollbars=no,resizable=no,status=no,toolbar=no,menubar=no");
}

function showMap(hostel){
    var url='http://www.bbh.co.nz/bbh_Map.aspx?hid='+hostel;
    window.open(url, "map", "width=690,height=460,toolbar=no,header=no,location=no,resizable=0,scrollbars=yes");	
}

function showBpkrProfile(p_UserID){
    var url = s10_Url + s10_BaseDir + 'bbh_Profile.aspx?UserID=' + p_UserID + '&InPopup=True';
    window.open(url, "profile", "width=540,height=660,toolbar=no,header=no,location=no,resizable=0,scrollbars=yes");	
}

function showRatingReviews(p_HostelID){
    var url = s10_Url + s10_BaseDir + 'bbh_RatingReviews.aspx?BaseHostelID=' + p_HostelID;
    window.open(url, "reviews", "width=650,height=660,toolbar=no,header=no,location=no,resizable=0,scrollbars=yes");	
}

function showBpkrRatingReviews(p_VoteID){
    var url = s10_Url + s10_BaseDir + 'bbh_RatingReviews.aspx?VoteID=' + p_VoteID;
    window.open(url, "reviews", "width=650,height=660,toolbar=no,header=no,location=no,resizable=0,scrollbars=yes");	
}

function showterms(invoice, base){
    var url=base+'bbh_Terms.aspx?iid='+invoice;
    window.open(url, "", "width=690,height=600,toolbar=no,header=no,location=no,resizable=0,scrollbars=yes");	
}

function changeImage(image){	
	document.getElementById("imageHolder").src = "hostelimages/" + image;	
}

var s10_Url = "";
var s10_SecureUrl = "";
var s10_BaseDir = "";
var s10_Common_DataCur = "";
var s10_Common_DataAll = "";
var s10_Common_Image = "";
var s10_Common_LocID = 0;
var s10_Common_HostelID = 0;
var s10_Common_Loc = "";
var s10_Common_Hostel = "";

var s10_Fade_oPic1 = null;
var s10_Fade_oPic2 = null;
var s10_Fade_oName = null;
var s10_Fade_oLocation = null;
var s10_Fade_TopNo = 0;
var s10_Fade_NextNameHtml = "";
var s10_Fade_NextLocationHtml = "";
var s10_Fade_Opacity1 = 0;
var s10_Fade_Opacity2 = 0;
var s10_Fade_UseFilter = false;
var s10_Fade_ShiftValue = 5;
var s10_Fade_ImageAreaHeight = 162;
var s10_Fade_Pause = 6000;
var s10_Fade_Speed = 5;

var s10_Comp_Days = 0;
var s10_Comp_Hrs = 0;
var s10_Comp_Mins = 0;
var s10_Comp_Secs = 0;
var s10_Comp_oDigit1 = null;
var s10_Comp_oDigit2 = null;
var s10_Comp_oDigit3 = null;
var s10_Comp_oDigit4 = null;
var s10_Comp_oDigit5 = null;
var s10_Comp_oDigit6 = null;
var s10_Comp_oDigit7 = null;
var s10_Comp_oDigit8 = null;
var s10_Comp_oDigit9 = null;

var s10_CompLangRoller = null;
var s10_CompLangRollerWait = 50;
var s10_CompLangRollerMove = 1;
var s10_CompLangRollerPos = 0;
var s10_CompLangRollerTop = -460;


function s10_Common_Init() {

	s10_Url = document.getElementById("s10_Url").value;
	s10_SecureUrl = document.getElementById("s10_SecureUrl").value;
	s10_BaseDir = document.getElementById("s10_BaseDir").value;
	s10_Common_DataAll = document.getElementById("s10_Common_DataAll").value;
	s10_Common_DataCur = s10_Common_DataAll;

	if (document.getElementById("s10_Fade_Area")) { s10_Fade_Init(); }
	if (document.getElementById("s10_Comp_Box")) { s10_Comp_Init(); }
	
	if (document.getElementById("s10_CompLangRoller")) {
	  s10_CompLangRoller = document.getElementById("s10_CompLangRoller");
		s10_CompLangRollerJump(); }

//	Dimmer_BuildDiv();
}

function s10_CompLangRollerJump() {
  if (s10_CompLangRollerPos < s10_CompLangRollerTop) {
	  s10_CompLangRollerPos = 0; }
  else {
	  s10_CompLangRollerPos = s10_CompLangRollerPos - s10_CompLangRollerMove; }
	s10_CompLangRoller.style.backgroundPosition = "0px " + s10_CompLangRollerPos + "px";
	window.setTimeout("s10_CompLangRollerJump()",s10_CompLangRollerWait);
}


function s10_Common_GetNextData() {
	var iPos = 0;
	
	iPos = s10_Common_DataCur.indexOf(";");
	s10_Common_Image = s10_Common_DataCur.substr(0, iPos);
	s10_Common_DataCur = s10_Common_DataCur.substr(iPos + 1);
	iPos = s10_Common_DataCur.indexOf(";");
	s10_Common_LocID = s10_Common_DataCur.substr(0, iPos);
	s10_Common_DataCur = s10_Common_DataCur.substr(iPos + 1);
	iPos = s10_Common_DataCur.indexOf(";");
	s10_Common_HostelID = s10_Common_DataCur.substr(0, iPos);
	s10_Common_DataCur = s10_Common_DataCur.substr(iPos+ 1);
	iPos = s10_Common_DataCur.indexOf(";");
	s10_Common_Loc = s10_Common_DataCur.substr(0, iPos);
	s10_Common_DataCur = s10_Common_DataCur.substr(iPos + 1);
	iPos = s10_Common_DataCur.indexOf(";");
	s10_Common_Hostel = s10_Common_DataCur.substr(0, iPos);
	s10_Common_DataCur = s10_Common_DataCur.substr(iPos + 1);

	if (s10_Common_DataCur == "") { s10_Common_DataCur = s10_Common_DataAll; }
}


function s10_Fade_Init() {
	var iTop = 0;

	s10_Fade_oPic1 = document.getElementById("s10_Fade_Pic1");
	s10_Fade_oPic2 = document.getElementById("s10_Fade_Pic2");
	s10_Fade_oName = document.getElementById("s10_Fade_Name");
	s10_Fade_oLocation = document.getElementById("s10_Fade_Location");
	s10_Fade_ImageAreaHeight = document.getElementById("s10_Fade_PicArea").clientHeight;	
	s10_Fade_TopNo = 1;

	iTop = 0 + ((s10_Fade_ImageAreaHeight - s10_Fade_oPic1.clientHeight) / 2);
	s10_Fade_oPic1.style.top = iTop + "px";

	if (s10_Fade_oPic1.filters) {
		s10_Fade_UseFilter = true; }
	else {
		s10_Fade_UseFilter = false; }
	s10_Fade_Opacity1 = 100;
	s10_Fade_Opacity2 = 0;

	s10_Common_GetNextData();	
	s10_Fade_PrepareNextItem();
}


function s10_Fade_PrepareNextItem() {
	var iPos = 0;
	var iNextNo = "";
	var iNewNextNo = 0;
	var iDataCur;

	s10_Common_GetNextData();
	
	if (s10_Fade_TopNo == 1) {
		s10_Fade_oPic2.src = s10_BaseDir + "hostelimages/" + s10_Common_Image; }
	else {
		s10_Fade_oPic1.src = s10_BaseDir + "hostelimages/" + s10_Common_Image; }
	s10_Fade_NextNameHtml = "<a href='" + s10_Url + s10_BaseDir + "bbh_HostelSearch.aspx?bbh=detail&AreaID=" + s10_Common_LocID + "&HostelID=" + s10_Common_HostelID + "'><b>" + s10_Common_Hostel + "</b></a>";
	s10_Fade_NextLocationHtml = "Location : <a href='" + s10_Url + s10_BaseDir + "bbh_HostelSearch.aspx?bbh=list&AreaID=" + s10_Common_LocID + "'><b>" + s10_Common_Loc + "</b></a>";

	window.setTimeout("s10_Fade_StartNextItem()",s10_Fade_Pause);
}


function s10_Fade_StartNextItem() {
	var iTop = 0;
	
	if (s10_Fade_TopNo == 1) {
		iTop = 0 + ((s10_Fade_ImageAreaHeight - s10_Fade_oPic2.clientHeight) / 2);
		s10_Fade_oPic2.style.top = iTop + "px"; }
	else {
		iTop = 0 + ((s10_Fade_ImageAreaHeight - s10_Fade_oPic1.clientHeight) / 2);
		s10_Fade_oPic1.style.top = iTop + "px"; }

	s10_Fade_oName.innerHTML = "";
	s10_Fade_oLocation.innerHTML = "";
	
	s10_Fade_Shift();
}


function s10_Fade_Shift() {

	if (s10_Fade_TopNo == 1) {
		s10_Fade_Opacity1 = s10_Fade_Opacity1 - s10_Fade_Speed;
		if (s10_Fade_Opacity1 < 0) { s10_Fade_Opacity1 = 0; }
		s10_Fade_Opacity2 = s10_Fade_Opacity2 + s10_Fade_Speed;
		if (s10_Fade_Opacity2 > 100) { s10_Fade_Opacity2 = 100; } }
	else {
		s10_Fade_Opacity1 = s10_Fade_Opacity1 + s10_Fade_Speed;
		if (s10_Fade_Opacity1 > 100) { s10_Fade_Opacity1 = 100; }
		s10_Fade_Opacity2 = s10_Fade_Opacity2 - s10_Fade_Speed;
		if (s10_Fade_Opacity2 < 0) { s10_Fade_Opacity2 = 0; } }

	if (s10_Fade_UseFilter) {
		s10_Fade_oPic1.filters.alpha.opacity = s10_Fade_Opacity1;
		s10_Fade_oPic2.filters.alpha.opacity = s10_Fade_Opacity2; }
	else {
		s10_Fade_oPic1.style.opacity = s10_Fade_Opacity1 / 100;
		s10_Fade_oPic2.style.opacity = s10_Fade_Opacity2 / 100; }
	
	if (s10_Fade_Opacity1 == 0 || s10_Fade_Opacity2 == 0) {
		s10_Fade_oLocation.innerHTML = s10_Fade_NextLocationHtml; 
		s10_Fade_oName.innerHTML = s10_Fade_NextNameHtml;
		if (s10_Fade_TopNo == 1) { s10_Fade_TopNo = 2; } else { s10_Fade_TopNo = 1; }
		s10_Fade_PrepareNextItem();
		return; }

	setTimeout("s10_Fade_Shift()",30);
}


function s10_Comp_Init () {

	s10_Comp_oDigit1 = document.getElementById("s10_Comp_Digit1");
	s10_Comp_oDigit2 = document.getElementById("s10_Comp_Digit2");
	s10_Comp_oDigit3 = document.getElementById("s10_Comp_Digit3");
	s10_Comp_oDigit4 = document.getElementById("s10_Comp_Digit4");
	s10_Comp_oDigit5 = document.getElementById("s10_Comp_Digit5");
	s10_Comp_oDigit6 = document.getElementById("s10_Comp_Digit6");
	s10_Comp_oDigit7 = document.getElementById("s10_Comp_Digit7");
	s10_Comp_oDigit8 = document.getElementById("s10_Comp_Digit8");
	s10_Comp_oDigit9 = document.getElementById("s10_Comp_Digit9");
	
	var iCompData = document.getElementById("s10_Comp_Data").value;
	var iNo1 = 0;
	var iNo2 = 0;
	var iNo3 = 0;

	s10_Comp_Days = Number(iCompData.substr(0, 3));
	s10_Comp_Hrs = Number(iCompData.substr(3, 2));
	s10_Comp_Mins = Number(iCompData.substr(5, 2));
	s10_Comp_Secs = Number(iCompData.substr(7, 2));

	iNo2 = s10_Comp_Days % 100;
	iNo3 = iNo2 % 10;
	iNo2 = (iNo2 - iNo3) / 10;
	iNo1 = (s10_Comp_Days - (iNo2 * 10) - iNo3) / 100;
	iNo1 = 0 - (iNo1 * 15);
	iNo2 = 0 - (iNo2 * 15);
	iNo3 = 0 - (iNo3 * 15);

	s10_Comp_oDigit1.style.backgroundPosition = iNo1 + "px 0px";
	s10_Comp_oDigit2.style.backgroundPosition = iNo2 + "px 0px";
	s10_Comp_oDigit3.style.backgroundPosition = iNo3 + "px 0px";

	iNo2 = s10_Comp_Hrs % 10;
	iNo1 = (s10_Comp_Hrs - iNo2) / 10;
	iNo1 = 0 - (iNo1 * 15);
	iNo2 = 0 - (iNo2 * 15);

	s10_Comp_oDigit4.style.backgroundPosition = iNo1 + "px 0px";
	s10_Comp_oDigit5.style.backgroundPosition = iNo2 + "px 0px";

	iNo2 = s10_Comp_Mins % 10;
	iNo1 = (s10_Comp_Mins - iNo2) / 10;
	iNo1 = 0 - (iNo1 * 15);
	iNo2 = 0 - (iNo2 * 15);

	s10_Comp_oDigit6.style.backgroundPosition = iNo1 + "px 0px";
	s10_Comp_oDigit7.style.backgroundPosition = iNo2 + "px 0px";

	iNo2 = s10_Comp_Secs % 10;
	iNo1 = (s10_Comp_Secs - iNo2) / 10;

	iNo1 = 0 - (iNo1 * 15);
	iNo2 = 0 - (iNo2 * 15);

	s10_Comp_oDigit8.style.backgroundPosition = iNo1 + "px 0px";
	s10_Comp_oDigit9.style.backgroundPosition = iNo2 + "px 0px";

	window.setTimeout("s10_Comp_Click()",1000);
}


function s10_Comp_Click() {
	
	if (s10_Comp_Secs > 0) { s10_Comp_Secs = s10_Comp_Secs - 1; } else { s10_Comp_Secs = 59; }
	iNo2 = s10_Comp_Secs % 10;
	iNo1 = (s10_Comp_Secs - iNo2) / 10;

	iNo1 = 0 - (iNo1 * 15);
	iNo2 = 0 - (iNo2 * 15);

	s10_Comp_oDigit8.style.backgroundPosition = iNo1 + "px 0px";
	s10_Comp_oDigit9.style.backgroundPosition = iNo2 + "px 0px";

	if (s10_Comp_Secs == 59) {

		if (s10_Comp_Mins > 0) { s10_Comp_Mins = s10_Comp_Mins - 1; } else { s10_Comp_Mins = 59; }
		iNo2 = s10_Comp_Mins % 10;
		iNo1 = (s10_Comp_Mins - iNo2) / 10;
		iNo1 = 0 - (iNo1 * 15);
		iNo2 = 0 - (iNo2 * 15);

		s10_Comp_oDigit6.style.backgroundPosition = iNo1 + "px 0px";
		s10_Comp_oDigit7.style.backgroundPosition = iNo2 + "px 0px";

		if (s10_Comp_Mins == 59) {

			if (s10_Comp_Hrs > 0) { s10_Comp_Hrs = s10_Comp_Hrs - 1; } else { s10_Comp_Hrs = 23; }

			iNo2 = s10_Comp_Hrs % 10;
			iNo1 = (s10_Comp_Hrs - iNo2) / 10;
			iNo1 = 0 - (iNo1 * 15);
			iNo2 = 0 - (iNo2 * 15);

			s10_Comp_oDigit4.style.backgroundPosition = iNo1 + "px 0px";
			s10_Comp_oDigit5.style.backgroundPosition = iNo2 + "px 0px";

			if (s10_Comp_Hrs == 23) {

				if (s10_Comp_Days > 0) { s10_Comp_Days = s10_Comp_Days - 1; } else { s10_Comp_Days = 999; }

				iNo2 = s10_Comp_Days % 100;
				iNo3 = iNo2 % 10;
				iNo2 = (iNo2 - iNo3) / 10;
				iNo1 = (s10_Comp_Days - (iNo2 * 10) - iNo3) / 100;
				iNo1 = 0 - (iNo1 * 15);
				iNo2 = 0 - (iNo2 * 15);
				iNo3 = 0 - (iNo3 * 15);

				s10_Comp_oDigit1.style.backgroundPosition = iNo1 + "px 0px";
				s10_Comp_oDigit2.style.backgroundPosition = iNo2 + "px 0px";
				s10_Comp_oDigit3.style.backgroundPosition = iNo3 + "px 0px";
			}
		}
	}
	window.setTimeout("s10_Comp_Click()",1000);
}


function bbh_ShowTextSize(p_TextArea, p_Area, p_MaxSize)
{
		var i_TextArea = document.getElementById(p_TextArea);
		var i_Area = document.getElementById(p_Area);
		if (i_TextArea != null && i_Area != null)
		{
		    i_Area.innerHTML = i_TextArea.value.length + " of " + p_MaxSize + " Chars";
		}
}


function bbh_StrTrim (str)
{
	var whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
	for (var i = 0; i < str.length; i++)
	{
		if (whitespace.indexOf(str.charAt(i)) === -1)
		{
			str = str.substring(i);
			break;
		}
	}
	for (i = str.length - 1; i >= 0; i--)
	{
		if (whitespace.indexOf(str.charAt(i)) === -1)
		{
			str = str.substring(0, i + 1);
			break;
		}
	}
	return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}


function bpkr_ProfileSection(p_Section) {

  var i_CurImg = document.getElementById(p_Section + "_Button").src;
	i_CurImg = i_CurImg.substr(i_CurImg.length - 8);
	
  if ( i_CurImg == "Open.png") {
  	document.getElementById(p_Section + "_Button").src = s10_BaseDir + "imagesS10/ButDropClose.png";
	  document.getElementById(p_Section + "_Info").style.display = "none";
  	document.getElementById(p_Section + "_Data").style.display = "block"; }
	else {
	document.getElementById(p_Section + "_Button").src = s10_BaseDir +  "imagesS10/ButDropOpen.png";
	document.getElementById(p_Section + "_Info").style.display = "block";
	document.getElementById(p_Section + "_Data").style.display = "none"; }
}

		

function disc_FuncConfirm(p_HideDiv, p_ShowDiv)
{
    document.getElementById(p_HideDiv).className = "buttonsHide";
    document.getElementById(p_ShowDiv).className = "buttonsShow";
}

function disc_FuncConfirmEdit()
{
    document.getElementById("admin_FunctionButtons").className = "buttonsHide";
    document.getElementById("editConfirmText").className = "confirmShow";
}
function disc_FuncConfirmAccept()
{
    document.getElementById("admin_FunctionButtons").className = "buttonsHide";
    document.getElementById("acceptConfirmText").className = "confirmShow";
}
function disc_FuncConfirmDiscard()
{
    document.getElementById("admin_FunctionButtons").className = "buttonsHide";
    document.getElementById("discardConfirmText").className = "confirmShow";
}
function disc_FuncConfirmMakeLive()
{
    document.getElementById("admin_FunctionButtons").className = "buttonsHide";
    document.getElementById("makeLiveConfirmText").className = "confirmShow";
}
function disc_FuncConfirmCancel()
{
    document.getElementById("admin_FunctionButtons").className = "buttonsHide";
    document.getElementById("cancelConfirmText").className = "confirmShow";
}
function disc_FuncConfirmReinstate()
{
    document.getElementById("admin_FunctionButtons").className = "buttonsHide";
    document.getElementById("reinstateConfirmText").className = "confirmShow";
}
function disc_FuncConfirmDelete()
{
    document.getElementById("admin_FunctionButtons").className = "buttonsHide";
    document.getElementById("deleteConfirmText").className = "confirmShow";
}
function disc_FuncConfirmAbort()
{
    document.getElementById("editConfirmText").className = "confirmHide";
    document.getElementById("acceptConfirmText").className = "confirmHide";
    document.getElementById("discardConfirmText").className = "confirmHide";
    document.getElementById("makeLiveConfirmText").className = "confirmHide";
    document.getElementById("cancelConfirmText").className = "confirmHide";
    document.getElementById("reinstateConfirmText").className = "confirmHide";
    document.getElementById("deleteConfirmText").className = "confirmHide";
    document.getElementById("admin_FunctionButtons").className = "buttonsShow";
}

function disc_ToggleWebMainAsBook()
{
    if (document.getElementById("xdp_WebMainAsBook").checked == true)
		{
		    document.getElementById("xdp_WebMainAsBookArea").className = "editHidden";
		}
		else
		{
		    document.getElementById("dp_Company").value = document.getElementById("dp_BookCompany").value;
		    document.getElementById("dp_Product").value = document.getElementById("dp_BookProduct").value;
		    document.getElementById("xdp_WebMainAsBookArea").className = "editShown";
		}
}

function disc_ToggleWebDiscountAsBook()
{
    if (document.getElementById("xdp_WebDiscountAsBook").checked == true)
		{
		    document.getElementById("xdp_WebDiscountAsBookArea").className = "editHidden";
		}
		else
		{
		    document.getElementById("dp_NewDiscount").value = document.getElementById("dp_BookDiscount").value;
		    document.getElementById("dp_NewConditions").value = document.getElementById("dp_BookConditions").value;
		    document.getElementById("xdp_WebDiscountAsBookArea").className = "editShown";
		}
}

function disc_ToggleWebActiveAs()
{
	var i_As0 = document.getElementById("xdp_WebActiveAs0");
		
	if (i_As0 != null)
	{
		if (document.getElementById("xdp_WebActiveAs0").checked == true)
		{
			document.getElementById("xdp_WebActiveAsArea").className = "editHidden";
    		document.getElementById("dp_Discount").value = document.getElementById("xdp_CurrNewDiscount").value;
    		document.getElementById("dp_Conditions").value = document.getElementById("xdp_CurrNewConditions").value;
    		return;
    	}
	}
	if (document.getElementById("xdp_WebActiveAs1").checked == true)
	{
		document.getElementById("xdp_WebActiveAsArea").className = "editHidden";
		if (document.getElementById("xdpc_WebAsBookDiscount").value = "0")
		{
			document.getElementById("dp_Discount").value = document.getElementById("dp_NewDiscount").value;
			document.getElementById("dp_Conditions").value = document.getElementById("dp_NewConditions").value;
		}
		else
		{
			document.getElementById("dp_Discount").value = document.getElementById("dp_BookDiscount").value;
			document.getElementById("dp_Conditions").value = document.getElementById("dp_BookConditions").value;
		}
 	}
	else
	{
		document.getElementById("xdp_WebActiveAsArea").className = "editShown";
	}
}

function disc_ToggleEditLocReservations(LocNo)
{
	if (document.getElementById("xdpl_" + LocNo + "_MainReservation").checked == true)
	{
		document.getElementById("locReservations_" + LocNo).className = "editHidden";
	}
	else
	{
		document.getElementById("dpl_" + LocNo + "_ReservationsPhone").value = document.getElementById("dp_ReservationsPhone").value;
		document.getElementById("dpl_" + LocNo + "_ReservationsEmail").value = document.getElementById("dp_ReservationsEmail").value;
		document.getElementById("dpl_" + LocNo + "_WebSite").value = document.getElementById("dp_WebSite").value;
		document.getElementById("dpl_" + LocNo + "_Fax").value = document.getElementById("dp_Fax").value;
		document.getElementById("locReservations_" + LocNo).className = "editShown";
	}
}

function disc_ToggleEditLocStreetAddress(LocNo)
{
	if (document.getElementById("xdpl_" + LocNo + "_MainStreetAddress").checked == true)
	{
		document.getElementById("locStreetAddress_" + LocNo).className = "editHidden";
	}
	else
	{
		document.getElementById("dpl_" + LocNo + "_StreetAddress1").value = document.getElementById("dp_StreetAddress1").value;
		document.getElementById("dpl_" + LocNo + "_StreetAddress2").value = document.getElementById("dp_StreetAddress2").value;
		document.getElementById("dpl_" + LocNo + "_StreetAddress3").value = document.getElementById("dp_StreetAddress3").value;
		document.getElementById("locStreetAddress_" + LocNo).className = "editShown";
	}
}

function disc_ToggleEditLocDelete(LocNo)
{
	if (document.getElementById("xdpl_" + LocNo + "_LocationDelete").checked == true)
	{
		document.getElementById("locSection_" + LocNo).className = "editHidden";
	}
	else
	{
		document.getElementById("locSection_" + LocNo).className = "editShown";
	}
}

function disc_CreateLocation()
{
	var i_LocNo = 0;
	var i_Found = 0;
	var i_LocID = 0;
	var i_LocName = "";
	var i_Index;

	i_Index = document.getElementById("dpl_NewLocationID").selectedIndex;
	if (i_Index < 1)
	{
		alert("Please select the Location to create.");
		return;
	}
	i_LocID = document.getElementById("dpl_NewLocationID").options[i_Index].value;
	i_LocName = bbh_StrTrim(document.getElementById("dpl_NewLocationID").options[i_Index].text);

	if (i_LocID == 0)
	{
		alert("To add a Location please select the Region first and then Location, then click button.");
		return;
	}

	while (i_Found == 0)
	{
		i_LocNo = i_LocNo + 1;
		if (document.getElementById("dpl_" + i_LocNo + "_DiscLocationID") == null) { i_Found = 1; }
	}
	var i_Ip1 = document.createElement("input");
	i_Ip1.setAttribute("type", "hidden");
	i_Ip1.setAttribute("id", "dpl_" + i_LocNo + "_DiscLocationID");
	i_Ip1.setAttribute("name", "dpl_" + i_LocNo + "_DiscLocationID");
	i_Ip1.setAttribute("value", "0");

	var i_Ip2 = document.createElement("input");
	i_Ip2.setAttribute("type", "hidden");
	i_Ip2.setAttribute("id", "dpl_" + i_LocNo + "_LocationID");
	i_Ip2.setAttribute("name", "dpl_" + i_LocNo + "_LocationID");
	i_Ip2.setAttribute("value", i_LocID);

	
	var i_Tab1 = document.createElement("table");
	i_Tab1.setAttribute("class", "bbh_InputAligner100");
	i_Tab1.setAttribute("className", "bbh_InputAligner100");
	var i_Tr1 = document.createElement("tr");
	var i_Th1 = document.createElement("th");
	i_Th1.setAttribute("colspan", "2");
	i_Th1.setAttribute("style", "text-align:left;");
	i_Th1.appendChild(document.createTextNode("Location " + i_LocName + " (New Location) "));
	var i_Ip3 = document.createElement("input");
	i_Ip3.setAttribute("type", "checkbox");
	i_Ip3.setAttribute("id", "xdpl_" + i_LocNo + "_LocationDelete");
	i_Ip3.setAttribute("name", "xdpl_" + i_LocNo + "_LocationDelete");
	i_Ip3.setAttribute("value", "1");
	i_Th1.appendChild(i_Ip3);
	i_Th1.appendChild(document.createTextNode(" Delete Location"));
	i_Tr1.appendChild(i_Th1);
	i_Tab1.appendChild(i_Tr1);
	

	var i_Div1 = document.createElement("div");
	i_Div1.setAttribute("class", "editShown");
	i_Div1.setAttribute("className", "editShown");
	i_Div1.setAttribute("id", "locSection_" + i_LocNo);
		
	var i_Tab2 = document.createElement("table");
	i_Tab2.setAttribute("class", "bbh_InputAligner100");
	i_Tab2.setAttribute("className", "bbh_InputAligner100");
	i_Tr1 = document.createElement("tr");
	i_Th1 = document.createElement("th");
	var i_Td1 = document.createElement("td");
	i_Ip3 = document.createElement("input");
	i_Ip3.setAttribute("type", "checkbox");
	i_Ip3.setAttribute("id", "xdpl_" + i_LocNo + "_MainReservation");
	i_Ip3.setAttribute("name", "xdpl_" + i_LocNo + "_MainReservation");
	i_Ip3.setAttribute("value", "1");
	i_Ip3.setAttribute("defaultChecked", "checked");
	i_Ip3.setAttribute("checked", "checked");
	i_Td1.appendChild(i_Ip3);
	i_Td1.appendChild(document.createTextNode(" Use Primary Reservation Details"));
	i_Tr1.appendChild(i_Th1);
	i_Tr1.appendChild(i_Td1);
	i_Tab2.appendChild(i_Tr1);
	i_Div1.appendChild(i_Tab2);

	var i_Div2 = document.createElement("div");
	i_Div2.setAttribute("id", "locReservations_" + i_LocNo);
	i_Div2.setAttribute("class", "editHidden");
	i_Div2.setAttribute("className", "editHidden");
	i_Tab2 = document.createElement("table");
	i_Tab2.setAttribute("class", "bbh_InputAligner100");
	i_Tab2.setAttribute("className", "bbh_InputAligner100");
	i_Tr1 = document.createElement("tr");
	i_Th1 = document.createElement("th");
	i_Td1 = document.createElement("td");
	i_Th1.appendChild(document.createTextNode("Phone Number:"));
	i_Ip3 = document.createElement("input");
	i_Ip3.setAttribute("type", "text");
	i_Ip3.setAttribute("id", "dpl_" + i_LocNo + "_ReservationsPhone");
	i_Ip3.setAttribute("name", "dpl_" + i_LocNo + "_ReservationsPhone");
	i_Ip3.setAttribute("value", "");
	i_Ip3.setAttribute("maxlength", "50");
	i_Ip3.setAttribute("size", "50");
	i_Td1.appendChild(i_Ip3);
	i_Tr1.appendChild(i_Th1);
	i_Tr1.appendChild(i_Td1);
	i_Tab2.appendChild(i_Tr1);

	i_Tr1 = document.createElement("tr");
	i_Th1 = document.createElement("th");
	i_Td1 = document.createElement("td");
	i_Th1.appendChild(document.createTextNode("Email:"));
	i_Ip3 = document.createElement("input");
	i_Ip3.setAttribute("type", "text");
	i_Ip3.setAttribute("id", "dpl_" + i_LocNo + "_ReservationsEmail");
	i_Ip3.setAttribute("name", "dpl_" + i_LocNo + "_ReservationsEmail");
	i_Ip3.setAttribute("value", "");
	i_Ip3.setAttribute("maxlength", "100");
	i_Ip3.setAttribute("size", "50");
	i_Td1.appendChild(i_Ip3);
	i_Tr1.appendChild(i_Th1);
	i_Tr1.appendChild(i_Td1);
	i_Tab2.appendChild(i_Tr1);

	i_Tr1 = document.createElement("tr");
	i_Th1 = document.createElement("th");
	i_Td1 = document.createElement("td");
	i_Th1.appendChild(document.createTextNode("Web Site:"));
	i_Ip3 = document.createElement("input");
	i_Ip3.setAttribute("type", "text");
	i_Ip3.setAttribute("id", "dpl_" + i_LocNo + "_WebSite");
	i_Ip3.setAttribute("name", "dpl_" + i_LocNo + "_WebSite");
	i_Ip3.setAttribute("value", "");
	i_Ip3.setAttribute("maxlength", "100");
	i_Ip3.setAttribute("size", "50");
	i_Td1.appendChild(i_Ip3);
	i_Tr1.appendChild(i_Th1);
	i_Tr1.appendChild(i_Td1);
	i_Tab2.appendChild(i_Tr1);

	i_Tr1 = document.createElement("tr");
	i_Th1 = document.createElement("th");
	i_Td1 = document.createElement("td");
	i_Th1.appendChild(document.createTextNode("Fax Number:"));
	i_Ip3 = document.createElement("input");
	i_Ip3.setAttribute("type", "text");
	i_Ip3.setAttribute("id", "dpl_" + i_LocNo + "_Fax");
	i_Ip3.setAttribute("name", "dpl_" + i_LocNo + "_Fax");
	i_Ip3.setAttribute("value", "");
	i_Ip3.setAttribute("maxlength", "50");
	i_Ip3.setAttribute("size", "50");
	i_Td1.appendChild(i_Ip3);
	i_Tr1.appendChild(i_Th1);
	i_Tr1.appendChild(i_Td1);
	i_Tab2.appendChild(i_Tr1);

	i_Div2.appendChild(i_Tab2);
	i_Div1.appendChild(i_Div2);

	
	i_Tab2 = document.createElement("table");
	i_Tab2.setAttribute("class", "bbh_InputAligner100");
	i_Tab2.setAttribute("className", "bbh_InputAligner100");
	i_Tr1 = document.createElement("tr");
	i_Th1 = document.createElement("th");
	i_Td1 = document.createElement("td");
	i_Ip3 = document.createElement("input");
	i_Ip3.setAttribute("type", "checkbox");
	i_Ip3.setAttribute("id", "xdpl_" + i_LocNo + "_MainStreetAddress");
	i_Ip3.setAttribute("name", "xdpl_" + i_LocNo + "_MainStreetAddress");
	i_Ip3.setAttribute("value", "1");
	i_Ip3.setAttribute("defaultChecked", "checked");
	i_Ip3.setAttribute("checked", "checked");
	i_Td1.appendChild(i_Ip3);
	i_Td1.appendChild(document.createTextNode(" Use Primary Street Address"));
	i_Tr1.appendChild(i_Th1);
	i_Tr1.appendChild(i_Td1);
	i_Tab2.appendChild(i_Tr1);
	i_Div1.appendChild(i_Tab2);

	i_Div2 = document.createElement("div");
	i_Div2.setAttribute("id", "locStreetAddress_" + i_LocNo);
	i_Div2.setAttribute("class", "editHidden");
	i_Div2.setAttribute("className", "editHidden");
	i_Tab2 = document.createElement("table");
	i_Tab2.setAttribute("class", "bbh_InputAligner100");
	i_Tab2.setAttribute("className", "bbh_InputAligner100");
	i_Tr1 = document.createElement("tr");
	i_Th1 = document.createElement("th");
	i_Td1 = document.createElement("td");
	i_Th1.appendChild(document.createTextNode("Street Address:"));
	i_Ip3 = document.createElement("input");
	i_Ip3.setAttribute("type", "text");
	i_Ip3.setAttribute("id", "dpl_" + i_LocNo + "_StreetAddress1");
	i_Ip3.setAttribute("name", "dpl_" + i_LocNo + "_StreetAddress1");
	i_Ip3.setAttribute("value", "");
	i_Ip3.setAttribute("maxlength", "50");
	i_Ip3.setAttribute("size", "50");
	i_Td1.appendChild(i_Ip3);
	i_Ip3 = document.createElement("br");
	i_Td1.appendChild(i_Ip3);
	i_Ip3 = document.createElement("input");
	i_Ip3.setAttribute("type", "text");
	i_Ip3.setAttribute("id", "dpl_" + i_LocNo + "_StreetAddress2");
	i_Ip3.setAttribute("name", "dpl_" + i_LocNo + "_StreetAddress2");
	i_Ip3.setAttribute("value", "");
	i_Ip3.setAttribute("maxlength", "50");
	i_Ip3.setAttribute("size", "50");
	i_Td1.appendChild(i_Ip3);
	i_Ip3 = document.createElement("br");
	i_Td1.appendChild(i_Ip3);
	i_Ip3 = document.createElement("input");
	i_Ip3.setAttribute("type", "text");
	i_Ip3.setAttribute("id", "dpl_" + i_LocNo + "_StreetAddress3");
	i_Ip3.setAttribute("name", "dpl_" + i_LocNo + "_StreetAddress3");
	i_Ip3.setAttribute("value", "");
	i_Ip3.setAttribute("maxlength", "50");
	i_Ip3.setAttribute("size", "50");
	i_Td1.appendChild(i_Ip3);		
	i_Tr1.appendChild(i_Th1);
	i_Tr1.appendChild(i_Td1);
	i_Tab2.appendChild(i_Tr1);

	i_Div2.appendChild(i_Tab2);
	i_Div1.appendChild(i_Div2);

	var i_Insert = document.getElementById("locationNewArea");
	i_Insert.parentNode.insertBefore(i_Ip1, i_Insert);
	i_Insert.parentNode.insertBefore(i_Ip2, i_Insert);
	i_Insert.parentNode.insertBefore(i_Tab1, i_Insert);
	i_Insert.parentNode.insertBefore(i_Div1, i_Insert);

	document.getElementById("xdpl_" + i_LocNo + "_LocationDelete").onclick = function(evt){disc_ToggleEditLocDelete(i_LocNo)}
	document.getElementById("xdpl_" + i_LocNo + "_MainReservation").onclick = function(evt){disc_ToggleEditLocReservations(i_LocNo)}
	document.getElementById("xdpl_" + i_LocNo + "_MainStreetAddress").onclick = function(evt){disc_ToggleEditLocStreetAddress(i_LocNo)}
}

function disc_ShowSize(p_TextArea, p_Area, p_MaxSize)
{
	var i_TextArea = document.getElementById(p_TextArea);
	var i_Area = document.getElementById(p_Area);
	if (i_TextArea != null && i_Area != null)
	{
		i_Area.innerHTML = i_TextArea.value.length + " of " + p_MaxSize + " Chars";
	}
} 


function mail_SetListDetailsShown()
{
	var i_Index;
	var i_BaseID;
	var i_OrigOrder;
	var i_SelOrder;
	var i_ListBaseID = document.getElementById("mll_BaseID");
	var i_ListOrder = document.getElementById("mll_Order");
	var i_OrigOrder = document.getElementById("origOrder");

	i_Index = i_ListBaseID.selectedIndex;
	if (i_Index < 1)
	{
		i_BaseID = 0;
	}
	else
	{
		i_BaseID = i_ListBaseID.options[i_Index].value;
	}
		
	i_Index = i_ListOrder.selectedIndex;
	if (i_Index < 0)
	{
		i_SelOrder = i_OrigOrder.value;
	}
	else
	{
		i_SelOrder = i_ListOrder.options[i_Index].value;
		i_OrigOrder.value = i_SelOrder;
	}

	while (i_ListOrder.length > 0)
	{
		i_ListOrder.remove(i_ListOrder.length - 1);
	}

	switch (i_BaseID)
	{
		case "1":
			mail_SetListDetailsOrder(i_ListOrder, "Company", "Company");
			mail_SetListDetailsOrder(i_ListOrder, "Company-", "Company Decending");
			mail_SetListDetailsOrder(i_ListOrder, "ID", "ID");
			mail_SetListDetailsOrder(i_ListOrder, "ID-", "ID Decending");
			mail_SetListDetailsOrder(i_ListOrder, "Status", "Status");
			mail_SetListDetailsOrder(i_ListOrder, "Status-", "Status Decending");
			mail_SetListDetailsOrder(i_ListOrder, "National", "National");
			mail_SetListDetailsOrder(i_ListOrder, "National-", "National Decending");
			mail_SetListDetailsOrder(i_ListOrder, "Location", "Location");
			mail_SetListDetailsOrder(i_ListOrder, "Location-", "Location Decending");
			document.getElementById("lineCriteriaPrimaryOnly").className = "editShown";
			document.getElementById("lineCriteriaText").className = "editShown";
			document.getElementById("lineCriteriaModerate").className = "editShown";
			document.getElementById("lineCriteriaNeedConfirm").className = "editShown";
			document.getElementById("lineCriteriaStatus").className = "editShown";
			document.getElementById("lineCriteriaText").className = "editShown";
			document.getElementById("lineCriteriaPublication").className = "editShown";
			break;

		default:
			document.getElementById("lineCriteriaPrimaryOnly").className = "editHidden";
			document.getElementById("lineCriteriaText").className = "editHidden";
			document.getElementById("lineCriteriaModerate").className = "editHidden";
			document.getElementById("lineCriteriaNeedConfirm").className = "editHidden";
			document.getElementById("lineCriteriaStatus").className = "editHidden";
			document.getElementById("lineCriteriaText").className = "editHidden";
			document.getElementById("lineCriteriaPublication").className = "editHidden";
			break;
	}
	for (i_Sub = 0; i_Sub < i_ListOrder.length; i_Sub++)
	{
		if (i_ListOrder.options[i_Sub].value == i_SelOrder)
		{
			i_ListOrder.selectedIndex = i_Sub;
		}
	}
}

function mail_SetListDetailsOrder(p_ListOrder, p_Value, p_Text)
{
	var i_OptNew = document.createElement('option');

	i_OptNew.text = p_Text;
	i_OptNew.value = p_Value;
	try
	{
		p_ListOrder.add(i_OptNew, null); // standards compliant; doesn't work in IE
	}
	catch(ex)
	{
		i_ListOrder.add(i_OptNew); // IE only
	}
}

function mailBodyCatSelectOrig()
{
    var i_Select = document.getElementById("selSection");
		var i_Index = i_Select.selectedIndex;
		
		switch(i_Select.options[i_Index].value)
		{
		    case "1":
				    document.getElementById("mailBodyCatLocation").className = "mailDocDictHidden";
				    document.getElementById("mailBodyCatRecipient").className = "mailDocDictHidden";
				    document.getElementById("mailBodyCatProvider").className = "mailDocDictShown";
						break;
		    case "2":
				    document.getElementById("mailBodyCatRecipient").className = "mailDocDictHidden";
				    document.getElementById("mailBodyCatProvider").className = "mailDocDictHidden";
				    document.getElementById("mailBodyCatLocation").className = "mailDocDictShown";
						break;
		    case "3":
				    document.getElementById("mailBodyCatLocation").className = "mailDocDictHidden";
				    document.getElementById("mailBodyCatProvider").className = "mailDocDictHidden";
				    document.getElementById("mailBodyCatRecipient").className = "mailDocDictShown";
						break;
		}
}

function mailBodyCatSelect()
{
    var i_Select = document.getElementById("selSection");
    var i_Container = document.getElementById("mailBodyCat");
		var i_Index = i_Select.selectedIndex;
		var i_Sub;
		
		for (i_Sub = 0; i_Sub < i_Container.childNodes.length; i_Sub++)
		{
		  if (i_Container.childNodes[i_Sub].className == "mailDocDictShown")
			{
			  i_Container.childNodes[i_Sub].className = "mailDocDictHidden";
			}
		}
    document.getElementById("mailBodyCatSection" + i_Select.options[i_Index].value).className = "mailDocDictShown";
}

function mailListSelect()
{
    var i_Select = document.getElementById("icMlg_ListID");
		var i_Index = i_Select.selectedIndex;
		
		if (i_Select.options[i_Index].value == "0")
		{
		  document.getElementById("mailSelectInput").className = "mailSelectShown";
		}
		else
		{
	    document.getElementById("mailSelectInput").className = "mailSelectHidden";
		}
}

function helpPopup(page,width,height)
{
//alert(page);
//alert(scroll);
    if (width < 770) { width = 770; }
	  var a;
  	a = width;
  	var b;
  	b = height;	
  	var RightPosition = (screen.width) - a;
	  var TopPosition = 0;
		window.open(page, "", "width="+width+",height="+height+",toolbar=no,header=no,location=no,resizable=1,"+"left="+RightPosition +",top="+TopPosition+",scrollbars=1");		
}

function openWin()
{
  	window.open("warning_help.html", "Help", "width=250,height=250,scrollbars=no,resizable=no,status=no,toolbar=no,menubar=no");
}

function bbh_PopUpShow(p_Name)
{
  var i_PopUp = document.getElementById(p_Name)

	var i_WinWidth = 0;
	var i_WinHeight = 0;
	var i_ScrollLeft = 0;
	var i_ScrollTop = 0;
	var i_PopUpWidth = i_PopUp.offsetWidth;
	var i_PopUpHeight = i_PopUp.offsetHeight;
	var i_Left = 0;
	var i_Right = 0;
	var i_Found = false;
	var i_FoundScroll = false;
	
  if( typeof( window.innerHeight ) == 'number' ) {
	  if (window.innerHeight != 0) {
      i_WinWidth = window.innerWidth;
      i_WinHeight = window.innerHeight;
			i_Found = true; }}
			
	if (i_Found == false) {
    if( typeof( document.documentElement.clientHeight ) == 'number' ) {
	    if (document.documentElement.clientHeight != 0) {
        i_WinWidth = document.documentElement.clientWidth;
        i_WinHeight = document.documentElement.clientHeight;
			  i_Found = true; }}}

	if (i_Found == false) {
    if( typeof( document.body.clientHeight ) == 'number' ) {
	    if (document.body.clientHeight != 0) {
        i_WinWidth = document.body.clientWidth;
        i_WinHeight = document.body.clientHeight;
			  i_Found = true; }}}

  if( typeof( document.documentElement.scrollTop ) == 'number' ) {
	  if (document.documentElement.scrollTop != 0 || document.documentElement.scrollLeft != 0) {
  	  i_ScrollLeft = document.documentElement.scrollLeft;
	    i_ScrollTop = document.documentElement.scrollTop;
			i_FoundScroll = true; }}
	
	if (i_FoundScroll == false) {
    if( typeof( document.body.scrollTop ) == 'number' ) {
	    i_ScrollLeft = document.body.scrollLeft;
	    i_ScrollTop = document.body.scrollTop; }}
	
  if (i_WinWidth > i_PopUpWidth) { i_Left = (i_WinWidth - i_PopUpWidth) / 2; }
  if (i_WinHeight > i_PopUpHeight) { i_Top = (i_WinHeight - i_PopUpHeight) / 2; }
	
	i_Left = i_Left + i_ScrollLeft;
	i_Top = i_Top + i_ScrollTop;

  i_PopUp.style.top = i_Top + "px";
  i_PopUp.style.left = i_Left + "px";
  i_PopUp.style.visibility = 'visible';
}

function bbh_PopUpHide(p_Name)
{
  var x = document.getElementById(p_Name)
  x.style.visibility = 'hidden';
}


function job_PriorityPopUp(p_ListID)
{
  var i_Found = false;
  var i_List = document.getElementById('jobPrioritySelect');
  i_List.selectedIndex = -1;
  for (i=0; i < i_List.length; i++)
  {
    if (i_List.options[i].value == p_ListID)
  	{
	    i_List.selectedIndex = i;
  		document.getElementById('jobPriorityDesc').innerHTML = i_List.options[i].text;
  		i_Found = true;
  	}
  }
  if (i_Found == true)
  {
    document.getElementById('jobPrioirtyFrom').value = p_ListID;
    bbh_PopUpShow('dPopPriority');
  }
  else
  {
    alert('Job ' + p_ListID + ' not found');
  }
}

function bookenq_ShowPayDetails(p_TypeID, p_Style)
{
  var i_Style = "";
  if (p_Style == 'none')
	{
  	document.getElementById('payMagShow' + p_TypeID).style.display = 'inline';
		i_Style = "none";
	}
	else
	{
  	document.getElementById('payMagShow' + p_TypeID).style.display = 'none';
	}
	document.getElementById('payMagHide' + p_TypeID).style.display = i_Style;
  document.getElementById('payRef' + p_TypeID).style.display = i_Style;
  document.getElementById('payAuthCode' + p_TypeID).style.display = i_Style;
  document.getElementById('payTransDate' + p_TypeID).style.display = i_Style;
  document.getElementById('payBackpacker' + p_TypeID).style.display = i_Style;
  document.getElementById('payHostel' + p_TypeID).style.display = i_Style;
  document.getElementById('payBookingRef' + p_TypeID).style.display = i_Style;
  document.getElementById('payDpsRef' + p_TypeID).style.display = i_Style;
  document.getElementById('payUser' + p_TypeID).style.display = i_Style;
  document.getElementById('payBatch' + p_TypeID).style.display = i_Style;
}


function bbh_ClearSelect(p_Select)
{
  while (p_Select.length > 0)
  {
    p_Select.remove(p_Select.length - 1);
  }
}


function bbh_AddOption(p_Select, p_Value, p_Text)
{
  var i_Opt = document.createElement('option');
  i_Opt.text = p_Text;
  i_Opt.value = p_Value;

  try
  {
    p_Select.add(i_Opt, null); // standards compliant; doesn't work in IE
  }
  catch(ex)
  {
    p_Select.add(i_Opt); // IE only
  }
}


function bbh_InvShowPaymentDetails(magnifier)
{
  var payment_id = magnifier.id.substr(8);
  var displayValue;
  var rowClassName = 'payment_detail_' + payment_id;

  if (magnifier.src.indexOf('magnifier_off.png') > -1)
  {
    displayValue = 'none';
    magnifier.src = magnifier.src.replace('magnifier_off.png','magnifier.png');
  }
  else
  {    
    displayValue = '';
    magnifier.src = magnifier.src.replace('magnifier.png','magnifier_off.png');
  }
  var rows = bbh_GetElementsByClass(rowClassName);

  for (var i=0; i<rows.length; i++)
  {
    rows[i].style.display=displayValue;
  }
}


function bbh_GetElementsByClass(classToFind)
{
  var returnArray = [];        
  var allElements = document.getElementsByTagName("body")[0].getElementsByTagName("*");

  for (var i = 0; i < allElements.length; i++)
  {
    if (allElements[i].className == classToFind)
    {
      returnArray.push(allElements[i]);
    }
  }
  return returnArray;
}


function bbh_ChkToggleBut(p_Check, p_Button)
{
  if (p_Check.checked)
  {
    document.getElementById(p_Button).disabled = false;
  }
  else
  {
    document.getElementById(p_Button).disabled = true;
  }
}


function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function getDocWidth() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
        Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
        Math.max(D.body.clientWidth, D.documentElement.clientWidth)
    );
}

function Dimmer_BuildDiv()
{
  var i_Width = (document.body && document.body.offsetWidth) || (document.documentElement && document.documentElement.clientWidth) || window.innerWidth || self.innerWidth || document.body.clientWidth;
  var i_Height = (document.body && document.body.offsetHeight) || (document.documentElement && document.documentElement.clientHeight) || window.innerHeight || self.innerHeight || document.body.clientHeight;

  document.write('<div id="dimmer" class="dimmer" style="width:'+ i_Width + 'px; height:' + i_Height +'px"></div>');
}


function Dimmer_DisplayDiv(divId) 
{
	DivID = divId;
var i_Top;
var i_Left;
var i_Width = document.getElementById(divId).clientWidth;
var i_Height = document.getElementById(divId).clientHeight;
var i_CurTop;
var i_CurBottom;
var i_CurLeft;
var i_CurRight;
var i_WinTop;
var i_WinLeft;
var i_WinWidth;
var i_WinHeight;
//var i_DocWidth = (document.documentElement && document.documentElement.clientWidth) || window.innerWidth || self.innerWidth || document.body.clientWidth;
//var i_DocHeight = (document.documentElement && document.documentElement.clientHeight) || window.innerHeight || self.innerHeight || document.body.clientHeight;
var i_DocWidth = getDocWidth();
var i_DocHeight = getDocHeight();

//    if (typeof(document.body.offsetHeight) == 'number') {
//		  i_DocWidth = document.body.offsetWidth;
//		  i_DocHeight = document.body.offsetHeight; }
//		else {
//		  if (typeof(document.body.document.height) == 'number') {
//  		  i_DocWidth = document.body.document.width;
//	  	  i_DocHeight = document.body.document.height; }

  if (typeof( window.innerWidth ) == 'number' ) {  //Non-IE
		i_WinWidth = window.innerWidth;
		i_WinHeight = window.innerHeight; }
	else {
    if (document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)) {  //IE 6+ in 'standards compliant mode'
 			i_WinWidth = document.documentElement.clientWidth;
			i_WinHeight = document.documentElement.clientHeight; }
		else {
 			i_WinWidth = document.body.clientWidth;
  		i_WinHeight = document.body.clientHeight; }}

	if (i_DocWidth > i_WinWidth) {
  	document.getElementById('dimmer').style.width = i_DocWidth + "px"; }
	else {
  	document.getElementById('dimmer').style.width = i_WinWidth + "px"; }
	if (i_DocHeight > i_WinHeight) {
  	document.getElementById('dimmer').style.height = i_DocHeight + "px"; }
	else {
  	document.getElementById('dimmer').style.height = i_WinHeight + "px"; }
	document.getElementById('dimmer').style.visibility = "visible";

	if (document.documentElement.scrollTop) {
		i_WinTop = document.documentElement.scrollTop;
		i_WinLeft = document.documentElement.scrollLeft; }
	else {
		i_WinTop = document.body.scrollTop;
		i_WinLeft = document.body.scrollLeft; }
		

	if (i_Height > i_WinHeight) {
	  i_Top = i_WinTop; }
	else {
	  i_Top = i_WinTop + (i_WinHeight / 2) - (i_Height / 2); }
		
  i_Left = i_WinLeft + (i_WinWidth / 2) - (i_Width / 2);
	if (i_Width > i_WinWidth) {
		if (i_Left + i_Width > i_DocWidth) {
		  i_Left = i_DocWidth - i_Width; }
		if (i_Left < 0) {
		  i_Left = 0; }}

//		alert("t=" + i_WinTop + ",l=" + i_WinLeft + ",w=" + i_WinWidth + ", h=" + i_WinHeight + "  t=" + i_Top + ",l=" + i_Left + ",w=" + i_Width + ", h=" + i_Height);

  document.getElementById(divId).style.left = i_Left + 'px';
  document.getElementById(divId).style.top = i_Top + 'px';
	document.getElementById(divId).style.visibility = "visible";
}


function Dimmer_HideDiv(divId) 
{
	document.getElementById(divId).style.visibility='hidden';
	document.getElementById('dimmer').style.visibility = 'hidden';
	DivID = "";
}


function CompS10_AcceptTerms() {
  var i_Html;
	var i_Qte = "'";
	
	i_Html = 'You have accepted the Terms &amp; Conditions. <input type="button" value="View" onclick="Dimmer_DisplayDiv(' + i_Qte + 'windowcontent' + i_Qte + ');"/>';
	document.getElementById('compTerms').innerHTML = i_Html;
	document.getElementById('usr_CompS10Terms').value = "True";
  Dimmer_HideDiv('windowcontent');
}

function CompS10_DeclineTerms() {
  var i_Html;
	var i_Qte = "'";
	
	i_Html = 'You have <b>not</b> accepted the Terms &amp; Conditions.  <input type="button" value="View/Accept" onclick="Dimmer_DisplayDiv(' + i_Qte + 'windowcontent' + i_Qte + ');"/>';
	document.getElementById('compTerms').innerHTML = i_Html;
	document.getElementById('usr_CompS10Terms').value = "";
  Dimmer_HideDiv('windowcontent');
}

		
		
function bkg_ValidateSelection(p_SubmitUrl)
{
		var i_BdAvePriceDifference = document.getElementById("bd_AvePriceDifference").value;
		var i_BdMaxNumberOfPeople = document.getElementById("bd_MaxNumberOfPeople").value;
		var i_UsrCardNumber = document.getElementById("usr_CardNumber").value;
    var i_Be1stSelection = document.getElementById("be_1stSelection").value;
    var i_BeNights = document.getElementById("be_Nights").value;
    var i_BeNumberOfPeopleM = document.getElementById("be_NumberOfPeopleM").value;
    var i_BeNumberOfPeopleF = document.getElementById("be_NumberOfPeopleF").value;
    var i_BeThisChoice = document.getElementById("be_ThisChoice").value;
    var i_HostelID = document.getElementById("HostelID").value;
    var i_Ctrl;
    var i_DateIn;
    var i_DateOut;
		var i_NoNights = 0;
		var i_NoMales = 0;
		var i_NoFemales = 0;
		var i_NoPeople = 0;
		var i_NoPeopleCosted = 0;
		var i_TotMales = 0;
		var i_TotFemales = 0;
		var i_TotPeople = 0;
		var i_RoomNo = 0;
		var i_RoomRateWarning = "";
    var i_Description = "";
    var i_Ensuite = "";
    var i_TariffRange = "";
		var i_RoomPrice = 0;
		var i_HostelTotal = 0;
		var i_BookingFee = 0;
		var i_TotalAmount = 0;
		var i_NoActive = 0;
		var i_Html = "";
		var i_DefaultHtml = "";
		var i_SubHtml = "";
		
    i_DefaultHtml = "<table summary='' class='bbh_PageAligner' width='100%'><tr class='details'><th>" + i_BeThisChoice;
		i_DefaultHtml = i_DefaultHtml + "</th></tr><tr class='details'><td style='text-align:right;'>Please select the number of males and females in each room or go to request summary.</td></tr></table>";

		if (i_Be1stSelection == "True") {
        i_Ctrl = document.getElementById("be_DateIn");
        if (i_Ctrl.value == '') {
            alert("Please select your arrival date");
    				document.getElementById("NewSelectionSummary").innerHTML = i_DefaultHtml;
						return false; }
    		try {
        		i_DateIn = Date.parse(i_Ctrl.value); }
        catch(e) {
        		alert("Invalid arrival date");
						document.getElementById("NewSelectionSummary").innerHTML = i_DefaultHtml;
        		return false; }
        i_Ctrl = document.getElementById("be_DateOut");
        if (i_Ctrl.value == '') {
        	  alert("Please select your departure date");
					  document.getElementById("NewSelectionSummary").innerHTML = i_DefaultHtml;
        	  return false; }
        try {
        		i_DateOut = Date.parse(i_Ctrl.value); }
        catch(e) {
            alert("Invalid departure date");
				    document.getElementById("NewSelectionSummary").innerHTML = i_DefaultHtml;
            return false; }
        i_NoNights = Math.ceil((i_DateOut - i_DateIn) / (60 * 60 * 24 * 1000));
    		if (i_NoNights < 1) {
            alert("Please select valid arrival and departure dates");
				    document.getElementById("NewSelectionSummary").innerHTML = i_DefaultHtml;
            return false; } }
		else {
		    i_NoNights = i_BeNights; }

		i_RoomNo = 1;
		
		while (i_RoomNo != -1) {
				if (document.getElementById("hor_RoomID_" + i_RoomNo) == null) {
				    i_RoomNo = -1; }
				else {
    				if (document.getElementById("hor_RoomID_" + i_RoomNo).value == "-1") {
    				    i_RoomNo = i_RoomNo + 1; }
						else {
						    i_RoomRateWarning = "";
                i_Description = document.getElementById("hort_Description_" + i_RoomNo).value;
                i_Ensuite = document.getElementById("hor_Ensuite_" + i_RoomNo).value;
                i_TariffRange = document.getElementById("hor_TariffRange_" + i_RoomNo).value;
                i_NoMales = parseInt("0" + document.getElementById("besr_Males_" + i_RoomNo).value);
                i_NoFemales = parseInt("0" + document.getElementById("besr_Females_" + i_RoomNo).value);
								i_NoPeople = i_NoMales + i_NoFemales;
								i_NoPeopleCosted = i_NoPeople;
								i_TotMales = i_TotMales + i_NoMales;
								i_TotFemales = i_TotFemales + i_NoFemales;
								i_TotPeople = i_TotPeople + i_NoPeople;

                if (i_Description == "Double" || i_Description == "Twin") {
                  if (i_NoPeople % 2 != 0) {
                    i_NoPeopleCosted = i_NoPeople + 1;
                    i_RoomRateWarning = " (room rates apply)"; } }
        
                i_RoomPrice = i_NoPeopleCosted * i_NoNights * i_TariffRange;
								i_HostelTotal = i_HostelTotal + i_RoomPrice;
								i_TotalAmount = i_TotalAmount + i_RoomPrice;
								
								document.getElementById("besr_RoomPriceQuoted_" + i_RoomNo).value = i_RoomPrice.toFixed(2);
								
								if (i_NoPeopleCosted != 0) {
								    i_Html = i_Html + "<tr class='details'><td style='text-align:right;'>" + i_NoPeople + (i_NoPeople==1 ? " person" : " people") + " in " + i_Description + (i_Ensuite == "True" ? " with ensuite " : " ") + (i_NoPeople != i_NoPeopleCosted ? "(room rates apply) " : " ") + "will pay $" + i_RoomPrice.toFixed(2) + "</td></tr>"; }

    				    i_RoomNo = i_RoomNo + 1; } } }
										
		if (p_SubmitUrl != "" && i_Html == "") {
            alert("Please select at least 1 person");
				    document.getElementById("NewSelectionSummary").innerHTML = i_DefaultHtml;
            return false; }
				    
		if (i_Html == "") {
				document.getElementById("NewSelectionSummary").innerHTML = i_DefaultHtml;
				if (p_SubmitUrl != "") {
            alert("Please select at least 1 person");
            return false; }
				return true; }

		i_SubHtml = "<table summary='' class='bbh_PageAligner' width='100%'><tr class='details'><th>";

   	if (window.hostel_operator === undefined) {
		  i_SubHtml = i_SubHtml + "<div style='float:right;'><a class='ActionButton' href='bbh_MakeBooking.aspx?bbh=NewSelection&amp;HostelID=" + i_HostelID + "'>Delete these choices and start again</a></div>"; }
		
		i_SubHtml = i_SubHtml + i_BeThisChoice + "</th></tr>";
		i_Html = i_SubHtml + i_Html;

    if (i_UsrCardNumber == '') {
	  	  i_BookingFee = i_TotPeople * i_NoNights * i_BdAvePriceDifference;
  			i_Html = i_Html + "<tr class='details'><td style='text-align:right;'>Booking fee $" + i_BookingFee.toFixed(2) + "</td></tr>"; }

		document.getElementById("bes_BookingFeeQuoted").value = i_BookingFee.toFixed(2);
		i_TotalAmount = i_TotalAmount + i_BookingFee;
  
    i_Html = i_Html + "<tr class='details'><td style='text-align:right; font-weight:bold;'>For " ;
    if (i_TotMales > 0) {
        i_Html += i_TotMales;
        if (i_TotMales == 1) {
            i_Html += " male"; }
        else {
            i_Html += " males"; }
        if (i_TotFemales > 0) {
            i_Html += " and "; } }    
    if (i_TotFemales > 0) {
        i_Html += i_TotFemales; 
				if (i_TotFemales == 1) {
            i_Html += " female"; }
        else {
            i_Html += " females"; } }
    
    i_Html += " staying";
    if (i_NoNights == 1) {
        i_Html += " 1 night"; }
    else {
        i_Html += " " + i_NoNights + " nights"; }
				
	  i_Html = i_Html + " the total amount payable is $" + i_TotalAmount.toFixed(2) + "</td></tr></table>";
		document.getElementById("bes_TotalAmountQuoted").value = i_TotalAmount.toFixed(2);

		document.getElementById("NewSelectionSummary").innerHTML = i_Html;

		if (p_SubmitUrl != "") {
		    if (i_Be1stSelection != "True") {
    		    if (i_TotMales != i_BeNumberOfPeopleM) {
		    			  if (i_TotFemales != i_BeNumberOfPeopleF) {
                    alert("Please select " + i_BeNumberOfPeopleM + (i_BeNumberOfPeopleM==1 ? " male and " : " males and ") + i_BeNumberOfPeopleF + (i_BeNumberOfPeopleF==1 ? " female" : " females")); }
						    else {
                    alert("Please select " + i_BeNumberOfPeopleM + (i_BeNumberOfPeopleM==1 ? " male" : " males")); }
                return false; }
		    		else {
				    	  if (i_TotFemales != i_BeNumberOfPeopleF) {
                    alert("Please select " + i_BeNumberOfPeopleF + (i_BeNumberOfPeopleF==1 ? " female" : " females"));
                    return false; } } }
				else {
				    if (i_TotPeople > i_BdMaxNumberOfPeople) { 
						    alert("For bookings of more than " + i_BdMaxNumberOfPeople + " people please contact the hostel directly");
								return false; }
          	if (window.hostel_operator === undefined) {
                if (!window.confirm("Please note that after this step you will not be able to alter the total number of males and females, or change your arrival or departure date.")) { 
                    return; } }
						else {
                if (!window.confirm("You have requested to place this confirmed booking into the BBH Booking System, are you sure you wish to continue?")) { 
                    return; } } }
		    document.frm_booking.action = p_SubmitUrl; 
        document.frm_booking.submit(); }
		return true;
}


function bkg_SubmitEnquiry()
{
    var answer = confirm("This request will become a confirmed booking when it is accepted by a hostel. In accordance with the Terms and Conditions relating to this site, you will then be responsible for any fees relating to the booking. Click OK to continue. Otherwise, click Cancel.")
    if (answer)
    {
        document.frm.action=s10_BaseDir + 'ccdtl/bbh_MakeBooking.aspx?bbh=completeenquiry';
        document.frm.submit();
    }
//    else
//    {
//        document.frm.action='default.aspx?bbh=delete_booking&be_id=' + be_id;
//        document.frm.submit();
//    }
}
