function HeureCheck()
{
krucial = new Date;
heure = krucial.getHours();
min = krucial.getMinutes();
sec = krucial.getSeconds();
jour = krucial.getDate();
mois = krucial.getMonth()+1;
annee = krucial.getFullYear();
if (sec < 10)
{
sec0 = "0";
}
else
{
sec0 = "";
}
if (min < 10)
{
min0 = "0";
}
else
{
min0 = "";
}
if (heure < 10)
{
heure0 = "0";
}
else
{
heure0 = "";
}
if (mois < 10)
{
mois0 = "0";
}
else
{
mois0 = "";
}
if (jour < 10)
{
jour0 = "0";
}
else
{
jour0 = "";
}
if (annee < 10)
{
annee0 = "0";
}
else
{
annee0 = "";
}
DinaDate = "" + jour0 + jour + "/" +  mois0 + mois + "/" + annee0 + annee;
total = DinaDate
DinaHeure = heure0 + heure + ":" + min0 + min + ":" + sec0 + sec;
total = DinaHeure
total = DinaDate + " - " + DinaHeure;
document.getElementById('time').innerHTML = total;
tempo = setTimeout("HeureCheck()", 1000)
}
window.onload = HeureCheck;
/*
/*	Dynamic design functions and onLoad events
/*	----------------------------------------------------------------------
/* 	Creates added dynamic functions and initializes loading.
*/


// ======================================================================
//
//	On document ready functions
//
// ======================================================================
(function($){
 $.add_message = function(options) {  
            var defaults = {
            messaggio : '',
            tipo : '',
            delay: '',
            closable : true,
            overlay:true,
            color_overlay:'',/*vedi css generale oppure dai un colore ad ogni overlay di ogni messaggio*/
            overlay_opacity:'3',
            resizable:false,
            draggable:false,
            post_message: function(){},
            post_close: function(){},
            w_message : '',
            h_message : ''
            };
            var options = $.extend(defaults, options); 
               var o = options   


 if(o.tipo == "attenzione"){
  var img_msg = ''//'http://'+window.location.host+'/immagini/messaggi/attenzione.png'
 }else if(o.tipo == "info"){
  var img_msg = ''//'http://'+window.location.host+'/immagini/messaggi/info.png'
 }else{
  var img_msg = ''//'http://'+window.location.host+'/immagini/messaggi/messageloading.gif'
 }
  if(o.overlay){
   $('body').append('<div style="z-index:999;position:absolute;left:0px;top:0px;width:'+$('body').width()+'px;height:100%;background:'+o.color_overlay+';opacity:'+o.overlay_opacity/10+';filter:alpha(opacity='+o.overlay_opacity*10+');-moz-opacity:'+o.overlay_opacity/10+';display:none" class="panel_overlay_message"></div>')
  
   $(".panel_overlay_message").css({"top":$(window).scrollTop()+"px"});
   $(window).scroll(function(){
      var SCREENscrolltop = $(window).scrollTop();
	  $(".panel_overlay_message").hide();
      $(".panel_overlay_message").css({"top":SCREENscrolltop+"px"});
      $(".panel_overlay_message").show();
   });  
   $(window).resize(function(){
      $(".panel_overlay_message").css({'width':$('body').width()+'px'});
   });       
  }else{
   $('.messagg').remove()
  }
   o.w_message != '' ? larghezza = 'width:'+o.w_message+'px' : larghezza = ''
   o.h_message != '' ? altezza = 'height:'+o.h_message+'px' : altezza = ''
   
   if(o.tipo != 'form'){
     $('body').append('<div class="messagg" style="z-index:9999;position:absolute;display:none;'+larghezza+'"><table width="100%" height="100%" border="0" cellspacing="0"><tr><td>'
                     +'<div style="overflow:auto;'+altezza+'" class="rr_resize"><img src="'+img_msg+'" alt="" /><br/><div class="contenuto_messagg">'+o.messaggio+'</div></div></td></tr></table></div>')
   }else{
     $('body').append('<div class="messagg" style="z-index:9999;position:absolute;display:none;'+larghezza+'"><table width="100%" height="100%" border="0" cellspacing="0"><tr><td>'
                     +'<div style="overflow:auto;'+altezza+'" class="rr_resize"><div class="contenuto_messagg">'+o.messaggio+'</div></div></td></tr></table></div>')                          
   }
   o.post_message.call(this);
   if(o.delay == '' && o.closable){
     $('.messagg').prepend('<div class="container_chiudi_messaggio" ><span class="font1 chiudi_message">Chiudi</span></div>')
   }
   if(o.draggable){
     $('.messagg').draggable({
      containment: 'body'
     })
   }
   if(o.resizable){
     $('.messagg').resizable({
       alsoResize:'.rr_resize',
       minWidth: $('.chiudi_message').width()
     });
   }
   function re_position(){
	  var DIVwidth = $('.messagg').width();	
	  var DIVheight = $('.messagg').height();
	  var SCREENwidth = $(window).width();
	  var SCREENheight = $(window).height();	
	  var SCREENscrolltop = $(window).scrollTop();	               
      $('.messagg').css({"left": (SCREENwidth-DIVwidth)/2+"px","top": (SCREENheight-DIVheight)/2+SCREENscrolltop+"px"}).fadeIn('fast')
      $(".panel_overlay_message").fadeIn('fast')
   }
   re_position()  
   $(window).resize(function(){
      re_position()
   });    
   $(window).scroll(function(){
      var SCREENscrolltop = $(window).scrollTop();
	  $(".messagg").hide();
      re_position()
      $(".messagg").show();
   }); 
   if(o.delay != ''){ 
     remove_auto_message()
   }
   remove_click_message()  

function remove_auto_message(){
   setTimeout(function(){$('.panel_overlay_message,.messagg').fadeOut('fast',function(){$(this).remove()})},o.delay)
   o.post_close.call(this);
}   
function remove_click_message(){
 $(document).delegate('.chiudi_message','click',function(){
   $('.panel_overlay_message,.messagg').fadeOut('fast',function(){$(this).remove()});
   o.post_close.call(this);
 }); 
}

};
 
$.remove_message = function() { 
  $('.panel_overlay_message,.messagg').fadeOut('fast',function(){$(this).remove()})
}; 

   
})(jQuery);

