/**
 * Register Module
 * @author Kevin McBriraty
 * Register dialog box
 * @dependencies
 * DialogControl
 * CookieUtil
 * Form Plugin
 */
function RegisterModule()
{
	/** name of this module */
	this._name = RegisterModule.NAME;

	this._status = false;
	this._isExternal = false;

	this._sctkn = null;
	this._scgid = null;
	this._redirect = null;
	this._gameInvitor = null;

	this._omniTracking = {
		username:false,
		email:false,
		password:false,
		dobDay:false,
		dobMonth:false,
		dobYear:false
	};

	/**
	 * called by the page during initialization
	 */
	this.initialize = function(){
		this._cont = $("#register_module");
		this._form = $("#register_dialogForm");

		this._registerDialogControl = new DialogControl("#register_module");
		this._form.submit(bindContext(this,this.submitForm));

		$("#register_loginLink").click(bindContext(this, this._loginLink));
		$("#facebookRegister .btnFacebook").click(bindContext(this, RegisterModule.hideRegister));
		$("#register_cancelRegister").click(bindContext(this, this._cancelRegisterEvent));
		$("#registration_confOk").click(bindContext(this, this._registerHideEvent));
		$("#register_dob_month,#register_dob_year").change(bindContext(this, this._changeDate));
//		$("#register_country").change(bindContext(this, this._changeCountry));
		$("#registration_resendEmailLink").click(bindContext(this, this._resendEmail));

		this._populateDOB();
//		this._populateCountry();
//		this._populateState();
	};

	this.submitForm = function(e){
		e.preventDefault();
		this._disableSubmitButton();
		this._processRegistration();
		return false;
	};

	this.register = function(args) {
		this._enableSubmitButton();
		if (args){
			if (args.headerMessage){
				this._cont.find("p.h1").html(args.headerMessage);
			}
			if (args.scoreToken){
				this._sctkn = args.scoreToken;
			}
			if (args.gameId){
				this._scgid = args.gameId;
			}
			if (args.redirect){
				this._redirect = args.redirect;
			}
		}
		if ( typeof g_page.useFacebook != 'undefined' && g_page.useFacebook ) {
			$("#facebookRegister").show();
			$("#register_module").addClass("withFacebookWide");
		}

		this._form.resetForm();

		// default the year to 12 years back
		//$("#register_dob_year option:eq(13)").attr("selected", "selected");
		
		this._resetDialog();
		this._registerDialogControl.showDialog();
		this._sendRegistrationStart();  //Omniture call
	};

	this._processRegistration = function(){
		var params={};
		if (this._sctkn){
			params.scoreToken = this._sctkn;
		}
		if (this._scgid){
			params.gameId = this._scgid;
		}
		this._clearErrors();
		this._makeRestRequest("/user/register", "POST", params, this._handleRegister, this._form);
	};

	this._resetDialog = function(){
		this._clearErrors();
		$("#register_subscribe").attr("checked","checked"); //Always default the newsletter checkbox to on
		$("#registration_conf").hide();
		$("#register_dialogForm").show();
		$("#registration_resendEmailSent").hide();
		$("#registration_resendEmail").show();
		$("#statePicker").hide();
	};
	this._clearErrors = function() {
		$("#register_errorContainer").hide().empty();
		$("#register_module .inValid").hide().empty();
		$("#introText").show();
	};

	this._cancelRegisterEvent = function(e) {
		e.preventDefault();
		this._registerHide();
		AgEvent.CANCEL_REGISTER.publish();
	}


	this._registerHideEvent = function(e){
		//bridge pattern
		e.preventDefault();
		this._registerHide();
	};

	this._registerHide = function(){
		this._registerDialogControl.hideDialog();
		if (this._redirect){
			window.location = this._redirect;
		}
	};

	this._loginLink = function(e){
		e.preventDefault();
		this._registerHide();
		var module = g_page.getModule("LoginModule");
		module.login();
	};
	this._disableSubmitButton = function(){
		$("#register_button_on").hide();
		$("#register_button_off").show();
	};
	this._enableSubmitButton = function(){
		$("#register_button_off").hide();
		$("#register_button_on").show();
	};

	this._handleFieldErrors = function(obj){
		for (var fielderror in obj){
			$("#register_"+obj[fielderror].field+"_fail").html(obj[fielderror].message).show();
			this._omniTracking[obj[fielderror].field] = true;
		}
		this._sendRegistrationFail(
				this._omniTracking.username,
				this._omniTracking.email,
				this._omniTracking.password,
				this._omniTracking.dobDay,
				this._omniTracking.dobMonth,
				this._omniTracking.dobYear
		);
	};

	this._handleGeneralErrors = function(obj){
		$("#introText").hide();
		for (var generalerror in obj){
			$("#register_errorContainer").append('<span><label class="inValid" style="display:block">'+obj[generalerror].message+'</label></span>').show();
		}
	};

	this._handleRegister = function(res){
		this._enableSubmitButton();
		if (res.returnCode == "Ok"){
			this._clearErrors();
			this._showConfirmation();
			this._sendRegistrationSuccess(); //Omniture call

			AgEvent.REGISTER.publish(res.response.uuid);

			// Log the user in and update the respective modules
			var userModule = g_page.getModule("UserInfoModule");
			var fbModule = g_page.getModule("FacebookRegisterModule");
			var loginModule = g_page.getModule("LoginModule");
			loginModule._status = LoginModule.isUserLoggedIn();
			userModule.initialize();
			userModule.updateForLoggedInUser();
			fbModule._formSubmitted = this._form;
			fbModule.initialize();
			g_page.updateForLoginChange();
		}
	};
	this._showConfirmation = function(){
		var email = $("#register_email").val();
		$("#register_dialogForm").hide();
		$("#register_module .dialogue_half_right").hide();
		$("#register_module .dialogue_half_left").addClass("dialogue_body").removeClass("dialogue_half_left");
		$("#register_module").removeClass("dialogue_flex");
		$("#registration_conf").find(".confirmEmail").html(email).end().show();
	};

	this._resendEmail = function(e){
		e.preventDefault();
		var userName = $("#register_username").val();
		if ( userName == "" ) {
			userName = $("#uimGreeting a").html();
		}
		var params = {
			"username" : userName
		};
		$("#register_errorContainer").empty();
		this._makeRestRequest("/user/resendConfirmEmail", "POST", params, this._handleResendEmail);
	};
	this._handleResendEmail = function(res){
		if (res.returnCode == "Ok"){
			this._clearErrors();
			$("#registration_resendEmail").hide();
			$("#registration_resendEmailSent").show();
		}
	};

	this._populateDOB = function(){
		// Populate the months
		$.each(RegisterModule.MONTHS, function(index, value) {
			$("#register_dob_month").addOption(index,value);
		});

		// Populate the years
		var year=Number(eval(RegisterModule.STARTYEAR));
		for (var endYear = Number(eval(RegisterModule.ENDINGYEAR)); year <= endYear ; --endYear) {
			$("#register_dob_year").addOption(endYear,endYear);
		}

		// Populate days 1-28
		for (var day=1; day<29; day++) {
			$("#register_dob_day").addOption(day,day);
		}
	};
//
//	this._populateCountry = function(){
//		$.each(RegisterModule.COUNTRIES, function(index, value) {
//			$("#register_country").addOption(value.code,value.country);
//		});
//	};
//
//	this._populateState = function(){
//		$.each(RegisterModule.STATES, function(index, value) {
//			$("#register_state").addOption(value.code,value.state);
//		});
//	};
//
//	this._changeCountry = function(){
//		if ($("#register_country").val() == "US" ){
//			$("#statePicker").show();
//		} else {
//			$("#statePicker").hide();
//			$("#register_state").val(0);
//		}
//	};

	this._changeDate = function(){
		var monthYear = new Date(this._getYear(), this._getMonth(), 1);
		var daysInMonth = this._getDaysInMonth(monthYear);
		var oldDayOfMonth = this._getDayOfMonth();

		// Reset the days in the month
		$("#register_dob_day").children(":gt(28)").remove();

		// Add days to month, if necessary
		for(var day=29; day<=daysInMonth;day++){
			$("#register_dob_day").addOption(day,day);
		}
		//  if the old day is valid in this month, select that day
		if(oldDayOfMonth > 0 && $("#register_dob_day").children().length-1 >= oldDayOfMonth){
			$("#register_dob_day").val(oldDayOfMonth).selected = true;
		}
	};

	this._getDaysInMonth = function(dateObject){
		var month = dateObject.getMonth();
		var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
		if(month == 1 && this._isLeapYear(dateObject)){ return 29; } // Number
		return days[month]; // Number
	};

	this._isLeapYear = function(dateObject){
		var year = dateObject.getFullYear();
		return !(year%400) || (!(year%4) && !!(year%100)); // Boolean
	};

	this._getYear = function() {
		return $("#register_dob_year").val();
	};

	this._getMonth = function() {
		// returns 0-based month value
		return $("#register_dob_month").val();
	};
	this._getDayOfMonth = function() {
		return $("#register_dob_day").val();
	};

	/*chainable jquery method to add an option to a dropdown*/
	$.fn.addOption = function(value,text){
		return this.each(function(){
			$(this).append($('<option></option>').val(value).html(text));
		});
	};

	/** @return list of request actions that can be handled by this module */
	this.getPageActionNames = function(){
		return [ "showRegisterPopup" ];
	};
	/** handle request action
	  * @action name of action to invoke
	  * @params bean containing request parameters
	  *
	  * */
	this.handlePageAction = function(action, params){
		if (action == "showRegisterPopup") {
			this._sctkn = $(document).getUrlParam("sctkn");
			this._scgid = $(document).getUrlParam("scgid");
			this._redirect = $(document).getUrlParam("redirect");
			this.register();
		}
	};


/***********************************
 * START omniture functions   ******
 * *********************************/
	this._resetParamsToDefault =  function(){
		  try {
			if(com.mtvi.util.isDefined(dispatcher)){
				com.mtvi.reporting.Account={
					name:'viaaddictinggames',
					dynamicAccountSelection:true,
					dynamicAccountList:'viaaddictinggamesdev=dev.addictinggames.com',
					linkInternalFilters:'javascript:,addictinggames.com',
					trackExternalLinks: true,
					trackDownloadLinks: true
				};
				dispatcher.setAttribute("pageName", "/"+channel+pageName);
				dispatcher.setAttribute("channel", channel+pageName);
				dispatcher.setAttribute("hier2", hier2);
			}
		} catch(e){}
	};
	this._omniSetOverrides= function (or,acctNameAction){
		try{
			this._resetParamsToDefault();
			var ro = {};
			for(i in or){
				var tmpi=i.replace(/s_/,"");
				tmpi=(tmpi=="account")? "name" : tmpi;
				ro[tmpi]=or[i];

				if(tmpi=="name"){
					if(acctNameAction){
						if(acctNameAction=="append"){
							var pattern = new RegExp("^"+ro[tmpi]+"$|^"+ro[tmpi]+",|,"+ro[tmpi]+"$|,"+ro[tmpi]+",");
							if(!pattern.test(com.mtvi.reporting.Account.name))
								com.mtvi.reporting.Account.name += ',' + ro[tmpi];
						}else if(acctNameAction=="overwrite")
							com.mtvi.reporting.Account.name = ro[tmpi];
					}
					ro[tmpi]= com.mtvi.reporting.Account.name;
				}
			}
			ro.dynamicAccountSelection = true;
			ro.linkInternalFilters = 'javascript:,addictinggames.com';
			ro.trackExternalLinks = true;
			ro.trackDownloadLinks = true;
			if(com.mtvi.util.isDefined(dispatcher)) dispatcher.setAccountVars(ro);
		}catch(e){}
	};
	//this function should be called when the registration layer opens
	this._sendRegistrationStart=function(){
		try{
			this._omniSetOverrides({name:"viaagregistration",pageName:"Registration: Start"},"overwrite");
			dispatcher.sendCall();
		}catch(e){}
	};
	//this function should be called when a registration is validated and completed
	this._sendRegistrationSuccess =function(){
		try{
			this._omniSetOverrides({name:"viaagregistration",pageName:"Registration: Success"},"overwrite");
			dispatcher.sendCall();
		}catch(e){}
	};
	//this function should be called when a registration is validated and failed
	this._sendRegistrationFail = function(userName,email,password,birthDay,birthMonth,birthYear){
		try{
			var propStr="";
			if(userName)propStr+="userName,";
			if(email)propStr+="email,";
			if(password)propStr+="password,";
			if(birthDay)propStr+="birthDay,";
			if(birthMonth)propStr+="birthMonth,";
			if(birthYear)propStr+="birthYear,";
			if (propStr){
				this._omniSetOverrides({name:"viaagregistration",pageName:"Registration: Fail",prop1:propStr},"overwrite");
				dispatcher.sendCall();
			}
		}catch(e){}
	};
/***********************************
 * END omniture functions   ******
 * *********************************/
};
RegisterModule.NAME = "RegisterModule";

