// FROM: js/page.js

// include/ProductInfo.inc.asp
function updateperpage()
{
document.getElementById('link1').href=document.getElementById('hlink1').href+document.getElementById('perpage').options[document.getElementById('perpage').selectedIndex].value;
window.location=document.getElementById('link1').href
}


function updateperpageforbottom()
{
//alert(document.getElementById('perpageforbottom').options.[selectedIndex].value);
document.getElementById('link1').href=document.getElementById('hlink1').href+document.getElementById('perpageforbottom').options[document.getElementById('perpageforbottom').selectedIndex].value;
window.location=document.getElementById('link1').href
}



//search.inc.asp

function trim(str)
{
     return str.replace(/(^\s*)|(\s*$)/g,'');
}


	function UpdateCompareList(strProductID,nCategoryID)
	{

		 //if (document.getElementById("compareproductid_hidden_list") != null)
		 //{
		 //		var prevstr = document.getElementById('compareproductid_hidden_list').value;
		 //		if (document.getElementById(nproductsid).checked==false)
		 //		{
		 //			var arrproductids =prevstr.split(',');
		 //			var newstr="";

		 //			for(i=arrproductids.length-1;i>=0;i--)
		 //			{
		 //				if (arrproductids[i]==nproductsid)
		 //					{}
		 //				else
		 //					if (newstr=="")
		 //					{newstr=arrproductids[i];}
		 //					else
		 //					{newstr+=','+arrproductids[i];}
		 //			}
		 //
		 //			document.getElementById('compareproductid_hidden_list').value=newstr;
		 //		}
		 //		else
		 //		{
		 //			if (prevstr=='')
		 //			{document.getElementById('compareproductid_hidden_list').value=nproductsid;}
		 //			else
		 //			{document.getElementById('compareproductid_hidden_list').value=prevstr + ',' + nproductsid;}
		 //		}
		 //}

		var strCompareProductIDs=GetCookieValue('CompareProductIDs')
		var strCompareProductCategoryID=GetCookieValue('CompareProductCategoryID')

		if (document.getElementById(strProductID).checked==false)    //revome product id
		{

			if (strCompareProductIDs != '')
			{
				//var prevstr = document.getElementById('compareproductid_hidden_list').value
				var prevstr = strCompareProductIDs
				var arrproductids =prevstr.split(',')
				var newstr="";

				for(i=arrproductids.length-1;i>=0;i--)
				{
					if (arrproductids[i]==strProductID)
					{}
					else
					{
						if (newstr=="")
						{newstr=arrproductids[i];}
						else
						{newstr+=','+arrproductids[i];}
					}
				}

				document.cookie = 'CompareProductIDs=' + newstr;

			}
		}
		else															//add product id
		{
			if (strCompareProductCategoryID =='' || trim(strCompareProductCategoryID)!=trim(nCategoryID) || strCompareProductIDs=='')
			{
				document.cookie = 'CompareProductIDs=' + strProductID;

			}
			else
			{
				document.cookie = 'CompareProductIDs=' + strCompareProductIDs +','+strProductID;
			}
		}

		document.cookie = 'CompareProductCategoryID=' + nCategoryID;

	}


	function opencomparepage()
	{
		//var strcompareproductid = document.getElementById('compareproductid_hidden_list').value;
		//if (strcompareproductid=='')

		//	{alert('Choose products to compare.');}

		//else
		//{
			//alert (strcompareproductid);
			//window.open ('gotoproductcompare.asp?compareproductid_hidden_list='+strcompareproductid, 'newwindow', 'height=1000, width=900, top=10, left=10, toolbar=no, menubar=yes, scrollbars=yes, resizable=no,location=no, status=no');
			//window.open ('compare-product.asp?compareproductid_hidden_list='+strcompareproductid, 'newwindow', 'height=1000, width=900, top=10, left=10, toolbar=no, menubar=yes, scrollbars=yes, resizable=no,location=no, status=no');
			window.open ('compare-product.asp', 'newwindow', 'height=1000, width=900, top=10, left=10, toolbar=no, menubar=yes, scrollbars=yes, resizable=no,location=no, status=no');
		//}
	}

	function GetCookieValue(cookieName)
	{
		 var cookieString =document.cookie;
		 var start = cookieString.indexOf(cookieName + '=');
		 var strCookieValue =''

		 if (start == -1)
		 {
				strCookieValue=''
		 }
		 else
		 {
				start += cookieName.length + 1;
				var end = cookieString.indexOf(';', start);
				if (end == -1)
					{strCookieValue= unescape(cookieString.substring(start));}
				else
					{strCookieValue= unescape(cookieString.substring(start, end));}
		 }

		 return strCookieValue
	}


	function ProductSetAddtoCart()
	{
		var checkboxes = document.getElementsByName('selectsetcheckbox');
		var aOrderIDs = new Array();

		//Add Primary Products ID and Price
		//aOrderIDs[aOrderIDs.length] =document.getElementById('productsetid').value+';'+document.getElementById('productsetprice').value+';'+document.getElementById('qtyforsets').value;

		var len = checkboxes.length;
		for (var i=0; i < len; ++i)
		{
			if ( checkboxes[i].checked )
			{
				aOrderIDs[aOrderIDs.length] = checkboxes[i].value + ';'+document.getElementById('selectprice'+checkboxes[i].value).value + ';'+document.getElementById('selectqty'+checkboxes[i].value).value;
				// id;price;qty
			}
		}


		var strProductIDs = aOrderIDs.join(',');
		document.getElementById('productids').value= strProductIDs

		document.getElementById('setproductaddtocartform').submit();

		return false;
	}

	function ProductSetAddtoCartByself()
	{
		var checkboxes = document.getElementsByName('selectsetcheckbox');
		var aOrderIDs = new Array();

		//Add Primary Products ID and Price
		//aOrderIDs[aOrderIDs.length] =document.getElementById('productsetid').value+';'+document.getElementById('productsetprice').value+';'+document.getElementById('qtyforsets').value;

		var len = checkboxes.length;
		for (var i=0; i < len; ++i)
		{
			if ( checkboxes[i].checked )
			{
				aOrderIDs[aOrderIDs.length] = checkboxes[i].value + ';'+document.getElementById('selectprice'+checkboxes[i].value).value + ';'+document.getElementById('selectqty'+checkboxes[i].value).value;
				// id;price;qty
			}
		}


		var strProductIDs = aOrderIDs.join(',');
		document.getElementById('productids').value= strProductIDs

		return true;
	}


	//function TransferPrimaryCustomAction(nCustomActionID,nProductID)
	//{
	//		document.getElementById(nCustomActionID+'-'+nProductID).value = document.getElementById('primary-'+nCustomActionID).value;
	//}


	function SetProductPriceChange(nProductID,item)
	{

			if (document.getElementById('selectsetcheckbox'+nProductID).checked)
			{
				document.getElementById('selectqty'+nProductID).disabled=false
				if (document.getElementById('selectqty'+nProductID).value==0)
				{
					document.getElementById('selectqty'+nProductID).value=1
				}
			}
			else
			{
				document.getElementById('selectqty'+nProductID).disabled=true
				document.getElementById('selectqty'+nProductID).value=0
			}

	}


	function SetProductPriceUpdate()
	{

			var checkboxes = document.getElementsByName('selectsetcheckbox');
			var aOrderIDs = new Array();
			var curprice = 0;
			var nTotalItems =0;

			var len = checkboxes.length;
			for (var i=0; i < len; ++i)
			{
				if ( checkboxes[i].checked )
				{
					curprice= curprice + document.getElementById('selectprice'+checkboxes[i].value).value* document.getElementById('selectqty'+checkboxes[i].value).value;

					nTotalItems =nTotalItems +document.getElementById('selectqty'+checkboxes[i].value).value*1;
				}
			}
			//document.getElementById('SetTotalPrice').innerText="$" + curprice
			document.getElementById('SetTotalPrice').innerHTML="$" + curprice.toFixed(2)
			document.getElementById('BottomTotalPrice').innerHTML="$" + curprice.toFixed(2)
			document.getElementById('BottomTotalItems').innerHTML=nTotalItems;
			document.getElementById('setfocus').focus();
	}

	function ViewProductDetail(nProductID)
	{
			if (document.getElementById('Div1'+nProductID).style.display=='')
			{document.getElementById('Div1'+nProductID).style.display='none';}
			else
			{document.getElementById('Div1'+nProductID).style.display='';}
	}

	//--Added by Kevin on 2010-10-8 -------------------------------------
	var previousFuncCurrentPage = 1;
	function getPreviousPage(pageDirection){
		if (pageDirection == "up")
		{
			previousFuncCurrentPage -= 1;
		}
		else
		{
			previousFuncCurrentPage += 1;
		}
		document.getElementById("bodyIframe").src="previousview.asp?pageNumber=" + previousFuncCurrentPage;
	}

	var CustomerViewedFuncCurrentPage = 1;
	function getCustomerViewedPreviousPage(pageDirection){
		if (pageDirection == "up")
		{
			CustomerViewedFuncCurrentPage -= 1;
		}
		else
		{
			CustomerViewedFuncCurrentPage += 1;
		}
		document.getElementById("pageNumber").value=CustomerViewedFuncCurrentPage;
		formViewedProductIDs.action = "CustomerViewedpreviousview.asp";
		formViewedProductIDs.method = "post";
		//formViewedProductIDs.target = document.getElementById("bodyIframe");
		formViewedProductIDs.submit();
		//document.getElementById("bodyIframe").src="CustomerViewedpreviousview.asp?pageNumber=" + previousFuncCurrentPage + "&inputViewedProductIDs=" + document.getElementById("inputViewedProductIDs").value ;
	}
	//---------------------------------------------------------------------





