
window.onscroll = function() {
	var pos = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	window.status = "pos="+pos;
	//document.getElementById('left_menu').style.top = pos+'px';
};

function animateHighlights1()
{
	var obj = document.getElementById("highlight1");
	if (obj!==null) {
		document.getElementById("highlight1").style.backgroundColor = 'white';
		document.getElementById("highlight4").style.backgroundColor = '#DDC5A6';
		setTimeout("animateHighlights2();",2000);
	}
}

function animateHighlights2()
{
	document.getElementById("highlight2").style.backgroundColor = 'white';
	document.getElementById("highlight1").style.backgroundColor = '#DDC5A6';
	setTimeout("animateHighlights3();",2000);
}

function animateHighlights3()
{
	document.getElementById("highlight3").style.backgroundColor = 'white';
	document.getElementById("highlight2").style.backgroundColor = '#DDC5A6';
	setTimeout("animateHighlights4();",2000);
}

function animateHighlights4()
{
	document.getElementById("highlight4").style.backgroundColor = 'white';
	document.getElementById("highlight3").style.backgroundColor = '#DDC5A6';
	setTimeout("animateHighlights1();",3000);
}

function changeInputs()
{
	/*
	var els = document.getElementsByTagName('input');
	var elsLen = els.length;
	var i = 0;
	for ( i=0;i<elsLen;i++ )
	{
		if ( els[i].getAttribute('type') )
		{
			if ( els[i].getAttribute('type') == "text" )
			{
				els[i].className = 'text';
			}
			else if ( els[i].getAttribute('type') == "button" ) 
			{
				els[i].className = 'button';
			}
			else if ( els[i].getAttribute('type') == "submit" ) 
			{
				els[i].className = 'button';
			}
		}
	}
	*/
}

var windowVarsImage = 'top=200,left=200,height=425,width=400,titlebar=no,status=no,resizable=no,scrollbars=no,menubar=no';

function popUpImage(imageName) {
	//alert(imageName);
	window.open(imageName, '_blank', windowVarsImage);
}

var popUpImages = false;
var showIt = false;
var imageName = "";
var imageDiv = null;
var imageObj = null;
var mouseX = 0;
var mouseY = 0;
var timeoutId = 0;

function resetXY(evt) {
	if (evt.pageX) mouseX = evt.pageX;
	else if (evt.clientX) {
		mouseX = evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
	}
	
	if (evt.pageY) mouseY = evt.pageY;
	else if (evt.clientY) {
		mouseY = evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	}
	
	// Now try to center the image to cursor
	mouseX = mouseX - 150;
	mouseY = mouseY - 150;
}

function enlargeImage(inName, evt) {
	//alert(imageName);
	var tmpTarget;
	
	tmpTarget = evt.srcElement;
	
	imageDiv = document.getElementById("enlargeImageDiv");
	imageObj = document.getElementById("enlargeImageObj");
	imageName = inName;
	
	resetXY(evt);
	
	showIt = true;
	timeoutId = setTimeout('enlargeImage2();',900);
	
	return false;
}

function enlargeImage2() {
	
	if (popUpImages==true && showIt===true && imageDiv!==null && imageObj!==null && imageName!=="") {
		imageDiv.style.visibility = "visible";
		imageDiv.style.left = mouseX+"px";
		imageDiv.style.top = mouseY+"px";
	
		imageObj.style.visibility = "visible";
		imageObj.src = imageName;
		
		//showIt = false;
	}
	
	return false;
}

function hideImage() {
	showIt = false;
	clearTimeout(timeoutId);
	
	//imageName = "";
	imageDiv = null;
	imageObj = null;
	mouseX = 0;
	mouseY = 0;
}

function hideImageMain() {
	showIt = false;
	clearTimeout(timeoutId);
	
	//alert("hide");
	imageDiv = document.getElementById("enlargeImageDiv");
	imageDiv.style.visibility = "hidden";
	imageObj = document.getElementById("enlargeImageObj");
	imageObj.src = "images/blank.jpg";
	imageObj.style.visibility = "hidden";
	
	//imageName = "";
	imageDiv = null;
	imageObj = null;
	mouseX = 0;
	mouseY = 0;
}