RegisterModule.prototype = new Module();
RegisterModule.showRegister = function(args){
	var module = g_page.getModule("RegisterModule");
	module.register(args);
};
RegisterModule.hideRegister = function(){
	this._registerDialogControl.hideDialog();
	// For IE
    if ( ! jQuery.support.opacity ) {
		com.ag.loginFB.facebookConnect();
    }
};


RegisterModule.MONTHS =[
	"January", "February", "March", "April", "May", "June", "July", "August",
	"September", "October", "November", "December"]	;
RegisterModule.STARTYEAR = "1900";
RegisterModule.ENDINGYEAR = new Date().getFullYear();
RegisterModule.COUNTRIES= [
		{code:"US", country:"United States"},
		{code:"CA", country:"Canada"},
		{code:"UK", country:"United Kingdom"},
		{code:"AU", country:"Australia"},
		{code:"-",  country:"--------"},
		{code:"AF", country:"Afghanistan"},
		{code:"AL", country:"Albania"},
		{code:"DZ", country:"Algeria"},
		{code:"AS", country:"American Samoa"},
		{code:"AD", country:"Andorra"},
		{code:"AO", country:"Angola"},
		{code:"AI", country:"Anguilla"},
		{code:"AQ", country:"Antarctica"},
		{code:"AG", country:"Antigua and Barbuda"},
		{code:"AR", country:"Argentina"},
		{code:"AM", country:"Armenia"},
		{code:"AW", country:"Aruba"},
		{code:"AT", country:"Austria"},
		{code:"AZ", country:"Azerbaidjan"},
		{code:"BS", country:"Bahamas"},
		{code:"BH", country:"Bahrain"},
		{code:"BD", country:"Bangladesh"},
		{code:"BB", country:"Barbados"},
		{code:"BE", country:"Belgium"},
		{code:"BZ", country:"Belize"},
		{code:"BJ", country:"Benin"},
		{code:"BM", country:"Bermuda"},
		{code:"BT", country:"Bhutan"},
		{code:"BO", country:"Bolivia"},
		{code:"BA", country:"Bosnia-Herzegovina"},
		{code:"BW", country:"Botswana"},
		{code:"BV", country:"Bouvet Island"},
		{code:"BR", country:"Brazil"},
		{code:"IO", country:"British Indian Ocean Territory"},
		{code:"BN", country:"Brunei Darussalam"},
		{code:"BG", country:"Bulgaria"},
		{code:"BF", country:"Burkina Faso"},
		{code:"BI", country:"Burundi"},
		{code:"KH", country:"Cambodia"},
		{code:"CM", country:"Cameroon"},
		{code:"CV", country:"Cape Verde"},
		{code:"KY", country:"Cayman Islands"},
		{code:"CF", country:"Central African Republic"},
		{code:"TD", country:"Chad"},
		{code:"CL", country:"Chile"},
		{code:"CN", country:"China"},
		{code:"CX", country:"Christmas Island"},
		{code:"CC", country:"Cocos (Keeling) Islands"},
		{code:"CO", country:"Colombia"},
		{code:"KM", country:"Comoros"},
		{code:"CK", country:"Cook Islands"},
		{code:"CR", country:"Costa Rica"},
		{code:"HR", country:"Croatia"},
		{code:"CY", country:"Cyprus"},
		{code:"CZ", country:"Czech Republic"},
		{code:"DK", country:"Denmark"},
		{code:"DJ", country:"Djibouti"},
		{code:"DM", country:"Dominica"},
		{code:"DO", country:"Dominican Republic"},
		{code:"TP", country:"East Timor"},
		{code:"EC", country:"Ecuador"},
		{code:"EG", country:"Egypt"},
		{code:"SV", country:"El Salvador"},
		{code:"GQ", country:"Equatorial Guinea"},
		{code:"ER", country:"Eritrea"},
		{code:"EE", country:"Estonia"},
		{code:"ET", country:"Ethiopia"},
		{code:"FK", country:"Falkland Islands"},
		{code:"FO", country:"Faroe Islands"},
		{code:"FJ", country:"Fiji"},
		{code:"FI", country:"Finland"},
		{code:"CS", country:"Former Czechoslovakia"},
		{code:"FR", country:"France"},
		{code:"FX", country:"France (European Territory)"},
		{code:"GF", country:"French Guyana"},
		{code:"TF", country:"French Southern Territories"},
		{code:"GA", country:"Gabon"},
		{code:"GM", country:"Gambia"},
		{code:"GE", country:"Georgia"},
		{code:"DE", country:"Germany"},
		{code:"GH", country:"Ghana"},
		{code:"GI", country:"Gibraltar"},
		{code:"GR", country:"Greece"},
		{code:"GL", country:"Greenland"},
		{code:"GD", country:"Grenada"},
		{code:"GP", country:"Guadeloupe (French)"},
		{code:"GU", country:"Guam (USA)"},
		{code:"GT", country:"Guatemala"},
		{code:"GN", country:"Guinea"},
		{code:"GW", country:"Guinea Bissau"},
		{code:"GY", country:"Guyana"},
		{code:"HT", country:"Haiti"},
		{code:"VA", country:"Holy See (Vatican City State)"},
		{code:"HN", country:"Honduras"},
		{code:"HK", country:"Hong Kong"},
		{code:"HU", country:"Hungary"},
		{code:"IS", country:"Iceland"},
		{code:"IN", country:"India"},
		{code:"ID", country:"Indonesia"},
		{code:"IE", country:"Ireland"},
		{code:"IL", country:"Israel"},
		{code:"IT", country:"Italy"},
		{code:"JM", country:"Jamaica"},
		{code:"JP", country:"Japan"},
		{code:"JO", country:"Jordan"},
		{code:"KZ", country:"Kazakhstan"},
		{code:"KE", country:"Kenya"},
		{code:"KI", country:"Kiribati"},
		{code:"KW", country:"Kuwait"},
		{code:"KG", country:"Kyrgyz Republic (Kyrgyzstan)"},
		{code:"LA", country:"Laos"},
		{code:"LV", country:"Latvia"},
		{code:"LB", country:"Lebanon"},
		{code:"LS", country:"Lesotho"},
		{code:"LY", country:"Libya"},
		{code:"LI", country:"Liechtenstein"},
		{code:"LT", country:"Lithuania"},
		{code:"LU", country:"Luxembourg"},
		{code:"MO", country:"Macau"},
		{code:"MK", country:"Macedonia"},
		{code:"MG", country:"Madagascar"},
		{code:"MW", country:"Malawi"},
		{code:"MY", country:"Malaysia"},
		{code:"MV", country:"Maldives"},
		{code:"ML", country:"Mali"},
		{code:"MT", country:"Malta"},
		{code:"MH", country:"Marshall Islands"},
		{code:"MQ", country:"Martinique (French)"},
		{code:"MR", country:"Mauritania"},
		{code:"MU", country:"Mauritius"},
		{code:"YT", country:"Mayotte"},
		{code:"MX", country:"Mexico"},
		{code:"FM", country:"Micronesia"},
		{code:"MD", country:"Moldavia"},
		{code:"MC", country:"Monaco"},
		{code:"MN", country:"Mongolia"},
		{code:"MS", country:"Montserrat"},
		{code:"MA", country:"Morocco"},
		{code:"MZ", country:"Mozambique"},
		{code:"NA", country:"Namibia"},
		{code:"NR", country:"Nauru"},
		{code:"NP", country:"Nepal"},
		{code:"NL", country:"Netherlands"},
		{code:"AN", country:"Netherlands Antilles"},
		{code:"NT", country:"Neutral Zone"},
		{code:"NC", country:"New Caledonia (French)"},
		{code:"NZ", country:"New Zealand"},
		{code:"NI", country:"Nicaragua"},
		{code:"NE", country:"Niger"},
		{code:"NG", country:"Nigeria"},
		{code:"NU", country:"Niue"},
		{code:"NF", country:"Norfolk Island"},
		{code:"MP", country:"Northern Mariana Islands"},
		{code:"NO", country:"Norway"},
		{code:"OM", country:"Oman"},
		{code:"PK", country:"Pakistan"},
		{code:"PW", country:"Palau"},
		{code:"PA", country:"Panama"},
		{code:"PG", country:"Papua New Guinea"},
		{code:"PY", country:"Paraguay"},
		{code:"PE", country:"Peru"},
		{code:"PH", country:"Philippines"},
		{code:"PN", country:"Pitcairn Island"},
		{code:"PL", country:"Poland"},
		{code:"PF", country:"Polynesia (French)"},
		{code:"PT", country:"Portugal"},
		{code:"PR", country:"Puerto Rico"},
		{code:"QA", country:"Qatar"},
		{code:"RE", country:"Reunion (French)"},
		{code:"RO", country:"Romania"},
		{code:"RU", country:"Russian Federation"},
		{code:"RW", country:"Rwanda"},
		{code:"GS", country:"S. Georgia & S. Sandwich Isls."},
		{code:"SH", country:"Saint Helena"},
		{code:"KN", country:"Saint Kitts & Nevis Anguilla"},
		{code:"LC", country:"Saint Lucia"},
		{code:"PM", country:"Saint Pierre and Miquelon"},
		{code:"ST", country:"Saint Tome (Sao Tome) and Principe"},
		{code:"VC", country:"Saint Vincent & Grenadines"},
		{code:"WS", country:"Samoa"},
		{code:"SM", country:"San Marino"},
		{code:"SA", country:"Saudi Arabia"},
		{code:"SN", country:"Senegal"},
		{code:"SC", country:"Seychelles"},
		{code:"SG", country:"Singapore"},
		{code:"SK", country:"Slovak Republic"},
		{code:"SI", country:"Slovenia"},
		{code:"SB", country:"Solomon Islands"},
		{code:"SO", country:"Somalia"},
		{code:"ZA", country:"South Africa"},
		{code:"KR", country:"South Korea"},
		{code:"ES", country:"Spain"},
		{code:"LK", country:"Sri Lanka"},
		{code:"SR", country:"Suriname"},
		{code:"SJ", country:"Svalbard and Jan Mayen Islands"},
		{code:"SZ", country:"Swaziland"},
		{code:"SE", country:"Sweden"},
		{code:"CH", country:"Switzerland"},
		{code:"TJ", country:"Tadjikistan"},
		{code:"TW", country:"Taiwan"},
		{code:"TZ", country:"Tanzania"},
		{code:"TH", country:"Thailand"},
		{code:"TG", country:"Togo"},
		{code:"TK", country:"Tokelau"},
		{code:"TO", country:"Tonga"},
		{code:"TT", country:"Trinidad and Tobago"},
		{code:"TN", country:"Tunisia"},
		{code:"TR", country:"Turkey"},
		{code:"TM", country:"Turkmenistan"},
		{code:"TC", country:"Turks and Caicos Islands"},
		{code:"TV", country:"Tuvalu"},
		{code:"UG", country:"Uganda"},
		{code:"UA", country:"Ukraine"},
		{code:"AE", country:"United Arab Emirates"},
		{code:"UY", country:"Uruguay"},
		{code:"UM", country:"USA Minor Outlying Islands"},
		{code:"UZ", country:"Uzbekistan"},
		{code:"VU", country:"Vanuatu"},
		{code:"VE", country:"Venezuela"},
		{code:"VN", country:"Vietnam"},
		{code:"VG", country:"Virgin Islands (British)"},
		{code:"VI", country:"Virgin Islands (USA)"},
		{code:"WF", country:"Wallis and Futuna Islands"},
		{code:"EH", country:"Western Sahara"},
		{code:"YE", country:"Yemen"},
		{code:"YU", country:"Yugoslavia"},
		{code:"ZR", country:"Zaire"},
		{code:"ZM", country:"Zambia"}];
