/* addLoadEvent for multiple onload functions */

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

/* col2: photo gallery */

function photoGallery(dir) {	 
if(photoGallery != 0) {

	//move left
	if(dir != 0) {
		if(photoGalleryCounter == 0) { $('ms-global-img-mover2').style.left = photoGalleryWidth }
		//reset the photo containers and the counter 
		if(photoGalleryCounter == (photoGalleryTotal-(photoGalleryTotal*2))) { 
			$('ms-global-img-mover1').style.left = '0px'; 
			$('ms-global-img-mover2').style.left = photoGalleryWidth;
			photoGalleryCounter = 0}	
				photoGalleryCounter = photoGalleryCounter -1;
				Effect.MoveBy( 'ms-global-img-mover1', 0, -82, { 
				beforeStart: function() { disablepGalleryBtns(0); }, afterFinish: function() { disablepGalleryBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'ms-global-img-mover2', 0, -82, {duration:1} );
							
		} else { 
		
		//move right
		if(photoGalleryCounter == 0) { $('ms-global-img-mover2').style.left = photoGalleryWidthRight; }
		//reset the photo containers and the counter 
		if(photoGalleryCounter == photoGalleryTotal) { 
			$('ms-global-img-mover1').style.left = '0px'; 
			$('ms-global-img-mover2').style.left = photoGalleryWidthRight;
			photoGalleryCounter = 0}
				photoGalleryCounter = photoGalleryCounter +1;
				Effect.MoveBy( 'ms-global-img-mover1', 0, 82, { 
				beforeStart: function() { disablepGalleryBtns(0); }, afterFinish: function() { disablepGalleryBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'ms-global-img-mover2', 0, 82, {duration:1} ); 
		}
	}
}	

//this function deactivates button while photo gallery is moving
function disablepGalleryBtns(active) {	
	if(active == 0) { 
		$('ms-col2-img-container').style.width = '320px';
		$('ms-col2-img-container').style.clip = 'rect(auto auto auto 5px)';
		$('ms-global-pGalleryBtn-right').onclick =  null;
		$('ms-global-pGalleryBtn-left').onclick =  null }
	if(active == 1) { 
		$('ms-col2-img-container').style.width = '320px';
		$('ms-col2-img-container').style.clip = 'rect(auto auto auto auto)';
		$('ms-global-pGalleryBtn-right').onclick =  photoGallery;
		$('ms-global-pGalleryBtn-left').onclick =  new Function("photoGallery("+0+")");
		}
}

//community module - column 2

var oldComm = 1;
function changeComm(comm) {
	previousComm = "community-boards-content"+oldComm
	selectedComm = "community-boards-content"+comm;	
	$(previousComm).style.display = 'none';
	$(selectedComm).style.display = 'block';
	$('community-board'+comm).className = "community-boards-numbers-on";
	$('community-board'+oldComm).className = "";
	//set new visible as current
	oldComm = comm;
}

//these functions handle rollover effect for community module
function ieRoll(selectedTR,selectedID) {
	if(selectedID != oldComm) {
	selectedTR.className = 'community-boards-numbers-hover'; }
}

function ieRollOut(selectedTR,selectedID) {
	if(selectedID != oldComm) {
	selectedTR.className = '';}
}

//food promo box - homepage

function nextRecipe(dir) {
	recipeCounter = recipeCounter + dir;
	
	if(recipeCounter == -1) { recipeCounter = recipeTxt.length-1; }
	if(recipeCounter == recipeTxt.length) {recipeCounter = 0; }
	if(recipeCounter > recipeTxt.length) {recipeCounter = 1; }
	
	recipeURL = recipeLink[recipeCounter];
	recipeNamePath = '<a href='+recipeURL+'>'+recipeTxt[recipeCounter]+'</a>';
	recipeImgPath = recipeImg[recipeCounter];
	if(recipeCounter >= 0) {
		Element.update('ms-home-howto-text',recipeNamePath);
		$('ms-home-howto-lnk').setAttribute('href', recipeURL);
			$('ms-home-recipe-featured').src = recipeImgPath;
	}
}

//more like this module - column 3

function moreThis(dir) {	 
if(moreThis != 0) {

	//move left
	if(dir != 0) { 
		if(moreThisCounter == 0) { $('ms-col3-morethis-mover2').style.left = moreThisWidth }
		//reset the photo containers and the counter 
		if(moreThisCounter == (moreThisTotal-(moreThisTotal*2))) { 
			$('ms-col3-morethis-mover1').style.left = '0px'; 
			$('ms-col3-morethis-mover2').style.left = moreThisWidth;
			moreThisCounter = 0}	
				moreThisCounter = moreThisCounter -1;
				Effect.MoveBy( 'ms-col3-morethis-mover1', 0, -80, { 
				beforeStart: function() { disablemoreThisBtns(0); }, afterFinish: function() { disablemoreThisBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'ms-col3-morethis-mover2', 0, -80, {duration:1} );
							
		} else { 
		
		//move right
		if(moreThisCounter == 0) { $('ms-col3-morethis-mover2').style.left = moreThisWidthRight; }
		//reset the photo containers and the counter 
		if(moreThisCounter == moreThisTotal) { 
			$('ms-col3-morethis-mover1').style.left = '0px'; 
			$('ms-col3-morethis-mover2').style.left = moreThisWidthRight;
			moreThisCounter = 0}
				moreThisCounter = moreThisCounter +1;
				Effect.MoveBy( 'ms-col3-morethis-mover1', 0, 80, { 
				beforeStart: function() { disablemoreThisBtns(0); }, afterFinish: function() { disablemoreThisBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'ms-col3-morethis-mover2', 0, 80, {duration:1} ); 
		}
	}
}	

//this function deactivates button while photo gallery is moving
function disablemoreThisBtns(active) {	
	if(active == 0) { 
		$('ms-col3-morethis-container').style.width = '250px';
		$('ms-col3-morethis-container').style.clip = 'rect(auto 245px auto 5px)';
		$('ms-global-morethisBtn-right').onclick = null;
		$('ms-global-morethisBtn-left').onclick = null; }
	if(active == 1) { 
		$('ms-col3-morethis-container').style.width = '250px';
		$('ms-col3-morethis-container').style.clip = 'rect(auto auto auto auto)';
		$('ms-global-morethisBtn-right').onclick =  moreThis;
		$('ms-global-morethisBtn-left').onclick =  new Function("moreThis("+0+")");
		}
}


//browse menu module - column 2

function menuBrowser(dir) {	 
if(menuBrowser != 0) {

	//move left
	if(dir == 0) { 
		if(menuBrowserCounter == 0) { $('ms-col2-menuBrowser-mover2').style.left = menuBrowserWidth }
		//reset the photo containers and the counter 
		if(menuBrowserCounter == (menuBrowserTotal-(menuBrowserTotal*2))) { 
			$('ms-col2-menuBrowser-mover1').style.left = '0px'; 
			$('ms-col2-menuBrowser-mover2').style.left = menuBrowserWidth;
			menuBrowserCounter = 0}	
				menuBrowserCounter = menuBrowserCounter -1;
				Effect.MoveBy( 'ms-col2-menuBrowser-mover1', 0, -100, { 
				beforeStart: function() { disablemenuBrowserBtns(0); }, afterFinish: function() { disablemenuBrowserBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'ms-col2-menuBrowser-mover2', 0, -100, {duration:1} );
							
		} else { 
		
		//move right
		if(menuBrowserCounter == 0) { $('ms-col2-menuBrowser-mover2').style.left = menuBrowserWidthRight; }
		//reset the photo containers and the counter 
		if(menuBrowserCounter == menuBrowserTotal) { 
			$('ms-col2-menuBrowser-mover1').style.left = '0px';
			$('ms-col2-menuBrowser-mover2').style.left = menuBrowserWidthRight;
			menuBrowserCounter = 0}
				menuBrowserCounter = menuBrowserCounter +1;
				Effect.MoveBy( 'ms-col2-menuBrowser-mover1', 0, 100, { 
				beforeStart: function() { disablemenuBrowserBtns(0); }, afterFinish: function() { disablemenuBrowserBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'ms-col2-menuBrowser-mover2', 0, 100, {duration:1} ); 
		}
	}
}	

//this function deactivates button while photo gallery is moving
function disablemenuBrowserBtns(active) {	
	if(active == 0) { 
		$('ms-col2-menu-module-items-container').style.width = '379px';
		$('ms-col2-menuBrowser-leftBtn').style.backgroundColor = '#D6F29F';
		$('ms-global-menuBrowseBtn-right').onclick =  null;
		$('ms-global-menuBrowseBtn-left').onclick =  null }
	if(active == 1) { 
		$('ms-col2-menu-module-items-container').style.width = '385px';
		$('ms-col2-menuBrowser-leftBtn').style.backgroundColor = ''
		$('ms-global-menuBrowseBtn-right').onclick =  menuBrowser;
		$('ms-global-menuBrowseBtn-left').onclick =  new Function("menuBrowser("+0+")");
		}
}

//collage appear/disappear
var killCollage;

function collageDetails(detail) {
	collageShow = 'collage'+detail;
	for(i=1;i<11;i++) {
		$('collage-thumb'+i).style.zIndex = 200;
		Element.hide('collage'+i);
	}
	$('collage-thumb'+detail).style.zIndex = 300;
	Element.show(collageShow);
}
function collageOff(detail) {
	collageHide = 'collage'+detail;
	Element.hide(collageHide);
}	

function safariOn(link) {
	$(link).style.textDecoration = 'underline';
}

function safariOff(link) {
	$(link).style.textDecoration = 'none';
}

//taxonomy list

var firstTax = ("0");

function showTaxDetails(taxNumber) {

if ( taxNumber != firstTax) {
	selectedTax = "tax"+taxNumber+"";
	oldTax = "tax"+firstTax+"";
	selectedTaxImg = "ms-col2-tax-arrow"+taxNumber+"";
	oldTaxImg = "ms-col2-tax-arrow"+firstTax+"";
	document.getElementById(selectedTax).style.display = "block";
	document.getElementById(oldTax).style.display = "none";
	document.getElementById(selectedTaxImg).src = 'images/assets/module/ms-col2-taxonomy-arrow-down.gif';
	document.getElementById(oldTaxImg).src = 'images/assets/module/ms-col2-taxonomy-arrow.gif';
	}
 firstTax = taxNumber;
 document.getElementById("tax0").style.display = "block";
}


//swaps text & video container on article pages

function videoSwap(tab) {
	if(tab == 1) {
		$('ms-col2-stepbystep-txt').style.display = 'block';
		$('ms-col2-stepbystep-video').style.display = 'none';
		$('recipe-tab').className = 'here';
		$('video-tab').className = '';
		} else {
		$('ms-col2-stepbystep-txt').style.display = 'none';
		$('ms-col2-stepbystep-video').style.display = 'block';
		$('recipe-tab').className = '';
		$('video-tab').className = 'here';					
		}
}

//swaps text & video container on article pages

function articleVideoSwap(tab) {
	if(tab == 1) {
		$('ms-col2-article-container').style.display = 'block';
		$('ms-col2-stepbystep-video').style.display = 'none';
		$('article-tab').className = 'here';
		$('video-tab').className = '';
		} else {
		$('ms-col2-article-container').style.display = 'none';
		$('ms-col2-stepbystep-video').style.display = 'block';
		$('article-tab').className = '';
		$('video-tab').className = 'here';					
		}
}


//search results left col

function searchCollapse() {

noBorder();

var itemsPerCat = 5;
searchCat = $("categories", "by-brands", "by-date", "by-editor");

for (i=0;i<searchCat.length;i++) {
	if(!$(searchCat[i])) return false;
	catId = searchCat[i].getAttribute("id");
	var listItems = searchCat[i].getElementsByTagName("li");
	for (j=0; j<listItems.length; j++) {
		if (j > itemsPerCat-1 && listItems.length > itemsPerCat + 2) {
			listItems[j].style.display = 'none';
			}
		}
		if (listItems.length > itemsPerCat && listItems.length > itemsPerCat + 2) {
		createLink();
		}
	}
}
	
function showLinks(whichLink) {
	var catId = whichLink.getAttribute("href").split("#")[1];
	var showCat = $(catId);
	var lastItem = whichLink.parentNode;
	var items = showCat.getElementsByTagName("li");
	for(i=0;i<items.length;i++) {
		items[i].style.display = 'block';	
	}
	lastItem.style.display = 'none';
}

function createLink() {
	li = document.createElement("li");
	moreLink = document.createElement("a");
  moreLink.setAttribute('href', '#' + catId);
  moreLink.onclick = function() { showLinks(this); return false; }
  lnkText = document.createTextNode("More...");
	li.appendChild(moreLink);
	moreLink.appendChild(lnkText);
	searchCat[i].appendChild(li);
}

function noBorder() {
	var searchContainers = $("refine-your-search", "most-popular");
	for (i=0; i < searchContainers.length; i++) {
	if(!$(searchContainers[i])) return false;
	var uls = searchContainers[i].getElementsByTagName("ul");
		for (j=0; j < uls.length; j++) {
			if(j == uls.length-1) {
				uls[j].className = "last";
			}
		}
	}
}

window.onload = searchCollapse;


// pop up

var newWin;
function openBrWindow(theURL,winName,features) { 
  newWin = window.open(theURL,winName,features);
  newWin.focus();
}


//poll text changes

function pollTxtChanges() {
	//hide question
	Element.hide('ms-col3-poll-question-container');
	
	//show resulting poll 
	Element.show('ms-col3-poll-results-container');
	
	//show "total votes" text at bottom
	Element.show('ms-col3-poll-bottom-container');
}

// new poll - used on microsites

function showPollResults() {
	$("col3-poll-options").style.display = "none";
	$("col3-poll-result-container").style.display = "block";
}

/* brand tray */

function brandTray(dir) {	 
if(brandTray != 0) {

	//move left
	if(dir != 0) {
		if(brandTrayCounter == 0) { $('brandLogosGroup2').style.left = brandTrayWidth }
		//reset the photo containers and the counter 
		if(brandTrayCounter == (brandTrayTotal-(brandTrayTotal*2))) { 
			$('brandLogosGroup1').style.left = '0px'; 
			$('brandLogosGroup2').style.left = brandTrayWidth;
			brandTrayCounter = 0}	
				brandTrayCounter = brandTrayCounter -1;
				Effect.MoveBy( 'brandLogosGroup1', 0, -115, { 
				beforeStart: function() { disableBrandTrayBtns(0); }, afterFinish: function() { disableBrandTrayBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'brandLogosGroup2', 0, -115, {duration:1} );
							
		} else { 
		
		//move right
		if(brandTrayCounter == 0) { $('brandLogosGroup2').style.left = brandTrayWidthRight; }
		//reset the photo containers and the counter 
		if(brandTrayCounter == brandTrayTotal) { 
			$('brandLogosGroup1').style.left = '0px'; 
			$('brandLogosGroup2').style.left = brandTrayWidthRight;
			brandTrayCounter = 0}
				brandTrayCounter = brandTrayCounter +1;
				Effect.MoveBy( 'brandLogosGroup1', 0, 115, { 
				beforeStart: function() { disableBrandTrayBtns(0); }, afterFinish: function() { disableBrandTrayBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'brandLogosGroup2', 0, 115, {duration:1} ); 
		}
	}
}	

//this function deactivates button while photo gallery is moving
function disableBrandTrayBtns(active) {	
	if(active == 0) { 
		$('next').onclick =  null;
		$('prev').onclick =  null;
	  }
	if(active == 1) { 
		$('next').onclick =  brandTray;
		$('prev').onclick =  new Function("brandTray("+0+")");
		}
}


/* make marthastewart.com your homepage */

function setMarthaAsHomePage(obj, url) {
	var browserName=navigator.appName; 

	// tracking
	var s=s_gi(s_account); 
	s.linkTrackVars='eVar1,prop8'; 
	s.linkTrackEvents='None'; 
	s.eVar1='homepage_bookmark'; 
	s.prop8='homepage_bookmark'; 
	s.tl(this,'o','Homepage Bookmark');

	// set home page, if possible
	if (browserName=="Microsoft Internet Explorer") {
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage('http://www.marthastewart.com');
	} else { 
		// can't set homepage with current browser - show instructions instead	
		openBrWindow(url,'setHomePageWindow','status=no,width=530,height=600');
	}
}

showCollageTitles = function() {

	if (!document.getElementById('collage')) return false;
		
	var collage = document.getElementById('collage');
	var collageImgs = collage.getElementsByTagName("img");
	
	for(i=0; i<collageImgs.length; i++) {
		var collageTitles = document.getElementById('collageTitle');
		collageImgs[i].onmouseover = function() {
			getCollageTitle = this.getAttribute("title");
			collageTitles.style.visibility = "visible";
			collageTitles.innerHTML = '<p>'+getCollageTitle+'</p>';
			this.className = "img_hover";
		}
			collageImgs[i].onmouseout = function() {
			collageTitles.innerHTML = '<p>&nbsp;</p>';
			this.className = "";
		}
	}
}

addLoadEvent(showCollageTitles);


showAlsoTryTitles = function() {

	if (!document.getElementById('also_try')) return false;
		
	var alsoTry = document.getElementById('also_try');
	var alsoTryImgs = alsoTry.getElementsByTagName("img");

	for(i=0; i<alsoTryImgs.length; i++) {
			var alsoTryTitles = document.getElementById('alsoTryTitleDiv');
			alsoTryImgs[i].onmouseover = function() {
			getAlsoTryTitle = this.getAttribute("title");
			alsoTryTitles.style.visibility = "visible";
			alsoTryTitles.innerHTML = '<p>'+getAlsoTryTitle+'</p>';
			this.className = "img_hover";
		}
			alsoTryImgs[i].onmouseout = function() {
			alsoTryTitles.innerHTML = '<p>&nbsp;</p>';
			this.className = "";
		}		
	}
}

addLoadEvent(showAlsoTryTitles);

/* col3: Also Try... */

function alsoTry(dir) {	 
if(alsoTry != 0) {

	//move left
	if(dir != 0) {
		if(alsoTryCounter == 0) { $('also_try_images_group2').style.left = alsoTryWidth }
		//reset the photo containers and the counter 
		if(alsoTryCounter == (alsoTryTotal-(alsoTryTotal*2))) { 
			$('also_try_images_group1').style.left = '0px'; 
			$('also_try_images_group2').style.left = alsoTryWidth;
			alsoTryCounter = 0}	
				alsoTryCounter = alsoTryCounter -1;
				Effect.MoveBy( 'also_try_images_group1', 0, -81, { 
				beforeStart: function() { disableAlsoTryBtns(0); }, afterFinish: function() { disableAlsoTryBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'also_try_images_group2', 0, -81, {duration:1} );
							
		} else { 
		
		//move right
		if(alsoTryCounter == 0) { $('also_try_images_group2').style.left = alsoTryWidthRight; }
		//reset the photo containers and the counter 
		if(alsoTryCounter == alsoTryTotal) { 
			$('also_try_images_group1').style.left = '0px'; 
			$('also_try_images_group2').style.left = alsoTryWidthRight;
			alsoTryCounter = 0}
				alsoTryCounter = alsoTryCounter +1;
				Effect.MoveBy( 'also_try_images_group1', 0, 81, { 
				beforeStart: function() { disableAlsoTryBtns(0); }, afterFinish: function() { disableAlsoTryBtns(1); }, duration:1} ); 
				Effect.MoveBy( 'also_try_images_group2', 0, 81, {duration:1} ); 
		}
	}
}

//this function deactivates button while photo gallery is moving
function disableAlsoTryBtns(active) {	
	if(active == 0) { 
		$('also_try_images').style.width = '239px';
		$('also_try_images').style.clip = 'rect(auto, auto, auto, 3px)';
		$('also_try_prev').onclick =  null;
		$('also_try_next').onclick =  null }
	if(active == 1) { 
		$('also_try_images').style.width = '243px';
		$('also_try_images').style.clip = 'rect(auto auto auto auto)';
		$('also_try_prev').onclick =  alsoTry;
		$('also_try_next').onclick =  new Function("alsoTry("+0+")");
		}
}


/* show archive functions */

showArchiveFunctions = function() {
	if (!document.getElementById('show-archive')) return false;
	var showArchiveTrs = $('show-archive').getElementsByTagName("tr");
	if (!window.XMLHttpRequest) {
		$('show-archive-dropdown').onmouseover = function() {
			$('show-archive-select').style.backgroundPosition = '0px -29px';
			$('show-archive-dates').style.display='block';
		}
		$('show-archive-dropdown').onmouseout = function() {
			$('show-archive-select').style.backgroundPosition = 'top left';
			$('show-archive-dates').style.display='none';
		}		
		for (i=0; i<showArchiveTrs.length; i++) {
			showArchiveTrs[i].onmouseover = function() {
				if (this.className != 'table-headers') {
					if(this.className == 'shaded') {
						this.className = "ieHover";
						this.onmouseout = function() { this.className = 'shaded'; }
					} else {
						this.className = "ieHover";
						this.onmouseout = function() { this.className = ''; }		
					}
				}
			}
		}
	}
}

addLoadEvent(showArchiveFunctions);

top7Sort = function() {

			if (!document.getElementById('top7')) return false;
		
			var top7List = document.getElementById("top7_dropdown").getElementsByTagName("li");

			// show dropdown
			$('top7_select').onmouseover = function() {
				$('top7_nest').style.height = "auto";
				$('top7_nest').style.visibility = "visible";
			}
			// hide dropdown (onmouseout)
			$('top7_select').onmouseout = function() {
				$('top7_nest').style.height = "0";
				$('top7_nest').style.visibility = "hidden";
			}
			// hide dropdown (onclick)
			for (var i=0; i<top7List.length; i++) {
				top7List[i].onclick=function() {
					$('top7_nest').style.height = "0px";
					$('top7_nest').style.visibility = "hidden";
				}
			}
				
			var getTop7Lnks = $('top7_dropdown').getElementsByTagName("a");
			
			for(i=0; i<getTop7Lnks.length; i++) {
		
			// hide all lists
			getTop7Lnks[i].onclick = function() {
			var allTop7 = $('top7_sort1','top7_sort2','top7_sort3');
			for(j=0; j<allTop7.length; j++) {
				if($(allTop7[j])) {
				allTop7[j].style.display = "none";
				}
			}

			// hid all hdrs
			var allTop7Hdrs = $('top7_hdr1', 'top7_hdr2', 'top7_hdr3');
			for(k=0; k<allTop7Hdrs.length; k++) {
				if($(allTop7Hdrs[k])) {
				allTop7Hdrs[k].className = "invisibleHdr";
				}
			}

			var top7Lnks = this.getAttribute("href").split("#")[1];
			
			// show appropriate list
			$(top7Lnks).style.display = "block";

			// show appropriate hdr
			if (top7Lnks == "top7_sort1") {
				$('top7_hdr1').className = "visibleHdr";
			}
			if (top7Lnks == "top7_sort2") {
				$('top7_hdr2').className = "visibleHdr";
			}
			if (top7Lnks == "top7_sort3") {
				$('top7_hdr3').className = "visibleHdr";
			}
			return false;	
		}
	}
}

addLoadEvent(top7Sort);

homeTop7Sort = function() {

			if (!document.getElementById('top7_home')) return false;
		
			var top7HomeList = document.getElementById("top7_home_dropdown").getElementsByTagName("li");

			// show dropdown
			$('top7_home_select').onmouseover = function() {
				$('top7_home_nest').style.height = "auto";
				$('top7_home_nest').style.visibility = "visible";
			}
			// hide dropdown (onmouseout)
			$('top7_home_select').onmouseout = function() {
				$('top7_home_nest').style.height = "0px";
				$('top7_home_nest').style.visibility = "hidden";
			}
			// hide dropdown (onclick)
			for (var i=0; i<top7HomeList.length; i++) {
				top7HomeList[i].onclick=function() {
					$('top7_home_nest').style.height = "0px";
					$('top7_home_nest').style.visibility = "hidden";
				}
			}
				
			var getTop7HomeLnks = $('top7_home_dropdown').getElementsByTagName("a");
			
			for(i=0; i<getTop7HomeLnks.length; i++) {
		
			// hide all lists
			getTop7HomeLnks[i].onclick = function() {
			var allHomeTop7 = $('top7_home_sort1','top7_home_sort2','top7_home_sort3');
			for(j=0; j<allHomeTop7.length; j++) {
				if($(allHomeTop7[j])) {
					allHomeTop7[j].style.display = "none";
				}
			}

			// hid all hdrs
			var allTop7Hdrs = $('top7_home_hdr1', 'top7_home_hdr2', 'top7_home_hdr3');
			for(k=0; k<allTop7Hdrs.length; k++) {
				if($(allTop7Hdrs[k])) {
				allTop7Hdrs[k].className = "invisibleHdr";
				}
			}

			var top7HomeLnks = this.getAttribute("href").split("#")[1];
			
			// show appropriate list
			$(top7HomeLnks).style.display = "block";

			// show appropriate hdr
			if (top7HomeLnks == "top7_home_sort1") {
				$('top7_home_hdr1').className = "visibleHdr";
			}
			if (top7HomeLnks == "top7_home_sort2") {
				$('top7_home_hdr2').className = "visibleHdr";
			}
			if (top7HomeLnks == "top7_home_sort3") {
				$('top7_home_hdr3').className = "visibleHdr";
			}
			return false;
		}
	}
}

addLoadEvent(homeTop7Sort);