		
		
		
		
		//alert ("javascript.js has loaded");
		//alert ('the_section = ' + the_section);
		//alert ('the_section_sub = ' + the_section_sub);
		
		
		
		
//	VARS

//	This path helps us move the site from server to server, use consistent root-level links, etc.
	var the_path = '/client_production/the_living_fields/www-thelivingfields-com/';
	var the_path = '/';

	// CHANGE THIS IN __global/page_top.php AS WELL!!!!
	// CHANGE THIS IN __global/popup_top.php AS WELL!!!!

//	List all the nav items we're going to be dealing with.
//	These references match the ID of each nav item's IMG.
//	Ideally, this list should be assembled automatically by looping through and getting anything which has an ID starting with "nav_".
	var nav_items = [
	
		'nav_btn_news',
		'nav_btn_biography',
		'nav_btn_discography',
		'nav_btn_downloads',
		'nav_btn_friends',
		'nav_btn_contact'
	];
	








//	PRELOAD ROLLOVER GRAPHICS

	var images_to_preload = [
		the_path + '___media/__framework/_page_top/sidebar_nav_btn_news_over.gif',
		the_path + '___media/__framework/_page_top/sidebar_nav_btn_biography_over.gif',
		the_path + '___media/__framework/_page_top/sidebar_nav_btn_discography_over.gif',
		the_path + '___media/__framework/_page_top/sidebar_nav_btn_downloads_over.gif',
		the_path + '___media/__framework/_page_top/sidebar_nav_btn_friends_over.gif',
		the_path + '___media/__framework/_page_top/sidebar_nav_btn_contact_over.gif'
	];
	
		//alert ("preloaded_images = " + images_to_preload.length);
	
	for (var i=0; i<images_to_preload.length; i++) {
		
		var preloaded_image = new Image();
		
		preloaded_image.src = the_path + images_to_preload[i];
	}
	
		//alert ("Not broken...");
		
		
		
		
		
		
		
		

//	FUNCTIONS

