/*
	Last published on : 03-Sep-09 10:44
	Location          : \commercial\destinationguide\cms\destinationguide\static\js
	Filename          : dg-functions.js
*/
/*
	Last published on : 22 June 2009
	Location          : \commercial\destinationguide\cms\destinationguide\static\js
	Filename          : dg-functions.js
*/

if (!console) { 
  var console = {
    log: function(msg) {}
  }
}
var destinationGuide = {
	extras: new Array( ) ,
	layover: null ,
	bookerTab: "booker-flights" ,
	weatherTab: "average-temperature" ,
	changeCountry: null ,
	closeCountry: null ,
	isChangeCountry: false,
	Calendar: {
		element: null ,
		date: new Date( ) ,
		monthOnFirstIndex: null,
		heading: null ,
		currentField: null ,
		currentNodeId: "" ,
		
		readDate: function( dateStr )
		{
			if( /^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/.test( dateStr ) == false )
			{
				destinationGuide.Calendar.date = new Date( );
				return;
			}

			dateStr = dateStr.split( "/" );
			var selectedDate = new Date( );
			selectedDate.setDate( dateStr[0] );
			selectedDate.setMonth(parseInt(dateStr[1]-1));
			selectedDate.setFullYear( dateStr[2] );
			
			destinationGuide.Calendar.date = selectedDate;
			destinationGuide.Calendar.setDate( );
			
			var monthFirstOption = document.getElementById("booker-calendar-month").options[0].value;
			monthFirstOption = monthFirstOption.substring(5,monthFirstOption.length);
			destinationGuide.Calendar.monthOnFirstIndex = monthFirstOption;
		} ,
		
		showHere: function( e )
		{
			if( !e ) var e = window.event;
			var targetNode = !!e.target ? e.target : e.srcElement;
			if( destinationGuide.Calendar.element && ( destinationGuide.Calendar.element.style.display == "block" && destinationGuide.Calendar.currentNodeId == targetNode.id ) )
			{
				return false;
			}
			
			destinationGuide.Calendar.readDate( targetNode.value );
			if( destinationGuide.Calendar.element == null )
			{
				destinationGuide.Calendar.createCalendar( );
			}
			
			destinationGuide.Calendar.currentField = targetNode;
			destinationGuide.Calendar.display( targetNode );
		} ,
		
		insertDate: function( day )
		{
			var theDate = destinationGuide.Calendar.date;
			var month = parseInt( theDate.getMonth( ) + 1 );
			var year =theDate.getFullYear( );
			day = parseInt( day );
			
			if( day < 10 ) var day = "0" + day;
			if( month < 10 ) var month = "0" + month;
			
			destinationGuide.Calendar.currentField.value = day + "/" + month + "/" + year;
			destinationGuide.Calendar.hide( );
		} ,
		
		createCalendar: function( )
		{
			destinationGuide.Calendar.element = document.getElementById( "booker-calendar" );
			destinationGuide.Calendar.heading = document.getElementById( "booker-calendar-top" );
			destinationGuide.Calendar.table = destinationGuide.Calendar.element.getElementsByTagName( "tbody" )[0];
			//booker-calendar-month event aan hangen (onchange)
			
			var anchors = destinationGuide.Calendar.element.getElementsByTagName( "A" );
			if( anchors[0] && anchors[0].className.indexOf( "close-calendar" ) != -1 )
			{
				addEventHandler( anchors[0] , "click" , function( e ) 
					{
						if( !e ) var e = window.event;
						
						destinationGuide.Calendar.hide( );
						
						cancelEvent( e );
						return false;
					} );
			}
			
			addEventHandler( document.getElementById( "booker-calendar-month" ) , "change" , destinationGuide.Calendar.updateMonth );
		} ,
		
		updateMonth: function( e )
		{
			if( !e ) var e = window.event;
			var targetNode = !!e.target ? e.target : e.srcElement;
			destinationGuide.Calendar.date.setMonth( (targetNode.options[targetNode.selectedIndex].value % 100) - 1);
			destinationGuide.Calendar.date.setYear(targetNode.options[targetNode.selectedIndex].value.slice(0,4));
			destinationGuide.Calendar.createMonth(destinationGuide.Calendar.date.getMonth() );
		} ,
		
		createMonth: function(index )
		{
			if( !destinationGuide.Calendar.table ) return;
			
			var table = destinationGuide.Calendar.table;
			var rows = table.getElementsByTagName( "tr" );
			
			for( var i = 0; i < rows.length; i++ )
			{
				if( rows[i].className.indexOf( "head" ) == -1 ) 
				{
					table.removeChild( rows[i] ); i--;
				}
			}
			
			var today = new Date( );
			var theDate = destinationGuide.Calendar.date;
			var numDays = destinationGuide.Calendar.getNumDays( theDate.getMonth( ) , theDate.getFullYear( ) );
			var firstDate = theDate;
			firstDate.setDate( 1 );
			var firstDay = firstDate.getDay( ) == 0 ? 6 : ( firstDate.getDay( ) - 1 );
			firstDate = null;
			var numRows = Math.ceil( ( firstDay + numDays ) / 7 );
			var numDayCount = 1;
			for( var currentRow = 0; currentRow < numRows; currentRow++ )
			{
				var tableRow = document.createElement( "TR" );
				
				for( var currentDay = 1; currentDay <= 7; currentDay ++ )
				{
					var tableCell = document.createElement( "TD" );
					
					if( currentRow == 0 && currentDay <= firstDay )
					{
						tableCell.appendChild( document.createTextNode( "" ) );
					}else if( numDayCount <= numDays )
					{
						tableCell.appendChild( document.createTextNode( numDayCount ) );
						
						if( numDayCount < today.getDate( ) && ( today.getFullYear( ) == theDate.getFullYear( ) && today.getMonth( ) == theDate.getMonth( ) ) )
						{
							tableCell.className = "unavailable";
						}else if ( theDate.getFullYear() < today.getFullYear() || (theDate.getFullYear() == today.getFullYear() && theDate.getMonth() < today.getMonth()))
						{
							tableCell.className = "unavailable";
						}else
						{
							tableCell.onmouseover = function( )
							{
								this.className = "pick-me";
							};
							
							tableCell.onmouseout = function( )
							{
								this.className = "";
							};
							
							addEventHandler( tableCell , "click" , function( e )
							{
								if( !e ) var e = window.event;
								var targetNode = !!e.target ? e.target : e.srcElement;
								destinationGuide.Calendar.insertDate( targetNode.innerHTML );
							} );
						}
						
						numDayCount++;
					}else 
					{
						tableCell.appendChild( document.createTextNode( "" ) );
					}
					
					tableRow.appendChild( tableCell );
				}
				
				table.appendChild( tableRow );
			}
			var selectedIndex = 0;
			var newDate = new Date();
			
			//var selectMonth = destinationGuide.Calendar.currentField.value;
			//selectMonth = selectMonth.substring(3,5);
			//alert("currentField"+selectMonth);
			
			/*
			if (theDate.getYear() == newDate.getYear()) {
				selectedIndex = theDate.getMonth() - newDate.getMonth();
				
				if(newDate.getMonth() == parseInt(theDate.getMonth()-1) || newDate.getMonth() == parseInt(destinationGuide.Calendar.monthOnFirstIndex - 2)) {
					//alert("minus");
					selectedIndex = selectedIndex - 1;
				}
			} else {
				selectedIndex = (12 + theDate.getMonth()) - newDate.getMonth();
				var temp = parseInt(destinationGuide.Calendar.monthOnFirstIndex);
				temp += 12;
				//alert("he ->"+temp);
				if(newDate.getMonth() == parseInt((12 + theDate.getMonth())-1) || newDate.getMonth() == parseInt(temp - 2)) {
					selectedIndex = selectedIndex - 1;
					alert("if1")
				} else if(newDate.getMonth() == parseInt(theDate.getMonth()-1) || newDate.getMonth() == parseInt(destinationGuide.Calendar.monthOnFirstIndex - 2)) { 
					selectedIndex = selectedIndex - 1;
					alert("if2")
				}
			}
			*/
 			document.getElementById( "booker-calendar-month" ).selectedIndex = searchMonth(index + 1);
 			
 			
			
		} ,
		
		setDate: function( )
		{

		} ,
		
		getNumDays: function( month , year )
		{
			switch( month )
			{
				case 1:
					if( ( year % 4 == 0 && year % 100 != 0 ) || year % 400 == 0 )
					{
						return 29;
					}else 
					{
						return 28;
					}
					break;
				
				case 3: case 5: case 8: case 10:
					return 30;
					break;
				default:
					return 31;
					break;
			}
		
			return -1;
		} ,
		
		display: function( node ) 
		{
			if( !node ) return;
			if( node.parentNode.nodeName == "LABEL" )
			{
				var label = node.parentNode;
			}else
			{
				var label = node.previousSibling;
				if( !label || !label.nodeType ) return;
				if( label.nodeType != 1 )
				{
					label = label.previousSibling;
				}
				if( !label || ( label.nodeType != 1 || label.nodeName != "LABEL" ) ) return;
			}
			
			var theLabel = label.innerHTML;
			if( theLabel.indexOf( "<" ) > 0 ) 
			{
				theLabel = theLabel.substr( 0 , theLabel.indexOf( "<" ) );
			}
			destinationGuide.Calendar.heading.innerHTML = theLabel;
			
			/* For Internet Explorer 6's Eyes Only */
			/*@cc_on
				@if( @_jscript_version <= 5.6 )

				var hideMe = ["cabin-class","select-adults","select-kids","select-baby","return-hour","return-minute","till-date"];
				for( var i = 0; i < hideMe.length; i++ )
				{
					var obj = document.getElementById( hideMe[i] );
					if( obj ) obj.style.visibility = "visible";
					if( hideMe[i] == "till-date" )
					{
						if( obj && obj.parentNode ) obj.parentNode.style.visibility = "visible";
					}
				}
			/*@end @*/
			
			var parentNode = node.parentNode;
			
			if( parentNode.nodeName == "LABEL" && parentNode.parentNode )
			{
				//node = parentNode;
				//parentNode = parentNode.parentNode;
			}
			
			if( node.nextSibling )
			{
				parentNode.insertBefore( destinationGuide.Calendar.element , node.nextSibling );
			}else
			{
				parentNode.appendChild( destinationGuide.Calendar.element );
			}
			
			var selectMonth = destinationGuide.Calendar.currentField.value;
			selectMonth = selectMonth.substring(3,5);
			
			destinationGuide.Calendar.createMonth( selectMonth - 1);
			destinationGuide.Calendar.currentNodeId = node.id;
			destinationGuide.Calendar.element.style.display = "block";
			destinationGuide.Calendar.element.style.zIndex = 9999;
			
			/* For Internet Explorer 6's Eyes Only */
			/*@cc_on
				@if( @_jscript_version <= 5.6 )

				var hideMe = ["cabin-class","select-adults","select-kids","select-baby"];
				for( var i = 0; i < hideMe.length; i++ )
				{
					var obj = document.getElementById( hideMe[i] );
					if( obj ) obj.style.visibility = "hidden";
				}
				
				if( destinationGuide.Calendar.currentNodeId == "from-date" )
				{
					var obj = document.getElementById( "till-date" );
					if( obj ) obj.style.visibility = "hidden";
					if( obj && obj.parentNode == "LABEL" ) obj.parentNode.style.visibility = "hidden";
				}
				
				if( destinationGuide.Calendar.currentNodeId != "dropoff-date" )
				{
					var obj = document.getElementById( "return-hour" );
					if( obj ) obj.style.visibility = "hidden";
					
					var obj = document.getElementById( "return-minute" );
					if( obj ) obj.style.visibility = "hidden";
				}
			/*@end @*/
		} ,
		
		hide: function( )
		{
			if( destinationGuide.Calendar.element )
			{
				destinationGuide.Calendar.element.style.display = "none";

				/* For Internet Explorer 6's Eyes Only */
				/*@cc_on
					@if( @_jscript_version <= 5.6 )

					var hideMe = ["cabin-class","select-adults","select-kids","select-baby","return-hour","return-minute","till-date"];
					for( var i = 0; i < hideMe.length; i++ )
					{
						var obj = document.getElementById( hideMe[i] );
						if( obj ) obj.style.visibility = "visible";
						if( hideMe[i] == "till-date" )
						{
							if( obj && obj.parentNode ) obj.parentNode.style.visibility = "visible";
						}
					}
				/*@end @*/
			}
		}
	} ,
	
	init: function( )
	{
		addEventHandler( window , 'load' , destinationGuide.openCurrentDisplay );
		addEventHandler( window , 'load' , destinationGuide.addPrintButton );
		addEventHandler( window , 'load' , destinationGuide.displayExtras );
		addEventHandler( window , 'load' , destinationGuide.startBookingTool );
		addEventHandler( window , 'load' , destinationGuide.handleShowMoreWithID );
		//addEventHandler( window , 'load' , destinationGuide.initAirports );
		addEventHandler( window , 'load' , destinationGuide.tagForWebtrends );
		addEventHandler( window , 'load' , destinationGuide.callMiniBT );
    			
		addEventHandler( document , 'click' , destinationGuide.handleInternalLinks );
		addEventHandler( document , 'click' , destinationGuide.changeCountryLink );
		addEventHandler( document , 'mousedown' , destinationGuide.handleDropdownOptions );
		addEventHandler( document , 'mousedown' , destinationGuide.hideDropDownOptions );

		addEventHandler( document , 'click' , destinationGuide.handleShowAll );
		addEventHandler( document , 'click' , destinationGuide.handleShowMore );
		/* JVDB: Removed eventhandler for fixing defect 620. No listener for list item set.
                                    addEventHandler( document , 'mousedown' , destinationGuide.handleShowMoreListItem );
                                */

		addEventHandler( document , 'click' , destinationGuide.handleMapLayover );
		addEventHandler( document , 'click' , destinationGuide.handleExternalLinks );
		
	} ,
  
  setupParameters: function() {
    var parameters = new Object();
    if (window.location.search) {
      var paramArray = window.location.search.substr(1).split('&');
      var length = paramArray.length;
      for (var index = 0;index <length; index++ ) {
        var param = paramArray[index].split('=');
        var name = param[0];
        var value = typeof param[1] == "string" ? decodeURIComponent(param[1].replace(/\+/g, ' ')) : null;
        parameters[name] = value;
      }
    }
    window.parameters = parameters;
  } ,
	
	startBookingTool: function( )
	{
		var changeCountry = document.getElementById( "select-country" );
		if( changeCountry )
		{
			addEventHandler( changeCountry , 'change' , destinationGuide.changeOriginByCountry );
		}

		var changeCountryForm = document.getElementById( "change-country-form" );
		if( changeCountryForm )
		{
			addEventHandler( changeCountryForm , 'submit' , function( e )
			{
				if( !e ) var e = window.event;
				var targetNode = !!e.target ? e.target : e.srcElement;
				var changeCountryForm = document.getElementById( "change-country-form" );
				//var selectFrom = document.getElementById( "select-from-fieldset" );
				//var selectReturnType = document.getElementById( "select-return-type" );
				if( !changeCountryForm) return true;
				changeCountryForm.style.display = "none";
                                                                var bookerFlightsTab = document.getElementById( "booker-flightsTab");
                                                                bookerFlightsTab.style.display = "block"; 
				//selectFrom.style.display = "block";
				//selectReturnType.style.display = "block";
				destinationGuide.changeCountry.style.display = "block";
				if( destinationGuide.closeCountry != null && destinationGuide.closeCountry.nodeName )
				{
					destinationGuide.closeCountry.style.display = "none";
				}
	
				// Change the Action url for ebt.
				var ebtForm = document.getElementById( "ebt-flight-searchform" );
				var country = document.getElementById('select-country');
				ebtForm.action = "/travel/"+ country.value.toLowerCase()  + "_en/apps/ebt/ebt_home.htm";

				destinationGuide.changeCountry = null;
				destinationGuide.closeCountry = null;
				cancelEvent( e );
				//handle synchronous because cabin classes is faster than 
				//departure airports
				//dwr.engine.setAsync(false);
				//destinationGuide.handleDepartureAirports();
				//destinationGuide.handleCabinClasses();
				//dwr.engine.setAsync(true);
                                                                destinationGuide.isChangeCountry = true;
				//destinationGuide.callMiniBT();
				handleData("");

				return false;
			} );
		}
	
		var departDate = document.getElementById( "depart-date" );
		if( departDate )
		{
			addEventHandler( departDate , 'focus' , destinationGuide.Calendar.showHere );
		}
		
		var returnDate = document.getElementById( "return-date" );
		if( returnDate )
		{
			addEventHandler( returnDate , 'focus' , destinationGuide.Calendar.showHere );
		}
		
		var checkinDate = document.getElementById( "checkin-date" );
		if( checkinDate )
		{
			addEventHandler( checkinDate , 'focus' , destinationGuide.Calendar.showHere );
		}
		
		var checkoutDate = document.getElementById( "checkout-date" );
		if( checkoutDate )
		{
			addEventHandler( checkoutDate , 'focus' , destinationGuide.Calendar.showHere );
		}
		
		var pickupDate = document.getElementById( "pickup-date" );
		if( pickupDate )
		{
			addEventHandler( pickupDate , 'focus' , destinationGuide.Calendar.showHere );
		}
		
		var dropoffDate = document.getElementById( "dropoff-date" );
		if( dropoffDate )
		{
			addEventHandler( dropoffDate , 'focus' , destinationGuide.Calendar.showHere );
		}
		
		var fromDate = document.getElementById( "from-date" );
		if( fromDate )
		{
			addEventHandler( fromDate , 'click' , destinationGuide.Calendar.showHere );
		}
		
		var tillDate = document.getElementById( "till-date" );
		if( tillDate )
		{
			addEventHandler( tillDate , 'click' , destinationGuide.Calendar.showHere );
		}
		
		var differentDropoff = document.getElementById( "different-dropoff" );
		if( differentDropoff )
		{
			addEventHandler( differentDropoff , 'click' , function( e )
			{
				if( !e ) var e = window.event;
				var targetNode = !!e.target ? e.target : e.srcElement;
				var dropoffField = document.getElementById( "dropoff-field" );
				
				dropoffField.style.display = !!targetNode.checked ? "block" : "none";
			} );
		}
		
		var selectTo = document.getElementById('select-to-airport');
		if (selectTo)
		{
			addEventHandler( selectTo , 'keyup' , function( e )
			{
				destinationGuide.handleDestinationAirports();
			});
		}
		
	} ,
	
	openCurrentDisplay: function( hash )
	{
		if( hash == undefined || typeof( hash ) != "string" ) var hash = window.location.hash;
		if( hash == undefined ) return false;
		if( hash.substr( 0 , 1 ) == "#" ) hash = hash.substr( 1 );
		if( hash == "" || !hash ) return false;
		var targetNode = document.getElementById( hash );
		if( !targetNode ) return false;
		var firstAnchor = targetNode.getElementsByTagName( "A" );
   
		if( hash == "walkinglay" ) {DGKLM.showThemedTour(hash);}
		if( firstAnchor.length > 0 )
		{
			firstAnchor = firstAnchor[0];
		}

		if( targetNode.className.indexOf( "open" ) == -1 )
		{
			targetNode.className = targetNode.className + " open";
			
			if( firstAnchor.nodeName && firstAnchor.nodeName == "A" )
			{
				if( firstAnchor.className.indexOf( "show-more" ) != -1 )
				{
					var strCaption = !!firstAnchor.innerText ? firstAnchor.innerText : firstAnchor.innerHTML;
					var strAlternative = firstAnchor.getAttribute( "rev" );
					firstAnchor.innerHTML = strAlternative;
					firstAnchor.setAttribute( "rev" , strCaption );
				}
			}
		}
	} ,
	
	addPrintButton: function( )
	{
		var parentNode = document.getElementById('user-functions');
		if( parentNode == undefined || parentNode == null ) return;
		/*var printLink = document.createElement( "A" );
		printLink.setAttribute( "href" , "javascript:window.print( );" );
		printLink.setAttribute( "rel" , "nofollow" );
		printLink.className = "print-function";
		printLink.appendChild( document.createTextNode( "Print this page" ) );
		parentNode.appendChild( printLink );*/
    $('print_page').style.display = '';
	} ,	
	tagForWebtrends: function(){
		//all text links in the content of city overview page
		var cityContent = document.getElementById("dg-content") != null ? document.getElementById("dg-content") : "";
		var contentTextLinks = cityContent != "" ? cityContent.getElementsByTagName("A") : "";
		var tmp = document.getElementById("mfInfoPage").value;
		var topicCode = tmp.substring(tmp.lastIndexOf('|')+1,tmp.length);
		topicCode = topicCode.substring(0,topicCode.indexOf("page"));
	   
	   if(contentTextLinks.length != 0) {
			for(var i = 0; i < contentTextLinks.length; i++ ) {
				if(contentTextLinks[i].parentNode.parentNode.className.indexOf( "dg-main-content" ) != -1 ){
					contentTextLinks[i].onclick = function(){trackCityPageInternal("link_text","");};
				}
				
				//weathere link on city overview page
				if(contentTextLinks[i].parentNode.parentNode.className.indexOf( "weather-info" ) != -1 ){
					contentTextLinks[i].onclick = function(){trackCityPageInternal("link_weather",this.innerHTML);};
				}
				
				// link events on the event page
				if(contentTextLinks[i].parentNode.parentNode.className.indexOf( "addition events" ) != -1 ){
					contentTextLinks[i].onclick = function(){trackCityPageInternal("link_events_read_more","");};
				}
				
				//pagination
				if(contentTextLinks[i].parentNode.className.indexOf( "pagination" ) != -1 ){
					contentTextLinks[i].onclick = function(){trackCityPageInternal("link_events_pagenr",this.innerHTML);};
				}
				
				//restaurants list and map view and airport tabs
				if(contentTextLinks[i].parentNode.parentNode.id != null &&  contentTextLinks[i].parentNode.parentNode.id == "list-map-view" ){
					if(topicCode.indexOf("airport") != -1){
						if(document.getElementById("airport-links") != null) // multiple airport 
						{
							contentTextLinks[i].onclick = function(){trackCityPageInternal("tab_"+getStaticTopic(getPageTopicCode())+"_airportname",this.innerHTML);};
						}else 	
							contentTextLinks[i].onclick = function(){trackCityPageInternal("tab_"+getStaticTopic(getPageTopicCode()),this.innerHTML);};
					} else if(contentTextLinks[i].parentNode.parentNode.className.indexOf( "weather-tabs" ) == -1 )contentTextLinks[i].onclick = function(){trackCityPageInternal("tab_"+getStaticTopic(getPageTopicCode())+"_"+getTabView(this.className),this.title);};
				}
				
				//show on map on each item
				if(contentTextLinks[i].parentNode.parentNode.className.indexOf("item-info") != -1){
					if(contentTextLinks[i].className.toString().indexOf("link-to-map") != -1 ){
						contentTextLinks[i].onclick = function(){trackCityPageInternal("link_"+getStaticTopic(getPageTopicCode())+"_show_on_map",this.title);};
					}
				}
				
				//airport tab child
				if(contentTextLinks[i].parentNode.parentNode.id != null && contentTextLinks[i].parentNode.parentNode.id == "airport-links"){
					contentTextLinks[i].onclick = function(){trackCityPageInternal("tab_"+getStaticTopic(getPageTopicCode()),this.innerHTML);};
				}
				
				if(contentTextLinks[i].className.indexOf("internal") != -1){
					if(topicCode.indexOf("airport") != -1){
						contentTextLinks[i].onclick = function(){trackCityPageInternal("link_airport_transfer_text",this.innerHTML);};
					}
				}
				
				//themedtour back link event
				if(contentTextLinks[i].className.indexOf("previous") != -1 && contentTextLinks[i].parentNode.className.indexOf("back") != -1){
					contentTextLinks[i].onclick = function(){trackCityPageInternal("link_tour_previouspage","");};
				}
			}
		}
		
	},
	callMiniBT: function()
		{
		
		//alert("calling minibt");
			var getDiv = document.getElementsByTagName("DIV");
			var flightDiv = document.getElementById('booker-flights');
			
			if (flightDiv == undefined || flightDiv == null) return;
			  for(var i = 0; i < getDiv.length; i++ ) {
				if(getDiv[i].parentNode.id == "booker-flights" && getDiv[i].parentNode.className.indexOf("booker-tab") != -1){
					var Map1 = { }
					var countryRequest;
					/*if(destinationGuide.isChangeCountry == true)
					{
						var changeCountry = document.getElementById('select-country');
						if (changeCountry) {
							countryRequest = changeCountry.value.toLowerCase();
						}
						
					}else {*/
						countryRequest = document.getElementById("countryLocale").value;
					//}
					var languageRequest = document.getElementById("langLocale").value;
                                                                                    
					//alert("country = "+countryRequest+ " language = "+languageRequest);
					var WidgetRequest = {
			   		country : ""+countryRequest,
					lang : ""+languageRequest,
					pos : ""+countryRequest,
					type : "miniBT",
					attributes : Map1
				}
				    Widget.getWidget(WidgetRequest, handleData)
			  } 
			}
	},
	
	displayExtras: function( )
	{
		var extrasNode = document.getElementById( 'dg-content-extra' );
		if( extrasNode == undefined || extrasNode == null ) return;
		var headerNodes = extrasNode.getElementsByTagName( "H3" );
		var numHeaders = 0, nextNode = null, prevNode = null, titleNode = null;
		
		//Upcoming event links in the city overview page
		var upcomingEventLinks = extrasNode.getElementsByTagName("li"); 
		var linkEventType = "link_event";
		for(var i = 0; i < upcomingEventLinks.length; i++ ) {
			if( upcomingEventLinks[i].parentNode.parentNode.className.indexOf("extra-item") != -1 && upcomingEventLinks[i].parentNode.nodeName == "UL") {
				upcomingEventLinks[i].firstChild.onclick = function(){
							var position = getPosition(this.href,"A","dg-content-extra") != 3 ?  getPosition(this.href,"A","dg-content-extra") : "all";
							trackCityPageInternal(linkEventType+position,"");
							};
			}
		}
		
		//spotlight links in the city overview page
		var spotlightLinks = extrasNode.getElementsByTagName("A");
		for(var i = 0; i < spotlightLinks.length; i++ ) {
			if(spotlightLinks[i].parentNode.className.indexOf( "dyn-extra-item" ) != -1 || spotlightLinks[i].parentNode.tagName == "P"){
				spotlightLinks[i].onclick = function(){trackCityPageInternal(this.className != "more" ? "link_spotlight_read_more" : "link_spotlight_read_all","");};
			}
		}
		
		for( var i = 0; i < headerNodes.length; i++ )
		{
			if( !headerNodes[i].parentNode || headerNodes[i].parentNode.className.indexOf( "dyn-extra-item" ) == -1 ) continue;
			
			destinationGuide.extras[numHeaders] = headerNodes[i].parentNode;
			
			nextNode = document.createElement( "A" );
			prevNode = document.createElement( "A" );
			titleNode = document.createElement( "SPAN" );
			
			prevNode.className = "previous";
			nextNode.className = "next";
			
			prevNode.setAttribute( "href" , "#prev-extra" );
			nextNode.setAttribute( "href" , "#next-extra" );
			
			prevNode.setAttribute( "rev" , numHeaders );
			nextNode.setAttribute( "rev" , numHeaders );
			
			addEventHandler( prevNode , "click" , function( e )
			{
				if( !e ) var e = window.event;
				var targetNode = !!e.target ? e.target : e.srcElement;
				
				destinationGuide.previousExtra( targetNode , targetNode.getAttribute( "rev" ) );
				trackCityPageInternal("link_spotlight_left","");
				cancelEvent( e );
				return false;
			} );
			
			addEventHandler( nextNode , "click" , function( e )
			{
				if( !e ) var e = window.event;
				var targetNode = !!e.target ? e.target : e.srcElement;
				
				destinationGuide.nextExtra( targetNode , targetNode.getAttribute( "rev" ) );
				trackCityPageInternal("link_spotlight_right","");
				cancelEvent( e );
				return false;
			} );
			
			titleNode.appendChild( document.createTextNode( headerNodes[i].innerHTML ) );
			headerNodes[i].innerHTML = "";
			
			headerNodes[i].appendChild( prevNode );
			headerNodes[i].appendChild( titleNode );
			headerNodes[i].appendChild( nextNode );
			
			numHeaders++;
		}
	} ,
	
	previousExtra: function( element , thisIndex )
	{
		var numHeaders = ( destinationGuide.extras.length - 1 );
		var newIndex = ( thisIndex - 1 );
		if( newIndex == -1 )
		{
			newIndex = numHeaders;
		}
		
		destinationGuide.extras[newIndex].style.display = "block";
		destinationGuide.extras[newIndex].style.cssFloat = "none";
		destinationGuide.extras[thisIndex].style.display = "none";
		return false;
	} ,
	
	nextExtra: function( element , thisIndex )
	{
		thisIndex = parseInt( thisIndex );
		var numHeaders = destinationGuide.extras.length;
		var newIndex = ( thisIndex + 1 );
		if( newIndex == numHeaders )
		{
			newIndex = 0;
		}
		
		destinationGuide.extras[newIndex].style.display = "block";
		destinationGuide.extras[newIndex].style.cssFloat = "none";
		destinationGuide.extras[thisIndex].style.display = "none";
		return false;
	} ,
	
	handleInternalLinks: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		if( targetNode.nodeType != 1 || targetNode.nodeName != "A" ) return true;
		var theLink = targetNode.getAttribute( "href" );
		if( theLink == "" || theLink == undefined ) return true;
		
		//email a friend item
		if(targetNode.className.indexOf("email-a-friend-event") != -1 || targetNode.className.indexOf("email-a-friend-list") != -1){
			trackCityPageInternal("link_"+getStaticTopic(getPageTopicCode())+"_email_item",targetNode.title);
		}
		//show on map for event topic only
		if(getPageTopicCode().toString().indexOf("event") != -1 && targetNode.className.indexOf("link-to-map") != -1){
			trackCityPageInternal("link_"+getStaticTopic(getPageTopicCode())+"_show_on_map",targetNode.title);
		}
		
		if( theLink.indexOf( "#" ) == -1 ) return true;
		
		if( theLink.indexOf( "booker-" ) != -1 )
		{
			var tabContainer = document.getElementById( "booker-navigation" );
			var bookerTabs = tabContainer.getElementsByTagName( "li" );
			var currentTab = document.getElementById( destinationGuide.bookerTab );
			var newTab = document.getElementById( theLink.substr( theLink.indexOf( "#" ) + 1 ) );
			
			if( !currentTab || !newTab ) return;
			
			for( var i = 0; i < bookerTabs.length; i++ )
			{
				bookerTabs[i].className = "";
			}
			
			if( targetNode.parentNode && targetNode.parentNode.nodeName == "LI" )
			{
				targetNode.parentNode.className = "active";
			}
			
			currentTab.style.display = "none";
			newTab.style.display = "block";
			destinationGuide.bookerTab = theLink.substr( theLink.indexOf( "#" ) + 1 );
			
			crosssellingOnClick(destinationGuide.bookerTab);
			
			destinationGuide.Calendar.hide( );
			cancelEvent( e );
			return false;
		}
		
		if( theLink.indexOf( "#average-temperature" ) != -1 || theLink.indexOf( "#rainfall" ) != -1 )
		{
			var tabContainer = document.getElementById( "list-map-view" );
			var weatherTabs  = tabContainer.getElementsByTagName( "li" );
			
			for( var i = 0; i < weatherTabs.length; i++ )
			{
				weatherTabs[i].className = "";
			}
			
			var currentTab = document.getElementById( destinationGuide.weatherTab );
			var newTab = document.getElementById( theLink.substr( theLink.indexOf( "#" ) + 1 ) );
			
			if( targetNode.parentNode && targetNode.parentNode.nodeName == "LI" )
			{
				targetNode.parentNode.className = "active";
			}
			
			destinationGuide.weatherTab = theLink.substr( theLink.indexOf( "#" ) + 1 );
			if(theLink.indexOf( "#average-temperature" ) != -1) trackCityPageInternal("tab_weather_temperature",""); 
			if(theLink.indexOf( "#rainfall" ) != -1 )trackCityPageInternal("tab_weather_rainfall",""); 
			currentTab.style.display = "none";
			newTab.style.display = "block";
			cancelEvent( e );
			return false;
		}
		destinationGuide.openCurrentDisplay( theLink.substr( theLink.indexOf( "#" ) ) );
	} ,
	
	changeCountryLink: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		if( targetNode.nodeType != 1 || targetNode.nodeName != "A" ) return true;
		if( targetNode.className.indexOf( "change-country" ) == -1 ) return true;
		var changeCountryForm = document.getElementById( "change-country-form" );
                                var bookerFlightsTab = document.getElementById( "booker-flightsTab");
		//var selectFrom = document.getElementById( "select-from-fieldset" );
		//var selectReturnType = document.getElementById( "select-return-type" );
		if( !changeCountryForm) return true;
		
		var nextSibling = targetNode.nextSibling;
		if( nextSibling.nodeType != 1 ) nextSibling = nextSibling.nextSibling;
		if( nextSibling.nodeType != 1 ) nextSibling = nextSibling.nextSibling;
		var closeCountry = null;
		if( ( nextSibling.nodeType == 1 && nextSibling.nodeName == "A" ) && nextSibling.className.indexOf( "close-change-country" ) != -1 )
		{
			closeCountry = nextSibling;
		}
		
		if( targetNode.className != "close-change-country" )
		{
			changeCountryForm.style.display = "block";
                                                bookerFlightsTab.style.display = "none";
                                	//selectFrom.style.display = "none";
			//selectReturnType.style.display = "none";
			targetNode.style.display = "none";
			if( closeCountry != null && closeCountry.nodeName )
			{
				closeCountry.style.display = "block";
			}
		
			destinationGuide.changeCountry = targetNode;
			destinationGuide.closeCountry = closeCountry;
		}else
		{
			changeCountryForm.style.display = "none";
                                                bookerFlightsTab.style.display = "block";
                                	//selectFrom.style.display = "block";
			//selectReturnType.style.display = "block";
			destinationGuide.changeCountry.style.display = "block";
			if( destinationGuide.closeCountry != null && destinationGuide.closeCountry.nodeName )
			{
				destinationGuide.closeCountry.style.display = "none";
			}
		
			destinationGuide.changeCountry = null;
			destinationGuide.closeCountry = null;
		}
		trackChangeCountry();
		cancelEvent( e );
		return false;
	} ,
	
	changeOriginByCountry: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		if( !targetNode.value ) return;
	} ,
	
	handleShowAll: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		if( targetNode.nodeType != 1 ) return true;
		var nextSibling = targetNode.nextSibling;
		if( nextSibling != undefined && nextSibling.nodeType != 1 )
		{
			nextSibling = nextSibling.nextSibling;
		}
		var parentNode = targetNode.parentNode;
		if( !nextSibling ) return true;

		if( targetNode.nodeName == "A"  && nextSibling.nodeName == "OL" )
		{
			if( targetNode.className.indexOf( "expand-all" ) == -1 && targetNode.className.indexOf( "expand-none" ) == -1 )
			{
				return true;
			}
			
			var listItems = nextSibling.getElementsByTagName( "LI" );
			var firstAnchor = null;
			var isVisible = ( targetNode.className == "expand-all" ) ? true : false;
			
			for( var i = 0; i < listItems.length; i++ )
			{
				firstAnchor = listItems[i].getElementsByTagName( "A" );
				if( firstAnchor.length > 0 )
				{
					firstAnchor = firstAnchor[0];
					destinationGuide.toggleBlockVisibility( firstAnchor , listItems[i] , isVisible );
				}
			}
			
			var strCaption = !!targetNode.innerText ? targetNode.innerText : targetNode.innerHTML;
			var strAlternative = targetNode.getAttribute( "rev" );
			targetNode.innerHTML = strAlternative;
			targetNode.setAttribute( "rev" , strCaption );
			targetNode.className = ( targetNode.className == "expand-all" ) ? "expand-none" : "expand-all";
			
			var eventLabel = ( targetNode.getAttribute("rev").toString() == "Expand all" ) ? "expand_all" : "close_all";
			trackCityPageInternal("link_"+getStaticTopic(getPageTopicCode())+"_"+trim(eventLabel),"");
			cancelEvent( e );
			return false;
		}
		
		return true;
	} , 

	handleShowMore: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		if( targetNode.nodeType != 1 ) return true;
		var nextSibling = targetNode.nextSibling;
		if( nextSibling != undefined && nextSibling.nodeType != 1 )
		{
			nextSibling = nextSibling.nextSibling;
		}
		var parentNode = targetNode.parentNode;
		if( ( targetNode.nodeName == "A" && targetNode.className.indexOf( "show-more" ) != -1 ) && parentNode.nodeName == "LI" )
		{
			destinationGuide.toggleBlockVisibility( targetNode , parentNode );
			var olistNode = parentNode.parentNode;
			var ExpandAllNone = olistNode.previousSibling;	
			var allopen = true;
			var allclose = true;
			var allswitch = false;
                                        if(ExpandAllNone =="expand-all" || ExpandAllNone =="expand-none") {
			if (parentNode.className.indexOf("open") != -1) {
				for (i=0; i < olistNode.childNodes.length; i++){
                                                    if (olistNode.childNodes[i].className != null){
					if (olistNode.childNodes[i].className.indexOf("open") == -1){
						allopen = false;
						i = olistNode.childNodes.length;
					}
                                                    }	
				
				}
				if (allopen&& ExpandAllNone.className!=null && (ExpandAllNone.className.indexOf("expand-none") == -1)){
					allswitch = true;
				}
			}else{
				for (i=0; i < olistNode.childNodes.length; i++)
				{
                                                                if (olistNode.childNodes[i].className != null){
					if (olistNode.childNodes[i].className.indexOf("open") != -1){
						allclose = false;
						i = olistNode.childNodes.length;
					}
                                                                }	
		        		}
				if (allclose && ExpandAllNone.className!=null && (ExpandAllNone.className.indexOf("expand-all") == -1)){
					allswitch = true;
				}
			}
			if (allswitch){
				var strCaption = !!ExpandAllNone.innerText ? ExpandAllNone.innerText : ExpandAllNone.innerHTML;
				var strAlternative = ExpandAllNone.getAttribute( "rev" );
				ExpandAllNone.innerHTML = strAlternative;
				ExpandAllNone.setAttribute( "rev" , strCaption );
				ExpandAllNone.className = ( ExpandAllNone.className == "expand-all" ) ? "expand-none" : "expand-all";
				
		         }
 			}
 			//if (targetNode.id != "") trackCityPageInternal("Clickout - "+targetNode.id +" "+targetNode.rev);
 			//else trackCityPageInternal("Clickout - "+targetNode.parentNode.id +" "+targetNode.rev);
 			if (targetNode.id != "") trackCityPageInternal("link_"+getStaticTopic(getPageTopicCode())+"_show_more",targetNode.title);
 			else trackCityPageInternal("link_"+getStaticTopic(getPageTopicCode())+"_showmore","");
 			
			cancelEvent( e );
			return false;
		}
		
		return true;
	} ,
	
	handleShowMoreWithID: function()
	{
	destinationGuide.setupParameters();
	      if (typeof window.parameters['event_num'] == "string") {
  		var targetNode = $('item' +  window.parameters['event_num'])
  		if( targetNode == null || targetNode.nodeType != 1) return true; 
  		var nextSibling = targetNode.nextSibling;
  		if( nextSibling != undefined && nextSibling.nodeType != 1 ) {
  			nextSibling = nextSibling.nextSibling;
  		}
  		var parentNode = targetNode.parentNode;
  		if( ( targetNode.nodeName == "A" && targetNode.className.indexOf( "show-more" ) != -1 ) && parentNode.nodeName == "LI" )
  		{
  			destinationGuide.toggleBlockVisibility( targetNode , parentNode );
        window.scrollTo(0, destinationGuide.findPos( parentNode )[1]);
        //trackCityPageInternal("Clickout - "+targetNode.eventid +" "+targetNode.rev);
  			return false;
  		}
    	      }
		return true;
	},
  
	handleshowMoreWithEvent: function() {
	     destinationGuide.setupParameters();
	     if (typeof window.parameters['event_num'] == "string") {
  		var targetNode = $('item' +  window.parameters['event_num'])
  		if( targetNode == null || targetNode.nodeType != 1) return true; 
  		var nextSibling = targetNode.nextSibling;
  		if( nextSibling != undefined && nextSibling.nodeType != 1 ) {
  			nextSibling = nextSibling.nextSibling;
  		}
  		var parentNode = targetNode.parentNode;
	     	if( ( targetNode.nodeName == "LI" && parentNode.className.indexOf( "events" ) != -1 ) && parentNode.nodeName == "UL" ) {
		var links = targetNode.getElementsByTagName("A");
		var link = null;
		for(i = 0; i < links.length; i++) {
          if (links[i].className.indexOf("show-more") != -1) {
            link = links[i];
            break;
          }
        }
        if (link != null) {
          destinationGuide.toggleBlockVisibility( link , link.parentNode );
          DGKLM.showMoreEvent(link);
          window.scrollTo(0, destinationGuide.findPos( targetNode )[1]);
        }
      }
    }
  
  },
  
  findPos: function (obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
      do {
        curleft += obj.offsetLeft;
        curtop += obj.offsetTop;
    	} while (obj = obj.offsetParent);
      
      return [curleft,curtop];
    }
  },
	
	handleShowMoreListItem: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		if( targetNode.nodeType != 1 || targetNode.nodeName == "A" ) return true;
		var nextSibling = targetNode.nextSibling;
		if( nextSibling != undefined && nextSibling.nodeType != 1 )
		{
			nextSibling = nextSibling.nextSibling;
		}
		var parentNode = targetNode.parentNode;
		if( targetNode.nodeName == "LI" && parentNode.className.indexOf( "events" ) == -1 ) return;
		
		if( targetNode.nodeName == "LI" )
		{
			firstAnchor = targetNode.getElementsByTagName( "A" );
			if( firstAnchor.length > 0 )
			{
				firstAnchor = firstAnchor[0];
				destinationGuide.toggleBlockVisibility( firstAnchor , targetNode , true );
			}
			return;
		}
		
		if( parentNode.nodeName != "LI" )
		{
			for( var i = 0; i < 5; i++ )
			{
				if( !parentNode || parentNode.nodeName == "LI" ) break;
				parentNode = parentNode.parentNode;
			}
		}
		
		if( parentNode && parentNode.nodeName == "LI" )
		{
			if( parentNode.nodeName == "LI" && parentNode.parentNode.className.indexOf( "events" ) == -1 ) return;
			firstAnchor = parentNode.getElementsByTagName( "A" );
			if( firstAnchor.length > 0 )
			{
				firstAnchor = firstAnchor[0];
				destinationGuide.toggleBlockVisibility( firstAnchor , parentNode , true );
			}
		}
	} ,
	
	hideDropDownOptions: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		if( targetNode.nodeName != "A" ) return true;
		if( targetNode.className.indexOf( "show-options" ) != -1 ) return true;
		for( var i = 0; i < 10; i++ )
		{
			if( !targetNode ) break;
			if( targetNode.id == "select-options" || targetNode.id == "select-categorie" ) break;
			targetNode = targetNode.parentNode;
		}
		if( ( targetNode && targetNode.id ) && ( targetNode.id == "select-options" || targetNode.id == "select-categorie" ) ) return true;
		
		if( destinationGuide.layover != undefined && destinationGuide.layover != null )
		{
			destinationGuide.layover.style.display = "none";
			destinationGuide.layover = null;
		}
		
		var optionsNode = document.getElementById( "select-options" );
		if( optionsNode == undefined || optionsNode == null ) return true;
		optionsNode.style.display = "none";
		optionsNode = document.getElementById( "select-categorie" );
		optionsNode.style.display = "none";
		return true;
	} ,
	
	handleDropdownOptions: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		if( targetNode.nodeType != 1 || targetNode.nodeName != "SPAN" ) return true;
		if( targetNode.className.indexOf( "show-options" ) == -1 ) return true;
		var optionsNode = null, isOpening = false;
		var optionsNodeIE = null, OtherNodeSet = false;

		
		if( targetNode.id == "show-date" ) 
		{
			optionsNode = document.getElementById( "select-options" );
		}else if( targetNode.id == "show-category" )
		{
			optionsNode = document.getElementById( "select-categorie" );
		}else
		{
			return true;
		}

		if( optionsNode.offsetHeight > 1 || optionsNode.style.display == "block" )
		{
			
			optionsNode.style.display = "none";
			destinationGuide.Calendar.hide( );

			if (is_ie6up){
				if (targetNode.id == "show-date") {
					optionsNodeIE = document.getElementById( "select-categorie" );
					if (optionsNodeIE.style.display =="block"){ OtherNodeSet = true;}
				}
				if (targetNode.id == "show-category") {
					optionsNodeIE = document.getElementById( "select-options" );
					if (optionsNodeIE.style.display =="block"){ OtherNodeSet = true;}
				}
				if (!OtherNodeSet){
					optionsNodeIE = document.getElementById("extra-options-pop-ie");
					optionsNodeIE.style.display = "none";
 				}
			}


		} else
		{
			if (is_ie6up){
				optionsNodeIE = document.getElementById("extra-options-pop-ie");
				optionsNodeIE.style.display = "block"; 
			}
			
			optionsNode.style.display = "block";
			isOpening = true;

		}
		if( isOpening && targetNode.id == "show-date" ) {
			trackCityPageInternal("link_events_monthdate","");
			var inputElements = optionsNode.getElementsByTagName( "INPUT" );
			for( var i = 0; i < inputElements.length; i++ ) {
			// from-date, till-date
				if( inputElements[i].type == "text" ) {
					inputElements[i].className = "disabled";
					inputElements[i].onfocus = function( e ) {     
						var inputElements = optionsNode.getElementsByTagName( "INPUT" );
						for( var i = 0; i < inputElements.length; i++ ) {
						// check-months
							if( inputElements[i].type == "radio" ) {
								inputElements[i].checked = false;
							}
						}
						destinationGuide.selectOptionDateField( e );
					};
				}
				// check-months
				else if ( inputElements[i].type == "radio" ) {
					inputElements[i].onclick = function( e )  {
						var inputElements = optionsNode.getElementsByTagName( "INPUT" );
						for( var i = 0; i < inputElements.length; i++ ) {
						// from-date, till-date
							if( inputElements[i].type == "text" ) {
								inputElements[i].className = "disabled";
								inputElements[i].value = "dd/mm/yyyy";
							}
						}
					}
				}
			}
		}
		if(isOpening && targetNode.id == "show-category") trackCityPageInternal("link_events_category","");
		cancelEvent( e );
		return false;
	} ,
	selectOptionDateField: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		var dropDown = document.getElementById( "select-options" );
		var inputElements = dropDown.getElementsByTagName( "INPUT" );

		for( var i = 0; i < inputElements.length; i++ )
		{
			// from-date, till-date
			if( inputElements[i].type == "text" )
			{
				inputElements[i].className = "";
			}
		}
	} ,
	
	toggleBlockVisibility: function( anchorNode , blockNode , isVisible )
	{
		if( isVisible == undefined ) var isVisible = null;
		var strCaption = !!anchorNode.innerText ? anchorNode.innerText : anchorNode.innerHTML;
		var strAlternative = anchorNode.getAttribute( "rev" );
		
		if( typeof( isVisible ) == "boolean" )
		{
			if(
				( isVisible == true && blockNode.className.indexOf( "open" ) != -1 ) 
				||
				( isVisible == false && blockNode.className.indexOf( "open" ) == -1 ) )
			{
				return;
			}
		}
		
		if( blockNode.className.indexOf( "open" ) == -1 )
		{
			blockNode.className = blockNode.className + " open";
		}else
		{
			blockNode.className = blockNode.className.replace( "open" , "" );
		}
		
		anchorNode.innerHTML = strAlternative;
		anchorNode.setAttribute( "rev" , strCaption );
	} ,
	
	handleMapLayover: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		if( targetNode.nodeType != 1 ) return true;
		//show-on-map
		//show-walking-map
		//closemap
		if( targetNode.nodeName == "A" && targetNode.className.indexOf( "show-walking-map" ) != -1 )
		{
			var mapId = targetNode.href.substr( targetNode.href.indexOf( "#" ) + 1 );
			var mapNode = document.getElementById( mapId );
			if( mapNode == undefined || mapNode == null ) return true;
			var scrollTop = 0;
			if( document.documentElement && document.documentElement.scrollTop )
			{
				scrollTop = document.documentElement.scrollTop;
			}else if( document.body ) 
			{
				scrollTop = document.body.scrollTop;
			}
			
			mapNode.style.display = "block";
			mapNode.style.top = "0px";
			mapNode.style.visibility = "hidden";
			mapNode.style.top = Math.round( scrollTop + ( getWindowHeight( ) / 2 ) - ( mapNode.offsetHeight / 2 ) ) + "px";
			mapNode.style.visibility = "visible";
			
			destinationGuide.layover = mapNode;
			
			var mapImage = mapNode.getElementsByTagName( "IMG" );
			if( mapImage.length > 0 )
			{
				mapImage = mapImage[0];
				mapImage.onclick = function( )
				{
					if( !destinationGuide.layover ) return;
					destinationGuide.layover.style.display = "none";
					destinationGuide.layover = null;
				};
			}
			trackCityPageInternal("link_tour_text_map","");
			cancelEvent( e );
			return false;
		}
		
		if( targetNode.nodeName == "A" && targetNode.className.indexOf( "closemap" ) != -1 )
		{
			if( !destinationGuide.layover ) return;
			destinationGuide.layover.style.display = "none";
			destinationGuide.layover = null;
			
			cancelEvent( e );
			return false;
		}
		
		return true;
	} ,
	
	handleExternalLinks: function( e )
	{
		if( !e ) var e = window.event;
		var targetNode = !!e.target ? e.target : e.srcElement;
		if( targetNode.nodeType != 1 || targetNode.nodeName != "A" ) return true;
		var cssClass = targetNode.className.toLowerCase( );
		
		if( cssClass.indexOf( "external" ) == -1 ) return true;
		var eventValue = targetNode.title != ""? targetNode.title : targetNode.innerHTML;
		eventValue = removeWhiteSpace(eventValue);
		
		if(getPageTopicCode().toString().indexOf("airport") != -1) trackCityPageInternal("offsite_airport",eventValue);
		else if(getPageTopicCode().toString().indexOf("themedtour") != -1) trackCityPageInternal("offsite_events",eventValue);
		else trackCityPageInternal("offsite_"+getStaticTopic(getPageTopicCode()),eventValue);
		
		window.open( targetNode.href );
	
		cancelEvent( e );
		return false;
	} ,

	showMap: function( eventid )
	{
		overlayer = document.getElementById('overlay');
		maplay = document.getElementById('map');
		var test = document.getElementById('item32159');
		var test1 = document.getElementById(eventid);

		bodyHeight = document.body.offsetHeight;
		overlayer.style.display = 'block';
		overlayer.style.height = bodyHeight+'px';
		maplay.style.visibility = 'visible';
		
		//alert('showing map..');

		if( (typeof document.body.style.maxHeight) != "undefined")
		{
			
		}else
		{
			if( document.documentElement && document.documentElement.clientHeight )
			{
				y = document.documentElement.scrollTop;
				yh = document.documentElement.clientHeight;
				overlayer.style.top = '0';
				maplay.style.top = ( ( yh / 2 ) ) + y + 'px';
				maplay.style.backgroundPosition = '0 0';
			}
		}
		
		overlayer.onclick = function( )
		{
			destinationGuide.closeMap( );
		};
	} , 
	
	closeMap: function( )
	{
		overlayer = document.getElementById('overlay');
		maplay = document.getElementById('map');
		overlayer.style.display = 'none';
		maplay.style.visibility = 'hidden';
	} ,
	
	initAirports: function ()
	{
		//do synchonous initialisation of the form
		dwr.engine.setAsync(false);
		destinationGuide.handleDepartureAirports();
		
		var selectTo = document.getElementById('select-to-airport');
		var selectFrom = document.getElementById('select-from');
		
		if (selectTo && selectFrom)
		{
			var destination = selectTo.value;
			var departureCode = selectFrom.value;
			
			if (destination && departureCode) 
			{
	      		Ajax.searchDestinationAirports(destination, departureCode, function(airports)
	      		{
	      			if (airports.length > 0) 
	      			{
		      			var selectTo = document.getElementById('select-to-airport');
						if (selectTo)
						{
							selectTo.value = airports[0].name;
							selectTo.setAttribute('code', airports[0].code);
							selectTo.clazz = airports[0].clazz;							
						}
						destinationGuide.handleCabinClasses();
					}
	      		});
	      	}
	      	//back asynchronous for performance
	      	dwr.engine.setAsync(true);
		}
	} ,
	
	handleDepartureAirports: function ( )
	{
		var changeCountry = document.getElementById('select-country');
		if (changeCountry)
		{
			var country = changeCountry.value;
			if (country && country != '')
			{
				Ajax.listDepartureAirports (country, function(airports)
				{
					var selectFrom = document.getElementById('select-from');
					//remove all options
					for (var i = selectFrom.options.length - 1; i >= 0; i--) 
					{
						selectFrom.remove(i);
					}
					//add the new airports
					for (var i = 0; i < airports.length; i++) 
					{
						var option = new Option(airports[i].name, airports[i].code, airports[i].defaultAirport, airports[i].defaultAirport);
						option.clazz = airports[i].clazz;
						selectFrom[i] = option;
					}		
				});
			}
		}
	},
	
	handleDestinationAirports: function ( ) 
	{
		var selectAirport = document.getElementById('select-to-airport');
		if (selectAirport)
		{
			var destination = selectAirport.value;
			if (!destination)
			{
				var autoCompleteFill = document.getElementById('autocompletefill');
				if (autoCompleteFill)
				{
					autoCompleteFill.style.display = 'none';
				}
				return;
			} 
			var departureCode = document.getElementById('select-from').value;
			if (destination && departureCode) 
			{
	      		Ajax.searchDestinationAirports(destination, departureCode, function(airports)
	      		{
	      			var autoComplete = document.getElementById('autocomplete');
	  				var autoCompleteFill = document.getElementById('autocompletefill');
	      			if (autoComplete) 
	      			{
	      				autoComplete.innerHTML = '';
	      			}
					for (var i = 0; i < airports.length; i++)
					{
						var a = document.createElement('a');
						a.setAttribute('code', airports[i].code);
						a.setAttribute('clazz', airports[i].clazz);
						a.innerHTML = airports[i].name;
						a.onclick = function ( )
						{
							var selectTo = document.getElementById('select-to-airport');
							if (selectTo)
							{
								selectTo.value = this.innerHTML;
								selectTo.setAttribute('code', this.getAttribute('code'));
								selectTo.clazz = this.getAttribute('clazz');							
							}
							if (autoCompleteFill)
							{
								autoCompleteFill.style.display = 'none';
							}
							destinationGuide.handleCabinClasses();
							return false;
						}
						autoComplete.appendChild(a);
					}      			
					if (autoCompleteFill)
					{
						if (airports.length > 0)
						{
							autoCompleteFill.style.display = 'block';
						}
						else 
						{
							autoCompleteFill.style.display = 'none';
						}
					}
	      		});
	      	}
		}
	} ,
	
	handleCabinClasses: function ( ) 
	{
		var selectFrom = document.getElementById('select-from');
		if (selectFrom && selectFrom.selectedIndex >= 0)
		{
			var fromClass = selectFrom.options[selectFrom.selectedIndex].clazz;
		}
		var toClass = document.getElementById('select-to-airport').clazz;
		
		if (fromClass && toClass) 
		{
			CabinClass.listCabinClasses(fromClass, toClass, function(cabinClasses) 
			{
				var cabinClass = document.getElementById('cabin-class');
				//remove all options
				for (var i = cabinClass.options.length - 1; i >= 0; i--) 
				{
					cabinClass.remove(i);
				}
				//add the new cabinclasses
				for (var i = 0; i < cabinClasses.length; i++) 
				{
					cabinClass.options[i] = new Option(cabinClasses[i].text, cabinClasses[i].value, cabinClasses[i].selected, cabinClasses[i].selected);
				}
			});
		}
	}  
};

