/*              Utility functions                    */
  var thisPriceValue5Shown = false
  var thisPriceValue10Shown = false
  var thisPriceValue25Shown = false
  var thisPriceValue50Shown = false



Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};


function addEvent( obj, type, fn ) {
try {
		if (obj.addEventListener) {
			obj.addEventListener( type, fn, false );
			EventCache.add(obj, type, fn);
		}
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
			obj.attachEvent( "on"+type, obj[type+fn] );
			EventCache.add(obj, type, fn);
		}
		else {
			obj["on"+type] = obj["e"+type+fn];
		}
  } catch (e) {
    //alert('addEventERROR');
  }
}
	
var EventCache = function(){
try {
		var listEvents = [];
		return {
			listEvents : listEvents,
			add : function(node, sEventName, fHandler){
				listEvents.push(arguments);
			},
			flush : function(){
				var i, item;
				for(i = listEvents.length - 1; i >= 0; i = i - 1){
					item = listEvents[i];
					if(item[0].removeEventListener){
						item[0].removeEventListener(item[1], item[2], item[3]);
					};
					if(item[1].substring(0, 2) != "on"){
						item[1] = "on" + item[1];
					};
					if(item[0].detachEvent){
						item[0].detachEvent(item[1], item[2]);
					};
					item[0][item[1]] = null;
					};
		}
		};
  } catch (e) {
    alert('EventCacheERROR');
  }
}();
addEvent(window,'unload',EventCache.flush);

//function addEvent(obj, evType, fn){
//  /* adds an eventListener for browsers which support it
//  Written by Scott Andrew: nice one, Scott */
//  if (obj.addEventListener){
//    obj.addEventListener(evType, fn, true);
//    return true;
//  } else if (obj.attachEvent){
//    var r = obj.attachEvent("on"+evType, fn);
//    return r;
//  } else {
//    return false;
//  }
//}



// BEGIN script_sniffer.js

function Browser(){var ua,s,i,Count;this.isOpera=false;this.isIE=false;this.isNS=false;this.isModern=false;this.Width=null;this.Height=null;this.version=null;blnLoop=true;if(document.getElementById){this.isModern=true;ua=navigator.userAgent;for(Count=1;Count<2;Count++){s="Opera";if((i=ua.indexOf(s))>=0){this.isOpera=true;this.version=parseFloat(ua.substr(i+s.length));if(this.version<7){this.isModern=false;}break;}s="MSIE";if((i=ua.indexOf(s))>=0){this.isIE=true;this.version=parseFloat(ua.substr(i+s.length));break;}s="Netscape6/";if((i=ua.indexOf(s))>=0){this.isNS=true;this.version=parseFloat(ua.substr(i+s.length));break;}s="Netscape7/";if((i=ua.indexOf(s))>=0){this.isNS=true;this.version=parseFloat(ua.substr(i+s.length));break;}s="Gecko";if((i=ua.indexOf(s))>=0){this.isNS=true;this.version=6.1;break;}blnLoop=false;break;}}if(document.documentElement&&document.documentElement.clientHeight&&(this.isOpera==false)){this.Height=document.documentElement.clientHeight;this.Width=document.documentElement.clientWidth;}else if(document.body&&document.body.clientHeight){this.Height=document.body.clientHeight;this.Width=document.body.clientWidth;}else if(window.innerHeight){this.Height=window.innerHeight;this.Width=window.innerWidth;}else{this.Height=1;this.Width=1;}}var objBrowser=new Browser();

// END script_sniffer.js

// BEGIN script_menubar.js

//old
//var activeButton=null;var activeButtonName="";var whythisneeded=0;var CurrentWidth=0;var zindex=102;if(objBrowser.isIE)document.onmousedown=pageMousedown;else document.addEventListener("mousedown",pageMousedown,true);function pageMousedown(event){var el;if(activeButton==null)return;if(objBrowser.isIE)el=window.event.srcElement;else el=(event.target.tagName?event.target:event.target.parentNode);if(el==activeButton)return;if(getContainerWith(el,"DIV","menu")==null){resetButton(activeButton,true);activeButton=null;}}function buttonClick(event,menuId){var button;if(objBrowser.isIE)button=window.event.srcElement;else button=event.currentTarget;button.blur();if(button.menu==null){if(menuId!=""){button.menu=document.getElementById(menuId);if(button.menu.isInitialized==null)menuInit(button.menu);}}if(activeButton!=null)resetButton(activeButton,true);if(button!=activeButton){depressButton(button);activeButton=button;}else activeButton=null;return false;}function buttonMouseover(event,menuId){var button;if(objBrowser.isIE)button=window.event.srcElement;else button=event.currentTarget;if(activeButton!=null&&activeButton!=button)whythisneeded=1;buttonClick(event,menuId);}function depressButton(button){var x,y;if(activeButton!=null)resetButton(activeButton,true);activeButtonName=button.parentElement.parentElement.className;activeButtonName=activeButtonName.replace(/\D/gi,"");button.parentElement.parentElement.className+=" menuButtonHighlight"+activeButtonName;CurrentWidth=button.parentElement.parentElement.offsetWidth;if(button.onmouseout==null)button.onmouseout=buttonOrMenuMouseout;if(button.menu==null)return;if(button.menu.onmouseout==null)button.menu.onmouseout=buttonOrMenuMouseout;x=getPageOffsetLeft(button);if(objBrowser.isIE){x=getPageOffsetLeft(button)-1;y=getPageOffsetTop(button)+button.offsetHeight;}else{x=getPageOffsetLeft(button);y=getPageOffsetTop(button)+button.offsetHeight;}if(objBrowser.isIE){x+=button.offsetParent.clientLeft;y+=button.offsetParent.clientTop;}button.menu.style.left=x+"px";button.menu.style.top=y+"px";for(loop=0;loop<button.menu.children.length;loop++){button.menu.children[loop].style.width=(button.parentElement.parentElement.offsetWidth-17)+"px";}CurrentWidth=button.menu.offsetWidth;for(loop=0;loop<button.menu.children.length;loop++){button.menu.children[loop].style.width=CurrentWidth-18+"px";}button.menu.style.visibility="visible";zindex=103;button.menu.style.zIndex=zindex;}function resetButton(button,blnClearMain){if(blnClearMain==true){removeClassName(getContainerWith(activeButton,"DIV","menuButton"),"menuButtonHighlight"+activeButtonName);removeClassName(activeButton,"menuButtonHighlight"+activeButtonName);}if(button.menu!=null){closeSubMenu(button.menu);button.menu.style.visibility="hidden";}}function menuMouseover(event){var menu;if(objBrowser.isIE)menu=getContainerWith(window.event.srcElement,"DIV","menu");else menu=event.currentTarget;if(menu.activeItem!=null)closeSubMenu(menu);}function menuItemMouseover(event,menuId){var item,menu,x,y;if(objBrowser.isIE)item=getContainerWith(window.event.srcElement,"A","menuItem");else item=event.currentTarget;menu=getContainerWith(item,"DIV","menu");if(menu.activeItem!=null)closeSubMenu(menu);menu.activeItem=item;item.className+=" menuItemHighlight"+activeButtonName;if(item.subMenu==null){item.subMenu=document.getElementById(menuId);if(item.subMenu.isInitialized==null)menuInit(item.subMenu);}if(activeButton==null){if(button.onmouseout==null)button.onmouseout=buttonOrMenuMouseout;if(button==activeButton)return false;}x=getPageOffsetLeft(item)+item.offsetWidth-15;y=getPageOffsetTop(item)+12;var maxX,maxY;if(objBrowser.isNS){maxX=window.scrollX+window.innerWidth;maxY=window.scrollY+window.innerHeight;}if(objBrowser.isIE){maxX=(document.documentElement.scrollLeft!=0?document.documentElement.scrollLeft:document.body.scrollLeft)+(document.documentElement.clientWidth!=0?document.documentElement.clientWidth:document.body.clientWidth);maxY=(document.documentElement.scrollTop!=0?document.documentElement.scrollTop:document.body.scrollTop)+(document.documentElement.clientHeight!=0?document.documentElement.clientHeight:document.body.clientHeight);}maxX-=item.subMenu.offsetWidth;maxY-=item.subMenu.offsetHeight;if(x>maxX)x=Math.max(0,x-item.offsetWidth-item.subMenu.offsetWidth+(menu.offsetWidth-item.offsetWidth)+26);y=Math.max(0,Math.min(y,maxY));item.subMenu.style.left=x+"px";item.subMenu.style.top=y+"px";item.subMenu.style.visibility="visible";zindex+=1;item.subMenu.style.zIndex=zindex;if(objBrowser.isIE)window.event.cancelBubble=true;else event.stopPropagation();}function closeSubMenu(menu){if(menu==null||menu.activeItem==null)return;if(menu.activeItem.subMenu!=null){closeSubMenu(menu.activeItem.subMenu);menu.activeItem.subMenu.style.visibility="hidden";menu.activeItem.subMenu=null;}removeClassName(menu.activeItem,"menuItemHighlight"+activeButtonName);menu.activeItem=null;}function buttonOrMenuMouseout(event){var el;if(activeButton==null)return;if(objBrowser.isIE)el=window.event.toElement;else if(event.relatedTarget!=null)el=(event.relatedTarget.tagName?event.relatedTarget:event.relatedTarget.parentNode);if(getContainerWith(el,"DIV","menu")==null){resetButton(activeButton,true);activeButton=null;}}function menuInit(menu){var itemList,spanList;var textEl,arrowEl;var itemWidth;var w,dw;var i,j;if(objBrowser.isIE){spanList=menu.getElementsByTagName("SPAN");for(i=0;i<spanList.length;i++)if(hasClassName(spanList[i],"menuItemArrow")){spanList[i].style.fontFamily="Webdings";spanList[i].firstChild.nodeValue="4";}}itemList=menu.getElementsByTagName("A");if(itemList.length>0)itemWidth=itemList[0].offsetWidth;else return;for(i=0;i<itemList.length;i++){spanList=itemList[i].getElementsByTagName("SPAN");textEl=null;arrowEl=null;for(j=0;j<spanList.length;j++){if(hasClassName(spanList[j],"menuItemText"))textEl=spanList[j];if(hasClassName(spanList[j],"menuItemArrow"))arrowEl=spanList[j];}if(textEl!=null&&arrowEl!=null)textEl.style.paddingRight=((itemWidth-(textEl.offsetWidth+arrowEl.offsetWidth))-16)+"px";}if(objBrowser.isIE){w=itemList[0].offsetWidth;itemList[0].style.width=w+"px";dw=itemList[0].offsetWidth-w;w-=dw;itemList[0].style.width=w+"px";}menu.isInitialized=true;}function getContainerWith(node,tagName,className){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;list=el.className.split(" ");for(i=0;i<list.length;i++)if(list[i]==name)return true;return false;}function removeClassName(el,name){var i,curList,newList;if(el.className==null)return;newList=new Array();curList=el.className.split(" ");for(i=0;i<curList.length;i++)if(curList[i]!=name)newList.push(curList[i]);el.className=newList.join(" ");}function getPageOffsetLeft(el){var x;x=el.offsetLeft;if(el.offsetParent!=null)x+=getPageOffsetLeft(el.offsetParent);return x;}function getPageOffsetTop(el){var y;y=el.offsetTop;if(el.offsetParent!=null)y+=getPageOffsetTop(el.offsetParent);return y;}function findPosX(obj){var curleft=0;if(obj.offsetParent){while(obj.offsetParent){curleft+=obj.offsetLeft;obj=obj.offsetParent;}}else if(obj.x)curleft+=obj.x;return curleft;}function findPosY(obj){var curtop=0;if(obj.offsetParent){while(obj.offsetParent){curtop+=obj.offsetTop;obj=obj.offsetParent;}}else if(obj.y)curtop+=obj.y;return curtop;}

