(function(){
	var protocol = location.protocol;

	var BooksAuthors = {
		'titleSec1' : 'Most Popular Series',
		'linksSec1' : [
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_39-clues.jpg',
				linktext : 'The 39 Clues',
				linkurl : 'http://www.scholastic.com/kids/39clues/?lnkid=stacks/nav/b_and_a/titles/39clues',
				linkalt : 'The 39 Clues book site',
				linktitle : 'Go to The 39 Clues book site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_allie-finkle.jpg',
				linktext : 'Allie Finkle\'s Rules for Girls',
				linkurl : 'http://alliefinkle.scholastic.com/?lnkid=stacks/nav/b_and_a/titles/alliefinkle',
				linkalt : 'Allie Finkle\'s Rules for Girls',
				linktitle : 'Go to the Allie Finkle\'s Rules for Girls site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_animorphs.jpg',
				linktext : 'Animorphs',
				linkurl : 'http://www.scholastic.com/animorphs/index.htm?lnkid=stacks/nav/b_and_a/titles/animorphs',
				linkalt : 'Animorphs',
				linktitle : 'Go to the Animorphs site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_baby-sitters-club.jpg',
				linktext : 'The Baby Sitters Club',
				linkurl : 'http://www.scholastic.com/thebabysittersclub/?lnkid=stacks/nav/b_and_a/titles/babysittersclub',
				linkalt : 'The Baby Sitters Club',
				linktitle : 'Go to The Baby-Sitters Club site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_bone.jpg',
				linktext : 'Bone',
				linkurl : 'http://www.scholastic.com/bone/?lnkid=stacks/nav/b_and_a/titles/bone',
				linkalt : 'Bone',
				linktitle : 'Go to the Bone site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_captain-underpants.jpg',
				linktext : 'Captain Underpants',
				linkurl : 'http://www.scholastic.com/captainunderpants/?lnkid=stacks/nav/b_and_a/titles/captunderpants',
				linkalt : 'Captain Underpants',
				linktitle : 'Go to the Captain Underpants site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_dear-america.jpg',
				linktext : 'Dear America',
				linkurl : 'http://www.scholastic.com/dearamerica/?lnkid=stacks/nav/b_and_a/titles/dearamerica',
				linkalt : 'Dear America',
				linktitle : 'Go to the Dear America site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_deltora.jpg',
				linktext : 'Deltora',
				linkurl : 'http://www.scholastic.com/deltora/?lnkid=stacks/nav/b_and_a/titles/deltora',
				linkalt : 'Deltora',
				linktitle : 'Go to the Deltora site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_goosebumps.jpg',
				linktext : 'Goosebumps',
				linkurl : 'http://www.scholastic.com/goosebumps/?lnkid=stacks/nav/b_and_a/titles/goosebumps',
				linkalt : 'Goosebumps',
				linktitle : 'Go to the Goosebumps site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_harry-potter.jpg',
				linktext : 'Harry Potter',
				linkurl : 'http://harrypotter.scholastic.com/?lnkid=stacks/nav/b_and_a/titles/harrypotter',
				linkalt : 'Harry Potter',
				linktitle : 'Go to the Harry Potter site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_how-i-survived-middle-school.jpg',
				linktext : 'How I Survived Middle School',
				linkurl : 'http://www.scholastic.com/kids/middleschoolsurvival/?lnkid=stacks/nav/b_and_a/titles/middleschool',
				linkalt : 'How I Survived Middle School',
				linktitle : 'Go to the How I Survived Middle School site'
			},
			{
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/ba_ispy.jpg',
				linktext : 'I SPY',
				linkurl : 'http://www.scholastic.com/kids/ispy/?lnkid=stacks/nav/b_and_a/titles/ispy',
				linkalt : 'I SPY',
				linktitle : 'Go to the I SPY site'
			}
		],
		'btn' : {
			btntext : 'All Book Sites',
			btnurl : 'http://www.scholastic.com/kids/favorites.htm?lnkid=stacks/nav/b_and_a/all/',
			btnalt : 'All Book sites for Kids',
			btntitle : 'See a list of all book sites'
		},
		'btnAlt' : {
			btntext : 'Featured Books &amp; Authors',
			btnurl : 'http://www.scholastic.com/kids/stacks/books/?lnkid=stacks/nav/b_and_a/featured/',
			btnalt : 'Books &amp; Authors for Kids',
			btntitle : 'Go to the Books &amp; Authors page'
		}
	};

	var Games = {
		'titleSec1' : 'Most Popular Games',
		'linksSec1' : [
			{
				linksite : 'Goosebumps',
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/games_flee-camp-jellyjam.jpg',
				linktext : 'Flee Camp Jellyjam',
				linkurl : 'http://www.scholastic.com/goosebumps/games_activities/jellyjam.htm?lnkid=stacks/nav/games/fg/1/goosebumps_campjellyjam',
				linkalt : 'Goosebumps: Flee Camp Jellyjam',
				linktitle : 'Play the Flee Camp Jellyjam game'
			},
			{
				linksite : 'Allie Finkle',
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/games_dress-allie.jpg',
				linktext : 'Dress Allie',
				linkurl : 'http://alliefinkle.scholastic.com/games/game_dressallie.html?lnkid=stacks/nav/games/fg/2/dressallie',
				linkalt : 'Allie Finkle: Dress Allie',
				linktitle : 'Play the Dress Allie game'
			},
			{
				linksite : 'Deltora',
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/games_dragons-of-deltora.jpg',
				linktext : 'Dragons of Deltora Adventure',
				linkurl : 'http://www.scholastic.com/deltora/games/dragonsgame.htm?lnkid=stacks/nav/games/fg/3/deltora_adventure',
				linkalt : 'Deltora: Dragons of Deltora Adventure',
				linktitle : 'Play the Deltora: Dragons of Deltora Adventure game'
			},
			{
				linksite : 'Bone',
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/games_whack-a-rat.jpg',
				linktext : 'Whack-a-Rat',
				linkurl : 'http://www.scholastic.com/bone/whac.htm?lnkid=stacks/nav/games/fg/4/bone_whackarat',
				linkalt : 'Bone: Whack-a-Rat',
				linktitle : 'Play the Bone: Whack-a-Rat game'
			},
			{
				linksite : 'Captain Underpants',
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/games_robo-bugger-round-up.jpg',
				linktext : 'Robo-Bugger Round Up',
				linkurl : 'http://www.scholastic.com/captainunderpants/boogerboy/game.htm?lnkid=stacks/nav/games/fg/5/captunderpants_robobugger',
				linkalt : 'Captain Underpants and the Robo-Bugger Round Up',
				linktitle : 'Play the Captain Underpants and the Robo-Bugger Round Up game'
			},
			{
				linksite : 'Middle School Survival',
				linkimg : protocol + '//www.scholastic.com/kids/stacks/common/images/nav/games_create-a-crush.jpg',
				linktext : 'Create a Crush',
				linkurl : 'http://www.scholastic.com/kids/middleschoolsurvival/create-a-crush/?lnkid=stacks/nav/games/fg/6/middleschoolsurvival_createacrush',
				linkalt : 'Middle School Survival: Create a Crush',
				linktitle : 'Play the Middle School Survival: Create a Crush game'
			}
		],
		'titleSec2' : 'More Fun',
		'linksSec2' : [
			{
				linktext : 'Poll Mania',
				linkurl : 'http://blog.scholastic.com/poll_mania/?lnkid=stacks/nav/games/pollmania',
				linktitle : 'Go to Poll Mania'
			},
			{
				linktext : 'Contests &amp; Sweepstakes',
				linkurl : 'http://blog.scholastic.com/kids_contests_sweepstakes/?lnkid=stacks/nav/games/contests',
				linktitle : 'Go to the Contests &amp; Sweepstakes page'
			}
		],
		'btn' : {
			btntext : 'All Games',
			btnurl : 'http://www.scholastic.com/kids/stacks/games/?lnkid=stacks/nav/games/all',
			btnalt : 'All Games',
			btntitle : 'Go to the Games homepage'
		}
	};

	var Blog = {
		'titleSec1' : 'Ink Splot 26',
		'mainTout' : protocol + '//www.scholastic.com/kids/stacks/common/images/logo_ink_splot.jpg',
		'mainToutLink' : 'http://blog.scholastic.com/ink_splot_26/?lnkid=stacks/nav/blog/logo',
		'mainToutAlt' : 'Ink Splot 26 Blog',
		'mainToutTitle' : 'Go to Ink Splot 26 Blog',
		'mainToutTxt' : 'Daily book news, celeb interviews, trivia, and more!',
		'titleSec2' : 'Top Categories',
		'linksSec2' : [
			{
				linktext : 'Celebrities',
				linkurl : 'http://blog.scholastic.com/ink_splot_26/celebrities/?lnkid=stacks/nav/blog/category/celeb',
				linktitle : 'Celebrity Interviews and News'
			},
			{
				linktext : 'Reads',
				linkurl : 'http://blog.scholastic.com/ink_splot_26/reads-1/?lnkid=stacks/nav/blog/category/reads',
				linktitle : 'Book Reviews, Recommendations, and News'
			},
			{
				linktext : 'Trivia',
				linkurl : 'http://blog.scholastic.com/ink_splot_26/trivia-1/?lnkid=stacks/nav/blog/category/trivia',
				linktitle : 'Trivia'
			},
			{
				linktext : 'Writing Prompts',
				linkurl : 'http://blog.scholastic.com/ink_splot_26/writing-prompt/?lnkid=stacks/nav/blog/category/writing_prompts',
				linktitle : 'Writing Prompts and Create-a-Caption'
			}
		],
		'btn' : {
			btntext : 'All Posts',
			btnurl : 'http://blog.scholastic.com/ink_splot_26/?lnkid=stacks/nav/blog/all',
			btnalt : 'Ink Splot 26 Blog',
			btntitle : 'Go to the Ink Splot 26 Blog'
		}
	};			
	
	var Videos = {
		'titleSec1' : 'Categories',
		'linksSec1' : [
			{
				linktext : 'Inside the Book',
				linkurl : 'http://www.scholastic.com/kids/stacks/videos/index.htm?pid=1847329164&lnkid=stacks/nav/videos/insidebook',
				linktitle : 'Watch book-related videos'
			},
			{
				linktext : 'Your Favorite Series',
				linkurl : 'http://www.scholastic.com/kids/stacks/videos/index.htm?pid=1847329166&lnkid=stacks/nav/videos/yourfavseries',
				linktitle : 'Watch videos about your favorite series'
			},
			{
				linktext : 'Celebrities &amp; Entertainment',
				linkurl : 'http://www.scholastic.com/kids/stacks/videos/index.htm?pid=1847329168&lnkid=stacks/nav/videos/celebs_ent',
				linktitle : 'Watch Celebrity and Entertainment videos'
			},
			{
				linktext : 'Meet the Authors',
				linkurl : 'http://www.scholastic.com/kids/stacks/videos/index.htm?pid=1847329167&lnkid=stacks/nav/videos/authors',
				linktitle : 'Watch author videos'
			},
			{
				linktext : 'Special Events',
				linkurl : 'http://www.scholastic.com/kids/stacks/videos/index.htm?pid=1847353729&lnkid=stacks/nav/videos/events',
				linktitle : 'Watch special events videos'
			},
			{
				linktext : 'Grab Bag &amp; Funny Stuff',
				linkurl : 'http://www.scholastic.com/kids/stacks/videos/index.htm?pid=1847353728&lnkid=stacks/nav/videos/grab_funny',
				linktitle : 'Watch funny videos'
			}
		],
		'btn' : {
			btntext : 'All Videos',
			btnurl : 'http://www.scholastic.com/kids/stacks/videos/?lnkid=stacks/nav/videos/all',
			btnalt : 'All Videos',
			btntitle : 'Go to the Videos page'
		}
	};

	var MB = {
		'titleSec1' : 'Most Popular Boards',
		'linksSec1' : [
			{ 
				linktext : 'Buzz Board',
				linkurl : 'http://community.scholastic.com/scholastic/board?board.id=summerreadingbuzz',
				linktitle : 'Go to the Buzz Message Board'
			},
			{
				linktext : 'Save the Planet Board',
				linkurl : 'http://community.scholastic.com/scholastic/board?board.id=DTE',
				linktitle : 'Go to the Save the Planet Message Board'
			},
			{
				linktext : 'The 39 Clues Board',
				linkurl : 'http://community.scholastic.com/scholastic?category.id=The_39_Clues',
				linktitle : 'Go to The 39 Clues Message Board'
			},
			{
				linktext : 'Allie Finkle\'s Rules for Girls Board',
				linkurl : 'http://community.scholastic.com/scholastic?category.id=alliefinkle',
				linktitle : 'Go to the Allie Finkle’s Rules for Girls Message Board'
			},
			{
				linktext : 'Goosebumps Board',
				linkurl : 'http://community.scholastic.com/scholastic/board?board.id=Goosebumps',
				linktitle : 'Go to the Goosebumps Message Board'
			},
			{
				linktext : 'Harry Potter Board',
				linkurl : 'http://community.scholastic.com/scholastic?category.id=Harry_Potter',
				linktitle : 'Go to the Harry Potter message Board'
			}			
		],
		'titleSec2' : 'Community Features',
		'linksSec2' : [
			{ 
				linktext : 'STACKS Signatures',
				linkurl : 'http://www.scholastic.com/kids/stacks/scene/signatures/index.htm?lnkid=stacks/nav/boards/signatures',
				linktitle : 'Get a STACKS Signature for the Message Boards'
			},
			{ 
				linktext : 'Live Chats',
				linkurl : 'http://blog.scholastic.com/ink_splot_26/live-chats/?lnkid=stacks/nav/boards/chats',
				linktitle : 'Go to the Live Chats page'
			}
		],
		'btn' : {
			btntext : 'Join the Conversation',
			btnurl : 'http://community.scholastic.com/scholastic?category.id=kidBoards&lnkid=stacks/nav/boards/all',
			btnalt : 'Message Boards',
			btntitle : 'Join the conversation of the Message Boards'
		}
	};
	
	var Profile = {
		'links' : [
			{
				linktext : 'Update My Avatar',
				linkurl : 'http://kids.scholastic.com/community/avatar_maker.htm?lnkid=stacks/nav/profile/updateavatar',
				linktitle : 'Update My Avatar'
			},
			{
				linktext : 'View My Friends',
				linkurl : 'http://kids.scholastic.com/community/view_all_friends.htm?lnkid=stacks/nav/profile/viewfriends',
				linktitle : 'View My Friends'
			},
			{
				linktext : 'Add Widgets',
				linkurl : 'http://kids.scholastic.com/community/myStacks.htm?lnkid=stacks/nav/profile/addwidgets',
				linktitle : 'Add Widgets to My Profile'
			}
		],
		'btnProfile' : {
			btntext : 'My Profile',
			btnurl : 'http://kids.scholastic.com/community/my_profile.htm?lnkid=stacks/nav/profile/myprofile',
			btnalt : 'My Profile',
			btntitle : 'Go to my profile'
		},
		'btnSignIn' : {
			btntext : 'Sign In',
			btnurl : 'https://my.scholastic.com/sps_my_account/accmgmt/FlashLogin.jsp?finalSuccessURL=' + getCleanURL(),
			btnalt : 'Sign In',
			btntitle : 'Sign-In'
		}
	};

 /* ============================================================================================ */

	var $stacksDD, firstRun = true, stacksTimer, stacksDelayHide, stacksDisappearDelay = 1, stacksVisible;
	var  s_nVideos = '', s_nMB = '', s_nProfile = '', s_nGames = '', s_nBlog = '', s_nBA = '';

	jQuery('#schlStacksNav a').click(function(){ saveCookie('header','bigKids'); });
	
	jQuery('#schlStacksNav a:gt(0)').hover(
		function(){	
			if ( firstRun ) { 
				jQuery('#schlStacksNav').after('<div id="stacksDD"><div class="content"></div><div class="btm"></div></div>');
				setupStacksDD();
				firstRun = false;
			}
			$this = jQuery(this);
			$stacksDD = jQuery(this);
			jQuery('#schlStacksNav ul').css('z-index', '10003'); //for peel ad
			jQuery('#schlStacksNav ul a').removeClass('active');			
			$this.addClass('active');	
			
			clearTimeout(stacksTimer);
			stacksTimer = setTimeout( function() {
				jQuery('#schlStacksNav ul').css('z-index', '10003'); //for peel ad
				$this.addClass('active');
				showSTACKSMenu($this);		
				stacksVisible = true;					
			}, 10);     
		},
		function(){
			jQuery('#schlStacksNav ul').css('z-index', ''); //for peel ad
		
			$this = jQuery(this);
			$this.removeClass('active'); 
			
			if (stacksVisible) {
				stacksDelayHide=setTimeout(function() {
					hideSTACKSMenu();						
					stacksVisible = false;
				}, stacksDisappearDelay);
			}
			else { clearTimeout(stacksTimer); }
			
			
		}
	);

	function showSTACKSMenu(which) {	
		jQuery('#stacksDD').removeClass().addClass(which.attr('rel'));
		setPosition(which);	
		jQuery('#stacksDD .content').html(populateDD(which));
		jQuery('#stacksDD .content td').hover(function(){jQuery(this).addClass('hov');}, function(){jQuery(this).removeClass();});
		jQuery('#stacksDD').show();
	}

	function hideSTACKSMenu() { jQuery('#stacksDD').hide(); }

	function setPosition(which) {
		var btn = which.attr('rel');
		var offset = which.offset();
		var btn_width = which.width();
		var box_width = jQuery('#stacksDD').width();
		var left, top;
		if ( btn != 'nProfile' ) {
			left = parseInt(offset.left - ( box_width - btn_width ) / 2, 10);		
		}
		else {
			left = parseInt((offset.left + btn_width + 10) - box_width, 10);
		}
		top = parseInt(offset.top + 27, 10);
		jQuery('#stacksDD').css({left : left, top: top});
	}

	function setupStacksDD() {				
		jQuery('#stacksDD').bind('mouseover', function(){
			$stacksDD.addClass('active');
			jQuery('#schlStacksNav ul').css('z-index', '10003'); //for peel ad
			if ( typeof stacksDelayHide != "undefined" ) clearTimeout(stacksDelayHide);
		});
		jQuery('#stacksDD').bind('mouseout', function(){
			if (stacksVisible) {
				stacksDelayHide=setTimeout(function() {
					$stacksDD.removeClass('active');
					hideSTACKSMenu();	
					stacksVisible = false;				
					jQuery('#schlStacksNav ul').css('z-index', ''); //for peel ad
				}, stacksDisappearDelay);
			}
			else {			
				clearTimeout(stacksTimer);
			}
		});
	}

	function populateDD(which) { return DD[which.attr('rel')](); }
	
	var DD = {
		nBA : function() {
			if ( s_nBA == '' ) {
				s_nBA = '<h3 class="main">' + BooksAuthors['titleSec1' ] + '</h3>';
				s_nBA += getMostPopular({ 'arr': BooksAuthors.linksSec1, 'cols' : 4});
				s_nBA += getButton([BooksAuthors.btn, BooksAuthors.btnAlt], 'alt');
			}				
			return s_nBA;
		},
		
		nGames : function() {
			if ( s_nGames == '' ) {
				s_nGames = '<h3 class="main">' + Games['titleSec1' ] + '</h3>';
				s_nGames += getMostPopular({ 'arr': Games.linksSec1, 'cols' : 3});
				s_nGames += '<h3>' + Games['titleSec2' ] + '</h3>';
				s_nGames += getLinks(Games.linksSec2);
				s_nGames += getButton(Games.btn);
			}				
			return s_nGames;
		},
		
		nBlog : function() {
			if ( s_nBlog == '' ) {
				s_nBlog = '<h3 class="main">' + Blog['titleSec1' ] + '</h3>';
				s_nBlog += '<p class="logo"><a href="' + Blog.mainToutLink + '" title="' + Blog.mainToutTitle + '"><img src="' + Blog.mainTout + '" alt="' + Blog.mainToutAlt + '" border="0" /></a></p>';
				s_nBlog += '<p class="txt">' + Blog.mainToutTxt + '</p>';
				s_nBlog += '<h3>' + Blog['titleSec2' ] + '</h3>';
				s_nBlog += getLinks(Blog.linksSec2);
				s_nBlog += getButton(Blog.btn);
			}		
			return s_nBlog;
		},
		
		nVideos : function() {
			if ( s_nVideos == '' ) {
				s_nVideos = '<h3>' + Videos['titleSec1' ] + '</h3>';
				s_nVideos += getLinks(Videos.linksSec1);
				s_nVideos += getButton(Videos.btn);
			}		
			return s_nVideos;
		},
	
		nMB : function() {
			if ( s_nMB == '' ) {
				s_nMB = '<h3>' + MB['titleSec1' ] + '</h3>';
				s_nMB += getLinks(MB.linksSec1);			
				s_nMB += '<h3>' + MB['titleSec2' ] + '</h3>';
				s_nMB += getLinks(MB.linksSec2);		
				s_nMB += getButton(MB.btn); 
			}		
			return s_nMB;
		},
	
		nProfile : function() {
			if ( s_nProfile == '' ) {
				var ud = readCookie('SPS_UD');
				if ( ud ) {
					ud = ud.split('|');
					var randomInteger=Math.floor(Math.random()*11);
					s_nProfile = '<iframe width="154" height="85" frameborder="0" scrolling="no" marginwidth="0" marginheight="0" src="' + protocol + '//kids.scholastic.com/community/getavatar.htm?lnkid=stacks/nav/profile/avatarimage&ieQuery=' + randomInteger +'"></iframe>';				
					s_nProfile += '<h5><a href="http://kids.scholastic.com/community/my_profile.htm?lnkid=stacks/nav/profile/username" title="My Profile">Hi ' + ud[1] + '!</a></h5>'
					s_nProfile += '<p class="signout"><a href="#" onclick="maLogOut(); return false;">Sign Out</a></p>';
				}
				else {
					s_nProfile = '<a href="https://my.scholastic.com/sps_my_account/accmgmt/FlashLogin.jsp?finalSuccessURL=' + getCleanURL() + '" title="Sign In"><img src="' + protocol + '//www.scholastic.com/kids/stacks/common/images/nav/get_started.jpg" border="0" width="154" height="85" class="getStarted" /></a>';
				}
			
				s_nProfile += getLinks(Profile.links);
			
				if ( ud ) {
					s_nProfile += getButton(Profile.btnProfile, 'profile');
				}
				else {
					s_nProfile += getButton(Profile.btnSignIn, 'signin');
				}			
			}		
			return s_nProfile;
		}
	};	

	function getButton(obj, c) {
		var klass = '', btn = '';
		if ( c ) {	klass = ' ' + c; }
		if ( obj instanceof Array ) {
			btn = '<div class="btnWrap"><a class="btn" href="' + obj[0].btnurl + '" title="' + obj[0].btntitle + '">' + obj[0].btntext + '</a><a class="btn' + klass + '" href="' + obj[1].btnurl + '" title="' + obj[1].btntitle + '">' + obj[1].btntext + '</a></div>';
		}
		else {
			btn = '<div class="btnWrap"><a class="btn' + klass + '" href="' + obj.btnurl + '" title="' + obj.btntitle + '">' + obj.btntext + '</a></div>';
		}
		return btn;
	}
	
	function getMostPopular(obj) {
		var arrSize, site = obj.arr[0].linksite ? true : false;
		var tmp = '<table border="0" cellpadding="0" cellspacing="0">', hdr = '', content = '';
		if ( obj.arr.length % obj.cols != 0 ) arrSize = obj.arr.length + ( obj.cols - (obj.arr.length % obj.cols) );
		else arrSize = obj.arr.length;
		for ( var i = 0; i < arrSize; i++ ) {
			if ( i != 0 && i % obj.cols == 0 ) {
				if ( site ) { tmp += '<tr>' + hdr + '</tr><tr>' + content + '</tr>'; }
				else { tmp += '<tr>' + content + '</tr>'; }
				hdr = '';
				content = '';
			}
			if ( obj.arr[i] ) {
				if ( site ) { hdr += '<th>' + obj.arr[i].linksite + '</th>'; }
				content += '<td width="' + parseInt(100 / obj.cols, 10) + '%"><a href="' + obj.arr[i].linkurl + '" title="' + obj.arr[i].linktitle + '"><img src="' + obj.arr[i].linkimg + '" width="59" height="49" alt="' + obj.arr[i].linkalt + '" /></a><br /><a href="' + obj.arr[i].linkurl + '" title="' + obj.arr[i].linktitle + '">' + obj.arr[i].linktext + '</a></td>';					
			}
			else {
				if ( site ) { hdr += '<th>&nbsp;</th>'; }
				content += '<td width="' + parseInt(100 / obj.cols, 10) + '%">&nbsp;</td>';
			}
		}		
		if ( site )
			tmp += '<tr>' + hdr + '</tr><tr>' + content + '</tr></table>';
		else
			tmp += '<tr>' + content + '</tr></table>';
		return tmp;
	}	
	
	function getLinks(arr) {
		var tmp = '<ul>';
		for ( var i = 0; i < arr.length; i++ ) {
			tmp += '<li><a href="' + arr[i].linkurl + '" title="' + arr[i].linktitle + '">' + arr[i].linktext + '</a></li>';
		}
		tmp += '</ul>';		
		return tmp;
	}
	
	function getCleanURL() {
		var url = location.href;
		if ( location.search ) {
			var tracking = 'lnkid=stacks/nav/profile/signout';
			if ( location.search.length > tracking.length + 1 ) {
				if ( location.search.indexOf(tracking) > -1 )
					url = location.href.substring(0, location.href.indexOf(location.search)) + '?' + location.search.substring(tracking.length+ 2);
			}
			else {
				if ( location.search.indexOf(tracking) > -1 )
					url = location.href.substring(0, location.href.indexOf(location.search));
			}
		}
		return url;
	}
	
	setOnSignOutHook(function(){		
		var t_url = (location.search) ? '&' : '?';
		t_url += 'lnkid=stacks/nav/profile/signout';
		window.location = location.href + t_url;		
	});
})();