// --- [start /site/destinations.js] ---


	// Function for flight search to skip multidestinations error for specific cities
	checkFlightDestination = {
		init: function(){
			if(lm.e('flights_submit')){
				submitButton = lm.e('flights_submit')
				submitButton.onclick = checkFlightDestination.selectClickHandler;
			}
		},
		selectClickHandler: function(){
			var dest = lm.e('destination').value;
			var inputDestination = dest.toUpperCase();
			var dept = lm.e('departurePoint').value;
			var inputDeparture = dept.toUpperCase();
			var citiesToSkip = ['BALI|DPS','BEIJING|PEK','COOK ISLANDS|RAR','FIJI|NAN','FRASER COAST|HVB','HAWAII|HNL','LONDON|LON','MELBOURNE|MEL','NOUMEA|NOU','REUNION|RUN','SAMOA|APW','SOLOMAN ISLANDS|HIR','ST DENIS|RUN','VANUATU|VLI','WHITSUNDAY COAST|PPP'];

			if (inputDestination != "" || inputDeparture != ""){
				if (inputDestination != ""){
					for (var i=0; i < citiesToSkip.length; i++) {
						var skipCity = citiesToSkip[i].split("|")[0];
						if (inputDestination == skipCity) {
							lm.e('destination').value = citiesToSkip[i].split("|")[1];
						} 
					} 
				}
				if (inputDeparture != ""){
					for (var i=0; i < citiesToSkip.length; i++) {
						var skipCity = citiesToSkip[i].split("|")[0];
						if (inputDeparture == skipCity) {
							lm.e('departurePoint').value = citiesToSkip[i].split("|")[1];
						} 
					} 
				}
				return true;
			}
		}

	}


	// Function for the onChange dropdown for Index page
	function menu_goto(menuform)
	{
		baseurl = window.location.href.split("?")[0] + "?skin=ensg.zuji.com.sg";
		selecteditem = menuform.newurl.selectedIndex;
		newurl = menuform.newurl.options[selecteditem].value;
		
			if (newurl.length != 0) {
				location.href = baseurl + newurl;
			}
	}


	// Function to check for main page template or hotel template
