/*
*  All javascripts used in NetStore  
*/


/*****************************************************************************
*	Message alert
*
*  @param headTxt the header text
*  @param msg the message to display
*******************************************************************************/

function message(headTxt, msg) {
	alert(headTxt + "\n\n" + msg);		
}

/*******************************************************************************
*
* Select all checkboxes on a page.
* @param selectAllCheckbox 		the checkbox invoking this function 
*
*******************************************************************************/
function selectAllCheckboxes(selectAllCheckbox) {
	len = document.forms[2].elements.length;
	var i=0;
	while(i!=len) {
		if (document.forms[2].elements[i].type=='checkbox' && document.forms[2].elements[i].name != eval("selectAllCheckbox.name"))	
			document.forms[2].elements[i].checked = selectAllCheckbox.checked;
		i++;
	}
}

/*******************************************************************************
*
* Set checkboxes to selected or deselected 
* @param checked 		Set checkboxes to selected or deselected (true or false)
* @param name			The name of the check boxes to select or deselect
*
*******************************************************************************/
function toggleCheckboxes(checked,name) {
	len = document.forms[2].elements.length;
	var i=0;
	while(i!=len) {
		if (document.forms[2].elements[i].type=='checkbox' && document.forms[2].elements[i].name == eval("name"))	
			document.forms[2].elements[i].checked = checked;
		i++;
	}
}

/******************************************************************************
* Updates the entry string to uppercase.
*
* @param inputElement The charactes to changes to uppercase
*******************************************************************************/

function toUpperCase(inputElement) {
    if (inputElement.value.length > 0) inputElement.value = inputElement.value.toUpperCase();
}

/******************************************************************************
*	Confirm sign off		
*   @param headTxt the header text				      
******************************************************************************/
function confirmSignoff(headtxt, href) {
//	if (top.window.frameSetLoaded) {
		if (confirm(headtxt + "!")) {
//			top.window.frameSetLoaded = false;
        	top.location.replace(href);
     	}
//     }
}

/******************************************************************************
*	Switch language	
*
*   Ignored if frameset not loaded yet							      
******************************************************************************/
function languageSwitch(href,code,warningText) {
//	if (top.window.frameSetLoaded) {
		if (!top.window.blockedLanguageSwitch || confirm(warningText)) {
//			top.window.frameSetLoaded = false;
			top.location.replace(href+'?TO_LANGUAGE='+code);
		}
//	}
}


/******************************************************************************
*	General home frame confirmation prompt  					 
******************************************************************************/
function confirmation(text,href) {
	if (confirm(text)) {
        	top.home.location.replace(href);
     	}
}

/******************************************************************************
*	Allowed card checkbox changed from selected to not selected confirmation  					 
******************************************************************************/
function confirmCardInactivation(text,actionName,checkbox) {

	if (confirm(text)) {
		submitLinkOnce(actionName,checkbox.value);
	} else {
      	checkbox.checked = !checkbox.checked;
    }
        
}

/******************************************************************************
*	Allowed card checkbox changed from not selected to selected confirmation  					 
******************************************************************************/
function confirmCardActivation(text,cardInfo,actionName,checkbox) {

    text = text + "\n" + cardInfo
	cn = prompt(text,"");
	if (cn == null) {
		checkbox.checked = !checkbox.checked;
	} else {
		submitLinkOnce(actionName,cn);
    }
        
}
/******************************************************************************
* Open standard sized a possitioned new window with the specified jsp or html
*
*   Ignored if frameset not loaded yet					
******************************************************************************/
function showWindow(jspName) {
//	if (top.window.frameSetLoaded) {
		if (top.window.infoWindow != null && !top.window.infoWindow.closed) {
			top.window.infoWindow.close(); 
		}
		if (navigator.userAgent.indexOf("MSIE")!=-1) {
			top.window.infoWindow = window.open(jspName, "NetStore", "left=500,top=200,height=400,width=600,toolbar=no,menubar=no,location=no,status=yes,scrollbars=yes,resizable=yes");
			top.window.infoWindow.focus();
        } else {
			top.window.infoWindow = window.open(jspName, "NetStore", "screenX=500,screenY=200,height=400,width=600,toolbar=no,menubar=no,location=no,status=yes,scrollbars=yes,resizable=yes");
			top.window.infoWindow.focus();
        }
//     }
}