//productfilter.inc.asp

function setformfiltervalueUpTo0(){
	document.getElementById("formfiltervalueup").selectedIndex = 0;
	try{

	}
	catch(err){}
}

function show(moreid, attributeid)
	{
//		document.getElementById(moreid).style.display = 'none';
		if (document.getElementById(moreid).innerHTML=='- Less Options')
			{		document.getElementById(attributeid).style.display = 'none';
					document.getElementById(moreid).innerHTML='+ More Options';
			}
		else
		{
			document.getElementById(attributeid).style.display = 'inline';
			document.getElementById(moreid).innerHTML='- Less Options';
		}

	}
function showmenu(menuid)
{
	if(document.getElementById('arrow_'+menuid).src=='http://www.serenitylivingstores.com/images/rightarrow.gif')
	{
	document.getElementById('arrow_'+menuid).src='http://www.serenitylivingstores.com/images/downarrow.gif'
	document.getElementById('menu_'+menuid).style.display = 'inline';
	}
	else
	{
	document.getElementById('arrow_'+menuid).src='http://www.serenitylivingstores.com/images/rightarrow.gif'
	document.getElementById('menu_'+menuid).style.display = 'none';
	}
}






//product-details.asp
	function ManageTabPanelDisplay() {
	//
	// Between the parenthesis, list the id's of the div's that 
	//     will be affected when tabs are clicked. List in any 
	//     order. Put the id's in single quotes (apostrophes) 
	//     and separate them with a comma -- all one line.
	//
	var idlist = new Array('tab1focus','tab2focus','tab3focus','tab4focus','tab5focus','tab6focus','tab1ready','tab2ready','tab3ready','tab4ready','tab5ready','tab6ready','content1','content2','content3','content4','content5','content6');

	// No other customizations are necessary.
	if(arguments.length < 1) { return; }
	for(var i = 0; i < idlist.length; i++) {
	   var block = false;
	   for(var ii = 0; ii < arguments.length; ii++) {
		  if(idlist[i] == arguments[ii]) {
			 block = true;
			 break;
			 }
		  }
	   if(block) { document.getElementById(idlist[i]).style.display = "block"; }
	   else { document.getElementById(idlist[i]).style.display = "none"; }
	   }
	}



	function ManageTabPanelDisplayset() {

	//
	// Between the parenthesis, list the id's of the div's that 
	//     will be affected when tabs are clicked. List in any 
	//     order. Put the id's in single quotes (apostrophes) 
	//     and separate them with a comma -- all one line.
	//
	var idlist = new Array('tab1focusset'+arguments[0],'tab2focusset'+arguments[0],'tab3focusset'+arguments[0],'tab4focusset'+arguments[0],'tab5focusset'+arguments[0],'tab6focusset'+arguments[0],'tab1readyset'+arguments[0],'tab2readyset'+arguments[0],'tab3readyset'+arguments[0],'tab4readyset'+arguments[0],'tab5readyset'+arguments[0],'tab6readyset'+arguments[0],'contentset1'+arguments[0],'contentset2'+arguments[0],'contentset3'+arguments[0],'contentset4'+arguments[0],'contentset5'+arguments[0],'contentset6'+arguments[0]);

	// No other customizations are necessary.
	if(arguments.length < 1) { return; }
	for(var i = 0; i < idlist.length; i++) {
	   var block = false;
	   for(var ii = 0; ii < arguments.length; ii++) {
	   //alert(idlist[i]+'==='+arguments[ii]);
		  if(idlist[i] == arguments[ii]) {
			 block = true;
			 //alert(idlist[i]);
			 break;
			 }
		  }
	   if(block) { document.getElementById(idlist[i]).style.display = "block"; }
	   else { document.getElementById(idlist[i]).style.display = "none"; }
	   }
//document.getElementById('contentset27907').style.display = "block"; 
//document.getElementById('tab2focusset7907').style.display = "block";

	}







//compare-product.asp

	function removecompareproduct(strProductID,nCategoryID) 
	{
		if ( window.opener.document.getElementById(strProductID) != null) 
		{

			window.opener.document.getElementById(strProductID).checked=false
		}
	
	   	var strCompareProductIDs=GetCookieValue('CompareProductIDs')
		var strCompareProductCategoryID=GetCookieValue('CompareProductCategoryID')
		
		
		


		if (strCompareProductIDs != '') 
		{  
			//var prevstr = document.getElementById('compareproductid_hidden_list').value
			var prevstr = strCompareProductIDs
			var arrproductids =prevstr.split(',')
			var newstr="";
			
			for(i=arrproductids.length-1;i>=0;i--) 
			{  
				if (arrproductids[i]==strProductID)
				{}
				else
				{
					if (newstr=="")
					{newstr=arrproductids[i];}
					else
					{newstr+=','+arrproductids[i];}
				}
			} 
		
			document.cookie = 'CompareProductIDs=' + newstr;
			document.cookie = 'CompareProductCategoryID=' + nCategoryID;

			//document.getElementById('compareproductid_hidden_list').value=newstr
			//window.opener.document.getElementById('compareproductid_hidden_list').value=newstr
			document.forms['compareform'].submit();
		}
	}


	function GetCookieValue(cookieName)
	{
		 var cookieString =document.cookie;
		 var start = cookieString.indexOf(cookieName + '=');
		 var strCookieValue =''
		 
		 if (start == -1)
		 {
				strCookieValue=''
		 }
		 else
		 {
				start += cookieName.length + 1;
				var end = cookieString.indexOf(';', start);
				if (end == -1) 
					{strCookieValue= unescape(cookieString.substring(start));}
				else
					{strCookieValue= unescape(cookieString.substring(start, end));}
		 }

		 return strCookieValue
	}


