
// JavaScript Document

//-----------------------INIZIO BOTTONI LISTINO RICERCA---------------------------//

function boxMenu(){

	$('.boxParametri').hide();

$('.qrt-param .btn_listino a').click(function() {

	 var id = jQuery(this).attr('id'); 

	  $('.btn_listino a.btn_listino_active').addClass("btn_listino_ok").removeClass("btn_listino_active");

	  $("a .btn_listino_ok").click(

					  function () {

						$(this).removeClass("btn_listino_ok");

						$(this).addClass("btn_listino_active");

					  },					  

					  function () {

						$(this).addClass("btn_listino_ok");

						$(this).removeClass("btn_listino_active");

					  }

					);

      $(this).addClass("btn_listino_active").removeClass("btn_listino_normal");

	   //$('.boxParametri','#box-'+id).slideToggle("slow");
		
	   $(".boxParametri").slideUp("slow");

	   $('#box-'+id).slideToggle("slow");

		}, function () {

			var id = jQuery(this).attr('id');

	  $(".boxParametri").slideUp("slow");

	   $('#box-'+id).slideToggle("slow");

	   $(this).addClass("btn_listino_ok").removeClass("btn_listino_active"); 

	});

}

//-----------------------INIZIO BOTTONI gallery home listino---------------------------//

function boxMenuGallery(mar,cmod,ccar){

	$('.container-gallery').hide();

	$('.panes .container-gallery:first').show();

$('.btn_listino a').click(function() {
	
	 var id = jQuery(this).attr('id');

	//alert(id);

	 $('.btn_listino a.btn_listino_active').addClass("btn_listino_normal").removeClass("btn_listino_active");

      $(this).addClass("btn_listino_active").removeClass("btn_listino_normal");

	  // $('.boxParametri','#box-'+id).slideToggle("slow");
	if (id == 'panes_04') {
		//alert("ajax1")
		$(".container-gallery").hide();
		$('#box-panes_04').show();
		$("#box-panes_04").html('<div align="center">loading...</div>');
		jQuery.ajax({
		url: "/listino/correlazioni_video.cfm",
		type: "GET",
		dataType: "html",
		data: {
			"mar": mar,
			"cmod": cmod,
			"ccar": ccar
		},
		async: true,
		success: function (data) {  $("#box-panes_04").html(data); },
		error: function (request) { $("#box-panes_04").html("Error requesting data"); }
	});
		
		
		
	}
	else 
		if (id == 'panes_05') {
		
		$(".container-gallery").hide();
		$('#box-panes_05').show();
		$("#box-panes_05").html('<div align="center">loading...</div>');
		jQuery.ajax({
		url: "/listino/correlazioni_provepdf.cfm",
		type: "GET",
		dataType: "html",
		data: {
			"mar": mar,
			"cmod": cmod,
			"ccar": ccar
		},
		async: true,
		success: function (data) {  $("#box-panes_05").html(data); },
		error: function (request) { $("#box-panes_05").html("Error requesting data"); }
	});
		}
		
	else	
		if (id == 'panes_03') {
		
		$(".container-gallery").hide();
		$('#box-panes_03').show();
		$("#box-panes_03").html('<div align="center">loading...</div>');
		jQuery.ajax({
		url: "/listino/correlazioni_proveutenti.cfm",
		type: "GET",
		dataType: "html",
		data: {
			"mar": mar,
			"cmod": cmod,
			"ccar": ccar
		},
		async: true,
		success: function (data) {  $("#box-panes_03").html(data); },
		error: function (request) { $("#box-panes_03").html("Error requesting data"); }
	});
		}
	else	
		if (id == 'panes_02') {
		
		$(".container-gallery").hide();
		$('#box-panes_02').show();
		$("#box-panes_02").html('<div align="center">loading...</div>');
		jQuery.ajax({
		url: "/listino/correlazioni_provesustrada.cfm",
		type: "GET",
		dataType: "html",
		data: {
			"mar": mar,
			"cmod": cmod,
			"ccar": ccar
		},
		async: true,
		success: function (data) {  $("#box-panes_02").html(data); },
		error: function (request) { $("#box-panes_02").html("Error requesting data"); }
	});
		}
	else	
		if (id == 'panes_01') {
		
		$(".container-gallery").hide();
		$('#box-panes_01').show();
		$("#box-panes_01").html('<div align="center">loading...</div>');
		jQuery.ajax({
		url: "/listino/correlazioni_notizie.cfm",
		type: "GET",
		dataType: "html",
		data: {
			"mar": mar,
			"cmod": cmod,
			"ccar": ccar
		},
		async: true,
		success: function (data) {  $("#box-panes_01").html(data); },
		error: function (request) { $("#box-panes_01").html("Error requesting data"); }
	});
		}
	else	
		if (id == 'panes_06') {
		
		$(".container-gallery").hide();
		$('#box-panes_06').show();
		$("#box-panes_06").html('<div align="center">loading...</div>');
		jQuery.ajax({
		url: "/listino/correlazioni_mandalaprova.cfm",
		type: "GET",
		dataType: "html",
		data: {
			"mar": mar,
			"cmod": cmod,
			"ccar": ccar
		},
		async: true,
		success: function (data) {  $("#box-panes_06").html(data); },
		error: function (request) { $("#box-panes_06").html("Error requesting data"); }
	});
		}
		else {
			$(".container-gallery").hide();
			
			$('#box-' + id).show();
		}
		}, function () {

			var id = jQuery(this).attr('id');

	  $(".container-gallery").hide();

	  $('#box-'+id).show();

	   $(this).addClass("btn_listino_normal").removeClass("btn_listino_active"); 

	});

}