/* For Internet Explorer versions below 7, use ActiveX */
if( !window.XMLHttpRequest )
{
	window.XMLHttpRequest = function( )
	{
		var Microsoft = new Array( );
		Microsoft.push( "MSXML2.XMLHTTP.6.0" );
		Microsoft.push( "MSXML2.XMLHTTP.3.0" );

		for( var i = 0; i < Microsoft.length; i++ )
		{
			try
			{
				return new ActiveXObject( Microsoft[i] );
			}catch( e ){ }
		}

		return false;
	};
}

function initBookerHeight(){
	booker=document.getElementById("booker-main");
	if(!booker) return;
	booker.style.height=booker.offsetHeight-15+'px';
}

destinationGuide.init( );
addEventHandler( window , 'load' , initBookerHeight );

function getCategorie(fullString) {
  categorie = fullString;
  stopIndex = fullString.indexOf(":");
  if (stopIndex != -1) {
    categorie = fullString.substring(0, stopIndex);
  }
  return categorie;
}

var Email = {
	recipients: 1,
	eventNumber: 0,
    overlay:null, 
	show: function() {
		$('captcha_img').src =  $('captchaurl').value;
		$('EmailPopup').style.display = '';
                                Email.overlayBox();
		return false;
               
	},
	showEvent: function(event) {
		$('captcha_img').src =  $('captchaurl').value;
		$('EmailPopup').style.display = '';
		this.eventNumber=event;
        Email.overlayBox();
        //trackCityPageInternal("link_"+getStaticTopic(getPageTopicCode())+"_email_item",event.title);
        return false;
	},


 overlayBox: function() {
      overlayBgOpacity = 7;
      var overlayBg = document.createElement("div");
      overlayBg.setAttribute("id", "overlayBg");
      overlayBg.style.position = "absolute";
      overlayBg.style.top = "0px";
      overlayBg.style.left = "0px";
      overlayBg.style.height = Email.getDocumentHeight() + "px";
      overlayBg.style.width = Email.getDocumentWidth() + "px";
      overlayBg.style.backgroundColor = "#f7fcff";
      overlayBg.style.opacity = ".7" ;
      overlayBg.style.filter = "alpha(opacity=" + overlayBgOpacity + "0)";
      overlayBg.style.zIndex = "2";
      overlayBg.innerHTML = "<table width=\"100%\" height=\"100%\"><tr><td>&nbsp;</td></tr></table>";
 
  // Apply the DIVs as a child to BODY
     document.getElementsByTagName("body")[0].appendChild(overlayBg);
 
 //disabled select fields for IE
      var ctrl = document.getElementById("select-from"); 
      if (ctrl !=null){
         ctrl.disabled = true;
         ctrl = document.getElementById("select-adults"); 
         ctrl.disabled = true;
         ctrl = document.getElementById("cabin-class"); 
         ctrl.disabled = true;
         ctrl = document.getElementById("select-kids"); 
         ctrl.disabled = true;
         ctrl = document.getElementById("select-baby"); 
         ctrl.disabled = true;
      }
      ctrl = document.getElementById("otherKLMsites"); 
      if (ctrl !=null){
         ctrl.disabled = true;
      }
         window.scrollTo(0, 0);
 },

	getDocumentHeight: function() {
                return document.body.scrollHeight ;
                },

                getDocumentWidth: function() {
                return document.body.scrollWidth;
                },


	getElementbyClass: function(classname) {
                     var inc=0
                     var alltags=document.all? document.all : document.getElementsByTagName("*")
                     for (i=0; i<alltags.length; i++){
                       if (alltags[i].className==classname){
                          return alltags[i];
                          return;
                       }
                     }
                 },

	
	hide: function() {
    	 $('emailForm').reset();
		$('EmailPopup').style.display = 'none';
      	 $('emailError').style.display = 'none';
//remove  overlayBG 
                 document.getElementsByTagName("body")[0].removeChild(document.getElementById("overlayBg"));
//enabeled 'select' fields for IE
                 ctrl = document.getElementById("select-from"); 
                 if (ctrl !=null){
                   ctrl.disabled = false;
                   ctrl = document.getElementById("select-adults"); 
                   ctrl.disabled = false;
                   ctrl = document.getElementById("cabin-class"); 
                   ctrl.disabled = false;
                   ctrl = document.getElementById("select-kids"); 
                   ctrl.disabled = false; 
                   ctrl = document.getElementById("select-baby"); 
                   ctrl.disabled = false;
                 }
                   ctrl = document.getElementById("otherKLMsites"); 
                   if (ctrl !=null){
                         ctrl.disabled = false;
                 }
             	 return false;
                },
	
	addTextField: function() {
                        this.recipients++;
                        if (this.recipients <= 3) {
                            if (this.recipients == 2) {
                               document.getElementById( "cc2" ).style.display = '';
                            }
                            if (this.recipients == 3) {
                               document.getElementById( "cc3" ).style.display = '';
                               document.getElementById( "addccfield" ).style.display = "none";
                            }
                        }
                 },
    
    getToMailAddresses: function () {
      	var recipients = "";
      	var nodeList = $('emailForm').elements['toMailAddresses[]'];
      	if(nodeList.length) {
        	for(i = 0; i < nodeList.length; i++ ) {
          		var node = nodeList[i];
          		recipients += dwr.util.getValue(node);
          		if (i + 1 < nodeList.length) { 
          			recipients += ',' 
          		}
        	}
      	} else {
        	recipients = dwr.util.getValue(nodeList);
      	}
      	return recipients;
    }, 
    
    send: function () {
    var arr = dwr.util.getValue("url").split("?");
    urlResult=arr[0];
    var str=arr[0];
    var result = ( str.indexOf( "thingstodo-map") != -1 ) ? true: false;
    if (result) {
           urlResult = (this.eventNumber ==0) ? urlResult : (urlResult +"?" +"event_num=" + this.eventNumber);
    } else {
                result = ( str.indexOf( "events") != -1 || str.indexOf( "eventos") != -1 || 
                str.indexOf( "evenements") != -1 || str.indexOf( "eventi") != -1 || 
                str.indexOf( "evenementen") != -1) ? true: false;
                //if (result) 
                      urlResult = (this.eventNumber ==0) ? urlResult : (urlResult +"?" +"event_num=" + this.eventNumber);
    }

	    $('emailError').innerHTML = "";
	  	$('emailError').style.display = 'none';
	  	var toMailAddresses = Email.getToMailAddresses();
	  	var params = {
	    	    title: dwr.util.getValue("title"),
		    name: dwr.util.getValue("senderName"),
	    	    fromMailAddress: dwr.util.getValue("fromMailAddress"),
		    message: dwr.util.getValue("message"),
	    	    captcha: dwr.util.getValue("captcha"),
                                    url : urlResult,
		    toMailAddresses: toMailAddresses,
		    locale: window.locale
	  	}
  
	  	MailController.handleRequest(params, function(errors) {
	    	if (errors != null) {
	      		for(i = 0; i < errors.length; i++ ) {
	        		$('emailError').innerHTML += "<li>" + errors[i] + "</li>"
	      		}
	      		$('emailError').style.display = '';
	    	} else {
	      		//alert(dwr.util.getValue("sendConfirmation"));
		      	Email.hide();
	    	}
	    	var captcha_img = $('captcha_img').src.replace(/\?(.*)/, "");
		    $('captcha_img').src = captcha_img + '?' + (new Date()).getTime();
	    	$('captcha').value = '';
	    	return false;
	  	});
    }
}
var airportMap = {
	enlarge: function() {
                              document.getElementById( "airport-small-map" ).style.display = "none";
                              document.getElementById( "largeAirportMap" ).style.display = "block";
                              document.getElementById( "airport-map-image-holder" ).style.display = "none";
                              document.getElementById( "map-enlarge" ).style.display = "none";
                              document.getElementById( "footer" ).style.display = "none";
                              document.getElementById("otherKLMsites").disabled = true;
                              document.getElementById("otherKLMsites").style.visibility = "hidden";
                },
	close: function() {
                              document.getElementById( "airport-small-map" ).style.display = "block";
                              document.getElementById( "largeAirportMap" ).style.display = "none";
                              document.getElementById( "airport-map-image-holder" ).style.display = "block";
                              document.getElementById( "map-enlarge" ).style.display = "block";
                              document.getElementById( "footer" ).style.display = "block";
                              document.getElementById("otherKLMsites").disabled = false;
                              document.getElementById("otherKLMsites").style.visibility = "visible";
                 }
}
var videoTracking = {
        videoLength: "",
        videoName: "",
        lastState: "",
        lastTime:0,
        videoLength:0,
        percent:0,
        muteTracker: function(so) {
             this.lastState=so.state;
               // alert(so.id +' '+ so.state);
        },
        stopTracker: function() {
                 //alert(this.lastState + ' =last state ,should be stoped ');
             videoTracking.videoTracker(this.videoName,  this.videoLength,'state', 'STOP');
             },
        stateTracker: function(so) {
             this.lastState=so.newstate;
              
             //alert("state => "+this.lastState);
             //  alert('the old STATE = ' + so.oldstate + 'the new State =' + so.newstate);
            videoTracking.videoTracker(this.videoName,  this.videoLength,'state', so.newstate);
        },
        timeTracker: function(so) {
              // alert('the new TIME: position=' + so.position + 'duration= ' + so.duration);
              
              this.lastTime=Math.floor(so.position);
              trackPlayingByPercent(this.videoName,so.position,this.videoLength,this.lastState);
            
         },
         resizeTracker: function(so) {
         	if(so.fullscreen == true)
         	  videoTracking.videoTracker(this.videoName,  this.videoLength,'state', 'RESIZE');
         	else 
         	  videoTracking.videoTracker(this.videoName,  this.videoLength,'state', 'NORMALSIZE');
         },
         playTracker: function(so) {
         	if(this.lastState != "PAUSED")
         		videoTracking.videoTracker(this.videoName,  this.videoLength,'state', 'PLAY');
         },
        videoTracker: function(videoName, videoLength, eventType, eventState ) {
             var video_websensor = document.getElementById('video_websensor');
             var percentCalc;
             position ='&mfinfo.dg_video_position='+'0';
             if(eventState=='PLAYING'||eventState=='PAUSED'||eventState=='STOP' ||eventState=='CLOSED' || eventState=='RESIZE' || eventState=='NORMALSIZE' || eventState=='PLAY'){
                position ='&mfinfo.dg_video_position='+this.lastTime;
                
                // webtrends 
               if((eventState=='PLAYING' && this.lastTime == 0)||eventState=='PAUSED'||eventState=='STOP' ||eventState=='CLOSED'
               		|| eventState=='RESIZE' || eventState=='NORMALSIZE' || eventState=='PLAY'){
	                percentCalc = this.lastTime/this.videoLength;	
	             	percentCalc = percentCalc*100;
	                videoWebTrendsTracking(eventState,videoName,Math.round(percentCalc));
                } 
             }
             else if(eventState=='COMPLETED'){
                position ='&mfinfo.dg_video_position='+this.videoLength;
                videoWebTrendsTracking(eventState,videoName,"100");
             } 
             
             
           
                  if (video_websensor) {
                         video_websensor.src = '/generic/man/static_img/1x1.gif?mfinfo.page='+document.getElementById('mf').innerHTML.split(' ').join('')
                              +'&mfinfo.dg_video_name='+videoName
                              +'&mfinfo.dg_video_length='+videoLength
                              +position
                              +'&mfinfo.act='+eventState
                              +'&mfinfo.language='+locale.substring(3)
                             +'&mfinfo.dg_location='+document.getElementById('mf_location').innerHTML.split(' ').join('')
                              +'&cachebuster='+Math.random();
                   }
                   
            }
}

