var win = null;
function newWindow(mypage,myname,w,h,features) {
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}


function Register_match_school_invoice_address()
{
	document.forms.registerForm.invoice_address.value = document.forms.registerForm.address.value;
	document.forms.registerForm.invoice_town.value = document.forms.registerForm.town.value;
	document.forms.registerForm.invoice_county.value = document.forms.registerForm.county.value;
	document.forms.registerForm.invoice_postcode.value = document.forms.registerForm.postcode.value;
}


function declareStock()
{
	document.forms.StockForm.action = 'declare_stock.asp';
	document.forms.StockForm.submit();
}

function NumberReturns(current_stock,num_returns,already_requested,which_field)
{
var a = parseInt(current_stock);
var b = parseInt(num_returns);
var c = parseInt(already_requested);
var d = which_field;

var e = b+c;

if (a >= e)
	{
	//do nothing
	}
else
	{
	eval("document.forms.StockForm."+d+".value = '0'");
	alert ("Please ensure the number of returns is less than or equal to your current stock level");
	}
}


function CheckBoxQtyMultiple(formQty,boxQty)
{
var a = parseInt(formQty)
var b = parseInt(boxQty)
var c = (a/b);
var d = c+"";
var e = d.indexOf(".");

//convert to string
var f = e+"";

if (f == "-1")
	{
	//alert ("Quantity is fine");
	document.forms.optionForm.submit();
	}
else
	{
	alert ("Please ensure the quantity you enter is a multiple of the box quantity");
	}

}


function show_large_product_image()
{
pInfo.style.display = "none";
pLimage.style.display = "block";
}

function hide_large_product_image()
{
pInfo.style.display = "block";
pLimage.style.display = "none";
}


function print_page()
{
window.print();
}
