// ____________________________________________________________________________
//	Plan Dropdown Generator v1.0 (for Universal American)
//
//	Author: Scott C. Ziegler, Innova Partners - 09/17/2008
//
//	Innova Partners - http://innova-partners.com
// ____________________________________________________________________________

//	function mapStateToFile(stateName) 
//	- returns a relative path to the individual PDF files according to the 
//		state name
function mapStateToFile(stateName)
{
	return pdfRoot + fileMap[stateMap[stateName]];
}

//	deprecated: used when options are present in the source
// function decorateStatePulldown(pulldownId)
// {
// 	var options = $('#' + pulldownId + " option");
// 	$.each(options, function()
// 	{
// 		$(this).attr('value', mapStateToFile($(this).html()));
// 	});
// }

//	currently in use: creates option tags in the targeted select tag
//		(uses the stateMap to construct the options)
function createStatePulldown(pulldownId)
{
	//	get the select tag by id as a jQuery object.
	var select = jQuery('#' + pulldownId);
	
	//	add a 'dummy placeholder' option...
	select.append('<option selected>Select your state</option>');
	
	// for each item in the stateMap,
	jQuery.each(stateMap, function(key, val)
	{
		//	...build an option tag with the state name, whose value points
		//		to the appropriate PDF file for that state.
		select.append('<option value="' + mapStateToFile(key) + '">' 
			+ key + '</option>');
	});
}

//	This line removes jQuery's overloading of the '$' symbol
jQuery.noConflict();

//	This will create option tags in the pulldown with id 'state_pd'
//	The option tags are generated from the stateMap variable.
//	It will be called on the document's onReady event.
//	Note: it is wrapped in a function that allows use of jQuery's $ binding.

(function ($) {
	$(document).ready(function()
	{
		createStatePulldown('state_pd');
	});
})(jQuery);
