
/*******************************************************************************

Crackerjack Javascript

********************************************************************************/

/* Run on load */

function fnConfig() {
	fnSelectDefault();  // set default selected image on photos page	
	crackerjack_update_global_search_onload();
}




/* Set up user agent string for browser eval */
var ua = navigator.userAgent.toLowerCase();

/******************************************************************************************
set bolean to detect IE5 Mac
******************************************************************************************/
ieMac = ((ua.indexOf("msie") != -1)&&(ua.indexOf("windows") == -1))? true:false;
	



/********************************************************************************

Name: 					Flash detect.
Description:			boolean true/false if installed and version number 
						accessed via flash.version
@var flash.installed	true is flash is installed
@var flash.version		flash player version
*********************************************************************************/

var flash = new Object();	
flash.installed = false;

if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {		
			flash.installed = true;					
			flash.version = eval(navigator.plugins[x].description.split('Shockwave Flash ')[1].split('.')[0]);					
			break;
		}
	}
}
else if (window.ActiveXObject) {
	for (x = 2; x <= 20; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {		
				flash.installed = true;	
				flash.version = x;
			}
		}
		catch(e) {}
	}
}



	
/********************************************************************************

Name: 				Flash embed
Description:		Writeout flash code. Fixes Eolas update for IE as well.
@param	swf		String path to swf file
@param	width		Number value of movie width
@param	height	Number value of movie height

*********************************************************************************/

flash.insert = function(swf,width,height,minVersion) {	
	
	if(!minVersion){minVersion = 6;}
	
	if (flash.installed) {
		if(flash.version > minVersion) {		
			flashObject = '<embed src="'+swf+'" menu="false" width="'+width+'" height="'+height+'" scale="noscale" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" salign="T" />';	
			document.getElementById("noFlashContent").style.display = "none";	
			//document.getElementById("flashContent").style.display = "block";	
			//document.getElementById("flashContent").innerHTML = flashObject;	
			document.write(flashObject);	
		}
		else {
			document.getElementById("noFlashContent").style.display = "block";
		}	
	}
}
 	
	
	
	
 	


/********************************************************************************
 
Name:     fnPhotoShowHide
Description:  Takes link url on thumbnails and shows this image within the page.  
Sets transparency of thumbnails once selected.
@param targ:     path to full size image

*********************************************************************************/

function fnPhotoShowHide(targ) {

	/* Set photo source to target of clicked link */
	document.getElementById("photoShowHide").getElementsByTagName("img")[0].src = targ.href;	
	
	/* Set up array of links */
	var anchors = document.getElementById("thumbnails").getElementsByTagName("A");

	/* Run through links and change opacity */
	if (document.all) {
		for (i=0;i<anchors.length;i++) {
			anchors[i].className = "";
			}			
		targ.className = "active";
		}
	else {
		for (i=0;i<anchors.length;i++) {
			anchors[i].className = "";
			}	
		targ.className = "active";
		}
	}	

/********************************************************************************
 
Name:     fnSelectDefault
Description:  Selects default thumbnail


*********************************************************************************/

function fnSelectDefault() {
	if(document.getElementById("thumbnails")){
		var oTarg = document.getElementById("thumbnails").getElementsByTagName("A")[0];
		
		oTarg.className = "active";						
	}	
}	



var sAllCats = false;

function crackerjack_update_global_search_onload() {
    var oType = document.getElementById("edit-type");
    
    if (oType && document.getElementById("globalResults")) {
        var iSelectedType = parseInt(oType.options[oType.selectedIndex].value);
        if (iSelectedType > 0) {
            crackerjack_update_global_search();
        }
    }
}

/**
 * This updates the category drop down when you change the type drop down on the global search page.
 */
