(function($) {
		  
	$.fn.cruisewidget = function(options) {
		
		options = $.extend({ title: null, search_types: [["cruise","Cruise","Search for Cruises",[/*more options*/"true"]]], grad:"true"}, options || {});
		
		this.empty();
		var div = this;
		var numCabins = 7;
		var cruiseDestsDefault = '<option value="">Any Destination</option>';
		var cruiseLinesDefault = '<option value="">All vendors</option>';
		var cruiseMonthDefault = '<option value="">Select Month</option>';
		
		// CREATE SEARCH WIDGET CONTAINER DIV
		this.html("<div id=\"cruise_widget\"></div>");
		
		var wrapper = "<div class=\"margin\"><div class=\"wrapper\"></div></div>";
		
		$('#'+this.attr("id")+' #cruise_widget').html(wrapper);
		
		if (options.title) {
			$('#'+this.attr("id")+' #cruise_widget #forms').append("<h2>"+options.title+"</h2>");
		}
		
		if ($('#'+this.attr("id")+' #cruise_widget').outerWidth() <= 800 && $('#'+this.attr("id")+' #cruise_widget').outerWidth() > 510) {
			$('#'+this.attr("id")+' #cruise_widget').attr("class","seach_widget_large");
		} else if ($('#'+this.attr("id")+' #cruise_widget').outerWidth() <= 510 && $('#'+this.attr("id")+' #cruise_widget').outerWidth() > 330) {
			$('#'+this.attr("id")+' #cruise_widget').attr("class","seach_widget_medium");
		} else if ($('#'+this.attr("id")+' #cruise_widget').outerWidth() <= 330) {
			$('#'+this.attr("id")+' #cruise_widget').attr("class","seach_widget_small");
		}
		
		// START FORM TAG
		$('#cruise_widget .wrapper').append("<div id=\"forms\"></div>"); //NEED TO UPDATE WITH REAL PATH & ACTION
		
		// PRODUCT SEARCH PANEL
		for (x in options.search_types) {
				// CREATE SEARCH PANEL DIV
				$('#'+this.attr("id")+' #cruise_widget #forms').append("<div id=\"search_"+options.search_types[x][0]+"\" class=\"search_type\"></div>");
				// SEARCH TITLE
				if (options.search_types[x][2] != "" && options.search_types[x][2] != null) {
					//$('#'+this.attr("id")+' #search_'+options.search_types[x][0]).append("<h4>"+options.search_types[x][2]+"</h4>");
				}
				// SEARCH FIELDS	
				$('#'+this.attr("id")+' #search_'+options.search_types[x][0]).append(eval(options.search_types[x][0]+"Html"));
				
				$('#'+this.attr("id")+' .more_rooms_link .num_rooms').text(numCabins+1);
		
				// CRUISE MORE OPTIONS
				if (options.search_types[x][0] == "cruise" && options.search_types[x][3][0] == "false") $('#'+this.attr("id")+' #search_'+options.search_types[x][0]+' .more_search').remove();
				
				
				if (options.search_types[x][0] == "cruise") { 
					cityId = "destination"; 
					citiesId = "geographicRegion";
					var city = cruiseDests;
				}
				// POPULATE CITY FIELD IF USER SPECIFIED
				if (options.city) { var city = options.city; }
				if (city) { 
					$('#'+this.attr("id")+' #search_'+options.search_types[x][0]+' .to .field').append('<select name="'+citiesId+'" id="'+citiesId+'" onchange="changeMapping(this.form)">'+cruiseDestsDefault+destSelectList+'</select>');
				}
				
				// CITY FIELD
				if (options.city_fields == "false") $('#'+this.attr("id")+' #search_'+options.search_types[x][0]+' .to').remove();
				
				if (options.search_types[x][0] == "cruise") { 
					//CRUISE LENGTH
					$('#'+this.attr("id")+' #search_'+options.search_types[x][0]+' .length .field').append('<select name="cruiseLength" id="cruiseLength"></select>');
					for (y in cruiseLengths) {
						$('#'+this.attr("id")+' #search_'+options.search_types[x][0]+' .length select').append('<option value="'+cruiseLengths[y][0]+'">'+cruiseLengths[y][1]+'</option>');
					}
					//CRUISE MONTHS
					$('#'+this.attr("id")+' #search_'+options.search_types[x][0]+' .time_depart .field').append('<select name="fromMonthYear" id="fromMonthYear">'+cruiseMonthDefault+monthSelectList+'</select>');

					//CRUISE LINES
					$('#'+this.attr("id")+' #search_'+options.search_types[x][0]+' .line .field').append('<select name="cruiseVendor" id="cruiseVendor"></select>');

				}
			}
			
		if (options.grad == "true") {
			$('#'+this.attr("id")+' #cruise_widget').gradientLite(); // CREATE GRADIENT	
		}
		
		// init cruise lines select
		doVendorSel("cruiseVendor", "All Cruise Lines");
		
	};
	
})(jQuery);

