function gotoIndex() {
	document.location.href = "index.php";
}

function mainControl() {
	document.vtExpandBtnStatus = 0;
	document.vtHistoryStatus = 1;
	document.vtTopContentStatus = 0;
	var ctlLogoBtn = document.getElementById( "vtLogoPanel" );

	ctlLogoBtn.onclick = gotoIndex;

	//	Dinamic Menu Top Panel
	var params = 	{
					argCategory	: category,
					argCountry	: country,
					linkItems	: [ 'vtTripStyleItemMenuLink', 'vtDestinationItemMenuLink' ]
					};
	var dinamicMenuTopPanelObject = new app.DinamicMenuTopPanel( params );

	document.getElementById( "vtTripStyleItemMenu" ).onmouseover = function() {
		dinamicMenuTopPanelObject.makeSubMenuL1({
												subExec	:	activeMenuItem,
												linkItem:	'vtTripStyleItemMenuLink',
												position:	'230px',
												divWidth:	'166px',
												ids		:	[ 'vtTPMenuItemClassic', 'vtTPMenuItemBoutique', 'vtTPMenuItemLuxury', 'vtTPMenuItemOthers' ],
												labels	:	category,
												links	:	[]
												});
	}

	var array_country = dinamicMenuTopPanelObject.getArrayCountry();

	document.getElementById( "vtDestinationItemMenu" ).onmouseover = function() {
		dinamicMenuTopPanelObject.makeSubMenuL1({
												subExec	:	null,
												linkItem:	'vtDestinationItemMenuLink',
												position:	'397px',
												divWidth:	'176px',
												ids		:	[],
												labels	:	country.name,
												links	:	array_country
												});
	}

	var array_country_classic = dinamicMenuTopPanelObject.getArrayStyleByCountry(0);
	var array_country_boutique = dinamicMenuTopPanelObject.getArrayStyleByCountry(1);
	var array_country_luxury = dinamicMenuTopPanelObject.getArrayStyleByCountry(2);
	
	function activeMenuItem() {
		document.getElementById( "vtTPMenuItemClassic" ).onmouseover = function() {
			dinamicMenuTopPanelObject.makeSubMenuL2({
													style	:	0,
													ids		:	[],
													posx	:	'397px',
													posy	:	19,
													labels	:	country.name,
													links	:	array_country_classic
													});
		}

		document.getElementById( "vtTPMenuItemBoutique" ).onmouseover = function() {
			dinamicMenuTopPanelObject.makeSubMenuL2({
													style	:	1,
													ids		:	[],
													posx	:	'397px',
													posy	:	38,
													labels	:	country.name,
													links	:	array_country_boutique
													});
		}

		document.getElementById( "vtTPMenuItemLuxury" ).onmouseover = function() {
			dinamicMenuTopPanelObject.makeSubMenuL2({
													style	:	2,
													ids		:	[],
													posx	:	'397px',
													posy	:	57,
													labels	:	country.name,
													links	:	array_country_luxury
													});
		}

		document.getElementById( "vtTPMenuItemOthers" ).onmouseover = function() {
			dinamicMenuTopPanelObject.makeSubMenuL2({
													style	:	3,
													ids		:	[],
													posx	:	'397px',
													posy	:	76,
													labels	:	[ 'Galapagos', 'Christmas' ],
													links	:	[ 'galapagosyachts.php', 'la_p_cmp.php' ]
													});
		}
	}

	function callHideMenuTopPanel() {
		dinamicMenuTopPanelObject.hideSubMenuPanel();
	}

	ctlLogoBtn.onmouseover = callHideMenuTopPanel;
	document.getElementById( "vtLanguagesPanel" ).onmouseover = callHideMenuTopPanel;
	document.getElementById( "vtHPContactUs" ).onmouseover = callHideMenuTopPanel;
	document.getElementById( "vtTourIdeasItemMenu" ).onmouseover = callHideMenuTopPanel;
	document.getElementById( "vtResponsibleTravelItemMenu" ).onmouseover = callHideMenuTopPanel;
	document.getElementById( "vtContentAfterMenuTopPanel" ).onmouseover = callHideMenuTopPanel;

	//	Dinamic Country Left Panel
	var isThereMenu = '1';//document.getElementById( "isThereMenu" ).value;

	if( isThereMenu == '1' ) {
		var args = {
				divContainer:	'vtDinamicCountryLeftPanel',
				argcategory	:	category,
				argcountry	:	country,
				argtour		:	tour
					};
		var dinamicCountryLeftPanelObject = new app.DinamicCountryLeftPanel( args );

		var handlerMenuClassic = document.getElementById( 'vtItemMenuLeftClassic' );
	
		handlerMenuClassic.onmouseover = function() {
			dinamicCountryLeftPanelObject.makeMenu( 0, 'vtItemMenuLeftClassic' );
		}

		var handlerMenuBoutique = document.getElementById( 'vtItemMenuLeftBoutique' );

		handlerMenuBoutique.onmouseover = function() {
			dinamicCountryLeftPanelObject.makeMenu( 1, 'vtItemMenuLeftBoutique' );
		}

		var handlerMenuLuxury = document.getElementById( 'vtItemMenuLeftLuxury' );
	
		handlerMenuLuxury.onmouseover = function() {
			dinamicCountryLeftPanelObject.makeMenu( 2, 'vtItemMenuLeftLuxury' );
		}

		var handlerMenuOthers = document.getElementById( 'vtItemMenuLeftOthers' );
	
		handlerMenuOthers.onmouseover = function() {
			dinamicCountryLeftPanelObject.makeMenuOthers( 3, ['Galapagos Yachts', 'Christmas Tour'], ['galapagosyachts.php', 'la_p_cmp.php'], 'vtItemMenuLeftOthers' );
		}

		document.getElementById( "vtContentPanel" ).onmouseover = function() {
			dinamicCountryLeftPanelObject.hideMenu();
		}

		document.getElementById( "vtCategoryHeaderItem" ).onmouseover = function() {
			dinamicCountryLeftPanelObject.hideMenu();
		}

		document.getElementById( "vtLeftMenuSeparator" ).onmouseover = function() {
			dinamicCountryLeftPanelObject.hideMenu();
		}
	}
	
	function validateSignIn( fields ) {
		var fieldValue;

		for( var i = 0; i < fields.length; i++ ) {
			fieldValue = document.getElementById( fields[ i ] );

			if( fieldValue.value == '' ) {
				fieldValue.focus();
				return false;
			}
		}

		return true;
	}

	function singin() {
		var loginparams = new Array( "inlogin2", "inpassword2" );
		var idform = 'vtsigninform';
		var mylogin = document.getElementById( loginparams[0] ).value;
		var mypasswd = document.getElementById( loginparams[1] ).value;
		
		if( validateSignIn( loginparams ) ) {
			document.getElementById( idform ).submit();
		}
		else {
			alert( 'Login and/or password missing' );
		}
	}

	document.getElementById( 'send2' ).onclick = function() {
		singin();
	}
	
	document.getElementById( 'vtHPLoginAction' ).onclick = function() {
		document.getElementById( 'vtSignin' ).style.display = 'block';
	}
	
	document.getElementById( 'resetlogin2' ).onclick = function() {
		document.getElementById( 'vtSignin' ).style.display = 'none';
	}
}

