function searchPlaceHolder(){
	var placeHolder = $('#search-container input[type=text]').val();
	$('#search-container input[type=text]').focus(function(){
		var placeHolder = $(this).val();
		$(this).val('');			
		$(this).blur(function(){
			$(this).val(placeHolder);
		});
	});
}





//Login/Setup Tab Box
function expandCollapseTabs(){
	$('.expand-collapse a:first-child').click(function(){
		
		var thisLink = $(this);
		var thisTabBox = thisLink.next();
		var thisLi = thisLink.parent();	

		//onclick if this box is NOT currently "expanded", fade it in
		//if it IS currently "expanded" fade it out
		if(thisTabBox.is(':hidden')){
			$('.blue-tab-box').hide();
			thisLi.addClass('expanded');
			thisTabBox.animate({opacity: 'show'}, 350, function(){ });
		} else {
			thisTabBox.animate({opacity: 'hide'}, 250, function(){ thisLi.removeClass('expanded'); });
		}

		//find the box the other box and remove the class 'expanded'
		var otherTabBox = thisLi.parent().children('.expand-collapse').children('.blue-tab-box:hidden');		
		otherTabBox.parent().removeClass('expanded');

		//If user clicks outside the tab area, hide the box and remove the .expanded class
		$('html').click(function(){
			thisTabBox.animate({opacity: 'hide'}, 250, function(){ thisLi.removeClass('expanded'); });			
		});

		//This is so we won't close the box when the user clicks inside of it (counteract the function above)
		$('#top-right-nav').click(function(event){
			event.stopPropagation();
		});

		return false;
	});
}


$(document).ready(function() {
  
  //set up all html5 video objects to use videoJS
  
  // Onload lets hide the H1s - then once they're convered with sifr, switchm em back.
});


//sIFR

sIFR.bHideBrowserText = false;

var avenir85 = { src: '/wp-content/themes/teladoc_theme/sifr/avenir85.swf' };
sIFR.activate(avenir85);

sIFR.replace(avenir85, {
	selector: '.slide h1',
	css: '.sIFR-root { background-color: transparent; color: #FFFFFF; font-size: 40px;  }',
	forceSingleLine: true,
	wmode: 'transparent'
});
sIFR.replace(avenir85, {
	selector: '.slide P.h1',
	css: '.sIFR-root { background-color: transparent; color: #FFFFFF; font-size: 40px; font-weight:normal;  }',
	forceSingleLine: true,
	wmode: 'transparent'
});

sIFR.replace(avenir85, {
	selector: '.home-col h1',
	css: '.sIFR-root { background-color: transparent; color: #244e67; font-size: 16px; }',
	forceSingleLine: true,
	wmode: 'transparent'
});
sIFR.replace(avenir85, {
	selector: '.home-col .h1',
	css: '.sIFR-root { background-color: transparent; color: #244e67; font-size: 16px; }',
	forceSingleLine: true,
	wmode: 'transparent'
});


sIFR.replace(avenir85, {
	selector: '#main-content-columns h1',
	css: '.sIFR-root { background-color: transparent; color: #244e67; font-size: 20px; }',
	forceSingleLine: true,
	wmode: 'transparent'
});

sIFR.replace(avenir85, {
	selector: '#main-content-columns .h1',
	css: '.sIFR-root { background-color: transparent; color: #244e67; font-size: 20px; }',
	forceSingleLine: true,
	wmode: 'transparent'
});
	
	
$(function(){
	searchPlaceHolder();
	expandCollapseTabs();	

	$('.accordion-title').click(function(){
		var accordionTitle = $(this);
		var accordionContent = accordionTitle.next();
		
		if(accordionContent.is(':hidden')){
			$('.accordion-content').animate({height: 'hide'}, 500);
			accordionContent.animate({height: 'show'}, 500);
			$('.accordion-title').removeClass('collapse');
			accordionTitle.addClass('collapse').removeClass('expand');			
		} else {
			accordionContent.animate({height: 'hide'}, 500, function(){
				accordionTitle.addClass('expand').removeClass('collapse');
			});
		}		
	});
	
	//Append PDF to any News Anchor Name if its URL is to a PDF Document
	$('.news-list li div a[href*=\'.pdf\']').each(function(){
		$(this).parent().append(' (PDF)');
	});
	
	//Open new window/tab if link is not internal
	var externalLinks = [$("a[href*='http://']:not([href*='"+location.hostname+"'])"), $("a[href*='telehealthreports']")];
	$.each(externalLinks, function(){
		$(this).attr('target', '_blank');
	});
	
	//See How It Works Sidebar Slider
	$('.move-right').click(function(){			
		var currSlide = $('#shiw .active');
		var nextSlide = currSlide.next();
		
		var amountOfSlides = $('.shiw-slide').length;
		
		if(nextSlide.length !== 0){		
			
			currSlide.removeClass('active');
			
			var nextSlidePos = nextSlide.position().left;
			var pos = '-'+nextSlidePos;
			
			var nextSlideWidth = nextSlide.width();
			var maxWidth = (amountOfSlides * nextSlideWidth) - nextSlideWidth;
			
			$('#shiw').animate({left: pos}, 500, function(){
				nextSlide.addClass('active');
			});
		}			
		return false;
	});
	
	$('.move-left').click(function(){			
		var currSlide = $('#shiw .active');
		var prevSlide = currSlide.prev();
		
		var amountOfSlides = $('.shiw-slide').length;
		
		if(prevSlide.length !== 0){
			currSlide.removeClass('active');
			
			var nextSlidePos = prevSlide.position().left;
			var pos = '-'+nextSlidePos;

			var nextSlideWidth = prevSlide.width();
			var maxWidth = (amountOfSlides * nextSlideWidth) - nextSlideWidth;

			$('#shiw').animate({left: pos}, 500, function(){
				prevSlide.addClass('active');
			});
		}			
		return false;
	});
	
});

