// JavaScript Document

		// Function: setCarbonCookies()
		// Called in reCalculate() after calculations have been made
		// Use AJAX to call setCarbonCookies.cfm to set cookies storing emissions

function setCarbonCookies(cookie_name, cookie_value) {	
				var xmlHttp;
				try
				  {
				  // Firefox, Opera 8.0+, Safari
				  xmlHttp=new XMLHttpRequest();
				  }
				catch (e)
				  {
				  // Internet Explorer
				  try
					{
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}
				  catch (e)
					{
					try
					  {
					  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					  }
					catch (e)
					  {
					  alert("Your browser does not support AJAX!");
					  return false;
					  }
					}
				  }				
				var url = "setCarbonCookies.cfm?cookie_name=" + cookie_name + "&cookie_value=" + cookie_value;
				xmlHttp.open("GET",url,true);
				xmlHttp.send(null);				
}



		// Function: radioSet()
		// Triggered after a radio button change
		// Used to account for the radio button's unique and awkward syntax. Radio buttons are saved into an array and must normally be looped through to find out which one was checked 
		// This function assigns the passed variable value to the passed variable name; the variable name is a hidden input that holds the value of the selected radio button.	
	function radioSetStatic(variable_name, variable_value) {
		document.getElementById(variable_name).value = variable_value;
	}
	
		// Function: variableCheck()
		// Triggered in two cases: in the calculators without submit buttons this calculator is triggered right after a form input is changed. Or it is triggered for each form input after the form is submitted
		// This function checks whether an answer for the required field has been provided. In the case that the variable type is a number, the function will check for a number value. A blank input will result in a blank graphic, an error message, and a return of 1. An incorrect input will result in an Xed graphic, an error message, and a return of 1. An correct input will result in a checked graphic, no error message, and a return of 0.

	function variableCheck(variable_name, variable_type, box_name) {
					var label = "individuals";		

		if ((document.URL).indexOf("residents") != -1) {
			 label = "individuals";		
		}
		else if ((document.URL).indexOf("groupsandbusinesses") != -1) {
			 label = "organizations";		
		}
		
		if( box_name ) { // tick box & message have different name from input...
			var pic = box_name + "_box";
			var message = box_name + "_message";
		} else {
			var pic = variable_name + "_box";
			var message = variable_name + "_message";
		}
			
		
		if (document.getElementById(variable_name).value == "") {
			setVariablePic( pic, label, 'blank' );
//			document.getElementById(pic).src = "images/icon_" + label + "_box_blank.png";
			if (document.getElementById(message)) {	
				document.getElementById(message).innerHTML = "You haven't provided an answer for this step.";
			}
			return 1;
		}
		else {
			if ((variable_type == "number" || variable_type == "positive_number") && isNaN(document.getElementById(variable_name).value) == true) {
				setVariablePic( pic, label, 'x' );
//				document.getElementById(pic).src = "images/icon_" + label + "_box_x.png";
				if (document.getElementById(message)) {	
					document.getElementById(message).innerHTML = "This step requires a numbered value. What you have provided isn't a number.";
				}
				return 1;
			} else if( variable_type == "number" && document.getElementById( variable_name ).value < 0 ) {
				setVariablePic( pic, label, 'x' );
				if (document.getElementById(message))	
					document.getElementById(message).innerHTML = "This step requires a non-negative number.";
				return 1;

			} else if( variable_type == "positive_number" && document.getElementById( variable_name ).value < 1 ) {
				setVariablePic( pic, label, 'x' );
//				document.getElementById(pic).src = "images/icon_" + label + "_box_x.png";
				if (document.getElementById(message)) {	
					document.getElementById(message).innerHTML = "This step requires a number greater than zero.";
				}
				return 1;
			} else {
				setVariablePic( pic, label, 'check' );
//				document.getElementById(pic).src = "images/icon_" + label + "_box_check.png";
				if (document.getElementById(message) && document.getElementById(message).innerHTML) {	
					document.getElementById(message).innerHTML = "";
				}
				return 0;
			}
		}
	}
	
	function setVariablePic( id, label, type ) {
		if( typeof( document.getElementById( id ) ) != 'undefined' && document.getElementById( id ) ) {
			document.getElementById( id ).src = "images/icon_"+ label +"_box_"+ type +".png";
		}
	}
	
	// Function: calculatorFooter()
	// Triggered when a new result appears for calculators
	// 	
function calculatorFooter(emissions, summary_date, isClerUser, last_calculator, next_calculator) {
    if (document.getElementById("calculator_footer").innerHTML.indexOf("What Next") == -1) {
        var results_string = "";
        var footer_string = "";
        var this_page = 0;
        var calculator_titles = ["Home Energy", "Household Transportation", "Household Waste Generation", "Lawn and Garden"];
        var calculator_labels = ["homeenergy", "personaltransportation", "waste2", "lawnandgarden"];
		var calculator_images = ["icon_homeenergy_tiny.png","icon_personaltransportation_tiny.png","icon_individuals_calculators_waste_tiny.png","icon_individuals_calculators_lawn_tiny.png","icon_vacationtravel_tiny.png"];
        /*var calculator_titles = ["Personal Transportation", "Vacation Travel", "Food", "Waste", "Home Energy"];
			var calculator_labels = ["personaltransportation", "vacationtravel", "food", "waste", "homeenergy"];*/

                for (var i = 0; i < calculator_labels.length; i++) 
                {
                    if ((document.URL).indexOf(calculator_labels[i]) != -1) {
						this_page = i;
					}
				}


        footer_string = "<div class='bg_kobi rounded padding_all margin_all' style='height: 80px'><h1>Results</h1><strong style='float: left'>Your emissions are estimated to be:</strong><strong style='float: right;'><div id='final_emissions' style='clear: none'>" + emissions.toString() + "</div> tonnes of C0<sub>2</sub></strong></div><h1 class='fg_rockyspine' style='text-align: center'>What Next</h1><div class='bg_kobi rounded padding_all margin_all' style='height: 100px'>";

        if(isClerUser > 0)
        {

            if (!summary_date) 
            {
            footer_string += "<h2 style='padding-bottom: 8px;'>NEXT STEP</h2>";
                if(last_calculator == 1) //we just added a trip. offer to add another trip
                {
                    footer_string = footer_string + "<div style='clear: none; float: left; width: 80px; text-align: center; padding: 0px 6px 0px 6px'><a href='#form'><img src='images/icon_personaltransportation_tiny.png' style='clear: both; padding: 0px 13px 0px 13px' /></a><br /><a href='#form'>Personal Transportation (next trip)</a></div>";
                } 
				else if( last_calculator == 4) // vacation calc is now optional
				{
					footer_string += "<div style='clear: none; float: left; width: 80px; text-align: center; padding: 0px 6px 0px 6px'><a href='#form'><img src='images/icon_vacationtravel_tiny.png' style='clear: both; padding: 0px 13px 0px 13px' /></a><br /><a href='#form'>Vacation Travel (next trip)</a></div>";
				}
                if(next_calculator == undefined) //no next calculator, or there's a problem
                {
					if( last_calculator != 4 ) {
					footer_string += "<div style='clear: none; float: left; width: 80px; text-align: center; padding: 0px 6px 0px 6px'><a href='residents_measureyouremissions_calculators_vacationtravel.cfm'><img src='images/icon_vacationtravel_tiny.png' style='clear: both; padding: 0px 13px 0px 13px' /></a><br /><a href='residents_measureyouremissions_calculators_vacationtravel.cfm'>Vacation Travel (optional)</a></div>";
					}
					
                    footer_string += "<div style='padding: 0px 6px; clear: none; float: left; width: 80px; text-align: center;'>"
                    footer_string += "<a href='residents_measureyouremissions_calculators_summary.cfm'>";
                    footer_string += "<img src='images/co2_flat_tiny.png' style='padding: 0px 13px; clear: both;'></a>";
                    footer_string += "<br>";
                    footer_string += "<a href='residents_measureyouremissions_calculators_summary.cfm'>View Your Emissions Summary</a>";
                    footer_string += "</div>";
                }
                else
                {
                    footer_string = footer_string + "<div style='clear: none; float: left; width: 80px; text-align: center; padding: 0px 6px 0px 6px'><a href='residents_measureyouremissions_calculators_" + calculator_labels[next_calculator] + ".cfm'><img src='/images/" + calculator_images[next_calculator] + "' style='clear: both; padding: 0px 13px 0px 13px' /></a><br /><a href='residents_measureyouremissions_calculators_" + calculator_labels[next_calculator] + ".cfm'>" + calculator_titles[next_calculator] + "</a></div>";
                }
                    
                footer_string += "</div>";

            } else {
                footer_string += "<h2 style='padding-bottom: 8px;'>RETURN TO SUMMARY <img src='images/arrow_white.png' /></h2>";
                footer_string += "<a href='residents_measureyouremissions_calculators_summary_breakdown.cfm?date=" + summary_date + "'>";
                footer_string += "<img src='images/co2_flat.png' style='clear: left; float: left;'></a>";
                footer_string += "<div style='clear: none; float: left; width: 90px; padding: 5px;'>";
                footer_string += "<a href='residents_measureyouremissions_calculators_summary_breakdown.cfm?date=" + summary_date + "'>Return to Your Emissions Summary</a>";
                footer_string += "</div>";
                footer_string += "<div style='clear: right; float: left; width: 280px;'>";
                footer_string += "See the rest of your emissions from " + summary_date + ".";
                footer_string += "</div>";
                footer_string += "</div>";
            }
        }
        else
        {
            if (!summary_date) 
            {

                footer_string += "<h2 style='padding-bottom: 8px;'>COMPLETE ANOTHER CALCULATOR</h2>";

                for (var i = 0; i < calculator_labels.length; i++) 
                {
                    if ((document.URL).indexOf(calculator_labels[i]) == -1) {
                        footer_string = footer_string + "<div style='clear: none; float: left; width: 80px; text-align: center; padding: 0px 6px 0px 6px'><a href='residents_measureyouremissions_calculators_" + calculator_labels[i] + ".cfm'><img src='images/" + calculator_images[i] + "' style='clear: both; padding: 0px 13px 0px 13px' /></a><br /><a href='residents_measureyouremissions_calculators_" + calculator_labels[i] + ".cfm'>" + calculator_titles[i] + "</a></div>";
                    }
                    else {
                        if (calculator_titles[i] == "Personal Transportation" || calculator_titles[i] == "Vacation Travel") {
                            footer_string = footer_string + "<div style='clear: none; float: left; width: 80px; text-align: center; padding: 0px 6px 0px 6px'><a href='#form'><img src='images/" + calculator_images[i] + "' style='clear: both; padding: 0px 13px 0px 13px' /></a><br /><a href='#form'>" + calculator_titles[i] + " (next trip)</a></div>";
                        }
                    }
                    //if (i != (calculator_labels.length) || (i == (calculator_labels.length -1) && (document.URL).indexOf(calculator_labels[calculator_labels.length]) != -1)) {
                    //footer_string = footer_string + "<img src='images/arrow_grey.png' style='clear: none; float: left; padding: 3px' />";
                    //}
                }

/*              footer_string += "<div style='padding: 0px 6px; clear: none; float: left; width: 80px; text-align: center;'>"
                footer_string += "<a href='residents_measureyouremissions_calculators_summary.cfm'>";
                footer_string += "<img src='images/co2_flat_tiny.png' style='padding: 0px 13px; clear: both;'></a>";
                footer_string += "<br>";
                footer_string += "<a href='residents_measureyouremissions_calculators_summary.cfm'>View Your Emissions Summary</a>";
                footer_string += "</div>";
*/
                footer_string += "</div>";
				
				footer_string += "<div class='bg_kobi rounded padding_all margin_all' style='height: 90px'>";
    			footer_string += "<h2 style='padding-bottom: 10px;'>OR SKIP TO <img src='images/arrow_white.png' /></h2>";
    			footer_string += "<a href='residents_measureyouremissions_calculators_summary.cfm'>";
                footer_string += "<img src='images/co2_flat.png' style='clear: left; float: left;'></a>";
                footer_string += "<div style='clear: none; float: left; width: 90px; padding: 5px;'>";
                footer_string += "<a href='residents_measureyouremissions_calculators_summary.cfm'>View Your Emissions Summary</a>";
                footer_string += "</div>";
                footer_string += "<div style='clear: right; float: left; width: 280px;'>";
                footer_string += "View a summary of all the calculators you have completed so far and fill in any gaps. ";
				footer_string += "If you <a href='register.cfm'>created an account</a>, you could also view a breakdown of your emissions over time.";
                footer_string += "</div>";
    			footer_string += "</div>";


            } else {
                footer_string += "<h2 style='padding-bottom: 8px;'>RETURN TO SUMMARY <img src='images/arrow_white.png' /></h2>";
                footer_string += "<a href='residents_measureyouremissions_calculators_summary_breakdown.cfm?date=" + summary_date + "'>";
                footer_string += "<img src='images/co2_flat.png' style='clear: left; float: left;'></a>";
                footer_string += "<div style='clear: none; float: left; width: 90px; padding: 5px;'>";
                footer_string += "<a href='residents_measureyouremissions_calculators_summary_breakdown.cfm?date=" + summary_date + "'>Return to Your Emissions Summary</a>";
                footer_string += "</div>";
                footer_string += "<div style='clear: right; float: left; width: 280px;'>";
                footer_string += "See the rest of your emissions from " + summary_date + ".";
                footer_string += "</div>";
                footer_string += "</div>";
            }
        }
        
            var tags = calculator_titles[this_page].toLowerCase().split(" ");
            var tag_string = "";
            for (var j = 0; j < tags.length; j++) {
                tag_string = tag_string + "tag" + (j + 1) + "=" + tags[j];
                if (j != tags.length - 1) {
                    tag_string = tag_string + "&";
                }
            }
		
		if( ! isClerUser ) {
            footer_string = footer_string + "<div class='bg_kobi rounded padding_all margin_all' style='height: 90px'><h2 style='padding-bottom: 10px;'>OR SKIP TO <img src='images/arrow_white.png' /></h2><a href='residents_reduceyouremissions_actions.cfm?" + tag_string + "'><img src='images/" + calculator_images[this_page] + "' style='clear: left; float: left' /></a><div style='clear: none; float: left; width: 90px; padding: 5px;'><a href='residents_reduceyouremissions_actions.cfm?" + tag_string + "'>Reduce Your " + calculator_titles[this_page] + " Emissions</a></div><div style='clear: right; float: left; width: 280px;'>Now that you have an idea of what your " + calculator_titles[this_page] + " emissions are, you can use tools to find out what options you have to reduce those emissions.</div></div><div class='bg_kobi rounded padding_all margin_all' style='height: 80px'><h2 style='padding-bottom: 10px;'>OR SKIP TO <img src='images/arrow_white.png' /></h2><a href='buyoffsets.cfm?pagetheme=residents'><img src='images/offsets_factory_flat.png' style='clear: left; float: left;' /></a><div style='clear: none; float: left; width: 90px; padding: 5px;'><a href='buyoffsets.cfm?pagetheme=residents'>Offset Your Emissions</a></div><div style='clear: right; float: left; width: 280px;'>Now that you have calculated your emissions, you can become carbon neutral by purchasing offsets.</div></div><div>";
		}
			
            document.getElementById("calculator_footer").innerHTML = footer_string;
            document.getElementById("calculator_footer").style.visibility = "visible";
            document.getElementById("calculator_footer").style.height = "auto";
        
    }
    else {
        document.getElementById("final_emissions").innerHTML = emissions;
    }

}

function calculatorFooterGaB( emissions, summary_date, isCler, last_calculator, next_calculator ) {
	
	var flow = [ // order in which CLER users go thru the calcs
		{   // 0
			url: 'groupsandbusinesses_measureyouremissions_calculators_buildingenergy.cfm',
			icon: '/images/icon_organizations_buildings_tiny.png',
			name: 'Building Energy'
		},
		{   // 1
			url: 'residents_measureyouremissions_calculators_personaltransportation.cfm',
			icon: '/images/icon_personaltransportation_tiny.png',
			name: 'Transportation',
			multi: true
		},
		{   // 2
			url: 'groupsandbusinesses_measureyouremissions_calculators_waste2.cfm',
			icon: '/images/icon_individuals_calculators_waste_tiny.png',
			name: 'Waste Generation'
		},
		{   // 3
			url: 'residents_measureyouremissions_calculators_lawnandgarden.cfm',
			icon: '/images/icon_individuals_calculators_lawn_tiny.png',
			name: 'Grounds Maintenance'
		},
		{   // 4
			url: 'residents_measureyouremissions_calculators_vacationtravel.cfm',
			icon: '/images/icon_vacationtravel_tiny.png',
			name: 'Business Travel',
			multi: true,
			optional: true
		}
	];
	
	footer_string = "<div class='bg_sushi rounded padding_all margin_all' style='height: 80px'>";
	footer_string += "<h1>Results</h1>";
	footer_string += "<strong style='float: left'>Your emissions are estimated to be:</strong>";
	footer_string += "<strong style='float: right'>" + emissions + " tonnes of C0<sub>2</sub></strong>";
	footer_string += "</div>";
	footer_string += "<h1 class='fg_rockyspine' style='text-align: center'>What Next</h1>";
		
	if( isCler ) {
		footer_string += "<div class='bg_sushi rounded padding_all margin_all' style='height: 100px'>";
		footer_string += "<h2 style='padding-bottom: 8px;'>NEXT STEP</h2>";
		
		if( typeof( flow[last_calculator].multi ) != 'undefined' && flow[last_calculator].multi ) {
			footer_string += "<div style='clear: none; float: left; width: 80px; text-align: center; padding: 0px 6px 0px 6px'>";
			footer_string += "<a href='#form'>";
			footer_string += "<img src='"+ flow[last_calculator].icon +"' style='clear: both; padding: 0px 13px 0px 13px' />";
			footer_string += "</a><br />";
			footer_string += "<a href='#form'>"+ flow[last_calculator].name +" (next trip)</a></div>";
		}
		
		if( typeof( next_calculator ) == 'undefined' || typeof( flow[next_calculator].optional ) != 'undefined' && flow[next_calculator].optional ) {
			if( typeof( next_calculator ) != 'undefined' && typeof( flow[next_calculator].optional ) != 'undefined' && flow[next_calculator].optional ) {
				footer_string += "<div style='clear: none; float: left; width: 80px; text-align: center; padding: 0px 6px 0px 6px'>";
				footer_string += "<a href='"+ flow[next_calculator].url +"'>";
				footer_string += "<img src='"+ flow[next_calculator].icon +"' style='clear: both; padding: 0px 13px 0px 13px' />";
				footer_string += "</a><br />";
				footer_string += "<a href='"+ flow[next_calculator].url +"'>"+ flow[next_calculator].name +" (optional)</a></div>";
			}
	        footer_string += "<div style='padding: 0px 6px; clear: none; float: left; width: 80px; text-align: center;'>"
            footer_string += "<a href='residents_measureyouremissions_calculators_summary.cfm'>";
            footer_string += "<img src='images/co2_flat_tiny.png' style='padding: 0px 13px; clear: both;'></a>";
            footer_string += "<br>";
            footer_string += "<a href='residents_measureyouremissions_calculators_summary.cfm'>View Your Emissions Summary</a>";
            footer_string += "</div>";
		} else {
			footer_string += "<div style='clear: none; float: left; width: 80px; text-align: center; padding: 0px 6px 0px 6px'>";
			footer_string += "<a href='"+ flow[next_calculator].url +"'>";
			footer_string += "<img src='"+ flow[next_calculator].icon +"' style='clear: both; padding: 0px 13px 0px 13px' />";
			footer_string += "</a><br />";
			footer_string += "<a href='"+ flow[next_calculator].url +"'>"+ flow[next_calculator].name +"</a></div>";
		}
		
		footer_string += "</div>";
		
	} else {
	
	footer_string += "<div class='bg_sushi rounded padding_all margin_all' style='height: 80px'>";
	footer_string += "<h1 style='margin-top: -7px; padding-top: -7px'>COMPLETE ANOTHER CALCULATOR</h1>";
	footer_string += "<a href='groupsandbusinesses_measureyouremissions_calculators_conferences.cfm'><img src='images/icon_organizations_conferences_tiny.png' style='clear: left; float: left' /></a>";
	footer_string += "<div style='clear: none; float: left; padding: 6px'>";
	footer_string += "<a href='groupsandbusinesses_measureyouremissions_calculators_conferences.cfm'>Conferences</a></div>";
	footer_string += "</div>";
	
	footer_string += "<div class='bg_sushi rounded padding_all margin_all' style='height: 90px'><h1 style='margin-top: -7px; padding-top: -7px'>OR SKIP TO <img src='images/arrow_white.png' /></h1><a href='buyoffsets.cfm?pagetheme=groupsandbusinesses'><img src='images/offsets_factory_flat.png' style='clear: left; float: left;' /></a><div style='clear: none; float: left; width: 80px; padding: 5px;'><a href='buyoffsets.cfm?pagetheme=groupsandbusinesses'>Offset Your Emissions</a></div><div style='clear: right; float: left; width: 280px;'>Now that you have calculated your emissions, you can become carbon neutral by purchasing offsets.</div></div><div>";	
	}
					 
		document.getElementById("calculator_footer").innerHTML = footer_string;			 
					 
					document.getElementById("calculator_footer").style.visibility = "visible";
					document.getElementById("calculator_footer").style.height = "auto";
					makeroundedcorners(); 										
					//chart(emissions, space_heating_emissions, water_heating_emissions, auxiliary_equipment_emissions, lighting_emissions, auxiliary_motors_emissions, space_cooling_emissions);					
}

/* options: {
	success_callback: function (required)
	error_callback: function (required)
	message_element_id: error messages will be written here (required)
	precision: the minimum precision of the returned address - see gmaps API (optional, default 5)
	country: bias results to a particular country (optional, default ca)
*/
top.check_address_semaphore = false; // ensures only one execution at a time
function checkAddress( address, opts ) {
	if( top.check_address_semaphore )
		return;
	
	var message = document.getElementById( opts.message_element_id );
	
	if( typeof( GBrowserIsCompatible ) != 'function' ) {
		message.innerHTML = "GMaps not available.";
		opts.error_callback();
		return;
	} else if( ! GBrowserIsCompatible() ) {
		message.innerHTML = "GMaps not available.";
		opts.error_callback();
		return;
	} else if( address == "" ) {
		message.innerHTML = "No address entered.";
		opts.error_callback();
		return;
	}
	
	top.check_address_semaphore = true;
	
	var precision = (typeof( opts.precision ) == 'undefined' ? 5 : opts.precision);
	var geocoder = new GClientGeocoder();
	geocoder.setBaseCountryCode( (typeof( opts.country ) == 'undefined' ? 'ca' : opts.country) );

	message.innerHTML = "Checking address...";
	geocoder.getLocations( address, function( response ) {
		if( ! response || response.Status.code != 200 ) {
			message.innerHTML = "Could not locate address.";
			opts.error_callback();
		} else if( response.Placemark[0].AddressDetails.Accuracy < precision ) {
			message.innerHTML = "Address not accurate enough.";
			opts.error_callback();
		} else {
			message.innerHTML = "Using address "+ response.Placemark[0].address +".";
			opts.success_callback( response );
		}
		
		top.check_address_semaphore = false;
	} );

}

function checkEmail() {
  if( $('email').value == '' ) {
  	$('email_message').update( "You haven't provided an answer for this step." );
	setVariablePic( 'email_box', 'individuals', 'blank' );
	return 1;
  } else if( ! $('email').value.match( /^\w+[\.\w]*\@\w+\.[\w\.]*\w+$/ ) ) {
   	$('email_message').update( "You haven't provided a valid email address." );
	setVariablePic( 'email_box', 'individuals', 'x' );
	return 1;
  } else {
    if( $('email_message').innerHTML )
	  $('email_message').update( '' );
	setVariablePic( 'email_box', 'individuals', 'check' );
	return 0;
  }
}

function checkPasswords() {
  if( $('password').value == '' && $('confirm_password').value == '' ) {
	setVariablePic( 'password_box', 'individuals', 'blank' );
	setVariablePic( 'confirm_password_box', 'individuals', 'blank' );
    if( $('password_message').innerHTML ) $('password_message').update( '' );
    if( $('confirm_password_message').innerHTML ) $('confirm_password_message').update( '' );
	return 1;
  } else if( $('password').value == '' && $('confirm_password').value != '' ) {
	setVariablePic( 'password_box', 'individuals', 'blank' );
    $('password_message').update( "You haven't provided an answer for this step." );
	return 1;
  } else if( $('password').value != '' && $('confirm_password').value != '' ) {
    if( $('password').value.length < 4 ) {
      $('password_message').update( "Passwords must be at least 4 characters long." );
	  setVariablePic( 'password_box', 'individuals', 'x' );
	  return 1;
	} else if( $('password').value != $('confirm_password').value ) {
	  $('password_message').update( "Passwords do not match." );
  	  setVariablePic( 'password_box', 'individuals', 'x' );
      return 1;
	} else {
  	  setVariablePic( 'password_box', 'individuals', 'check' );
  	  setVariablePic( 'confirm_password_box', 'individuals', 'check' );
      if( $('password_message').innerHTML ) $('password_message').update( '' );
      if( $('confirm_password_message').innerHTML ) $('confirm_password_message').update( '' );
	  return 0;
	}
  } else if( $('password').value != '' && $('password').value.length > 3 ) {
  	  setVariablePic( 'password_box', 'individuals', 'check' );
      if( $('password_message').innerHTML ) $('password_message').update( '' );
	  return 1;
  }
  return 1;
}
