function show_large($new_src) { 
	document.getElementById('large_img').src='/templates/img/products/larges/'+$new_src;
}

function MM_openBrWindow(theURL,winName,features) { // Used to open product thumb image in new window
  window.open(theURL,winName,features);
}

function doNothing() { // Intentionally empty
}

function checkEnter(e) // Enable forms to be submitted with 'enter' even if the buttons a graphic
{ //e is event object passed from function invocation
	var characterCode
	if(e && e.which)
	{ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}
	else
	{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13)
	{ //if generated character code is equal to ascii 13 (if enter key)
		document.forms[0].submit() //submit the form
		return false 
	}
	else
	{
		return true 
	}
}

// Check T & C box is ticked before proceeding to paypal
function checkme() { 
	missinginfo = '';
	if (!document.registrationform.agreement.checked) 
	{
		missinginfo += '\n - You must agree to the Disclaimer by ticking the checkbox';
	}
	
	var radio_choice = false;
	if (missinginfo != '') 
	{
		missinginfo ='Required information is missing: \n' +
		missinginfo + '\n' + '';
		alert(missinginfo);
		return false;
	}
	else 
	{
		
		document.goRegister.submit();
		return true;
	}
}
fp = {
	init:function()
	{
		// Check to see if W3C DOM is available - if not terminate script
		// If required objects are available, hide js alert and show update form
		if(!document.getElementById || !document.createTextNode){return;}
		var container = document.getElementById("updatenumberform");
		var container2 = document.getElementById("javascript_alert");
		var container3 = document.getElementById("additional_number");
		//alert("test");
		if(container)
		{
			// If the 'hidden_content' element is availabe (we've got this far , so it must be) - apply a dynamic style
			// to hide it (display:none)
			fp.cssjs('remove', container, "hide_form");
			fp.cssjs('add', container2, "hide_form");
			
			// Add the onclick event behaviour to the dropdown menue
			fp.addEvent(container3, 'change', fp.createAdditionalField, false);
			// Add the onclick event behaviour to the dropdown menue
			fp.addEvent(container, 'submit', fp.checkAdditionalField, false);
		}
	},
	
	// Create additional name fields on booking pages (if users want to make multiple bookings)
	createAdditionalField:function() 
	{
		var container = document.getElementById("update_booking_button");
		fp.cssjs('remove', container, "hide_form");
		
		// Obtain and set parent node (so we know where to place the additional nodes within the doc)
		var parentDiv = document.getElementById('additional_number');
		var parentNodeRef = parentDiv.parentNode;
		
		// Get number of additional bookings (needed for a loop that creates each form element)
		var additionalNumber = document.getElementById('additional_number').value;
		
		if (additionalNumber ==0)
		{
			fp.cssjs('add', container, "hide_form");
		}
		
		// Loop through inserting number of additional fields
		for (var x = 1; x <= additionalNumber; x++)
		{
			// If the form element doesnt already exist, create it
			if (!document.getElementById("name_"+x))
			{
				// Create li node
				var liElement = document.createElement("li");
				// NOTE: Very impotant to assign an id to the new li element. 
				// This allows us to delete it later if the user decides to reduce the number(we need to be able to reference it)
				var divIdName = 'my'+x+'Div';
				// Set id attribute of li node
				liElement.setAttribute('id',divIdName);
				// Create the text for the formfield
				var nametext = document.createTextNode('Full Name: ');
				// Attach text to li node
				liElement.appendChild(nametext);
				// Create input node
				var formFieldElement = document.createElement("input");
				// Set attributes for input
				formFieldElement.setAttribute("id", "name_"+x);
				formFieldElement.setAttribute("name", "name_"+x);
				// Attach form field to li node
				liElement.appendChild(formFieldElement);
				// li node to our specified parent
				parentNodeRef.appendChild(liElement);
			}
		}
		//alert (x);
		var maximum_number = x;
		// Loop through inserting number of additional fields
		for (var y = maximum_number; y <= 50; y++)
		{
			if (document.getElementById("name_"+y))
			{
				var divIdName = 'my'+y+'Div';
				var d = document.getElementById("updatenumberform");
				var olddiv = document.getElementById(divIdName);
	
				if(window.XMLHttpRequest)
				{
					if(window.ActiveXObject)
					{
						// IE 7
						// As usual, IE doesnt wanna play ball so we have to remove each node individually and specifically change the text value
						var oldformfield = document.getElementById("name_"+y);
						// Set the firstchild of <li> element (the text) to nothing. Its important to do this because when IE removes nodes, it does not remove any nested elements that are within the node
						olddiv.firstChild.nodeValue = "";
						// Remove <li> tag
						olddiv.removeNode();
						// Finally, remove the form field
						oldformfield.removeNode();
					}
						else
					{
						// Opera, Safari, Firefox
						//alert ('Standards Complient');
						// Standards complient browsers can use one single line to remove the full node
						d.removeChild(olddiv);
					}
				}
					else
				{
					//IE 6 and below
					//alert ('IE 6 and others');
				}
			}
		}
	},
	// Check additional name fields are filled in
	checkAdditionalField : function(e) 
	{ 
		missinginfo = '';
		var status = true;
		for (var y = 1; y <= 50; y++)
		{
			if (document.getElementById("name_"+y)) 
			{
				if (!document.getElementById("name_"+y).value) 
				{
					missinginfo = 'You must add all additional names';
					status = false;
				}
			}
		}
		if(status)
		{
			return true;
		}
		alert(missinginfo);
		// VERY IMPORTANT - We need to use the custom cancelClick function to prevent the function from submitting
		// Usually - when using JS inline - we would apply false to the function to tell the browser not to run it
		// We cannot use this with unobtrusive JS so we use the cancelClick function return false
		fp.cancelClick(e);
	},
	/************************************* helper methods ********************************************************/
	addEvent: function(elm, evType, fn, useCapture)
	{
		if (elm.addEventListener) 
		{
			elm.addEventListener(evType, fn, useCapture);
			return true;
		} else if (elm.attachEvent) {
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		} else {
			elm['on' + evType] = fn;
		}
	},
	
	// cssjs mthod that adds, removes or swaps classes
	// see http://www.onlinetools.org/articles/unobtrusivejavascript/cssjsseparation.html
	cssjs:function(a,o,c1,c2)
	{
		switch (a)
		{
			case 'swap':
				o.className=!fp.cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
			break;
			case 'add':
				if(!fp.cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
			break;
			case 'remove':
				var rep=o.className.match(' '+c1)?' '+c1:c1;
				o.className=o.className.replace(rep,'');
			break;
			case 'check':
				return new RegExp("(^|\\s)" + c1 + "(\\s|$)").test(o.className)
			break;
		}
	},
	// Use cancelClick method to cancel 'event bubbling' and default actions associated to elements
	cancelClick:function(e)
	{
		if (window.event)
		{
			window.event.cancelBubble = true;
			window.event.returnValue = false;
			return;
		}
		if (e)
		{
			e.stopPropagation();
			e.preventDefault();
		}
	}
}
// addEvent is a method used to sort of stack functions up after the page has loaded.
// On this page this method is watching the window and waiting till its loaded.
// After which the fp.init object is initialized
fp.addEvent(window, 'load', fp.init, false);