//	www.lucazaccaro.it	//
//	versione 4.2.0		//
//	10/07/2011			//
var check = 1;
var block = 0;
var social = 0;
$(document).ready(function () {
	$('#minBlogBar').mouseover(function () {
		if ($(this).attr('class') != "selected") {
			$(this).removeClass('mouseOut');
			$(this).addClass('mouseOver');
		}
	});
	$('#minBlogBar').mouseout(function () {
		if ($(this).attr('class') != "selected") {
			$(this).removeClass('mouseOver');
			$(this).addClass('mouseOut');
		}
	});
	$('#minBlogBar').click(function () {
	   if ($(this).attr('class') != "selected") {
			window.open('http://www.lucazaccaro.it/blog','blank');
		} 		
	});
	$('#minLastBar').click(function () {
	   if ($(this).attr('class') != "selected") {
			window.location.href = "news.php";
		} 		
	});
	$('#minLabsBar').click(function () {
	   if ($(this).attr('class') != "selected") {
			window.location.href = "projects.php";
		} 		
	});
	$('#minLinkBar').click(function () {
	   if ($(this).attr('class') != "selected") {
			window.location.href = "contatti.php";
		} 		
	});
	$('#minLastBar').mouseover(function () {
		if ($(this).attr('class') != "selected") {
			$(this).removeClass('mouseOut');
			$(this).addClass('mouseOver');
		}
	});
	$('#minLastBar').mouseout(function () {
		if ($(this).attr('class') != "selected") {
			$(this).removeClass('mouseOver');
			$(this).addClass('mouseOut');
		}
	});
	$('#minLabsBar').mouseover(function () {
		if ($(this).attr('class') != "selected") {
			$(this).removeClass('mouseOut');
			$(this).addClass('mouseOver');
		}
	});
	$('#minLabsBar').mouseout(function () {
		if ($(this).attr('class') != "selected") {
			$(this).removeClass('mouseOver');
			$(this).addClass('mouseOut');
		}
	});
	$('#minLinkBar').mouseover(function () {
		if ($(this).attr('class') != "selected") {
			$(this).removeClass('mouseOut');
			$(this).addClass('mouseOver');
		}
	});
	$('#minLinkBar').mouseout(function () {
		if ($(this).attr('class') != "selected") {
			$(this).removeClass('mouseOver');
			$(this).addClass('mouseOut');
		}
	});
	$("a#linkTwitter").click(function () {
		block = 1;
		social = 1;
		window.open('http://twitter.com/#!/lucazaccaro','blank');
	}); 
	$("a#linkFacebook").click(function () {
		block = 1;
		social = 1;
		window.open('http://www.facebook.com/lucazaccaro','blank');
	}); 
	$("a#linkLogo").click(function () {
		block = 1;
		social = 1;
		window.location.href = "index.php";
	}); 
	$("a#linkHome").click(function () {
		block = 1;
		social = 1;
		window.location.href = "index.php";
	}); 
	$('#titleBar').click(function () {
		if(social == 0)
		{
			window.location.href = "index.php";
		}
	});
	$('#buttonSubmit').mouseover(function () {
		$(this).removeClass('button');
		$(this).addClass('buttonHovered');
	});
	$('#buttonSubmit').mouseout(function () {
		$(this).removeClass('buttonHovered');
		$(this).addClass('button');
	});
	/*$('#minBlogBar').qtip({
      content: '<img src="images/omnia_logo.png" alt="Omnia - Uno sguardo sul mondo" />'
   	});*/
});
function sendMessage()
	{
		if (window.XMLHttpRequest)
			{
				xmlhttp=new XMLHttpRequest();
			}
		else
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		xmlhttp.open("POST", "ajax/sendMail.php", true);
		xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState==4)
					{
						if (xmlhttp.status==200)
							{
								document.getElementById("responseMessage").innerHTML=xmlhttp.responseText;
							}
					}
				else
					{
						document.getElementById("responseMessage").innerHTML="<img src=\"images/ajax-loader.gif\" /> Invio messaggio in corso..";
					}
					
			}
		var bottone = document.frmContatti.invia.value
		var nome = document.frmContatti.nome.value
		var email = document.frmContatti.email.value
		var messaggio = document.frmContatti.messaggio.value
		var controllo = document.frmContatti.controllo.value
		var addendo1 = document.frmContatti.addendo1.value
		var addendo2 = document.frmContatti.addendo2.value
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.send("bottone="+ bottone +"&nome="+ nome +"&email="+ email +"&messaggio="+ messaggio +"&controllo="+ controllo +"&addendo1="+ addendo1 +"&addendo2="+ addendo2);
	}
function updateDownload(id)
	{
		if (window.XMLHttpRequest)
			{
				xmlhttp=new XMLHttpRequest();
			}
		else
			{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		xmlhttp.open("POST", "ajax/downloader.php", true);
		xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState==4)
					{
						if (xmlhttp.status==200)
							{
								var risposta = xmlhttp.responseText;
								var dati = risposta.split("###")
								var id = dati[0]
								var download = dati[1]
								document.getElementById("counter_" + id).innerHTML="Numero di download: " + download;								
								window.location="download/manager.php?id="+ id;
							}
						else
							{
								window.location="download/manager.php?id="+ id;
							}
					}
			}
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.send("id="+id);
	}
