//<![CDATA[

var Site = {

	start: function(){
		if($('calendar')) Site.vertical();
		if($('vertical')) Site.vertical2();

		
	},
	
	vertical: function(){
		var list = $$('#calendar li div.collapse');

		
		var headings = $$('#calendar li.expandable a.exp');
		var collapsibles = new Array();
		
		headings.each( function(heading, i) {	

			var collapsible = new Fx.Slide(list[i], { 
				duration: 300, 
				transition: Fx.Transitions.Sine.easeInOut,
				onComplete: function(request){ 
					var open = request.getStyle('margin-top').toInt();
					if(open >= 0) new Fx.Scroll(window).toElement(headings[i]);
				}
			});
			
			collapsibles[i] = collapsible;
			
			heading.onclick = function(){
				var span = $(this.getElement('span'));

				if(span){
					var newHTML = span.innerHTML == '-' ? '+' : '-';
					span.set('html',newHTML);
				}
				
				collapsible.toggle();
				return false;
			}
			
			collapsible.hide();
			
		});
		
		$('collapse-all').onclick = function(){
			headings.each( function(heading, i) {
				collapsibles[i].hide();
				var span =  $(heading.getElement('span'));
				if(span) span.set('html','+');
			});
			return false;
		}
		
		$('expand-all').onclick = function(){
			headings.each( function(heading, i) {
				collapsibles[i].show();
				var span =  $(heading.getElement('span'));
				if(span) span.set('html','-');
			});
			return false;
		}
		
	},
	

	vertical2: function(){
		var list = $$('#vertical div.collapse');

		
		var headings = $$('#vertical h4.expandable');
		var collapsibles = new Array();
		
		headings.each( function(heading, i) {	

			var collapsible = new Fx.Slide(list[i], { 
				duration: 300, 
				transition: Fx.Transitions.Sine.easeInOut,
				onComplete: function(request){ 
					var open = request.getStyle('margin-top').toInt();
					if(open >= 0) new Fx.Scroll(window).toElement(headings[i]);
				}
			});
			
			collapsibles[i] = collapsible;
			
			heading.onclick = function(){
				var span = $(this.getElement('span'));

				if(span){
					var newHTML = span.innerHTML == '-' ? '+' : '-';
					span.set('html',newHTML);
				}
				
				collapsible.toggle();
				return false;
			}
			
			collapsible.hide();
			
		});
		
		$('collapse-all').onclick = function(){
			headings.each( function(heading, i) {
				collapsibles[i].hide();
				var span =  $(heading.getElement('span'));
				if(span) span.set('html','+');
			});
			return false;
		}
		
		$('expand-all').onclick = function(){
			headings.each( function(heading, i) {
				collapsibles[i].show();
				var span =  $(heading.getElement('span'));
				if(span) span.set('html','-');
			});
			return false;
		}
		
	}
	
};
window.addEvent('domready', Site.start);
//]]>	


function showVideo(videoCode, title, desc){
	embedCode="<h2>"+title+"</h2><div style='padding:5px;'>"+desc+"</div><object width='425' height='344'><param name='movie' value='http://www.youtube.com/v/"+videoCode+"&autoplay=1'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube.com/v/"+videoCode+"&hl=it&fs=1&autoplay=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='425' height='344'></embed></object>";
	document.getElementById("videoContainer").innerHTML=embedCode;
}

function checkMessage(formObj){
    for (var i = 0; i<document[formObj].elements.length; i++) {
        if (document[formObj].elements[i].name.substring(0,2)=="#_") {
            alertMsg=document[formObj].elements[i].value;
            compField=document[formObj].elements[i].name.substring(2,document[formObj].elements[i].name.length)
			document[formObj][compField].focus()
            switch (document[formObj][compField].type) {
            case "select-one":
                if (document[formObj][compField].selectedIndex == 0) {
                    window.alert(alertMsg);
                    return false;
                }
                break;
            case "text":
                if (document[formObj][compField].value.trim() == "") {
                    window.alert(alertMsg);
                    return false;
                }
                break;
            case "textarea":
                if (document[formObj][compField].value.trim() == "") {
                    window.alert(alertMsg);
                    return false;
                }
                break;
            case "checkbox":
                if (document[formObj][compField].checked==false) {
                    window.alert(alertMsg);
                    return false;
                }
                break;
            }            
        }        
    }    
}

function hideShowLayer(idList, anchorTarget){
	var hideArray=idList.split(",");
	for(i=0;i< hideArray.length ;i++) {
		if(document.getElementById(hideArray[i]).className=="hidden"){
			document.getElementById(hideArray[i]).className="visible";
		}else{
			document.getElementById(hideArray[i]).className="hidden";
		}
	}

	if(anchorTarget!=null){
		window.location.href='#'+anchorTarget;
	}
}
