//nascondo le label del form solo a chi ha javascript abilitato
if (document.getElementById) {
  document.write('<style type="text/css">#area_riservata label{position:absolute;left:-10000px;top:-10000px;width:1px;height:1px;overflow:hidden} #playlist{height:328px;overflow:hidden;}<\/style>');
}
//imposta target _blank ai link esterni
function linkext(){
	$("a.ext, a.link").each(function () {
		 $(this).attr({ 
          target: "_blank",
          title: $(this).attr("title")+" (link esterno, si apre in una nuova finestra)"
        });
	});
}
//aggiunge il css per i bordi arrotondati in Opera
function borderOpera(){
    var userAgent = navigator.userAgent.toLowerCase();
    $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
    if($.browser.opera){
		$('head').append('<link rel="stylesheet" href="css/borders.css" type="text/css" />');
    }
}

//riempie i campi del form di login col testo delle label
function createValueLabel (selector, defaultValue){
  //assign the default value to the form selector
  $(selector).data("default", defaultValue);
  //assign a function to the focus and blur events
  $(selector).bind("focus blur", function(){
    value = $(this).val();
    //if the current and default value are the same, clear the input field
    if(value==defaultValue){ $(this)
     .val("")
     .removeClass("value-label");
    }
    //if the field is empty, set the value to default
    if(!value){ $(this)
      .addClass("value-label")
      .val(defaultValue);
    }
  });
  //invoke the events to initialize the default value
  $(selector).val(defaultValue);
}

//init
$(document).ready(function(){
  $("#processi").tabs("#playlist > div", { 
    //effect: 'fade'
  }).slideshow({clickable: false});
	/*****FLASH EMBEDDING VIDEO*****/
	$(".video .player a img").remove();
	$(".video .player a").flowplayer({ 
    src: "swf/flowplayer-3.1.5.swf", 
	expressInstall: "swf/expressinstall.swf",
	wmode: 'transparent',  
    version: [10, 0]
    } , { 
		clip:{
			//url: 'swf/05imballaggio.flv',
			autoPlay: false,
			scaling: 'fit'
			},
		canvas: { 
			backgroundGradient: 'none' 
		},
		plugins:  { 
			controls: {             
				// custom colors 
				bufferColor: '#dbe2f2', 
				progressColor: '#8185a0',             
				buttonColor: '#8E93AF', 
				buttonOverColor: '#AEB2CB', 
				backgroundColor: '#333333',
				timeColor: '#dbe2f2',
				tooltipColor: '#85889A',
				opacity:0.7,
				//scrubber
				scrubberHeightRatio: 0.6,
				scrubberBarHeightRatio: 0.6,
				volumeSliderHeightRatio: 0.6,
				volumeBarHeightRatio: 0.6,
				// setup auto hide 
				autoHide: 'always',
				//hideDelay: 2000,
				//tooltips
				tooltips:  { 
					// a shortcut for enabling tooltips for buttons (English) 
					buttons: true,
					play: null,
					pause: null
				},
				// a little more styling              
				width: '98%',  
				bottom: 5, 
				left: '50%', 
				borderRadius: 10
			} 
		} 
});
  /*---fine FLASH EMBEDDING---*/
  $("#area_riservata label").each(function(){
    label = $(this).html();
    selector = "#"+$(this).attr("for");
    createValueLabel(selector, label);
	$(selector).addClass("value-label")
  });
  //$("#menu h3 a").attr("href","#");
  borderOpera();
  $('#menu').superfish({ 
            delay:       200,
            animation:   {opacity:'show',height:'show'},
            autoArrows:  false,
            dropShadows: false
        }); 
	$('.ita #banner').flashembed({
		src: 'swf/banner.swf',  
		version: [10, 0],
		wmode: 'transparent',
		quality:'high'
	});
		$('.eng #banner').flashembed({
		src: 'swf/banner_en.swf',  
		version: [10, 0],
		wmode: 'transparent',
		quality:'high'
	});

  $("#nav a").show().click(function(){
    return false;
	});

  /*$(".tooltip").removeClass("tooltip").addClass("tooltip_js");
  $("#punti h3").tooltip({
	effect: 'slide',
	relative: true,
	offset: [35, -25]
  });*/
  linkext();
});