var activeButton=null;var activeButtonName="";var whythisneeded=0;var CurrentWidth=0;var zindex=102;if(objBrowser.isIE)document.onmousedown=pageMousedown;else document.addEventListener("mousedown",pageMousedown,true);function pageMousedown(event){var el;if(activeButton==null)return;if(objBrowser.isIE)el=window.event.srcElement;else el=(event.target.tagName?event.target:event.target.parentNode);if(el==activeButton)return;if(getContainerWith(el,"DIV","menu")==null){resetButton(activeButton,true);activeButton=null;}}function buttonClick(event,menuId){var button;if(objBrowser.isIE)button=window.event.srcElement;else button=event.currentTarget;button.blur();if(button.menu==null){if(menuId!=""){button.menu=document.getElementById(menuId);if(button.menu.isInitialized==null)menuInit(button.menu);}}if(activeButton!=null)resetButton(activeButton,true);if(button!=activeButton){depressButton(button);activeButton=button;}else activeButton=null;return false;}function buttonMouseover(event,menuId){var button;if(objBrowser.isIE)button=window.event.srcElement;else button=event.currentTarget;if(activeButton!=null&&activeButton!=button)whythisneeded=1;buttonClick(event,menuId);}function depressButton(button){var x,y;if(activeButton!=null)resetButton(activeButton,true);activeButtonName=button.parentElement.parentElement.className;activeButtonName=activeButtonName.replace(/\D/gi,"");button.parentElement.parentElement.className+=" menuButtonHighlight"+activeButtonName;CurrentWidth=button.parentElement.parentElement.offsetWidth;if(button.onmouseout==null)button.onmouseout=buttonOrMenuMouseout;if(button.menu==null)return;if(button.menu.onmouseout==null)button.menu.onmouseout=buttonOrMenuMouseout;x=getPageOffsetLeft(button);if(objBrowser.isIE){x=getPageOffsetLeft(button)-1;y=getPageOffsetTop(button)+button.offsetHeight;}else{x=getPageOffsetLeft(button);y=getPageOffsetTop(button)+button.offsetHeight;}if(objBrowser.isIE){x+=button.offsetParent.clientLeft;y+=button.offsetParent.clientTop;}button.menu.style.left=x+"px";button.menu.style.top=y+"px";for(loop=0;loop<button.menu.children.length;loop++)button.menu.style.visibility="visible";zindex=103;button.menu.style.zIndex=zindex;}function resetButton(button,blnClearMain){if(blnClearMain==true){removeClassName(getContainerWith(activeButton,"DIV","menuButton"),"menuButtonHighlight"+activeButtonName);removeClassName(activeButton,"menuButtonHighlight"+activeButtonName);}if(button.menu!=null){closeSubMenu(button.menu);button.menu.style.visibility="hidden";}}function menuMouseover(event){var menu;if(objBrowser.isIE)menu=getContainerWith(window.event.srcElement,"DIV","menu");else menu=event.currentTarget;if(menu.activeItem!=null)closeSubMenu(menu);}function menuItemMouseover(event,menuId){var item,menu,x,y;if(objBrowser.isIE)item=getContainerWith(window.event.srcElement,"A","menuItem");else item=event.currentTarget;menu=getContainerWith(item,"DIV","menu");if(menu.activeItem!=null)closeSubMenu(menu);menu.activeItem=item;item.className+=" menuItemHighlight"+activeButtonName;if(item.subMenu==null){item.subMenu=document.getElementById(menuId);if(item.subMenu.isInitialized==null)menuInit(item.subMenu);}if(activeButton==null){if(button.onmouseout==null)button.onmouseout=buttonOrMenuMouseout;if(button==activeButton)return false;}x=getPageOffsetLeft(item)+item.offsetWidth-15;y=getPageOffsetTop(item)+12;var maxX,maxY;if(objBrowser.isNS){maxX=window.scrollX+window.innerWidth;maxY=window.scrollY+window.innerHeight;}if(objBrowser.isIE){maxX=(document.documentElement.scrollLeft!=0?document.documentElement.scrollLeft:document.body.scrollLeft)+(document.documentElement.clientWidth!=0?document.documentElement.clientWidth:document.body.clientWidth);maxY=(document.documentElement.scrollTop!=0?document.documentElement.scrollTop:document.body.scrollTop)+(document.documentElement.clientHeight!=0?document.documentElement.clientHeight:document.body.clientHeight);}maxX-=item.subMenu.offsetWidth;maxY-=item.subMenu.offsetHeight;if(x>maxX)x=Math.max(0,x-item.offsetWidth-item.subMenu.offsetWidth+(menu.offsetWidth-item.offsetWidth)+26);y=Math.max(0,Math.min(y,maxY));item.subMenu.style.left=x+"px";item.subMenu.style.top=y+"px";item.subMenu.style.visibility="visible";zindex+=1;item.subMenu.style.zIndex=zindex;if(objBrowser.isIE)window.event.cancelBubble=true;else event.stopPropagation();}function closeSubMenu(menu){if(menu==null||menu.activeItem==null)return;if(menu.activeItem.subMenu!=null){closeSubMenu(menu.activeItem.subMenu);menu.activeItem.subMenu.style.visibility="hidden";menu.activeItem.subMenu=null;}removeClassName(menu.activeItem,"menuItemHighlight"+activeButtonName);menu.activeItem=null;}function buttonOrMenuMouseout(event){var el;if(activeButton==null)return;if(objBrowser.isIE)el=window.event.toElement;else if(event.relatedTarget!=null)el=(event.relatedTarget.tagName?event.relatedTarget:event.relatedTarget.parentNode);if(getContainerWith(el,"DIV","menu")==null){resetButton(activeButton,true);activeButton=null;}}function menuInit(menu){var itemList,spanList;var textEl,arrowEl;var itemWidth;var w,dw;var i,j;if(objBrowser.isIE){spanList=menu.getElementsByTagName("SPAN");for(i=0;i<spanList.length;i++)if(hasClassName(spanList[i],"menuItemArrow")){spanList[i].style.fontFamily="Webdings";spanList[i].firstChild.nodeValue="4";}}itemList=menu.getElementsByTagName("A");if(itemList.length>0)itemWidth=itemList[0].offsetWidth;else return;for(i=0;i<itemList.length;i++){spanList=itemList[i].getElementsByTagName("SPAN");textEl=null;arrowEl=null;for(j=0;j<spanList.length;j++){if(hasClassName(spanList[j],"menuItemText"))textEl=spanList[j];if(hasClassName(spanList[j],"menuItemArrow"))arrowEl=spanList[j];}if(textEl!=null&&arrowEl!=null)textEl.style.paddingRight=((itemWidth-(textEl.offsetWidth+arrowEl.offsetWidth))-16)+"px";}if(objBrowser.isIE){w=itemList[0].offsetWidth;itemList[0].style.width=w+"px";dw=itemList[0].offsetWidth-w;w-=dw;itemList[0].style.width=w+"px";}menu.isInitialized=true;}function getContainerWith(node,tagName,className){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;list=el.className.split(" ");for(i=0;i<list.length;i++)if(list[i]==name)return true;return false;}function removeClassName(el,name){var i,curList,newList;if(el.className==null)return;newList=new Array();curList=el.className.split(" ");for(i=0;i<curList.length;i++)if(curList[i]!=name)newList.push(curList[i]);el.className=newList.join(" ");}function getPageOffsetLeft(el){var x;x=el.offsetLeft;if(el.offsetParent!=null)x+=getPageOffsetLeft(el.offsetParent);return x;}function getPageOffsetTop(el){var y;y=el.offsetTop;if(el.offsetParent!=null)y+=getPageOffsetTop(el.offsetParent);return y;}function findPosX(obj){var curleft=0;if(obj.offsetParent){while(obj.offsetParent){curleft+=obj.offsetLeft;obj=obj.offsetParent;}}else if(obj.x)curleft+=obj.x;return curleft;}function findPosY(obj){var curtop=0;if(obj.offsetParent){while(obj.offsetParent){curtop+=obj.offsetTop;obj=obj.offsetParent;}}else if(obj.y)curtop+=obj.y;return curtop;}


// END script_menubar.js


// BEGIN script_core.js