// FROM: js/dw_event.js
//  dw_event.js version date Apr 2008
//  basic event handling file from dyn-web.com

var dw_Event = {
  
    add: function(obj, etype, fp, cap) {
        cap = cap || false;
        if (obj.addEventListener) obj.addEventListener(etype, fp, cap);
        else if (obj.attachEvent) obj.attachEvent("on" + etype, fp);
    }, 

    remove: function(obj, etype, fp, cap) {
        cap = cap || false;
        if (obj.removeEventListener) obj.removeEventListener(etype, fp, cap);
        else if (obj.detachEvent) obj.detachEvent("on" + etype, fp);
    }, 
    
    DOMit: function(e) { 
        e = e? e: window.event; // e IS passed when using attachEvent though ...
        if (!e.target) e.target = e.srcElement;
        if (!e.preventDefault) e.preventDefault = function () { e.returnValue = false; return false; }
        if (!e.stopPropagation) e.stopPropagation = function () { e.cancelBubble = true; }
        return e;
    },
    
    getTarget: function(e) {
        e = dw_Event.DOMit(e); var tgt = e.target; 
        if (tgt.nodeType != 1) tgt = tgt.parentNode; // safari...
        return tgt;
    }
    
}

// Danny Goodman's version (DHTML def ref)
function addLoadEvent(func) {
    var oldQueue = window.onload? window.onload: function() {};
    window.onload = function() {
        oldQueue();
        func();
    }
}



// FROM: js/dw_rotator.js
/*************************************************************************
    This code is from Dynamic Web Coding at dyn-web.com
    Copyright 2001-2009 by Sharon Paine 
    See Terms of Use at www.dyn-web.com/business/terms.php
    regarding conditions under which you may use this code.
    This notice must be retained in the code as is!
    
    Version date: April 2009
    supports sequential and random rotation and IE win transition filter
    requires dw_event.js 2008 version
*************************************************************************/

// arguments: image id, rotation speed, path to images (optional), 
// new (optional) arguments: for transitions, mouse events and random rotation 
function dw_Rotator(id, speed, path, bTrans, bMouse, bRand) {
    var imgObj = document.getElementById(id); 
    if (!imgObj) { // in case name, not id attached to image
        imgObj = document.images[id];
        if (!imgObj) return;
        imgObj.id = id;
    }
    this.id = id; this.speed = speed || 4500; // default speed of rotation
    this.path = path || "";  this.bRand = bRand;
    this.ctr = 0; this.timer = 0; this.imgs = []; 
    this._setupLink(imgObj, bMouse);
    this.bTrans = bTrans && typeof imgObj.filters != 'undefined';
    var index = dw_Rotator.col.length; dw_Rotator.col[index] = this;
    this.animString = "dw_Rotator.col[" + index + "]";
}

dw_Rotator.col = []; // hold instances
dw_Rotator.resumeDelay = 400; // onmouseout resume rotation after delay

// mouse events pause/resume
dw_Rotator.prototype._setupLink = function(imgObj, bMouse) { 
    if ( imgObj.parentNode && imgObj.parentNode.tagName.toLowerCase() == 'a' ) {
        var parentLink = this.parentLink = imgObj.parentNode;
        if (bMouse) {
            dw_Event.add(parentLink, 'mouseover', dw_Rotator.pause);
            dw_Event.add(parentLink, 'mouseout', dw_Rotator.resume);
        }
    }
}

// so instance can be retrieved by id (as well as by looping through col)
dw_Rotator.getInstanceById = function(id) {
    var len = dw_Rotator.col.length, obj;
    for (var i=0; i<len; i++) {
        obj = dw_Rotator.col[i];
        if (obj.id && obj.id == id ) {
            return obj;
        }
    }
    return null;
}

dw_Rotator.prototype.on_rotate = function() {}

dw_Rotator.prototype.addImages = function() { // preloads images
    var img;
    for (var i=0; arguments[i]; i++) {
        img = new Image();
        img.src = this.path + arguments[i];
        this.imgs[this.imgs.length] = img;
    }
}

dw_Rotator.prototype.rotate = function() {
    clearTimeout(this.timer); this.timer = null;
    var imgObj = document.getElementById(this.id);
    if ( this.bRand ) {
        this.setRandomCtr();
    } else {
        if (this.ctr < this.imgs.length-1) this.ctr++;
        else this.ctr = 0;
    }
    if ( this.bTrans ) {
        this.doImageTrans(imgObj);
    } else {
        imgObj.src = this.imgs[this.ctr].src;
    }
    this.swapAlt(imgObj); this.prepAction(); this.on_rotate();
    this.timer = setTimeout( this.animString + ".rotate()", this.speed);   
}

dw_Rotator.prototype.setRandomCtr = function() {
    var i = 0, ctr;
    do { 
        ctr = Math.floor( Math.random() * this.imgs.length );
        i++; 
    } while ( ctr == this.ctr && i < 6 )// repeat attempts to get new image, if necessary
    this.ctr = ctr;
}

dw_Rotator.prototype.doImageTrans = function(imgObj) {
    imgObj.style.filter = 'blendTrans(duration=1)';
    if (imgObj.filters.blendTrans) imgObj.filters.blendTrans.Apply();
    imgObj.src = this.imgs[this.ctr].src;
    imgObj.filters.blendTrans.Play(); 
}

dw_Rotator.prototype.swapAlt = function(imgObj) {
    if ( !imgObj.setAttribute ) return;
    if ( this.alt && this.alt[this.ctr] ) {
        imgObj.setAttribute('alt', this.alt[this.ctr]);
    }
    if ( this.title && this.title[this.ctr] ) {
        imgObj.setAttribute('title', this.title[this.ctr]);
    }
}

dw_Rotator.prototype.prepAction = function() {
    if ( this.actions && this.parentLink && this.actions[this.ctr] ) {
        if ( typeof this.actions[this.ctr] == 'string' ) {
            this.parentLink.href = this.actions[this.ctr];
        } else if ( typeof this.actions[this.ctr] == 'function' ) {
            // to execute function when linked image clicked 
            // passes id used to uniquely identify instance  
            // retrieve it using the dw_Rotator.getInstanceById function 
            // so any property of the instance could be obtained for use in the function 
            var id = this.id;
            this.parentLink.href = "javascript: void " + this.actions[this.ctr] + "('" + id + "')";
        } 
    }
}

dw_Rotator.prototype.showCaption = function() {
    if ( this.captions && this.captionId ) {
        var el = document.getElementById( this.captionId );
        if ( el && this.captions[this.ctr] ) {
            el.innerHTML = this.captions[this.ctr];
        }
    }
}