function crackerjack_update_global_search() {
    var oType = document.getElementById("edit-type");
    var oCats = document.getElementById("edit-category");

    // Remember the html originally used in the drop down so we can put it back in if the user changes back to All Types.
    if (!sAllCats) sAllCats = oCats.parentNode.innerHTML;

    // remember the "all" option to put it back in at the top after clearing the list.
    var oAllCats = new Option(oCats.options[0].text, oCats.options[0].value);
    
    // TID of the selected term from top level section vocab.
    var iSelectedType = parseInt(oType.options[oType.selectedIndex].value);
    
    // TID of selected category (important when running onload, to keep the selected category)
    var sSelectedCat = oCats.options[oCats.selectedIndex].value;
    
    // Clear categories drop down, including opt groups.
    while (oCats.firstChild) oCats.removeChild(oCats.firstChild);
    
    // If they chose All Types, put the original html back inside the select.
    if (iSelectedType == 0) {
        oCats.parentNode.innerHTML = sAllCats;
        oCats = document.getElementById("edit-category");
        oCats.options[0].selected = true;   // loose whatever category might have been selected when the html was saved.
        return;
    }
    
    // They chose a different one. We need to put only the right categories into the drop down.
    // Put the All option in first.
    oCats.options[oCats.options.length] = oAllCats;
    var sHidden = "0";

    // Find the ID of the hidden field that contains this type's categories
    switch (iSelectedType) {
        case 1: sHidden = "edit-Cuisine"; break; // restaurants
        case 2: sHidden = "edit-Pubs--bars-genre"; break; // pubs
        case 3: sHidden = "edit-Music-genre"; break; // music
        case 4: sHidden = "edit-Film-genre"; break; // film
        case 5: sHidden = "edit-Theatre-genre"; break; // theatre
        case 6: sHidden = "edit-Days-out-type"; break; // days out
        case 7: sHidden = "edit-Community-Events-genre"; break; // community events
        case 8: sHidden = "edit-Clubbing-genre"; break; // clubbing
        case 9: sHidden = "edit-Comedy-genre"; break; // comedy
        case 10: sHidden = "edit-Art-genre"; break; // art
    }

    // Try to find the hidden input
    var oHidden = document.getElementById(sHidden);

    // Give up if we can't find the options or something
    if (sHidden.length == 0 || !oHidden) {
        oCats.parentNode.innerHTML = sAllCats;
        oCats = document.getElementById("edit-category");
        oCats.options[0].selected = true;
        return;
    }
    
    // Create the items
    var oItems = oHidden.value.split(";");
    for (var i = 0; i < oItems.length; i++) {
        var oItem = oItems[i].split("=");
        oCats.options[oCats.options.length] = new Option(oItem[1], oItem[0]);
        if (oItem[0] == sSelectedCat) {
            oCats.options[oCats.options.length - 1].selected = true;
        }
    }
}

/**
 * Venue / event form: Hides all category selection areas and shows the one for the type you chose.
 * Also show/hides the elements which are only required for a particular category.
 *
 * bEditPageLoad is set to true if you're editing a node AND this is running upon page load
 * (used in crackerjack_update_venue_for_event)
 */
function crackerjack_update_categories(oType, bEditPageLoad) {
		if (typeof(bEditPageLoad) == 'undefined') bEditPageLoad = false;

    // Get selected term ID from top level section (Type) drop down.
    var iTid = parseInt(oType.options[oType.selectedIndex].value);
    
    // Map it onto a vocab ID
    var iVid = 0;
    switch (iTid) {
	    case 1: iVid = 4;     break; // restaurants cuisine
			case 2: iVid = 7; break; // pubs and bars
			case 3: iVid = 8; break; // music genre
			case 4: iVid = 9; break; // film genre
			case 5: iVid = 10; break; // theatre genre
			case 6: iVid = 11; break; // days out genre
			case 7: iVid = 12; break; // community events genre
			case 8: iVid = 13; break; // clubbing genre
			case 9: iVid = 14; break; // comedy genre
			case 10: iVid = 15; break; // art genre
    }
    
    // Hide all categories.
    for (var i = 4; i <= 15; i++) {
 
        var oCatDiv = document.getElementById("vocab" + i);
        if (oCatDiv) {
            oCatDiv.style.display = 'none';
        }
    }
    
    // Show the category we have found.
    var oCatDiv = document.getElementById("vocab" + iVid);
    if (oCatDiv) {
         oCatDiv.style.display = '';
    }
    
    // If we get in here then we know it's a venue
    if (document.getElementById("wrapperSigDish")) {
    
        // If restaurants OR pubs and bars, menus and sig dish
        document.getElementById("wrapperSigDish").style.display = (iTid == 1 || iTid == 2 ? '' : 'none');
        document.getElementById("wrapperMenus").style.display   = (iTid == 1 || iTid == 2 ? '' : 'none');
        
        // show price range (and hint) for only restaurants and days out venues.
        document.getElementById("priceRangeDiv").style.display = (iTid == 1 || iTid == 6 ? '' : 'none');
        document.getElementById("priceRangeDiv2").style.display = (iTid == 1 || iTid == 6 ? '' : 'none');
        
        // show accepts bookings for restaurants only. Untick it so its not counted in the total price.
        document.getElementById("acceptsBookingsDiv").style.display = (iTid == 1 ? '' : 'none');
        if (iTid != 1) {
        	document.getElementById("edit-field-accepts-bookings-keys").checked = false;
        }
        
        crackerjack_update_venue_price();
    }
    else 
    {
        // It's an event!
        // Show promote event tick box for community events only.
        document.getElementById("promoteEventDiv").style.display = (iTid == 7 ? '' : 'none');
        document.getElementById("promoteEventDiv2").style.display = (iTid == 7 ? '' : 'none');  // help paragraph
        if (iTid != 7) {
        	// If not community event, turn off the promote box to keep the total price correct.
        	document.getElementById("edit-field-want-to-promote-event-keys").checked = false;
        }
        
		    // Update total price. It might have changed...
		    crackerjack_update_event_price();
		    
		    // Update venues displayed in the Select Venue drop down to only show those in this section.
		    crackerjack_update_venue_for_event(iTid, bEditPageLoad);
    }
}