function enlargeImage_thumb(imageName, evt) {
	//alert(imageName);
	var tmpTarget;
	
	tmpTarget = evt.srcElement;
	
	var mouseX = evt.clientX;
	var mouseY = evt.clientY;
	//alert(mouseX + " " + mouseY);
	//mouseX = 400;
	mouseX = mouseX - 50;
	mouseY = mouseY - 50;
	var imageDiv = document.getElementById("enlargeImageDiv");
	imageDiv.style.visibility = "visible";
	imageDiv.style.left = mouseX+"px";
	imageDiv.style.top = mouseY+"px";
	//imageDiv.style.left = "100px";
	//imageDiv.style.top = "100px";
	var imageObj = document.getElementById("enlargeImageObj");
	imageObj.style.visibility = "visible";
	imageObj.src = imageName;
	
	return false;
}


var windowVarsHelp = 'top=100,left=200,height=500,width=650,titlebar=no,status=no,resizable=no,scrollbars=no,menubar=no';
function help() {
	//alert(imageName);
	window.open('pages/help.jsp', '_blank', windowVarsHelp);
}

function CloseWindow() {
	this.close();
}

function automatePayPalInvoice() {
	/*
	for (var i=0;i<99999;i++)	{
		window.status = i;
	}
	*/
	
	var paypalForm = document.getElementById('paypalForm');
	if(paypalForm !== null) {
		paypalForm.submit();
	}
}

function CheckEmail(emailObj) {
  var blnGo = true;
  
  if (emailObj.value.length == 0)
    {blnGo = false;
     document.getElementById('lblEmail').innerHTML = '* Required';
    }
  else 
    {
    if (isEmail(emailObj.value) == false)
      {blnGo = false;
       document.getElementById('lblEmail').innerHTML = '* Invalid Email Address';}
    else
      {document.getElementById('lblEmail').innerHTML = '';}
    }
  
  if (blnGo == true)
    {return true;}
  else
    {return false;}
}

  var whitespace = " \t\n\r";
  
function isWhitespace (s) {
  var i;
  if (isEmpty(s)) return true;
  for (i=0; i<s.length; i++) {
    var c = s.charAt(i);
    if (whitespace.indexOf(c) == -1) return false;
  }
  return true;
}

function isEmpty(s) {
  return ((s == null) || (s.length == 0))
}

function isEmail (s) {
    if (isWhitespace(s)) return false;
  var i = 1;
  var sLength = s.length;
  while ((i < sLength) && (s.charAt(i) != "@")) {
    i++
  }
  if ((i >= sLength) || (s.charAt(i) != "@")) return false;
  else i += 2;
  while ((i < sLength) && (s.charAt(i) != ".")) {
    i++
  }
  if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
  else return true;
}



/*-------------------------------------------


Everything from common2.js 


---------------------------------------------*/

var ie5 = (document.getElementById && document.all); 
var n6 	= (document.getElementById && !document.all);

var helpWindow;
var comboNameInFocus = false;

	var WindowWidth = 1000;
	var WindowHeight = 703;
	
function InitializeNew(windowName) {

//	moveTo(0,0);
//	resizeTo(screen.width, screen.height);
//	moveTo((screen.width - WindowWidth)/2,(screen.height - WindowHeight)/2);
//	window.open('mainMenu.do', windowName, 'top=0,left=0,height=700,width=1000,status=yes,resizable=no,scrollbars=no,menubar=no');
	var newWindow = window.open('Frames.do', windowName, 'top=0,left=0,height=700,width=1000,location=no,toolbar=no,status=yes,resizable=no,scrollbars=no,menubar=no');
	//this.close();
	top.opener = top;
	top.close();
	window.close();
}

function InitializeNewWindowWithAction(action) {
	var winvargs = 'top=50,left=50,height=500,width=500,status=yes,resizable=yes,scrollbars=yes,menubar=yes';
	window.open(action, '_blank', winvargs);
}


function CloseWindow() {
	this.close();
}