// Start rotation for all instances 
dw_Rotator.start = function() {
    var len = dw_Rotator.col.length, obj;
    for (var i=0; i<len; i++) {
        obj = dw_Rotator.col[i];
        if (obj && obj.id ) {
            clearTimeout( obj.timer ); obj.timer = null; 
            obj.timer = setTimeout( obj.animString + ".rotate()", obj.speed);
        }
    }
}

// Stop rotation for all instances 
dw_Rotator.stop = function() {
    var len = dw_Rotator.col.length, obj;
    for (var i=0; i<len; i++) {
        obj = dw_Rotator.col[i];
        if (obj ) { clearTimeout(obj.timer); obj.timer = null; }
    }
}

// for stopping/starting (onmouseover/out)
dw_Rotator.pause = function(e) {	
    e = dw_Event.DOMit(e);
    var id = e.target.id;
    var obj = dw_Rotator.getInstanceById(id);
    if ( obj ) { clearTimeout( obj.timer ); obj.timer = null; }
}

dw_Rotator.resume = function(e) {
    e = dw_Event.DOMit(e);
    var id = e.target.id;
    var obj = dw_Rotator.getInstanceById(id);
    if ( obj && obj.id ) {
        obj.timer = setTimeout( obj.animString + ".rotate()", dw_Rotator.resumeDelay );
    }
}

// calls constructor, addImages, adds actions, etc.
dw_Rotator.setup = function () {
    if (!document.getElementById) return;
    var i, j, rObj, r, imgAr, len;
    for (i=0; arguments[i]; i++) {
        rObj = arguments[i];
        r = new dw_Rotator(rObj.id, rObj.speed, rObj.path, rObj.bTrans, rObj.bMouse, rObj.bRand);
        try {
            imgAr = rObj.images; len = imgAr.length;
            for (j=0; j<len; j++) { r.addImages( imgAr[j] ); }
            if( rObj.num ) r.ctr = rObj.num; // for seq after random selection
            if ( rObj.actions && rObj.actions.length == len ) {
                r.addProp('actions', rObj.actions);
            }
            if ( rObj.alt && rObj.alt.length == len ) {
                r.addProp('alt', rObj.alt);
            }
            if ( rObj.title && rObj.title.length == len ) {
                r.addProp('title', rObj.title);
            }
            if ( rObj.captions ) {
                r.addProp('captions', rObj.captions);
                r.captionId = rObj.captionId;
                dw_Rotator.addRotateEvent(r, function (id) { 
                    return function() { dw_Rotator.getInstanceById(id).showCaption(); }
                }(rObj.id) ); // see Crockford js good parts pg 39
            }
        } catch (e) { 
            //alert(e.message); 
        }
    }
    dw_Rotator.start();
}

// add to on_rotate for specified instance (r)
// see usage above for captions
dw_Rotator.addRotateEvent = function( r, fp ) {
    var old_on_rotate = r.on_rotate;
    r.on_rotate = function() { old_on_rotate(); fp(); }
}

// for adding actions, alt, title
dw_Rotator.prototype.addProp = function(prop, ar) {
    if ( !this[prop] ) {
        this[prop] = [];
    }
    var len = ar.length; 
    for (var i=0; i < len; i++) {
        this[prop][ this[prop].length ] = ar[i]; 
    }
}

/////////////////////////////////////////////////////////////////////
// Reminder about licensing requirements
// See Terms of Use at www.dyn-web.com/business/terms.php
// OK to remove after purchasing a license or if using on a personal site.
function dw_checkAuth() {

}
dw_Event.add( window, 'load', dw_checkAuth);
/////////////////////////////////////////////////////////////////////


// FROM: js/add_bookmark.js
var urlAddress = "http://www.serenitylivingstores.com/"; 
var pageName = "Serenity Living Stores Inc."; 

function addToFavorites() { 
	if ( navigator.appName=='Microsoft Internet Explorer')
	{
		window.external.AddFavorite(urlAddress,pageName) 
	} 
	else {alert('Please press CTRL+D to Bookmark this website!'); } 
}



// FROM: js/image_resize.js

function resize(which, max) {
  var elem = document.getElementById(which);
  if (elem == undefined || elem == null) return false;
  if (max == undefined) max = 100;
  if (elem.width > elem.height) {
    if (elem.width > max) elem.width = max;
  } else {
    if (elem.height > max) elem.height = max;
  }
}



// FROM: https://seal.buysafe.com/private/rollover/rollover.js
/*

 buySAFE Rollover Loader
 Copyright 2010, buySAFE, Inc.
 $Revision: 1.216 $
*/
var bs_R,bsUndef="undefined";if(typeof bs_R==bsUndef||!bs_R)bs_R={};bs_R.err=function(a,b){if(b)a+=": "+b.message;window.setTimeout(function(){throw Error("buySAFE: "+a);},0)};bs_R.GetCodeBase=function(){for(var a="https://seal.buysafe.com/private/rollover/",b=document.getElementsByTagName("script"),c,d=0;d<b.length;d++)if(c=b[d].src.match(/(.*)rollover(?:\.unpacked)?\.js/i))a=c[1];return a};
bs_R.onLoad=function(a){if(bs_R.fOnLoad)a&&a();else{var b=window.onload;window.onload=function(c){var d;try{b&&b(c)}catch(e){d=e}finally{a&&a(c);if(d)throw d;}}}};bs_R.AppendJS=function(a){var b=document.createElement("script");b.type="text/javascript";b.src=a;(a=document.getElementsByTagName("script")[0])&&a.parentNode.insertBefore(b,a)};bs_R.NewObject=function(a,b){b||(b=window);if(!b[a]){b[a]={};return true}return false};
if(bs_R.NewObject("buySAFE")||!buySAFE.Loaded){if(!buySAFE.Hash)buySAFE.Hash="";if(!buySAFE.Guarantee)buySAFE.Guarantee={order:"",total:"",email:""};if(!buySAFE.Seal)buySAFE.Seal={bgcolor:"#FFFFFF"};if(!buySAFE.Button)buySAFE.Button={bgcolor:"#FFFFFF"};buySAFE.Loaded=1}var buySAFESealConfig=buySAFE.Seal,buySAFEButtonConfig=buySAFE.Button;
bs_R.Loader=function(){var a=window,b=["WriteBuySafeButtonAjax","WriteBuySafeButtonAjaxInvisible","WriteBuySafeSeal","WriteBuySafeButton","WriteBuySafeButtonInvisible","WriteBuySafeTrusteeSeal","buysafeGetAffiliateURL","WriteBuySafeAffiliateSeal","WriteBuySafeTrustRatingSeal","WriteBuySafeTrustSeal","WriteBuySafeGuarantee","WriteBuySafeKickers"];bs_R.oLoader={};for(var c=0;c<b.length;c++){bs_R.oLoader[b[c]]=0;a[b[c]]=function(){var d=arguments,e=d.callee.sName;a.setTimeout(function(){bs_R.oLoader[e]++<=
100&&a[e].apply(null,d)},200)};a[b[c]].sName=b[c]}bs_R.onLoad(function(){bs_R.fOnLoad=1});a.setTimeout(function(){bs_R.AppendJS(bs_R.GetCodeBase()+"rollover.core.js")},100)};bs_R.Loader();