var MainTop = 0;
var sentGUID ;
var storedGUID ;
//var ContentTop = 34;
var ContentTop = 42;
var ContentMinusHeight = 0;
//var ContentBoxHeight = 44;
//var ContentBoxHeight = 39;
var ContentBoxHeight = 37;
var varBrowserHeight = objBrowser.Height;
var varBrowserWidth = objBrowser.Width;
var ContentHeight = 0;
var thisPage;
var s = document.location.href.split("/"); 

var isNotPrintPage = document.location.href.indexOf('printer=true');
//alert(isNotPrintPage);
//if (isNotPrintPage==-1)
//else
//}

thisPage = document.location.href.indexOf('/cart/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/wholesalecart/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/shippingprefs/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/shippingspeed/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/optionalprefs/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/neworexistingcustomer/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/newcustomer/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/updatecustomer/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/shippingaddress/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/addnewaddress/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/updateaddress/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/choosecc/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/choosepaymentmethod/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/addcc/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/updatecc/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/finalcheckout/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/checkoutcompleted/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/admin/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/getstuff/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/existinglogins/');
if (thisPage > 0)
{
  ContentTop = 110;
}

thisPage = document.location.href.indexOf('/addnewlogins/');
if (thisPage > 0)
{
  ContentTop = 110;
}



if (isNotPrintPage==-1) {
  if (objBrowser.isModern) {
    _addDOM() ;
  }
}

function _addDOM() {
  var head = document.getElementsByTagName("head").item(0);
  var elm = document.createElement("link");
  elm.setAttribute("href", "/navscripts/domstyles.css");
  elm.setAttribute("rel", "stylesheet");
  elm.setAttribute("type", "text/css");
  elm.setAttribute("title", "DOMDefault");
  elm.setAttribute("media", "screen");
  head.appendChild(elm);

      //if (objBrowser.isIE) {
        var head = document.getElementsByTagName("head").item(0);
        var elm = document.createElement("link");
        elm.setAttribute("href", "/navscripts/domstyles_ie.css");
        elm.setAttribute("rel", "stylesheet");
        elm.setAttribute("type", "text/css");
        elm.setAttribute("title", "DOM_IE");
        elm.setAttribute("media", "screen");
        head.appendChild(elm);
      //}
}


function saveUserData(){
  var objStoreElem = document.getElementById('spnUserData') ;
  var oTimeNow = new Date(); // Start Time
  oTimeNow.setMinutes(oTimeNow.getMinutes() + 131400); // # minutes in 3 months
  var sExpirationDate = oTimeNow.toUTCString();
  objStoreElem.expires = sExpirationDate;
  objStoreElem.save("PageData");
  //document.all[objStoreElem].save("PageData");
}

function addUserDataElement(objUElemName, objUElemValue){
  var objStoreElem = document.getElementById('spnUserData') ;
  objStoreElem.setAttribute( objUElemName,objUElemValue);
  //document.all[objStoreElem].setAttribute( objUElemName,objUElemValue);
}

function getUserDataElement(objElemName){
  var objStoreElemName = document.getElementById('spnUserData') ;
  var res = objStoreElemName.getAttribute(objElemName);
  //var res = document.all[objStoreElemName].getAttribute(objElemName);
  return res;
}

function removeUserDataElement(objStoreElemName, objElemName){
  //document.all[objStoreElemName].removeAttribute(objElemName);
  objStoreElemName.removeAttribute(objElemName);
}

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function ResizeMain() {

  if( document.documentElement && document.documentElement.clientHeight && (objBrowser.isOpera == false)) {
    objBrowser.Height = document.documentElement.clientHeight;
    objBrowser.Width = document.documentElement.clientWidth;
  }
  else if( document.body && document.body.clientHeight) {
    objBrowser.Height = document.body.clientHeight;
    objBrowser.Width = document.body.clientWidth;
  }
  else if( window.innerHeight ) {
    objBrowser.Height = window.innerHeight;
    objBrowser.Width = window.innerWidth;
  }
  else {
    objBrowser.Height = 1;
    objBrowser.Width = 1;
  }

  varBrowserHeight = objBrowser.Height;
  varBrowserWidth = objBrowser.Width;

  var varContainerHeight = (varBrowserHeight - (ContentTop + ContentMinusHeight));

  if (isNotPrintPage==-1) {
    var thisDiv = document.getElementById('pvMenuBar').style;
    thisDiv.width = varBrowserWidth + "px";

    var thisDiv = document.getElementById('container').style;
    thisDiv.position = "absolute";
    thisDiv.visibility = "visible";
    thisDiv.top = ContentTop + "px";
    thisDiv.left = "0px";
    thisDiv.width = varBrowserWidth + "px";
    ContentHeight = thisDiv.height;
    thisDiv.height = varContainerHeight + "px";
    //if (s.length <= 4) {
    //  //signifies home page
      thisDiv.overflow = "auto";
    //}


    //var thisDiv = document.getElementById('AddToCartDiv').style;
    //thisDiv.width = "300px";

    //var thisCell = document.getElementById('RowCellAddButton');
    //thisCell.setAttribute("width", 104);

    //var thisTable = document.getElementById('AddToCartTable');
    //thisTable.setAttribute("width", varBrowserWidth - 170);

    var thisDiv = document.getElementById('main').style;
    thisDiv.height = varContainerHeight + "px";

    //if (s.length > 4) {
    //  //NOT home page
    //  thisDiv.overflow = "auto";
    //}
    
    //var thisDiv = document.getElementById('sectionHeading').style;
    //thisDiv.width = (varBrowserWidth - 232) + "px";
  }
  

  if ((objBrowser.isModern) && (objBrowser.isIE))
  {
    try { 
      var thisSpan = document.getElementById('thisGUID');

      sentGUID = thisSpan.innerHTML ;
      //if (sentGUID != null)
      //{
      //  alert('sentGUID: ' + sentGUID);
      //}
      var objStoreElem = document.getElementById('spnUserData') ;
      if (objStoreElem != null)
      {
        objStoreElem.load("PageData");
        //document.all[objStoreElem].load("PageData");
      }
      else
      {
        //alert('spnUserData no fetched');
      }

      storedGUID = getUserDataElement('myGUID') ;
      if (storedGUID != null)
      {
        //alert('storedGUID: ' + storedGUID);
      }
      else
      {
        if (sentGUID != null)
        {
          addUserDataElement('myGUID', sentGUID);
          saveUserData();
        }
      }


      if ((storedGUID != null) && (storedGUID != sentGUID))
      {
        //BEFORE
        //alert('getCookie: ' + getCookie('aliasIdentity'));
        //alert('getCookie: ' + getCookie('aliasIdentitySession'));
        var nowTime = new Date();
        var thisExpirationDate = new Date(nowTime.getTime() + 1000 * 60 * 60 * 24 * 92); //92 days
        if (s[2] == 'localhost') //for local testing, no domain specified
        {
          setCookie('aliasIdentity', storedGUID, thisExpirationDate, '/', null, false) ;
          setCookie('aliasIdentitySession', storedGUID, null, '/', null, false) ;
        }
        else
        {
          setCookie('aliasIdentity', storedGUID, thisExpirationDate, '/', '.aircomparts-air-compressors.com', false) ;
          setCookie('aliasIdentitySession', storedGUID, null, '/', '.aircomparts-air-compressors.com', false) ;
        }
        //AFTER
        //alert('getCookie: ' + getCookie('aliasIdentity'));
        //alert('getCookie: ' + getCookie('aliasIdentitySession'));
      }

    } 
    catch(er) {
    } 
  }

	for (var i = 0; (currTag = document.getElementsByTagName("link")[i]); i++)
	{
		if (currTag.getAttribute("rel").indexOf("style") != -1 && currTag.getAttribute("title"))
		{
			if(currTag.getAttribute("title") == "LegacySizeStyleSheet")
			{
        if (varBrowserWidth > 940)
        {
          currTag.disabled = true;
        }
        else
        {
          currTag.disabled = false;
        }
			}
		}
	}

}






document.onkeydown=keypress;
document.onmousewheel=mousewheel;

function keypress(e) {

  if (objBrowser.isIE) {
    tmp = window.event.keyCode;
  }
  else {
    tmp = e.keyCode;
  }

  //...old Navigator..
  //else if (navigator.appName == "Navigator")
  //tmp = e.which;

   if ((tmp == 33) || (tmp == 34) || (tmp == 38) || (tmp == 40))
      {
        var thisDiv = document.getElementById('innercontent');
        thisDiv.focus();
        return;
      }

//33,34,38,40
  //if (tmp == 33) {
  //}
}

function mousewheel(e) {
  //alert("mouse wheel");
  var thisDiv = document.getElementById('innercontent');
  thisDiv.focus() ;
  return;
}

function ResizeMainWrapper() {
  if( objBrowser.isIE ) {
    ResizeMain();
  }
  else {
    setTimeout("ResizeMain();",50);
  }
}


// END script_core.js



// BEGIN IEmarginFix.js

