// JavaScript Document

	
		var calendar2 = new Object();
		var tr2 = new Object();
		tr2.nextMonth2 = "&#x4E0B;&#x4E2A;&#x6708;";
		tr2.prevMonth2 = "&#x4E0A;&#x4E2A;&#x6708;";
		tr2.closeCalendar2 = "&#x5173;&#x95ED;&#x65E5;&#x5386;";
		tr2.pressCtlD2 = "&#x8BF7;&#x6309;control-p&#x6216;&#x5728;&#x60A8;&#x7684;&#x6D4F;&#x89C8;&#x5668;&#x4E0A;&#x9009;&#x62E9;&#x4E66;&#x7B7E;/&#x6DFB;&#x52A0;&#x6216;&#x8005;&#x6536;&#x85CF;&#x5939;/&#x6DFB;&#x52A0;&#x3002;";
		tr2.pressCtlD2 = "&#x8BF7;&#x6309;control-p&#xFF0C;&#x6216;&#x8005;&#x5728;&#x60A8;&#x7684;&#x6D4F;&#x89C8;&#x5668;&#x4E0A;&#x9009;&#x62E9;&#x6587;&#x4EF6;/&#x6253;&#x5370;&#x3002;";
		tr2.url2 = "http://www.booking.com/index.zh.html?aid=330835;sid=73e9c8bf2d1228a194e764803574f3ce;tmpl=searchbox";
		tr2.title2 = "Booking.com &#x6B22;&#x8FCE;";
		tr2.icons2 = "http://static.booking.com/static/affiliate_base/img";
		var months2 = ['1&#x6708;','2&#x6708;','3&#x6708;','4&#x6708;','5&#x6708;','6&#x6708;','7&#x6708;','8&#x6708;','9&#x6708;','10&#x6708;','11&#x6708;','12&#x6708;'];
		var days32 = "";

		var $t_hotels2 = '&#x5BB6;&#x9152;&#x5E97;'.toLowerCase();
		var $t_hotels_around2 = '&#x9152;&#x5E97;&#x9644;&#x8FD1;'.toLowerCase().replace(/ /g, '&#160;');
		var b_today2 = "";
		var day2 = "&#x65E5;";
	



	var days2 = ['&#x5468;&#x4E00;','&#x5468;&#x4E8C;','&#x5468;&#x4E09;','&#x5468;&#x56DB;','&#x5468;&#x4E94;','&#x5468;&#x516D;','&#x5468;&#x65E5;'];
	Date.MILLISECONDS_PER_DAY = Date.prototype.MILLISECONDS_PER_DAY = 86400000;

	// Put placeholder in destination input box if empty, and remove when focused
	var destination2 = document.getElementById('b_destination');
	destination2.onblur = function () {
		if (!this.value) {
			this.value = this.getAttribute('title2');
			this.className = ' blur';
		}
	}
	destination2.onfocus = function () {
		if (this.value == this.getAttribute('title2')) {
			this.value = '';
			this.className = '';
		}
	}
	destination2.onblur();

	function tickCheckBox2(el) {
		if (document.getElementById) {
			if (document.getElementById(el)) {
				document.getElementById(el).checked = true;
			}
		}
		return true;
	}

	Date.prototype.getTwoDigitMonth2 = function () {
		// Returns a two-digit string from '01' to '12' representing the month property of a Date object.
		var month = (this.getMonth() + 1).toFixed().toString();
		if (month.length == 1) {
			month = '0' + month;
		}
		return month;
	};

	function checkDateOrder2(me, ci_day, ci_month_year, co_day, co_month_year) {
		var
			frm = document.getElementById('b_frm2'),
			my2,
			ci = new Date( 0 ),
			co = new Date( 0 ),
			com,
			today = new Date();
		// create date object from checkin values
		// set date to 12:00 to avoid problems with one
		// date being wintertime and the other summertime
		if ( frm[ci_day].value !== '0' )
		{
			ci.setDate( frm[ci_day].value );
		}
		if ( frm[ci_month_year].value !== '0' )
		{
			my2 = frm[ci_month_year].value.split( "-" );
			ci.setFullYear( my2[0] );
			ci.setMonth( my2[1] - 1 );
		}
		ci.setHours( 12 );
		ci.setMinutes( 0 );
		ci.setSeconds( 0 );
		// create date object from checkout values
		if ( frm[co_day].value !== '0' )
		{
			co.setDate( frm[co_day].value );
		}
		if ( frm[co_month_year].value !== '0' )
		{
			my2 = frm[co_month_year].value.split( "-" );
			co.setFullYear( my2[0] );
			co.setMonth( my2[1] - 1 );
		}
		co.setHours( 12 );
		co.setMinutes( 0 );
		co.setSeconds( 0 );
		// If the new checkin date's month does not match
		// the current value of the dropdown, then it is
		// because the month was incremented creating an
		// invalid date (e.g. February 31st).
		// We'll cycle back the checkin date until we're in
		// the correct month.
		if ( frm[ci_month_year].value !== '0' )
		{
			while ( ci.getMonth() != frm[ci_month_year].value.split( "-" )[1] - 1 )
			{
				ci.setDate( ci.getDate() - 1 );
				frm[ci_day].value = ci.getDate();
			}
			var cim = ci.getMonth() + 1;
			frm[ci_month_year].value = ci.getFullYear() + "-" + cim;
		}
		// if checkin date is at or after checkout date,
		// add a day full of milliseconds, and set the
		// selectbox values for checkout date to new value
		if ( ci >= co )
		{
			co.setTime( ci.getTime() + Date.prototype.MILLISECONDS_PER_DAY );
			com = co.getMonth() + 1;
			if ( frm[ci_day].value !== '0' )
			{
				frm[co_day].value = co.getDate();
			}
			if ( frm[ci_month_year].value !== '0' )
			{
				frm[co_month_year].value = co.getFullYear() + "-" + com;
			}
		}
	}

	function updateDaySelect2( me )
	{
		// 1-2 testing
		if ( !days32 )
		{
			return;
		}
		var frm = document.getElementById('frm');
		if ( frm.getAttribute( 'id' ) !== 'frm' && frm.className !== 'availForm' )
		{
			return;
		}
		// Check if we have all fields. If not, we are in the first stage
		// of the book process and should not auto-update selects since there
		// is only the check-in select and the amount of nights.
		if ( !frm.checkin_monthday || !frm.checkout_monthday || !frm.checkin_year_month || !frm.checkout_year_month )
		{
			return;
		}
		if ( frm.checkin_monthday.value === '0' && frm.checkout_monthday.value === '0' && frm.checkin_year_month.value === '0' && frm.checkout_year_month.value === '0' )
		{
			return;
		}
		// If the year-month fields have nonzero values, prepend the day of the week to each monthday in the check-in and check-out monthday Selects.
		var
			ci_d = frm.checkin_monthday,
			co_d = frm.checkout_monthday,
			ci_my,
			co_my,
			todaysDate;
		// If the form field has a nonzero value, use it;
		if ( frm.checkin_year_month.value !== '0' )
		{
			ci_my = frm.checkin_year_month.value.split( "-" );
		}
		else
		{
			// Use the current date value.
			todaysDate = new Date();
			ci_my = [ todaysDate.getFullYear(), todaysDate.getTwoDigitMonth2() ];
		}
		if ( frm.checkout_year_month.value !== '0' )
		{
			co_my = frm.checkout_year_month.value.split( "-" );
		}
		else
		{
			todaysDate = new Date();
			co_my = [ todaysDate.getFullYear(), todaysDate.getTwoDigitMonth2() ];
		}
		var
			ci_sel = Math.max( ci_d.selectedIndex, 0 ),
			co_sel = Math.max( co_d.selectedIndex, 0 ),
			ci_sel_value = ci_d[ ci_sel ].value,
			co_sel_value = co_d[ co_sel ].value,
			monthDays = [],
			opt,
			i;
	
		ci_d.innerHTML = '';
		co_d.innerHTML = '';
	
		var MonthdayPromptOption = function ()
		{
			this.option = {
				"_this" : this,
				"@selected" : "selected",
				"@class" : "day prompt site_experiment_encourage_date_entry_2",
				"@value" : 0,
				"#text" : "day"
			};
		};
		if ( ci_sel_value === '0' )
		{
			buildHtmlNode( new MonthdayPromptOption(), ci_d ).selected = true;
		}
		if ( co_sel_value === '0' )
		{
			buildHtmlNode( new MonthdayPromptOption(), co_d ).selected = true;
		}

		function writeMonthdaysOptions( numberOfMonthdaysToShow, yearMonthSelectElement, monthDaysArray, monthDaysSelectElement, monthDaySelectValue )
		{
			var i, optionElementInnerHTML, optionElement;
			for ( i = 0; i < numberOfMonthdaysToShow; i++ )
			{
				optionElement = document.createElement( 'option' );
				optionElementInnerHTML = i + 1;
				if ( yearMonthSelectElement.value !== '0' )
				{
					optionElementInnerHTML = monthDaysArray[i] + ' ' + optionElementInnerHTML;
				}
				optionElement.innerHTML = optionElementInnerHTML;
				optionElement.value = ( i + 1 );
				if ( i > 0 && monthDaySelectValue == i + 1 )
				{
					optionElement.defaultSelected = optionElement.selected = true;
				}
				monthDaysSelectElement.appendChild( optionElement );
			}
		}
		// Check-in month
		monthDays = buildDaysForMonth2( ci_my[0], ci_my[1] );
		var numberOfMonthdaysToShow = 31;
		if ( frm.checkin_year_month.value !== '0' )
		{
			numberOfMonthdaysToShow = monthDays.length;
		}
		writeMonthdaysOptions( numberOfMonthdaysToShow, frm.checkin_year_month, monthDays, ci_d, ci_sel_value );
		// Checkout month
		monthDays = buildDaysForMonth2( co_my[0], co_my[1] );
		numberOfMonthdaysToShow = 31;
		if ( frm.checkout_year_month.value !== '0' )
		{
			numberOfMonthdaysToShow = monthDays.length;
		}
		writeMonthdaysOptions( numberOfMonthdaysToShow, frm.checkout_year_month, monthDays, co_d, co_sel_value );
		// IE 6 exhibits a bug whereby the value of the monthday select always jumps to zero.
		if ( document.all && !gClientIsOpera && /MSIE 6\.0/.test(navigator.appVersion) )
		{
			ci_d.value = ci_sel_value;
			co_d.value = co_sel_value;
		}
	}

	function buildDaysForMonth2( year, month )
	{
		// Month index starts on 0(-11) in Date()-object
		var monthDate = new Date( year, month - 1 );
		var orgMonth = monthDate.getMonth();
		var dayArray = [], weekDay;
		while ( monthDate.getMonth() == orgMonth )
		{
			// Week starts on Sunday in Date()-object
			weekDay = ( monthDate.getDay() == 0 ) ? 6 : ( monthDate.getDay() - 1 );
			dayArray.push( days32[weekDay] );
			monthDate.setDate( monthDate.getDate() + 1 );
		}
		return dayArray;
	}

	function buildHtmlNode (elementsObject, targetNode, refChild)
	{
		/*
		Accepts an object of elements where the key specifies the tagname unless prefixed by @, in which case it specifies an attribute of the parent, or when it is #cdata, in which case it specifies a CDATA child.
		
		http://xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html
		
		The big flaw now is the case <a><b/><c/><b/><a/>, which cannot be represented as a JS object. In that case interject an array of generic div or span elements.
		*/
		// If we want to validate as JSON, we must make sure what we pass in is JSON, which it presently isn窶冲.
		//elementsObject = booking.json.validate(elementsObject);
		var
			key,
			counter,
			found,
			newElement,
			newNode;
		for (key in elementsObject)
		{
			if (elementsObject.hasOwnProperty(key))
			{
				var
					prefix = key.substring(0, 1),
					primaryKey = key.substring(1);
				if (prefix != '_') // We窶决e on a non-DOM key, so skip.
				{
					if (prefix == '@') // Attribute
					{
						if (!targetNode.getAttribute(primaryKey))
						{
							// Perhaps extend this in the future to support multiple class values.
							targetNode.setAttribute(primaryKey, elementsObject[key]);
						}
					}
					else
					{
						if (prefix == '#') // Text or CDATA
						{
							if (primaryKey == 'text') // Text
							{
								found = false;
								if (targetNode.childNodes && targetNode.childNodes.length > 0)
								{
									// Traverse text node children and append only if it isn窶冲 already there.
									counter = 0;
									while (counter < targetNode.childNodes.length && !found)
									{
										if (targetNode.childNodes[counter].nodeType == Node.TEXT_NODE && targetNode.childNodes[counter].nodeValue == elementsObject[key])
										{
											found = true;
										}
										counter++;
									}
								}
								if (!found)
								{
									// MGP 040209: Cope with strings split by linebreaks - need to insert <br> elements
									if ( elementsObject[key].indexOf("\n") == -1 )
									{
										newNode = document.createTextNode(elementsObject[key]);
										if (refChild)
										{
											targetNode.insertBefore(newNode, refChild);
										}
										else
										{
											targetNode.appendChild(newNode);
										}
									}
									else
									{
										// Found some linebreaks - split the string into component parts
										var newNodeParts = elementsObject[key].split("\n");
										// Loop through the parts, adding a linebreak after each one (except the last one)
										for ( var i = 0; i < newNodeParts.length; i++ )
										{
											// Check for the existence of a star rating in the text node
											if ( newNodeParts[i].match(/\d\*$/) )
											{
												// Found a star rating - extract the star
												lastSpace = newNodeParts[i].lastIndexOf(" ");
												newNodeString = newNodeParts[i].substring( 0, lastSpace );
												starImgSrc = '/static/img/icons/stars/' + newNodeParts[i].substr( lastSpace + 1, 1 ) + 'sterren-small.png';
											}
											else
											{
												newNodeString = newNodeParts[i];
												starImgSrc = '';
											}
											newNode = document.createTextNode(newNodeString);
											if (refChild)
											{
												targetNode.insertBefore(newNode, refChild);
												if ( starImgSrc )
												{
													newImg = document.createElement('img');
													newImg.setAttribute('src', starImgSrc);
													newImg.className = "stars";
													targetNode.insertBefore(newImg, refChild);
												}
											}
											else
											{
												targetNode.appendChild(newNode);
												if ( starImgSrc )
												{
													newImg = document.createElement('img');
													newImg.setAttribute('src', starImgSrc);
													newImg.className = "stars";
													targetNode.appendChild(newImg);
												}
											}
											if ( i < newNodeParts.length - 1)
											{
												// Add a <br>
												newBR = document.createElement("br");
												if (refChild)
												{
													targetNode.insertBefore(newBR, refChild);
												}
												else
												{
													targetNode.appendChild(newBR);
												}
											}
										}
									}
								}
							}
							else
							{
								if (primaryKey == 'cdata') // CDATA
								{
									targetNode.appendChild(document.createCDATASection(elementsObject[key]));
								}
							}
						}
						else // Element
						{
							// If targetNode was passed into this function, append the new child to it窶ｦ
							if (targetNode)
							{
								// If elementsObject[key] is an array, we窶冤l create an element of type key for each array member.
								if (elementsObject[key].length > 0)
								{
									for (counter = 0; counter < elementsObject[key].length; counter++)
									{
										if (elementsObject[key][counter])
										{
											if (!elementsObject[key][counter]._node)
											{
												newElement = document.createElement(key);
												elementsObject[key][counter]._node = newElement;
												var r = counter + 1;
												while (r < elementsObject[key].length && !refChild)
												{
													if (elementsObject[key][r])
													{
														refChild = elementsObject[key][r]._node;
													}
													r++;
												}
												if (refChild)
												{
													newNode = targetNode.insertBefore(
														elementsObject[key][counter]._node,
														refChild);
												}
												else
												{
													newNode = targetNode.appendChild(
														elementsObject[key][counter]._node);
												}
												arguments.callee(
													elementsObject[key][counter],
													newNode);
												newElement._elementTree = elementsObject[key][counter];
											}
											else
											{
												arguments.callee(
													elementsObject[key][counter],
													elementsObject[key][counter]._node);
											}
										}
									}
								}
								else
								{
									if (elementsObject[key].length !== 0)
									{
										if (!elementsObject[key]._node)
										{
											newElement = document.createElement(key);
											elementsObject[key]._node = newElement;
											if (refChild)
											{
												newNode = targetNode.insertBefore(
													elementsObject[key]._node,
													refChild);
											}
											else
											{
												newNode = targetNode.appendChild(
													elementsObject[key]._node);
											}
											arguments.callee(
												elementsObject[key],
												newNode);
											newElement._elementTree = elementsObject;
										}
										else
										{
											arguments.callee(
												elementsObject[key],
												elementsObject[key]._node);
										}
									}
								}
							}
							// 窶ｦelse create the new element as targetNode.
							else
							{
								if (!elementsObject[key]._node)
								{
									arguments.callee(elementsObject[key],
										elementsObject[key]._node = targetNode = document.createElement(key));
								}
								else
								{
									arguments.callee(elementsObject[key],
										elementsObject[key]._node);
								}
							}
						}
					}
				}
			}
		}
		return targetNode;
	};