//	This function adds our prepare_elements function to the list of functions to execute onLoad.
//	This is necessary because when Geo adds rollovers, etc. w/ Dreamweaver, DW adds an onLoad call in the body. 	
	function add_load_event(func) {
	
		var old_onload = window.onload;
		
		if (typeof window.onload != 'function') {
			
			window.onload = func;
		
		} else {
		
			window.onload = function () {
				old_onload();
				func();
			}
		}
	}
	
	
	
	
	function getElementsByClass(elem, classname) {
		
		classes = new Array();
		
		alltags = document.getElementsByTagName(elem);
		
		for (i=0; i<alltags.length; i++) {
		
			if (alltags[i].className == classname) {
		
				classes[classes.length] = alltags[i];
			}
		}
		
		return classes;
	}
	
	
	
	
	function image_swap (id, src) {
		
			//alert ("rolling over " + id + ", swapping with " + src);
			
		document.getElementById(id).src = src;
	}
	
	
	
	
	function prepare_elements() {
	
			
			
			//alert ("preparing elements...");
	
	
	
	//	Attach functionality to various images
	
		var images = document.getElementsByTagName("img");
		
		for (var i=0; i<images.length; i++) {
			
		//	Wire the nav buttons for image_swap & subnav reveals
			
			if (images[i].getAttribute("class") == "nav_btn" || images[i].getAttribute("className") == "nav_btn") {
				
				images[i].onmouseover = function () {
				
						//alert ('rolling over ' + the_path + '___media/__framework/_page_top/sidebar_' + this.getAttribute('id') + '_over.gif');
				
				//	Turn off all other buttons
					for (var i=0; i<nav_items.length; i++) {
						image_swap(nav_items[i], the_path + '___media/__framework/_page_top/sidebar_' + nav_items[i] + '.gif');
					}
				
				//	HIghlight this button
					image_swap(this.getAttribute('id'), the_path + '___media/__framework/_page_top/sidebar_' + this.getAttribute('id') + '_over.gif');
				}
				
				images[i].onmouseout = function () {
					
						//alert ('rolling out');
					
					image_swap(this.getAttribute('id'), the_path + '___media/__framework/_page_top/sidebar_' + this.getAttribute('id') + '.gif');
				}
			}
		}
		
	//	Attach functionality to various links
	
		var links = document.getElementsByTagName("a");
		
		for (var i=0; i<links.length; i++) {
		
		//	Wire the popup links
		
			if (links[i].getAttribute("class") == "popup" || links[i].getAttribute("className") == "popup") {
				
				links[i].onclick = function () {
					
					popup(this,'popup','650','500','scrollbars=yes,resizable=yes');
					
					return false;
				}
			}
		
		//	Wire the REVIEW popup links
		
			if (links[i].getAttribute("class") == "popup_review" || links[i].getAttribute("className") == "popup_review") {
				
				links[i].onclick = function () {
					
					popup(this,'popup_review','480','350','scrollbars=yes,resizable=no');
					
					return false;
				}
			}
		
		//	Wire the LYRICS popup links
		
			if (links[i].getAttribute("class") == "popup_lyrics" || links[i].getAttribute("className") == "popup_lyrics") {
				
				links[i].onclick = function () {
					
					popup(this,'popup_lyrics','440','700','scrollbars=yes,resizable=no');
					
					return false;
				}
			}
		
		//	Wire the MP3 popup links
		
			if (links[i].getAttribute("class") == "popup_mp3" || links[i].getAttribute("className") == "popup_mp3") {
				
				links[i].onclick = function () {
					
					popup(this,'popup_mp3','480','100','scrollbars=yes,resizable=no');
					
					return false;
				}
			}
		
		//	Wire the ALBUM COVER popup links
		
			if (links[i].getAttribute("class") == "popup_album_cover" || links[i].getAttribute("className") == "popup_album_cover") {
				
				links[i].onclick = function () {
					
					popup(this,'popup_album_cover','528','528','scrollbars=no,resizable=no');
					
					return false;
				}
			}
		
		//	Wire the BUY popup links
		
			if (links[i].getAttribute("class") == "popup_buy_pic"
					
					||
					
				links[i].getAttribute("className") == "popup_buy_pic"
					
					||
					
				links[i].getAttribute("class") == "popup_buy"
					
					||
					
				links[i].getAttribute("className") == "popup_buy"
			  
			) {
				
				links[i].onclick = function () {
					
					popup(this,'buy','620','500','scrollbars=yes,resizable=no');
					
					return false;
				}
			}
		
		//	Wire the SPREAD popups links
		
			if (links[i].getAttribute("class") == "popup_spread" || links[i].getAttribute("className") == "popup_spread") {
				
				links[i].onclick = function () {
					
					popup(this,'popup_spreadw','520','347','scrollbars=no,resizable=no');
					
					return false;
				}
			}
		}
		
		
	//	Make sure they've selected a shirt size on the merch page
		var forms_w_shirt_size = getElementsByClass('form', 'form_w_shirt_size');
		
			/* FOR TESTING ONLY */ //alert ('There are ' + forms_w_shirt_size.length + ' forms w/ tshirt size');
		
		for (i=0; i<forms_w_shirt_size.length; i++) {
			
				/* FOR TESTING ONLY */ //alert (forms_w_shirt_size[i].item_name.value);
			
			forms_w_shirt_size[i].onsubmit = function () {
				
					/* FOR TESTING ONLY */ //alert (this.item_name.value); return false;
				
				if (this.item_name.value == '') {
					
					alert ('Please choose your shirt size before ordering...');
					
					return false;
				}
			}
		}
		
		
		
			/* FOR TESTING ONLY */ //alert ('page preparation complete');
 	}	
	
	
	
	
	function popup (link, name, width, height, features) {
	
			//alert ("opening a popup");
	
		window.open(link, name, "width="+width+","+"height="+height+","+features);
	}
	
	
	
	
	function toggle (id, state) {
	
			//alert ("toggling " + id + " to " + state);
	
		document.getElementById(id).style.display = state;
	}
	
	
	
	
	
	
	
	
//	ACTIONS
	
//	Trigger the prepare_elements script as soon as the page loads
	add_load_event(prepare_elements);
	
	
	
	
	
