/*images*/
  var	imgGreenCheck		= new Image(23,23); 
  	imgGreenCheck.src	= gsib+'/img/global/inp-c.gif';

  var	imgRedX			= new Image(23,23); 
  	imgRedX.src		= gsib+'/img/global/inp-x.gif';


/* prototypes */
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

/* HEADER RELATED */
	/* top search box */
/**
 * TBCOM - wipes out the default text (if present) in the top text search box
 */
function tbTopSearchClear() {
	sObj	= document.getElementById('topNavSearchText');
	if (sObj.value == 'Enter multiple ISBNs, single ISBN, title, author or keyword(s)')
		sObj.value = '';
}
function tbTopSearchReset() {
	sObj	= document.getElementById('topNavSearchText');
	if (sObj.value == '')
		sObj.value = 'Enter multiple ISBNs, single ISBN, title, author or keyword(s)';
}
function tbBuySearchClear() {
	sObj	= document.getElementById('buySearchText');
	if (sObj.value == 'Enter multiple ISBNs, single ISBN, title, author or keyword(s)')
		sObj.value = '';
}
function tbBuySearchReset() {
	sObj	= document.getElementById('buySearchText');
	if (sObj.value == '')
		sObj.value = 'Enter multiple ISBNs, single ISBN, title, author or keyword(s)';
}

	/* top tab mouseovers */
function tbHeadTab(tabId, typeId) {
	var imgArr	= new Array('buy','sell','etext','whyus');
	document.getElementById('hdtb'+tabId).src	= gsib+'/img/global/nav_'+String(imgArr[tabId])+'_'+((typeId == 1)?'on':'off')+'.gif';
}



window.onscroll = function() {
	if (String(document.getElementById('ctBox')) != 'null') {
		if (truebody().scrollTop > 105 || self.pageYOffset > 105) {
			document.getElementById('ctBox').style.position	= 'fixed';
			document.getElementById('ctBox').style.top	= 0;
		} else if (truebody().scrollTop < 105 || self.pageYOffset < 105) {
			document.getElementById('ctBox').style.position	= 'absolute';
			document.getElementById('ctBox').style.top	= 'auto';
		}
	}
	floatSideBar();
}



/* CART RELATED */
	/* add to cart */
function tbATCImgFlip(cartImg, imgArr, imgIdx) {
	cartImg.src	= imgArr[imgIdx];
}
	/* cart flyout */

// the first cart item
var ctTopItem	= 0;
var ctItemTimer	= null;
var lastDir	= 1;
var opacTimer	= -1;
var flyTimer	= -1;
var flyoutObj	= "";

function tbCartShowFlyout(objTd, arrIdx) {
	var foB	= document.getElementById('cartFOB');

	var ctRowId	= objTd.id;
	
	var arTopPos	= new Array()
	arTopPos["ctItemRow0"]	= 159;
	arTopPos["ctItemRow1"]	= 265;
	arTopPos["ctItemRow2"]	= 371;

	if (flyTimer != -1)
		clearTimeout(flyTimer);

// ct subtotal
	subtotal	= new String(document.getElementById("ctSubtotal").innerHTML).replace(/\D/g, "");
	iSubtotal	= (!isNaN(subtotal))?parseInt(subtotal)/100:0;

// free ship
	sFSMsg		= (iSubtotal >= 25)?"FREE SHIPPING":"";

// set scrolltop
	scrTop	= (document.all)?truebody().scrollTop:self.pageYOffset;

	var idxPull						= arrIdx+ctTopItem;
	if (idxPull > ctItms.length-1)
		idxPull	= idxPull-(ctItms.length);
	var infArr						= ctItms[idxPull];
	document.getElementById('ctItmBkTtl').innerHTML		= String(infArr[0]);
	document.getElementById('ctItmBkAut').innerHTML		= String(infArr[1]);
	document.getElementById('ctItmBkCond').innerHTML	= String(infArr[2]);
	document.getElementById('ctItmBkPri').innerHTML		= String(infArr[3]);
	document.getElementById('ctItmBkSave').innerHTML	= String(infArr[4]);
	document.getElementById('ctItmBkFS').innerHTML		= sFSMsg;
	gbVal	= new String(infArr[5]);
	if (gbVal != '$0.00' && gbVal != "") {
		document.getElementById('ctItmBkGB').innerHTML		= "" +
			"<div style='width:328px;height:8px;border:0;'></div>" +
			"<img src='"+gsib+"/img/global/ctfob-gb-sep.gif'><br>" +
			"<img src='"+gsib+"/img/global/ctfob-gb.gif' align=absmiddle> " +
			"Guaranteed Cash Back: " + gbVal;
        }
        else {
		document.getElementById('ctItmBkGB').innerHTML		= "";
        }
        
	topOffset	= Math.round(objTd.offsetHeight/2);

	if (document.all) {
		document.getElementById('cartFOB').style.background	= 'url('+gsib+'/img/global/cart-flyout.gif)';
	}

	foB.x		= getposOffset(objTd, "left");
	foB.y		= getposOffset(objTd, "top")+((scrTop >= 105)?scrTop:0)-topOffset+20;
	foB.style.left	= foB.x-(parseInt(foB.style.width)-5)+"px";
	foB.style.top	= (foB.y-clearbrowseredge(objTd, "bottomedge", foB))+"px";

	foB.style.display	= 'inline';
	high(foB);
	objTd.className		= 'ctBkImgMO';
	flyoutObj		= objTd;
}