//-----------------------FINE BOTTONI---------------------------//



function paramCheckBox(){

/* BERLINA 2-4 PORTE */ 

$('#box_berlina24').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_berlina24 input').attr("checked","checked");

		}, function () {

	$('#box_berlina24 input').attr("checked","");

	   $('#box_berlina24').removeClass("active");

	});

/* BERLINA 3-5 PORTE */ 

$('#box_berlina35').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_berlina35 input').attr("checked","checked");

		}, function () {

	$('#box_berlina35 input').attr("checked","");

	   $('#box_berlina35').removeClass("active");

	});

/* CABRIO */ 

$('#box_cabrio').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_cabrio input').attr("checked","checked");

		}, function () {

	$('#box_cabrio input').attr("checked","");

	   $('#box_cabrio').removeClass("active");

	});

/* FUORISTRADA APERTA */ 

$('#box_fuoristradaaperta').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_fuoristradaaperta input').attr("checked","checked");

		}, function () {

	$('#box_fuoristradaaperta input').attr("checked","");

	   $('#box_fuoristradaaperta').removeClass("active");

	});

/* FUORISTRADA CHIUSA */ 

$('#box_fuoristradachiusa').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_fuoristradachiusa input').attr("checked","checked");

		}, function () {

	$('#box_fuoristradachiusa input').attr("checked","");

	   $('#box_fuoristradachiusa').removeClass("active");

	});

/* MULTISPAZIO */ 

$('#box_multispazio').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_multispazio input').attr("checked","checked");

		}, function () {

	$('#box_multispazio input').attr("checked","");

	   $('#box_multispazio').removeClass("active");

	});

/* COUPÉ */ 

$('#box_coupe').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_coupe input').attr("checked","checked");

		}, function () {

	$('#box_coupe input').attr("checked","");

	   $('#box_coupe').removeClass("active");

	});

/* STATION WAGON */ 

$('#box_stationwagon').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_stationwagon input').attr("checked","checked");

		}, function () {

	$('#box_stationwagon input').attr("checked","");

	   $('#box_stationwagon').removeClass("active");

	});



/* --- TRAZIONE --- */ 

/* TRAZIONE ANTERIORE*/ 

$('#box_trazant').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_trazant input').attr("checked","checked");

		}, function () {

	$('#box_trazant input').attr("checked","");

	   $('#box_trazant').removeClass("active");

	});

/* TRAZIONE INTEGRALE*/ 

$('#box_trazint').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_trazant input').attr("checked","checked");

		}, function () {

	$('#box_trazint input').attr("checked","");

	   $('#box_trazint').removeClass("active");

	});

/* TRAZIONE POSTERIORE*/ 

$('#box_trazpost').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_trazpost input').attr("checked","checked");

		}, function () {

	$('#box_trazpost input').attr("checked","");

	   $('#box_trazpost').removeClass("active");

	});

/* TRAZIONE ANTERIORE + POSTERIORE*/ 

$('#box_trazantpost').toggle(function() {

      $(this).addClass("active"); 

	   $('#box_trazantpost input').attr("checked","checked");

		}, function () {

	$('#box_trazpost input').attr("checked","");

	   $('#box_trazantpost').removeClass("active");

	});



}



//----------------------- fine jquery carrozzerie + trazione ---------------------------//