if(!Array.prototype.push){Array.prototype.push=function(){var i,j;for(i=0;j=arguments[i];i++)this[this.length]=j;return this.length;}};IEmarginFix={list:new Array,ss:null,init:function(){var ua=navigator.userAgent.toLowerCase();if((ua.indexOf("msie 5.")!=-1||ua.indexOf("msie 6.")!=-1)&&ua.indexOf('mac')==-1&&document.compatMode!="CSS1Compat"&&window.attachEvent&&document.styleSheets.length>0){this.ss=document.styleSheets;var auto,lop,list,s,i,a;auto=new Array;lop=new Array;list=new Array;s=this.getRules();for(i=0;i<s.length;i++){if(this.checkMargin(s[i][1]))auto.push(s[i][0]);else if(this.checkLopsided(s[i][1]))lop.push(s[i][0]);}for(i=0;a=auto[i];i++)this.ss[this.ss.length-1].addRule(a,"margin-left : expression( IEmarginFix.autoFix(this) );");for(i=0;a=lop[i];i++)this.ss[this.ss.length-1].addRule(a,"margin-left : expression( IEmarginFix.lopsidedFix(this) );");this.list=auto.length>0?lop.length>0?auto.concat(lop):auto:lop;window.attachEvent("onload",IEmarginFix.checkInline);}},autoFix:function(elm){var rslt="auto",w=elm.currentStyle.width;var id=elm.id?"#"+elm.id:elm.className?elm.tagName+"."+elm.className:elm.tagName;if(w.indexOf("%")!=-1){rslt=(100-parseInt(w))/2+"%";IEmarginFix.ss[IEmarginFix.ss.length-1].addRule(id,"margin-left : "+rslt+"; margin-right : "+rslt+"; width : 100%");}else IEmarginFix.ss[IEmarginFix.ss.length-1].addRule(id,"margin-left : expression( IEmarginFix.pxAutoFix(this) );");return rslt;},pxAutoFix:function(elm){var rslt,par=elm.parentNode;rslt=par.clientWidth>0?par.clientWidth:par.scrollWidth;rslt=(rslt-elm.offsetWidth)/2;return rslt;},lopsidedFix:function(elm){var par=elm.parentNode,parWidth,rslt;parWidth=par.clientWidth>0?par.clientWidth:par.scrollWidth;rslt=parWidth-elm.offsetWidth;if(elm.currentStyle.marginRight.indexOf("px")!=-1)rslt-=parseInt(elm.currentStyle.marginRight);else if(elm.currentStyle.marginRight.indexOf("%")!=-1)rslt-=parseInt(elm.currentStyle.marginRight)*0.01*parWidth;rslt-=(parseInt(par.currentStyle.paddingLeft)+parseInt(par.currentStyle.paddingRight));return rslt;},checkInline:function(){var i,a,elm,blk,list=new Array,auto=IEmarginFix.list;for(i=0;a=auto[i];i++){if(a.indexOf(".")!=-1)list=list.concat(IEmarginFix.getClass(a.substring(a.indexOf(".")+1)));else if(a.charAt(0)=='#')list.push(document.all[a.substring(1)]);else{elm=document.getElementsByTagName(a);if(elm.length>0)for(i=0;i<elm.length;i++)list=list.concat(elm.item(i));}}for(i=0;i<list.length;i++){elm=list[i];if(elm&&elm.style){blk=IEmarginFix.getStyle(elm,"display");if(blk!="block"&&(IEmarginFix.ie50?!IEmarginFix.ie50check(elm.tagName):blk!="list-item")){elm.style.margin=0;}}}},checkMargin:function(str){return(str.search(/position\s*:\s*absolute/i)==-1&&(str.match(/margin\s*:\s*auto(;|$)/i)||str.match(/margin\s*:\s*\S+\s+auto(;|$)/i)||(str.match(/margin-left\s*:\s*auto/i)&&str.match(/margin-right\s*:\s*auto/i))||str.match(/margin\s*:\s*\S+\s+auto\s+\S+(;|$)/i)||str.match(/margin\s*:\s*\S+\s+auto\s+\S+\s+auto/i)));},checkLopsided:function(str){return(str.search(/position\s*:\s*absolute/i)==-1&&(str.match(/margin-left\s*:\s*auto/i)&&str.match(/margin-right\s*:\s*\d+(px|%)?/i)||str.match(/margin-left\s*:\s*auto/i)&&!str.match(/margin-right/i)));},ie50:navigator.appVersion.toLowerCase().indexOf("msie 5.0")!=-1,ie50check:function(tag){var i,r=false;tag=tag.toUpperCase();for(i=0;i<this.blockElms.length;i++)if(tag==this.blockElms[i])r=true;return r;},blockElms:new Array("ADDRESS","BLOCKQUOTE","BODY","CENTER","COL","COLGROUP","DD","DIR","DIV","DL","DT","FIELDSET","FORM","FRAME","HN","HR","IFRAME","LEGEND","LI","LISTING","MARQUEE","MENU","OL","P","PLAINTEXT","PRE","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL","XMP"),getClass:function(cls){var el,r,i;el=document.all?document.all:document.getElementsByTagName('*');r=new Array;for(i=0;el[i];i++)if(el[i].className==cls)r.push(el[i]);if(r.length==0)r=null;return r;},getRules:function(wh){var s=null;if(document.styleSheets&&document.styleSheets.length){var i,j,k,m,x,y,is=true,screen=true;s=new Array;for(i=0;i<document.styleSheets.length;i++){j=document.styleSheets.item(i);if(wh)is=(j.title||j.id)==wh;if(typeof j.media=="string"&&j.media.length>0&&!j.media.match(/^(screen)|(media)$/i)){screen=false;alert()}if(!j.disabled&&screen&&is){if(j.cssRules){for(k=0;m=j.cssRules.item(k);k++){if(m.styleSheet&&m.styleSheet.cssRules.length)for(x=0;y=m.styleSheet.cssRules.item(x);x++)s.push([y.selectorText,y.style.cssText]);else s.push([m.selectorText,m.style.cssText])}}else if(j.rules){if(j.imports&&j.imports.length){for(k=0;k<j.imports.length;k++)for(x=0;y=j.imports[k].rules[x];x++)s.push([y.selectorText,y.style.cssText]);}for(k=0;m=j.rules[k];k++)s.push([m.selectorText,m.style.cssText]);}}if(wh&&is)break;else is=true;}}return s;},getStyle:function(obj,sty){var sty2=IEmarginFix.compactStyle(sty);var r=obj.style[sty2];if(r==''){if(document.defaultView)r=document.defaultView.getComputedStyle(obj,'').getPropertyValue(sty);else r=obj.currentStyle[sty2];}if(!r)r=null;return r;},compactStyle:function(str){var s=str.split('-');var o=[s[0]];for(i=1;(j=s[i]);i++){o[o.length]=j.charAt(0).toUpperCase();o[o.length]=j.substring(1)};return o.join('');}};IEmarginFix.init();

// END IEmarginFix.js


// BEGIN script_common.js
// had problem updating this on Brainjar last time I tried.
function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num))
    num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10)
      cents = "0" + cents;
      for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3));
  return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function Mod(a, b)
{
  return a-Math.floor(a/b)*b ;
}

function QbDcTEST(s)    
{	var d = s.options[s.selectedIndex].value;    
	window.top.location.href = d;    
	s.selectedIndex=0;    
}    

// END script_common.js


/*
Sweet Titles (c) Creative Commons 2005
http://creativecommons.org/licenses/by-sa/2.5/
Author: Dustin Diaz | http://www.dustindiaz.com
*/
var sweetTitles = { 
	xCord : 0,				// @Number: x pixel value of current cursor position
	yCord : 0,				// @Number: y pixel value of current cursor position
	tipElements : ['a'],	// @Array: Allowable elements that can have the toolTip
	obj : Object,			// @Element: That of which you're hovering over
	tip : Object,			// @Element: The actual toolTip itself
	active : 0,				// @Number: 0: Not Active || 1: Active
	init : function() {
		if ( !document.getElementById ||
			!document.createElement ||
			!document.getElementsByTagName ) {
			return;
		}
		var i,j;
		this.tip = document.createElement('div');
		this.tip.id = 'toolTip';
		document.getElementsByTagName('body')[0].appendChild(this.tip);
		this.tip.style.top = '0';
		this.tip.style.visibility = 'hidden';
		addEvent(document,'mousemove',this.updateXY);
		if ( document.captureEvents ) {
				document.captureEvents(Event.MOUSEMOVE);
		}
		var tipLen = this.tipElements.length;
		for ( i=0; i<tipLen; i++ ) {
			var current = document.getElementsByTagName(this.tipElements[i]);
			var curLen = current.length;
			for ( j=0; j<curLen; j++ ) {
		    if (current[j].className == "tooltip") {
				  addEvent(current[j],'mouseover',this.tipOver);
				  addEvent(current[j],'mouseout',this.tipOut);
				  current[j].setAttribute('tip',current[j].title);
				  current[j].removeAttribute('title');
		    }
			}
		}
	},
	updateXY : function(e) {
		if ( document.captureEvents ) {
			sweetTitles.xCord = e.pageX;
			sweetTitles.yCord = e.pageY;
		} else if ( window.event.clientX ) {
			sweetTitles.xCord = window.event.clientX+document.documentElement.scrollLeft;
			sweetTitles.yCord = window.event.clientY+document.documentElement.scrollTop;
		}
	},
	tipOut: function() {
		if ( window.tID ) {
			clearTimeout(tID);
		}
		if ( window.opacityID ) {
			clearTimeout(opacityID);
		}
		sweetTitles.tip.style.visibility = 'hidden';
	},
	checkNode : function() {
		var trueObj = this.obj;
		if ( this.tipElements.inArray(trueObj.nodeName.toLowerCase()) ) {
			return trueObj;
		} else {
			return trueObj.parentNode;
		}
	},
	tipOver : function() {
		sweetTitles.obj = this;
		tID = window.setTimeout("sweetTitles.tipShow()",50)
	},
	tipShow : function() {		
		var scrX = Number(this.xCord);
		var scrY = Number(this.yCord);
		var tp = parseInt(scrY-5);
		var lt = parseInt(scrX+80);
		var anch = this.checkNode();
		var addy = '';
		var access = '';
		if ( anch.nodeName.toLowerCase() == 'a' ) {
			addy = (anch.href.length > 25 ? anch.href.toString().substring(0,25)+"..." : anch.href);
			var access = ( anch.accessKey ? ' <span>['+anch.accessKey+']</span> ' : '' );
		} else {
			addy = anch.firstChild.nodeValue;
		}
		this.tip.innerHTML = "<p>"+anch.getAttribute('tip')+"</p>";
		if ( parseInt(document.documentElement.clientWidth+document.documentElement.scrollLeft) < parseInt(this.tip.offsetWidth+lt) ) {
			this.tip.style.left = parseInt(lt-(this.tip.offsetWidth+10))+'px';
		} else {
			this.tip.style.left = lt+'px';
		}
		if ( parseInt(document.documentElement.clientHeight+document.documentElement.scrollTop) < parseInt(this.tip.offsetHeight+tp) ) {
			this.tip.style.top = parseInt(tp-(this.tip.offsetHeight+10))+'px';
		} else {
			this.tip.style.top = tp+'px';
		}
		this.tip.style.visibility = 'visible';
		//this.tip.style.opacity = '.1';
		//this.tipFade(10);
	},
	tipFade: function(opac) {
		var passed = parseInt(opac);
		var newOpac = parseInt(passed+10);
		if ( newOpac < 80 ) {
			this.tip.style.opacity = '.'+newOpac;
			this.tip.filter = "alpha(opacity:"+newOpac+")";
			opacityID = window.setTimeout("sweetTitles.tipFade('"+newOpac+"')",5);
		}
		else { 
			this.tip.style.opacity = '.80';
			this.tip.style.filter = "alpha(opacity:80)";
		}
	}
};
function pageLoader() {
	sweetTitles.init();
}
addEvent(window,'load',pageLoader);