/******************************************************************************
* Open new window for the specified jsp or html with specifeied size and pos
*
*   Ignored if frameset not loaded yet					
******************************************************************************/
function showWindow(jspName,anchorName,windowName,x,y,h,w) {

//	if (top.window.frameSetLoaded) {
		if (top.window.infoWindow != null && !top.window.infoWindow.closed) {
			top.window.infoWindow.close(); 
		}
        str = ",height=" + h + ",width=" + w + ",toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes";
		if (navigator.userAgent.indexOf("MSIE")!=-1) {
	    	str = "left=" + x + ",top=" + y + str;		
        } else {
	    	str = "screenX=" + x + ",screenY=" + y + str;
        }
      
        if (anchorName != null) {
        	jspName = jspName+"#"+anchorName;
        }
		top.window.infoWindow = window.open(jspName, windowName, str);
		top.window.infoWindow.focus();
//	}
}
function showCartWindow(jspName,anchorName,windowName,x,y,h,w) {

//	if (top.window.frameSetLoaded) {
		if (top.window.cartWindow != null && !top.window.cartWindow.closed) {
			top.window.cartWindow.close(); 
		}
        str = ",height=" + h + ",width=" + w + ",toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes";
		if (navigator.userAgent.indexOf("MSIE")!=-1) {
	    	str = "left=" + x + ",top=" + y + str;		
        } else {
	    	str = "screenX=" + x + ",screenY=" + y + str;
        }
      
        if (anchorName != null) {
        	jspName = jspName+"#"+anchorName;
        }
		top.window.cartWindow = window.open(jspName, windowName, str);
		top.window.cartWindow.focus();
//	}
}
/******************************************************************************
* cross-window JavaScripting.
* Open new window for the specified jsp or html with specified size and pos
* Checks if the exist already open remote window
*   Ignored if frameset not loaded yet						
******************************************************************************/

var listName = "";
var itemKey = null;
var action = "";
function openShoppingListWindow(actionValue, key, jspName,windowName,x,y,h,w) {

//	if (top.window.frameSetLoaded) {
	
		itemKey = key;
		action = actionValue;
	
		if (top.window.shoppingListWindow != null && !eval("typeof(top.window.shoppingListWindow)!=\"undefined\"") && !top.window.shoppingListWindow.closed) {// if mywindow has been opened, and mywindow hasn't already been closed
			top.window.shoppingListWindow.close(); //close it in order to re-assign properties
		}
 
        str = ",height=" + h + ",width=" + w + ",toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes";
		if (navigator.userAgent.indexOf("MSIE")!=-1) {
	    	str = "left=" + x + ",top=" + y + str;		
        } else {
	    	str = "screenX=" + x + ",screenY=" + y + str;
        }
     
        top.window.shoppingListWindow=open(jspName, windowName, str);
        
		// If no opener was found can happen in NetScape 2.x
    	if (top.window.shoppingListWindow.opener == null) {
			 top.window.shoppingListWindow.opener = self;
	  	}
		top.window.shoppingListWindow.focus() 
//	}
}
/*******************************************************************
* Submit the specfied button when the Enter key is pressed
*******************************************************************/
function submitEnter(button,ev) {
	var keycode;
	if (window.event) 
		keycode = window.event.keyCode;
	else if (ev) 
		keycode = ev.which;
	else 
		return true;
	
	if (keycode == 13) {
		submitButtonOnce(button);
		return false;
	} else
		return true;
}
/*******************************************************************
* Submit the specfied link when the Enter key is pressed
*******************************************************************/
function submitLinkOnEnter(action,value,ev) {
	var keycode;
	if (window.event) 
		keycode = window.event.keyCode;
	else if (ev) 
		keycode = ev.which;
	else 
		return true;
	
	if (keycode == 13) {
		submitLinkOnce(action,value);
		return false;
	} else
		return true;
}
/******************************************************************************
* cross-window JavaScripting.
* Method to update data from the remote window
* 
* Uses the attribute listName, action, itemKey which is initilized in javascript
* method openShoppingListWindow(actionValue, key, jspName,windowName,x,y,h,w)
*				
******************************************************************************/
function updateDataFromShoppingListWindow() {

	if(document.forms[2].IBS_LISTSELECTION_VALUE != null) {		
		document.forms[2].IBS_LISTSELECTION_VALUE.value = escape(listName);
	}
	
	if (top.window.shoppingListWindow != null) {
		top.window.shoppingListWindow.close();
	}
	submitLinkOnce(action, itemKey); 
}


