function getScriptPath( script ) {
	return BASE_URL + "/js/" + script;
}

function getLibScriptPath ( script ) {
	return BASE_URL + "/js/common/lib/" + script;
}

function getCompressedScriptPath( script ) {
	return BASE_URL + "/c/" + script;
}

function getCommonScripts() {

	var
		scripts = new Array(),
		userLanguage = $CONFIG.locale,
		liteVersion = $CONFIG.liteVersion;

	if ( $CONFIG.useCompressed == false ) {

		scripts.push( getLibScriptPath("ui18/jquery.ui.core.js") );
		scripts.push( getLibScriptPath("ui18/jquery.ui.widget.js") );
		scripts.push( getLibScriptPath("ui18/jquery.ui.mouse.js"));
		scripts.push( getLibScriptPath("ui18/jquery.ui.draggable.js"));
		scripts.push( getLibScriptPath("ui18/jquery.ui.datepicker.js"));
		scripts.push( getLibScriptPath("jquery.i18n.js"));
		scripts.push( getLibScriptPath("03.jquery.metadata.js"));
		scripts.push( getLibScriptPath("84.jquery.ajaxQueue.js"));
		scripts.push( getLibScriptPath("88.jquery.masked.js"));
		scripts.push( getLibScriptPath("89.bsn.autosuggest.js"));
		scripts.push( getLibScriptPath("90.jquery.watermarkinput.js"));
		scripts.push( getLibScriptPath("jquery.blockUI.js"));
		scripts.push( getLibScriptPath("jquery.rsv.js"));
		scripts.push( getLibScriptPath("shadowbox." + userLanguage + ".js"));

		scripts.push( getScriptPath("mph." + userLanguage + ".js"));

		scripts.push( getScriptPath("mph.json.js"));
		scripts.push( getScriptPath("mph.util.js"));
		scripts.push( getScriptPath("nemo.common.js"));
		scripts.push( getScriptPath("mph.common.js"));
		scripts.push( getScriptPath("mph.destinationsSearch.js"));

	}
	else {
		scripts.push( getCompressedScriptPath("00-common-" + userLanguage + ".js") );
	}

	return scripts;
}

function getStep1Scripts() {

	var pageScripts = new Array();

	if ( $CONFIG.useCompressed == false ) {
		pageScripts.push( getLibScriptPath("85.jquery.scrollable.js"));
		pageScripts.push( getLibScriptPath("86.jquery.bgiframe.js"));
		pageScripts.push( getLibScriptPath("87.jquery.scrollpanel.js"));
		pageScripts.push( getLibScriptPath("96.jquery.imageslide.js"));
		pageScripts.push( getLibScriptPath("swfobject/swfobject.js"));
		pageScripts.push( getScriptPath("mph.search-form.js"));
	}
	else {
		pageScripts.push( getCompressedScriptPath("01-home.js") );
	}

	return pageScripts;
}

function getStep2Scripts() {

	var
		pageScripts = new Array();

	if ( $CONFIG.useCompressed == false ) {

		var libScripts =
			[
	          "98.jquery.pagination.js",
	          "ui18/jquery.ui.slider.js",
	          "ui18/jquery.ui.tabs.js",
	          "ui18/jquery.ui.dialog.js",
	          "91.jquery.scrollTo.js",
	          "83.jquery.tools.js",
	          "82.jquery.jmap.js"
	        ];

		var scripts =
			[
			 	"mph.comparator.js",
			 	"mph.budget.js",
			 	"mph.search-form.js"
		    ];

		for(var i = 0; i < libScripts.length; i++) {
			pageScripts.push( getLibScriptPath(libScripts[i]));
		}

		for(i = 0; i < scripts.length; i++ ) {
			pageScripts.push( getScriptPath(scripts[i]));
		}
	}
	else {
		pageScripts.push( getCompressedScriptPath("02-searchResults.js"))
	}

	return pageScripts;
}

function getLiteStep2Scripts() {

	var pageScripts = new Array();

	if ( $CONFIG.useCompressed == false ) {
		pageScripts.push( getLibScriptPath("ui18/jquery.ui.slider.js"));
		pageScripts.push( getLibScriptPath("98.jquery.pagination.js"));
		pageScripts.push( getScriptPath("mph.search-form.js"));
	}
	else {
		pageScripts.push( getCompressedScriptPath("02-searchResults-lite.js"));
	}

	return pageScripts;
}

function getStep3Scripts() {

	var pageScripts = new Array();

	pageScripts.push( getLibScriptPath("ui18/jquery.ui.tabs.js") );

	return pageScripts;
}

function getMyBookingsScripts() {

	var pageScripts = new Array();

	if ( $CONFIG.useCompressed == false ) {
		pageScripts.push(getLibScriptPath("98.jquery.pagination.js"));
		pageScripts.push(getLibScriptPath("table.sorter.js"));
	}

	return pageScripts;
}

function getBookingDetailsScripts() {

	var pageScripts = new Array();

	if ( $CONFIG.useCompressed == false ) {
		pageScripts.push( getScriptPath("mph.booking-common.js"));
	}
	else {
		pageScripts.push( getCompressedScriptPath("14-booking-details.js"));
	}

	return pageScripts;
}

function getDisplayMapScripts() {

	var pageScripts = new Array();

	return pageScripts;
}

function getComparatorScripts() {

	var pageScripts = new Array();

	if ( $CONFIG.useCompressed == false ) {
		pageScripts.push( getLibScriptPath("ui18/jquery.ui.tabs.js"));
	}
	else {
		pageScripts.push( getCompressedScriptPath("11-comparator.js"));
	}

	return pageScripts;
}

function getWebTerminalScripts() {

	var pageScripts = new Array();

	if ( $CONFIG.useCompressed == false ) {
		pageScripts.push( getLibScriptPath("ui18/jquery.ui.tabs.js"));
		pageScripts.push( getLibScriptPath("ui18/jquery.ui.dialog.js"));
		pageScripts.push( getLibScriptPath("ui18/jquery.ui.button.js"));
	}
	else {
		pageScripts.push( getCompressedScriptPath("13-webTerminal.js"));
	}

	return pageScripts;
}

function loadScripts( pageScripts, callback ) {

	var
		labOptions = {
			AlwaysPreserverOrder : true
		},
		commonScripts = getCommonScripts();

	if(pageScripts.length == 0) {
		pageScripts.push(getScriptPath("mph.null.js"));
	}

	$LAB.setOptions(labOptions)
		.script( commonScripts  )
		.wait()
		.script( pageScripts )
		.wait( function() {

			callback();

			var event = jQuery.Event("pageLoaded.priceSurfer");
			jQuery(document).trigger(event);

		});
};