// JavaScript Document
var linksContents = new Array();

function linkContents_init()
{
	for(i = 0; i < 4; i++)
	{
		linksContents[i] = new Array();		
		switch(i){
			case 0:
			  linksContents[i][0] = "LINK@SHERATON"
			  linksContents[i][1] = "linkatsheraton_thum.gif"
			  linksContents[i][2] = "linkatsheraton_content.png";
			  /*
			  linksContents[i][2] = "<h1>STAY CONNECTED</h1>" +
			                        "Your clients can now stay connected with instant access to information and<br/>technology with the \"Link@Sheraton experienced with Microsoft&reg;.\" This unique<br/>virtual and physical lobby lounge space enables guests to work, relax and<br/>remain connected with friends and family during their travels." +
									"<h1 style='margin-top:6px;'>A SOCIAL DESTINATION</h1>" +
									"The Link@Sheraton invites your clients to interact with each other while they<br/>check their email, research local attractions and even print boarding passes<br/>using free Wi-Fi and Internet-enabled computer stations." +
									"<h1 style='margin-top:6px;'>KEY FEATURES</h1>" +
									"Key features include Microsft branded webcams (allowing guests of all ages<br/>to easily email video postcards back home). televisions, daily newspapers,<br/>and The Link Cafe.";
									*/
			break;
			case 1:
			  linksContents[i][0] = "SHERATON FITNESS";
			  linksContents[i][1] = "fitness_thum.gif";
			  linksContents[i][2] = "fitness_content.png";
			  /*
			  linksContents[i][2] = "The new Sheraton brand fitness program was created in partnership with<br/>world-renowned personal training experts Core&reg; Performance to keep your<br/>clients at their peak at all times.<br/><br/>" +
			                        "The innovative Core Performance System is a complete approach that incorporate four fundaments :<br/><br/>" +
									"<span class='propTitle'>MINDSET</span>: Formulating mental strategies and habits to stay focused &amp; in cotrol<br/>"+
									"<span class='propTitle'>NUTRITION</span>: Properly fueling and hydrating to sustain peak performance levels<br/>" +
									"<span class='propTitle'>MOVEMENT</span>: Optimizing performance through mobility, stability and balance<br/>"+
									"<span class='propTitle'>RECOVERY</span>: Recharging mind and body to have your clients perform at their best<br/>throughout the day<br/><br/>" +
									"Staying fit has never been easier.<br/>";
									*/
			break;
			case 2:
			  linksContents[i][0] = "SWEET SLEEPER";
			  linksContents[i][1] = "guestrooms_thum.gif";
			  linksContents[i][2] = "guestrooms_content.png";
			  /*
			  linksContents[i][2] = "Your clients are treated to the celebrated Sweet Sleeper&trade; Bed, Shine<br/>by Sheraton&trade; bath amenities, a great cup of coffee, and flat screen TVs. With distinctive design and impressive functionality. our guestrooms infuse a fresh<br/>look with a greater opportunity to work, relax or socialize.<br/><br/>" +
			  "<h1>THE KEY FEATURES OF THE NEW SWEET SLEEPER BED INCLUDE:</h1>"+
			  "<div class='features'><ul>" +
			  "<li>Mattress: The new Sealy Luxurious Sleeper System mattress.</li>" +
			  "<li>Linens: Crisp, white 300 thread count linens</li>" +
			  "<li>Blanket: An ail-white quilted down blanket</li>" +
			  "<li>Duvet: A white-on-white duvet design</li>" +
			  "<li>Pillows: A combination of 50/50 feather/down pillows</li></ul></div>";			  
			  */
			break;
			case 3:
			  linksContents[i][0] = "SHERATON CLUB";
			  linksContents[i][1] = "sheratonclub_thum.gif";
			  linksContents[i][2] = "sheratonclub_content.png";
			  /*
			  linksContents[i][2] = "Sheraton Club offers our your very best clients the chance to upgrade to a<br/>higher level of comfort and convenience. When they step up to Club, they discover their own place to be more productive or to catch up with friends.<br/><br/>" +
			  "<h1>KEY FEATURES &amp; ENHANCEMENTS</h1>"+
			  "<div class='features'><ul>" +
			  "<li>Complimentary breakfast</li>" +
			  "<li>Snacks available throughout the day</li>" +
			  "<li>New communal tables and seating</li>" +
			  "<li>New enterainment/lounge area with signature seating and TVs</li>" +
			  "<li>New open kitchen/residential decor with integrated self-serve features</li></ul></div>";		
			  */
			break;
			default:
			break;			
		}
	}
	
}