/******************************************************************************
*	disable all buttons						      
******************************************************************************/
function disableAllButtons() {
    var totalFormsNumber = document.forms.length;
    if (totalFormsNumber > 0) {
        for (var i=0; i<totalFormsNumber; i++) {
            var form = document.forms[i];
            for (var j=0; j<form.elements.length; j++) {
                var formElement = form.elements[j];
		if (formElement.type == "submit" || formElement.type == "button") {
                    formElement.disabled = true;
                }
            }
        }
    }
}

/******************************************************************************
*	reset and reload form for the specified frame				     					 
******************************************************************************/
function resetForm(frameName) {
	top.frames[frameName].document.forms[2].reset();
	if (top.frames[frameName]) { 
		top.frames[frameName].location.reload();
	}	
}


/******************************************************************************
*	Disable actions in all frames			     					 
******************************************************************************/
function disableActions() {
//	blocked = true; // temp fix to stop other options being chosen until current function is complete
//	top.window.frameSetLoaded = false;
    if (navigator.userAgent.indexOf("Mac") < 0) {
//    	var no = top.frames.length;
//		for (var i=0; i < no; i++) {
//			top.frames[i].document.body.style.cursor = 'wait';		
			document.body.style.cursor = 'wait';		
//		}
	}
}

/******************************************************************************
*	Enable actions in all frames			     					 
******************************************************************************/
function enableActions() {
    if (navigator.userAgent.indexOf("Mac") < 0) {
//    	var no = top.frames.length;
//		for (var i=0; i < no; i++) {
//			top.frames[i].document.body.style.cursor = 'default';		
			document.body.style.cursor = 'default';		
//		}
	}
//	blocked = false; // temp fix to stop other options being chosen until current function is complete
//	top.window.frameSetLoaded = true;
}

/******************************************************************************
*	Invoke link:
*   
* 	Invoke the link once when the current frame is loaded.
*   If the link is clicked while frameset not loaded yet or something else is
*   blocking the actions (via the 'blocked' variable) is the invokation ignored   
******************************************************************************/
var loaded = false;
var blocked = false;
var activeHref = null;
var loops = 0;

function invokeLink(href) {
//  if(!blocked && top.window.frameSetLoaded) {
  if(!blocked) {
	activeHref = href;
	blocked = true;
    invokeLinkWhenLoaded();
  }
}

function invokeLinkWhenLoaded() {
  if (loaded) {
  	if (navigator.userAgent.indexOf("Mac") < 0) {
  		document.body.style.cursor = 'wait';
  	}
	disableAllButtons();	
	window.location.href = activeHref;
  } else {
     loops++;
     if (loops < 720) {
     	setTimeout("invokeLinkWhenLoaded()",250);	
     } else {
        blocked = false;
		alert('Not ready loading page!');
     }
  }
}

/******************************************************************************
*	Submit link: 
*
* 	Submit the link once when the frame set and current frame is loaded.
*   If the link is submitted while frameset not loaded yet or something else is
*   blocking the actions (via the 'blocked' variable) is the submit ignored    
*							    
* Note: include following input fields in jsp:				       
* <INPUT NAME="IBS_LINKSELECTION_ACTION"  TYPE="HIDDEN"  VALUE="">     	        
* <INPUT NAME="IBS_LINKSELECTION_VALUE"  TYPE="HIDDEN"  VALUE="">	      
******************************************************************************/
var sbmAction = null;
var sbmValue = null;
var sbmQty = null;
var sbmUnit = null;
var sbmAlias = null;

function submitLinkOnce(action,value) {

//   if(!blocked && top.window.frameSetLoaded) {
   if(!blocked) {
		blocked = true;
        sbmAction = action;
        sbmValue = value;
       	submitLinkWhenLoaded();
   }
}

