jQuery(document).ready(function(){
	jQuery('.contact-tab').click(function(){
		var selected_tab = jQuery(this);
		if (selected_tab.hasClass("ct1")) {
			var open_tab = "#contact-tab-content-inner-1";
			if (jQuery(open_tab).is(":visible")) {
				jQuery('.ct1').removeClass("open");
				jQuery(open_tab).slideUp('slow');
			} else {
				jQuery('.ct1').addClass("open");
				jQuery(open_tab).slideDown('slow');
			}
		} else if (selected_tab.hasClass("ct2")) {
			var open_tab = "#contact-tab-content-inner-2";
			if (jQuery(open_tab).is(":visible")) {
				jQuery('.ct2').removeClass("open");
				jQuery(open_tab).slideUp('slow');
			} else {
				jQuery('.ct2').addClass("open");
				jQuery(open_tab).slideDown('slow');
			}
		} else {
			var open_tab = "#contact-tab-content-inner-3";
			if (jQuery(open_tab).is(":visible")) {
				jQuery('.ct3').removeClass("open");
				jQuery(open_tab).slideUp('slow');
			} else {
				jQuery('.ct3').addClass("open");
				jQuery(open_tab).slideDown('slow');
			}
		}
	});
	/* Functionality for the old form
	jQuery('.add-to-request').click(function() {
		var this_section = jQuery(this).parent().siblings('h3').text();
		var current_message = jQuery('textarea.contact-form-input-area').val();
		if (this_section == "Items:") {
			this_section = "\nOrder Supplies:\n"+ this_section;
		} else {
			this_section = "\nRequest a Retrieval:\n" + this_section;
		}
		jQuery('textarea.contact-form-input-area').val(current_message +"\r\n"+ this_section +"\n");
		if (jQuery(this).parent('p').hasClass('request')) {
			if (jQuery(this).parent('p.request').siblings('p.request')) {
				jQuery(this).parent('p.request').siblings('p.request').each(function() {
					jQuery(this).children('label').each(function() {
						var this_label = jQuery(this).text();
						var this_field = jQuery(this).children('span').children('input').val();
						jQuery(this).children('span').children('input').val("");
						this_field = this_field == "" ? "N/A" : this_field;
						var current_message = jQuery('textarea.contact-form-input-area').val();
						jQuery('textarea.contact-form-input-area').val(current_message + this_label +" "+ this_field +"\n");
					});
				});
				jQuery(this).parent('p.request').each(function() {
					jQuery(this).children('label').each(function() {
						var this_label = jQuery(this).text();
						var this_field = jQuery(this).children('span').children('input').val();
						jQuery(this).children('span').children('input').val("");
						this_field = this_field == "" ? "N/A" : this_field;
						var current_message = jQuery('textarea.contact-form-input-area').val();
						jQuery('textarea.contact-form-input-area').val(current_message + this_label +" "+ this_field +"\n");
					});
				});
			} else {
				jQuery(this).parent('p.request').each(function() {
					jQuery(this).children('label').each(function() {
						var this_label = jQuery(this).text();
						var this_field = jQuery(this).children('span').children('input').val();
						jQuery(this).children('span').children('input').val("");
						this_field = this_field == "" ? "N/A" : this_field;
						var current_message = jQuery('textarea.contact-form-input-area').val();
						jQuery('textarea.contact-form-input-area').val(current_message + this_label +" "+ this_field +"\n");
					});
				});
			}
		} else {
			jQuery(this).parent().siblings('p.supplies').each(function() {
				var this_label = jQuery(this).children('label:first-child').text();
				var this_field = jQuery(this).children('span').children('span').children('span').children('input[checked]').val();
				if (this_field == undefined && (this_label == "BARCODE:" || this_label == "SHREDDING STACKS:")) {
					this_field = "Not Required";
				}
				if (this_field === "Other") {
					var this_field_other = jQuery(this).children('span').children(':input[type="text"]').val();
					jQuery(this).children('span').children(':input[type="text"]').val("");
					this_field_other = this_field_other == "" ? "N/A" : this_field_other;
					this_field += ": "+ this_field_other;
				}
				var current_message = jQuery('textarea.contact-form-input-area').val();
				jQuery('textarea.contact-form-input-area').val(current_message + this_label +" "+ this_field +"\n");
			});
		}
	});*/
	var auto_open_tab = window.location.hash;
	if (auto_open_tab) {
		switch(auto_open_tab) {
			case "#request-a-retrieval":
				jQuery('.ct1:eq(0)').click();
			break;
			case "#arrange-a-collection":
				jQuery('.ct2:eq(0)').click();
			break;
			case "#order-supplies":
				jQuery('.ct3:eq(0)').click();
			break;
			default:
		}
	}
});