jQuery(document).ready(function($) {

/***************** menu documentazione con overlay *************/
$('#documentazione').click(function(){
 $.add_message({
  post_message:function(){

  },
  tipo:'form',
  closable:true
 });
  $('.contenuto_messagg').load('documentazione.html') 
 return false;
});
/***************** DOVE SIAMO *************/
$('iframe').each(function(){
 var src = $(this).attr('src')
 if (src.indexOf('?')>-1){
  $(this).attr({'src':src+'&wmode=transparent','wmode':'Opaque'})
 }else{
  $(this).attr({'src':src+'?wmode=transparent','wmode':'Opaque'})
 }
}); 
$('#dove_siamo').click(function(){
 $.add_message({
  post_message:function(){

  },
  w_message:660,
  h_message:400,
  tipo:'form',
  closable:true
 });
  $('.contenuto_messagg').load('dove_siamo.html')
 return false;
});


$('.area_riservata a').click(function(){
var agent = navigator.userAgent.toLowerCase();
if(agent.indexOf('iphone') <= 0 || agent.indexOf('ipad') <= 0 || agent.indexOf('ipod') <= 0){
  window.location = "ar.asp";
  //return false
}
 $.add_message({
  post_message:function(){

  },
  messaggio:'<br/><br/><form name="form1" method="post" action="http://'+window.location.host+'/admin/login/controllo.asp">'
+'<table border="0" width="100%" cellspacing="10" cellpadding="0">'
	+'<tr>'
		+'<td align="left" valign="top">NOME UTENTE:</td>'
		+'<td align="left" valign="top"><input name="utente" type="text" id="utente"></td>'
	+'</tr>'
	+'<tr>'
		+'<td align="left" valign="top"><br/>PASSWORD:</td>'
		+'<td align="left" valign="top"><br/><input name="pword" type="password" id="pword"></td>'
	+'</tr>'
	+'<tr>'
		+'<td align="left" valign="top">&nbsp;</td>'
		+'<td align="right" valign="top"><br/><input type="submit" name="Submit" value="ACCEDI"></td>'
	+'</tr>'
+'</table>'
+'</form>',
  tipo:'form',
  closable:true
 });
  
 return false;
}); 

			$('.cn_item,.cn_item p')
			.css('height','100%')
			$('.cn_content').find('a').attr('target','_blank')
			Cufon('.cn_wrapper h1', {
			    fontFamily: 'TitilliumText22L-Bold',
				textShadow: '-1px 1px #ccc',
				color:'#3399ff'
				
			});    
			Cufon('.cn_wrapper h2', {
			    fontFamily: 'TitilliumText22L-Bold',
				textShadow: '-1px 1px black',
				color:'#fff'
			}); 				
 $('a.back').click(function(){
        parent.history.back();
        //return false;
    });	
	// Show/Hide slide show buttons
	// -------------------------------------------------------------------
	// This will show/hide the slide show buttons for Next and Previous
	// on the jQuery Cycle plugin slide show.
	
	if ($('#CyclePlugin #Slides').length > 0) {
		// on mouse over/out functions
		if (typeof $.fn.hoverIntent == 'function') {
			$('#SlideShow').hoverIntent(function() {showSlideNav(jQuery)}, function() {hideSlideNav(jQuery)});
		} else {
			$('#SlideShow').hover(function() {showSlideNav(jQuery)}, function() {hideSlideNav(jQuery)});
		}
		// Hide on page load...
		if ($('#SlideShow-Controls')) {
			var initHideSlideNav = setTimeout("hideSlideNav(jQuery)", 1000);	// delay in milliseconds
		}
	}


	// initialize modal (fancybox)
	// -------------------------------------------------------------------
	
	// Quickly setup some special references
	// fancybox doesn't like #name references at the end of links so we find
	// them and modify the link to use a class and remove the #name.
	$('a[href$="#popup"]').addClass('zoom').each( function() {
		$(this).attr('href', this.href.replace('#popup',''));
	});
	
	// setup fancybox for YouTube
	$("a.zoom[href*='http://www.youtube.com/watch?']").each( function() {
		$(this).addClass('fancyYouTube').removeClass('zoom');
	});

	// setup fancybox for Vimeo
	$("a.zoom[href*='http://www.vimeo.com/']").each( function() {
		$(this).addClass('fancyVimeo').removeClass('zoom');
	});
	

	var overlayColor = '#2c2c2c';
	
	// fancybox - default
	$('a.zoom').fancybox({
		'padding': 1,
		'overlayOpacity': 0.2,
		'overlayColor': overlayColor, 
		'onComplete': modalStart
	});
	
	// fancybox - YouTube
	$('a.fancyYouTube').click(function() {
		jQuery.fancybox({
			'padding': 1,
			'overlayOpacity': 0.2,
			'overlayColor': overlayColor, 
			'onComplete': modalStart,
			'title': this.title,
			'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type': 'swf',
			'swf': {
				'wmode': 'transparent',
				'allowfullscreen'	: 'true'} // <-- flashvars
		});
		return false;
	});

	// fancybox - Vimeo	
	$("a.fancyVimeo").click(function() {
		$.fancybox({
			'padding': 1,
			'overlayOpacity': 0.2,
			'overlayColor': overlayColor, 
			'onComplete': modalStart,
			'title': this.title,
			'href': this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
			'type': 'swf'
		});
		return false;
	});


	// Text and password input styling
	// -------------------------------------------------------------------
	
	// This should be in the CSS file but IE 6 will ignore it.
	// If you have an input you don't want styles, add the class "noStyle"

	$("input[type='text']:not(.noStyle), input[type='password']:not(.noStyle)").each(function(){
		$(this).addClass('textInput');
	});
	// Focus and blur style changing
	$('.textInput').blur( function() {
		$(this).removeClass('inputFocus');
	}).focus( function() {
		$(this).addClass('inputFocus');
	});
	
	
	// portfolio item height test (prevents long titles from causing gaps)
	// -------------------------------------------------------------------
	if ($('.portfolioDescription:not(.portfolioStyle-2 .portfolioDescription)').length > 0 ) {
		var pi = $('.portfolioDescription:not(.portfolioStyle-2 .portfolioDescription)');
		pi.each( function(i, val) {
			//if ($(pi[i]).parents('.portfolioStyle-2').length <= 0) {
				if (pi[i].scrollHeight > 120) {
					pi.css('height',pi[i].scrollHeight+'px');
					return false;
				}
			//}
		});
	}


	// FAQ's functionality
	// -------------------------------------------------------------------
	if ($('.faqs li').length > 0 ) {
		var faqs = $('.faqs li');
		faqs.each( function() {
			var q = $(this);
			q.children('.question').click( function() {
				q.children('div').slideToggle('fast', function() {
					// Animation complete...
				});
			});
		});
	}


	// input lable replacement
	// -------------------------------------------------------------------
	$("label.overlabel").overlabel();

	// apply custom search input functions
	// -------------------------------------------------------------------
	searchInputEffect();
	
	// apply image icon overlays
	// -------------------------------------------------------------------
	imgIconOverlay(jQuery);

	// apply custom button styles
	// -------------------------------------------------------------------
	buttonStyles(jQuery);

});




