/**
 * @author FINSA Consulting s.r.l.
 * @classDescription: Manage menus' behaviour
 */

/*
 * * Function implementing the Flash navigation menu 
 */

/**
 * @classDescription: Quick javascript for creating any page's menu, excluding home. html and "news's pages"
 */
function createCollectionsMenu(lang){
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'id', 'Main_Menu',
			'name', 'Main_Menu',
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '226',
			'height', '466',
			'movie', '/flash/collections_menu',
			'src', '/flash/collections_menu',
			'FlashVars', //'path=/xml/collection.xml',
			'path=/' + lang + '/xml_menu_collections/coll',
			'quality', 'high',
			'bgcolor', '#000000',
			'wmode', 'transparent',
			'allowScriptAccess','sameDomain',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'play', 'true',
			'loop', 'false',
			'allowFullScreen', 'false',
			'align', 'middle'
			); //end AC code
	}	
}

/**
 * @classDescription: Quick javascript for creating blog's menu
 */
function createBlogMenu(lang){
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'id', 'Main_Menu',
			'name', 'Main_Menu',
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '232',
			'height', '480',
			'movie', 'http://blog.maxmara.com/it/wp-content/themes/wp_MMF/flash/collections_menu',
			'src', 'http://blog.maxmara.com/it/wp-content/themes/wp_MMF/flash/collections_menu',
			'FlashVars', //'path=/MaxMara/xml/collection.xml',
			'path=http://cms.maxmara.com/it/xml_menu_collections/coll',
			'quality', 'high',
			'bgcolor', '#000000',
			'wmode', 'transparent',
			//'allowScriptAccess','sameDomain',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'play', 'true',
			'loop', 'false',
			'allowFullScreen', 'false',
			'align', 'middle'
			); //end AC code
	}	
}

/**
 * @classDescription: Quick javascript for creating news pages's menu
 */
function createNewsMenu(lang){
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'id', 'Main_Menu',
			'name', 'Main_Menu',
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '226',
			'height', '435',
			'movie', '/flash/collections_menu',
			'src', '/flash/collections_menu',
			'FlashVars', //'path=/xml/collection.xml',
			'path=/' + lang + '/xmlMenuCollections/coll',
			'quality', 'high',
			'bgcolor', '#000000',
			'wmode', 'transparent',
			'allowScriptAccess','sameDomain',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'play', 'true',
			'loop', 'false',
			'allowFullScreen', 'false',
			'align', 'middle'
			); //end AC code
	}	
}

/**
 * @classDescription: Quick javascript for creating homepage's menu
 */
function createHomeMenu(lang){
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'id', 'Main_Menu',
			'name', 'Main_Menu',
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '930',
			'height', '536',
			'movie', '/flash/collections_menu',
			'src', '/flash/collections_menu',
			'FlashVars', //'path=/xml/home.xml&show_images=true&show_gallery=true',
			'path=/' + lang + '/xml_menu_collections/home&show_images=true&show_gallery=true',
			'quality', 'high',
			'bgcolor', '#000000',
			'wmode', 'transparent',
			'allowScriptAccess','sameDomain',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'play', 'true',
			'loop', 'false',
			'allowFullScreen', 'false',
			'align', 'middle'
			); //end AC code
	}	
}

/** 
 * Function getting the element by id according to each browser's features
 * @param {string} objID : element's ID
 */
function getFlashMenu(objID){
	if (isIE) {
		return window[objID];
	} else {
		return document[objID];
	}
}

/** 
 * Function intercating with the flash navigation menu turning it on and off
 * @param {Object} menuID
 */
function MenuOnOff(menuID){
	return;
	try {
		menu_visible();
		getFlashMenu(menuID).toggle_menu();
	}
	catch (e) {
    	alert(e.message);
  }
}

function MenuON(menuID){
	try {
	    getFlashMenu(menuID).show_menu();
	}
	catch (e) {
   		alert(e.message);
  }
}

function MenuOFF(menuID){    
	try {
	   getFlashMenu(menuID).hide_menu();
	}
	catch (e) {
    	alert(e.message);
  }
}

/* 
 * FLASH Menu Events
 */

// is called when the flash is ready to receive parameters
function collections_menu_is_ready() {
  if((window.location.href.toLowerCase().indexOf("home") == -1) && 
  		!document.getElementById('homePage')) {
	   menu_invisible();
	}
}

// do something when menu is visible
function menu_visible() {
  document.getElementById("FlashMenuGallery").style.visibility = "visible";
}


// do something when menu is invisible
function menu_invisible() {
	if ((window.location.href.toLowerCase().indexOf("home") == -1) && 
  			!document.getElementById('homePage')) {
		document.getElementById("FlashMenuGallery").style.visibility = "hidden";
	}
}

function cambiaLingua(selectL){
	//var indice = selectL.selectedIndex
	//var lingua = selectL[indice].value
	//alert(lingua)
	
	document.getElementById("flag_cambio_lingua").value = "true";
	//alert(document.getElementById("flag_cambio_lingua").value);
	document.getElementById("frmCambiaLingua").submit();
}