// FROM: js/fw_menu.js
var strimage, strimage, strimageno
/**
* fw_menu 24OCT2000 Version 4.0
* John Ahlquist, October 2000
* Copyright (c) 2000 Macromedia, Inc.
*
* based on menu.js
* by gary smith, July 1997
* Copyright (c) 1997-1999 Netscape Communications Corp.
*
* Netscape grants you a royalty free license to use or modify this
* software provided that this copyright notice appears on all copies.
* This software is provided "AS IS," without a warranty of any kind.
*/
function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh) {


    this.version = "990702 [Menu; menu.js]";
    this.type = "Menu";
    this.menuWidth = mw;
    this.menuItemHeight = mh;
    this.fontSize = fs || 12;
    this.fontWeight = "bold";
    this.fontFamily = fnt || "arial,helvetica,verdana,sans-serif";
    this.fontColor = fclr || "#cccccc";
    this.fontColorHilite = fhclr || "#ffffff";
    this.bgColor = "#ffffff";
    this.menuBorder = 1;
    this.menuItemBorder = 1;
    this.menuItemBgColor = bg || "#eeeeee";
    this.menuLiteBgColor = "#ffffff";
    this.menuBorderBgColor = "#777777";
    this.menuHiliteBgColor = bgh || "#000084";
    this.menuContainerBgColor = "#cccccc";
    this.childMenuIcon = "arrows.gif";
    this.items = new Array();
    this.actions = new Array();
    this.childMenus = new Array();
    this.hideOnMouseOut = true;

    this.addMenuItem = addMenuItem;
    this.addMenuSeparator = addMenuSeparator;
    this.writeMenus = writeMenus;
    this.FW_showMenu = FW_showMenu;
    this.onMenuItemOver = onMenuItemOver;
    this.onMenuItemAction = onMenuItemAction;
    this.hideMenu = hideMenu;
    this.hideChildMenu = hideChildMenu;

    if (!window.menus) window.menus = new Array();
    this.label = label || "menuLabel" + window.menus.length;
    window.menus[this.label] = this;
    window.menus[window.menus.length] = this;
    if (!window.activeMenus) window.activeMenus = new Array();
}

function addMenuItem(label, action) {
    this.items[this.items.length] = label;
    this.actions[this.actions.length] = action;
}

function addMenuSeparator() {
    this.items[this.items.length] = "separator";
    this.actions[this.actions.length] = "";
    this.menuItemBorder = 0;
}

// For NS6. 
function FIND(item) {
    if (document.all) return (document.all[item]);
    if (document.getElementById) return (document.getElementById(item));
    return (false);
}