/*	function checkURL(region)
	{
		var pos = '&'+'dtype';
		var baseUrl=window.location.href.split("site")[0];
		var backUrl = window.location.href.split ("site")[1];
			if (backUrl!=undefined){
				var pos = backUrl.indexOf (pos);
			}
			else{
				pos=-1;
			}
			if (backUrl!= undefined){
				if (pos==-1){
					window.location.href=baseUrl + "site" + backUrl + "&" + "dtype=" + region;
				}
				else{
					backUrl  = backUrl.substring(0,pos) + "&" + "dtype=" + region;
					window.location.href=baseUrl + "site" + backUrl;
				}
			}
			else{
				if (pos==-1){
								if (baseUrl =="http://www3.zuji.com.au/?skin=enau.zuji.com.au"){
								window.location.href="http://www3.zuji.com.au/site/main/homepage.html?skin=enau.zuji.com.au" + "&" + "dtype=" + region;
								}
									else if (baseUrl =="http://www.zuji.com.au/?skin=enau.zuji.com.au"){
									window.location.href="http://www.zuji.com.au/site/main/homepage.html?skin=enau.zuji.com.au" + "&" + "dtype=" + region;
									}
									else {baseUrl=window.location.href.split("?")[0];	
										  window.location.href=baseUrl + "site/main/homepage.html?skin=enau.zuji.com.au" + "&" + "dtype=" + region;
									}
							}
				else{
					var backUrl = window.location.href.split ("site")[1];
					backUrl  = backUrl.substring(0,pos) + "&" + "dtype=" + region;
					window.location.href=baseUrl + "site/main/homepage.html?skin=enau.zuji.com.au" + backUrl;
				}
			}
	}
*/
function checkURL(region){
	var dtype='dtype=';
	var thisurl=window.location.href.split("#")[0];
	var pos=thisurl.indexOf(dtype);
	var quesMark = thisurl.indexOf('?');
	if (pos!=-1){
		var newURL=thisurl.substring(0,pos)+dtype+region;
		window.location.href=newURL;
	} else if (quesMark==-1){
		var newURL=thisurl+'?'+dtype+region;
		window.location.href=newURL;
	} else if ((quesMark!=-1)&&(pos==-1)) {
		var newURL=thisurl+'&'+dtype+region;
		window.location.href=newURL;
	}
}


	// Function for the onChange dropdown for India Deals
	function launch_podule(dealsselect) {
	var option = dealsselect.options[dealsselect.selectedIndex];
	var out = '&'+'deparp=';
	var outtype = '&'+'dtype=';
	if (option.getAttribute('name') != ''){
	thisurl=window.location.href.split("#")[0];
	pos = thisurl.indexOf(out);
	posd = thisurl.indexOf(outtype);
	quesMark = thisurl.indexOf('?');
	myvalue = option.value;
	deparpoption = myvalue.substring(0,pos);
	dtypeoption = myvalue.substring(0,posd);
	if ((pos != -1) && (posd == -1))
	{
	newurl = thisurl.substring(0,pos)+deparpoption;
	window.open(newurl,"_self");
	}
	else if ((pos != -1) && (posd != -1))
	{
	newurl = thisurl.substring(0,posd) + myvalue;
	window.open(newurl,"_self");
	}
	else if (quesMark == -1){
	newurl = thisurl + '?' +myvalue;
	window.open(newurl,"_self");
	}
	else{
	newurl = thisurl + myvalue;
	window.open(newurl,"_self");
	}
	}else {window.open("/site/travel/search_travel_deals.html?skin=ensg.zuji.com.sg","_self")}
	}


	// Function used on Destination pages to populate the flights search form
	function preFillFlights(dep,dest,carrier,ticket,class_type,adult) {
			
			var fieldsId = ['departurePoint','destination','carrier','ticketType','class','adults'];
			var fieldsValue = [dep,dest,carrier,ticket,class_type,adult];
	
			for (var i=0; i < fieldsId.length; i++) {
				var fieldSelected = document.getElementById(fieldsId[i]);
				if(fieldSelected.type == 'select-one') {
					for (var l=0; l < fieldSelected.length; l++){
						if(fieldSelected.options[l].text == fieldsValue[i] || fieldSelected.options[l].value == fieldsValue[i])
							{fieldSelected.selectedIndex = l;}
						if (fieldsValue[i]=='')
							{fieldSelected.selectedIndex = 0;}
					}
				}
				if (fieldSelected.type == 'text') {
					fieldSelected.value = fieldsValue[i];
				}
			}
	}
	
	
	// Function used on Destination pages to populate the hotels search form
	function preFillHotels(country,dest,adult) {
	
			var fieldsId = ['country','adults0'];
			var fieldsValue = [country,adult];
			
				for (var i=0; i < fieldsId.length; i++) {
					var fieldSelected = document.getElementById(fieldsId[i]);
					if(fieldSelected.type == 'select-one') {
						for (var l=0; l < fieldSelected.length; l++){
							if(fieldSelected.options[l].text == fieldsValue[i] || fieldSelected.options[l].value == fieldsValue[i])
								{fieldSelected.selectedIndex = l;}
							if (fieldsValue[i]=='')
								{fieldSelected.selectedIndex = 0;}
						}
					}
					if (fieldSelected.type == 'text') {
						fieldSelected.value = fieldsValue[i];
					}
				}
				
				document.forms['hotels_search'].lmnLocation.value = dest;
	}
	
	
	// Function used on Destination pages to populate the packages search form
	function preFillPackages(dep,dest,place,hotelgroup,carrier) {
	
			var fieldsId = ['departurePoint','destination','carrier'];
			var fieldsValue = [dep,dest,carrier];
				
			for (var i=0; i < fieldsId.length; i++) {
				var fieldSelected = document.getElementById(fieldsId[i]);
				if(fieldSelected.type == 'select-one') {
					for (var l=0; l < fieldSelected.length; l++){
						if(fieldSelected.options[l].text == fieldsValue[i] || fieldSelected.options[l].value == fieldsValue[i])
							{fieldSelected.selectedIndex = l;}
						if (fieldsValue[i]=='')
							{fieldSelected.selectedIndex = 0;}
					}
				}
				if (fieldSelected.type == 'text') {
					fieldSelected.value = fieldsValue[i];
				}
			}

			if (place != null) {
				document.forms['dp_search'].DPSRT.value = place;
			} 

			if (hotelgroup != null) {
				document.forms['dp_search'].DPXMG.name = 'DPHGI';
				document.forms['dp_search'].DPHGI.value = hotelgroup;
			} 

	}