function trackPlayingByPercent(videoName,currentTime,videoLength,state){
	var percent = 0;
	percent = currentTime/videoLength;
    percent = percent*100;
  
    if (percent == 20 || percent == 40 || percent == 60 || percent == 80) {
        //alert('state = '+state+" percent => "+percent);
    	videoWebTrendsTracking("BUFFERING",videoName,percent);
    	//setTimeout("videoWebTrendsTracking('BUFFERING',videoName,percent);",50);
    }
    return false;
}

function playerReady(so) {
        id = so['id'];
        player=null;
        player = document.getElementById(id);
        player.addControllerListener('MUTE','videoTracking.muteTracker');
        player.addModelListener('STATE','videoTracking.stateTracker');
        player.addModelListener('TIME','videoTracking.timeTracker');
        player.addControllerListener('STOP','videoTracking.stopTracker');
        player.addControllerListener('RESIZE','videoTracking.resizeTracker');
        player.addControllerListener('PLAY','videoTracking.playTracker');
        player.sendEvent('PLAY', 'true');

};
var Video = {
	open: function(city, page, topic,videoName,videoLength) {
                                  if (topic !=null){
                                  document.getElementById("topicname").innerHTML = "&nbsp;" + topic.toLowerCase() + "&nbsp;";
                                  document.getElementById("topicname1").innerHTML = "&nbsp;" + topic.toLowerCase()+ "&nbsp;";
                                  document.getElementById("citynametopic1").innerHTML = "&nbsp;" + city + "&nbsp;";
                                  document.getElementById("citynametopic").innerHTML = city + "&nbsp;";
                                  document.getElementById("video-duration-topic").innerHTML = "(" + videoLength+ ")";
                                
                             }
                             if(page=='city'){
                                  document.getElementById("cityname").innerHTML = "&nbsp;" + city + "&nbsp;";
                                  document.getElementById("cityname1").innerHTML = city + "&nbsp;";
                                  document.getElementById("topicpagevideo").style.display = "none";
                                  document.getElementById("citypagevideo").style.display = "block";
                                  document.getElementById("video-duration-city").innerHTML = "(" + videoLength+ ")";
                             } else {
                                  if(page=='topic'){
                                     document.getElementById("topicpagevideo").style.display = "block";
                                     document.getElementById("citypagevideo").style.display = "none";
                                  }
                                }
 
                   var arr= videoName.split("/");
                   var videoNameNew;
 		     
                     so = new SWFObject('/destinationguide/static/swf/player.swf','klmdgvideo','536','321','9', {name: 'klmdgvideo'});
                     so.addParam('allowscriptaccess','always');
                     so.addParam('allowscriptaccess','always');
                     so.addParam('allowfullscreen','true');
                     so.addParam('type','application/x-shockwave-flash');
                     so.addParam('height', '321');
                     so.addParam('width', '536');
                     
                     if(videoName.indexOf("rtmp") != -1){
		     // video is hosted outside KLM
		       videoNameNew = "file=" +arr[arr.length-2]+"/"+arr[arr.length-1]+"&streamer="+arr[0]+"//"+arr[2]+"/"+arr[3]+"/";
		       so.addParam('flashvars', videoNameNew );

		     } else {
		       videoNameNew = "file="+videoName;
		       so.addParam('flashvars', videoNameNew);
                     }
                     
                     videoTracking.videoName=arr[arr.length-1];
                     arr=videoLength.split(":");
                     videoTracking.videoLength=Math.floor(parseInt(arr[0]*60)) + parseInt(arr[1]);
                     so.write('flashbanner');
                     document.getElementById("VideoPopup").style.display = "block";
                     videoTracking.videoTracker(videoTracking.videoName, videoTracking.videoLength,'state', 'click_to_open');
                   	 
                   	
                     Email.overlayBox();
                     return false;

                },


	hide: function() {
                             if (!!document.getElementById("klmdgvideo")) {
                                      //alert("stopping...");
                                      player.sendEvent("STOP");
                                      document.getElementById("flashbanner").innerHTML = "";
                             
                                     videoTracking.videoTracker(videoTracking.videoName,       videoTracking.videoLength,'state', 'CLOSED');
}
                             var ctl = document.getElementById("VideoPopup"); 
                             ctl.style.display = "none";
//remove  overlayBG 
                 document.getElementsByTagName("body")[0].removeChild(document.getElementById("overlayBg"));
//enabeled 'select' fields for IE
                 ctrl = document.getElementById("select-from"); 
                 if (ctrl !=null){
                   ctrl.disabled = false;
                   ctrl = document.getElementById("select-adults"); 
                   ctrl.disabled = false;
                   ctrl = document.getElementById("cabin-class"); 
                   ctrl.disabled = false;
                   ctrl = document.getElementById("select-kids"); 
                   ctrl.disabled = false; 
                   ctrl = document.getElementById("select-baby"); 
                   ctrl.disabled = false;
                 }
                 ctrl = document.getElementById("otherKLMsites"); 
                 if (ctrl !=null){
                     ctrl.disabled = false;
                 }
                 return false;
                 }

}

