$(document).ready(function() {	
	
	//$('#menu ul li:last').css('background','transparent');
	//$('ul.newsTicker li:last,ul.promotionTicker li:last').css({'border-bottom':'none','margin-bottom':'0px'});
	
	$('#getNewsletter, #userDetails').resetForm();
	
	//$('#staticContent').pager('div', {height: '320px'});
	//$('#pagingContent').pager('div', {height: '320px'});
	
	/*var flashContentHeight = $('#staticContent').height() + 72;
	$('#flashcontent').height(flashContentHeight).css({backgroundColor:"#000000"});*/
	
	
	//FUNZIONE PER IL ROLLOVER DELLE THUMB PHOTOGALLERY
	var thumbOpacity = '0.5';
	
	//$('ul.photogallery li a img').css({opacity:thumbOpacity});	
	
	/*
	$('ul.photogallery li a').hoverIntent(function() {
		$(this).find('img').animate({ opacity: 1 }, "normal");
	},
	function() {
		$(this).find('img').animate({ opacity: thumbOpacity }, "fast");
	});
	*/
	
	//FUNZIONE PER L'HIGHLIGHT DEL SUBMENU 
	$('ul.subMenu li a').each(function (i) {
			var myBaseUrl = jQuery.url.attr('file'); //file restituisce il nome file, ma senza query string, non ha '/' davanti
			//var myBaseUrl = jQuery.url.attr('relative'); //relative restituisce il path relativo, query string inclusa, ma ha un '/' davanti 
			var mySubmenuLink = $(this).attr('href');
						
			if (myBaseUrl==mySubmenuLink) {
				$(this).addClass('current');
			}
      });
	
	//FUNZIONE PER GESTIRE I ROLLOVER
	$(".rollover").hover(
	function() {
	  curr = $(this).find("img").attr("src");
	  overlen = curr.length;
	  over = curr.substr(0, overlen-4);
	  over = over+'_over.png';
	  $(this).find("img").attr({ src: over});
	},
	function() {
	  $(this).find("img").attr({ src: curr});
	}
	)

	$(".rollover").find("img").each(function(i) {
	  temp = this.src;
	  prelen = temp.length;
	  pre = temp.substr(0, prelen-4);
	  pre = pre+'_over.png';
	  preload_image_object = new Image();
	  preload_image_object.src = pre;
	});
					
	$(function() {
					$("a.blank").attr("target","_blank");
				});
	
	$('input.myTextinput, textarea.myTextarea, select.mySelect').focus(
					function() {
						$(this).css('border','1px solid #006633');
					});
	$('input.myTextinput, textarea.myTextarea, select.mySelect').blur(
					function() {
						$(this).css('border','1px solid #CCCCCC');
					});
	$('input.myTextinput, input.editableField').focus(function() {
    				if(this.value==this.defaultValue) {
					this.value=''
					}
					});
	$('input.myTextinput, input.editableField').blur(function() {
					if(this.value=='') {
					this.value=this.defaultValue
					}
					});
	
	$('input.editableField').focus(
			  function() {
				  $(this).css('background-color','#FFFFFF');
				  $(this).parent().css({'background-image':'none','background-color':'#FFFFFF'});
			  });
	$('input.editableField').blur(
			  function() {
				  $(this).css('background-color','#F3F3F3');
				  $(this).parent().css({'background-image':'url(../img/icon_editThis.png)','background-color':'#F3F3F3'});
			  });
	
	// INIZIO TOOOLTIP HELP REGISTRAZIONE
	$('a.codeBarToggler').hover(
		function() {
		this.tip = this.title;		
		$(this).append(
			'<div id="codeBarHint">'
				+'<div class="codeBarInner">'
					+'<p class="hint">'
						+this.tip
					+'</p>'	
				+'</div>'
			+'</div>'
		);
		this.title = "";
		//this.width = $(this).width();
		$(this).find('#codeBarHint').css({left:15,top:-15})
		$('#codeBarHint').fadeIn(500);
	},
	function() {
		$('#codeBarHint').fadeOut(300, function() {
				$('#codeBarHint').remove();							
			});
			this.title = this.tip;
		}
	);
	// FINE TOOOLTIP HELP REGISTRAZIONE
	
	 	
	
});

function getApertureStraordinarie() {
	$('<a />').colorbox({bgOpacity:0.6, fixedWidth:"500px", fixedHeight:"500px", href:"straordinarie.php", open:true});
	//$('#homeModalToggler').hide();
} 

function getNewsModal(id_news) {
	$('#'+id_news).colorbox({bgOpacity:0.6, fixedWidth:"800px",  href:"news.php?id_news="+id_news, open:true});
	//$('#homeModalToggler').hide();
} 

function getPromotionModal(id_promozione) {
	$('#'+id_promozione).colorbox({bgOpacity:0.6, fixedWidth:"800px",  href:"promozioni.php?id_promozione="+id_promozione, open:true});
	//$('#homeModalToggler').hide();
} 


function get_obj(id){
	return document.getElementById(id);
}

