;(function($){
	/* hoverIntent by Brian Cherne */
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
	
})(jQuery);

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License

function parseUri (str) {
	var	o   = parseUri.options,
		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i   = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};


;(function($) {
					
	/**
	 * jQuery custom selectboxes
	 * 
	 * Copyright (c) 2008 Krzysztof Suszynski (suszynski.org)
	 * Licensed under the MIT License:
	 * http://www.opensource.org/licenses/mit-license.php
	 *
	 * @version 0.6.1
	 * @category visual
	 * @package jquery
	 * @subpakage ui.selectbox
	 * @author Krzysztof Suszynski <k.suszynski@wit.edu.pl>
	**/
	$.fn.selectbox = function(options){
		/* Default settings */
		var settings = {
			className: 'jquery-selectbox',
			animationSpeed: "fast",
			listboxMaxSize: 10,
			replaceInvisible: false
		};
		var commonClass = 'jquery-custom-selectboxes-replaced';
		var listOpen = false;
		var showList = function(listObj) {
			var selectbox = listObj.parents('.' + settings.className + '');
			listObj.slideDown(settings.animationSpeed, function(){
				listOpen = true;
			});
			selectbox.addClass('selecthover');
			$(document).bind('click', onBlurList);
			return listObj;
		};
		var hideList = function(listObj) {
			var selectbox = listObj.parents('.' + settings.className + '');
			listObj.slideUp(settings.animationSpeed, function(){
				listOpen = false;
				$(this).parents('.' + settings.className + '').removeClass('selecthover');
			});
			$(document).unbind('click', onBlurList);
			return listObj;
		};
		var onBlurList = function(e) {
			var trgt = e.target;
			var currentListElements = $('.' + settings.className + '-list:visible').parent().find('*').andSelf();
			if($.inArray(trgt, currentListElements)<0 && listOpen) {
				hideList( $('.' + commonClass + '-list') );
			}
			return false;
		};
		/* Processing settings */
		settings = $.extend(settings, options || {});
		/* Wrapping all passed elements */
		return this.each(function() {
			var _this = $(this);
			if(_this.filter(':visible').length == 0 && !settings.replaceInvisible)
				return;
			var replacement = $(
				'<div class="' + settings.className + ' ' + commonClass + '">' +
					'<div class="' + settings.className + '-moreButton" />' +
					'<div class="' + settings.className + '-list ' + commonClass + '-list" />' +
					'<span class="' + settings.className + '-currentItem" />' +
				'</div>'
			);
			$('option', _this).each(function(k,v){
				var v = $(v);
				var listElement =  $('<span class="' + settings.className + '-item value-'+v.val()+' item-'+k+'">' + v.text() + '</span>');	
				listElement.click(function(){
					var thisListElement = $(this);
					var thisReplacment = thisListElement.parents('.'+settings.className);
					var thisIndex = thisListElement[0].className.split(' ');
					for( k1 in thisIndex ) {
						if(/^item-[0-9]+$/.test(thisIndex[k1])) {
							thisIndex = parseInt(thisIndex[k1].replace('item-',''), 10);
							break;
						}
					};
					var thisValue = thisListElement[0].className.split(' ');
					for( k1 in thisValue ) {
						if(/^value-.+$/.test(thisValue[k1])) {
							thisValue = thisValue[k1].replace('value-','');
							break;
						}
					};
					thisReplacment
						.find('.' + settings.className + '-currentItem')
						.text(thisListElement.text());
					thisReplacment
						.find('select')
						.val(thisValue)
						.triggerHandler('change');
					var thisSublist = thisReplacment.find('.' + settings.className + '-list');
					if(thisSublist.filter(":visible").length > 0) {
						hideList( thisSublist );
					}else{
						showList( thisSublist );
					}
				}).bind('mouseenter',function(){
					$(this).addClass('listelementhover');
				}).bind('mouseleave',function(){
					$(this).removeClass('listelementhover');
				});
				$('.' + settings.className + '-list', replacement).append(listElement);
				if(v.is(':selected')) {
					$('.'+settings.className + '-currentItem', replacement).text(v.text());
				}
			});
			replacement.click(function(){
				var thisMoreButton = $(this).find('.' + settings.className + '-moreButton');
				var otherLists = $('.' + settings.className + '-list')
					.not(thisMoreButton.siblings('.' + settings.className + '-list'));
				hideList( otherLists );
				var thisList = thisMoreButton.siblings('.' + settings.className + '-list');
				if(thisList.filter(":visible").length > 0) {
					hideList( thisList );
				}else{
					showList( thisList );
				}
			}).bind('mouseenter',function(){
				$(this).addClass('morebuttonhover');
			}).bind('mouseleave',function(){
				$(this).removeClass('morebuttonhover');
			});
			_this.hide().replaceWith(replacement).appendTo(replacement);
			var thisListBox = replacement.find('.' + settings.className + '-list');
			var thisListBoxSize = thisListBox.find('.' + settings.className + '-item').length;
			if(thisListBoxSize > settings.listboxMaxSize)
				thisListBoxSize = settings.listboxMaxSize;
			if(thisListBoxSize == 0)
				thisListBoxSize = 1;	
			var thisListBoxWidth = Math.round(_this.width()+5);
			thisListBoxWidth = ($.browser.safari) ? thisListBoxWidth * 0.94 : ($.browser.msie && $.browser.version == 6)? thisListBoxWidth * 1.05: thisListBoxWidth;
			replacement.css('width', thisListBoxWidth + 'px');
		});
	};
	
	$.fn.unselectbox = function(){
		var commonClass = 'jquery-custom-selectboxes-replaced';
		return this.each(function() {
			var selectToRemove = $(this).filter('.' + commonClass);
			selectToRemove.replaceWith(selectToRemove.find('select').show());
		});
	};
	
	/*
		Copyright (c) 2009 MCIL FilterForm
	*/
	$.fn.filterForm = function(options) {
		if (!this.length) {
			options && options.debug && window.console && console.warn( "nothing selected, can't create, returning nothing" );
			return;
		}

		// check if a destinationForm for this form was already created
		var destinationForm = $.data(this[0], 'destinationForm');
		if (destinationForm) {
			return destinationForm;
		}
		
		// if a destinationForm object is not created, instantiate a new one
		destinationForm = new $.destinationForm(options);
		$.data(this[0], 'destinationForm', destinationForm);
		
		return destinationForm;
	};
	
	$.destinationForm = function(options) {
		var obj = this;
		var settings = $.extend({}, $.destinationForm.defaults, options);
		var domain = '';
		
		switch (parseUri(location.href).host) {
			case '10.0.0.185':
			domain = '/html/';
			break;
			case 'stg.millenniumhotels.com':
			domain = 'http://stg.millenniumhotels.com/opencms/opencms/millennium/cn/';
			break;
			case 'www.millenniumhotels.com.sg':
			domain = 'http://www.millenniumhotels.com.sg/mcilchina/';
			break;
			default:
			domain = '/'; // Production
			break;
		}
		//var domain = '';
		
		this.city = $(settings.city);
		this.duration = $(settings.duration);
		this.activity = $(settings.activity);
		this.selections = $([settings.city, settings.duration, settings.activity].join(','));
		this.submitButton = $(settings.submitButton);
		
		/* public properties */
		this.getSelectedValue = function(property) {
			return obj[property].val();
		};
		
		this.setSelectedValue = function(property, value) {
			obj[property].val(value);
			obj[property].data('hasChanged', true);
			// Update selectbox
			var listItem = obj[property].parents('.jquery-custom-selectboxes-replaced').find('.value-'+value);
			var currentItem = obj[property].parents('.jquery-custom-selectboxes-replaced').find('.jquery-selectbox-currentItem');
			currentItem.text(listItem.text());
		};
		
		/* public methods */
		this.filter = function() {
			if (obj.hasAnySelectionChanged(obj.city)) {
				// if city selection has changed refresh all content
				obj.filterHotels();
				obj.filterPromotions();
				obj.filterEvents();
				obj.filterPlacesOfInterests();
			} 
			else if (obj.hasAnySelectionChanged(obj.duration)) {
				obj.filterPromotions();
				obj.filterEvents();
			}
			else if (obj.hasAnySelectionChanged(obj.activity)) {
				obj.filterEvents();
				obj.filterPlacesOfInterests();
			}
			else if (obj.hasAnySelectionChanged(obj.duration, obj.activity)) {
				
			}
			
			// Reset each selection hasChanged property to false
			obj.selections.data('hasChanged', false);
			
			return false;
		};
		
		this.submitButton.click(function() {
			// Begin : Omniture tracking for Ajax Search parameters
			var s=s_gi('millenniumhotelstst'); //test
			s.dc=122;
			s.visitorNamespace='millenniumhotels';
			s.linkTrackVars='events,eVar26';
			s.linkTrackEvents='event21';
			s.events='event21';
			var s_duration=document.getElementById('duration');
			var s_city=document.getElementById('city');
			var s_activity=document.getElementById('activity');
			s.eVar26=s_duration.options[s_duration.selectedIndex].value+'|'+s_city.options[s_city.selectedIndex].value+'|'+s_activity.options[s_activity.selectedIndex].value;
			s.tl(this,'o');
			// End : Omniture tracking for Ajax Search parameters

			settings.onSubmitting.call(obj);
			return false;
		});
		
		this.selections.change(function() {
			$(this).data('hasChanged', true);
			trace($(this).attr('id')+' has changed? '+hasChanged(this));
			settings.onSelectionChanged.call(this, obj);
		});
		
		this.filterHotels = function() {
			var selectedCity = obj.getSelectedValue('city');
			var dataFile = domain + 'hotels/'+selectedCity+'.xml?noCache='+new Date().getTime();
			$.ajax({
				type: 'GET',
				url: dataFile,
				dataType: 'xml',
				beforeSend: function() {
					return settings.onHotelsFiltering.call(obj, $(settings.hotelsContainer));
				},
				success: function(data, textStatus) {
					settings.onHotelsFiltered.call(obj, $(settings.hotelsContainer), data, textStatus);
					settings.onContentRendered.call(obj);
				}
			});
			
		};
		
		this.filterPromotions = function() {
			var selectedCity = obj.getSelectedValue('city');
			var selectedDuration 	= obj.getSelectedValue('duration');
			
			var dataFile = domain + 'promotions/promotions.xml?noCache='+new Date().getTime();
			$.ajax({
				type: 'GET',
				url: dataFile,
				dataType: 'xml',
				beforeSend: function() {
					return settings.onPromotionsFiltering.call(obj, $(settings.promotionsContainer));
				},
				success: function(data, textStatus) {
					settings.onPromotionsFiltered.call(obj, $(settings.promotionsContainer), data, textStatus);
					settings.onContentRendered.call(obj);
				}
			});
		};
		
		this.filterEvents = function() {
			var selectedCity = obj.getSelectedValue('city');
			var selectedDuration 	= obj.getSelectedValue('duration');
			var selectedActivity = obj.getSelectedValue('activity');
			
			var dataFile = domain + 'events/'+selectedCity+'.xml?noCache='+new Date().getTime();
			$.ajax({
				type: 'GET',
				url: dataFile,
				dataType: 'xml',
				beforeSend: function() {
					return settings.onEventsFiltering.call(obj, $(settings.eventsContainer));
				},
				success: function(data, textStatus) {
					settings.onEventsFiltered.call(obj, $(settings.eventsContainer), data, textStatus);
					settings.onContentRendered.call(obj);
				}
			});
		};
		this.filterPlacesOfInterests = function() {
			var selectedCity = obj.getSelectedValue('city');
			var selectedActivity = obj.getSelectedValue('activity');
			
			var dataFile = domain + 'places-of-interests/'+selectedCity+'.xml?noCache='+new Date().getTime();
			$.ajax({
				type: 'GET',
				url: dataFile,
				dataType: 'xml',
				beforeSend: function() {
					return settings.onPlacesOfInterestsFiltering.call(obj, $(settings.placesOfInterestsContainer));
				},
				success: function(data, textStatus) {
					settings.onPlacesOfInterestsFiltered.call(obj, $(settings.placesOfInterestsContainer), data, textStatus);
					settings.onContentRendered.call(obj);
				}
			});
		};
		
		this.hasAnySelectionChanged = function() {
			if (arguments.length) {
				if (arguments.length == 1) {
					return hasChanged(arguments[0]);
				}
				else {
					var args = $.makeArray(arguments);
					var values = [];
					
					$.each(args, function() {
						values.push(hasChanged(this));
					});
					
					return ($.inArray(true, values) != -1);
				}
			}
		};
		
		/* private methods */
		var hasChanged = function(element) {
			var result = $(element).data('hasChanged');
			if (result) {
				return result;
			}
			else {
				return false;
			}
		};
	};
	
	$.destinationForm.defaults = {
		city: '#city',
		duration: '#duration',
		activity: '#activity',
		hotelsContainer: '.hotels.box',
		promotionsContainer: '.promotions.box',
		eventsContainer: '.events.box',
		placesOfInterestsContainer: '.places-of-interests.box',
		submitButton: '#filterButton',
		onSelectionChanged: function(form) {},
		onHotelsFiltering: function(container) {return true;},
		onHotelsFiltered: function(container, hotelsData, textStatus) {},
		onPromotionsFiltering: function(container) {return true;},
		onPromotionsFiltered: function(container, promotionsData, textStatus) {},
		onEventsFiltering: function(container) {return true;},

		onEventsFiltered: function(container, eventsData, textStatus) {},
		onPlacesOfInterestsFiltering: function(container) {return true;},
		onPlacesOfInterestsFiltered: function(container, POIsData, textStatus) {},
		onContentRendered: function() {$('ul li:last-child').addClass('last-child');},
		onSubmitting: function() {this.filter();}
	};
	
})(jQuery);