/*
Yetii - Yet (E)Another Tab Interface Implementation
version 1.6
http://www.kminek.pl/lab/yetii/
Copyright (c) Grzegorz Wojcik
Code licensed under the BSD License:
http://www.kminek.pl/bsdlicense.txt
*/
function tab() {
	this.defaults = {
		id: null,
		active: 1,
		tabclass: 'tab',
		activeclass: 'active'
	};
	for (var n in arguments[0]) { this.defaults[n]=arguments[0][n]; };	
	this.getTabs = function() {
        var retnode = [];
        var elem = document.getElementById(this.defaults.id).getElementsByTagName('*');
		var regexp = new RegExp("(^|\\s)" + this.defaults.tabclass.replace(/\-/g, "\\-") + "(\\s|$)");
        for (var i = 0; i < elem.length; i++) {
			if (regexp.test(elem[i].className)) retnode.push(elem[i]);
        }
        return retnode;
    };
	this.links = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('a');
	this.listitems = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('li');
	this.show = function(number) {
        for (var i = 0; i < this.tabs.length; i++) {
			if ((i+1)==number) {
				this.addClass(this.links[i], this.defaults.activeclass+'-link');
				this.addClass(this.listitems[i], this.defaults.activeclass);
				this.removeClass(this.tabs[i], 'hide');
				this.removeClass(this.tabs[i], 'tab-content-inactive');
			} else {
				this.removeClass(this.links[i], this.defaults.activeclass+'-link');
				this.removeClass(this.listitems[i], this.defaults.activeclass);
				this.addClass(this.tabs[i], 'hide');
			}
		}
    };
	this.gup = function(name) {
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp( regexS );
		var results = regex.exec( window.location.href );
		if (results == null) return null;
		else return results[1];
	};
	this.parseurl = function(tabinterfaceid) {
		var result = this.gup(tabinterfaceid);
		if (result==null) return null;
		if (parseInt(result)) return parseInt(result); 
		if (document.getElementById(result)) {	
			for (var i=0;i<this.tabs.length;i++) {
				if (this.tabs[i].id == result) return (i+1);
			}
		}
		return null;
	};
	this.contains = function(el, item, from) {
		return el.indexOf(item, from) != -1;
	};
	this.hasClass = function(el, className){
		return this.contains(el.className, className, ' ');
	};
	this.addClass = function(el, className){
		if (!this.hasClass(el, className)) el.className = (el.className + ' ' + className).replace(/\s{2,}/g, ' ').replace(/^\s+|\s+$/g, '');
	};
	this.removeClass = function(el, className){
		el.className = el.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');
		el.className.replace(/\s{2,}/g, ' ').replace(/^\s+|\s+$/g, '');
	};
	this.tabs = this.getTabs();
	this.defaults.active = (this.parseurl(this.defaults.id)) ? this.parseurl(this.defaults.id) : this.defaults.active;
	this.show(this.defaults.active);
	var self = this;
	for (var i = 0; i < this.links.length; i++) {
		this.links[i].customindex = i+1;
		this.links[i].onclick = function(){ 
			self.show(this.customindex);
			return false;
		};
    }
};
// --- [end prdpwgbd4803:5002 - /site/destinations.js - Feb 9, 2010 12:16 pm GMT - akamai,pcth0308,pct0410 - 4f03hgqoQ1UAAFUfpDcAAAAM - cache 1800 ] ---