function boxElimina(){

		// inizio azioni  eliminazione

			$(".risultati_ricerca .delete").click(function(){

				$(this).parents("li").animate({ opacity: 'hide' }, "slow");

			});

		//	boxPreventivi

			$(".deleteAll").click(function(){

				var id = $(this).attr('rel');						   

				$('#'+ id +' .boxSxRiga').animate({ opacity: 'hide' }, "slow");

			});

			$(".boxSxRiga .delete").click(function(){

				$(this).parents(".boxSxRiga").animate({ opacity: 'hide' }, "slow");

			});

}

//----------------------- fine jquery elimina righe ---------------------------//



function boxEliminaTr(){

		// inizio azioni  eliminazione

			$("#boxCalcoloPrev .delete").click(function(){

				$(this).parents().parents("tr").animate({ opacity: 'hide' }, "slow");

			});

}

//-----------------------inizio azioni box interamente cliccabile---------------------------//

function boxCliccabile(){



			$(".click").click(function(){

    			window.location=$(this).find("a").attr("href");return false;

			});

}

//-----------------------inizio azioni colorazione tabella---------------------------//

function colorTable(){

$('#scheda_tec table tr:odd').addClass('odd');



  $('#scheda_tec table tr:even').addClass('even');

}

//-----------------------inizio function slider prezzi / dimensioni---------------------------//

function sliderTool(){

		

			//prezzi

			$('select#prezzomin, select#prezzomax').selectToUISlider({

				labels: 6

			});

			//potenza

			$('select#potmin, select#potmax').selectToUISlider({

				labels: 4

			});

			//consumo

			$('select#consmin, select#consmax').selectToUISlider({

				labels: 6

			});

			//emissione co2

			$('select#co2min, select#co2max').selectToUISlider({

				labels: 6

			});	

			//velocita

			$('select#velmin, select#velmax').selectToUISlider({

				labels: 6

			});		

			//accelerazione

			$('select#accmin, select#accmax').selectToUISlider({

				labels: 6

			});		

			//bagagliaio

			$('select#bagmin, select#bagmax').selectToUISlider({

				labels: 6

			});		

			//cilindrata

			$('select#cilmin, select#cilmax').selectToUISlider({

				labels: 8

			});			

			//lunghezza

			$('select#dimLungmin, select#dimLungmax').selectToUISlider({

				labels: 0

			});

			//altezza

			$('select#dimAltezmin, select#dimAltezmax').selectToUISlider({

				labels: 0

			});

			//altezza

			$('select#dimLarghmin, select#dimLarghmax').selectToUISlider({

				labels: 0

			});

			//fix color 

			fixToolTipColor();

}

		

//-----------------------inizio function slider prezzi / dimensioni---------------------------//

function sliderToolPrezzo(){

		

			//prezzi

			$('select#prezzomin, select#prezzomax').selectToUISlider({

				labels: 6

			});

			//fix color 

			fixToolTipColor();

}

		

//-----------------------quick function for tooltip color match---------------------------//

function fixToolTipColor(){

	//grab the bg color from the tooltip content - set top border of pointer to same

	$('.ui-tooltip-pointer-down-inner').each(function(){

		var bWidth = $('.ui-tooltip-pointer-down-inner').css('borderTopWidth');

		var bColor = $(this).parents('.ui-slider-tooltip').css('backgroundColor')

		$(this).css('border-top', bWidth+' solid '+bColor);

	});	

}

//-----------------------inizio function angoli---------------------------//

function angoli(){		

		$('.myCorner').corner(); 

		$('.myCorner2').corner("5px");

		$('.CornerTop').corner("top");

		$('.CornerLeft').corner("left");

		$('.CornerBottom').corner("bottom");

		// fine azioni angoli

}





//-----------------------inizio function tooltip hover immagine---------------------------//

function toolTipZoom() {

   // Use the each() method to gain access to each of the elements attributes

   $('.cont-img img').each(function()

   {

      $(this).qtip(

      {

         content: '<img src="/asset/img/nuovo/ico_zoom.gif" alt="zoom" border="0">', // Give it some content

         position: 'bottomRight', // Set its position

         hide: {

            fixed: true // Make it fixed so it can be hovered over

         },

         style: {

		 	background: 'transparent',

			border:'0px',

            padding: '10px 10px' // Give it some extra padding

           // name: 'dark' // And style it with the preset dark theme

         }

      });

   });

}



//-----------------------inizio function Gallery scroll---------------------------//

