// JavaScript Document
//for use with jQuery
/*This script loads the header and footer into every page.  Pages that don't use this are: "home", "working", and "template" */

(function($) {
   
	$.fn.rwutemplate = function() {
		
		//setup headerMural img list
		function makeMural(){
			var headerMuralImgs = ['a','b','c','d','e','f'];
			var LI = [];
			$.each(headerMuralImgs, function() {
				var url = 'images/header/mural-' + this + '.jpg';
				var childClass = '';
				var switchVar = this + "";
				switch (switchVar)
				{
				case 'a':
					childClass=' class="firstChild"';
				  break;
				case 'f':
					childClass=' class="lastChild"';
				  break;
				default:
					childClass='';
				}
				LI.push('<li' + childClass + '><img src="' + url + '" /></li>');
			});
			var headerMural = LI.join(''); 
			return headerMural;
		}
		
		//setup menu List
		function makeMenu(){
			var menuItems = ['Home','Footwear','Elite Team','Club Team','Partners','Recycle Shoes','About Us','Contact Us'];
			var LI = [];
			$.each(menuItems, function() {
				var url = this.toLowerCase().split(' ').join('-') + '.html';
			   	LI.push('<li><div><a href="' + url + '"><span>' + this + '</span></a></div></li>');
			});
			var menuHTML = LI.join('');
			return menuHTML;
		}
		
		var theMenu = '';
		theMenu += '<ul>';	
		theMenu += makeMenu();
		theMenu += '</ul>';
			
		
		var header = '';
		header += '<div id="headerBox">';
		header += '<div class="headerBoxLeft">';
		header += '<div id="headerLogo"><a href="home.html">';
		header += '<img id="rwuLogo" src="images/rwu-logo.jpg" alt="run with us store logo" /></a></div>';
		header += '<div id="logoDesc"><span>Footwear and Apparel Store</span></div></div>';
		/*<!--end headerBoxLeft -->*/
		header += '<div class="headerBoxRight">';
		header += '<div><a target="_blank" href="images/full-mural-final.jpg">';
		header += '<ul id="headerMural">';
		header += makeMural();
		header += '</ul></a></div>';
		header += '<div id="headerInfo">';
		header += '<p><span>235 N. Lake Ave, Pasadena CA 91101 : Tel (626) 568-3331</span></p>';
		header += '</div>';
		header += '</div>';
	/*<!--end headerBoxRight -->*/
		header += '</div>';
   	/*<!--end headerBox-->*/
		
		header += '<div id="menuMain" class="menu">';
		header += theMenu;
		header += '</div>';
   		/*<!--end menuMain -->*/

		$('#header').html(header);

		var footer = '';
		footer += '<div id="menuFooter" class="menu">';	
		footer += theMenu;
		footer += '</div>';	
		footer += '<div id="copyright"><p>';
		footer += 'Copyright &copy; 2000-2009 Run With Us. All Rights Reserved.  All other trademarks and copyrights are the property of their respective holders.';
		footer += '</p></div>';	
		$('#footer').html(footer);
		
		/*important to keep this last 'return this' --> it maintains the jquery chain*/
		return this;
	};
 
})(jQuery);