function getTabView(name){
	var tabView = "";
	if( name.indexOf("link-to-map") != -1 ){
			return tabView = "mapview";
	//} else if(name.indexOf("airport") != -1){
	//  	return tabView = "airportnr";
	}else return tabView = "listview";
}

/**
* Returns the static label of a specific topicCode
* param - topicCode - taken from the hidden fields that stores the db value of a topic
*/
function getStaticTopic(topicCode){
	var label = "";
	if(topicCode.toString().indexOf("event")!= -1) label = "events";
	else if(topicCode.toString().indexOf("ttd")!= -1) label = "thingstodo";
	else if(topicCode.toString().indexOf("shop")!= -1) label = "shopping";
	else if(topicCode.toString().indexOf("rest")!= -1) label = "restaurants";
	else if(topicCode.toString().indexOf("nl")!= -1) label = "nightlife";
	else if(topicCode.toString().indexOf("airport")!= -1) label = "airport";
	else if(topicCode.toString().indexOf("themedtour")!= -1) label = "tour";
	else if(topicCode.toString().indexOf("practical")!= -1) label = "practical";
	else if(topicCode.toString().indexOf("travel")!= -1) label = "transportation";
	return label;
}

// Gets the position of li tag
function getPosition(childId,tagName,parentId) {
   var listOfItems = document.getElementById(parentId).getElementsByTagName(tagName);
   for(i=0;i<listOfItems.length;i++) {
        if(listOfItems[i].href.toString().indexOf(childId.toString()) != -1 ) {
          return i;
        }
   }
}