function submitLinkWhenLoaded() {
    if(loaded) {
    	if (navigator.userAgent.indexOf("Mac") < 0) {
    		document.body.style.cursor = 'wait';
    	}
		disableAllButtons();
		document.forms[2].IBS_LINKSELECTION_ACTION.name= sbmAction;
		document.forms[2].IBS_LINKSELECTION_VALUE.value= sbmValue;
		document.forms[2].submitPopupQty.value= sbmQty;
		document.forms[2].submitPopupUnit.value= sbmUnit;
		document.forms[2].submitPopupAlias.value= sbmAlias;
		document.forms[2].submit();
		if (navigator.userAgent.indexOf("MSIE")!=-1
			&& navigator.userAgent.indexOf("Mac") < 0){
			document.forms[2].IBS_LINKSELECTION_VALUE.value= "";
		} 
    } else {
        loops++;
        if (loops < 720) {
	   		setTimeout("submitLinkWhenLoaded()",250);
        } else {
        	blocked = false;
	   		alert('Not ready loading page!');
        }
    } 
}

/******************************************************************************
*	Submit buttons:
* 
* 	Submit the specified button once when the current frame is loaded.
*       If the button is clicked while something else is blocking actions 
*       (via the 'blocked' variable) is the submit ignored 
*  						 
* Note: include following input fields in jsp:				      
* <INPUT NAME="IBS_SUBMIT_ACTION"  TYPE="HIDDEN"  VALUE="">  	      	        
******************************************************************************/
var sbmButton = "";

function submitButtonOnce(button) {
//   if(!blocked && top.window.frameSetLoaded) {
   if(!blocked) {
		blocked = true;
        sbmButton = button.name;
        submitButtonWhenLoaded();
   }
}


function submitButtonWhenLoaded() {
    if(loaded) {
    	if (navigator.userAgent.indexOf("Mac") < 0) {
    		document.body.style.cursor = 'wait';
    	}
        disableAllButtons();
		document.forms[2].IBS_SUBMIT_ACTION.name= sbmButton;
		document.forms[2].submit();
    } else {
        loops++;
        if (loops < 720) {
	    	setTimeout("submitButtonWhenLoaded()",250);
        } else {
        	blocked = false;
	   		alert('Not ready loading page!');
        }
    } 
}

/*******************************************************************
* Submit the specfied button when the Enter key is pressed
*******************************************************************/
function submitenter(button,e) {
	var keycode;
	if (window.event) 
		keycode = window.event.keyCode;
	else if (e) 
		keycode = e.which;
	else 
		return true;
	
	if (keycode == 13) {
		submitButtonOnce(button);
		return false;
	} else
		return true;
}
/******************************************************************************
*	Submit resequence form												      *
* Note: include following input fields in jsp:				      			  *
* <INPUT NAME="IBS_RESEQUENCE_ACTION"  TYPE="HIDDEN"  VALUE="">	      	      *    
* <INPUT NAME="IBS_RESEQUENCE_COLUMN"  TYPE="HIDDEN"  VALUE="">		     	  *
* <INPUT NAME="IBS_RESEQUENCE_SEQUENCE"  TYPE="HIDDEN"  VALUE="">             *
******************************************************************************/
var prevAction = "";

var sbmResAction = null;
var sbmResCol = null;
var sbmResSeq = null;

function submitResequenceFormWhenLoaded() {
   if(loaded) {
   		if (navigator.userAgent.indexOf("Mac") < 0) {
   			document.body.style.cursor = 'wait';
   		}
		disableAllButtons();
		document.forms[2].IBS_RESEQUENCE_ACTION.name= sbmResAction;
		document.forms[2].IBS_RESEQUENCE_COLUMN.value= sbmResCol;
		document.forms[2].IBS_RESEQUENCE_SEQUENCE.value= sbmResSeq;
		document.forms[2].submit();
    } else {
        loops++;
        if (loops < 720) {
	   		setTimeout("submitResequenceFormWhenLoaded()",250);
        } else {
        	blocked = false;
	   		alert('Not ready loading page!');
        }
    } 
}