// BEGIN aqtree3clickable.js

addEvent(window,"load",makeTreesC);function makeTreesC(){if(!document.createElement)return;uls=document.getElementsByTagName("ul");for(uli=0;uli<uls.length;uli++){ul=uls[uli];if(ul.nodeName=="UL"&&ul.className=="aqtree3clickable"){processULELC(ul);}}}function processULELC(ul){if(!ul.childNodes||ul.childNodes.length==0)return;for(var itemi=0;itemi<ul.childNodes.length;itemi++){var item=ul.childNodes[itemi];if(item.nodeName=="LI"){var a;var subul;subul="";for(var sitemi=0;sitemi<item.childNodes.length;sitemi++){var sitem=item.childNodes[sitemi];switch(sitem.nodeName){case "P":if(sitem.firstChild.className=="thisPoint"){a=sitem.firstChild;}break;case "SPAN":break;case "UL":subul=sitem;processULELC(subul);break;}}if(subul){if(a!=null){if(a.className=="thisPoint"){associateELC(a,subul);}}}}}}

function associateELC(a,ul) {
  var MasterNode = a.parentNode.parentNode ;
  if (MasterNode.className.indexOf('aq3open') == -1) {
    MasterNode.className = 'aq3closed';
    for (var thisITEM=0;thisITEM<MasterNode.childNodes.length;thisITEM++) {
      var item = MasterNode.childNodes[thisITEM];
      if (item.nodeName == "UL") {
        for (var thatITEM=0;thatITEM<item.childNodes.length;thatITEM++) {
          var insideItem = item.childNodes[thatITEM];
          if (insideItem.nodeName == "LI") {
            if (insideItem.className == "aq3open") {
              insideItem.firstChild.firstChild.firstChild.src = "/navimages/here.gif";
              MasterNode.className = "aq3open";
              MasterNode.firstChild.firstChild.firstChild.src = "/navimages/minus.gif";
            }
          }
        }
      }
    }
  }
  if (MasterNode.className.indexOf('aq3open') != -1) {
    var thisNotFinished = true  ;
    var theNextParent = a.parentNode.parentNode.parentNode ;
    if (theNextParent != null) {
      while (thisNotFinished)
      {
        if (theNextParent == null) {
          thisNotFinished = false ;
        }
        else
        {
          if (theNextParent.className == "aqtree3clickable") 
          {
            thisNotFinished = false ;
          }
          else 
          {
            if (theNextParent.nodeName == "LI") 
            {
              if (theNextParent.className == "") 
              {
              theNextParent.className = "aq3open" ;
              theNextParent.firstChild.firstChild.firstChild.src = "/navimages/minus.gif";
              }
              if (theNextParent.className == "aq3closed") 
              {
                theNextParent.className = "aq3open" ;
                theNextParent.firstChild.firstChild.firstChild.src = "/navimages/minus.gif";
              }
            }
            theNextParent = theNextParent.parentNode ;
          }
        }
      }
    }
  }
  a.onclick = function () {
    //this.parentNode.className = (this.parentNode.className=='aq3open') ? "aq3closed" : "aq3open";
    if (this.parentNode.parentNode.className == "aq3open") {
      this.parentNode.parentNode.className = "aq3closed" ;
      this.firstChild.src = "/navimages/plus.gif" ;
      //alert(this.firstChild.src) ;
    }
    else
    {
      this.parentNode.parentNode.className = "aq3open" ;
      this.firstChild.src = "/navimages/minus.gif" ;
      //alert(this.firstChild.src) ;
    }
    this.blur();
    return false;
  }
  return false;
}


// END aqtree3clickable.js






// BEGIN CartPanelFunctions.js
var ShoppingCartPage = false;

var thisPath = document.location.href;
if (thisPath.indexOf("/cart/") > 0)  {
  ShoppingCartPage = true;
}

function IncreaseQTY(frmField, incrementVal, minimumVal) {
  if (isNaN(parseInt(frmField.value)))
  {
    frmField.value = Math.max(incrementVal, minimumVal) ;
  }
  else
  {
    varCurrentValue = parseInt(frmField.value) ;
    if (varCurrentValue < 0) 
    {
      frmField.value = Math.max(incrementVal, minimumVal)  ;
    }
    else
    {
      frmField.value = Math.max((varCurrentValue - Mod(varCurrentValue, incrementVal)) + incrementVal, minimumVal) ;
    }
  }
  CartReminder(frmField);
}
function DecreaseQTY(frmField, incrementVal, minimumVal) {
  if (isNaN(parseInt(frmField.value)))
  {
    frmField.value = 0 ;
  }
  else
  {
    varCurrentValue = parseInt(frmField.value) ;
    if (varCurrentValue <= minimumVal) 
    {
      frmField.value = 0 ;
    }
    else
    {
      if (Mod(varCurrentValue, incrementVal) != 0) 
      {
        varCurrentValue = Math.max((varCurrentValue - Mod(varCurrentValue, incrementVal)), minimumVal) ;
      }
      else
      {
        if ((varCurrentValue - incrementVal) < minimumVal) 
        {
          varCurrentValue = 0 ;
        }
        else
        {
          varCurrentValue = varCurrentValue - incrementVal ;
        }
      }
      frmField.value = varCurrentValue ;
    }
  }
  CartReminder(frmField);
}

