// JavaScript Document
var viewportwidth;
var viewportheight;

/* eliminata dal 20090420
function subMenu(id,stato,caller) {
	
	var figli = document.getElementById('gr_fascia_menu_link').childNodes;
	
	for(i=0;i<figli.length;i++) {
		if(figli[i].tagName == 'A') {
			if(figli[i] == caller) caller.style.backgroundImage='url(img_home/fascia_menu_elemento_hover.png)';
			else figli[i].style.backgroundImage='url(img_home/fascia_menu_elemento.png)';
		}
	}
	
	var flag = true;
	var cnt = 1;

	while(flag && cnt<100) {
		if(elemento = document.getElementById('sub_'+cnt)) {
			if(cnt != id) {

				elemento.style.display = 'none';

				var flag2 = true;
				var cnt2 = 1;
				while(flag2 && cnt2<100) {
					if(elemento2 = document.getElementById('sub_sub_'+cnt+'_'+cnt2)) {
						elemento2.style.display = 'none';
					}
					else {
						flag2 = false;
					}
					cnt2++;
				}

			}
			else {
				
				Effect.Appear('sub_'+cnt, {duration: 0.5 });
				
				var figli = elemento.childNodes;
				
				for(i=0;i<figli.length;i++) {
					if(figli[i].tagName == 'A') {
						figli[i].style.backgroundImage='none';
					}
				}
			}
		}
		else {
			flag = false;
		}
		cnt++;
	}

}

function subSubMenu(id,sub,caller) {
	
	var figli = document.getElementById('sub_'+id).childNodes;
	
	for(i=0;i<figli.length;i++) {
		if(figli[i].tagName == 'A') {
			if(figli[i] == caller) {
				caller.style.backgroundImage='url(img_all/sub_menu_hover.png)';
			}
			else {
				figli[i].style.backgroundImage='none';
			}
		}
	}
	
	var flag = true;
	var cnt = 1;
	while(flag && cnt<100) {
		if(elemento = document.getElementById('sub_sub_'+id+'_'+cnt)) {
			if(cnt != sub) elemento.style.display = 'none';
			else Effect.Appear('sub_sub_'+id+'_'+cnt, {duration: 0.5 });
		}
		else {
			flag = false;
		}
		cnt++;
	}

}
*/

function toggler(elemento) {
	var stato = document.getElementById(elemento).style.display;
	if(stato == 'none') {
		Effect.BlindDown(elemento, {duration: 1 });
		document.getElementById('fr_' + elemento).src = 'img_all/frecce_su.png';
	}
	else {
		Effect.BlindUp(elemento, {duration: 1 });	
		document.getElementById('fr_' + elemento).src = 'img_all/frecce_sotto.png';
	}
}

function whichMenu(id) {
	return id.replace('link','menu');
}

function whichLink(id) {
	return id.replace('menu','link');
}

function switchTab(contpre, apre, to, class_0, class_1) {
	var i = 1;
	var flag = true;
	while (flag && i<100) {
		var nome = contpre + i;
		if(elemento = document.getElementById(nome)) {
			if(elemento.style.display == 'none' && i == to) {
				elemento.style.display = '';
				document.getElementById(apre + i).className = class_1;
			}
			if(elemento.style.display == '' && i != to) {
				elemento.style.display = 'none';
				document.getElementById(apre + i).className = class_0;
			}
		}
		else {
			flag = false;
		}
		i++;
	}
	return false;
}








function flashFunction(beyondLayerUrl){

	if ($jq("#fancybox").length == 0 || !$jq("a#fancybox")) {
		$jq('body').append("<div id='fancybox' style='float:left'></div>");
	}
	
	$jq("#fancybox").load(beyondLayerUrl).modal({
		overlayCss: {
		  backgroundColor: '#000000',
		  cursor: 'wait'
		},
		opacity:80,
		closeHTML: ('<a class="modalCloseImg" title="Close">close</a>'),
		close:true,
		position:[100,Math.floor( ($jq(window).width() - 760)/2)]
	});
	
	/*
	else if ($('a#fancybox').attr("href") != beyondLayerUrl) {
		$jq('a#fancybox').attr("href", beyondLayerUrl);
	}http://192.168.10.1/gitzo/20081230_gitzo/01_01_macrofamiglia_tripod.html#
	*/

	/*$jq('a#fancybox').attr("href", beyondLayerUrl);*/

	// now we will simulate the click here.
	/*$jq('a#fancybox').trigger("click");*/

/*
if (!$jq("#dialog").length > 0) 
	$jq('body').append("<div id='dialog'></div>");
	
	$jq("#dialog").load(beyondLayerUrl).dialog({
		width: 760,
		height: 'auto',
		zIndex: 3999,
		modal: true,
		title: null,
		resizable: false,
		position: 'top',
		overlay: {
			backgroundColor: '#000000',
			opacity: 0.6
		}
	});
*/
}

function flashLightbox(imagesrc) {
	
	if ($jq("a#lightbox").length > 0) {
		$jq("a#lightbox").remove();
  }
	else {
	}
	
	if (!$jq("a#lightbox").length > 0) {
		$jq('body').append("<a id='lightbox' style='visibility:hidden; position: absolute; left: -9999px;' href='" + imagesrc + "'>calling js lightbox from flash</a>");
		$jq('a#lightbox').lightBox({
  		fixedNavigation: true,
  		imageLoading: '/jsp/jahia/templates/gitzo/corporate_portal_templates_v2/custom/static/include/jquery/jquery.lightbox.js/images/lightbox-ico-loading.gif',
  		imageBtnClose: '/jsp/jahia/templates/gitzo/corporate_portal_templates_v2/custom/static/include/jquery/jquery.lightbox.js/images/lightbox-btn-close.gif',
  		imageBtnNext: '/jsp/jahia/templates/gitzo/corporate_portal_templates_v2/custom/static/include/jquery/jquery.lightbox.js/images/lightbox-btn-next.gif',
  		imageBtnPrev: '/jsp/jahia/templates/gitzo/corporate_portal_templates_v2/custom/static/include/jquery/jquery.lightbox.js/images/lightbox-btn-prev.gif',
  		imageBlank: '/jsp/jahia/templates/gitzo/corporate_portal_templates_v2/custom/static/include/jquery/jquery.lightbox.js/images/lightbox-blank.gif'
		});
	}
	// now we will simulate the click here.
	$jq('a#lightbox').trigger("click");
		
}

/* mesi dell'anno nel calendario*/
	
		function showCalendar(month, year){
		
			$jq('#calendar_box').load('/cms/site/gitzo/home/newsevents/cache/off/events_calendar?month='+month+'&year='+year);
		}
	
/* mesi dell'anno nel calendario*/

/* ritorna l'evento selezionato */
	
		function showEvent(month, year, day){

			$jq('#calendar_popup').load('/cms/site/gitzo/home/newsevents/cache/off/popup_events?month='+month+'&year='+year+'&day='+day);
			
		}
	
/* ritorna l'evento selezionato */