function writeMenus(container) {
    if (window.triedToWriteMenus) return;

    if (!container && document.layers) {
        window.delayWriteMenus = this.writeMenus;
        var timer = setTimeout('delayWriteMenus()', 250);
        container = new Layer(100);
        clearTimeout(timer);
    } else if (document.all || document.hasChildNodes) {
        document.writeln('<SPAN ID="menuContainer"></SPAN>');
        container = FIND("menuContainer");
    }

    window.fwHideMenuTimer = null;
    if (!container) return;
    window.triedToWriteMenus = true;
    container.isContainer = true;
    container.menus = new Array();
    for (var i = 0; i < window.menus.length; i++)
        container.menus[i] = window.menus[i];
    window.menus.length = 0;
    var countMenus = 0;
    var countItems = 0;
    var top = 0;
    var content = '';
    var lrs = false;
    var theStat = "";
    var tsc = 0;
    if (document.layers) lrs = true;
    for (var i = 0; i < container.menus.length; i++, countMenus++) {
        var menu = container.menus[i];
        if (menu.bgImageUp) {
            menu.menuBorder = 0;
            menu.menuItemBorder = 0;
        }
        if (lrs) {
            var menuLayer = new Layer(100, container);
            var lite = new Layer(100, menuLayer);
            lite.top = menu.menuBorder;
            lite.left = menu.menuBorder;
            var body = new Layer(100, lite);
            body.top = menu.menuBorder;
            body.left = menu.menuBorder;
        } else {
            content += '' +
			'<DIV ID="menuLayer' + countMenus + '" STYLE="position:absolute;z-index:1;left:10;top:' + (i * 100) + ';visibility:hidden;">\n' +
			'  <DIV ID="menuLite' + countMenus + '" STYLE="position:absolute;z-index:1;left:' + menu.menuBorder + ';top:' + menu.menuBorder + ';visibility:hide" onMouseOut="mouseoutMenu();">\n' +
			'	 <DIV ID="menuFg' + countMenus + '" STYLE="position:absolute;left:' + menu.menuBorder + ';top:' + menu.menuBorder + ';visibility:hide;">\n' +
			'';
        }
        var x = i;
        for (var i = 0; i < menu.items.length; i++) {
            var item = menu.items[i];
            var childMenu = false;
            var defaultHeight = menu.fontSize + 6;
            var defaultIndent = menu.fontSize;
            if (item.label) {
                item = item.label;
                childMenu = true;
            }
            menu.menuItemHeight = menu.menuItemHeight || defaultHeight;
            menu.menuItemIndent = menu.menuItemIndent || defaultIndent;
            var itemProps = 'font-family:' + menu.fontFamily + ';font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + ';';
            if (menu.fontStyle) itemProps += 'font-style:' + menu.fontStyle + ';';
            if (document.all)
                itemProps += 'font-size:' + menu.fontSize + ';" onMouseOver="onMenuItemOver(null,this);" onClick="onMenuItemAction(null,this);';
            else if (!document.layers) {
                itemProps += 'font-size:' + menu.fontSize + 'px;'; // zilla wants 12px.
            }
            var l;
            if (lrs) {
                l = new Layer(800, body);
            }
            var dTag = '<DIV ID="menuItem' + countItems + '" STYLE="position:absolute;left:0;top:' + (i * menu.menuItemHeight) + ';' + itemProps + '">';
            var dClose = '</DIV>'
            if (menu.bgImageUp) {
                menu.menuBorder = 0;
                menu.menuItemBorder = 0;
                dTag = '<DIV ID="menuItem' + countItems + '" STYLE="background:url(' + menu.bgImageUp + ');position:absolute;left:0;top:' + (i * menu.menuItemHeight) + ';' + itemProps + '">';
                if (document.layers) {
                    dTag = '<LAYER BACKGROUND="' + menu.bgImageUp + '" ID="menuItem' + countItems + '" TOP="' + (i * menu.menuItemHeight) + '" style="' + itemProps + '">';
                    dClose = '</LAYER>';
                }
            }
            var textProps = 'position:absolute;left:' + menu.menuItemIndent + ';top:1;';
            if (lrs) {
                textProps += itemProps;
                dTag = "";
                dClose = "";
            }

            var dText = '<DIV ID="menuItemText' + countItems + '" STYLE="' + textProps + 'color:' + menu.fontColor + ';">' + item + '&nbsp</DIV>\n<DIV ID="menuItemHilite' + countItems + '" STYLE="' + textProps + 'top:1;color:' + menu.fontColorHilite + ';visibility:hidden;">' + item + '&nbsp</DIV>';
            if (item == "separator") {
                content += (dTag + '<DIV ID="menuSeparator' + countItems + '" STYLE="position:absolute;left:1;top:2;"></DIV>\n<DIV ID="menuSeparatorLite' + countItems + '" STYLE="position:absolute;left:1;top:2;"></DIV>\n' + dClose);
            } else if (childMenu) {
                content += (dTag + dText + '<DIV ID="childMenu' + countItems + '" STYLE="position:absolute;left:0;top:3;"><IMG SRC="' + menu.childMenuIcon + '"></DIV>\n' + dClose);
            } else {
                content += (dTag + dText + dClose);
            }
            if (lrs) {
                l.document.open("text/html");
                l.document.writeln(content);
                l.document.close();
                content = '';
                theStat += "-";
                tsc++;
                if (tsc > 50) {
                    tsc = 0;
                    theStat = "";
                }
                status = theStat;
            }
            countItems++;
        }
        if (lrs) {
            // focus layer
            var focusItem = new Layer(100, body);
            focusItem.visiblity = "hidden";
            focusItem.document.open("text/html");
            focusItem.document.writeln("&nbsp;");
            focusItem.document.close();
        } else {
            content += '	  <DIV ID="focusItem' + countMenus + '" STYLE="position:absolute;left:0;top:0;visibility:hide;" onClick="onMenuItemAction(null,this);">&nbsp;</DIV>\n';
            content += '   </DIV>\n  </DIV>\n</DIV>\n';
        }
        i = x;
    }
    if (document.layers) {
        container.clip.width = window.innerWidth;
        container.clip.height = window.innerHeight;
        container.onmouseout = mouseoutMenu;
        container.menuContainerBgColor = this.menuContainerBgColor;
        for (var i = 0; i < container.document.layers.length; i++) {
            proto = container.menus[i];
            var menu = container.document.layers[i];
            container.menus[i].menuLayer = menu;
            container.menus[i].menuLayer.Menu = container.menus[i];
            container.menus[i].menuLayer.Menu.container = container;
            var body = menu.document.layers[0].document.layers[0];
            body.clip.width = proto.menuWidth || body.clip.width;
            body.clip.height = proto.menuHeight || body.clip.height;
            for (var n = 0; n < body.document.layers.length - 1; n++) {
                var l = body.document.layers[n];
                l.Menu = container.menus[i];
                l.menuHiliteBgColor = proto.menuHiliteBgColor;
                l.document.bgColor = proto.menuItemBgColor;
                l.saveColor = proto.menuItemBgColor;
                l.onmouseover = proto.onMenuItemOver;
                l.onclick = proto.onMenuItemAction;
                l.action = container.menus[i].actions[n];
                l.focusItem = body.document.layers[body.document.layers.length - 1];
                l.clip.width = proto.menuWidth || body.clip.width + proto.menuItemIndent;
                l.clip.height = proto.menuItemHeight || l.clip.height;
                if (n > 0) l.top = body.document.layers[n - 1].top + body.document.layers[n - 1].clip.height + proto.menuItemBorder;
                l.hilite = l.document.layers[1];
                if (proto.bgImageUp) l.background.src = proto.bgImageUp;
                l.document.layers[1].isHilite = true;
                if (l.document.layers[0].id.indexOf("menuSeparator") != -1) {
                    l.hilite = null;
                    l.clip.height -= l.clip.height / 2;
                    l.document.layers[0].document.bgColor = proto.bgColor;
                    l.document.layers[0].clip.width = l.clip.width - 2;
                    l.document.layers[0].clip.height = 1;
                    l.document.layers[1].document.bgColor = proto.menuLiteBgColor;
                    l.document.layers[1].clip.width = l.clip.width - 2;
                    l.document.layers[1].clip.height = 1;
                    l.document.layers[1].top = l.document.layers[0].top + 1;
                } else if (l.document.layers.length > 2) {
                    l.childMenu = container.menus[i].items[n].menuLayer;
                    l.document.layers[2].left = l.clip.width - 13;
                    l.document.layers[2].top = (l.clip.height / 2) - 4;
                    l.document.layers[2].clip.left += 3;
                    l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
                }
            }
            body.document.bgColor = proto.bgColor;
            body.clip.width = l.clip.width + proto.menuBorder;
            body.clip.height = l.top + l.clip.height + proto.menuBorder;
            var focusItem = body.document.layers[n];
            focusItem.clip.width = body.clip.width;
            focusItem.Menu = l.Menu;
            focusItem.top = -30;
            focusItem.captureEvents(Event.MOUSEDOWN);
            focusItem.onmousedown = onMenuItemDown;
            menu.document.bgColor = proto.menuBorderBgColor;
            var lite = menu.document.layers[0];
            lite.document.bgColor = proto.menuLiteBgColor;
            lite.clip.width = body.clip.width + 1;
            lite.clip.height = body.clip.height + 1;
            menu.clip.width = body.clip.width + (proto.menuBorder * 3);
            menu.clip.height = body.clip.height + (proto.menuBorder * 3);
        }
    } else {
        if ((!document.all) && (container.hasChildNodes)) {
            container.innerHTML = content;
        } else {
            container.document.open("text/html");
            container.document.writeln(content);
            container.document.close();
        }
        if (!FIND("menuLayer0")) return;
        var menuCount = 0;
        for (var x = 0; x < container.menus.length; x++) {
            var menuLayer = FIND("menuLayer" + x);
            container.menus[x].menuLayer = "menuLayer" + x;
            menuLayer.Menu = container.menus[x];
            menuLayer.Menu.container = "menuLayer" + x;
            menuLayer.style.zIndex = 1;
            var s = menuLayer.style;
            s.top = s.pixelTop = -300;
            s.left = s.pixelLeft = -300;

            var menu = container.menus[x];
            menu.menuItemWidth = menu.menuWidth || menu.menuIEWidth || 140;
            menuLayer.style.backgroundColor = menu.menuBorderBgColor;
            var top = 0;
            for (var i = 0; i < container.menus[x].items.length; i++) {
                var l = FIND("menuItem" + menuCount);
                l.Menu = container.menus[x];
                if (l.addEventListener) { // ns6
                    l.style.width = menu.menuItemWidth;
                    l.style.height = menu.menuItemHeight;
                    l.style.top = top;
                    l.addEventListener("mouseover", onMenuItemOver, false);
                    l.addEventListener("click", onMenuItemAction, false);
                    l.addEventListener("mouseout", mouseoutMenu, false);
                } else { //ie
                    l.style.pixelWidth = menu.menuItemWidth;
                    l.style.pixelHeight = menu.menuItemHeight;
                    l.style.pixelTop = top;
                }
                top = top + menu.menuItemHeight + menu.menuItemBorder;
                l.style.fontSize = menu.fontSize;
                l.style.backgroundColor = menu.menuItemBgColor;
                l.style.visibility = "inherit";
                l.saveColor = menu.menuItemBgColor;
                l.menuHiliteBgColor = menu.menuHiliteBgColor;
                l.action = container.menus[x].actions[i];
                l.hilite = FIND("menuItemHilite" + menuCount);
                l.focusItem = FIND("focusItem" + x);
                l.focusItem.style.pixelTop = l.focusItem.style.top = -30;
                var childItem = FIND("childMenu" + menuCount);
                if (childItem) {
                    l.childMenu = container.menus[x].items[i].menuLayer;
                    childItem.style.pixelLeft = childItem.style.left = menu.menuItemWidth - 11;
                    childItem.style.pixelTop = childItem.style.top = (menu.menuItemHeight / 2) - 4;
                    //childItem.style.pixelWidth = 30 || 7;
                    //childItem.style.clip = "rect(0 7 7 3)";
                    l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
                }
                var sep = FIND("menuSeparator" + menuCount);
                if (sep) {
                    sep.style.clip = "rect(0 " + (menu.menuItemWidth - 3) + " 1 0)";
                    sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;
                    sep.style.backgroundColor = menu.bgColor;
                    sep = FIND("menuSeparatorLite" + menuCount);
                    sep.style.clip = "rect(1 " + (menu.menuItemWidth - 3) + " 2 0)";
                    sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;
                    sep.style.backgroundColor = menu.menuLiteBgColor;
                    l.style.height = l.style.pixelHeight = menu.menuItemHeight / 2;
                    l.isSeparator = true
                    top -= (menu.menuItemHeight - l.style.pixelHeight)
                } else {
                    l.style.cursor = "hand"
                }
                menuCount++;
            }
            menu.menuHeight = top - 1;
            var lite = FIND("menuLite" + x);
            var s = lite.style;
            s.height = s.pixelHeight = menu.menuHeight + (menu.menuBorder * 2);
            s.width = s.pixelWidth = menu.menuItemWidth + (menu.menuBorder * 2);
            s.backgroundColor = menu.menuLiteBgColor;

            var body = FIND("menuFg" + x);
            s = body.style;
            s.height = s.pixelHeight = menu.menuHeight + menu.menuBorder;
            s.width = s.pixelWidth = menu.menuItemWidth + menu.menuBorder;
            s.backgroundColor = menu.bgColor;

            s = menuLayer.style;
            s.width = s.pixelWidth = menu.menuItemWidth + (menu.menuBorder * 4);
            s.height = s.pixelHeight = menu.menuHeight + (menu.menuBorder * 4);
        }
    }
    /*if (document.captureEvents) {	
    document.captureEvents(Event.MOUSEUP);
    }
    if (document.addEventListener) {	
    document.addEventListener("mouseup", onMenuItemOver, false);
    }*/
    if (document.layers && window.innerWidth) {
        window.onresize = NS4resize;
        window.NS4sIW = window.innerWidth;
        window.NS4sIH = window.innerHeight;
    }
    ///document.onmouseup = mouseupMenu;
    window.fwWroteMenu = true;
    status = "";
}