function CartReminder(frmField) {

  var partNum = frmField.id ;
  var thisRegEx = new RegExp ('ThisItem', 'gi') ;
  partNum = partNum.replace(thisRegEx, '') ;

	var thisImage = document.getElementById('UpdateCartImage' + partNum);
  if (thisImage != null) {
    thisImage.setAttribute("src", "/images/updatecart_smallnow.gif");
  }

  var thisImage = document.getElementById('UpdateCartImage1');
  if (thisImage != null) {
    thisImage.setAttribute("src", "/images/updatecartnow.gif");
  }

  var thisGrandTotal = document.getElementById("displayGrandTotal");
  if (thisGrandTotal != null) {
    thisGrandTotal.innerHTML = "<span class='ClickButton'>Click 'Save Changes'<br /><nobr>Button For Total</nobr></span>" ;
  }

  var thisImage = document.getElementById('UpdateCartImage2');
  if (thisImage != null) {
    thisImage.setAttribute("src", "/images/updatecartnow.gif");
  }


  var thisIQInput = document.getElementById("thisIQ_" + partNum);
  var thisIQ = thisIQInput.value;
  var thisIQLInput = document.getElementById("thisIQL_" + partNum);
  var thisIQL = thisIQLInput.value;
  var displayPriceDiv = document.getElementById("displayPrice_" + partNum);
	var LabelWhenQuantityZero = "<br />sub-total";
  var DoesThisElementExist = document.getElementById("isWholesale_" + partNum)

  if (DoesThisElementExist)
  {
   var thisPriceInput1 = document.getElementById("thisPrice1_" + partNum);
   var thisPriceValue1 = thisPriceInput1.value.split("$")[1];
   thisPriceValue1 = thisPriceValue1.replace(",", "");
   var thisPriceInput5 = document.getElementById("thisPrice5_" + partNum);
   var thisPriceValue5 = thisPriceInput5.value.split("$")[1];
   thisPriceValue5 = thisPriceValue5.replace(",", "");
   var thisPriceInput10 = document.getElementById("thisPrice10_" + partNum);
   var thisPriceValue10 = thisPriceInput10.value.split("$")[1];
   thisPriceValue10 = thisPriceValue10.replace(",", "");
   var thisPriceInput25 = document.getElementById("thisPrice25_" + partNum);
   var thisPriceValue25 = thisPriceInput25.value.split("$")[1];
   thisPriceValue25 = thisPriceValue25.replace(",", "");
   var thisPriceInput50 = document.getElementById("thisPrice50_" + partNum);
   var thisPriceValue50 = thisPriceInput50.value.split("$")[1];
   thisPriceValue50 = thisPriceValue50.replace(",", "");
  }
  else
  {
   var thisPriceInput = document.getElementById("thisPrice_" + partNum);
   var thisPriceValue = thisPriceInput.value.split("$")[1];
   thisPriceValue = thisPriceValue.replace(",", "");
  }  


	//for shubee
	//var LabelWhenQuantityAboveZero = "<br />item-<br />total";

	//for acs
	var LabelWhenQuantityAboveZero = "<br />subtotal";


  if (ShoppingCartPage == true)
  {
    LabelWhenQuantityAboveZero = ""
  }

  if ((thisIQ.length > 0) && (thisIQL.length > 0)) {
    if (parseFloat(thisIQ) == 1) //for example "1 Pair (of socks)" OR "2 Pairs (of socks)"
    {
      if (parseFloat(frmField.value) > 1)
      {
        if (thisIQL.charAt(thisIQL.length - 1) != "s")
        {
          thisIQL = thisIQL + "s"
        }
      }
      else
      {
        if (thisIQL.charAt(thisIQL.length - 1) == "s")
        {
          thisIQL = thisIQL.subString(0, (thisIQL.length - 1))
        }
      }
    }
    if ((isNaN(parseFloat(frmField.value))) || (parseFloat(frmField.value) == 0)) {
	    LabelWhenQuantityZero = "<br />for " + thisIQ + " " + thisIQL ;
    }
    else
    {
	    LabelWhenQuantityAboveZero = "<br />for " + (parseFloat(frmField.value) * parseFloat(thisIQ)) + " " + thisIQL ;
    }
  }


  //if (thisPriceInput != null) {
    if ((isNaN(parseFloat(frmField.value))) || (parseFloat(frmField.value) == 0)) {
      if (ShoppingCartPage == true)
      {
        displayPriceDiv.innerHTML = "" ;
      }
      else
      {
        //displayPriceDiv.innerHTML = formatCurrency(parseFloat(thisPriceValue)) + LabelWhenQuantityZero ;
        displayPriceDiv.innerHTML = "$0.00<br />subtotal" ;
        //alert("test")
        //displayPriceDiv.innerHTML = formatCurrency(thisPriceValue) + LabelWhenQuantityZero ;
      }
    }
    else
    {
      //var DoesThisElementExist = document.getElementById("displayPrice_" + partNum)
      if (DoesThisElementExist)
      {
        //alert(parseFloat(thisPriceValue));
   //alert("item does exist");
        if (parseFloat(frmField.value) >= 50)
        {
          displayPriceDiv.innerHTML = "<strong>" + formatCurrency((parseFloat(thisPriceValue50) * parseFloat(frmField.value))) + LabelWhenQuantityAboveZero + "</strong>" ;
        }
        else if  (parseFloat(frmField.value) >= 25)
        {
          displayPriceDiv.innerHTML = "<strong>" + formatCurrency((parseFloat(thisPriceValue25) * parseFloat(frmField.value))) + LabelWhenQuantityAboveZero + "</strong>" ;
          if ((thisPriceValue50Shown == false) && (parseFloat(frmField.value) == 49) && (thisPriceValue25 != thisPriceValue50))
          {
            alert("You have selected 49 items. \n\nPlease compare the price for 49 items to the price for 50 items!\n\nFor this product, when you reach 50 items, an additional quantity discount applies! \n\n(Adding 1 more to the quantity *might* even result in a LOWER price!)");
            thisPriceValue50Shown = true
          }
        }
        else if  (parseFloat(frmField.value) >= 10)
        {
          displayPriceDiv.innerHTML = "<strong>" + formatCurrency((parseFloat(thisPriceValue10) * parseFloat(frmField.value))) + LabelWhenQuantityAboveZero + "</strong>" ;
          if ((thisPriceValue25Shown == false) && (parseFloat(frmField.value) == 24) && (thisPriceValue10 != thisPriceValue25))
          {
            alert("You have selected 24 items. \n\nPlease compare the price for 24 items to the price for 25 items!\n\nFor this product, when you reach 25 items, an additional quantity discount applies! \n\n(Adding 1 more to the quantity *might* even result in a LOWER price!)");
            thisPriceValue25Shown = true
          }
        }
        else if  (parseFloat(frmField.value) >= 5)
        {
          displayPriceDiv.innerHTML = "<strong>" + formatCurrency((parseFloat(thisPriceValue5) * parseFloat(frmField.value))) + LabelWhenQuantityAboveZero + "</strong>" ;
          if ((thisPriceValue10Shown == false) && (parseFloat(frmField.value) == 9) && (thisPriceValue5 != thisPriceValue10))
          {
            alert("You have selected 9 items. \n\nPlease compare the price for 9 items to the price for 10 items!\n\nFor this product, when you reach 10 items, an additional quantity discount applies! \n\n(Adding 1 more to the quantity *might* even result in a LOWER price!)");
            thisPriceValue10Shown = true
          }
        }
        else
        {
          displayPriceDiv.innerHTML = "<strong>" + formatCurrency((parseFloat(thisPriceValue1) * parseFloat(frmField.value))) + LabelWhenQuantityAboveZero + "</strong>" ;
          if ((thisPriceValue5Shown == false) && (parseFloat(frmField.value) == 4) && (thisPriceValue1 != thisPriceValue5))
          {
            //alert(thisPriceValue5Shown);
            thisPriceValue5Shown = true
            alert("You have selected 4 items. \n\nPlease compare the price for 4 items to the price for 5 items!\n\nFor this product, when you reach 5 items, an additional quantity discount applies!");
          }
        }
      }
      else
      {
        displayPriceDiv.innerHTML = "<strong>" + formatCurrency((parseFloat(thisPriceValue) * parseFloat(frmField.value))) + LabelWhenQuantityAboveZero + "</strong>" ;
      }  
      //displayPriceDiv.innerHTML = "<strong>" + formatCurrency((thisPriceValue * parseFloat(frmField.value))) + LabelWhenQuantityAboveZero + "</strong>" ;
    }

    if (isNaN(parseFloat(frmField.value))) {
      frmField.value = "" ;
    }
  //}
}

// End CartPanelFunctions.js



//-----------------------------------------------------------------------------
// sortTable(id, col, rev)
//
//  id  - ID of the TABLE, TBODY, THEAD or TFOOT element to be sorted.
//  col - Index of the column to sort, 0 = first column, 1 = second column,
//        etc.
//  rev - If true, the column is sorted in reverse (descending) order
//        initially.
//
// Note: the team name column (index 1) is used as a secondary sort column and
// always sorted in ascending order.
//-----------------------------------------------------------------------------

function sortTable(id, col, rev) {

  // Get the table or table section to sort.
  var tblEl = document.getElementById(id);

  // The first time this function is called for a given table, set up an
  // array of reverse sort flags.
  if (tblEl.reverseSort == null) {
    tblEl.reverseSort = new Array();
    // Also, assume the team name column is initially sorted.
    tblEl.lastColumn = 1;
  }

  // If this column has not been sorted before, set the initial sort direction.
  if (tblEl.reverseSort[col] == null)
    tblEl.reverseSort[col] = rev;

  // If this column was the last one sorted, reverse its sort direction.
  if (col == tblEl.lastColumn)
    tblEl.reverseSort[col] = !tblEl.reverseSort[col];

  // Remember this column as the last one sorted.
  tblEl.lastColumn = col;

  // Set the table display style to "none" - necessary for Netscape 6 
  // browsers.
  var oldDsply = tblEl.style.display;
  tblEl.style.display = "none";

  // Sort the rows based on the content of the specified column using a
  // selection sort.


  var tmpEl;
  var i, j, m, n;
  var minVal, minIdx;
  var testVal;
  var cmp;

  for (i = 0; i < tblEl.rows.length - 1; i++) {

    // Assume the current row has the minimum value.
    minIdx = i;
    minVal = getTextValue(tblEl.rows[i].cells[col]);

    // Search the rows that follow the current one for a smaller value.
    for (j = i + 1; j < tblEl.rows.length; j++) {
      testVal = getTextValue(tblEl.rows[j].cells[col]);
      cmp = compareValues(minVal, testVal);
      // Negate the comparison result if the reverse sort flag is set.
      if (tblEl.reverseSort[col])
        cmp = -cmp;
      // Sort by the second column (team name) if those values are equal.
      if (cmp == 0 && col != 1)
        cmp = compareValues(getTextValue(tblEl.rows[minIdx].cells[1]),
                            getTextValue(tblEl.rows[j].cells[1]));
      // If this row has a smaller value than the current minimum, remember its
      // position and update the current minimum value.
      if (cmp > 0) {
        minIdx = j;
        minVal = testVal;
      }
    }

    // By now, we have the row with the smallest value. Remove it from the
    // table and insert it before the current row.
    if (minIdx > i) {
      tmpEl = tblEl.removeChild(tblEl.rows[minIdx]);
      tblEl.insertBefore(tmpEl, tblEl.rows[i]);
    }
  }

  // Make it look pretty.
  makePretty(tblEl, col);

  // Set team rankings.
  //setRanks(tblEl, col, rev);

  // Restore the table's display style.
  tblEl.style.display = oldDsply;

  return false;
}

//-----------------------------------------------------------------------------
// Functions to get and compare values during a sort.
//-----------------------------------------------------------------------------

// This code is necessary for browsers that don't reflect the DOM constants
// (like IE).
if (document.ELEMENT_NODE == null) {
  document.ELEMENT_NODE = 1;
  document.TEXT_NODE = 3;
}

function getTextValue(el) {

  var i;
  var s;

  // Find and concatenate the values of all text nodes contained within the
  // element.
  s = "";
  for (i = 0; i < el.childNodes.length; i++)
    if (el.childNodes[i].nodeType == document.TEXT_NODE)
      s += el.childNodes[i].nodeValue;
    else if (el.childNodes[i].nodeType == document.ELEMENT_NODE &&
             el.childNodes[i].tagName == "BR")
      s += " ";
    else
      // Use recursion to get text within sub-elements.
      s += getTextValue(el.childNodes[i]);

  return normalizeString(s);
}

function compareValues(v1, v2) {

  var f1, f2;

  // If the values are numeric, convert them to floats.



  if ((v1.indexOf("$") >= 0) && (v2.indexOf("$") >= 0))
  {
    v1 = v1.substr(v1.indexOf("$") + 1);
    v1 = v1.replace(',', '');
    v2 = v2.substr(v2.indexOf("$") + 1);
    v2 = v2.replace(',', '');
  }

  f1 = parseFloat(v1);
  f2 = parseFloat(v2);

  if (!isNaN(f1) && !isNaN(f2)) {
    v1 = f1;
    v2 = f2;
  }

  // Compare the two values.
  if (v1 == v2)
    return 0;
  if (v1 > v2)
    return 1
  return -1;
}

// Regular expressions for normalizing white space.
var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
var whtSpMult = new RegExp("\\s\\s+", "g");

function normalizeString(s) {

  s = s.replace(whtSpMult, " ");  // Collapse any multiple whites space.
  s = s.replace(whtSpEnds, "");   // Remove leading or trailing white space.

  return s;
}

//-----------------------------------------------------------------------------
// Functions to update the table appearance after a sort.
//-----------------------------------------------------------------------------

