function AdminItemRequest(address, subject, body, productID, productCode, description, price, quantity)
{
	var sendRequest = window.confirm('Your account has been set up to only allow ordering from the "Authorised Products" list.\n\nWould you like to ask your Administrator to order this product for you?');
	if (sendRequest == true)
	{	           
       mailMessage = body.replace(/__/, quantity)
	   parent.location.href = 'mailto:' + address + '?subject=' + subject + '&body=' + mailMessage + "%0D%0A%0D%0A  "  + "Product ID : " + productID + "%0D%0A  " + "Product Code : " + productCode + "%0D%0A  " + "Description : " + description  + "%0D%0A  " + "Price : " + price + "%0D%0A  " + "Quantity : " + quantity;
	}
}

function validateRequiredField(obj, message)
{
	if (obj.value.length == 0)
	{
		alert(message);
		obj.focus();
		return false;
	}
	return true;
}

function extractNumber(obj, decimalPlaces, allowNegative)
{	
	var temp = obj.value;
		
	// avoid changing things if already formatted correctly
	var reg0Str = '[0-9]*';
	if (decimalPlaces > 0) 
	{
		reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
	} else if (decimalPlaces < 0) 
	{
		reg0Str += '\\.?[0-9]*';
	}
	reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
	reg0Str = reg0Str + '$';
	var reg0 = new RegExp(reg0Str);
	if (reg0.test(temp)) return true;

	// first replace all non numbers
	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
	var reg1 = new RegExp(reg1Str, 'g');
	temp = temp.replace(reg1, '');

	if (allowNegative) 
	{
		// replace extra negative
		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
		var reg2 = /-/g;
		temp = temp.replace(reg2, '');
		if (hasNegative) temp = '-' + temp;
	}
	
	if (decimalPlaces != 0) 
	{
		var reg3 = /\./g;
		var reg3Array = reg3.exec(temp);
		if (reg3Array != null) {
			// keep only first occurrence of .
			//  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
			reg3Right = reg3Right.replace(reg3, '');
			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
		}
	}
	
	obj.value = temp;
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) 
	{
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) 
	{
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	keychar = String.fromCharCode(key);
	
	if (!allowDecimal && keychar == '0')
	{
		if (obj.value.length == 0)
			return false;
	}
	
	if (isNaN(key)) return true;
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
}

function ShowRejectMessageExRejectAll(b)
{
    var position = Sys.UI.DomElement.getLocation(b)
    var x = position.x - 200;
    var y = position.y - 150;
    
    var iw = $get('infowindowRejectAll');
    iw.style.display = "";
    Sys.UI.DomElement.setLocation(iw,x,y);
        
    return true;
}

function ShowReverseMessageExReverseAll(b) {
    var position = Sys.UI.DomElement.getLocation(b)
    var x = position.x - 200;
    var y = position.y - 150;

    var iw = $get('infowindowReverseAll');
    iw.style.display = "";
    Sys.UI.DomElement.setLocation(iw, x, y);

    return true;
}

function ShowCancelMessageExCancelAll(b) {
    var position = Sys.UI.DomElement.getLocation(b)
    var x = position.x - 200;
    var y = position.y - 150;

    var iw = $get('infowindowCancelAll');
    iw.style.display = "";
    Sys.UI.DomElement.setLocation(iw, x, y);

    return true;
}