// Function to add 1 into the basket
function addline(obj){
	var x = document.getElementById(obj);
	if (x.value==0){
		x.value = "1";
	}
}

// Function ensure all occurances of the product on the list have the same quantity
function updateQty(pVal,pID) { 
	for (i=0; i<document.productlist.elements.length; i++)
	{
		if ((document.productlist.elements[i].id == pID)){
			document.productlist.elements[i].value = pVal;
		}
	}
} 


// Function to check stock, and give message box if requested stock > current stock
function checkStock(element,iStockLevel) {
	var theElement = document.getElementById(element).value;
	
	if (theElement > iStockLevel) {
			alert("You have requested more than we have in stock.\n\n\The current " + iStockLevel + " in stock will be dispatched, and the additional stock will be placed on back order for you.\n\n\If you wish to check when these will be dispatched please phone 0844 844 4300.\n\n\If you still want to place these items into your basket, please click Add.");
		}
}

// Function to remove '0' from the quantity box
function clearQty(p){
if (p.value == "0")
	p.value = "";
}

// Clear the default search phrase
function clearSearch(p){
if (p.value == p.defaultValue)
	{p.value = "";}
}

// Remove this line from the order
function removeline(obj){
	var x = document.getElementById(obj);
	x.value = "0";
}

// Reload Capatcha image
function reloadvalidation() {
	document.getElementById('validationimg').src='images/img_validation.jpg?'+Date();
}

// Open a new window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Preload Images
function mm_preloadimages() { //v3.0
var d=document; if(d.images){ if(!d.mm_p) d.mm_p=new Array();
var i,j=d.mm_p.length,a=mm_preloadimages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.mm_p[j]=new Image; d.mm_p[j++].src=a[i];}}
} 

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}