function galleryScroll() {

 $(".scrollable").scrollable().mousewheel().navigator().find("a").tooltip({ 

 // use this single tooltip element for all trigger elements 
	 lazy:false,
	 tip: '#tooltip' ,
	 fadeOutSpeed: 100,
	 predelay: 10

 });}

 

//-----------------------inizio function Gallery scroll  verticale---------------------------//

function galleryScrollV() {

$(".scrollableVert").scrollable({size: 1, clickable: false }).navigator(".navi.small");

  }

  

//-----------------------inizio function Pngfix---------------------------//

function pngIe(){         

		$(document).pngFix(); 

		}



//----------------------- inizio azioni controllo checkbox-------------------------//

function checkBoxChange(){
$('.box_confMod').toggle(function() {
      $(this).addClass("MdChecked"); 

	  $(this).find('input:checkbox').attr("checked","checked");

		}, function () {

		$(this).removeClass("MdChecked");
 		$(this).find('input:checkbox').attr("checked",""); 

	});

}

//----------------------- inizio azioni controllo checkbox e radio button-------------------------//

function RadioCheckboxChange(){

$('#formAllestimenti input:radio').click(function() {           

    	if($(this).is(':checked')) {

			$(this).parents("tr").find("input:checkbox").attr("checked","checked");

			$(this).parent().parent().parent().parent().parent().parent().parent('#formAllestimenti').find("tr.bkgBase").removeClass('bkgBase');

			$(this).parent().parent().addClass('bkgActive').addClass('bkgBase');	

		}

		});

		

		$('.box_allestimenti input:checkbox').click(function() {           

    	if($(this).is(':checked')) {

			$(this).parent().parent().removeClass('bkgActive');

			$(this).parent().parent().addClass('bkgActive');

		}

		if($(this).is(':not(:checked)')) {
			$(this).parents("tr").find("input:input").attr("checked","");
			$(this).parent().parent().removeClass('bkgActive').removeClass('bkgBase');

		}

		});

}



//----------------------- inizio gallery confronto-------------------------//

function galleryConfronto() { 
 // nasconde il bottone next se i box sono minori di 4
	var elem= $(".items").find(".boxConfronto").length
	if (elem <= 4){
		$(".browse").addClass('disabled');
		}	
 // inizializzazione scroller		
 $(".scrollable").scrollable({size: 4, clickable: false }).mousewheel();

 }

//----------------------- inizio colorazione li-------------------------//

function colorationList(){			 

$('.box_leg_car ul li:odd').addClass('odd');

$('.boxConfronto:odd').addClass('colDisp');

$('.boxConfronto:odd ul li:odd').addClass('oddDisp');

$('.boxConfronto:even ul li:odd').addClass('odd');

$('.confronto_base ul li:odd').addClass('oddBase');

}



//----------------------- open overlayer confronto-------------------------//

function openOverlayer() {

	// if the function argument is given to overlay,

	// it is assumed to be the onBeforeLoad event listener

	$("a[rel]").overlay({



		expose: '#333',

		effect: 'apple',

		onBeforeLoad: function() {

// grab wrapper element inside content

			var wrap = this.getContent().find(".contentWrap");



			// load the page specified in the trigger

			wrap.load(this.getTrigger().attr("href"));

		}

	});
	
		$(".btnCambiaSmall a").click(function(event) {
		 var titolo=$(this).attr("title");
		 var content = $("#overlay");
		 content.find(".txtbig").html(titolo);
		});
}



//----------------------- colore alternato righe-------------------------//



function tablePreventivo (){

  $('#scheda_accessori table tr:even').addClass('even');

}



//----------------------- open tooltip-------------------------//

function openToolTip() { 
    $("a.openTool[title]").tooltip({
	 lazy:false,
	 tip: '#tooltip',
	 position: 'top center',
	 offset:[-34,0],
	 fadeOutSpeed: 100,
	 predelay: 10,
	 onShow: function() {  
                this.getTip().wrapInner("<div></div>"); 
            }  
	})
}



//----------------------- open tooltip-------------------------//

function openToolTipInfo() { 

    $("#box_allestimenti a[title]").tooltip({
	 lazy:false,
	 tip: '#tooltipBase',
	 fadeOutSpeed: 100,
	 predelay: 10
	}); 

}


//----------------------- open overlayer preventivo-------------------------//

function openOverlayerPrev() {

// if the function argument is given to overlay, 

    // it is assumed to be the onBeforeLoad event listener 

    $("#scheda_accessori a[rel]").overlay({ 

        expose: '#333'

    })

}