RegisterModule.STATES= [
	{code:"AL", state:"Alabama"},
	{code:"AK", state:"Alaska"},
	{code:"AZ", state:"Arizona"},
	{code:"AR", state:"Arkansas"},
	{code:"CA", state:"California"},
	{code:"CO", state:"Colorado"},
	{code:"CT", state:"Connecticut"},
	{code:"DE", state:"Delaware"},
	{code:"DC", state:"District of Columbia"},
	{code:"FL", state:"Florida"},
	{code:"GA", state:"Georgia"},
	{code:"HI", state:"Hawaii"},
	{code:"ID", state:"Idaho"},
	{code:"IL", state:"Illinois"},
	{code:"IN", state:"Indiana"},
	{code:"IA", state:"Iowa"},
	{code:"KS", state:"Kansas"},
	{code:"KY", state:"Kentucky"},
	{code:"LA", state:"Louisiana"},
	{code:"ME", state:"Maine"},
	{code:"MD", state:"Maryland"},
	{code:"MA", state:"Massachusetts"},
	{code:"MI", state:"Michigan"},
	{code:"MN", state:"Minnesota"},
	{code:"MS", state:"Mississippi"},
	{code:"MO", state:"Missouri"},
	{code:"MT", state:"Montana"},
	{code:"NE", state:"Nebraska"},
	{code:"NV", state:"Nevada"},
	{code:"NH", state:"New Hampshire"},
	{code:"NJ", state:"New Jersey"},
	{code:"NM", state:"New Mexico"},
	{code:"NY", state:"New York"},
	{code:"NC", state:"North Carolina"},
	{code:"ND", state:"North Dakota"},
	{code:"OH", state:"Ohio"},
	{code:"OK", state:"Oklahoma"},
	{code:"OR", state:"Oregon"},
	{code:"PA", state:"Pennsylvania"},
	{code:"RI", state:"Rhode Island"},
	{code:"SC", state:"South Carolina"},
	{code:"SD", state:"South Dakota"},
	{code:"TN", state:"Tennessee"},
	{code:"TX", state:"Texas"},
	{code:"UT", state:"Utah"},
	{code:"VT", state:"Vermont"},
	{code:"VA", state:"Virginia"},
	{code:"WA", state:"Washington"},
	{code:"WV", state:"West Virginia"},
	{code:"WI", state:"Wisconsin"},
	{code:"WY", state:"Wyoming"}];
