$(document).ready(function(){
			
				Init();
				
				
			
				$('.boxgrid.captionfull').hover(function(){
					$(".cover", this).stop().animate({top:'60px'},{queue:false,duration:0});
				}, function() {
					$(".cover", this).stop().animate({top:'260px'},{queue:false,duration:0});
				});
				
				$('.boxgrid.captionfull2').hover(function(){
					$(".cover", this).stop().animate({top:'60px'},{queue:false,duration:0});
				}, function() {
					$(".cover", this).stop().animate({top:'260px'},{queue:false,duration:0});
				});
				
				$('.boxgrid2.captionfull').hover(function(){
					$(".cover2", this).stop().animate({top:'64px'},{queue:false,duration:0});
				}, function() {
					$(".cover2", this).stop().animate({top:'260px'},{queue:false,duration:0});
				});
				
				
				
				$.featureList(
				$("#tabs li a"),
				$("#output li"), {
					start_item	:	1
				}
				);
				
				
				
			});
			
			jQuery().ready(function(){
		jQuery('#list1a').accordion();
				
		var accordions = jQuery('#list1a');
		
		jQuery('#switch select').change(function() {
			accordions.accordion("activate", this.selectedIndex-1 );
		});
		jQuery('#close').click(function() {
			accordions.accordion("activate", -1);
		});
		jQuery('#switch2').change(function() {
			accordions.accordion("activate", this.value);
		});
		jQuery('#enable').click(function() {
			accordions.accordion("enable");
		});
		jQuery('#disable').click(function() {
			accordions.accordion("disable");
		});
		jQuery('#remove').click(function() {
			accordions.accordion("destroy");
			wizardButtons.unbind("click");
		});
	});
	
		$(document).ready(function(){
		$('#photos').galleryView({
			panel_width: 619,
			panel_height: 237
		});
	});
			
$.ajaxSetup ({
    cache: false
});

var formSelected;
var btnSelected;

function rotate_partners ( )
{
	var url = 'ajax_module_wrapper.php?';
	$('.partners_container').each(function(index, element){
		url = url + 'modules[]=' + element.id + '&';
		});
		
	$.get(url, {'ajax': 1}, function(reply){
		for (var idx in reply)
		{
			$("#" + idx).html(reply[idx]);
		}
	}, 'json');
}

function rotate_banners ( )
{
	var pattern = /< *img[^>]*src *= *["\']?([^"\']*)/gi;
	
	var url = 'ajax_module_wrapper.php?';
	$('.banner_container').each(function(index, element){
		url = url + 'modules[]=' + element.id + '&';
		});
		
	page_info.ajax = 1;
	$.get(url, page_info, function(reply){
		for (var idx in reply)
		{
			var match;
			while (match = pattern.exec(reply[idx]))
			{
				var img = new Image();
				img.src = match[1];
			}
			
			$("#" + idx).attr('html', reply[idx]);
		}
		setTimeout ( "update_banners()", 1000 );
		
	}, 'json');
	
	
}

function update_banners()
{
	$('.banner_container').each(function(index, element){
		$("#" + element.id).html($(this).attr('html'));
		});
}

function Init()
{
	InitForm();
	
	try {
			ShowForm('formHoliday',document.getElementById('btnVacanze'));
		}	
		 catch (e) { };
	
	//setInterval ( "rotate_partners()", 10000 );
	//setInterval ( "rotate_banners()", 10000 );
}

function InitForm()
{
	formSelected = $("#formHoliday");
	$("#formHotel").hide();
	$("#formFlight").hide();
	$("#formFerry").hide();
	
	$("#divDestination").hide();
}

function ShowDestination()
{
	$("#divDestination").show(0);
}

function CloseDestination()
{
	$("#divDestination").hide();
}

function SelectDestination(obj)
{
	$("#idDestination").val(obj.innerHTML);
	$("#divDestination").hide();
}

function ShowForm(formName,btn)
{
	if(btnSelected) btnSelected.style.backgroundImage = 'url(../_templates/TemplateSNJGenerale/images/bot_search_menu.png)';
	
	btn.style.backgroundImage = 'url(../_templates/TemplateSNJGenerale/images/bot_search_menu_hov.png)';
	btnSelected = btn;

	$("#divDestination").hide();
	formSelected.hide();
	$("#" + formName).show(0);
	formSelected = $("#" + formName);
}

function Go(url, type)
{
  if (type != 'new') {
    window.location.href = url;
  } else {
    window.open(url);  
  }
}

/* ---------------------------- */
/* SHOW-HIDE Layer				*/
/* ---------------------------- */
function showlayer(layer){
	var myLayer=document.getElementById(layer);
	if(myLayer.style.display=="none" || myLayer.style.display==""){
		myLayer.style.display="block";
	} else { 
		myLayer.style.display="none";
		}
}
