// aprire pop-up
function apriPop(url, name, w, h) {
	var l = Math.floor((screen.width-w)/3);
	var t = Math.floor((screen.height-h)/3);
	window.open(url,name,"width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
}

// automazione per show/hide
function setSH() {

	var myElements = ".btSh";

	$(myElements).each(function(i) {

		$(this).click(function() {

			if($(this).next('div').css('display') == 'none')
				$(this).next('div').show('slow');
			else
				$(this).next('div').hide('slow');
		});

	});

}

/* -------------------------------------------------------------------------- */

// VOTO E COMMENTO FOTO

function votaAud(pIdAlbum, pIdFoto, pId_customer, pVotoComm, pAction) {

	$.ajax({
		type: 'POST',
		cache: false,
		url: 'ajaxVotaFoto.php?action='+pAction,
		data: 'idAlbum='+pIdAlbum+'&idFoto='+pIdFoto+'&id_customer='+pId_customer+'&votoComm='+pVotoComm,

		success: function(pPar){

			if(pPar.length>0) {
				alert(pPar);
			}
			else {
				setTimeout ( function(){
					window.location.href=window.location.href;
				}, 500);
			}
		},
		dataType: 'text'
	});

}

function setVotoHover() {

	var myElements = ".stellaVoto";
	var mySrc = '';

	$(myElements).hover(
		function() {
			mySrc = $(this).attr('src');

			$(this).attr('src', 'img/votaGatto_full.gif');
		},
		function() {
			$(this).attr('src', mySrc);
		}
	);
}

/* -------------------------------------------------------------------------- */

$(document).ready(function() {

	setSH();

	setVotoHover();

	if($.browser.msie) {
		if(jQuery.browser.version == '6.0') {

		}
	}

	// FancyBox
	$("a.gallery").fancybox();

});