/**
 * Update the venue drop down for the event form based on the selected section.
 */
function crackerjack_update_venue_for_event(iTid, bEditPageLoad) {
	var oVenues = Drupal.parseJson(document.getElementById("edit-venues-hidden-array").value);
	var oDDL = document.getElementById("edit-field-venue-for-event-nids");
	
  // NID of selected venue (important when running onload, to keep the selected venue)
  var sSelectedVenue = oDDL.options[oDDL.selectedIndex].value;
  
  // This is true if the venue this WAS linked to is now deleted. Need to allow them to edit the address now.
  var bVenueDeleted = (bEditPageLoad && sSelectedVenue == "0" && (iTid == 1 || iTid == 2 || iTid == 3 || iTid == 5 || iTid == 8 || iTid == 9 || iTid == 10));
  
  // Clear Venues drop down, including opt groups.
  while (oDDL.firstChild) oDDL.removeChild(oDDL.firstChild);

  // Get the object representing the venues for the selected category, or null if there isn't one.
  var oItems = null;
	for (prop in oVenues) {
		switch (iTid) {
			case 1: if (prop == "Restaurant") oItems = oVenues[prop]; break;
			case 2: if (prop == "Pubs & bars") oItems = oVenues[prop]; break;
			case 3: if (prop == "Music") oItems = oVenues[prop]; break;
			case 5: if (prop == "Theatre") oItems = oVenues[prop]; break;
			case 8: if (prop == "Clubbing") oItems = oVenues[prop]; break;
			case 9: if (prop == "Comedy") oItems = oVenues[prop]; break;
			case 10: if (prop == "Art") oItems = oVenues[prop]; break;
		}
	}
	
	// Populate the drop down and show/hide the sections.
	if (oItems != null) {
		// User chose a section that allows you to select venues. List the applicable venues.
		for (prop in oItems) {
			oDDL.options[oDDL.options.length] = new Option(oItems[prop], prop);
			if (prop == sSelectedVenue) {
				oDDL.options[oDDL.options.length - 1].selected = true;
			}
		}
		
		// Hide the address entry form and show the drop down field.
		document.getElementById("addressEntryDiv").style.display = 'none';
		document.getElementById("venueSelectionDiv").style.display = '';
		
		// If the original venue was deleted, allow them to choose between selecting another venue, or keeping/altering the old venue's address.
		if (bVenueDeleted) {
			oDDL.options[oDDL.options.length] = new Option('--- Old Deleted Venue (below) ---', '0');
			oDDL.options[oDDL.options.length - 1].selected = true;
			document.getElementById("addressEntryDiv").style.display = '';
		}
		// Show message about deleted venue 
		document.getElementById("venueDeletedNotice").style.display = (bVenueDeleted ? '' : 'none');
	}
	else {
		// User chose a section that requires them to enter the address manually.
		// This should only be used if the drop down is hidden, for days out / community events where they enter their own address.
		oDDL.options[oDDL.options.length] = new Option("No venues found", "0");
		
		// Show the address entry form and hide the drop down field.
		document.getElementById("venueSelectionDiv").style.display = 'none';
		document.getElementById("addressEntryDiv").style.display = '';
	}
}


