		var param_names = [
			["lsource", "00N60000001j6Di"],
			["mgmtsys", "00N60000001LDyq"],
			["industry", "industry"],
			["city", "city"],
			["state", "state"],
			["zcode", "zip"],
		];
		
		var hidden_names = [
			["ldetail", "00N60000001j6Dr"],
			["bcode", "00N60000001j6DN"],
		];
		
		/*******************************************/
		/* ADD MORE CHOICES FOR EACH INDUSTRY HERE */
		/*******************************************/
		var mgmt_sys_choices = {
			"Automotive" : [
					
					"--Please Select One--",
					"AllData",
					"AutoShop Wiz",
					"Garage Operator",
					"Invomax",
					"MaxxTraxx Pro CE",
					"Mitchell",
					"MOTOR Shop Director",
					"Napa Tracs",
					"PACE/YES",
					"PCA Autogenius",
					"ProfitBoost",
					"Protractor Standard Edition",
					"RO Writer",	
					"Service 2000",
					"Shop Controller",
					"Triad Service Writer",
					"Winworks",
					"Wrenchead",
					"Other"
					
				],
			"Dental" : [
					"--Please Select One--",
					"ABELDent",
					"ACE",
					"Autopia",
					"Computer Age",
					"Data Con",
					"Dental Mac",
					"Dental Mate",
					"Dental Vision",
					"Dentech",
					"Dentrix",
					"Dentrix Enterprise",
					"Eaglesoft",
					"Easy Dental",
					"iDental",
					"LiveDDM",
					"MacPractice",
					"Maxident",
					"Mogo",
					"Open Dental",
					"Paradigm",
					"Patient base",
					"Power Practice",
					"Practice X",
					"Practice-Web",
					"Practiceworks",
					"QSI",
					"Softdent",
					"Tracker",
					"Windent",
					"Other"
				],
			"Chiropractic" : [
					"--Please Select One--",
					"3dRx - 3dRx Chiro",
					"AcuBase Pro - Trigram Software",
					"AltaPoint - Med Experts",
					"AMS Software - AMS",
					"Anywhere MD - Auto-DOC",
					"AppointmentsPRO - SpectraSoft",
					"AS/PC - DB Consultants",
					"Atlas Systems",
					"Autumn8 - TgiSoftware",
					"Centricity - GE",
					"Chiro 7000 - Forte Systems",
					"Chiro8000 by Forte Systems",
					"Chiroglyphix - Forte Holdings",
					"ChiroOffice/ChiroSuite - Life Systems",
					"Chiropractic Advantage - Compulink",
					"Chiropractical - InfosysMC",
					"ChiroPractice - BR Online Solutions",
					"ChiroPractice Pro - Eldridge Enterprise Solutions",
					"ChiropracticSOFT - Get Physical! Software",
					"ChiroPulse365 - Pulse Software",
					"ChiroSoft - Forte Systems",
					"ChiroTouch",
					"Clinic Pro Chiropractic",
					"CollaborateMD",
					"DC-PowerNotes - ClaKen Software",
					"Eclipse - MPN Software Systems",
					"EMR4 - EMR4doctors",
					"EMR Datacenter - Software Motif",
					"E-nate - E-nate Integrated Services",
					"eThomas - Genius Solutions",
					"E-Z BIS",
					"EZnotes",
					"For Chiropractors Only - Versatile Software Systems",
					"Future Health- eConnect",
					"Future Health - VOS",
					"G2 Software Solutions - Greycat",
					"Go Home at Five - BestNotes",
					"Guardian EMR",
					"HandyWorks - Chapter 1 Software",
					"Health Highway",
					"Herfert Chiropractic Software",
					"Latis - Eurosmart",
					"Lytec",
					"MacEssentials - AccountMaster Chiropractic",
					"MacPractice DC",
					"Medical Mastermind - Software Unlimited",
					"MediFusion",
					"Medisoft - McKesson",
					"Meditab - Intelligent Medical Software",
					"Midwest Software - Chiro QuickCharts",
					"MPMsoft",
					"OfficeAlly - Practice Mate",
					"OfficeMate",
					"Open PM - Open Practice Solutions",
					"Platinum System",
					"Practice Automation - H3K",
					"PracticeFusion",
					"Practice Made Perfect (PMP) - K & K Systems",
					"Practice Studio",
					"Q'Notes - Quick Notes",
					"Quickbooks - Intuit",
					"Quixote Software",
					"Rapid - Acom Health",
					"Red Pine - Chiropractic Business Services",
					"Satori Chiropractic Software - Satori",
					"SilkOne",
					"Sunrise Solutions",
					"Therapy Rehab Plus - Raintree Systems",
					"TM2 Practice Management",
					"TPS (The Practice Solution) - EON Systems",
					"Universal Office - Antibex",
					"Vericle - Billing Precision",
					"Wonder Doc",
					"Write Pad - Addison Health Systems",
					"Other"
				],
			"Spa" : [
					"--Please Select One--",
					"Appointments Plus"
					"BeautyTrack",
					"Book4Time",
					"ClienTrak",
					"Elite",
					"Emisoft",
					"Ennoview",
					"Korvue",
					"Millennium",
					"mSpa",
					"Orchid",
					"Priverus",
					"Shortcuts",
					"SpaBiz",
					"SpaBooker",
					"SpaSoft",
					"Other"
				],
			"Salon" : [
					"--Please Select One--",
					"Appointments Plus"
					"BeautyTrack",
					"Book4Time",
					"ClienTrak",
					"Elite Salon",
					"Emisoft",
					"Ennoview",
					"Hairmax",
					"Korvue",
					"Merlin",
					"Millennium",
					"Mindbody",
					"Priverus",
					"SalonBiz",
					"SalonIris",
					"Salon Transcripts",
					"Other"
				],
			"Med Spa" : [
					"--Please Select One--",
					"Appointments Plus"
					"Book4Time",
					"ClienTrak",
					"Emisoft",
					"Kareo",
					"Medisoft",
					"mSpa",
					"NexTech",
					"Orchid",
					"Rosy",
					"Other"
				],
			"Medical" : [
					"--Please Select One--",
					"Alta Point",
					"Lytec",
					"Micro MD",
					"miSys/All Scripts",
					"NexGen",
					"Other"
				],
			"Optometry" : [
					"--Please Select One--",
					"AltaPoint",
					"Compulink",
					"Crystal",
					"EasyFrame",
					"EyeCom3",
					"First Insight Corp",
					"GOAL",
					"iFile",
					"MaximEyes",
					"Misys/Allscripts",
					"Misys Tiger- Allscripts",
					"Mountain",
					"MyVisionExpress",
					"OD Professional",
					"OfficeMate",
					"OfficeMate Enterprise",
					"OfficeMate RLIsys",
					"Opti-Schedule - QSAccess",
					"Optivision",
					"Opto",
					"Practice Director",
					"RevolutionEHR",
					"Other"
				],
			"Orthodontist" : [
					"--Please Select One--",
					"Dolphin",
					"Orthoease",
					"Orthotrac",
					"Ortho II",
					"Other"
				],
			"Veterinary" : [
					"--Please Select One--",
					"AVIMark",
					"Cornerstone",
					"DVManager",
					"Idexx",
					"Other"
				],
			"Other" : [
					"Other"
				],
	
			"--Please Select One--" : [
					"--Please Select an Industry--"
				]		
		}
		
		/* Modifies form elements to hide those that are specified in url */
		function createForm() {
			// Deal with visible values
			for (var param_idx in param_names) {
				var param_code = param_names[param_idx][0];
				var param_id = param_names[param_idx][1];
				
				//$("#result").append(param_code + "<br/>");
				
				if ( (param = gup(param_code)) != "") {
					//$("#result").append(param_code + " = " + param + "<br/>");
					if (param_code=="industry") {
						if(param == "Optometry and Ophthalmology"){
							param =	"Optometry";
						}
						updateMgmtSystems(param);
					}
					
					if (param_code=="state" ||
						param_code=="mgmtsys" ||
						param_code=="industry" ||
						param_code=="city" ||
						param_code=="lsource"
					) {
						// Don't show certain rows if specified in the URL
						$("#row_"+param_code).remove();
						$("#contactForm").append(
							"<input name=\""+param_id+"\" id=\""+param_id+
							"\" type=\"hidden\" value=\""+param+"\" />");
					} else {
						$("#cell_"+param_code).replaceWith(
							"<input name=\""+param_id+"\" name=\""+param_id+
							"\" type=\"hidden\" value=\""+param+"\" />"+param);
					}
				} 
			}
			
			// Deal with hidden values
			for (var param_idx in hidden_names) {
				var param_code = hidden_names[param_idx][0];
				var param_id = hidden_names[param_idx][1];
				
				if ( (param = gup(param_code)) != "") {
					$("#"+param_id).attr("value", param);
				} 
			}
			
			// When Industry choice is changed, change the Management System choices
			$("#industry").change(function(e) {
			
				var industry = $("#industry").val();
				updateMgmtSystems(industry);
				
			});
		}
		
		function updateMgmtSystems(industry_name) {
			
				//alert(industry_name);
			
				// Clear current select options
				$("#mgmt_system").find("option").remove();
				
				// Fill in new ones
				var choices = mgmt_sys_choices[industry_name];
				for (var i in choices) {
					$("#mgmt_system").append("<option value=\"" + choices[i] + "\">" + choices[i] + "<\/option>");
				}
		}
		
		/* Function grabs param called "name" from the url */
		function gup( name )
		{
		  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		  var regexS = "[\\?&]"+name+"=([^&#]*)";
		  var regex = new RegExp( regexS );
		  var results = regex.exec( window.location.href );
		  if( results == null )
			return "";
		  else {
		  	var result = results[1];
		  	result = result.replace(/%20/g, " ");
			return result;
		  }
		}
		
		/*
		 *  OnLoad Function
		 */
		$(function() {
			createForm();
			changeComment();
		});
	
		function changeComment(){
			var generalCom = "Or fill out the form and someone will contact you.";
			var dentalCom = "Or fill out the form and someone will contact you.";
			var autoCom = "Or fill out the form and someone will contact you.";

			var url = window.location.href;
		
			if(url.indexOf("Dental")!=-1){
				$("#contactComment").text(dentalCom);
				
				}
			else if(url.indexOf("Auto")!=-1){
				$("#contactComment").text(autoCom);
				}
			else{
				$("#contactComment").text(generalCom);
			};	
			
		}
		