/**
 * jQuery.browser.mobile (http://detectmobilebrowser.com/)
 *
 * jQuery.browser.mobile will be true if the browser is a mobile device
 *
 **/
(function(a){jQuery.browser.mobile=/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))})(navigator.userAgent||navigator.vendor||window.opera);

/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Version 2.1.3-pre
 */

(function($){

$.fn.bgiframe = ($.browser.msie && /msie 6\.0/i.test(navigator.userAgent) ? function(s) {
    s = $.extend({
        top     : 'auto', // auto == .currentStyle.borderTopWidth
        left    : 'auto', // auto == .currentStyle.borderLeftWidth
        width   : 'auto', // auto == offsetWidth
        height  : 'auto', // auto == offsetHeight
        opacity : true,
        src     : 'javascript:false;'
    }, s);
    var html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
                   'style="display:block;position:absolute;z-index:-1;'+
                       (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
                       'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
                       'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
                       'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
                       'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
                '"/>';
    return this.each(function() {
        if ( $(this).children('iframe.bgiframe').length === 0 )
            this.insertBefore( document.createElement(html), this.firstChild );
    });
} : function() { return this; });

// old alias
$.fn.bgIframe = $.fn.bgiframe;

function prop(n) {
    return n && n.constructor === Number ? n + 'px' : n;
}




})(jQuery);

$(function() {
	$('ul li:last-child').addClass('last-child');
	$('.content .introduction').css({'opacity': 0.8});
	$('#city,#activity,#duration').selectbox();
	setTodayDate();
	
	$('select#chinaHotels').change(function() {
		var url = $(this).val();
		$(this).val('');
		location.href = url;
	});
	
	$('#topnav > ul > li').hoverIntent({
		over: function() {
			$(this).find('ul').show();	
			return false;
		},
		out: function() {
			$(this).find('ul').hide();
			return false;
		}
	});
	
	var selectHotels = $(".selectHotels").each(function(e) {
		var $this = $(this);
		$this.children("h2").click(function() {
			if(jQuery.browser.mobile) {
				$this.children('.hotelslist').toggle();
			}
			else
				$this.children('.hotelslist').toggle();
		});
		
		// hide hotelslist when clicking anywhere else
		$(document).bind('click', function(e) {
			if ($.inArray(e.target, $this.find('*').andSelf()) < 0)
				$this.children('.hotelslist').hide();
		});
	});
});

function trace(value) {
	if (window.console) { window.console.log(value); }
};