/**
 * Updates the Total Cost at the bottom of the Add Event form.
 */
function crackerjack_update_venue_price () {

	// Get selected term ID from top level section (Type) drop down.
	var iTid = parseInt(document.getElementById("edit-taxonomy-1").options[document.getElementById("edit-taxonomy-1").selectedIndex].value);
   
	var dTotal = 0;
	
	// textual fields. 
	if (document.getElementById("edit-field-email-address-0-value").value.length > 0) dTotal += fnGetPrice("price20");
	
	// if website is ticked then don't count fields 22-27.
	if ((document.getElementById("edit-field-www-url-0-value").value.length > 0)) 
	{
		dTotal += fnGetPrice("price21");
	}
	else
	{	
		// These fields are free since website is entered.
		if (document.getElementById("edit-field-opening-hours-0-value").value.length > 0) dTotal += fnGetPrice("price22");
	
		// tick boxes
		if (document.getElementById("edit-field-good-for-kids-keys").checked) dTotal += fnGetPrice("price23");
		if (document.getElementById("edit-field-accepts-credit-cards-keys").checked) dTotal += fnGetPrice("price24");
		if (document.getElementById("edit-field-wheelchair-access-keys").checked) dTotal += fnGetPrice("price25");
		if (document.getElementById("edit-field-accepts-bookings-keys").checked) dTotal += fnGetPrice("price26");
		
		// Menus and sig dish (restaurants / pub bar only)
		if (iTid == 1 || iTid == 2) {
			if (document.getElementById("edit-field-venue-menus-0-description")) dTotal += fnGetPrice("price32");
			if (document.getElementById("edit-field-venue-menus-1-description")) dTotal += fnGetPrice("price35");
			if (document.getElementById("edit-field-venue-signaturedish-title-0-value").value.length > 0) dTotal += fnGetPrice("price33");
		}
	}
	
	// no Price range (27) - see note on form.
	
	// Images
	if (document.getElementById("edit-field-venue-photos-0-title")) dTotal += fnGetPrice("price28");
	if (document.getElementById("edit-field-venue-photos-1-title")) dTotal += fnGetPrice("price29");
	
	// Calculate VAT and amount excluding VAT.
	var dTotalExVAT = dTotal / 1.175;
	var dTotalVAT = dTotal - dTotalExVAT;
	
	if (document.getElementById("finalCostExVAT")) {
		document.getElementById("finalCostExVAT").innerHTML = dTotalExVAT.toFixed(2);
	}
	if (document.getElementById("finalCostVAT")) {
		document.getElementById("finalCostVAT").innerHTML = dTotalVAT.toFixed(2);
	}
	if (document.getElementById("finalCost")) {
		document.getElementById("finalCost").innerHTML = dTotal.toFixed(2);
	}
}



/**
 * Updates the Total Cost at the bottom of the Add Event form.
 */
function crackerjack_update_event_price () {
	var dTotal = 0;
	
	// TODO: Only add them to the cost if they haven't already been paid for.
	if (document.getElementById("edit-upgrade-2000").checked) dTotal += fnGetPrice("price1");
	if (document.getElementById("edit-field-venue-photos-0-title")) dTotal += fnGetPrice("price2");
	if (document.getElementById("edit-field-venue-photos-1-title")) dTotal += fnGetPrice("price3");
	if (document.getElementById("edit-field-want-to-promote-event-keys").checked) dTotal += fnGetPrice("price6");

	// Calculate VAT and amount excluding VAT.
	var dTotalExVAT = dTotal / 1.175;
	var dTotalVAT = dTotal - dTotalExVAT;
	
	if (document.getElementById("finalCostExVAT")) {
		document.getElementById("finalCostExVAT").innerHTML = dTotalExVAT.toFixed(2);
	}
	if (document.getElementById("finalCostVAT")) {
		document.getElementById("finalCostVAT").innerHTML = dTotalVAT.toFixed(2);
	}
	if (document.getElementById("finalCost")) {
		document.getElementById("finalCost").innerHTML = dTotal.toFixed(2);
	}
}

