/*
 * inizializazione menu a tendina
 * 
 */

// initialise plugins
		$(document).ready(function() { 
		$('ul.sf-menu').superfish({ 
            delay:       500,                            
            animation:   {height:'show',width:'show'},  
            speed:       'fast',                          
            autoArrows:  false,                           
            dropShadows: false                            
        }); 
		}); 
		
		/*jQuery.fn.delay = function(time,func){
			return this.each(function(){
				setTimeout(func,time);
			});
		};*/


		function chooseLang(){
		 $(document).delay(1000,function(){
		 tb_show('','language.php?KeepThis=true&amp;TB_iframe=true&amp;height=335&amp;width=970&amp;modal=true');
		   });
		}

/*
 * Gestione del carrello
 */
function delCartItem(cod) {
	document.getElementById("qt[" + cod + "]").value = 0;
	document.getElementById("carrello_spesa").submit();
}

/*******************************************************************************
 * 
 * accettazione condizioni di vendita
 * 
 ******************************************************************************/

function ordina(pagamento) {
						
								if (!(document.getElementById('cartagree').checked)) {
									alert('Accettare le condizioni per ordinare.');  
									return false;
								} else {
									document.location.href="/carts/pay_shopping_cart/1/pagamento:"+pagamento;
								}
								
								/*if (aggiorna_dati_consegna()) {
									document.getElementById('form_riepilogo').submit();
									return true;
								} else {
									alert('Warning!');
								}
								return false;*/

						}


/*******************************************************************************
 * 
 * faq script
 * 
 ******************************************************************************/

var old = 'a1';
function openFAQ(id) {
	$(".answer_" + old).hide("slow", function() {
		old = id;
		$(".answer_" + id).slideDown("slow");
	});
	
}





/*******************************************************************************
 * 
 * getProductsList
 * 
 ******************************************************************************/
 
 function getProductsList(div,list,element) { 
							
							$(div+ " > .productList").empty().html('<img src="/img/loadingAnimation.gif" alt="loading..." title="loading..." />');

							 $.ajax({ 
								url: "/products/ajax_view/"+list+"/"+element,
								success: function(data){
									$(div+ " > .productList").hide();
									$(div+ " > .productList").slideDown("slow");
									$(div+ " > .productList").html(data);  
								},
								cache: true
							});
					 
						}
 
 
 
/*******************************************************************************
 * 
 * sendFriend
 * 
 ******************************************************************************/

function show_sendFriend() {
	display = $("#sendfriend").css("display");
	if (display == 'none') {
		$("#sendfriend").slideDown("slow");
	} else {
		$("#sendfriend").slideUp("slow");
	}

}

/*******************************************************************************
 * 
 * /****
 * 
 * 
 * gabriele cuda blumade.com 2/2/2009
 * gabriele cuda blumade.com 31/3/2009
 * 
 ******************************************************************************/
function ajaxRegistration_b() { // non utilizzata
//alert("gas");
/*
html ='<img src="css/loading.gif" alt="loading" style="margin:0 auto;" />';
$("#msgModule").append(html);


	var risposta = $.ajax({
		   type: "GET",
		   url: "registration.php",
		   data: "ajaxEmail=->"+$("#email").value,
		   success: gestisciRisposta
		   }
		 })
*/

}



function ajaxRegistration() {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			document.getElementById("msgModule").innerHTML = xmlHttp.responseText;
		}
	}
	document.getElementById("msgModule").innerHTML = '<img src="css/loading.gif" alt="loading" style="margin:0 auto;" />';
	xmlHttp.open("GET", "registration.php?ajaxEmail=->"
			+ document.getElementById("email").value, true);
	xmlHttp.send(null);
}