// ======================================================================
//
//	Design functions
//
// ======================================================================


	
// Search input - custom effects for mouse over and focus.
// -------------------------------------------------------------------

function searchInputEffect() {
	$ = jQuery;
	var	searchFocus = false,
		searchHover = false,
		searchCtnr = $('#Search'),
		searchInput = $('#SearchInput'),
		searchSubmit = $('#SearchSubmit');
	// Search input - mouse events
	if (searchCtnr.length > 0) {
		searchCtnr.hover(
			function () {	// mouseover
				if (!searchFocus) $(this).addClass('searchHover');
				searchHover = true; }, 
			function () {	// mouseout
				if (!searchFocus) $(this).removeClass('searchHover');
				searchHover = false;
		}).mousedown( function() {
			if (!searchFocus) $(this).removeClass('searchHover').addClass('searchActive');
		}).mouseup( function() {
			searchInput.focus();
			searchSubmit.show();
			searchFocus = true;
		});
		// set focus/blur events
		searchInput.blur( function() {
			if (!searchHover && searchInput.val().replace(/ /gi, '') == '') {
				searchCtnr.removeClass('searchActive');
				searchSubmit.hide();
				searchFocus = false;
			}
		});
	}
}


// Functions to show and hide slide navigation controls (for cycle SS)
// -------------------------------------------------------------------

	// show slide navigation
	function showSlideNav($) {
		if ($('#SlideShow-Controls').length > 0) {
			$('#SlideShow-Controls').slideDown('fast');
		}		
	}
	// hide slide navigation
	function hideSlideNav($) {
		if ($('#SlideShow-Controls').length > 0) {
			$('#SlideShow-Controls').slideUp('fast');
		}
	}