/**
 * Function to run when you tick or untick the upgrade to 2000 box
 */
function crackerjack_change_upgrade_tickbox () {
	// Check with the user if they might loose any content.
	if (!document.getElementById("edit-upgrade-2000").checked) {
		if (document.getElementById("edit-body").value.length > 2000) {
			//if (!confirm("Are you sure? You will loose any text past 2000 characters!")) {
			//	document.getElementById("edit-upgrade-2000").checked = true;
			//}
		}
	}

	// Update character count.
	crackerjack_update_description_count(document.getElementById("edit-body"), false);
	
	// Update total price.
	crackerjack_update_event_price();
}


/**
 * This updates the character counter for the event description text area.
 * It will also trim the excess characters if the box is over the max length.
 */
function crackerjack_update_description_count(oTextArea, bOnLoad) {
    var iLen = oTextArea.value.length;
    var iMaxLen = 2000;
    
	  var oUpgradeBox = document.getElementById("edit-upgrade-2000");
    if (oUpgradeBox) {
	    if (bOnLoad) {
	    	// On page load, tick the tick box based on the length of the text in the area.
	    	oUpgradeBox.checked = iLen > iMaxLen;
	    }
  		if (oUpgradeBox.checked) iMaxLen = 2000;
    }
    
    var oCount = document.getElementById("charCount");
    
    if (iLen > iMaxLen) {
        oTextArea.value = oTextArea.value.substring(0, iMaxLen);
        iLen = iMaxLen;
    }
    if (oCount) {
        oCount.innerHTML = iMaxLen - iLen;
    }
}

/**
 * Sets the charity number box to disabled if the tickbox isn't ticked.
 */
function crackerjack_update_charity_event(oTickbox) {
    var oCharityNumber = document.getElementById("edit-field-charity-number-0-value");    
    if (oCharityNumber) {
				var oParent = oCharityNumber.parentNode;
        oCharityNumber.disabled = !oTickbox.checked;
        if (!oTickbox.checked) {
            oCharityNumber.value = "";
						oParent.id = "charityBoxDisabled"; 
        }
			else {
				oParent.id = "";
			}
   }
}


/**
 * Updates the total price on the Pay now form.
 */