// Style class names.
var rowClsNm = "RowCell";
var colClsNm = "sortedColumn";

// Regular expressions for setting class names.
var rowTest = new RegExp(rowClsNm, "gi");
var colTest = new RegExp(colClsNm, "gi");

function makePretty(tblEl, col) {

  var i, j;
  var rowEl, cellEl;

  // Set style classes on each row to alternate their appearance.
  for (i = 0; i < tblEl.rows.length; i++) {
  rowEl = tblEl.rows[i];
  //rowEl.className = rowEl.className.replace(rowTest, "");
  //rowEl.className = 'RowCell';
  //if (i % 2 != 0)
  //rowEl.className += " " + rowClsNm;
  //rowEl.className = normalizeString(rowEl.className);
  // Set style classes on each column (other than the name column) to
  // highlight the one that was sorted.
    for (j = 0; j < tblEl.rows[i].cells.length; j++) {
      cellEl = rowEl.cells[j];
      //cellEl.className = cellEl.className.replace(colTest, "");
      if ((i + 2) % 2 != 0)
      {
        cellEl.className = "RowCell";
      }
      else
      {
        cellEl.className = "RowCellAlt";
      }
      cellEl.className = normalizeString(cellEl.className);
    }
  }

  // Find the table header and highlight the column that was sorted.
  var el = tblEl.parentNode.tHead;
  rowEl = el.rows[el.rows.length - 1];
  // Set style classes for each column as above.
  for (i = 2; i < rowEl.cells.length; i++) {
    cellEl = rowEl.cells[i];
    cellEl.className = cellEl.className.replace(colTest, "");
    // Highlight the header of the sorted column.
    if (i == col)
      cellEl.className += " " + colClsNm;
      cellEl.className = normalizeString(cellEl.className);
  }
}


//=============================================================================
// Window Object
//=============================================================================

function Window(el) {

  var i, mapList, mapName;

  // Get window components.

  this.frame           = el;
  this.titleBar        = winFindByClassName(el, "titleBar");
  this.titleBarText    = winFindByClassName(el, "titleBarText");
  this.titleBarButtons = winFindByClassName(el, "titleBarButtons");
  this.clientArea      = winFindByClassName(el, "clientArea");

  // Find matching button image map.

  mapName = this.titleBarButtons.useMap.substr(1);
  mapList = document.getElementsByTagName("MAP");
  for (i = 0; i < mapList.length; i++)
    if (mapList[i].name == mapName)
      this.titleBarMap = mapList[i];

  // Save colors.

  this.activeFrameBackgroundColor  = this.frame.style.backgroundColor;
  this.activeFrameBorderColor      = this.frame.style.borderColor;
  this.activeTitleBarColor         = this.titleBar.style.backgroundColor;
  this.activeTitleTextColor        = this.titleBar.style.color;
  this.activeClientAreaBorderColor = this.clientArea.style.borderColor;
  if (objBrowser.isIE)
    this.activeClientAreaScrollbarColor = this.clientArea.style.scrollbarBaseColor;

  // Save images.

  this.activeButtonsImage   = this.titleBarButtons.src;
  this.inactiveButtonsImage = this.titleBarButtons.longDesc;

  // Set flags.

  this.isOpen      = false;
  this.isMinimized = false;

  // Set methods.

  this.open       = winOpen;
  this.close      = winClose;
  this.minimize   = winMinimize;
  this.restore    = winRestore;
  this.makeActive = winMakeActive;

  // Set up event handling.

  this.frame.parentWindow = this;
  this.frame.onmousemove  = winResizeCursorSet;
  this.frame.onmouseout   = winResizeCursorRestore;
  this.frame.onmousedown  = winResizeDragStart;

  this.titleBar.parentWindow = this;
  this.titleBar.onmousedown  = winMoveDragStart;

  this.clientArea.parentWindow = this;
  this.clientArea.onclick      = winClientAreaClick;

  for (i = 0; i < this.titleBarMap.childNodes.length; i++)
    if (this.titleBarMap.childNodes[i].tagName == "AREA")
      this.titleBarMap.childNodes[i].parentWindow = this;

  // Calculate the minimum width and height values for resizing
  // and fix any initial display problems.

  var initLt, initWd, w, dw;

  // Save the inital frame width and position, then reposition
  // the window.

  initLt = this.frame.style.left;
  initWd = parseInt(this.frame.style.width);
  this.frame.style.left = -this.titleBarText.offsetWidth + "px";

  // For IE, start calculating the value to use when setting
  // the client area width based on the frame width.

  if (objBrowser.isIE) {
    this.titleBarText.style.display = "none";
    w = this.clientArea.offsetWidth;
    this.widthDiff = this.frame.offsetWidth - w;
    this.clientArea.style.width = w + "px";
    dw = this.clientArea.offsetWidth - w;
    w -= dw;     
    this.widthDiff += dw;
    this.titleBarText.style.display = "";
  }

  // Find the difference between the frame's style and offset
  // widths. For IE, adjust the client area/frame width
  // difference accordingly.

  w = this.frame.offsetWidth;
  this.frame.style.width = w + "px";
  dw = this.frame.offsetWidth - w;
  w -= dw;     
  this.frame.style.width = w + "px";
  if (objBrowser.isIE)
    this.widthDiff -= dw;

  // Find the minimum width for resize.

  this.isOpen = true;  // Flag as open so minimize call will work.
  this.minimize();
  // Get the minimum width.
  if (objBrowser.isNS && objBrowser.version >= 1.2)
    // For later versions of Gecko.
    this.minimumWidth = this.frame.offsetWidth;
  else
    // For all others.
    this.minimumWidth = this.frame.offsetWidth - dw;

  // Find the frame width at which or below the title bar text will
  // need to be clipped.

  this.titleBarText.style.width = "";
  this.clipTextMinimumWidth = this.frame.offsetWidth - dw;

  // Set the minimum height.

  this.minimumHeight = 1;

  // Restore window. For IE, set client area width.

  this.restore();
  this.isOpen = false;  // Reset flag.
  initWd = Math.max(initWd, this.minimumWidth);
  this.frame.style.width = initWd + "px";
  if (objBrowser.isIE)
    this.clientArea.style.width = (initWd - this.widthDiff) + "px";

  // Clip the title bar text if needed.

  if (this.clipTextMinimumWidth >= this.minimumWidth)
    this.titleBarText.style.width = (winCtrl.minimizedTextWidth + initWd - this.minimumWidth) + "px";

  // Restore the window to its original position.

  this.frame.style.left = initLt;
}

//=============================================================================
// Window Methods
//=============================================================================

function winOpen() {

  if (this.isOpen)
    return;

  // Restore the window and make it visible.

  this.makeActive();
  this.isOpen = true;
  if (this.isMinimized)
    this.restore();
  this.frame.style.visibility = "visible";
}

function winClose() {

  // Hide the window.

  this.frame.style.visibility = "hidden";
  this.isOpen = false;
}

function winMinimize() {

  if (!this.isOpen || this.isMinimized)
    return;

  this.makeActive();

  // Save current frame and title bar text widths.

  this.restoreFrameWidth = this.frame.style.width;
  this.restoreTextWidth = this.titleBarText.style.width;

  // Disable client area display.

  this.clientArea.style.display = "none";

  // Minimize frame and title bar text widths.

  if (this.minimumWidth)
    this.frame.style.width = this.minimumWidth + "px";
  else
    this.frame.style.width = "";
  this.titleBarText.style.width = winCtrl.minimizedTextWidth + "px";

  this.isMinimized = true;
}

function winRestore() {

  if (!this.isOpen || !this.isMinimized)
    return;

  this.makeActive();

  // Enable client area display.

  this.clientArea.style.display = "";

  // Restore frame and title bar text widths.

  this.frame.style.width = this.restoreFrameWidth;
  this.titleBarText.style.width = this.restoreTextWidth;

  this.isMinimized = false;
}

function winMakeActive() {

  if (winCtrl.active == this)
    return;

  // Inactivate the currently active window.

  if (winCtrl.active) {
    winCtrl.active.frame.style.backgroundColor    = winCtrl.inactiveFrameBackgroundColor;
    winCtrl.active.frame.style.borderColor        = winCtrl.inactiveFrameBorderColor;
    winCtrl.active.titleBar.style.backgroundColor = winCtrl.inactiveTitleBarColor;
    winCtrl.active.titleBar.style.color           = winCtrl.inactiveTitleTextColor;
    winCtrl.active.clientArea.style.borderColor   = winCtrl.inactiveClientAreaBorderColor;
    if (objBrowser.isIE)
      winCtrl.active.clientArea.style.scrollbarBaseColor = winCtrl.inactiveClientAreaScrollbarColor;
    if (objBrowser.isNS && objBrowser.version < 6.1)
      winCtrl.active.clientArea.style.overflow = "hidden";
    if (winCtrl.active.inactiveButtonsImage)
      winCtrl.active.titleBarButtons.src = winCtrl.active.inactiveButtonsImage;
  }

  // Activate this window.

  this.frame.style.backgroundColor    = this.activeFrameBackgroundColor;
  this.frame.style.borderColor        = this.activeFrameBorderColor;
  this.titleBar.style.backgroundColor = this.activeTitleBarColor;
  this.titleBar.style.color           = this.activeTitleTextColor;
  this.clientArea.style.borderColor   = this.activeClientAreaBorderColor;
  if (objBrowser.isIE)
    this.clientArea.style.scrollbarBaseColor = this.activeClientAreaScrollbarColor;
  if (objBrowser.isNS && objBrowser.version < 6.1)
    this.clientArea.style.overflow = "auto";
  if (this.inactiveButtonsImage)
    this.titleBarButtons.src = this.activeButtonsImage;
  this.frame.style.zIndex = ++winCtrl.maxzIndex;
  winCtrl.active = this;
}

//=============================================================================
// Event handlers.
//=============================================================================

function winClientAreaClick(event) {

  // Make this window the active one.

  this.parentWindow.makeActive();
}

//-----------------------------------------------------------------------------
// Window dragging.
//-----------------------------------------------------------------------------

