
function validateNewPL(){
		var inputBox = document.getElementById('newpl');
	var plName = removeLeadingWhiteSpace(inputBox.value);
	inputBox.value = plName;
	if(!plName.match("^.+$"))
	{
		alert("Please enter a name for this purchasing list");
		inputBox.focus();
		return false;
	}
	else
	{
		if(!plName.match("^[a-zA-Z0-9/ ]+$")){
			alert("Please ensure that the purchasing list name only\nincludes alphanumeric characters, / or space");
			inputBox.focus();
			return false;
		}
	}

	return true;

}

function validateQty()
{
	var qtyName = 0;
	var nocontent = true ;
	while(document.getElementById('quantity_' + qtyName) != null){

		_value = document.getElementById('quantity_' + qtyName).value ;

			if( _value != null )
			{
				if( _value != "" )
				{
					nocontent =  false ;
				}
				if( _value != "" && !_value.match("^[0-9]+$") )
				{

					alert("Please enter a number in this quantity field");
					document.getElementById('quantity_' + qtyName).focus();
					document.getElementById('quantity_' + qtyName).select();
					return false;
				}
			} else {
				break;
			}
			qtyName++;

	}

	if( nocontent )
	{
		alert("You have not entered any quantities.  Please enter some quantities below") ;
		document.getElementById('quantity_0').focus();
		document.getElementById('quantity_0').select();
		return false;

	}
	return true;
}

function performAddToBasket(){
	if(validateQty())
		document.addToBasket.submit();	
}

function notLoggedIn() {
	alert("Sorry but in order to take advantage of this part of the site \\nyou must be a registered user and logged into the site");
	return false
}

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Philip Myers :: http://virtualipod.tripod.com/bookmark.html */

function bookmark(urllink,title){
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
	  window.external.AddFavorite(urllink,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,urllink,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
  
}

function popup(gotoUrl, w, h) 
{
 var width  = w;
 var height = h;
 var left   = Math.round((screen.width  - width)/2);
 var top    = Math.round((screen.height - height)/2);
 var params = 'width='+width+',height='+height;
 params += ',top='+top+', left='+left;
 params += ',directories=no';
 params += ',location=no';
 params += ',menubar=no';
 params += ',resizable=no';
 params += ',scrollbars=no';
 params += ',status=no';
 params += ',toolbar=no';

 newwin=window.open(gotoUrl,'emailfriend', params);
 return false;
}
