function HasQuoteAlert()
{
	return alert('WARNING: You must wait for your quote request to be returned before you can continue and pay.'+"\n"+'We will contact you once the quote is ready.');	
}

function delQuoteFormConfirm()
{	
	missinginfo = '';
	confim = true;
	
	if(document.delivery_quote_form.parking_distance.value == '')
	{
		confim = false;
	}	

//confim = false;
	if(confim == true)
	{
		missinginfo = 'WARNING: Are you sure you want to submit this quote request? You can not delete the associated products from your basket once this quote request is submitted!';
		if(confirm(missinginfo) == true)
		{
			return document.delivery_quote_form.submit();
		}
		else
		{
			return false;
		}
	}
	else
	{
		//return alert('test');
		return;
	}
}

function fillDeliveryAddress() {	
	var $address1 = document.getElementById("address1_billing").value;
	document.getElementById("address1").value =  $address1;
	var $address2 = document.getElementById("address2_billing").value;
	document.getElementById("address2").value =  $address2;
	var $town = document.getElementById("town_billing").value;
	document.getElementById("town").value =  $town;
	var $county = document.getElementById("county_billing").value;
	document.getElementById("county").value =  $county;
	var $postcode = document.getElementById("postcode_billing").value;
	document.getElementById("postcode").value =  $postcode;
}

// Product-info page function which opens new image window for large product shots
function getImageXtraLarge(pExistingImageID, ImageURL, imageWidth, imageHeight)
{
	$imageLink = document.getElementById(pExistingImageID).src; // Get image link using the img id (placeholder)
	
	$imageName=$imageLink.split("/"); // Because the link contains directorys, use split to create an array
	
	$arrayLength=$imageName.length-1; // We only need the last array value so obtain it using length minus 1.
	
	// Open new window with the url created with [PRD_XTRA_LARGE_LINK] and the image name (taken from the created array)
	newwindow=window.open("/library/image_popup/popup.php?url="+ImageURL+$imageName[$arrayLength]+"&clTxt=Click on image to close window", "mywindow","menubar=1,resizable=1"); // ,'name','height='+imageWidth+', width='+imageHeight+', location=yes'

	if (window.focus) 
	{
		newwindow.focus()
	}
}

function checkTerms() { // Check T & C box is ticked before proceding to paypal
	missinginfo = '';
	if (!document.agreement_form.agreement.checked) 
	{
		missinginfo += '\n - You must agree to the Terms and Conditions';
	}
	
	if (missinginfo != '') 
	{
		missinginfo ='Required information is missing: \n' +
		missinginfo + '\n' + '';
		alert(missinginfo);
		/*return false;*/
	}
	else 
	{
		document.checkout.submit();
		return true;
	}

}
function doNothing() {
}

function MM_openBrWindow(theURL,winName,features) { // Used to open new window
  window.open(theURL,winName,features);
}

// This function runs the funtion (defined as an argument) after the page has loaded (it is used so we dont overwrite additional onLoad functions that could be located in the body tag
function onPageLoad(func) 
{
	var oldonLoad = window.onload; // Set variable to the window.onload event
	// If the window.onload event does not already have a function attached, run checkCommentForm() function (or whatever the argument is)
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	} 
	else  // If the onload event has functions attached to it, run them first before runnning the checkCommentForm() function
	{
		window.onload = function() 
		{
			oldonLoad();
			func();
		}
	}
}

function flickerControlHide() 
{
	document.getElementById('review-product-form').style.display = "none";

	// Need this because the below code doesnt workin IE. Checks to see
	// if browser is firefox and if so uses the DOM to display hide class (eliminates flicker)
	if(navigator.userAgent.indexOf("Firefox") != -1) 
	{
		js = document.createElement('style');
		js.appendChild(document.createTextNode('#review-product-form{display:none;}'));
		js.type = 'text/css';
		document.getElementsByTagName('head').item(0).appendChild(js);
	}
}

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 
	}
}