/*extern DOM, calendar, dn, getChildImage, getDimensions, m, months, n, tr, y, checkDateOrder, d, days, days3, gClientIsIE5, i, tickCheckBox, updateDaySelect, booking, buildDaysForMonth, gClientIsMac, monthDaysArray */
// showCalendar without requirements for unique id's
//	@me	DOMNode context node
//	@calId	String	id of calendar node
//	@dt	String	'checkin' or 'checkout' prefix
var td;
function buildCal2( y, m, d )
{
	var daysInMonth = [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	// Create today窶冱 date.
	td = new Date();
	if ( !y )
	{
		y = td.getFullYear();
	}
	if ( !m )
	{
		m = td.getMonth() + 1;
	}
	if ( !d )
	{
		d = td.getDate;
	}
	var dt = calendar2.caldt;
	var mDate = new Date( y, m - 1, 1 );
	var firstMonthDay = mDate.getDay();
	daysInMonth[1] = ( ( ( mDate.getFullYear() % 100 != 0 ) && ( mDate.getFullYear() % 4 == 0 ) ) || ( mDate.getFullYear() % 400 == 0 ) ) ? 29 : 28;
	var t = '<div id="b_calendarInner" class="b_popupInner"><table class="b_caltable" cellspacing="0"><tr class="b_calHeader">';
	t += '<td colspan="7">';
	if ( y == td.getFullYear() && m == td.getMonth() + 1 )
	{
		t += '&lt;';
	}
	else
	{
		t += '<a class="calPrevMonth" href="" onclick="prevMonth2( ' + y + ',' + m + ' ); return false;" title="' + tr2.prevMonth2 + '">&lt;</a>';
	}
	t += '&nbsp;<select name="ym" onchange="goYearMonth2( this.options[this.selectedIndex].value );">';
	var mn = td.getMonth() + 1;
	var yr = td.getFullYear();
	var last_month = 0;
	for ( n = 0; n <= 11; n++ )
	{
		t += '<option value="' + yr + '-' + mn + '"';
		if ( mn == m && yr == y )
		{
			t += ' selected="selected"';
			last_month = 1;
		}
		else
		{
			last_month = 0;
		}
		t += '>' + months2[mn - 1] + ' ' + yr +'</option>';
		mn++;
		if ( mn > 12 )
		{
			mn = 1;
			yr++;
		}
	}
	t += ' </select>&nbsp;';
	if ( last_month == 1 )
	{
		t += '&gt;';
	}
	else
	{
		t += '<a class="calNextMonth" href="" onclick="nextMonth2( ' + y + ',' + m + ' ); return false;" title="' + tr2.nextMonth2 +'">&gt;</a>';
	}
	t += '</td></tr>';
	t += '<tr class="b_calDayNames">';
	var cl;
	for ( dn = 0; dn < 7; dn++ )
	{
		cl = '';
		if ( ( dn % 7 == 5 ) || ( dn % 7 == 6 ) )
		{
			cl += ' weekend';
		}
		t += '<td class="' + cl + '">' + days2[dn] + '</td>';
	}
	t += '</tr><tr class="b_calDays">';
	for ( i = 1; i <= 42; i++ )
	{
		var x = i - ( firstMonthDay + 6 ) % 7;
		if ( x > daysInMonth[m - 1] || x < 1 )
		{
			x = '&nbsp;';
		}
		cl = '';
		var href = 0;
		if ( ( i % 7 == 0 ) || ( i % 7 == 6 ) )
		{
			cl += ' b_calWeekend';
		}
		if ( x > 0 )
		{
			var xDay = new Date( y, m - 1, x );
			if ( ( xDay.getFullYear() == y ) && ( xDay.getMonth() + 1 == m ) && ( xDay.getDate() == d ) )
			{
				cl += ' b_calSelected';
				href = 1;
			}
			if ( ( xDay.getFullYear() == td.getFullYear() ) && ( xDay.getMonth() == td.getMonth() ) && ( xDay.getDate() == td.getDate() ) )
			{
				cl += ' b_calToday';
				href = 1;
			}
			else
			{
				if ( xDay > td )
				{
					cl += ' b_calFuture';
					href = 1;
				}
				else
				{
					if ( xDay < td )
					{
						cl += ' b_calPast';
					}
				}
			}
		}
		t += '<td class="' + cl + '">';
		if ( href )
		{
			t += '<a href="#" onclick="pickDate2( ' + y + ',' + m + ',' + x + ',\'' + dt + '\' ); return false;">' + x + '</a>';
		}
		else
		{
			t += x;
		}
		t += '</td>';
		if ( ( ( i ) % 7 == 0 ) && ( i < 36 ) )
		{
			t += '</tr><tr class="b_calClose">';
		}
	}
	t += '</tr><tr><td colspan="7"><a href="#" onclick="closeCal2(); return false;">' + tr2.closeCalendar2 + '</a></td></tr></table></div>';
	document.getElementById( "b_calendarPopup" ).innerHTML = t;
}

function showCalendar2( me, calId, dt )
{
	getDimensions( me );
	if ( document.getElementById )
	{
		var c = document.getElementById( calId );
		var i = getChildImage( me );
		var f = document.getElementById('b_frm2');
		calendar2.cal = c;
		calendar2.caldt = dt;
		calendar2.calf = f;
		var my2 = f[dt + '_year_month'].value.split( "-" );
		y = my2[0];
		m = my2[1];
		d = f[dt + '_monthday'].value;
		// Ensure y is nonzero so the pop-up calendar correctly figures out the past/current/future classes for each monthday.
		if ( y === '0' )
		{
			y = new Date().getFullYear();
		}
		buildCal2( y, m, d );
		var box = getDimensions( i );
		var
			left = box.x,
			top = ( box.y + i.offsetHeight );
		c.style.left = left + 'px';
		c.style.top = top + 'px';
		c.style.display = "block";
	}
}

function closeCal2()
{
	calendar2.cal.style.display = 'none';
}

function prevMonth2( y, m )
{
	if ( new Date( y, m - 1, 1 ) < td )
	{
		return;
	}
	if ( m > 1 )
	{
		m--;
	}
	else
	{
		m = 12;
		y--;
	}
	buildCal2( y, m );
}

//does this finction need to check for max month/year?
function nextMonth2( y, m )
{
	if ( m < 12 )
	{
		m++;
	}
	else
	{
		m = 1;
		y++;
	}
	buildCal2( y, m );
}

function goYearMonth2( ym )
{
	var ymlist = ym.split("-");
	buildCal2( ymlist[0], ymlist[1] );
}

function pickDate2( y, m, d, dt )
{
	// set form values
	var f = calendar2.calf;
	var dt = calendar2.caldt;
	f[dt + '_year_month'].value = y + "-" + m;
	f[dt + '_monthday'].value = d;
    tickCheckBox2( 'availcheck' );
	if ( dt == "checkin" )
	{
		checkDateOrder2( f, 'checkin_monthday', 'checkin_year_month', 'checkout_monthday', 'checkout_year_month' );
	}
	closeCal2();
	updateDaySelect2( f );
}

function initDaySelect2()
{
	var forms = document.getElementsByTagName( 'form' );
	for ( var i = 0; i < forms.length; i++ )
	{
		if ( forms[i].checkin_monthday )
		{
			if ( !gClientIsIE5 )
			{
				forms[i].validator = new booking.datebox.Validator( forms[i] );
			}
			updateDaySelect2( forms[i] );
		}
	}
}

function updateDaySelect2( me )
{
	// 1-2 testing
	if ( !days32 )
	{
		return;
	}
	var frm = document.getElementById('b_frm2');
	if ( frm.getAttribute( 'id' ) !== 'b_frm2' && frm.className !== 'availForm' )
	{
		return;
	}
	// Check if we have all fields. If not, we are in the first stage
	// of the book process and should not auto-update selects since there
	// is only the check-in select and the amount of nights.
	if ( !frm.checkin_monthday || !frm.checkout_monthday || !frm.checkin_year_month || !frm.checkout_year_month )
	{
		return;
	}
	if ( frm.checkin_monthday.value === '0' && frm.checkout_monthday.value === '0' && frm.checkin_year_month.value === '0' && frm.checkout_year_month.value === '0' )
	{
		return;
	}
	// If the year-month fields have nonzero values, prepend the day of the week to each monthday in the check-in and check-out monthday Selects.
	var
		ci_d = frm.checkin_monthday,
		co_d = frm.checkout_monthday,
		ci_my,
		co_my,
		todaysDate;
	// If the form field has a nonzero value, use it;
	if ( frm.checkin_year_month.value !== '0' )
	{
		ci_my = frm.checkin_year_month.value.split( "-" );
	}
	else
	{
		// Use the current date value.
		todaysDate = new Date();
		ci_my = [ todaysDate.getFullYear(), todaysDate.getTwoDigitMonth2() ];
	}
	if ( frm.checkout_year_month.value !== '0' )
	{
		co_my = frm.checkout_year_month.value.split( "-" );
	}
	else
	{
		todaysDate = new Date();
		co_my = [ todaysDate.getFullYear(), todaysDate.getTwoDigitMonth2() ];
	}
	var
		ci_sel = Math.max( ci_d.selectedIndex, 0 ),
		co_sel = Math.max( co_d.selectedIndex, 0 ),
		ci_sel_value = ci_d[ ci_sel ].value,
		co_sel_value = co_d[ co_sel ].value,
		monthDays = [],
		opt,
		i;

	ci_d.innerHTML = '';
	co_d.innerHTML = '';

	// Build the Day/Month prompt Options if the monthday values aren窶冲 already set or, if they are set, they are nonzero; and if the client isn窶冲 IE 5. This condition mimics the TMPL_IF in datebox.inc/div#avail (except for the inclusion here of gClientIsIE5).
	var MonthdayPromptOption = function ()
	{
		this.option = {
			"_this" : this,
			"@selected" : "selected",
			"@class" : "day prompt site_experiment_encourage_date_entry_2",
			"@value" : 0,
			"#text" : day2
		};
	};
	if ( ci_sel_value === '0' )
	{
		buildHtmlNode( new MonthdayPromptOption(), ci_d ).selected = true;
	}
	if ( co_sel_value === '0' )
	{
		buildHtmlNode( new MonthdayPromptOption(), co_d ).selected = true;
	}
	function writeMonthdaysOptions( numberOfMonthdaysToShow, yearMonthSelectElement, monthDaysArray, monthDaysSelectElement, monthDaySelectValue )
	{
		var i, optionElementInnerHTML, optionElement;
		for ( i = 0; i < numberOfMonthdaysToShow; i++ )
		{
			optionElement = document.createElement( 'option' );
			optionElementInnerHTML = i + 1;
			if ( yearMonthSelectElement.value !== '0' )
			{
				optionElementInnerHTML = monthDaysArray[i] + ' ' + optionElementInnerHTML;
			}
			optionElement.innerHTML = optionElementInnerHTML;
			optionElement.value = ( i + 1 );
			if ( i > 0 && monthDaySelectValue == i + 1 )
			{
				optionElement.defaultSelected = optionElement.selected = true;
			}
			monthDaysSelectElement.appendChild( optionElement );
		}
	}
	// Check-in month
	monthDays = buildDaysForMonth2( ci_my[0], ci_my[1] );
	var numberOfMonthdaysToShow = 31;
	if ( frm.checkin_year_month.value !== '0' )
	{
		numberOfMonthdaysToShow = monthDays.length;
	}
	writeMonthdaysOptions( numberOfMonthdaysToShow, frm.checkin_year_month, monthDays, ci_d, ci_sel_value );
	// Checkout month
	monthDays = buildDaysForMonth2( co_my[0], co_my[1] );
	numberOfMonthdaysToShow = 31;
	if ( frm.checkout_year_month.value !== '0' )
	{
		numberOfMonthdaysToShow = monthDays.length;
	}
	writeMonthdaysOptions( numberOfMonthdaysToShow, frm.checkout_year_month, monthDays, co_d, co_sel_value );
	// IE 6 exhibits a bug whereby the value of the monthday select always jumps to zero.
	if ( document.all && !gClientIsOpera && /MSIE 6\.0/.test(navigator.appVersion) )
	{
		ci_d.value = ci_sel_value;
		co_d.value = co_sel_value;
	}
}

function buildDaysForMonth2( year, month )
{
	// Month index starts on 0(-11) in Date()-object
	var monthDate = new Date( year, month - 1 );
	var orgMonth = monthDate.getMonth();
	var dayArray = [], weekDay;
	while ( monthDate.getMonth() == orgMonth )
	{
		// Week starts on Sunday in Date()-object
		weekDay = ( monthDate.getDay() == 0 ) ? 6 : ( monthDate.getDay() - 1 );
		dayArray.push( days32[weekDay] );
		monthDate.setDate( monthDate.getDate() + 1 );
	}
	return dayArray;
}

// Hides "Available rooms" and shows date input for stay.
// This currently works without unique id's under the assumption that
// the two (or more) divs containing the different "views" are in the same container.
function switchDateStack( me, page )
{
	var stackPage = DOM.getParentOrSelf( me, 'div' );
	var stackCount = 0;
	while ( stackPage )
	{
		if ( stackPage.nodeName.toLowerCase() == 'div' )
		{
			stackCount++;
			if ( stackCount == page )
			{
				stackPage.style.display = 'block';
			}
			else
			{
				stackPage.style.display = 'none';
			}
		}
	stackPage = stackPage.nextSibling;
	}
}

// Searches children to find image
function getChildImage( contextElm )
{
	contextElm = contextElm.firstChild;
	while ( contextElm.nodeName.toLowerCase() != 'img' && contextElm.nextSibling )
	{
		contextElm = contextElm.nextSibling;
	}
	return contextElm;
}

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// OBSOLETE - use DOM.getParentOrSelf in base.js instead
// Searches upwards from the current context element until it finds the specified tag
function getParentOrSelf( contextElm, nodeName )
{
	nodeName = nodeName.toLowerCase();
	while ( contextElm.nodeName.toLowerCase() != nodeName && contextElm.parentNode )
	{
		contextElm = contextElm.parentNode;
	}
	return contextElm;
}

// Getting element dimensions
function getDimensions( elm ) {
	var box = { x:0, y:0, w:0, h:0 };
	if(document.getBoxObjectFor) {
		var boxRef = document.getBoxObjectFor(elm);
		box.x = boxRef.x;
		box.y = boxRef.y;
		box.w = boxRef.width;
		box.h = boxRef.height;
	}
	else if(elm.getBoundingClientRect) {
		var rxIE50 = /MSIE 5\.0/g;
		//alert(rxIE50 + '.test("' + navigator.appVersion + '" = ' + rxIE50.test(navigator.appVersion));
		var boxRef = elm.getBoundingClientRect();
		box.x = boxRef.left;
		box.y = boxRef.top;
		box.w = (boxRef.right - boxRef.left);
		box.h = (boxRef.bottom - boxRef.top);
		//var s='';for(p in boxRef) s+=p+'    '; alert(s);
		// Damn IE...
		if(document.compatMode && document.compatMode != 'BackCompat') {
			// IE6/compliance mode
			box.x += document.documentElement.scrollLeft - 2;
			box.y += document.documentElement.scrollTop - 2;
		}
		else if(!gClientIsIE5) {
			// IE5.5
			box.x += document.body.scrollLeft - 2;
			box.y += document.body.scrollTop - 2;
		}
	}
	else {
		// No known box information available, walking
		// manually through offsetParents to calculate x/y coordinates
		box.w = elm.offsetWidth;
		box.h = elm.offsetHeight;
		while(elm) {
			box.x += elm.offsetLeft;
			box.y += elm.offsetTop;
			if(elm.offsetParent) // Required for Safari 1.3 :(
				elm = elm.offsetParent;
			else
				break;
		}
	}
	var cc;
	if(cc = document.getElementById('bodyconstraint'))
		box.x -= cc.offsetLeft;
	return box;
}


/////////////////////////////////////
///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
  var currentDate2 = new Date(); 
	var currentYear2 = 1900 + currentDate2.getYear();
    var dailyMS2 = 24*60*60*1000;
    var arrivalDate2 = new Date(currentDate2.getTime());
    var departureDate2 = new Date(currentDate2.getTime() + 1*dailyMS2);
    var arrivalYearMonth2 = 1900+arrivalDate2.getYear() + "-" + 1+arrivalDate2.getMonth();
	var arrivalDay2 = arrivalDate2.getDate();
    var departureYearMonth2 = 1900+departureDate2.getYear() + "-" + 1+departureDate2.getMonth(); 
	var departureDay2 = departureDate2.getDate();
    var a2=document.b_frm2;
    if ((a2.checkin_monthday.selectedIndex == 0) && (a2.checkout_monthday.selectedIndex == 0)){
        a2.checkin_monthday.options[arrivalDay2-1].selected = true;
        a2.checkout_monthday.options[departureDay2-1].selected = true;
	}
	var frm2 = document.getElementById('b_frm2');
		// create date object from checkin values
		// set date to 12:00 to avoid problems with one
		// date being wintertime and the other summertime
	var my2 = frm2['b_checkin_month'].value.split("-");
	   var ci = new Date (my2[0], my2[1]-1, frm2['b_checkin_day'].value, 12, 0, 0, 0);

        // create date object from checkout values
	 my2 = frm2['b_checkout_month'].value.split("-");
	 var co = new Date (my2[0], my2[1]-1, frm2['b_checkout_day'].value, 12, 0, 0, 0);
	if (ci >= co){
    	    co.setTime(ci.getTime() + 1000 * 60 * 60 * 24);
	        frm2['b_checkout_day'].value =  co.getDate();
    	    var com = co.getMonth()+1;
	        frm2['b_checkout_month'].value = co.getFullYear() + "-" + com;
    }

