// Wrap code with module pattern.
(function() {
  var global = this;

  // widget constructor function
  global.HFE_TravelFinds_450_150_1 = function(dealData) {
	
	var widget_style = '450_150_1';
	var widget_id=Math.floor(Math.random()*10000);
	
	// Don't do style for Fodor's or for Tix4Tonight
	if (dealData.partner_id != "515" && dealData.partner_id != "518") { 

		var styleHTML = '<style> \
			#hfe-widget {clear:both; width:450px;height:145px;overflow:hidden;border-top:5px solid #f60;font:12px/18px Verdana,Arial,Helvetica,sans-serif;color:#06c; background: #FFFFFF;} \
			#hfe-widget a{color:#06c;text-decoration:none;} \
			#hfe-widget a:hover{text-decoration:underline;}  \
			#hfe-widget h3.dest-head {padding:8px 8px 6px; background:url(http://'+dealData.img_domain+'/widgets/images/hfe-widget-450-150-heading.gif) repeat-x;} \
			#hfe-widget .dest-head a {margin:0;font:15px/16px Verdana,Arial,Helvetica,sans-serif; font-weight:bold;color:#f60; background:none; width:420px;} \
			#hfe-widget ul{list-style:none;margin:0 0 0 8px;padding:0;} \
			#hfe-widget ul li{list-style:none;overflow:hidden;border-top:1px solid #fc9;padding:3px 7px 2px;vertical-align:middle;} \
			#hfe-widget .dest-button {overflow:hidden; width:440px; margin:5px 0 0 8px; padding:3px 7px 2px; font:14px/16px Verdana,Arial,Helvetica,sans-serif; font-weight:bold;color:#f60;} \
			#hfe-widget .dest-button span {float:right; color: #000;} \
			#hfe-widget ul li a {float:left;width:420px; font-weight:bold;} \
			#hfe-widget ul em {color:#06c; font-style: normal;} \
			#hfe-widget ul em:before {content: " ";} \
			#hfe-widget ul a.found {float:right; width:30px; margin-right:8px; text-align:center; text-decoration:none; font:11px/20px Arial,Helvetica,sans-serif;color:#333;} ';

		// Before we close this out, let's make some adjustments if the landmark name is too long

		if (dealData.title_1 && dealData.title_1.length > 38) {
			styleHTML += '#hfe-widget div.header {padding-top: 6px;padding-bottom:6px;}';
			styleHTML += '#hfe-widget ul li {padding-top:2px; padding-bottom:1px;}'
		}
	
		styleHTML += '</style>';
		
		// Drop in the widget's id
		styleHTML = styleHTML.replace(/#hfe-widget/g,"#hfe-widget-"+widget_id);

		document.write(styleHTML);
		
	}

	document.write('<div id="hfe-widget-'+widget_id+'" class="dest-section clearfix" ></div>');
	
	var widget = document.getElementById('hfe-widget-'+widget_id);

	
	// Create header widget DOM fragment
	var dealListHTML = '<h3 class="dest-head"><span><a '+dealData.click_tracking_code+' href="'+dealData.default_url+'" target="_blank" rel="nofollow">'+dealData.title_1+'</a></span></h3>';
	dealListHTML +='<ul class="dest-section">';
	
	for (var i = 0; i < dealData.deals.length; i++) { 
	
		var deal = dealData.deals[i];

		dealListHTML += '<li><a '+dealData.click_tracking_code+' href="'+deal.url+'" target="_blank" rel="nofollow">'+deal.promo_text+'</a></li>';
	}

	dealListHTML +='</ul>';

	dealListHTML += '<a class="dest-button" href="'+dealData.default_url+'" target="_blank" rel="nofollow" '+dealData.click_tracking_code+'">Find More Deals</a>';

	// Analytics call
	dealListHTML += '<iframe src="http://'+dealData.widget_domain+'/widget-load/'+widget_style+'/'+dealData.type+'/'+dealData.name_slug+'.html" style="display: none;" border="0" scrolling="no"></iframe>';
	
	widget.innerHTML = dealListHTML;

  };
})();

var dealData = {"default_url" : "http://fodors-finds.hotels-for-everyone.com/landmark_pages/view_destination/Maui/20.785005/-156.461792?pid=515&spec=0", "tagline_1" : "Fodor's Finds", "tagline_2" : "Fodor's Find", "title_1" : "Fodor's Finds Hotel Deals in Maui", "title_2" : "Maui landmarks", "title_3" : "Maui hotels", "title_4" : "in Maui", "title_5" : "in<br>Maui", "domain" : "fodors-finds.hotels-for-everyone.com", "widget_domain" : "fodors.hotels-for-everyone.com", "type" : "destination", "img_domain" : "img1.hotels-for-everyone.com", "phone" : "800-916-8592", "partner_id" : "515", "destination" : "maui-island", "name_slug" : "maui", "city_state_country" : "Maui Island, Hawaii, USA", "min_date" : "02/09/2012", "max_date" : "01/04/2013", "click_tracking_code" : "onclick=\"linkCode(this,'event32');\" rel=\"nofollow\"", "category" : "beach", "hotel_id" : "", "hotel_name" : "", "deals" : [ {"promo_text" : "4 Star Hotel - <em>4th Night Free</em>", "url" : "http://fodors-finds.hotels-for-everyone.com/landmark_pages/view_destination/Maui/20.785005/-156.461792?pid=515&spec=0&hhid=153179&checkIn=03/16/2012&checkOut=03/21/2012", "discovered" : "02/08/2012", "source" : "Deal from 000", "hotel_id" : "153179"}, {"promo_text" : "Book Early and <em>Save 60%</em>", "url" : "http://fodors-finds.hotels-for-everyone.com/landmark_pages/view_destination/Maui/20.785005/-156.461792?pid=515&spec=0&hhid=217395&checkIn=10/27/2012&checkOut=11/03/2012", "discovered" : "02/08/2012", "source" : "Deal from 000", "hotel_id" : "217395"}, {"promo_text" : "3 Star Hotel - <em>Save 25% On Your Stay</em>", "url" : "http://fodors-finds.hotels-for-everyone.com/landmark_pages/view_destination/Maui/20.785005/-156.461792?pid=515&spec=0&hhid=218300&checkIn=05/27/2012&checkOut=06/01/2012", "discovered" : "02/08/2012", "source" : "Deal from 000", "hotel_id" : "218300"}]};
HFE_TravelFinds_450_150_1(dealData);

