// dependant on mootools.js !var DHTML = (document.getElementById || document.all || document.layers); // quirksmode!function getStyleObject(objectId) {    // cross-browser function to get an object's style object given its id    if(document.getElementById && document.getElementById(objectId)) { // W3C DOM	return document.getElementById(objectId).style;    } else if (document.all && document.all(objectId)) { // MSIE 4 DOM	return document.all(objectId).style;    } else if (document.layers && document.layers[objectId]) { // NN 4 DOM	return document.layers[objectId];    } else { return false; }} // getStyleObjectfunction getObject(objectId) { // cross-browser function to get an object given its id REPLACED BY PROTOTYPE    if(document.getElementById && document.getElementById(objectId)) { // W3C DOM	return document.getElementById(objectId);    } else if (document.all && document.all(objectId)) { // MSIE 4 DOM	return document.all(objectId)    } else if (document.layers && document.layers[objectId]) { // NN 4 DOM	return document.layers[objectId];    } else { return false; }	} // getObjectfunction Array_push() { // fixing older browsers array handlin'  var A_p = 0  for (A_p = 0; A_p < arguments.length; A_p++) { this[this.length] = arguments[A_p] }  return this.length} if (typeof Array.prototype.push == "undefined") { Array.prototype.push = Array_push } // only if it doesnt exist...Number.prototype.toDecimals=function(n){ // handy, handy, handy    n=(isNaN(n))? 2: n;    var nT=Math.pow(10,n);    function pad(s){ s=s||'.'; return (s.length>n)? s: pad(s+'0'); }    return (isNaN(this))? this: (new String( Math.round(this*nT)/nT )).replace(/(\.\d*)?$/,pad);}function showMenuNow(theMenuElementID,eventObj,theButtonElementID) {    if ( !getStyleObject(theMenuElementID) ) { return false; } // do nothing if browser cant handle	else {		if (typeof catalogDelay == "number") clearTimeout(catalogDelay);		var theButtonElement = $(theButtonElementID);		var theMenuElement = $(theMenuElementID);		getStyleObject(theMenuElementID).top=findPosY(theButtonElement)+theButtonElement.height+2+"px";		hideAllMenus();				if (theMenuElementID == "catalogContainer") $('h_btsb_link').setStyle('backgroundPosition','0px -44px');		if (theMenuElementID == "headerCartContainer") {			$('h_cb_link').setStyles({'backgroundPosition':'0px -44px','backgroundColor':'#9A9797'});			//$('headerCartTotal').setStyle('backgroundColor:#9A9797');		}		/*if (theMenuElementID == "loginFormContainer") {			var theMainContainer = $('mainContainer');			var theMainContainersX = findPosX(theMainContainer);			var theMainContainersWidth = theMainContainer.style.width;			getStyleObject(theMenuElementID).right = theMainContainersX+theMainContainersWidth+"px";		} else {*/			getStyleObject(theMenuElementID).left = findPosX(theButtonElement)+"px";		//}				try {			theMenuElement.setStyles({'display':'block','visibility':'hidden'});			whichMenuElementIDWillShow = theMenuElementID;			menuAppear = new Fx.Style(theMenuElementID, 'opacity', {				duration:300,				transition:Fx.Transitions.linear,				// onStart is flawed! I need onBeforeStart like scriptaculous!				// onStart:function(){whichMenuElementIDWillShow = theMenuElementID},				onComplete:function(){whichMenuElementIDIsShowing = theMenuElementID}			}).start(0,1);		} catch(e) {			theMenuElement.style.display = 'block';			theMenuElement.style.visibility = 'visible';			whichMenuElementIDIsShowing = theMenuElementID;		}				if (!eventObj) eventObj = window.event; // fix for MS event model		eventObj.cancelBubble = true; // make sure the buck stops here		return true;    }}function hideCart() {	$('h_cb_link').setStyles({'backgroundPosition':'0px 0px','backgroundColor':'transparent'});	//Element.setStyle('headerCartTotal',{backgroundColor:'transparent'});	getStyleObject('headerCartContainer').display='none';	whichMenuElementIDIsShowing = "none";	whichMenuElementIDWillShow = "none";}function hideAllMenus() {	getStyleObject('catalogContainer').display="none";	$('h_btsb_link').setStyle('backgroundPosition','0px 0px');	hideCart();	getStyleObject('loginFormContainer').display="none";	whichMenuElementIDIsShowing = "none";	whichMenuElementIDWillShow = "none";	//return true;}function _checkIfJustAddedToCart() { // returns true or false	var httpVars=document.location.href.split("?");	if (httpVars.length>1) { // if there's any http variables passed in the url at all		var httpVarsValues = httpVars[1].split("&"); // break up the vars (using &)		if (httpVarsValues.length>1) { // if the vars have any values			var shouldIShowCart = "no"; // init it			for (var i=0; i<httpVarsValues.length; i++) { //loop through all the variable values				if (httpVarsValues[i] == "showCart=go") var shouldIShowCart = "yes"; // if any of them match the showcart, do it			}			if (shouldIShowCart == "yes") return true; else return false;		}	}}var hideItAgain = "";		/* Thundercats are go. */function _thunderCatsHo() {	var thunderCats = "Ho!";		new SmoothScroll();		$('debugLink').onclick = function() {		getStyleObject('debug').display="block";		return true;	}		whichMenuElementIDIsShowing = "none";	whichMenuElementIDWillShow = "none";	document.onclick = hideAllMenus;		var theBrowseTheStoreLink = $('h_btsb_link');	var theYourShoppingCartLink = $('h_cb_link');	var theCheckOnYourOrdersLink = $('h_ohb_link');	var theLoginFormContainer = $('loginFormContainer');	var theCatalogContainer = $('catalogContainer');		theBrowseTheStoreLink.onclick = function (e) {		if (whichMenuElementIDIsShowing != "catalogContainer")			return !showMenuNow('catalogContainer',e,'h_btsb');		else { hideAllMenus(); this.blur(); return false; }	}	theBrowseTheStoreLink.onmouseover = function() {		// debug('1.over ');		if (whichMenuElementIDIsShowing != "catalogContainer") {			$('h_btsb_link').setStyle('backgroundPosition','0px -22px');			catalogDelay = setTimeout("showMenuNow('catalogContainer',' ','h_btsb');",250);		}	}	theBrowseTheStoreLink.onmouseout = function() {		// debug('4.out ');		if (typeof catalogDelay == "number") { clearTimeout(catalogDelay) }		if (whichMenuElementIDWillShow != "catalogContainer")			$('h_btsb_link').setStyle('backgroundPosition','0px 0px');	}	theCatalogContainer.onmouseover = function() {		if (typeof catalogDelay == "number") clearTimeout(catalogDelay); }	theCatalogContainer.onmouseout = function() {		catalogDelay = setTimeout("hideAllMenus()",1000); };		theYourShoppingCartLink.onclick = function (e) {		if (whichMenuElementIDIsShowing != "headerCartContainer") return !showMenuNow('headerCartContainer',e,'h_cb');		else { hideAllMenus(); this.blur(); return false; }	}	theYourShoppingCartLink.onmouseover = function() {		if (whichMenuElementIDIsShowing != "headerCartContainer")  {			$('h_cb_link').setStyle('backgroundPosition','0px -22px');		}	}	theYourShoppingCartLink.onmouseout = function() {		if (whichMenuElementIDWillShow != "headerCartContainer") $('h_cb_link').setStyle('backgroundPosition','0px 0px');	}			if (typeof theCheckOnYourOrdersLink != "undefined") { theCheckOnYourOrdersLink.onclick = function (e) {		if (whichMenuElementIDIsShowing != "loginFormContainer") return !showMenuNow('loginFormContainer',e,'h_ohb');		else { hideAllMenus(); return false; }	} }		// function below keeps the click from snapping loginForm shut	if (typeof theLoginFormContainer != "undefined") { 		theLoginFormContainer.onclick = function (e) { if (!e) var e = window.event; e.cancelBubble = true; }		$('loginCancelButton').onclick = function() { hideAllMenus(); }	}		if (_checkIfJustAddedToCart() == true) { 		hideItAgain = setTimeout("hideCart();",4000);		return !showMenuNow('headerCartContainer','noEvent','h_cb');	}}function animateFeaturedItem(moveMeID) {	Effect.Grow(moveMeID, {direction: 'center', duration: 3});}function _showBuyNowButton(spanID) {	if ($(spanID)) {		var theSpan = $(spanID);		theSpan.style.visibility = "visible";	} else { return false; }}function _ajaxAddToCartHref(orderForm,buyNowLink) {	$(buyNowLink).onclick = function (e) {		if (!e) var e = window.event;		e.cancelBubble = true;		buyNow(orderForm);	}}function _initShippingAddressForm(checkBoxID,elementToToggleID) {	if ($(checkBoxID)) var chk = $(checkBoxID); else return false; // compatibility check	if (getStyleObject(elementToToggleID)) var elm = getStyleObject(elementToToggleID); else return false;	chk.onclick = function () {		if (chk.checked == true) elm.display = 'none'; else elm.display = 'block';	}	chk.checked = true; elm.display = 'none'; // the default: checked}// for the initial values that dont change on checkout page 2:function _addToCOtotal(Jx) {	Jy = new Number(Jx);	if (typeof coValues != 'undefined') { coValues.push(Jy); } else { coValues = [Jy]; }}function _initStep2Totals(theSelect) {	if ($(theSelect)) var shippingMethodMenu = $(theSelect); else return false;	if ($('totalValue')) var theTotalSpan = $('totalValue'); else return false;	if ($('shippingValue')) var theShippingSpan = $('shippingValue'); else return false;	b = new Number(); c = new Number();	for ( i=0; i<coValues.length; i++ ) { if (typeof b != 'undefined') { b += coValues[i]; } else { b = coValues[i] } }	shippingMethodMenu.onchange = function() {		shippingCost = new Number(shippingMethodMenu.options[this.selectedIndex].title);		c = b + shippingCost;		theTotalSpan.innerHTML = "$"+c.toDecimals(2);		theShippingSpan.innerHTML = "$"+shippingCost.toDecimals(2);	}}function _noJSNote() {	if (DHTML) { var code = "<style type=\"text/css\">#noJSNote {display:none;}</style>"; document.write(code); }}function _initPaymentForm(gcRadioValue,ccRadioValue) {	if ($('paymentMethodForm')) var theForm = $('paymentMethodForm'); else return false;	if ($('giftCertForm')) gcDiv = $('giftCertForm');	if ($('creditCardForm')) ccDiv = $('creditCardForm');		// the default: hidden:	if (document.securePaymentForm.paymentMethod) { gcDiv.style.display = 'none'; ccDiv.style.display = 'none'; }	for ( i=0; i<document.securePaymentForm.paymentMethod.length; i++ ) {				// if the page is reloaded and form values stick:		if (document.securePaymentForm.paymentMethod[i].checked==true && document.securePaymentForm.paymentMethod[i].value==gcRadioValue)			{ ccDiv.style.display = 'none'; gcDiv.style.display = 'block'; }		if (document.securePaymentForm.paymentMethod[i].checked==true && document.securePaymentForm.paymentMethod[i].value==ccRadioValue)			{ ccDiv.style.display = 'block'; gcDiv.style.display = 'none'; }					// when the radio group is changed:		document.securePaymentForm.paymentMethod[i].onclick = function() {			selectedMethod = this.value;			if (selectedMethod==gcRadioValue) { ccDiv.style.display = 'none'; gcDiv.style.display = 'block'; }			else if (selectedMethod==ccRadioValue) { ccDiv.style.display = 'block'; gcDiv.style.display = 'none'; }			else { gcDiv.style.display = 'none'; ccDiv.style.display = 'none'; }		}	}}function _initOrderOptions() {	if ($('leaveNotes') && $('notesTextarea')) { 		theCheckbox = $('leaveNotes'); theTextbox = $('notesTextarea');		$(theTextbox).toggle(); // hide it first		theCheckbox.onclick = function() { $(theTextbox).toggle(); }	} else { return false; }	}// thanks quirksmode! http://www.quirksmode.org/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; }// URL encodefunction urlEncode(url) {	return url.replace(/\s/g, "+").replace(/&/, "&amp;").replace(/"/, "&quot;")}// Substitutefunction substitute(lbl) {var x, rg;	for(x = 1; x < arguments.length; x+=2) {		if(arguments[x] && arguments[x+1]) {			rg = new RegExp("\\{\\{"+arguments[x]+"\\}\\}", "gi");			lbl = lbl.replace(rg,  arguments[x+1]);			rg = new RegExp('~~'+arguments[x]+'~~', "gi");			lbl = lbl.replace(rg,  arguments[x+1]);		}	}	return lbl;}function visibleBox(id,skipOpenClose) {	elm1 = document.getElementById("open"+id);	elm2 = document.getElementById("close"+id);	elm3 = document.getElementById("box"+id);	if(!elm3)		return false;	if (skipOpenClose) {		elm3.style.display = (elm3.style.display == "")?"none":"";	} else if(elm1) {		if (elm1.style.display == "") {			elm1.style.display = "none";			if(elm2)				elm2.style.display = "";			elm3.style.display = "none";		} else {			elm1.style.display = "";			if(elm2)				elm2.style.display = "none";			elm3.style.display = "";		}	}}var ajaxActive = 0;var cartQ = new Array();function debug(e) { $('debugfloat').innerHTML += '<span>' + e + '</span>&nbsp;' }function buyNow(frm) { 	if (typeof hideItAgain != "undefined") { clearTimeout(hideItAgain) }	if (ajaxActive == 1) { cartQ.push(frm);	} else { ajaxCartAdd(frm);	}}function nextInCartQ () {	// debug('cartQ[0]: ' + cartQ[0]);	if (cartQ.length != 0) { 		ajaxCartAdd(cartQ[0]);		cartQ.shift(); 	} else { 		hideItAgain = setTimeout("hideCart();",4000); 	}}/* function ajaxCartAdd(form) { 	var frm = $(form);	var action = frm.action;	var inputs = $A(frm.getElementsByTagName('input'));	var params = "";	var productid = "";	for (var i=0; i<=inputs.length; i++) {		productid = (inputs[i] && inputs[i].name == "productid")? inputs[i].value : productid;		params += (inputs[i])? inputs[i].name + '=' + inputs[i].value + '&' : "";	}	params += 'ajax=go';	var myAjax = new Ajax(		action, 		{			method: 'post',			postBody: params,			onLoading: function() { ajaxActive = 1 },			// form didn't submit:			onFailure: function(e){frm.submit();},			// form submitted, but ajax return fudged:			onException: function(e){window.location.href = window.location.href + '&showCart=go';window.location.reload();},			onComplete: function(r) { refreshMinicart(r, productid) }		}	).request();		if (whichMenuElementIDIsShowing != "headerCartContainer") { 		showMenuNow('headerCartContainer','noEvent','h_cb')	}	getStyleObject('loading').display = "block";		return false;} */function ajaxCartAdd(form) { 	var frm = $(form);	var action = frm.action;	var inputs = $A(frm.getElementsByTagName('input'));	var params = "";	var productid = "";	for (var i=0; i<=inputs.length; i++) {		productid = (inputs[i] && inputs[i].name == "productid")? inputs[i].value : productid;		params += (inputs[i])? inputs[i].name + '=' + inputs[i].value + '&' : "";	}	params += 'ajax=go';	var myAjax = new Ajax(		action, 		{			method: 'post',			postBody: params,			onRequest: function() { ajaxActive = 1 },			// form didn't submit:			onFailure: function(e){frm.submit();},			// form submitted, but ajax return fudged:			onException: function(e){window.location.href = window.location.href + '&showCart=go';window.location.reload();},			// onComplete: function(r) { refreshMinicart(r, productid) }			onComplete: function(rTxt,rXML) { refreshMinicart(rXML, productid) }		}	).request();		if (whichMenuElementIDIsShowing != "headerCartContainer") { 		showMenuNow('headerCartContainer','noEvent','h_cb')	}	getStyleObject('loading').display = "block";	return false;}function refreshMinicart (responseXML, productid) {	var minicart = responseXML.documentElement.getElementsByTagName('minicart')[0].firstChild.data;	var carttotal = responseXML.documentElement.getElementsByTagName('carttotal')[0].firstChild.data;	$('minicart_data').innerHTML = minicart;	$('headerCartTotal').innerHTML = '$' + carttotal;	getStyleObject('loading').display = "none";	var productRow = $('productRow'+productid);	var highlight = new Fx.Style(productRow, 'background-color', {duration: 3000});	highlight.custom('FEFFCA', 'f7f3f3');	ajaxActive = 0;	nextInCartQ();}function ajaxProductDetail(productid) {	params = 'productid='+productid;	var productAjax = new Ajax(		'productAjax.php',		{			postBody: params,			onComplete: function(rTxt,rXML) { showInlineProductDetail(rXML, productid) }		}	).request();}function showInlineProductDetail(rXML, productid) {//	debug('productid: '+productid+' ');	var productTitle = rXML.documentElement.getElementsByTagName('producttitle')[0].firstChild.data;	var productDetail = rXML.documentElement.getElementsByTagName('productdetail')[0].firstChild.data;	var productDetailPath = rXML.documentElement.getElementsByTagName('path')[0].firstChild.data;		detailImgEl = $E('.productThumb img','product'+productid);		oldDim = detailImgEl.getDimensions();		detailImgEl.setProperties({		src: productDetailPath,		width: null,		height: null	});		newDim = detailImgEl.getDimensions();		var growDetail = new Fx.Styles(detailImgEl, {duration: 300/*, transition: fx.linear*/});	growDetail.custom({		'height': [oldDim['height'], newDim['height']],		'width': [oldDim['width'], newDim['width']]	});	//	$E('.productName','product'+productid).innerHTML = 'test ';	$E('.productDescr','product'+productid).innerHTML = productDetail;}// redefine the tips.js from mootools:var Tips = null;var Tips = new Class({ 	setOptions: function(options){		this.options = {			transitionStart: Fx.Transitions.linear,			transitionEnd: Fx.Transitions.linear,			maxTitleChars: 30,			fxDuration: 150,			maxOpacity: 1,			timeOut: 100,			clickable:false,			stayalive: false,			takeajax: false,			ajaxfile:'tooltext.php',			className: 'tooltip'		}		Object.extend(this.options, options || {});	},	initialize: function(elements, options){		this.elements = elements;		this.setOptions(options);		this.toolTip = new Element('div').addClassName(this.options.className).setStyle('position', 'absolute').injectInside(document.body);		this.toolClose = new Element('div').setProperties({'id':'close'}).injectInside(this.toolTip);		if(this.options.stayalive){			this.toolCloseText=document.createTextNode("close");			this.toolClose.appendChild(this.toolCloseText);		}		if (!this.options.takeajax) {			this.toolTitle = new Element('H4').injectInside(this.toolTip);			this.toolText = new Element('p').injectInside(this.toolTip);		} else {			this.toolText = new Element('div').setProperties({'id':'ajaxcontent'}).injectInside(this.toolTip);		}		// this.toolDivImg = new Element('div').setProperties({'id':'imgdiv'}).injectInside(this.toolTip);		// this.toolImg = new Element('img').injectInside(this.toolDivImg);		this.fx = new fx.Style(this.toolTip, 'opacity', {duration: this.options.fxDuration, wait: false}).hide();		$A(elements).each(function(el){			$(el).myText = el.title || false;			if (el.myText) el.removeAttribute('title');			if (el.href) {				if (el.href.test('http://')) el.myTitle = el.href.replace('http://', '');				if (el.href.length > this.options.maxTitleChars) el.myTitle = el.href.substr(0,this.options.maxTitleChars-3)+"...";			}			if(!this.options.takeajax) {				if (el.myText && el.myText.test('::')) {					var dual = el.myText.split('::');					el.myTitle = dual[0].trim();					el.myText = dual[1].trim();					if (dual.length==3) {						el.myImg = dual[2].trim();					} else						el.myImg='blank.gif'; }				}				if (this.options.clickable) {					el.onclick = function() {						this.show(el);						return false;					}.bind(this);				} else {					el.onmouseover = function() {						this.show(el); return false;					}.bind(this);				}				if (this.options.stayalive) {					$(this.toolClose).onclick=function() {						this.timer = $clear(this.timer); this.disappear(); 					}.bind(this);				} else {					el.onmouseout = function() {						this.timer = $clear(this.timer); this.disappear();					}.bind(this);				}				el.onmousemove = this.locate.bindAsEventListener(this);			}, this);		},	show: function (el) {		if(!this.options.takeajax){ this.toolTitle.innerHTML = el.myTitle; this.toolText.innerHTML = el.myText; /* this.toolImg.setAttribute("src",el.myImg); */ }else{ this.ajaxload(this.options.ajaxfile,el.myText.trim(),this.toolText); /* this.toolImg.setAttribute("src","images/blank.gif"); */ }		this.timer = $clear(this.timer); this.fx.options.transition = this.options.transitionStart; this.timer = this.appear.delay(this.options.timeOut, this); }, appear: function(){ this.fx.custom(this.fx.now, this.options.maxOpacity); }, ajaxload: function(file,what,tooling){ new ajax(file, {method: 'post',postBody:'action='+what,update:tooling, onFailure:function(){}, onComplete:function(){		} }).request(); return this; }, locate: function(evt){ var doc = document.documentElement; this.toolTip.setStyles({'top': evt.clientY + doc.scrollTop + 15 + 'px', 'left': evt.clientX + doc.scrollLeft - 30 + 'px'}); }, disappear: function(){ this.fx.options.transition = this.options.transitionEnd; this.fx.custom(this.fx.now, 0); } });// http://snipplr.com/view/6156/documentready/	(function () {	var ie  = !!(window.attachEvent && !window.opera);	var wk  = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525);	var fn  = [];	var run = function () { for (var i = 0; i < fn.length; i++) fn[i](); };	var d   = document;	d.ready = function (f) {		if (!ie && !wk && d.addEventListener)			return d.addEventListener('DOMContentLoaded', f, false);		if (fn.push(f) > 1) return;		if (ie)			(function () {				try { d.documentElement.doScroll('left'); run(); }				catch (err) { setTimeout(arguments.callee, 0); }			})();		else if (wk)			var t = setInterval(function () {				if (/^(loaded|complete)$/.test(d.readyState))					clearInterval(t), run();			}, 0);	};})();