function NS4resize() {
    if (NS4sIW < window.innerWidth ||
		NS4sIW > window.innerWidth ||
		NS4sIH > window.innerHeight ||
		NS4sIH < window.innerHeight) {
        window.location.reload();
    }
}

function onMenuItemOver(e, l) {
    strimage = ''; /*document.getElementById('pic').value*/

    if (strimage == 'howtoorder') {
        MM_swapImage('howtoorder', '', 'images/howtoorder_over.gif', 1)
    }
    if (strimage == 'customerservice') {
        MM_swapImage('customerservice', '', 'images/customerservice_over.gif', 1)
    }
    if (strimage == 'aboutus') {
        MM_swapImage('aboutus', '', 'images/aboutus_over.gif', 1)
    }

    FW_clearTimeout();
    l = l || this;
    a = window.ActiveMenuItem;
    if (document.layers) {
        if (a) {
            a.document.bgColor = a.saveColor;
            if (a.hilite) a.hilite.visibility = "hidden";
            if (a.Menu.bgImageOver) {
                a.background.src = a.Menu.bgImageUp;
            }
            a.focusItem.top = -100;
            a.clicked = false;
        }
        if (l.hilite) {
            l.document.bgColor = l.menuHiliteBgColor;
            l.zIndex = 1;
            l.hilite.visibility = "inherit";
            l.hilite.zIndex = 2;
            l.document.layers[1].zIndex = 1;
            l.focusItem.zIndex = this.zIndex + 2;
        }
        if (l.Menu.bgImageOver) {
            l.background.src = l.Menu.bgImageOver;
        }
        l.focusItem.top = this.top;
        l.Menu.hideChildMenu(l);
    } else if (l.style && l.Menu) {
        if (a) {
            a.style.backgroundColor = a.saveColor;
            if (a.hilite) a.hilite.style.visibility = "hidden";
            if (a.Menu.bgImageUp) {
                a.style.background = "url(" + a.Menu.bgImageUp + ")"; ;
            }
        }
        if (l.isSeparator) return;
        l.style.backgroundColor = l.menuHiliteBgColor;
        l.zIndex = 1;  // magic IE 4.5 mac happy doohicky.	jba
        if (l.Menu.bgImageOver) {
            l.style.background = "url(" + l.Menu.bgImageOver + ")";
        }
        if (l.hilite) {
            l.style.backgroundColor = l.menuHiliteBgColor;
            l.hilite.style.visibility = "inherit";
        }
        l.focusItem.style.top = l.focusItem.style.pixelTop = l.style.pixelTop;
        l.focusItem.style.zIndex = l.zIndex + 1;
        l.Menu.hideChildMenu(l);
    } else {
        return; // not a menu - magic IE 4.5 mac happy doohicky.  jba
    }
    window.ActiveMenuItem = l;
}

function onMenuItemAction(e, l) {
    l = window.ActiveMenuItem;
    if (!l) return;
    hideActiveMenus();
    if (l.action) {
        eval("" + l.action);
    }
    window.ActiveMenuItem = 0;
}

function FW_clearTimeout() {
    if (fwHideMenuTimer) clearTimeout(fwHideMenuTimer);
    fwHideMenuTimer = null;
    fwDHFlag = false;
}
function FW_startTimeout() {
    fwStart = new Date();
    fwDHFlag = true;
    fwHideMenuTimer = setTimeout("fwDoHide()", 1000);
}

function fwDoHide() {
    if (!fwDHFlag) return;
    var elapsed = new Date() - fwStart;
    if (elapsed < 1000) {
        fwHideMenuTimer = setTimeout("fwDoHide()", 1100 - elapsed);
        return;
    }
    fwDHFlag = false;
    hideActiveMenus();
    window.ActiveMenuItem = 0;
}