function submitResequenceForm(action,column,sequence) {
//   if(!blocked && top.window.frameSetLoaded) {
   if(!blocked) {
		if (prevAction != action) {
			blocked = true;		
			prevAction = action;		
			sbmResAction = action;
			sbmResCol = column;
			sbmResSeq = sequence;
			submitResequenceFormWhenLoaded();
		}
   }
}

function toggleResequenceImage(imageName,src) {
	if (document.images) {
	       document[imageName].src = src;
	}
} 

// ---------------------------------------------------------------------------

function invokeDestinationFrame(href) {

//	if(!top.home.blocked && top.window.frameSetLoaded) {
	if(!blocked) {
		activeHref = href;
		blocked = true;
		
        invokeDestinationFrameWhenLoaded();
	} 
}

function invokeDestinationFrameWhenLoaded() {
//	if (loaded && top.home.loaded) {
	if (loaded) {
//		top.home.location.href = activeHref;
		window.location.href = activeHref;
	} else {
		loops++;
		if (loops < 720) {
			setTimeout("invokeDestinationFrameWhenLoaded()",250);
		} else {
			blocked = false;
			alert('Not ready loading page!');
     	}
  	}
}

// ---------------------------------------------------------------------------
function submitDestinationLinkOnce(action,value) {
	
//   if(!top.home.blocked && top.window.frameSetLoaded) {
   if(!blocked) {
		blocked = true;
        sbmAction = action;
        sbmValue = value;
		submitDestinationLinkWhenLoaded();
   }
}

function submitDestinationLinkWhenLoaded() {

//    if(loaded && top.home.loaded) {
    if(loaded) {
		disableAllButtons();
		document.forms[2].IBS_LINKSELECTION_ACTION.name= sbmAction;
		document.forms[2].IBS_LINKSELECTION_VALUE.value= sbmValue;
		document.forms[2].submit();
		if (navigator.userAgent.indexOf("MSIE")!=-1
			&& navigator.userAgent.indexOf("Mac") < 0){
			document.forms[2].IBS_LINKSELECTION_VALUE.value= "";
		}
    } else {
        loops++;
        if (loops < 720) {
	    	setTimeout("submitDestinationLinkWhenLoaded()",250);
        } else {
        	blocked = false;
        	alert('Not ready loading page!');
        }
    } 
}

var listName = "";
var itemKey = null;
var action = "";
var remoteWindow = null;
function openRemoteWindow(actionValue, key, jspName,windowName,x,y,h,w) {

//	if (top.window.frameSetLoaded) {
		itemKey = key;
		action = actionValue;
		if (remoteWindow != null && !remoteWindow.closed) {// if mywindow has been opened, and mywindow hasn't already been closed
			remoteWindow.close(); //close it in order to re-assign properties
		}
    
        str = ",height=" + h + ",width=" + w + ",toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes";
		if (navigator.userAgent.indexOf("MSIE")!=-1) {
	    	str = "left=" + x + ",top=" + y + str;		
        } else {
	    	str = "screenX=" + x + ",screenY=" + y + str;
        }
        remoteWindow=open(jspName, windowName, str);
        
		// If no opener was found can happen in NetScape 2.x
    	if (remoteWindow.opener == null) {
			 remoteWindow.opener = self;
	  	}
		remoteWindow.focus() 
//	}
}

function openPopup(url,width,height) 
{
	openPopup(url,width,height, null) 
}

//function openPopup(url,width,height,args) 
//{
//	var left, top;

//	left = screen.width / 2 - width / 2;
//	top = screen.height / 2 - height / 2;
	
//		var features = "dialogWidth:" + width + "px; dialogHeight:" + height + "px; dialogLeft:" + left + "; dialogTop:" + top +
//						  "; directories:no; location:no; menubar:no; resizable:no; status:no; titlebar:no; toolbar:no";
//		return showModalDialog(url, args, features);
//}

function openPopup(url,width,height,args) 
{
	var left, top;

	left = screen.width / 2 - width / 2;
	top = screen.height / 2 - height / 2;
	
	var features;
	if (window.showModalDialog) {
		features = "dialogWidth:" + width + "px; dialogHeight:" + height + "px; dialogLeft:" + left + "; dialogTop:" + top +
						  "; directories:no; location:no; menubar:no; resizable:no; status:no; titlebar:no; toolbar:no";
		return showModalDialog(url, args, features);
	} else {
	  	features =  "height=" + height + ",width=" + width + ",directories=no,menubar=no,resizable=no,status=no,toolbar=no,scrollbars=no,modal=yes";
	  	return window.open(url,'PopUp',features);
	}
}