function tbCartHideFlyout(objTd) {
	objTd.className		= 'ctBkImg';
	low(document.getElementById('cartFOB'));
}

function tbCartItemIterate(intDir) {
// -1 means go back, 1 means go forward
	if (intDir == null)
		intDir	= lastDir;

	lastDir	= intDir;
	ctItem	= (ctTopItem+intDir);

	if (ctItem < 0)
		ctItem	= ctItms.length-1;
	if (ctItem > ctItms.length-1)
		ctItem	= 0;

	ctTopItem	= ctItem;

	ctRows		= ctItms.length;
	maxLoops	= (ctRows > 3)?3:ctRows;

	for (var cii=0;cii<maxLoops;cii++) {
		with (document) {
			thisArr					= ctItms[ctItem];
			getElementById("ctBkImg"+cii).src	= thisArr[6];
		}
		ctItem	= (ctItem+1 > ctItms.length-1)?0:ctItem+1;
	}
}


/* BOOK RELATED */
	/* book description */
var currTab	= new Number(0);
function setCntTab(tabId) {
	document.getElementById('cntTb' + currTab).className	= 'bkInfoBtn0';
	document.getElementById('cntStr' + currTab).className	= 'hid';
	document.getElementById('cntTb' + tabId).className	= 'bkInfoBtn1';
	document.getElementById('cntStr' + tabId).className	= 'vis';
	currTab	= tabId;
}
	/* shows more detail on book description */
function tbBkShowMoreInfo(cntId) {
	document.getElementById('readMoreImg' + cntId).className	= 'hid';
	document.getElementById('readFull' + cntId).className		= 'vis';
}


/* SEARCH RELATED */
function tbSrchOpenFilters() {
	document.getElementById("sfltOpnBlk").className	= 'hid';
	document.getElementById("sfltClsBlk").className	= 'sflt_box';
}

function tbSrchCloseFilters() {
	document.getElementById("sfltOpnBlk").className	= 'vis';
	document.getElementById("sfltClsBlk").className	= 'hid';
}

function toggleNav(navId, flipId) {
	document.getElementById(navId+'More').style.display	= (flipId==0)?'inline':'none';
	document.getElementById(navId+'Less').style.display	= (flipId==1)?'inline':'none';
}


/* GLOBAL */
	/* grabs the offset value of a page object */
function caloffset(what, offsettype){
	var totaloffset	= (offsettype == "left")?what.offsetLeft:what.offsetTop;
	var parentEl	= what.offsetParent;
	while (parentEl!=null){
		totaloffset	= (offsettype == "left")?totaloffset+parentEl.offsetLeft:totaloffset+parentEl.offsetTop;
		parentEl	= parentEl.offsetParent;
	}
	return totaloffset;
}


