


<!--Begin script for Google Analytics. -->

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20382406-1']);
//_gaq.push(['_setDomainName', '.amedisys.com']);
//_gaq.push(['_setAllowHash', false]);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();



$(document).ready(function(){
	
	// form start events
	if(document.getElementById("contactform")){
		var isContactFormStarted = false;
		$("#contactform").click(function(){
			if(!isContactFormStarted){
				console.log("ContactFormStarted");
				console.log(_gaq);
				_gaq.push(['_trackEvent', 'Form', 'Start', 'Contact Form']);
				isContactFormStarted = true;
			}
		})
	}
	
	if(document.getElementById("supplierform")){
		var isSupplierFormStarted = false;
		$("#supplierform").click(function(){
			if(!isSupplierFormStarted){
				console.log("SupplierFormStarted");
				_gaq.push(['_trackEvent', 'Form', 'Start', 'Doing Business Form']);
				isSupplierFormStarted = true;
			}
		})
	}
	
	if(document.getElementById("quizform")){
		var isQuizFormStarted = false;
		$("#quizform").click(function(){
			if(!isQuizFormStarted){
				console.log("QuizFormStarted");
				_gaq.push(['_trackEvent', 'Form', 'Start', 'Assessment Quiz Form']);
				isQuizFormStarted = true;
			}
		})
	}
	
	// form confirmations
	var loc = window.location.href.toLowerCase()
	if(loc.indexOf("/our-company/contact-us/contact-us-confirmation.aspx") != -1){
		console.log("ContactFormComplete");
		_gaq.push(['_trackEvent', 'Form', 'Complete', 'Contact Form']);
	}
	
	if(loc.indexOf("/our-company/contact-us/doing-business-with-amedisys-confirmation.aspx") != -1){
		console.log("SupplierFormComplete");
		_gaq.push(['_trackEvent', 'Form', 'Complete', 'Doing Business Form']);
	}
	
	if(loc.indexOf("/patients-and-caregivers/hospice-care/is-hospice-the-answer/is-hospice-the-answer-confirmation.aspx") != -1){
		console.log("AssessmentFormComplete");
		_gaq.push(['_trackEvent', 'Form', 'Complete', 'Assessment Quiz Form']);
	}
	
	if(loc.indexOf("/patients-and-caregivers/hospice-care/is-hospice-the-answer/is-hospice-the-answer-confirmation-ineligible.aspx") != -1){
		console.log("AssessmentFormComplete");
		_gaq.push(['_trackEvent', 'Form', 'Complete', 'Assessment Quiz Ineligible']);
	}
	
	if(loc.indexOf("/patients-and-caregivers/hospice-care/is-hospice-the-answer/is-hospice-the-answer-confirmation-out-of-area.aspx") != -1){
		console.log("AssessmentFormComplete");
		_gaq.push(['_trackEvent', 'Form', 'Complete', 'Assessment Quiz Out Of Area']);
	}
	
	
    $('a[href*="/assets/pdfs"]').click(function() {
		var path = $(this).attr("href")
        var pdfName = path.substring(path.lastIndexOf("/"));
		pdfName = pdfName.substring(0, pdfName.lastIndexOf(".")) + ".pdf";
		_gaq.push(['_trackEvent', 'PDF Download', 'Download', pdfName]);
		console.log(pdfName);
    });
	
    // if there's a video on the page, track it
	if(document.getElementById("ytplayer")){
		$.getScript("/app_themes/Main/js/json2.js");
		$.getScript("http://www.youtube.com/player_api");
	}
});

var player;
function onYouTubePlayerAPIReady() {
	//alert("onYouTubePlayerAPIReady");
	
	player = new YT.Player('ytplayer', {
		events: {
			'onStateChange': onPlayerStateChange
		}
	});
}
	
function onPlayerStateChange(event) {
	//alert(event.data);
	/*
	YT.PlayerState.ENDED || 0
	YT.PlayerState.PLAYING || 1
	YT.PlayerState.PAUSED || 2
	YT.PlayerState.BUFFERING || 3
	YT.PlayerState.CUED || 5
	*/
	
	switch (event.data) {
		case YT.PlayerState.ENDED:
			//alert(document.getElementById("ytplayer").title + " ended");
			_gaq.push(['_trackEvent', 'Video', 'Complete', document.getElementById("ytplayer").title]);
		break;
		
		case YT.PlayerState.PLAYING:
			//alert(document.getElementById("ytplayer").title + " playing");
			_gaq.push(['_trackEvent', 'Video', 'Play', document.getElementById("ytplayer").title]);
		break;
		
		case YT.PlayerState.PAUSED:
			//alert(document.getElementById("ytplayer").title + " paused");
			_gaq.push(['_trackEvent', 'Video', 'Paused', document.getElementById("ytplayer").title]);
		break;
	}
}