function fillDay(dayString)
{
	returnValue = dayString;
	window.close();
}

// ---------------------------------------------------------------------------
// Catalogue update functions
function expand(section, closePrevious) {
	if (section == top.expanded) {
		return;
	}
	if (section != null) {
		section.style.display='block';
	}
	if (top.expanded != null & closePrevious) {
		top.expanded.style.display='none';
	}
	if (closePrevious) {
		top.expanded = section;
	}
}
function highlight(object) {
	if (top.activeLink != null) {
		top.activeLink.className='';
	}
	object.className = 'active';
	top.activeLink = object;
}

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
function submitQuickSearchEnter(action,value,ev) {
	var keycode;
	if (window.event) 
		keycode = window.event.keyCode;
	else if (ev) 
		keycode = ev.which;
	else 
		return true;
	
	if (keycode == 13) {
		submitQuickSearch(action,value);
		return false;
	} else
		return true;
}
function submitQuickSearch(action,value) {
	document.forms[1].IBS_LINKSELECTION_ACTION.name= action;
	document.forms[1].IBS_LINKSELECTION_VALUE.value= value;
	document.forms[1].submit();
	if (navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Mac") < 0){
		document.forms[1].IBS_LINKSELECTION_VALUE.value= "";
	} 
}

function submitSignonHoverEnter(action,value,ev) {
	var keycode;
	if (window.event) 
		keycode = window.event.keyCode;
	else if (ev) 
		keycode = ev.which;
	else 
		return true;
	
	if (keycode == 13) {
		submitSignonHover(action,value);
		return false;
	} else
		return true;
}
function submitSignonHover(action,value) {
	document.forms[0].IBS_LINKSELECTION_ACTION.name= action;
	document.forms[0].IBS_LINKSELECTION_VALUE.value= value;
	document.forms[0].submit();
	if (navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Mac") < 0){
		document.forms[0].IBS_LINKSELECTION_VALUE.value= "";
	} 
}

function submitSignonHoverButtonOnce(button) {
   if(!blocked) {
		blocked = true;
        sbmButton = button.name;
        submitSignonHoverButtonWhenLoaded();
   }
}


function submitSignonHoverButtonWhenLoaded() {
    if(loaded) {
    	if (navigator.userAgent.indexOf("Mac") < 0) {
    		document.body.style.cursor = 'wait';
    	}
        disableAllButtons();
		document.forms[0].IBS_SUBMIT_ACTION.name= sbmButton;
		document.forms[0].submit();
    } else {
        loops++;
        if (loops < 720) {
	    	setTimeout("submitButtonWhenLoaded()",250);
        } else {
        	blocked = false;
	   		alert('Not ready loading page!');
        }
    } 
}

//function autoTab(current,to){
//	if (current.getAttribute && current.value.length==current.getAttribute("maxlength")) {
//		to.focus() 
//	}
//}
function autoTab(input, e) {
  isNN = (navigator.appName.indexOf("Netscape")!=-1);
  len = input.getAttribute("maxlength");
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
  }

  function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
  }

  function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
  }
  return true;
}
/*******************************************************************
* Submit the specfied popup link when the Enter key is pressed
*******************************************************************/
function submitPopupLinkOnEnter(action,value,qty,unit,alias,ev) {
	var keycode;
	if (window.event) 
		keycode = window.event.keyCode;
	else if (ev) 
		keycode = ev.which;
	else 
		return true;
	
	if (keycode == 13) {
		submitPopupLinkOnce(action,value,qty,unit,alias);
		return false;
	} else
		return true;
}

function submitPopupLinkOnce(action,value,qty,unit,alias) {

   if(!blocked) {
		blocked = true;
        sbmAction = action;
        sbmValue = value;
		sbmQty = qty;
		sbmUnit = unit;
		sbmAlias = alias;
       	submitLinkWhenLoaded(qty,unit,alias);
   }
}