function showContents(id)
{
	var resultbox = $('results');
	resultbox.hide();
	var div = $('links');
	var title = $('linkTitle');
	var imgPane = $('imgPane');	
	var infoPane = $('infoPane');
	title.update(linksContents[id][0] + "<img src='assets/images/btn_close.gif' alt='close' id='btn_close' class='btn_close' onclick='contentsHide(\"links\")'/>");
	imgPane.update("<img src='assets/images/"+linksContents[id][1]+"' alt='"+linksContents[id][0]+"' title='' border='0' />");
	infoPane.update("<img src='assets/images/"+linksContents[id][2]+"' alt='content' />");
	switch(id){
		case 0:
		  div.setStyle("position:relative;top:166px;left:-20px;");
		break;
		case 1:
		  div.setStyle("position:relative;top:170px;left:220px;");
		break;
		case 2:
		  div.setStyle("position:relative;top:200px;left:30px;");
		break;
		case 3:
		  div.setStyle("position:relative;top:200px;left:268px;");
		break;
		default:
		break;
	}
	div.show();
}

function contentsHide(div)
{
	$(div).hide();
}

function resetOptions(id)
{
	var resetText = $(id).readAttribute('reset');
	var o = new Element('option', {
		'value': ''
	}).update(resetText);
	$(id).update(o);
}

function getStates(country)
{
	//If no country chosen, reset options
	if (country.blank()) { resetOptions('state'); resetOptions('city'); return true; }
	
	new Ajax.Request(document.baseURL, {
		method: 'post',
		parameters: {
			'do':'get-options',
			'fx':'get_states',
			'country':country
		},
		onLoading: function(){
			resetOptions('state');
			resetOptions('city');
		},
		onSuccess: function(transport){
			$('state').insert(transport.responseText);
			$('state').firstDescendant().selected = true;
		},
		onFailure: function(){
			getStates(country);
		}
	});
}

function getCities(country, state)
{
	//If no state chosen, reset options
	if (state.blank()) { resetOptions('city'); return true; }
	
	new Ajax.Request(document.baseURL, {
		method: 'post',
		parameters: {
			'do':'get-options',
			'fx':'get_cities',
			'country':country,
			'state':state
		},
		onLoading: function(){
			resetOptions('city');
		},
		onSuccess: function(transport){
			$('city').insert(transport.responseText);
			$('city').firstDescendant().selected = true;
		},
		onFailure: function(){
			getCities(country, state);
		}
	});
}

function getOffers()
{
	var div = $('links');
	div.hide();
	if ($('city').value.blank()) { return true; }
	
	$('city').childElements().each(function(e){
		if (e.selected)
		{
			$('result_city_name').update(e.innerHTML);
		}
	});
	
	$('results').show();
	
	new Ajax.Request(document.baseURL, {
		method: 'post',
		parameters: {
			'do':'get-properties',
			'country':$('country').value,
			'state':$('state').value,
			'city':$('city').value
		},
		onLoading: function(){
			$('results_content').update('<div class="box" style="text-align: center;"><img src="assets/images/loading.gif" alt="" title="" border="0" /> Loading...</div>');
		},
		onSuccess: function(transport){
			$('results_content').update(transport.responseText);
			setupThumbs();
		},
		onFailure: function(){
			getOffers();
		}
	});
}

function setupThumbs()
{
	$$('.thumb .img').each(function(e){
		e.observe('mouseover', function(){ e.addClassName('hover'); });
		e.observe('mouseout', function(){ e.removeClassName('hover'); });
	});
	linkContents_init();
}