//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function findRealX(ev) {
	var curleft = 0;

	if (ev.srcElement)
	{
		//customAlert("Element offset is "+ev.offsetX);
		curleft = ev.offsetX;
		var obj = ev.srcElement;
		while (obj.offsetParent)
		{
			//customAlert(obj.tagName +", additional offset is "+obj.offsetLeft);
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (ev.pageX)
		curleft = ev.pageX;

	return curleft;
}

function findRealY(ev) {
	var curtop = 0;
	
	if (ev.srcElement)
	{
		//customAlert("Element offset is "+ev.offsetY);
		curtop = ev.offsetY;
		var obj = ev.srcElement;
		
		while (obj.offsetParent)
		{
			//customAlert(obj.tagName +", additional offset is "+obj.offsetTop);
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (ev.pageY)
		curtop = ev.pageY;
	
	return curtop;
}

function findRealObjX(obj) {
	var curleft = 0;

	while (obj.offsetParent)
	{
		//customAlert(obj.tagName +", additional offset is "+obj.offsetLeft);
		curleft += obj.offsetLeft
		obj = obj.offsetParent;
	}

	return curleft;
}

function findRealObjY(obj) {
	var curtop = 0;

	while (obj.offsetParent)
	{
		//customAlert(obj.tagName +", additional offset is "+obj.offsetTop);
		curtop += obj.offsetTop
		obj = obj.offsetParent;
	}
	return curtop;
}

function findColumnX(ev) {
	var curleft;
	var obj;
	if(ie5) obj = ev.srcElement;
	if(n6) obj = ev.target;
	
	curleft = obj.offsetWidth;
	while (obj.offsetParent)
	{
		curleft += obj.offsetLeft
		obj = obj.offsetParent;
	}

	return curleft;
}

function findRowY(ev) {
	var curtop;
	var obj;
	
	if(ie5) obj = ev.srcElement;
	if(n6) obj = ev.target;
	
	curtop = obj.offsetHeight;
	
	while (obj.offsetParent)
	{
		curtop += obj.offsetTop
		obj = obj.offsetParent;
	} 	
	return curtop;
}


function findMenuBarX(obj) {
	var curleft;
	curleft = 0;
	
	while (obj.offsetParent)
	{
		curleft += obj.offsetLeft
		obj = obj.offsetParent;
	}

	return curleft;
}

function findMenuBarY(obj) {
	var curtop;
	curtop = obj.offsetHeight;
	
	while (obj.offsetParent)
	{
		curtop += obj.offsetTop
		obj = obj.offsetParent;
	} 	
	return curtop;
}

function findSubMenuX(obj) {
	var curleft;
	curleft = obj.offsetWidth;
	
	while (obj.offsetParent)
	{
		curleft += obj.offsetLeft
		obj = obj.offsetParent;
	}

	return curleft;
}

function findSubMenuY(obj) {
	var curtop;
	curtop = 0;
	
	while (obj.offsetParent)
	{
		curtop += obj.offsetTop
		obj = obj.offsetParent;
	} 	
	return curtop;
}

function disableButtons() {
	closeHelpWindow();
	showOverlay();
	return true;
}

function disableSelects() {
	var sels = document.getElementsByTagName('select');
	for(var i = 0; i < sels.length; i++) {
		sels[i].style.visibility = 'hidden';	
	}
}

function enableSelects() {
	var sels = document.getElementsByTagName('select');
	for(var i = 0; i < sels.length; i++) {
		sels[i].style.visibility = 'visible';	
	}
}

function elementContainsMouse(id, evt) {
	var el = document.getElementById(id);
	var elementLeft = findRealObjX(el);
	var elementTop = findRealObjY(el);
	
	var evtLeft = findRealX(evt);
	var evtTop = findRealY(evt);
	var result = evtLeft > elementLeft && evtLeft < (elementLeft + el.offsetWidth) && evtTop > elementTop && evtTop < (elementTop + el.offsetHeight);
	if(result) {
		window.status = "Mouse inside element";
	}else {
		window.status = "Mouse outside element";
	}
	return result;
}

function isContainedIn(node, tagName, className) {

  // Starting with the given node, find the nearest containing element
  // with the specified tag name and style class.
  //customAlert(node.tagName);
  while (node != null) {
    if (node.tagName != null && node.tagName == tagName &&
        hasClassName(node, className))
      return node;
    node = node.parentNode;
  }

  return node;
}

function hasClassName(el, name) {

  var i, list;

  // Return true if the given element currently has the given class
  // name.

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}



function hideAllMenus(evt) {
	var tmpTarget;
	var btnClicked;
	if(ie5) {
		 tmpTarget = event.srcElement;
		 evt = event;
		 btnClicked = event.button;
	}
	if(n6) {
		tmpTarget = evt.target;
		btnClicked = evt.button;
		if(btnClicked == 0) {
			btnClicked = 1;
		}
	}
	//customAlert(btnClicked);
	if(btnClicked == 1) {
		if(isContainedIn(tmpTarget, "DIV", "menuBarMenuItemFlyout") == null) {
			if(isContainedIn(tmpTarget, "SPAN", "menuBarItem") == null) {
				hideMenuBarContent(currMenuBarMenuName);
				hideSubMenu(currSubMenuName);
			}
			
			if(isContainedIn(tmpTarget, "DIV", "menuBarSubMenu") == null) {
				
			}
			if(isContainedIn(tmpTarget, "DIV", "menuBarMenu") == null) {
				hidePopupMenu();
			}
			if(isContainedIn(tmpTarget, "DIV", "lblMenu") == null) {
				//hideLabelMenu();
			}
			if(isContainedIn(tmpTarget, "DIV", "popBtns") == null) {
				//hideHoldPopup();
			}
			if(isContainedIn(tmpTarget, "SPAN", "comboAssistMenu") == null) {
				if(document.getElementById('spanComboAssist') != null) {
					hideAssistPopup();
				}
			}
			if(isContainedIn(tmpTarget, "SPAN", "comboAssistMenu") == null){
				if(document.getElementById('spanSuperComboAssist') != null){
					hideAssistPopup();
				}
			}
		} 
		
		
		
	}
}

function LTrim(str) {
	return str.replace(/^\s+/, '');
}

function RTrim(str) {
	return str.replace(/\s+$/, '');
}

function Trim(str) {
	return LTrim(RTrim(str));
}


var ac_array = null;
function autocomplete(n){
	if (n.value == "") return 0;
    if (event.keyCode == 8 && n.backspace){
        n.value = n.value.substr(0,n.value.length-1);
        n.backspace = false;
    }

    var r = n.createTextRange();    
    tmp= n.value;
    if (tmp == "")return 0;
    for (z=0;z<ac_array.length;z++){
        tmp2 = ac_array[z];
        count = 0;
        for (i = 0;i<tmp.length;i++){
            if (tmp2.toUpperCase().charAt(i) == tmp.toUpperCase().charAt(i)){
                count++
            }
        }
        if (count == tmp.length){
            diff = tmp2.length - tmp.length;
            if (diff <= 0) break;
            kap = "";
            for (i=0;i<tmp2.length;i++){
                if (i >= tmp.length) kap += tmp2.charAt(i);
            }
            n.backspace = true;
            r.text += kap;
            r.findText(kap,diff*-2);
            r.select();
            return 0;
        }
    }
    n.backspace = false;
    return 0;
}

function handleBodyKeyUp(evt) {
	if(ie5) {
		evt = window.event;
	}
	var srcElem = evt.srcElement;
	var shiftPressed = evt.shiftKey;
	
	if(!(isPlanScreen() || isComboScreen() || isCompareScreen())) return;
	
	if(evt.keyCode == 9) { //TAB
		if(!(srcElem == null || srcElem.name == null)) { 
			var gridElementPattern = /^r\d+c\d+$/;
			var isGridElement = gridElementPattern.exec(srcElem.id);
		} 
		var gridTabList = document.getElementById('gridTabList');
		if(gridTabList!=null) gridTabList = gridTabList.value.split(',');
		var menuTabList = document.getElementById('menuTabList');
		if(menuTabList!=null) menuTabList = menuTabList.value.split(',');
		var newCell = null;
		
		if(gridTabList==null || gridTabList.length<=0) {
			gridTabList = new Array("");
		}
		if(menuTabList==null || menuTabList.length<=0) {
			menuTabList = new Array("");
		}
		
		
		if(isGridElement && gridTabList[0]!="") { //we are in a grid cell
	//		customAlert("focus is on grid element");
			var index = binarySearch(gridTabList, srcElem.id);	
			if(index == 0 && !(srcElem.id == gridTabList[0])) {
				//turns out that binarySearch will return 0 if it doesn't find the string
				//AND if it is the first element.
				newCell = document.getElementById(gridTabList[0]);
			} else {
				if(shiftPressed) {
					if(index == 0) {
						var menu = document.getElementById('menuCollapsedContainer');
						if(menu==null || (menu!=null && menu.style.display == 'none')) {
							newCell = document.getElementById(menuTabList[menuTabList.length-1]);
						} else {
							newCell = document.getElementById(gridTabList[gridTabList.length-1]);
						}
					} else {
						newCell = document.getElementById(gridTabList[index-1]);
					}
				} else {
					if(index == gridTabList.length-1) {
						var menu = document.getElementById('menuCollapsedContainer');
						if(menu==null || (menu != null && menu.style.display == 'none')) {
							newCell = document.getElementById(menuTabList[0]);
						} else {
							newCell = document.getElementById(gridTabList[0]);
						}
					} else {
						newCell = document.getElementById(gridTabList[index+1]);
					}
				}
			}
			endEvent(evt);	
		} else { //Not a grid element.
			var index = 0;
			if(!shiftPressed) {
				newCell = document.getElementById(menuTabList[0]);
				for(var i=0;i<menuTabList.length;i++) {
					//find the element if it is on the list.
					if(menuTabList[i] == srcElem.id) {
						if(i<menuTabList.length-1)	newCell = document.getElementById(menuTabList[i+1]);
						else if(gridTabList[0]!="") newCell = document.getElementById(gridTabList[0]);
					}
				}
			} else {
				newCell = document.getElementById(menuTabList[menuTabList.length-1]);
				for(var i=menuTabList.length-1; i>=0; i--) {
					if(menuTabList[i] == srcElem.id) {
						if(i>0) newCell = document.getElementById(menuTabList[i-1]);
						else if(gridTabList[0]!="") newCell = document.getElementById(gridTabList[gridTabList.length-1]);
						else newCell = document.getElementById(menuTabList[menuTabList.length-1]);
					}
				}
			}
			endEvent(evt);	
		}
		
		
		if(newCell != null) {
			try {
				newCell.focus();
			} catch(err) {
				try {
					var menu = document.getElementById('menuCollapsedContainer');
					if(menu==null || (menu != null && menu.style.display == 'none')) {
						newCell = document.getElementById(menuTabList[0]);
					} else {
						newCell = document.getElementById(gridTabList[0]);
					}
					newCell.focus();
				} catch(err2) {}
			}
		} else {
			newCell = document.getElementById(menuTabList[0]);
			try {
				newCell.focus();
			} catch(err) {
				//do nothing
			}
		}
	}
	
}

function endEvent(evt) {

	if(ie5) {
		evt.returnValue = false;
	}
	if(n6) {
		if(evt.cancelable) {
			evt.preventDefault();
		}
	}

}

function setCursorPointer(obj) {
	obj.style.cursor='pointer';
}
function setCursorNormal(obj) {
	obj.style.cursor='default';
}

function isNumeric(sText, pure) {
	sText = sText.replace(/,/g, '');
	if(sText != '') {
		reNumeric = /^-?\d*\.?\d*$/;
		reDigitsOnly = /^\d*$/;
		
		if(pure == null || pure == false) {
			return sText.match(reNumeric);
		}else {
			return sText.match(reDigitsOnly);
		}
	}else {
		return false;
	}
}

function checkIfNumeric(inObj) {
	if ( !isNumeric(inObj.value) ) {
		customAlert('Numbers Only: ' +  inObj.value + ' is not a number.');
		inObj.focus();
		inObj.select();
	}
}

function checkIfNumericWhole(inObj) {
	if ( !isNumeric(inObj.value,true) ) {
		customAlert('Whole Numbers Only: ' +  inObj.value + ' is not a whole number.');
		inObj.focus();
		inObj.select();
	}
}

var delayCurveAssist;


function showAssistPopup() {
	var menu = document.getElementById('spanSuperComboAssist');
	var txtField = document.getElementById('txtSuperComboName');
	
	x = findRealObjX(txtField);
	y = findRealObjY(txtField) + txtField.offsetHeight;
	
	//customAlert("overlay " + overlay);
	//customAlert("comboNameInFocus " + comboNameInFocus);
	//customAlert("Showing menu . . .");
	if(!overlay && comboNameInFocus) {
		menu.style.top=y+"px";
		menu.style.left=x+"px";
		menu.style.visibility = "visible";	
	}
}

function hideAssistPopup() {
	var menu = document.getElementById('spanSuperComboAssist');
	if(menu != null) {
		menu.style.top = '0px';
		menu.style.left = '0px';
		menu.style.visibility = 'hidden';
		menu.innerHTML = "Loading ...";
	}
}

function brandShowComboList() {	
	comboNameInFocus = true;
		var brandId = document.getElementById('menuBrand').value;
		
		showAssistPopup();
		var params = "brandId="+brandId+"&comboName="+"&type=brand";

	
	sndReq('comboAssist', params);
}

function brandComboAssist() {
	
	var stub = document.getElementById('txtSuperComboName').value;


	var brandId = document.getElementById('menuBrand').value;

	if(stub != '') {
		showAssistPopup();
		var params = "brandId="+brandId+"&comboName="+stub+"&type=brand";
		sndReq('comboAssist', params);
	}else {
		hideAssistPopup();
	}

}

function brandHandleComboNameKeyDown(evt) {
	if(ie5) evt = window.event;
	comboNameInFocus = true;
	
	if(evt.keyCode == 13) {
		clickRetrieveData();
	}else if(evt.keyCode == 40) {
		if(document.getElementById('spanSuperComboAssist').style.visibility == 'visible') {
			document.getElementById('comboAssist').focus();
		}
	}else if(evt.keyCode == 27) {
		hideAssistPopup();
		preventEvent(evt);
	} else if(evt.keyCode == 9) {
		hideAssistPopup();
	} else {
		if(delayCurveAssist != null) {
			window.clearTimeout(delayCurveAssist);
		}
		delayCurveAssist = window.setTimeout("brandComboAssist();", 500);
	}
}

function companyShowComboList() {	
	comboNameInFocus = true;
		var companyId = document.getElementById('menuCompany').value;
		
		showAssistPopup();
		var params = "companyId="+companyId+"&comboName="+"&type=company";

	
	sndReq('comboAssist', params);
}

function companyComboAssist() {
	//var type = document.getElementById('comboFlag');//test if using brand
	//customAlert(type.value);
	//var company = document.getElementById('companyFlag');//test if using company
	var stub = document.getElementById('txtSuperComboName').value;


	var companyId = document.getElementById('menuCompany').value;
	
	if(stub != '') {
		showAssistPopup();
		var params = "companyId="+companyId+"&comboName="+stub+"&type=company";
		sndReq('comboAssist', params);
	}else {
		hideAssistPopup();
	}

}

function companyHandleComboNameKeyDown(evt) {
	if(ie5) evt = window.event;
	comboNameInFocus = true;
	
	if(evt.keyCode == 13) {
		clickRetrieveData();
	}else if(evt.keyCode == 40) {
		if(document.getElementById('spanSuperComboAssist').style.visibility == 'visible') {
			document.getElementById('comboAssist').focus();
		}
	}else if(evt.keyCode == 27) {
		hideAssistPopup();
		preventEvent(evt);
	} else if(evt.keyCode == 9) {
		hideAssistPopup();
	} else {
		if(delayCurveAssist != null) {
			window.clearTimeout(delayCurveAssist);
		}
		delayCurveAssist = window.setTimeout("companyComboAssist();", 500);
	}
}
function handleComboNameListKeyDown(evt) {
	if(ie5) evt = window.event;
	
	if(evt.keyCode == 13) {
		populateComboName();
	}else if(evt.keyCode == 27) {
		var comboName = document.getElementById('txtSuperComboName');
		comboName.focus();
		hideAssistPopup();
	}
}
	
function populateComboName() {
	//customAlert("Setting value . . .");
	var selAssist = document.getElementById('comboAssist');
	var comboName = document.getElementById('txtSuperComboName');
	
	comboName.value = selAssist.value;
	hideAssistPopup();
	comboName.focus();
}
	
function clearComboName() {
	var comboName = document.getElementById('txtSuperComboName');
	
	comboName.value = "";
	hideAssistPopup();
}


function preventEvent(evt) {
	if(ie5) {
		evt.returnValue = false;
	}
	if(n6) {
		if(evt.cancelable) {
			evt.preventDefault();
		}
	}
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function sortNumber(a, b) {
	return a - b;
}

function handleComboBlur(inObj) {
	comboNameInFocus = false;
	if (inObj != null && inObj.value.length > 0) {
		inObj.value = inObj.value.toUpperCase();
	}
}

