

$(document).ready(function() {
	
	$('.topGallery li:last-child, .bottomGal li:last-child, .stepsCont .block:last-child, .frenoGal1 li:last-child, .frenoGal li:last-child').css({'padding-right': '0'});
	//$('.frenoGal1 ul.bullets li:last-child').css({'padding-left': '11px'});
	$('.enggCatGal .block:last-child').css({'margin-right': '0'});
	$('.ignited img:first-child').css({'margin-top': '4px'});
	
    // TOP MENU ACTIVE 
	$(".mainmenu li a").removeAttr("title");
    $(".mainmenu li.current_page_item a:first-child").addClass("active");
    $(".mainmenu li.current_page_parent a:first-child").addClass("active");
    $(".mainmenu li ul.children a").removeClass("active");
    
    // TOP NAVIGATION DROP MENU
    $(".mainmenu li .children").wrap("<div class='drop'></div>");
    $(".mainmenu li .children").before("<div class='topBg'><span class='left'><!----></span><span class='right'><!----></span><span><!----></span></div>");
    $(".mainmenu li .children").after("<div class='bottomBg'><span class='left'><!----></span><span class='right'><!----></span><span><!----></span></div>");
	/*$(".mainmenu li .children li:first-child").addClass("toplink");
	$(".mainmenu li .children li:last-child").addClass("bottomlink");
	$(".mainmenu li .children li.toplink a span").wrap("<span />");
	$(".mainmenu li .children li.bottomlink a span").wrap("<span />");
	$(".mainmenu li .children li a").unwrap("<span />");*/

	$('.mainmenu li.page-item-17 .drop').css({'width': '170px'});
	
    // FOOTER MENU
	$(".footer .menu li.page-item-13").addClass("home");
	$(".footer .menu li.page-item-15").addClass("prodotti");
	$(".footer .menu li.page-item-17").addClass("engg");
	$(".footer .menu li.page-item-78").addClass("novita");
	$(".footer .menu li.page-item-21").addClass("gallery");
	$(".footer .menu li.page-item-23").addClass("support");
	$(".footer .menu li.page-item-26").addClass("contact");
	$(".footer .menu li.page-item-57").addClass("botPad");
    
	$(".footer .menu li.page-item-51").before("<li class='subhead'>STRADA</li>");
	$(".footer .menu li.page-item-62").before("<li class='subhead'>RACING</li>");
    
	$(".mainmenu li.page-item-51").before("<li class='subhead'>TUNING STRADALE</li>");
	$(".mainmenu li.page-item-62").before("<li class='subhead'>RACING</li>");
 
    
    // Language show/hide
	$('.language img.control').click(function(){
		$('.dropSelectText').toggle();									  
		$('.language .dropmenu').slideToggle('fast');								  
	});
	// Menu Value Select
	$('.language .dropmenu a').click(function() {
		
		var dropText = $(this).parent().html();
		var classVal = $(this).parent().attr('class');
		var langTextLi = '<ul><li class="' +classVal+ '">' +dropText+ '</li></ul>';
		
		$('.language .dropmenu').hide();
		$('.dropSelectText').show();
		$('.dropSelectText').html(langTextLi);
	});
	
	//drop down menu script
	$('.drop').parent('li').hover (
		function() {
			$(this).children('.drop').show();
			$(this).children('a:first-child').addClass('hoverActive');
		},
		function() {
			$(this).children('.drop').hide();
			$(this).children('a:first-child').removeClass('hoverActive');
	});
	
	//footer social media
	$('.socialmedia img').each(function() {
		
		var tipId = "#" + $(this).attr('alt');
		var src1= $(this).attr('src'); // initial src
		var newSrc = src1.substring(src1.lastIndexOf('/'), src1.lastIndexOf('.')); 
		
		$(this).hover (
			function() {
				$(this).attr('src', 'http://it.tarox.com/wp-content/themes/tarox/images/' +newSrc+ '-active.' + /[^.]+$/.exec(src1));
				$(tipId).show();
			},
			function() {
				$(this).attr('src', 'http://it.tarox.com/wp-content/themes/tarox/images/' +newSrc + '.' + /[^.]+$/.exec(src1));
				$(tipId).hide();
		});
										
	});
	
	$(".enggCatGal .block").hover(function() {
		$(this).addClass('active');
	},
	function() {
		$(this).removeClass('active');
	});
	
	// Novita Video Show hide
	$(".stepsCont .block img, .imageGallery .block img").click(function() {
		$(this).hide();									  
		$(this).next('.video').show();								   
	});
	
	// Contact Form Select Valu assignment
	$(".jquery-selectbox-list span.item-1").click(function() {
		$('#selectVal').attr('value', 'sales@tarox.com');
	});
	$(".jquery-selectbox-list span.item-2").click(function() {
		$('#selectVal').attr('value', 'acquisti@tarox.com');
	});
	$(".jquery-selectbox-list span.item-3").click(function() {
		$('#selectVal').attr('value', 'help@tarox.com');
	});
	$(".jquery-selectbox-list span.item-4").click(function() {
		$('#selectVal').attr('value', 'engineering@tarox.com');
	});
	$(".jquery-selectbox-list span.item-5").click(function() {
		$('#selectVal').attr('value', 'press@tarox.com');
	});
	
	/*$("#budgetDrop option").each(function() {
		var optionVal = $(this).html();
		
		if (optionVal=="Ufficio vendite") {
			$(this).attr('value', 'sales@tarox.com');
		} 
		else if(optionVal=="Ufficio acquisti") {
			$(this).attr('value', 'acquisti@tarox.com');
		}
		else if(optionVal=="Supporto tecnico") {
			$(this).attr('value', 'help@tarox.com');
		}
		else if(optionVal=="Divisione Engineering") {
			$(this).attr('value', 'engineering@tarox.com');
		}
		else if(optionVal=="Stampa") {
			$(this).attr('value', 'press@tarox.com');
		}		
		
	});*/
	
	
	//Sistemi Frenanti Racing pop
	$('.sisFrenoRacing .frenoGal ul li a').append('<strong><!----></strong>')
	$('.sisFrenoRacing .frenoGal ul li div.popBlock strong').css('display', 'none');
	
	var i = 0;
	$('.sisFrenoRacing .frenoGal ul li .trigger').each(function() {
		var clickedElement = $(this).next('.popBlock');
		var clickedThumb = $(this).children('img');
		
		$(this).click(function() {
			if (i==0) {
				clickedElement.show();
				$('.sisFrenoRacing .frenoGal ul li .trigger a').css('cursor', 'default');
				$(".trigger img").fadeTo(50, 0.3);
				$(this).find('img').animate({ opacity: 1.0 }, 1);
				$('.sisFrenoRacing .frenoGal ul li a strong').css('background', 'none');
				i++;
			}
			return false;
		});
		
		$('.popBlock a.close').click(function() {
			i=0;
			$('.popBlock').hide();
			$(".trigger img").animate({ opacity: 1.0 }, 200);
			return false;
		});
		
	});
	
	
	
});


