﻿		Event.observe(window, 'load', loadAccordions, false);
	
		var topAccordion;
		
		var tabnum=2;
	
		function loadAccordions()
		{

				topAccordion = new accordion('horizontal_container', {
				classNames : {
					toggle : 'horizontal_accordion_toggle',
					toggleActive : 'horizontal_accordion_toggle_active',
					content : 'horizontal_accordion_content'
					},
					defaultSize : {
						width : 877
						},
					direction : 'horizontal'
				});

			// pick a tab index to start as open
			//topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[tabnum]);

			// show tabs and divs
			document.getElementById('panel_lead').style.display = 'block';
			document.getElementById('panel_hot').style.display = 'block';
			
			// check query string - direct to specific page
			try
			{
				if(getQueryVariable("o") == 'y')
				{
					topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[0]);
					tabnum = 0;
					show_registration('lead');
				}
				else if(getQueryVariable("h") == 'y')
				{
					topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[1]);
					tabnum = 1;
					show_registration('hot');
				}
				else
				{
					// pick a tab index to start as open
					topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[2]);
					if(document.getElementById('showingThankyou').value != "yes") { open_home(); }
				}
			}
			catch(ex)
			{
				// pick a tab index to start as open
				topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[2]);
			}

		}


		function getQueryVariable(variable)
		{
			var query = window.location.search.substring(1);
			var vars = query.split("&");
			for (var i=0;i<vars.length;i++)
			{
				var pair = vars[i].split("=");
				if (pair[0] == variable)
				{
					return pair[1];
				}
				else
					return 'not found';
			}
		}
		
		function open_advocate()
		{
			clean();
			if(tabnum != 0)
			{
				tabnum = 0;
				topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[0]);
			}
		}
		
		function open_hottopics()
		{
			clean();
			if(tabnum != 1)
			{
				tabnum = 1;
				topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[1]);
			}
		}
		
		function open_home()
		{
			clean();
			if(tabnum != 2)
			{
				tabnum = 2;
				topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[2]);
			}
		}
		
		function show_registration(id)
		{
			document.getElementById(id).style.display = 'none';
			document.getElementById(id + '_registration').innerHTML = document.getElementById('registration').innerHTML;
			document.title = "ABCF: Alamo Breast Cancer Foundation";
		}
		
		function clean()
		{
			document.getElementById('lead').style.display = 'inline';
			document.getElementById('hot').style.display = 'inline';
			
			document.getElementById('lead_registration').innerHTML = "";
			document.getElementById('hot_registration').innerHTML = "";
			
		    	document.getElementById('thankyou').style.display = 'none';
			document.getElementById('home').style.display = 'block';
		}
		
		function open_pl()
		{
			tabnum = 0;
			topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[0]);
		}
		
		function open_ht()
		{
			tabnum = 1;
			topAccordion.activate($$('#horizontal_container .horizontal_accordion_toggle')[1]);
		}
		
		function fix()
		{
			if(navigator.appName == "Microsoft Internet Explorer")
			{
				document.getElementById('under').style.display = "none";
			}
		}
		
		function validate()
		{
		    var valid = false;
		    
		    if(document.getElementById('txtFirstName').value != "" && document.getElementById('txtLastName').value != "")
		    {
		        if(document.getElementById('txtAddress1').value != "" && document.getElementById('txtCity').value != "")
		        {
		            if(document.getElementById('txtState').value != "" && document.getElementById('txtPostalCode').value != "")
		            {
	                    if(document.getElementById('txtEmailAddress').value != "")
	                    {
	                        if(document.getElementById('radio_notinclude').checked || document.getElementById('radio_include').checked)
		                    {
		                        valid = true;
		                    }
	                    }
		            }
		        }
		    }
		    
		    if(!valid)
		        document.getElementById('required').style.display = 'inline';
		    else
		        document.getElementById('required').style.display = 'none';
		        
            	    return valid; 
		}
		
		function show_thankyou()
		{
			document.getElementById('thankyou').style.display = 'block';
			document.getElementById('home').style.display = 'none';

			document.getElementById('showingThankyou').value = 'yes';
		}
		
		function removetext(caller)
		{
		    if(document.getElementById(caller.id).value == 'Qty')
		        document.getElementById(caller.id).value = '';
		}
				
        function isNumberKey(evt, caller)
        {
            removetext(caller);
        
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 40 || charCode > 57 || charCode == 42 || charCode == 43 ))
                return false;

            return true;
        }
