



// JQuery AJAX loader generico
	function ajax(obj,page) {
	
		$(obj).load(page);
	
	}
	

	// Mostra oggetto
	function show(objRef) {
	
		$(objRef).show();
	
	}
	
	// Nascondi oggetto
	function hide(objRef) {
	
		$(objRef).hide();
	
	}	

	
	// toggle generico
	function toggle(objID) {
	
		obj = document.getElementById(objID);
		
		if (obj.style.display == 'none') {
		
			obj.style.display = 'block';
		
		} else if (obj.style.display == 'block') {
		
			obj.style.display = 'none';
		
		}
	
	}

	
	
	
	
	
	// chiudi cluetip
		function chiudi(obj) {
		
		obj = document.getElementById("cluetip");
		obj.style.display = 'none';
	
	}			
	
	
    // Carica le ultime news di una specifica categoria
    function load_Ricerca_e_Notizie(catID,obj) {
	    // alert(obj);
		$("#menuRicerca-tessuto a").removeClass('current');	
		$(".tabs a").removeClass('current');
		$("#" + obj).addClass('current');
		
		$("#bottoneCluetip").addClass('current');
		$("#galleria .belt").load('_news.php?catID=' + catID);		
	} 
	
	
	
	// togli la classe current{
		function rimuovi_current (obj){
		
		obj = document.getElementById(obj);
		
		$("#menuRicerca-tessuto a").removeClass('current');	
		$(obj).addClass('current');
	}
	
	// togli la classe current{
		function rimuovi_current_2 (obj){
		$("#menuRicerca-tessuto a").removeClass('current');	
	}
	
	
	// Esegue il submit del form
	function doSubmit(formID) {
	
		document.getElementById(formID).submit();
	
	}
	
	function controllaNazione(value, action) {
		if(!value.indexOf('a')){
			$("#selectArea").css("display", "block");
			$("#selectArea").load('_select_area.php?nazione=' + value);
		} else {
			$("#selectArea").css("display", "none");
			if(value != 0 && action == 1){
				doSubmit('frmContattaci');
			}
		}
	}
	
	
	function cambioNazione(selectNazione, selectProvincia, inputProvincia){
		//alert(selectNazione);
		var nazione = document.getElementById(selectNazione);
		var provincia = document.getElementById(selectProvincia);
		var provincia2 = document.getElementById(inputProvincia);
		
		if(nazione[nazione.selectedIndex].value == 106){
			provincia.style.display = 'block';
			provincia2.style.display = 'none';
		} else {
			provincia2.style.display = 'block';
			provincia.style.display = 'none';
		}
	
	}
			
			
	$(document).ready( function () {	
				
				
				
				
	$(".imgDx").click(function(){
		$("#speciale").slideUp(600);        
    });
				
				
				
					// 
					
					$('.news_txt img').each(function(i) {
					
						// Se è allineata a SX ... 
						
						var larghezzaFoto = $(this).width();
						var altezzaFoto = $(this).height();
						
     					var alignment = $(this).attr("align");
						if (alignment == 'left') {
						$(this).wrap("<div class='container-foto container-Sx' style='height: "+altezzaFoto+"px; width: "+larghezzaFoto+"px;'></div>");
						} 
						if (alignment == 'middle') {
						$(this).wrap("<div class='container-foto container-Cx' style='height: "+altezzaFoto+"px; width: "+larghezzaFoto+"px;'></div>");
						}
						if (alignment == 'right') {
						$(this).wrap("<div class='container-foto container-Dx' style='height: "+altezzaFoto+"px; width: "+larghezzaFoto+"px;'></div>");
						}
					
					});
					
					$('.p_corpo_pagina img').each(function(i) {
					
						// Se è allineata a SX ... 
						
						var larghezzaFoto = $(this).width();
						var altezzaFoto = $(this).height();
						
     					var alignment = $(this).attr("align");
						if (alignment == 'left') {
						$(this).wrap("<div class='container-foto container-Sx' style='height: "+altezzaFoto+"px; width: "+larghezzaFoto+"px;'></div>");
						} 
						if (alignment == 'middle') {
						$(this).wrap("<div class='container-foto container-Cx' style='height: "+altezzaFoto+"px; width: "+larghezzaFoto+"px;'></div>");
						}
						if (alignment == 'right') {
						$(this).wrap("<div class='container-foto container-Dx' style='height: "+altezzaFoto+"px; width: "+larghezzaFoto+"px;'></div>");
						}
					
					});
					
					
					
					/*///////// sezione news ////////////////////////////////////////////////////////*/
					 
					$('.fotoNotizia img').each(function(i) {

						var larghezzaFoto = $(this).width();
						var altezzaFoto = $(this).height();
						
     					/*var alignment = $(this).attr("align");*/
						
						$(this).wrap("<div class='container-foto' style='height: "+altezzaFoto+"px; width: "+larghezzaFoto+"px;'></div>");
												
					});
					
					
					$(".container-foto").corner("round");
					
					/*//////// LIGHT BOX //////////////////*/
					
					$(function() {
       			 		$("#carousel01 ul li a").lightBox();		
    				});
					
					/*////////////////////////////////////*/				
										
					$("input[@name='decisione']:nth(1)").attr("checked","checked");		
				
					
					
                    $('.blocco-icona img').tooltip({
						showURL: false,
						fade: 250
					}); 
					
					$('.elencoIcone img').tooltip({
						showURL: false,
						fade: 250
					});
					
					$('li.glossario').tooltip({
						showURL: false,
						fade: 250
					});
					
					
					$('.elemento_caratteristica .glossario').tooltip({
						showURL: false,
						fade: 250
					});
					
					
					
					// close the offDiv content sections
                	//(doing this with js instead of css means if no js, content is all visible)
                    $('.paragrafoSupporto > .testoSupporto').hide();
                	// show the correct buttons for each div
                    // they are hidden with css for no-js users
                    $('.paragrafoSupporto > titoloVerde .showLink').show();
                    $('.paragrafoSupporto > titoloVerde .hideLink').hide();
                                    	
                    // show all link
                    $('a.showAll').click(function(){
																										
                        $('#categoriaFaq' + $(this).attr('href') + ' .testoSupporto').slideDown('slow');
                        $('#categoriaFaq' + $(this).attr('href') + ' .paragrafoSupporto').removeClass().addClass('paragrafoSupporto2');
                        $('#categoriaFaq' + $(this).attr('href') + ' a.hideAll').show();
                        $('#categoriaFaq' + $(this).attr('href') + ' a.hideLink').show();
                        $('#categoriaFaq' + $(this).attr('href') + ' a.showLink').hide();    								
                        return false;
                    });
					
                    // hide all link
                    $('a.hideAll').click(function(){
										
                        $('#categoriaFaq' + $(this).attr('href') + ' .testoSupporto').slideUp('slow');
                        $('#categoriaFaq' + $(this).attr('href') + ' .paragrafoSupporto2').removeClass().addClass('paragrafoSupporto');
                        $('#categoriaFaq' + $(this).attr('href') + ' a.showLink').show();
                        $('#categoriaFaq' + $(this).attr('href') + ' a.hideLink').hide();
                        $('#categoriaFaq' + $(this).attr('href') + ' a.showAll').show();
                        return false;
                    });
                	
                     // title is clickable, and toggles the content
                    $(".paragrafoSupporto2 >.titoloVerde").click( function() { 
                      	$(this).next("div").slideToggle('slow');
                    	$(this).parent("div").toggleClass('paragrafoSupporto2');
                		$(this).parent("div").toggleClass('paragrafoSupporto');
                    	$(this).siblings("a").toggle();                			
                     });
                		 
                    $(".paragrafoSupporto >.titoloVerde").click( function() { 
                      	$(this).next("div").slideToggle('slow');
                    	$(this).parent("div").toggleClass('paragrafoSupporto');
                		$(this).parent("div").toggleClass('paragrafoSupporto2');
                    	$(this).siblings("a").toggle();
                
                     } );		 
                		                     
                	$(".titoloRosso").click( function() { 
                      	$(this).next("div").slideToggle('slow');
                    	$(this).siblings("a").toggle();
                     } );
                		
                  
				});
                  
				
				

                function test () {
                	jQuery("input[@type='checkbox'] + label", this).each(function() {
                		//$(this)[0].checked = $(this)[0].checked != true;
                		$(this).cssCheckboxToggle();
                	});
                }
                
                $(document).ready( function () {
                	$("form").cssCheckbox();
                	$("form").submit( function() {
                		alert(
                			
							$("input[@name='cb1']")[0].checked + "\n" +
                			$("input[@name='cb2']")[0].checked
                		);
                		return false;
                	});
                });
                
                jQuery.fn.cssCheckboxToggle = function () {
                	jQuery(this).toggleClass("checked");
                	jQuery(this).prev()[0].checked = !jQuery(this).prev()[0].checked;
                }
                
                jQuery.fn.cssCheckbox = function () {
                
                	jQuery("input[@type='checkbox'] + label", this)
                		.each( function(){
                			if ( jQuery(this).prev()[0].checked )
                				jQuery(this).addClass("checked");
                			})
                		.hover( 
                			function() { jQuery(this).addClass("over"); },
                			function() { jQuery(this).removeClass("over"); }
                			)
                		.click( function() {
                			jQuery(this).cssCheckboxToggle();
                				//.toggleClass("checked")
                				//.prev()[0].checked = !jQuery(this).prev()[0].checked;
                			})
                		.prev().hide();
                }

			
	