﻿
$(document).ready(function() {    
  $('.imgover').imghover({suffix: '_over', fade: false, fadeSpeed: 200});
});

$(document).ready(function(){
    
    $(".autoZoom").mouseover(function(event){
    	//alert($(this).parent().parent().attr("id"))
    	//$(this).parent().parent().toggleClass("flashingBorder").toggleClass("flashingBorder_hover");
    	//$(this).toggleClass("flashingBorder").toggleClass("flashingBorder_hover");
			$(this).stop(true);
			//$(this).css({"z-index":"999"});
    	$(this).animate({"width": "200px"}, "slow");
    	$(this).attr({"src" : $(this).attr("bsrc")});
    }).mouseout(function(event){
    	//$(this).toggleClass("flashingBorder").toggleClass("flashingBorder_hover");
			$(this).stop(true);
    	//$(this).animate({"width": "150px"}, "slow", function(event) {$(this).css({"z-index":"1"});});
    	$(this).animate({"width": "150px"}, "slow");
    	//$(this).parent().parent().toggleClass("flashingBorder").toggleClass("flashingBorder_hover");
    	$(this).attr({"src" : $(this).attr("ssrc")});
    });

  });


var bandItemSelId = 'renzo';
function SetBandItem(id) {	
	if(bandItemSelId != id) {
		$("#" + bandItemSelId + ",#" + id).toggle("slow");
	
		bandItemSelId = id;
	}
	return false;
}
function checkAlbumForm(frm) {
	if(frm.txtQta.value>>0 == 0) {
		alert("Inserire una quantità valida!");
		frm.txtQta.focus();
		return false;
	}
	return true;
}
function checkGadgetForm(frm) {
	if(frm.txtQta.value>>0 == 0) {
		alert("Inserire una quantità valida!");
		frm.txtQta.focus();
		return false;
	}
	if(frm.cboSize.value == '') {
		alert("Scegliere una taglia!");
		frm.cboSize.focus();
		return false;
	}
	return true;
}
function deleteCartItem(itemKey) {
	if(confirm("Eliminare l'articolo dal carrello?")) {
		$('#delItem').attr('value', itemKey);		
		$('#frmCart').submit();
		return false;
	}
	
	return false;
}
function checkCartForm(frm) {
	
	
	if(frm.txtNome.value == '') {
		alert("Per proseguire è necessario inserire un nome!");
		frm.txtNome.focus();
		return false;
	}
	if(frm.txtCognome.value == '') {
		alert("Per proseguire è necessario inserire un cognome!");
		frm.txtCognome.focus();
		return false;
	}
	if(frm.txtIndirizzo.value == '') {
		alert("Per proseguire è necessario inserire un indirizzo!");
		frm.txtIndirizzo.focus();
		return false;
	}
	if(frm.txtCAP.value == '') {
		alert("Per proseguire è necessario inserire un CAP!");
		frm.txtCAP.focus();
		return false;
	}
	if(frm.txtCitta.value == '') {
		alert("Per proseguire è necessario inserire una città!");
		frm.txtCitta.focus();
		return false;
	}
	if(frm.txtProvincia.value == '') {
		alert("Per proseguire è necessario inserire una provincia!");
		frm.txtProvincia.focus();
		return false;
	}
	if(frm.txtMail.value == '') {
		alert("Per proseguire è necessario inserire un indirizzo email!");
		frm.txtMail.focus();
		return false;
	}
	if(frm.paymentType.value>>0 == 0) {
		alert("Per proseguire è necessario selezionare una modalità di pagamento!");
		frm.paymentType.focus();
		return false;
	}
	if(!frm.chkPrivacy.checked) {
		alert("Per proseguire è necessario accettare il trattamento dei dati personali!");
		frm.chkPrivacy.focus();
		return false;
	}
	
	return true;
}

var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(id){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#songOverlayBackGround").css({
			"opacity": "0.7"
		});
		$("#songOverlayBackGround").fadeIn("slow");
		$("#popupContact_" + id).fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(id){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#songOverlayBackGround").fadeOut("slow");
		$("#popupContact_" + id).fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(id){
	//request data for centering
	
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupContact_" + id).height();
	var popupWidth = $("#popupContact_" + id).width();
	//centering
	$("#popupContact_" + id).css({
		"position": "absolute",
		"top": 100 + document.body.scrollTop,
		"left": windowWidth / 2 - popupWidth / 2		
	});
	//only need force for IE6
	
	/*$("#songOverlayBackGround").css({
		"height": windowHeight
	});*/
	
}

function showSongText(id) {
	centerPopup(id);
	//load popup
	loadPopup(id);
}
function checkNewMessage(frm) {
	if(frm.txtTitle.value == '') {
		alert("Per proseguire è necessario inserire un titolo!");
		frm.txtTitle.focus();
		return false;
	}
	if(frm.txtMessage.value == '') {
		alert("Per proseguire è necessario inserire un messaggio!");
		frm.txtMessage.focus();
		return false;
	}
	if(frm.txtAuthor.value == '') {
		alert("Per proseguire è necessario inserire un nominativo!");
		frm.txtAuthor.focus();
		return false;
	}
	if(frm.captchacode.value == '') {
		alert("Per proseguire è necessario inserire il codice captcha!");
		frm.captchacode.focus();
		return false;
	}
	
	
	return true;
}
function refreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

function showInfoPayment(cbo) {
	switch(cbo.value>>0) {
		case 1:
			$('#infoPayment_1').fadeIn();
			$('#infoPayment_2').fadeOut("fast");
			break;			
		case 2:
			$('#infoPayment_1').fadeOut("fast");
			$('#infoPayment_2').fadeIn();
			break;
		default:
			$('#infoPayment_1').fadeOut("fast");
			$('#infoPayment_2').fadeOut("fast");
			break;
	}
	
}
