/**
 * @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', '/flash/collections_menu',
			'src', '/flash/collections_menu',
			'FlashVars', //'path=/MaxMara/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 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 createHomeSplash(lang){
// 	if (AC_FL_RunContent == 0) {
// 		alert("This page requires AC_RunActiveContent.js.");
// 	} else {
// 		AC_FL_RunContent(
// 			'id', 'Main_Menu_Intro',
// 			'name', 'Main_Menu_Intro',
// 			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
// 			'width', '802',
// 			'height', '500',
// 			'movie', '/flash/MM_sfilate_2011',
// 			'src', '/flash/MM_sfilate_2011',
// 			'FlashVars', //'path=/xml/home.xml&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 createHomeSplash(movie, src){
	src = src || movie;
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		AC_FL_RunContent(
			'id', 'Main_Menu_Intro',
			'name', 'Main_Menu_Intro',
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
			'width', '525',
			'height', '325',
			'movie', movie,
			'src', src,
			'FlashVars', //'path=/xml/home.xml&show_images=true&show_gallery=true',
			'',
			'quality', 'high',
			'bgcolor', '#000000',
			'wmode', 'transparent',
			'allowScriptAccess','sameDomain',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'play', 'true',
			'loop', 'true',
			'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){
	var menuhtml = $("collMenu");

	if (menuhtml) {
		menuhtml.fade("toggle");
	}

	try {
		menu_visible();
		var el_men = getFlashMenu(menuID);
		el_men.toggle_menu();
	}
	catch (e) {
		//alert(e.message);
  }
  
}

function MenuON(menuID){
	try { getFlashMenu(menuID).show_menu();
	} catch (e) {/**/}
}

function MenuOFF(menuID){    
	try { getFlashMenu(menuID).hide_menu();
	} catch (e) {/**/}
}
	
/* 
 * FLASH Menu Events
 */

// is called when the flash is ready to receive parameters
function collections_menu_is_ready() {
	menu_invisible();
	
	var param = window.location.search;
	if (param == '?m=1') {
		MenuON('Main_Menu');
	}
}

// do something when menu is visible
function menu_visible() {
	if (!!document.getElementById('homeSpan')) {
		document.getElementById("headCont").style.visibility = "visible";
	} else {
		document.getElementById("FlashMenuGallery").style.visibility = "visible";
	}
}


// do something when menu is invisible
function menu_invisible() {
	if (!!document.getElementById('homeSpan')) {
		document.getElementById("headCont").style.visibility = "collapse";

	} else {
		document.getElementById("FlashMenuGallery").style.visibility = "collapse";
	}
}

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();
}

function close_intro(){
	var bkg_intro = $$("div.intro_background");
	if (bkg_intro){
		//bkg_intro.set('class','intro_hide');
		bkg_intro.setStyle('display','none');
	}
	var cls_intro = $$("div.intro_close");
	if(cls_intro){
		//cls_intro.set('class','intro_hide');
		cls_intro.setStyle('display','none');
	}
	var fls_intro = $$("div.intro_flash");
	if(fls_intro){
		//fls_intro.set('class','intro_hide');
		fls_intro.setStyle('display','none');
	}

	return false
}
function open_intro(){
	var bkg_intro = $$("div.intro_background");
	if (bkg_intro){
		bkg_intro.setStyle('display','');
	}
	var cls_intro = $$("div.intro_close");
	if(cls_intro){
		cls_intro.setStyle('display','');
	}
	var fls_intro = $$("div.intro_flash");
	if(fls_intro){
		fls_intro.setStyle('display','');
	}
	
}