function winMoveDragStart(event) {

  var target;
  var x, y;

  if (objBrowser.isIE)
    target = window.event.srcElement.tagName;
  if (objBrowser.isNS)
    target = event.target.tagName;

  if (target == "AREA")
    return;

  this.parentWindow.makeActive();

  // Get cursor offset from window frame.

  if (objBrowser.isIE) {
    x = window.event.x;
    y = window.event.y;
  }
  if (objBrowser.isNS) {
    x = event.pageX;
    y = event.pageY;
  }
  winCtrl.xOffset = winCtrl.active.frame.offsetLeft - x;
  winCtrl.yOffset = winCtrl.active.frame.offsetTop  - y;

  // Set document to capture mousemove and mouseup events.

  if (objBrowser.isIE) {
    document.onmousemove = winMoveDragGo;
    document.onmouseup   = winMoveDragStop;
  }
  if (objBrowser.isNS) {
    document.addEventListener("mousemove", winMoveDragGo,   true);
    document.addEventListener("mouseup",   winMoveDragStop, true);
    event.preventDefault();
  }

  winCtrl.inMoveDrag = true;
}

function winMoveDragGo(event) {

  var x, y;

  if (!winCtrl.inMoveDrag)
    return;

  // Get cursor position.

  if (objBrowser.isIE) {
    x = window.event.x;
    y = window.event.y;
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (objBrowser.isNS) {
    x = event.pageX;
    y = event.pageY;
    event.preventDefault();
  }

  // Move window frame based on offset from cursor.

  winCtrl.active.frame.style.left = (x + winCtrl.xOffset) + "px";
  winCtrl.active.frame.style.top  = (y + winCtrl.yOffset) + "px";
}

function winMoveDragStop(event) {

  winCtrl.inMoveDrag = false;

  // Remove mousemove and mouseup event captures on document.

  if (objBrowser.isIE) {
    document.onmousemove = null;
    document.onmouseup   = null;
  }
  if (objBrowser.isNS) {
    document.removeEventListener("mousemove", winMoveDragGo,   true);
    document.removeEventListener("mouseup",   winMoveDragStop, true);
  }
}

//-----------------------------------------------------------------------------
// Window resizing.
//-----------------------------------------------------------------------------

function winResizeCursorSet(event) {

  var target;
  var xOff, yOff;

  if (this.parentWindow.isMinimized || winCtrl.inResizeDrag)
    return;

  // If not on window frame, restore cursor and exit.

  if (objBrowser.isIE)
    target = window.event.srcElement;
  if (objBrowser.isNS)
    target = event.target;
  if (target != this.parentWindow.frame)
    return;

  // Find resize direction.

  if (objBrowser.isIE) {
    xOff = window.event.offsetX;
    yOff = window.event.offsetY;
  }
  if (objBrowser.isNS) {
    xOff = event.layerX;
    yOff = event.layerY;
  }
  winCtrl.resizeDirection = ""
  if (yOff <= winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "n";
  else if (yOff >= this.parentWindow.frame.offsetHeight - winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "s";
  if (xOff <= winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "w";
  else if (xOff >= this.parentWindow.frame.offsetWidth - winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "e";

  // If not on window edge, restore cursor and exit.

  if (winCtrl.resizeDirection == "") {
    this.onmouseout(event);
    return;
  }

  // Change cursor.

  if (objBrowser.isIE)
    document.body.style.cursor = winCtrl.resizeDirection + "-resize";
  if (objBrowser.isNS)
    this.parentWindow.frame.style.cursor = winCtrl.resizeDirection + "-resize";
}

function winResizeCursorRestore(event) {

  if (winCtrl.inResizeDrag)
    return;

  // Restore cursor.

  if (objBrowser.isIE)
    document.body.style.cursor = "";
  if (objBrowser.isNS)
    this.parentWindow.frame.style.cursor = "";
}

function winResizeDragStart(event) {

  var target;

  // Make sure the event is on the window frame.

  if (objBrowser.isIE)
    target = window.event.srcElement;
  if (objBrowser.isNS)
    target = event.target;
  if (target != this.parentWindow.frame)
    return;

  this.parentWindow.makeActive();

  if (this.parentWindow.isMinimized)
    return;

  // Save cursor position.

  if (objBrowser.isIE) {
    winCtrl.xPosition = window.event.x;
    winCtrl.yPosition = window.event.y;
  }
  if (objBrowser.isNS) {
    winCtrl.xPosition = event.pageX;
    winCtrl.yPosition = event.pageY;
  }

  // Save window frame position and current window size.

  winCtrl.oldLeft   = parseInt(this.parentWindow.frame.style.left,  10);
  winCtrl.oldTop    = parseInt(this.parentWindow.frame.style.top,   10);
  winCtrl.oldWidth  = parseInt(this.parentWindow.frame.style.width, 10);
  winCtrl.oldHeight = parseInt(this.parentWindow.clientArea.style.height, 10);

  // Set document to capture mousemove and mouseup events.

  if (objBrowser.isIE) {
    document.onmousemove = winResizeDragGo;
    document.onmouseup   = winResizeDragStop;
  }
  if (objBrowser.isNS) {
    document.addEventListener("mousemove", winResizeDragGo,   true);
    document.addEventListener("mouseup"  , winResizeDragStop, true);
    event.preventDefault();
  }

  winCtrl.inResizeDrag = true;
}

function winResizeDragGo(event) {

 var north, south, east, west;
 var dx, dy;
 var w, h;

  if (!winCtrl.inResizeDrag)
    return;

  // Set direction flags based on original resize direction.

  north = false;
  south = false;
  east  = false;
  west  = false;
  if (winCtrl.resizeDirection.charAt(0) == "n")
    north = true;
  if (winCtrl.resizeDirection.charAt(0) == "s")
    south = true;
  if (winCtrl.resizeDirection.charAt(0) == "e" || winCtrl.resizeDirection.charAt(1) == "e")
    east = true;
  if (winCtrl.resizeDirection.charAt(0) == "w" || winCtrl.resizeDirection.charAt(1) == "w")
    west = true;

  // Find change in cursor position.

  if (objBrowser.isIE) {
    dx = window.event.x - winCtrl.xPosition;
    dy = window.event.y - winCtrl.yPosition;
  }
  if (objBrowser.isNS) {
    dx = event.pageX - winCtrl.xPosition;
    dy = event.pageY - winCtrl.yPosition;
  }

  // If resizing north or west, reverse corresponding amount.

  if (west)
    dx = -dx;
  if (north)
    dy = -dy;

  // Check new size.

  w = winCtrl.oldWidth  + dx;
  h = winCtrl.oldHeight + dy;
  if (w <= winCtrl.active.minimumWidth) {
    w = winCtrl.active.minimumWidth;
    dx = w - winCtrl.oldWidth;
  }
  if (h <= winCtrl.active.minimumHeight) {
    h = winCtrl.active.minimumHeight;
    dy = h - winCtrl.oldHeight;
  }

  // Resize the window. For IE, keep client area and frame widths in synch.

  if (east || west) {
    winCtrl.active.frame.style.width = w + "px";
    if (objBrowser.isIE)
      winCtrl.active.clientArea.style.width = (w - winCtrl.active.widthDiff) + "px";
  }
  if (north || south)
    winCtrl.active.clientArea.style.height = h + "px";

  // Clip the title bar text, if necessary.

  if (east || west) {
    if (w < winCtrl.active.clipTextMinimumWidth)
      winCtrl.active.titleBarText.style.width = (winCtrl.minimizedTextWidth + w - winCtrl.active.minimumWidth) + "px";
    else
      winCtrl.active.titleBarText.style.width = "";
  }

  // For a north or west resize, move the window.

  if (west)
    winCtrl.active.frame.style.left = (winCtrl.oldLeft - dx) + "px";
  if (north)
    winCtrl.active.frame.style.top  = (winCtrl.oldTop  - dy) + "px";

  if (objBrowser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (objBrowser.isNS)
    event.preventDefault();
}

function winResizeDragStop(event) {

  winCtrl.inResizeDrag = false;

  // Remove mousemove and mouseup event captures on document.

  if (objBrowser.isIE) {
    document.onmousemove = null;
    document.onmouseup   = null;
  }
  if (objBrowser.isNS) {
    document.removeEventListener("mousemove", winResizeDragGo,   true);
    document.removeEventListener("mouseup"  , winResizeDragStop, true);
  }
}

//=============================================================================
// Utility functions.
//=============================================================================

function winFindByClassName(el, className) {

  var i, tmp;

  if (el.className == className)
    return el;

  // Search for a descendant element assigned the given class.

  for (i = 0; i < el.childNodes.length; i++) {
    tmp = winFindByClassName(el.childNodes[i], className);
    if (tmp != null)
      return tmp;
  }

  return null;
}

//=============================================================================
// Initialization code.
//=============================================================================

var winList = new Array();
var winCtrl = new Object();

function winInit() {

  var elList;

  // Initialize window control object.

  winCtrl.maxzIndex                        =   0;
  winCtrl.resizeCornerSize                 =  16;
  winCtrl.minimizedTextWidth               = 100;
  winCtrl.inactiveFrameBackgroundColor     = "#c0c0c0";
  winCtrl.inactiveFrameBorderColor         = "#f0f0f0 #505050 #404040 #e0e0e0";
  winCtrl.inactiveTitleBarColor            = "#808080";
  winCtrl.inactiveTitleTextColor           = "#c0c0c0";
  winCtrl.inactiveClientAreaBorderColor    = "#404040 #e0e0e0 #f0f0f0 #505050";
  winCtrl.inactiveClientAreaScrollbarColor = "";
  winCtrl.inMoveDrag                       = false;
  winCtrl.inResizeDrag                     = false;

  // Initialize windows and build list.

  elList = document.getElementsByTagName("DIV");
  for (var i = 0; i < elList.length; i++)
    if (elList[i].className == "window")
      winList[elList[i].id] = new Window(elList[i]);
}

window.onload = winInit;  // run initialization code after page loads.