function rtrim(stringToTrim) {
		return stringToTrim.replace(/\s+$/,"");
	}
function ltrim(stringToTrim) {
	return stringToTrim.toString().replace(/^\s+/,"");
}

function trim(str) {
		//alert(str);
        return str.replace(/^\s+|\s+$/g,"");
    }

function removeWhiteSpace(nsText){
	nsText = nsText.replace(/(\n\r|\n|\r)/gm,"<1br />");
	nsText = nsText.replace(/\t/g,"");

	re1 = /\s+/g;
	nsText = nsText.replace(re1," ");

	re2 = /\<1br \/>/gi;
	nsText = nsText.replace(re2, "\n");

	return nsText;


}  

function searchMonth(selectMonth){
	var searchIndex = 0;
	for( var i = 0; i < document.getElementById("booker-calendar-month").options.length; i++ ) {
		var monthFirstOption = document.getElementById("booker-calendar-month").options[i].value;
		monthFirstOption = monthFirstOption.substring(4,monthFirstOption.length);
		if (selectMonth == monthFirstOption){
			searchIndex = i;
		}
	}
	return searchIndex;
} 

function handleData(str) {
                //alert("get data...")
               if(destinationGuide.isChangeCountry == true) {
                       var changeCountry = document.getElementById('select-country');
	        if (changeCountry) {
		setDestination(document.getElementById("defaultCity").value,changeCountry.value);
	        }
                       
                }else {
                       document.getElementById("booker-flightsTab").innerHTML = str;
                       setDestination(document.getElementById("defaultCity").value,"");
                }
                

	
}