// button styling function
// -------------------------------------------------------------------

function buttonStyles($) {
	// Button styles
	
	// This will style buttons to match the theme. If you don't want a button
	// styled, give it the class "noStyle" and it will be skipped.
	$("button:not(:has(span),.noStyle), input[type='submit']:not(.noStyle), input[type='button']:not(.noStyle)").each(function(){
		var	b = $(this),
			tt = b.html() || b.val();
		
		// convert submit inputs into buttons
		if (!b.html()) {
			b = ($(this).attr('type') == 'submit') ? $('<button type="submit">') : $('<button>');
			b.insertAfter(this).addClass(this.className).attr('id',this.id);
			$(this).remove();	// remove input
		}
		b.text('').addClass('btn').append($('<span>').html(tt));	// rebuilds the button
	});
	
	// Get all styled buttons
	var styledButtons = $('.btn');
	
	// Fix minor problem with Mozilla and WebKit rendering (can also be done adding this to CSS, 
	// button::-moz-focus-inner {border: none;}
	// @media screen and (-webkit-min-device-pixel-ratio:0) { button span {margin-top: -1px;} }
	if (jQuery.browser.mozilla || jQuery.browser.webkit) {
		styledButtons.children("span").css("margin-top", "-1px");
	}
	
	// Button hover class (IE 6 needs this)
	styledButtons.hover(
		function(){ $(this).addClass('submitBtnHover'); },		// mouseover
		function(){ $(this).removeClass('submitBtnHover'); }	// mouseout
	);
}


// Image icon overlay (hover shows icon - zoom, play, etc...)
// -------------------------------------------------------------------

function imgIconOverlay($) {

	if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) {
		// IE 6 sucks so the effect doesn't work at all and that's why we skip it here
		// we coluld do something different for IE 6 in this area if we wanted 
	} else {
		// This will select the items which should include the image overlays
		$("a.imgSmall:not(.noIcon), a.imgMedium:not(.noIcon), a.imgLarge:not(.noIcon), a.imgTall:not(.noIcon)").each(function(){
			var	ctnr = $(this);
			// insert the overlay image
			if (ctnr.children('img')) {
				if (ctnr.hasClass('iconPlay')) {
					ctnr.children('img').after($('<div class="imgOverlay symbolPlay"></div>'));
				} else if  (ctnr.hasClass('iconDoc')) {
					ctnr.children('img').after($('<div class="imgOverlay symbolDoc"></div>'));
				} else {
					ctnr.children('img').after($('<div class="imgOverlay symbolZoom"></div>'));
				} 
			}
			
			var overImg = ctnr.children('.imgOverlay'); 
			
			if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 9) {
				// IE sucks at fading PNG's with gradients so just use show hide
				overImg.css('visibility','hidden'); // not visible to start 
				
				ctnr.hoverIntent(
					function(){ overImg.css('visibility','visible'); },		// mouseover
					function(){ overImg.css('visibility','hidden'); }		// mouseout
				);
			} else {
				// make sure it's not visible to start 
				overImg.css('opacity',0);
				
				ctnr.hoverIntent(
					function(){ overImg.animate({'opacity':'1'},'fast'); },		// mouseover
					function(){ overImg.animate({'opacity':'0'},'fast'); }		// mouseout
				);
			}
		});
	}
	
}


// Modal after load functions
// -------------------------------------------------------------------

function modalStart() {
	// apply font replacement
	Cufon.replace('#fancybox-title-main', { fontFamily: 'TitilliumText22L-Thin' });
}


// Apply font replacement (cufon)
// -------------------------------------------------------------------
Cufon.replace('h1, h2, h3, h4, h5, h6, #fancybox-title-main', { fontFamily: 'TitilliumText22L-Thin' });
Cufon.replace('.pageTitle, #Showcase h1, #Showcase h2, #Showcase h3, #Showcase h4, #Showcase h5, #Showcase h6', { fontFamily: 'TitilliumText22L-Light' });

