// Javascript

// $('html').addClass('js'); // Flash of content fix (.js class hidden in CSS) - this now included inline header.php

$(document).ready(function() {
	
	
	/*
	==============================================================
		General DOM Manipulation
	==============================================================
	*/
	
	if ( (window.location.pathname.indexOf("/fr") != -1) && (window.location.pathname.indexOf("/fr/") == -1) ) {
		location.href = "/fr/";
	}
	else if (window.location.pathname.indexOf("/who-we-are")  != -1)
	{
		var position = window.location.pathname.indexOf("/who-we-are");
		var navigationString = window.location.pathname.substr(position).replace("/who-we-are", "").replace("/", "");
		
		if (navigationString == "")
		{
			location.href = "/" + (window.location.pathname.indexOf("fr/") != -1 ? "fr/" : "") + "who-we-are/our-story/";
		}
	}
	else if (window.location.pathname.indexOf("/client-login") != -1)
	{
		location.href = "http://infitrakportal.com";
	}
	
	$(".page_item.page-item-32").children("a").attr("href", "http://infitrakportal.com");
	
	$(".page_item.page-item-20").children("a").attr("href", $(".page_item.page-item-20").children("a").attr("href") + "our-story/");
	
	
	/*
	==============================================================
		Remove No-Script Styles
	==============================================================
	*/
	
	$('html').removeClass('js'); // Flash of content fix (when doc is ready, pull the .js class)
	
	
	/*
	==============================================================
		Block Element to Link
	==============================================================
	*/
	
	$('.video-thumb').click(function(){
		$(this).replaceWith('<iframe width="572" height="322" src="https://www.youtube.com/embed/crGp89P3sjI?rel=0&autoplay=1&version=3&autohide=1&showinfo=0" frameborder="0" allowfullscreen></iframe>');
	});
	
	
	/*
	==============================================================
		Toggle Slider
	==============================================================
	*/
	
	$('.slider').children().each(function(){
		
		// Kill empty DOM elements
		$(this).children(':empty').remove();
		
		// Add title class to first DOM element
		$(this).children(':first').addClass('slider-title');
		
		// Wrap all DOM elements except title
		$(this).children().not('.slider-title').wrapAll('<div class="slider-content"></div>');
	
	});
	
	$('.slider-content').each(function(){
		
		// Pull top/bottom margins off slider content to avoid animation jump
		$(this).children(':first').css('margin-top', '0');
		$(this).children(':last').css('margin-bottom', '0');
	
	});
	
	// Add +/- symbols
	$('.slider-title').append('<div class="plus">+</div><div class="minus">-</div>');
	
	// Slide toggle function
	$('.slider-title').click(function() {
		$(this).toggleClass('active');
		$(this).siblings('.slider-content').slideToggle();
		$(this).children('.plus, .minus').toggle();
	});
	
		
});
















