
//-----------------------------------------Drop Down Menu----------------
/*
Drop down menu link
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="/CS2000/Portal/DSD/" class="regLink">DSD</a><br>'

//Contents for StoreReturn upc field input
var upc=new Array()
upc[0]="<font size='1'>UPC:</font><input type='text' name='txtUPC' value='' onBlur='NumbersOnly(this)' maxLength='13' size='14' class='textBoxText'>" +
	"<input type='button' name='btnUPC' value='OK' class='textBoxText' onClick='closeUPCMenu(txtUPC)'>"

//sMenuList is the array of menus ex. upc (above)
function drawMenuContent(menu, sMenuList)
{
	var sMenu, oMenuList
	oMenuList = eval(sMenuList)
	sMenu = ""
	for (i=0;i< oMenuList.length;i++){
		sMenu = sMenu + "</BR>" + oMenuList[i]}
	menu.innerHTML = sMenu
}
   	  //reusable/////////////////////////////
var zindex=100
function dropit2(whichone, psMenuList, pbRedraw, pXPos, pYPos){
var xPos, yPos

xPos = 0;
yPos = 0;
if (pXPos)
	xPos = pXPos
if (pYPos)
	yPos = pYPos
if (window.themenu&&themenu.id!=whichone.id)
themenu.style.visibility="hidden"
themenu=whichone
if (document.all){
	if (pbRedraw)
		drawMenuContent(whichone, psMenuList)
//themenu.style.left=event.clientX + 5 //-event.offsetX
//themenu.style.top= event.clientY - 90 //-event.offsetY)

themenu.style.left=document.body.scrollLeft+event.clientX-event.offsetX + xPos
//alert(event.clientY + "-" + document.body.scrollTop)
themenu.style.top=document.body.scrollTop + (event.clientY-event.offsetY) - yPos

if (themenu.style.visibility=="hidden"){
themenu.style.visibility="visible"
themenu.style.zIndex=zindex++
}
else{
hidemenu()
}
}
}

function dropit(e,whichone){
if (window.themenu&&themenu.id!=eval(whichone).id)
themenu.visibility="hide"
themenu=eval(whichone)
if (themenu.visibility=="hide")
themenu.visibility="show"
else
themenu.visibility="hide"
themenu.zIndex++
themenu.left=e.pageX-e.layerX
themenu.top=e.pageY-e.layerY
return false
}

function hidemenu(whichone){
if (window.themenu &&
	event.srcElement.type != "text" &&
	event.srcElement.type != "select-one"){
	if (themenu != menuUPC)	//if it is menuUPC do not hide when body click, force to click OK button
		themenu.style.visibility="hidden"}}

function hidemenu2(){
themenu.visibility="hide"
}

//-----------------------------------------Side Menu Visibility----------------

function showHideMenu(oDiv)
{
  if(sideMenu){
	if(sideMenu.style.visibility == "hidden"){
		sideMenu.style.visibility = "visible";
		sideMenu.style.position = "relative";
		oDiv.style.color = "white";
		writeCookie("visible");}
	else{
		sideMenu.style.visibility = "hidden";
		sideMenu.style.position = "absolute";
		oDiv.style.color = "silver";
		writeCookie("hidden");}
	}
}

function writeCookie(sValue)
{
  document.cookie = "menuVisibility=" + sValue + "; path=/UWGWeb"
  //alert(location.pathname)
}
function getCookie(label)
{
  var labelLen = label.length
  var cLen = document.cookie.length
  //alert(document.cookie)
  var i = 0
  var cEnd
  while (i < cLen)
  {
    var j = i + labelLen
    if (document.cookie.substring(i,j) == label)
      {
        cEnd = document.cookie.indexOf(";",j)
        if (cEnd == -1)
        {
          cEnd = document.cookie.length
        }
        return (unescape(document.cookie.substring(j + 1, cEnd)))
        //return (document.cookie.substring(0,document.cookie.length))
      }
      i++
  }
  return ""
}
//-----------------------------------------Begin General js----------------
function showHand(oObj)
{
	if (event.type == "mouseover")
		oObj.style.cursor = "hand"
	
}	



//Used in Print Format under Vendors Channel

function GetReadyToPrint(sPosting, sChannel, sRegion)
  {
    var newWin
    newWin = window.open("../Print Format.asp?Posting=" + sPosting + "&Channel=" + sChannel + "&Region=" + sRegion,"newWin", "width=600, height=600,scrollbars=yes,toolbar=yes, resizable=yes")
    newWin.focus()
    //alert (sChannel)
  }
function ShowLargerImage(pParam, plHeight)
{
  var iBegin, iWidth, newWin
  if (plHeight.length == 0)
    plHeight = 500 
  if (pParam.length > 50)
  {
    
    iBegin = pParam.indexOf("width%3D") + 8  //Get the width of newWin
    iWidth = (pParam.substring(iBegin, iBegin + 3))
    iWidth = parseInt(iWidth) + 20
    newWin = window.open("Enlarged+Image.asp?&ImagePath=" + pParam, "newWin","resizable=yes,  width=" + iWidth + " height=" + plHeight)
	newWin.moveTo(document.body.clientWidth/2 - (iWidth + 20)/2,document.body.clientHeight/2 - 200)
	newWin.resizeTo(iWidth + 20, plHeight)
	newWin.focus()
  }
}
function CloseWindow(Me)
{
  Me.close()
}
function NumbersOnly(Me)
{
 if (isNaN(Me.value))
 {
   alert("Please enter numbers only!")
   Me.value = ""
 }
 else
 {
  if(Me.nonzero != null) //if field has this attribute, 0 value is not allowed--
  {
   if(Me.value == 0)
   {
     alert("Value must be greater than 0!")
     Me.value = ""
   }
  }
 }
}

function focusOnThis(poForm, psFocusTarget, psFocusColor)
{
	var i
	if (!poForm)
		return false;
	//controls
	for (i=0; i<poForm.length ; i++){
		//document.write(poForm.elements[i].id)
		if (poForm.elements[i].name.toLowerCase() == psFocusTarget.toLowerCase()){
			poForm.elements[i].focus()
			if(psFocusColor != "")
				poForm.elements[i].style.background = psFocusColor
			return false;}
	}
	//links
	for (i=0; i<document.links.length ; i++){
		if (document.links[i].id.toLowerCase() == psFocusTarget.toLowerCase()){
			document.links[i].focus()
			if(psFocusColor != "")
				document.links[i].style.color = psFocusColor
			return false;}
		}

}

function highlightButton(sClassName) { 
	if (event.srcElement.tagName == "INPUT") event.srcElement.className=sClassName }

function openNewItemsCartWin(sCartType, sFileNum, sDescription, sCurrRetail, sTypeBusiness, sProductID){
	var myWindow
	
	MyWindow=window.open("/CS2000/Portal/Products/addHeadQtrItems?catalog_name=Member Catalog" +
		 "&CartType=" + sCartType + "&CatalogName1=Member Catalog" +
		"&ProductCount=1&FileNum1=" + sFileNum + "&Description1=" + sDescription + 
		"&Price1=" + sCurrRetail + "&ChkProduct1=1&ShowMenu=no" +
		"&ProductId1=" + sTypeBusiness + sProductID + "0" ,"MyWindow",
		"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=620,height=470,screenX=20,screenY=20,left=20,top=20"); 
		return false;
 
}

function openShoppingBasketWin(sTypeBusiness, sProductID, sFileNum, sCatalogName){
	var MyWindow
	
	if (!sCatalogName)
		sCatalogName = "Member Catalog"
	
	MyWindow=window.open("/uwgweb/solutionsite/StoreListNoMenu.asp?catalog_name=Member Catalog" +
		"&category_name=" + sTypeBusiness + "&product_id=" + sTypeBusiness + sProductID + "0" + 
		"&FileNum=" + sFileNum,
		"MyWindow", 
		"toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=620,height=470,screenX=20,screenY=20,left=20,top=20");
	return false;
 
}			
//Vertical Navigation
	function NavigateKey (field, event, psContainer, piControlsPerRow) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		
		if (keyCode == 38 || keyCode == 40) {
			if (keyCode == 38)
				piControlsPerRow = (piControlsPerRow) * -1
			//alert(field.id)
			//dgBasket:_ctl2:chkDelete dgBasket__ctl2_chkDelete
			var i;
			if (!field.form)	//where field is not actual control
			{
				var iRowId = parseInt(field.RowId) + 2
				var sCntl = ""
				//dgBasket__ctl2_chkDelete
				sCntl = psContainer + iRowId + "_" + field.CntlName
				field = document.getElementById(sCntl)
			}
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + piControlsPerRow) % field.form.elements.length;
			if (field.form.elements[i].canReceiveFocus)
				field.form.elements[i].focus();

			return false;	
		} 
		else
			return true;
	}    
	
	
	function DisableEnterKey (field) {
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			return false;
		} 
		else
		return true;
	}  