$(document).ready(function() {
$("#bookmarkme").click(function() {
if (window.sidebar) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(location.href,document.title,"");
} else if(window.external) { // IE Favorite
window.external.AddFavorite(location.href,document.title); }
else if(window.opera && window.print) { // Opera Hotlist
this.title=document.title;
return true;
}
});
});



function RollTab(id, tipologia, path) {
	tab = document.getElementById('tab_'+id);
	
	if (tipologia == 1) {
		tab.style.backgroundImage = "url("+path+"/img/graphics/tab2.png)";
	} else {
		tab.style.backgroundImage = "url("+path+"/img/graphics/tab1.png)";
	}
	

}
var activebox='id1';
function jShow(id){
	
	
	
	for(var i=1; i<5; i++){
		document.getElementById("id"+i).style.display="none";
		document.getElementById("xid"+i).style.backgroundColor="#fff";
	}
	//$('#'+id).fadeIn();
	document.getElementById(id).style.display="block";
	document.getElementById("x"+id).style.backgroundColor="#f5fbff";
	//$('#x'+id).css('','');
	//$('#bigBox div').hide(function(){$('#'+id).fadeIn();});
}

	function Show(id) {
		$('#'+id).fadeIn();
		//var element = document.getElementById(id);
        var ele = document.getElementById('x'+id);
		//element.style.display='block';
        ele.style.background='#f5fbff';
	}
	
	function Hide(id) {
		var element = document.getElementById(id);
        var ele = document.getElementById('x'+id);
		element.style.display='none';
        ele.style.background='#ffffff';
	}

function FocusOn() {
	if (document.personali.nome.value == '')
	{
		alert('Attenzione, inserisci il tuo nome');
		return(false);
	}

	if (document.personali.telefono.value == '')
	{
		alert('Attenzione, inserisci il tuo numero di telefono');
		return(false);
	}

	if (document.personali.provincia.value == '')
	{
		alert('Attenzione, inserisci la tua provincia');
		return(false);
	}

	if (document.personali.mail.value == '')
	{
		alert('Attenzione, inserisci un indirizzo di e-mail valido!');
		return(false);
	}

	if (document.personali.messaggio.value == '')
	{
		alert('Attenzione, inserisci il tuo messaggio!');
		return(false);
	}

	if (!document.personali.privacy.checked)
	{
		alert('Attenzione, devi acconsentire al trattamento dei tuoi dati personali!');
		return(false);
	}
}

function ShowNews(value) {
	if (value == 1)
	{
		document.getElementById('id_news_1').style.display = 'block';
		document.getElementById('id_news_2').style.display = 'none';
		document.getElementById('id_news_3').style.display = 'none';

		document.getElementById('puls_1').style.backgroundColor = '#90d50b';
		document.getElementById('puls_2').style.backgroundColor = '#FFF';
		document.getElementById('puls_3').style.backgroundColor = '#FFF';
	}

	if (value == 2)
	{
		document.getElementById('id_news_1').style.display = 'none';
		document.getElementById('id_news_2').style.display = 'block';
		document.getElementById('id_news_3').style.display = 'none';

		document.getElementById('puls_2').style.backgroundColor = '#90d50b';
		document.getElementById('puls_1').style.backgroundColor = '#FFF';
		document.getElementById('puls_3').style.backgroundColor = '#FFF';
	}

	if (value == 3)
	{
		document.getElementById('id_news_1').style.display = 'none';
		document.getElementById('id_news_2').style.display = 'none';
		document.getElementById('id_news_3').style.display = 'block';
		
		document.getElementById('puls_3').style.backgroundColor = '#90d50b';
		document.getElementById('puls_2').style.backgroundColor = '#FFF';
		document.getElementById('puls_1').style.backgroundColor = '#FFF';
	}
}
$(function(){
	//slider
	$('#xid1,#xid2,#xid3,#xid4').hover(function(){
		$('div[id^=xid]').css('backgroundColor','#fff');
		$('div[id^=xid]').css('color','#6a6061');
		$(this).css('backgroundColor','#90d50b');
		$(this).css('color','#000');
		var el=$(this).attr('id').replace('x','');
		$('.groupClass').stop().animate({height:'0px'});
		$('#'+el).stop().animate({height:'340px'});
	});
	//news
	$('.puls_news').hover(function(){
		$('.puls_news').css('backgroundColor','#fff');
		$(this).css('backgroundColor','#90d50b');
		var el=$(this).attr('id').replace('puls_','id_news_');
		$('.groupNews').stop().animate({width:'0px'});
		$('#'+el).stop().animate({width:'347px'});
	});
	//tooltips
    $('.tt').poshytip({
		className: 'tip-yellowsimple',
		alignTo: 'target',
		alignX: 'center',
		alignY: 'top',
		offsetY: 5
	});
	//tabmenu
	$('#menu ul li').hover(function(){
		var id=$(this).attr('id').replace('tab_','sub');
		$('.groupSub').stop().animate({height:'0px'});
		$('#'+id).stop().animate({height:'26px'});
	});
	//lightbox prodotti
	$('a[rel^=lightbox]').lightBox();
	
	if(document.getElementById('sbi')){
		var q=document.getElementById('sbi');
		q.onfocus=function(){
			if(q.value=="Cerca"){
				q.value="";
			}
		}
		q.onblur=function(){
			if(q.value==""){
				q.value="Cerca";
			}
		}
	}
	
	if (document.attachEvent){
		window.attachEvent("onscroll",starter);
	}else{
		window.addEventListener('scroll',starter,false);
	}
	
});

var t
function starter(){
	clearTimeout(t);
	t=setTimeout('jqscrolling()',25);
}

function jqscrolling(){
	scrollamount=window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
	$('#FloatMail').stop(true, true).animate({marginTop: scrollamount+"px"},700,'swing');
}