function alertSize() {
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement &&
      (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    //	window.alert( 'Width = ' + myWidth + '\nHeight = ' + myHeight );
    return myWidth;
}

function FW_showMenu(menu, x, y, child) {

    // create offset for dynamic width
    /*
    var temp_x = alertSize();
    if (temp_x > 760) {
    var zz = ((temp_x - 760) / 2);
    x = (x + zz);
    }
    */

    // original
    if (!window.fwWroteMenu) return;
    FW_clearTimeout();
    if (document.layers) {
        if (menu) {
            var l = menu.menuLayer || menu;
            l.left = 1;
            l.top = 1;
            hideActiveMenus();
            if (this.visibility) l = this;
            window.ActiveMenu = l;
        } else {
            var l = child;
        }
        if (!l) return;
        for (var i = 0; i < l.layers.length; i++) {
            if (!l.layers[i].isHilite)
                l.layers[i].visibility = "inherit";
            if (l.layers[i].document.layers.length > 0)
                FW_showMenu(null, "relative", "relative", l.layers[i]);
        }
        if (l.parentLayer) {
            if (x != "relative")
                l.parentLayer.left = x || window.pageX || 0;
            if (l.parentLayer.left + l.clip.width > window.innerWidth)
                l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
            if (y != "relative")
                l.parentLayer.top = y || window.pageY || 0;
            if (l.parentLayer.isContainer) {
                l.Menu.xOffset = window.pageXOffset;
                l.Menu.yOffset = window.pageYOffset;
                l.parentLayer.clip.width = window.ActiveMenu.clip.width + 2;
                l.parentLayer.clip.height = window.ActiveMenu.clip.height + 2;
                if (l.parentLayer.menuContainerBgColor) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
            }
        }
        l.visibility = "inherit";
        if (l.Menu) l.Menu.container.visibility = "inherit";
    } else if (FIND("menuItem0")) {
        var l = menu.menuLayer || menu;
        hideActiveMenus();
        if (typeof (l) == "string") {
            l = FIND(l);
        }
        window.ActiveMenu = l;
        var s = l.style;
        s.visibility = "inherit";
        if (x != "relative")
            s.left = s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
        if (y != "relative")
            s.top = s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
        l.Menu.xOffset = document.body.scrollLeft;
        l.Menu.yOffset = document.body.scrollTop;
    }
    if (menu) {
        window.activeMenus[window.activeMenus.length] = l;
    }
}

function onMenuItemDown(e, l) {
    var a = window.ActiveMenuItem;
    if (document.layers) {
        if (a) {
            a.eX = e.pageX;
            a.eY = e.pageY;
            a.clicked = true;
        }
    }
}

function mouseupMenu(e) {
    hideMenu(true, e);
    hideActiveMenus();
    return true;
}

function mouseoutMenu() {
    hideMenu(false, false);
    return true;
}


function hideMenu(mouseup, e) {
    var a = window.ActiveMenuItem;
    if (a && document.layers) {
        a.document.bgColor = a.saveColor;
        a.focusItem.top = -30;
        if (a.hilite) a.hilite.visibility = "hidden";
        if (mouseup && a.action && a.clicked && window.ActiveMenu) {
            if (a.eX <= e.pageX + 15 && a.eX >= e.pageX - 15 && a.eY <= e.pageY + 10 && a.eY >= e.pageY - 10) {
                setTimeout('window.ActiveMenu.Menu.onMenuItemAction();', 2);
            }
        }
        a.clicked = false;
        if (a.Menu.bgImageOver) {
            a.background.src = a.Menu.bgImageUp;
        }
    } else if (window.ActiveMenu && FIND("menuItem0")) {
        if (a) {
            a.style.backgroundColor = a.saveColor;
            if (a.hilite) a.hilite.style.visibility = "hidden";
            if (a.Menu.bgImageUp) {
                a.style.background = "url(" + a.Menu.bgImageUp + ")"; ;
            }
        }
    }
    if (!mouseup && window.ActiveMenu) {
        if (window.ActiveMenu.Menu) {
            if (window.ActiveMenu.Menu.hideOnMouseOut) {
                FW_startTimeout();
            }
            return (true);
        }
    }
    return (true);
}

function PxToNum(pxStr) { // pxStr == 27px, we want 27.
    if (pxStr.length > 2) {
        n = Number(pxStr.substr(0, pxStr.length - 2));
        return (n);
    }
    return (0);
}

function hideChildMenu(hcmLayer) {
    FW_clearTimeout();
    var l = hcmLayer;
    for (var i = 0; i < l.Menu.childMenus.length; i++) {
        var theLayer = l.Menu.childMenus[i];
        if (document.layers) {
            theLayer.visibility = "hidden";
        } else {
            theLayer = FIND(theLayer);
            theLayer.style.visibility = "hidden";
        }
        theLayer.Menu.hideChildMenu(theLayer);
    }

    if (l.childMenu) {
        var childMenu = l.childMenu;
        if (document.layers) {
            l.Menu.FW_showMenu(null, null, null, childMenu.layers[0]);
            childMenu.zIndex = l.parentLayer.zIndex + 1;
            childMenu.top = l.top + l.parentLayer.top + l.Menu.menuLayer.top + l.Menu.menuItemHeight / 3;
            if (childMenu.left + childMenu.clip.width > window.innerWidth) {
                childMenu.left = l.parentLayer.left - childMenu.clip.width + l.Menu.menuLayer.left + 15;
                l.Menu.container.clip.left -= childMenu.clip.width;
            } else {
                childMenu.left = l.parentLayer.left + l.parentLayer.clip.width + l.Menu.menuLayer.left - 5;
            }
            var w = childMenu.clip.width + childMenu.left - l.Menu.container.clip.left;
            if (w > l.Menu.container.clip.width)
                l.Menu.container.clip.width = w;
            var h = childMenu.clip.height + childMenu.top - l.Menu.container.clip.top;
            if (h > l.Menu.container.clip.height) l.Menu.container.clip.height = h;
            l.document.layers[1].zIndex = 0;
            childMenu.visibility = "inherit";
        } else if (FIND("menuItem0")) {
            childMenu = FIND(l.childMenu);
            var menuLayer = FIND(l.Menu.menuLayer);
            var s = childMenu.style;
            s.zIndex = menuLayer.style.zIndex + 1;
            if (document.all) { // ie case.
                s.pixelTop = l.style.pixelTop + menuLayer.style.pixelTop + l.Menu.menuItemHeight / 3;
                s.left = s.pixelLeft = (menuLayer.style.pixelWidth) + menuLayer.style.pixelLeft - 5;
            } else { // zilla case
                var top = PxToNum(l.style.top) + PxToNum(menuLayer.style.top) + l.Menu.menuItemHeight / 3;
                var left = (PxToNum(menuLayer.style.width)) + PxToNum(menuLayer.style.left) - 5;
                s.top = top;
                s.left = left;
            }
            childMenu.style.visibility = "inherit";
        } else {
            return;
        }
        window.activeMenus[window.activeMenus.length] = childMenu;
    }
}

function hideActiveMenus() {
    MM_swapImgRestore()
    if (!window.activeMenus) return;
    for (var i = 0; i < window.activeMenus.length; i++) {
        if (!activeMenus[i]) continue;
        if (activeMenus[i].visibility && activeMenus[i].Menu) {
            activeMenus[i].visibility = "hidden";
            activeMenus[i].Menu.container.visibility = "hidden";
            activeMenus[i].Menu.container.clip.left = 0;
        } else if (activeMenus[i].style) {
            var s = activeMenus[i].style;
            s.visibility = "hidden";
            s.left = -200;
            s.top = -200;
        }
    }
    if (window.ActiveMenuItem) {
        hideMenu(false, false);
    }
    window.activeMenus.length = 0;
}






// FROM: js/menu.js
		<!--
		function newImage(arg) {
			if (document.images) {
				rslt = new Image();
				rslt.src = arg;
				return rslt;
			}
		}

		function changeImages() {
			if (document.images && (preloadFlag == true)) {
				for (var i=0; i<changeImages.arguments.length; i+=2) {
					document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
				}
			}
		}

		var preloadFlag = false;
		function preloadImages() {
			if (document.images) {
				nav_01_over = newImage("images/canada_02.gif");
				nav_02_over = newImage("images/canada_03.gif");
				nav_03_over = newImage("images/canada_04.gif");
				nav_04_over = newImage("images/canada_05.gif");
				nav_05_over = newImage("images/canada_06.gif");
				nav_06_over = newImage("images/canada_07.gif");
				preloadFlag = true;
			}
		}
		// -->
		<!--
		function MM_swapImage() { //v3.0
		var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
		}
		function MM_swapImgRestore() { //v3.0
		var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
		}

		function MM_preloadImages() { //v3.0
		var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
		}


		function MM_findObj(n, d) { //v4.01
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
			d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n); return x;
		}
		//-->
 function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }




