	// Script Author: Chase Adams
			var RPS = jQuery.noConflict();
			RPS(document).ready(function() {
			     // hides all the classes that we don't want seen just yet. fieldset removed as of 6/19/2011 per request, bob & hilary
				RPS(".tab, .hide_on_no").hide();
			    
			    // Uses the labels text as placeholders for the inputs. Necessary for non-labelled inputs in IE
		    	
		    	
			    (function() {
                    var httpRequest;
                    RPS("#centerId").change(function() { 
                        var id = RPS(this).attr('value');
                         // makeRequest('/123shoot/discoverypoint/ajax/get-dropmenu', id); 
                        makeRequest('/ajax/get-dropmenu', id); 
                    });
                    
                    function makeRequest(url, id) {
                        if(window.XMLHttpRequest) {
                            httpRequest = new XMLHttpRequest();
                            
                        } else if (window.ActiveXObject) {
                            try {
                                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                            }
                            catch(e) {
                                try {
                                    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                                }
                                catch(e) { }            
                            }
                        }
                        
                        if(!httpRequest) {
                            alert('Giving up: (Cannot create an XMLHTTP instance');
                            return false;
                        }
                        
                        httpRequest.onreadystatechange = alertContents;
                        httpRequest.open('POST', url);
                        httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                        httpRequest.send('id=' + id);
                        
                    }
                    
                    function alertContents() {
                        if(httpRequest.readyState === 4) {
                            if(httpRequest.status === 200) {
                                // var response = JSON.parse(httpRequest.responseText);
                                // alert(httpRequest.responseText);
                                RPS("#classCode").empty().append(httpRequest.responseText);
                                //alert(response.computedString);
                                
                            } else {
                                alert('There was a problem with the request.');
                            } 
                        }
                    }
                }) (); 
    			
    			var theInt = setInterval(function() {
        		 	RPS(".center_for_sale_fader").fadeIn(6000,function() {
        		 		RPS(this).fadeOut(6000);
        		 	});
                },1000);
                
                var processInt = setInterval(function() {
                    RPS('.process_complete').slideDown(function() {
                        RPS('.process_complete_message').fadeIn('slow');
                    });
                            
                }, 1000);
				
				
				// shows all the ones we do want seen. Anything that's current we want seen.
				RPS(".current_tab, .current_fieldset").show();
				
				// remove elements if javascript is enabled
				RPS('.remove_on_js').empty().addClass('new_dynamic_js').removeClass('remove_on_js');

                // Quick_navigation javascript added 07/19/2011
                RPS("#quick_navigation li a.show_it").click(function(e) {
                        e.preventDefault();
                        var name = '#' + RPS(this).parent().attr('class').replace('_show', '').replace('shown', '');
                        
                        if(RPS(this).hasClass('closed')) {                                                
                            RPS(name).slideDown();
                            RPS(this).addClass('open').removeClass('closed');
                            RPS(this).parent().addClass('shown');
                        } else if (RPS(this).hasClass('open')) {
                            RPS(name).slideUp(function() {
                            	RPS(this).parent().removeClass('shown');
                            });
                            RPS(this).removeClass('open').addClass('closed'); 
                            
                        }
                });
                
                
                /*
                // This is the tabbed navigation for the form. If you click a tab...
				RPS("#main_nav.tabbed_navigation li a").click(function(e) {
				
					e.preventDefault();
										
					// removes the current_nav class from the current tab, this will make it also change color automatically
					RPS(".current_nav").removeClass("current_nav");
					
					// adds the current_nav class to the new current tab, which will make it automatically change color
					RPS(this).parent().addClass("current_nav");
					
					// create a id based on the tabs title, ie #emp_info. This will be the name of the div we want shown.
					var tab_title = "#" + RPS(this).attr('title');
					
					// removes the current_tab class from the current pane we're showing, fades it out...
					RPS(".current_tab").removeClass("current_tab").fadeOut(function() {
					
    					// removes the shown_fieldset class from the fieldset that's currently shown in the current pane
    					// RPS('.shown_fieldset').removeClass('shown_fieldset').addClass('last_shown_fieldset');
					
					    // removes the current_fieldset class
				        RPS(".current_fieldset").removeClass('current_fieldset').addClass('last_known_fieldset');
						
						// acts on the id we declared earlier.
						RPS(tab_title).fadeIn( function() {
						  var last_shown = tab_title + " fieldset";
    						
    						if(RPS(last_shown).is(".last_known_fieldset")) {
    						
    						  RPS(".last_known_fieldset").slideDown().addClass('current_fieldset').removeClass('last_known_fieldset');
    						  RPS(".last_shown_fieldset").addClass('shown_fieldset').removeClass('last_shown_fieldset');
    						  
    						} else {
    						
    						  // declares an element of the first fieldset in the pane we're showing.
    						  var first_fieldset = tab_title + " fieldset:first";
    						  
    						  // shows the first fieldset.
    						  RPS(first_fieldset).slideDown().addClass('current_fieldset');
    						  
    						  // declares an element of the first heading
    						  first_heading = tab_title + " h3 a:first";
    						  
    						  // adds the shown_fieldset class to the first setting, automatically changing the color of it.
    						  // RPS(first_heading).addClass('shown_fieldset');
    						
    						}
						}).addClass("current_tab");
						
					});
					
					
				});
				
				RPS(".slide_down_js").change( function() {
				    if(RPS(this).attr('id') == 'p_education') {
    					if(RPS(this).attr('value') == "college") {
    						showThis = "#" + RPS(this).attr('title');
    						RPS(showThis).slideDown();
    					}
    				}
    				else {
    				    if(RPS(this).attr('value') != 'no' && RPS(this).attr('value') != 'default'  ) {
    				        showThis = "#" + RPS(this).attr('title');
    						RPS(showThis).slideDown();
    				    }
    				    if(RPS(this).attr('value') == 'no') {
    				        hideThis = "#" + RPS(this).attr('title');
    				        RPS(hideThis).slideUp();
    				    }
    				}
     				
    				
				});
				
				RPS(".char_ref_select").change(function() {
				    if(RPS(this).attr('value') == 'phone') {
				       var addTo = "#show_on_" + RPS(this).attr('id');
				        var number = RPS(addTo).attr('title');
				       RPS(addTo).slideUp(function(){
				        RPS(addTo).empty().hide().append('<label>Phone</label><input type="text" name="character_reference[' + number + '][contact_method]" />').slideDown('fast');
				       });
				    }
				    
				    if(RPS(this).attr('value') == 'address') {
				        var addTo = "#show_on_" + RPS(this).attr('id');
				        var number = RPS(addTo).attr('title');
                       RPS(addTo).slideUp(function(){
				            RPS(addTo).empty().hide().append('<label>Address</label><input type="text" name="character_reference[' + number + '][contact_method]" />').slideDown('fast');
				       });				    
				    }
				});
				
				// Working with the financial interface
				RPS("#fin_table.tabbed_navigation li a").click(function(e) {
					
					e.preventDefault();
					
					// removes the class from which ever panel you're looking at, assets or liabilities
					RPS(".current_fin_nav").removeClass("current_fin_nav");
					
					// changes the class of the current navigation tab to current_fin_nav
					RPS(this).parent().addClass("current_fin_nav");
					
					// gets the title of the financial type, and creates an id that we'll use... 
					var thisfintype = "#" + RPS(this).attr('title');
					
					// hides the pane we were in and shows the pane we want to see.
					RPS(".current_fin").removeClass("current_fin").fadeOut( function() {
					
						RPS(thisfintype).show().addClass("current_fin");
					
					});
				});
				
				 
				RPS("option:selected").change(function() {
					if(RPS(this).attr('value') == "yes") {
						var showThis = "#" + RPS(this).attr('title');
						RPS(showThis).slideDown();
					}
					if(RPS(this).attr('value') == "no") {
						var showThis = "#" + RPS(this).attr('title');
						RPS(showThis).slideUp();
					}
				});
				
				// Changes the fieldsets that are shown
				 RPS(".show_fieldset").click(function(e) {
					e.preventDefault();
					RPS('.shown_fieldset').removeClass('shown_fieldset');
					RPS(this).addClass('shown_fieldset');
					RPS(".current_fieldset").slideUp().removeClass('current_fieldset');
					var newfieldset = "#" + RPS(this).attr('title');
					RPS(newfieldset).slideDown().addClass('current_fieldset');
				    
				});
				
				
				
				RPS(".last_open").blur(function(e) {
					RPS('.shown_fieldset').removeClass('shown_fieldset');
					var newfieldset = "#" + RPS(this).attr('title');
					var newheader = newfieldset + "_header";
					RPS(newheader).addClass('shown_fieldset');
 					RPS(".current_fieldset").slideUp().removeClass('current_fieldset');
					RPS(newfieldset).slideDown().addClass('current_fieldset');
					var first = newfieldset + " input:first";
					RPS(first).focus();
				});
			
				
				
				// This just sets all the fieldsets in the current pane to shown, in case someone doesn't want to work with the ui
				RPS(".show_all_fieldsets").click(function(e) {
					
					e.preventDefault();
					
					title = "#" + RPS(this).attr('title') + " fieldset";
					
					RPS(title).show().addClass('current_fieldset');
				
				});
				
				
				// sums the assets classes
				RPS(".assets").blur( function() {
					var add = 0;
					
					RPS(".assets").each(function() {
						add += Number(RPS(this).val());
					});
					
					RPS("#total_assets span").text(add);
                        var assets = RPS("#total_assets span").text();
					   var liabl = RPS("#total_liabilities span").text();
					nw = assets - liabl;
					RPS("#net_worth span").text(nw);

				});
				
				
				// sums the liabilities classes
				RPS(".liabilities").blur( function() {
					var subtract = 0;
					
					RPS(".liabilities").each(function() {
						subtract += Number(RPS(this).val());
					});
					
					RPS("#total_liabilities span").text(subtract);
				    var assets = RPS("#total_assets span").text();
				    var liabl = RPS("#total_liabilities span").text();
					nw = assets - liabl;
					RPS("#net_worth span").text(nw);
					
				});
				
				// Used to add an item to a list.
				RPS(".add_one").click(function(e) {
					e.preventDefault();
					var add = RPS(this).attr('title');
					var list = "#" + add + "_list";
					var item = "." + add + "_to_add:first";
					if(RPS(this).attr('title') == 'college') {
					   newNum = RPS(".college_plus_one").attr('value');
					   newContent = '<li class="education_block hide_on_no college_to_add" style="display: list-item; "><div class="form_element_block"><label for="p_self_college" class="optional">College</label><input type="text" name="college[' + newNum + '][p_self_college]"  value=""></div><div class="form_element_block"><label for="p_self_degree" class="optional">Degree</label><input type="text" name="college[' + newNum + '][p_self_degree]"  value=""></div><div class="form_element_block"><label for="p_self_major" class="optional">Major</label><input type="text" name="college[' + newNum + '][p_self_major]"  value=""></div></li>';
					   RPS(list).append(newContent, function(){
					       RPS(newContent).hide().fadeIn();
					   });
					   ++newNum;
					   RPS(".college_plus_one").attr('value', newNum);
					}
					else {
					   RPS(item).clone().appendTo(list).hide().fadeIn();
				    }
				});
				*/
			}); // end jQuery document ready	