function tbSetFormImage(sImageName, iZeroOrOne, iScrollTo, sMsgString) {
	document.getElementById(sImageName).src	= (iZeroOrOne == 0)?imgRedX.src:imgGreenCheck.src;
//	if (sMsgString != "")
//		alert(sMsgString);

}




var vertical_offset	= "0px"; //horizontal offset of tooltip from anchor link
var horizontal_offset	= "-3px"; //horizontal offset of tooltip from anchor link

function getposOffset(what, offsettype) {
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	while (parentEl!=null) {
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function clearbrowseredge(obj, whichedge, whichFloater){
	var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1;
	if (whichedge=="rightedge") {
		var windowedge	= (document.all && !window.opera)? truebody().scrollLeft+truebody().clientWidth-15 : window.pageXOffset+window.innerWidth-15;
		whichFloater.contentmeasure=whichFloater.offsetWidth;
		if (windowedge-whichFloater.x < whichFloater.contentmeasure)
			edgeoffset=whichFloater.contentmeasure-obj.offsetWidth;
	}
	else {
		var windowedge = (document.all && !window.opera)? truebody().scrollTop+truebody().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
		whichFloater.contentmeasure=whichFloater.offsetHeight;
		if (windowedge-whichFloater.y < whichFloater.contentmeasure)
			edgeoffset=whichFloater.contentmeasure+obj.offsetHeight;
	}
	return edgeoffset;
}




/* TOOLTIP RELATED 
var tipwidth='150px' //default tooltip width
var tipbgcolor='lightyellow'  //tooltip bgcolor
var disappeardelay=250  //tooltip disappear speed onMouseout (in miliseconds)

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

//if (ie4||ns6)
//document.write('<div id="fixedtipdiv" style="visibility:hidden;width:'+tipwidth+';background-color:'+tipbgcolor+'" ></div>')



function showhide(obj, e, visible, hidden, tipwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}


function tbDoTT(tipId, obj, e, tipwidth) {
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()

	clearhidetip()
	dropmenuobj	= (document.getElementById)?document.getElementById(tipId):fixedtipdiv
//	dropmenuobj.innerHTML=menucontents

	if (ie4||ns6){
		showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth)
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left	= dropmenuobj.x-clearbrowseredge(obj, "rightedge", dropmenuobj)+"px"
		dropmenuobj.style.top	= dropmenuobj.y-clearbrowseredge(obj, "bottomedge", dropmenuobj)+obj.offsetHeight+"px"
	}
}

function hidetip(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidetip(){
if (ie4||ns6)
hidetip();
//delayhide=setTimeout("hidetip()",disappeardelay);
}

function clearhidetip(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

*/











/* OPACITY RELATED */
function opacity(id, opacStart, opacEnd, millisec, whichDir) { 

	if (window.opacTimer)
		clearTimeout(opacTimer);

//speed for each frame 
	var speed = 30; // Math.round(millisec / 100); 

	changeOpac(opacStart, id);

    //determine the direction for the blending, if start and end are the same nothing happens 
    if (whichDir < 0) { 
	if (opacStart == 0) {
		document.getElementById(id).style.display	= 'none';
	}
	else {
		opacStart	= opacStart-10;
		if (opacStart <= 0) opacStart = 0;

		opacTimer	= setTimeout("opacity('"+id+"',"+opacStart+","+opacEnd+","+millisec+","+whichDir+")", speed);
	}
    }
    else { 
	if (opacStart < 10)
		document.getElementById(id).style.display	= 'block';

	opacStart	= opacStart+10;
	if (opacStart >= 100) opacStart = 100;

	if (opacStart <= 100) {
		opacTimer	= setTimeout("opacity('"+id+"',"+opacStart+","+opacEnd+","+millisec+","+whichDir+")", speed);
	}
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function high(which2) {
	opacity(which2.id, 0, 100, 50, 1)
}

function low(which2) {
	opacity(which2.id, 100, 0, 50, -1)
}


/* LIGHTBOX RELATED */
// you want to use paypal?
	var ppOpt	= new String("");
		ppOpt	= "<font class='reg12px'>" +
			"You have selected to use PayPal as your payment method." +
			"<P>Is this correct?</p>" +
			"<small class='reg11px'>* You will be redirected to the PayPal site.</small>" +
			"<P align=center>" +
			"	<a href='#' onClick='coSetPaytype(0);tbHideLightbox();'><img src='"+gsib+"/img/acct/ma-cancel.gif' width=71 height=25 border=0 alt='[ Cancel ]'></a> &nbsp; &nbsp; " +
			"	<a href='#' onclick='PayPalGo(2); return false'><img src='"+gsib+"/img/co/co-ok.gif' width=71 height=25 border=0 alt='[ Ok? ]'></a>" +
			"</p>" +
			"</font>";

// what is paypal?
	var ppWot	= new String("");
		ppWot	= "<p>PayPal, the trusted leader in online payments, enables buyers and businesses to send and receive money online. PayPal has over 100 million member accounts in 190 countries and regions. It's accepted by merchants everywhere, both on and off eBay.<br>" +
			"<br>" +
			"<span class='emphasis'>Is it safe to use?</span><br>" +
			"PayPal helps protect your credit card information with industry-leading security and fraud prevention systems. When you use PayPal, your financial information is never shared with the merchant.<br>" +
			"<br>" +
			"<span class='emphasis'>Why use PayPal?</span></p>" +
			"<ul>" +
			"<li>Make purchases or send money with PayPal &#151; it's free</li>" +
			"<li>Shop and pay conveniently by saving your information with PayPal</li>" +
			"<li>PayPal is accepted by millions of businesses worldwide and is the preferred payment method on eBay</li>" +
			"</ul>" +
			"<p><a target='_blank' href='https://www.paypal.com/us/cgi-bin/webscr?cmd=_registration-run'>Start using PayPal</a> today!</p>";

function tbShowLightbox(sHtml, sHeading, blnContentContainsClose) {
	var sLBContent	= new String("");

	blnContentContainsClose	= (blnContentContainsClose == null)?false:blnContentContainsClose;

	if (sHeading != null && sHeading != "") {
		sLBContent	= "<b>"+sHeading+"</b><P>";
	}

	sLBContent	+= sHtml;

	document.getElementById('divLBC').className	= (blnContentContainsClose)?'hid':'lbClose';
	document.getElementById('lbCnt').className	= 'lbContent';
	document.getElementById('lbCnt').innerHTML	= sLBContent;
//	document.getElementById('light').style.display	='block';
	high(document.getElementById('light'));

	document.getElementById('fade').style.display	='block';

	floatSideBar('light');
}

function tbHideLightbox() {
//	document.getElementById('light').style.display	='none';
	low(document.getElementById('light'));

	document.getElementById('fade').style.display	='none';
}

function tbShowPrintLayer(sUrlToLoad, sPrintText) {
	document.getElementById('printFrm').src			= sUrlToLoad;
	document.getElementById('printTxt').innerHTML		= sPrintText;
	document.getElementById('printdiv').style.display	= 'block';
	floatSideBar('printdiv');
	document.getElementById('printfade').style.display	= 'block';

	return false;
}

function tbHidePrintLayer() {
	document.getElementById('printFrm').src			= '';
	document.getElementById('printTxt').innerHTML		= '';
	document.getElementById('printdiv').style.display	= 'none';
	document.getElementById('printfade').style.display	= 'none';
}

function tbPrintLayerGo() {
	if (document.all) {
		document.printFrm.focus();
		document.printFrm.print();
	}
	else {
		window.frames['printFrm'].focus();
		window.frames['printFrm'].print();
	}
}

function tbShowInfoLayer(sUrlToLoad, sInfoText) {
	document.getElementById('infoFrm').src			= sUrlToLoad;
	document.getElementById('infoTxt').innerHTML		= sInfoText;
	document.getElementById('infodiv').style.display	= 'block';
	document.getElementById('printfade').style.display	= 'block';

	floatSideBar('infodiv');

	return false;
}

function tbHideInfoLayer() {
	document.getElementById('infoFrm').src			= '';
	document.getElementById('infoTxt').innerHTML		= '';
	document.getElementById('infodiv').style.display	= 'none';
	document.getElementById('printfade').style.display	= 'none';
}



bY	= 0;
lPY	= 0;
lId	= '';
function floatSideBar(id) {
	if (id == null || String(id) == 'undefined') id = (lId != '')?lId:'light';
//pageY, pageHeight, boxHeight
	var pY,pH,bH	= 'light'; 

	var pDims	= getDimsWH();
	var sDims	= getScrollXY();

	pY	=  sDims[1]; // (navigator.appName.indexOf("Netscape")!=-1)?pageYOffset:((nn&&document.html.scrollTop)?document.html.scrollTop:truebody().scrollTop);

	var lPx	= ((pDims[0]-document.getElementById(id).offsetWidth)/2);

//	if (pY != lPY || id != lId) { //they scrolled or new item called

	pH = pDims[1]; 
	bH = document.getElementById(id).offsetHeight; 

	bY = (pH/2)-(bH/2)+pY; 

	document.getElementById(id).style.top = bY+'px';
	document.getElementById(id).style.left = lPx+'px';

//	}
	lPY	= pY;
	lId	= id;

}

function getDimsWH() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth	= window.innerWidth;
    myHeight	= window.innerHeight;
  }
  else {
    //IE compatible
    myWidth	= truebody().clientWidth;
    myHeight	= truebody().clientHeight;
  }
  return Array(myWidth,myHeight);
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  }
  else {
    // IE standards compliant mode
    scrOfY = truebody().scrollTop;
    scrOfX = truebody().scrollLeft;
  }
  return Array(scrOfX, scrOfY);
}

/* CHECKOUT RELATED */
function tbCOS1() {
	zip	= document.getElementById("shipzip");
	if (isNaN(Number(zip.value)) || String(zip.value).length != 5) {
		alert("Please enter a valid shipping zip code, and click the 'Go' button to view shipping methods");
		zip.focus();
		return false;
	}
	if (!getRadioValue('ShipMethod')) {
		alert("Please select a shipping method.");
		return false;
	}
	return true;
}

function getRadioValue(radioGroupName) {
	if (String(document.getElementsByName(radioGroupName)) != "null") {
		radios = document.getElementsByName(radioGroupName);
		for (i = 0; i < radios.length; i++) {
		    if (radios[i].checked) return radios[i].value;
		}
	}
	else {
		alert("no radios!");
	}
	return false;
}

/* SELL RELATED */
/**
 * TBCOM - wipes out the default text (if present) in the top text search box
 */
function tbSellSearchClear() {
	sObj	= document.getElementById('bb_isbns');
	if (sObj.value == 'START HERE - Enter multiple ISBNs or single ISBN')
		sObj.value = '';
}
function tbSellSearchReset() {
	sObj	= document.getElementById('bb_isbns');
	if (sObj.value == '')
		sObj.value = 'START HERE - Enter multiple ISBNs or single ISBN';
}

/* ACCOUNT RELATED */
function tbMATabs(tabId) {
	with (document) {
		getElementById("mat0").src		= gsib+"/img/acct/ma-bip-"+((tabId == 0)?1:0)+".gif";
		getElementById("mad0").className	= (tabId == 0)?"maSect":"hid";
		getElementById("mat1").src		= gsib+"/img/acct/ma-bis-"+((tabId == 1)?1:0)+".gif";
		getElementById("mad1").className	= (tabId == 1)?"maSect":"hid";
		getElementById("mat2").src		= gsib+"/img/acct/ma-mi-"+((tabId == 2)?1:0)+".gif";
		getElementById("mad2").className	= (tabId == 2)?"maSect":"hid";
		getElementById("mat3").src		= gsib+"/img/acct/ma-vb-"+((tabId == 3)?1:0)+".gif";
		getElementById("mad3").className	= (tabId == 3)?"maSect":"hid";
	}
}

function tbMASectTabs(tabId, modId) {
	with (document) {
		if (tabId == 0) {
			getElementById("mad20a").className	= (modId == 0)?"vis":"hid";
			getElementById("mad20b").className	= (modId == 1)?"vis":"hid";
		}

		if (tabId == 1) {
			getElementById("mad21a").className	= (modId == 0)?"vis":"hid";
			getElementById("mad21b").className	= (modId == 1)?"vis":"hid";
		}

		if (tabId == 2) {
			getElementById("mad22a").className	= (modId == 0)?"vis":"hid";
			getElementById("mad22b").className	= (modId == 1)?"vis":"hid";
		}
		if (tabId == 3) {
			getElementById("mad23a").className	= (modId == 0)?"vis":"hid";
			getElementById("mad23b").className	= (modId == 1)?"vis":"hid";
		}
	}
}


function clean_isbn(value) {
	return value.replace(/(^\s+)|(\s+$)|-/g, '');
}

function is_well_formed_isbn(value) {	// assumes value has been cleaned
	return /^\d{9}[xX\d]$/.test(value) || /^\d{13}$/.test(value);
}

function is_valid_isbn(value) {	// assumes value has been cleaned
	if (!/^0{10}$/.test(value) && /^\d{9}[xX\d]$/.test(value)) {
		var sum = 0;
		for (var i = 0; i < 9; ++i)
			sum += (10 - i) * eval(value.charAt(i));
		sum += (value.charAt(9) == 'x' || value.charAt(9) == 'X') ? 10 : eval(value.charAt(9));
		return (sum % 11) == 0;
	}
	else if (!/^0{13}$/.test(value) && /^\d{13}$/.test(value)) {
		var sum = 0;
		for (var i = 0; i < 13; ++i) {
			var n = eval(value.charAt(i));
			if ((i % 2) == 1) n *= 3;
			sum += n;
		}
		return (sum % 10) == 0;
	}
	else return false;
}


/** HOMEPAGE **/
function tbHpTabs($tabId) {
	with (document) {
	// buy
		getElementById('hpt0').src		= gsib+'/img/global/buy-tab'+(($tabId == 0)?'1':'0')+'.gif';
		getElementById('hpz0').className	= ($tabId == 0)?'vis':'hid';
		getElementById('hpfi0').className	= ($tabId == 0)?'hid':'hpFtrImg';
	// sell
		getElementById('hpt1').src		= gsib+'/img/global/sell-tab'+(($tabId == 1)?'1':'0')+'.gif';
		getElementById('hpz1').className	= ($tabId == 1)?'vis':'hid';
		getElementById('hpfi1').className	= ($tabId == 1)?'hid':'hpFtrImg';
	// etext
		getElementById('hpt2').src		= gsib+'/img/global/etext-tab'+(($tabId == 2)?'1':'0')+'.gif';
		getElementById('hpz2').className	= ($tabId == 2)?'vis':'hid';
		getElementById('hpfi2').className	= ($tabId == 2)?'hid':'hpFtrImg';
	// why us
		// nothing to do here, because Why Us is it's own page
	}
// cancel their click event
	return false;
}

/** customer service **/
function csToggleNav(topNm) {

	with (document) {
		if (getElementById(topNm+'Kids').className == 'hid') {
			getElementById(topNm).className		= 'csNavTopOn';
			getElementById(topNm+'Ct').className	= 'vis';
			getElementById(topNm+'Kids').className	= 'vis';
		}
		else {
			getElementById(topNm).className		= 'csNavTopOff';
			getElementById(topNm+'Ct').className	= 'hid';
			getElementById(topNm+'Kids').className	= 'hid';
		}
	}

}

/** error message **/
function tbErrorMsg(sMsg, objHighlight) {
	var objErrBlock	= document.getElementById("frmErr");
		objErrBlock.x=getposOffset(objHighlight, "left");
		objErrBlock.y=getposOffset(objHighlight, "top");
		objErrBlock.style.left	= objErrBlock.x-clearbrowseredge(objHighlight, "rightedge", objErrBlock)-8+"px";
		objErrBlock.style.top	= objErrBlock.y-clearbrowseredge(objHighlight, "bottomedge", objErrBlock)-23+"px";
		objErrBlock.className	= 'vis';
		objErrBlock.style.zIndex	= 2;
		document.getElementById("frmErrTxt").innerHTML	= sMsg;
}

function tbErrorHide() {
	document.getElementById("frmErr").className	= 'hid';
}








// SIGN IN / ACCOUNT DASH LAYER
	var dropboxleft	= 200; //set left position of box (in px)
	var dropboxtop	= 100; //set top position of box (in px)
	var dropspeed	= new Number(15);  //set speed of drop animation (larger=faster)
	var cTop	= new Number(-220);
	var ie		= document.all;
	var dom		= document.getElementById;
	var isVis	= false;
	var loc		= new String(window.location.href);


function tbRPCLoginForm(reqStyle) {
	if (isVis) return false;

	var sUrl	= new String(tbsu+"/login-mini.php?STL="+reqStyle+"&CSID="+sId);

	document.getElementById('silFrm').src		= sUrl;

	scroll(0,0);

	initboxv2();

// we return false, because the click allows non-js browsers to
// see a login page.
	return false;
}

function tbRPCForgotPass() {
	if (isVis) return false;

	var sUrl	= new String(tbsu+"/Pop-Ups-ForgotPass.php?CSID="+sId);

	document.getElementById('silFrm').src		= sUrl;

	scroll(0,0);

	initboxv2();

// we return false, because the click allows non-js browsers to
// see a login page.
	return false;
}

function tbUpdateSignIn(sTnsis, sTnsin) {
	document.getElementById("tnsis").innerHTML	= sTnsis;
	document.getElementById("tnsifn").innerHTML	= sTnsin;
}

function initboxv2() {
	if (window.hidestart) clearInterval(hidestart);
	initBoxPos();
	if (!dom&&!ie)
		return

	if (!isVis) {
		isVis				= true;
		crossboxcover			= document.getElementById("dropinboxv2cover");
		crossbox			= document.getElementById("dropinboxv2");
		scroll_top			= (ie)?truebody().scrollTop:window.pageYOffset;
		crossbox.height			= crossbox.offsetHeight;
		crossboxcover.style.height	= parseInt(crossbox.height)+"px";
		crossbox.style.top		= crossbox.height*(-1)+"px";
		crossboxcover.style.left	= dropboxleft+"px";
		crossboxcover.style.top		= dropboxtop+"px";
		crossboxcover.style.visibility	= (dom||ie)? "visible":"show";
		dropstart			= setInterval("dropinv2()",50);
	}
}

function initBoxPos() {
	var thePlus1		 = new Number(0);
	var thePlus2		 = new Number(0);
	var stopTag		 = new String("BODY");
	var oTbl		 = document.getElementById("tnTabsTbl");

	for(var p=oTbl; p&&p.tagName!=stopTag; p=p.offsetParent) {
		thePlus1	+= p.offsetLeft;
		thePlus2	+= p.offsetTop;
	}

	dropboxleft		= thePlus1+1;
	dropboxtop		= thePlus2+32;
}

function dropinv2() {
	cTop	= parseInt(crossbox.style.top)+dropspeed;
	if (cTop<0) {
		crossboxcover.style.top	= dropboxtop+"px";
		crossbox.style.top	= cTop+"px";
	}
	else {
		clearInterval(dropstart);
		crossbox.style.top	= 0;
	}
}

function dismissboxv2() {
	if (window.dropstart) clearInterval(dropstart);
	if (window.hidestart) clearInterval(hidestart);
	initBoxPos();
	cTop			= parseInt(crossbox.style.top);
	hidestart		= setInterval("hideinv2()",50);
}

function hideinv2() {
	cTop	= parseInt(crossbox.style.top)-dropspeed;
	if (cTop > -220) {
		crossbox.style.top		= cTop+"px";
		cTop	= cTop-dropspeed;
	}
	else {
		clearInterval(hidestart);
		crossboxcover.style.visibility	= (dom||ie)? "hidden":"hide";
		crossbox.style.top		= "-220px";
		isVis				= false;
	}
}

/**
* Determines which hierarchy to use for referring to the document body
*/
function truebody() {
	return (document.compatMode && document.compatMode!="BackCompat")?document.documentElement:document.body;
}

/**
* Hide the sign in layer
*/
function tbSilHide() {
	if (isVis)
		dismissboxv2();
}
// SIGN IN / ACCOUNT DASH LAYER