function e3payment_update_total_price(oTickbox) {
	if (oTickbox) {
		// Sort out tickbox prerequisites for the tickbox you ticked here. These are 1 image > 8 images, 1 offer > 3 offers.

		// Events.
		if (oTickbox.id == "edit-paidFields-2" && !oTickbox.checked) fnTick("edit-paidFields-3", false);
		if (oTickbox.id == "edit-paidFields-3" && oTickbox.checked) fnTick("edit-paidFields-2", true);
		if (oTickbox.id == "edit-paidFields-4" && !oTickbox.checked) fnTick("edit-paidFields-5", false);
		if (oTickbox.id == "edit-paidFields-5" && oTickbox.checked) fnTick("edit-paidFields-4", true);
		
		// Venues.
		if (oTickbox.id == "edit-paidFields-28" && !oTickbox.checked) fnTick("edit-paidFields-29", false);
		if (oTickbox.id == "edit-paidFields-29" && oTickbox.checked) fnTick("edit-paidFields-28", true);
		if (oTickbox.id == "edit-paidFields-30" && !oTickbox.checked) fnTick("edit-paidFields-31", false);
		if (oTickbox.id == "edit-paidFields-31" && oTickbox.checked) fnTick("edit-paidFields-30", true);
		if (oTickbox.id == "edit-paidFields-32" && !oTickbox.checked) fnTick("edit-paidFields-35", false);
		if (oTickbox.id == "edit-paidFields-35" && oTickbox.checked) fnTick("edit-paidFields-32", true);

		// Venues website - if you untick any of the free ones then untick Website.
		/*
		if (oTickbox.id == "edit-paidFields-22" && !oTickbox.checked) fnTick("edit-paidFields-21", false);
		if (oTickbox.id == "edit-paidFields-23" && !oTickbox.checked) fnTick("edit-paidFields-21", false);
		if (oTickbox.id == "edit-paidFields-24" && !oTickbox.checked) fnTick("edit-paidFields-21", false);
		if (oTickbox.id == "edit-paidFields-25" && !oTickbox.checked) fnTick("edit-paidFields-21", false);
		if (oTickbox.id == "edit-paidFields-26" && !oTickbox.checked) fnTick("edit-paidFields-21", false);
		if (oTickbox.id == "edit-paidFields-27" && !oTickbox.checked) fnTick("edit-paidFields-21", false);
	  */
	}
	
	// Website - this includes opening hours, good for kids etc. Tick them all and disable them when website is ticked.
	// Only run this one on initial page load and if you tick or untick website.
	if (!oTickbox || oTickbox.id == "edit-paidFields-21") { 
		var oWebsite = document.getElementById("edit-paidFields-21");
		if (oWebsite) {
			if (oWebsite.checked) {
				// Website is checked, then check and disable them all.
				// Dont disable as they dont get posted then!
				fnTick("edit-paidFields-22", true, true);
				fnTick("edit-paidFields-23", true, true);
				fnTick("edit-paidFields-24", true, true);
				fnTick("edit-paidFields-25", true, true);
				fnTick("edit-paidFields-26", true, true);
				fnTick("edit-paidFields-27", true, true);
				fnTick("edit-paidFields-32", true, true);
				fnTick("edit-paidFields-33", true, true);
				fnTick("edit-paidFields-35", true, true);
			}
			else {
				// Website not checked, just make sure they are all enabled.
				fnDisable("edit-paidFields-22", false);
				fnDisable("edit-paidFields-23", false);
				fnDisable("edit-paidFields-24", false);
				fnDisable("edit-paidFields-25", false);
				fnDisable("edit-paidFields-26", false);
				fnDisable("edit-paidFields-27", false);
				fnDisable("edit-paidFields-32", false);
				fnDisable("edit-paidFields-33", false);
				fnDisable("edit-paidFields-35", false);
			}
		}
	}
	
	var dTotal = 0;

	// Tot up the price of each ticked checkbox in the paid fields section.
	var oWrapper = document.getElementById("paidFieldsWrapper");
	if (oWrapper) {
		var oInputs = oWrapper.getElementsByTagName("input");
		for (var i = 0; i < oInputs.length; i++) {
			if (oInputs[i].checked) {
				dTotal += fnGetPrice(oInputs[i].id.replace("edit-paidFields-", "price"));
					
				// Discount of the price of fid's 22-27,32,33,35 if you choose Website.
				if (oInputs[i].id == "edit-paidFields-21") {
					for (var j = 22; j <= 27; j++) {
						dTotal -= fnGetPrice("price" + j);
					}
					dTotal -= fnGetPrice("price32");
					dTotal -= fnGetPrice("price33");
					dTotal -= fnGetPrice("price35");
				}
			}
		}
	}
	
	// Calculate VAT and amount excluding VAT.
	var dTotalExVAT = dTotal / 1.175;
	var dTotalVAT = dTotal - dTotalExVAT;
	
	if (document.getElementById("finalCostExVAT")) {
		document.getElementById("finalCostExVAT").innerHTML = dTotalExVAT.toFixed(2);
	}
	if (document.getElementById("finalCostVAT")) {
		document.getElementById("finalCostVAT").innerHTML = dTotalVAT.toFixed(2);
	}
	if (document.getElementById("finalCost")) {
		document.getElementById("finalCost").innerHTML = dTotal.toFixed(2);
	}
}



/**
 * Helper function for e3payment_update_total_price which changes the checked state of a checkbox by ID.
 */
function fnTick (sTickboxID, bTick, bDisabled) {
	var oTickbox = document.getElementById(sTickboxID);
	if (oTickbox) {
		oTickbox.checked = bTick;
		oTickbox.disabled = bDisabled;
	}
}

/**
 * Helper for e3payment_update_total_price which changes the disabled state of a checkbox.
 */
function fnDisable (sTickboxID, bDisabled) {
	var oTickbox = document.getElementById(sTickboxID);
	if (oTickbox) {
		oTickbox.disabled = bDisabled;
	}
}

/**
 * Helper function for e3payment_update_total_price which gets the price of a field by its checkbox ID.
 */
function fnGetPrice (sSpanID) {
	var oPrice = document.getElementById(sSpanID);
	if (oPrice) {
		// Substring off the £ sign
		var dPrice = Number(oPrice.innerHTML.substring(1));
		
		if (!isNaN(dPrice)) {
			return dPrice;
		}
	}
	return 0;
}






