$(document).ready(function() {
	Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
	PostMenopausal();
	$(".gender").click(function(){
		PostMenopausal()
	});
	Qtips();
	
	var cra_Protocol = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	$.getScript(cra_Protocol + "google-analytics.com/ga.js", function(){
		try {
			var pageTracker = _gat._getTracker("UA-10823334-1");
			pageTracker._trackPageview();
		}
		catch(err) {}
	});
});

function EndRequestHandler(){
	try {
		var pageTracker = _gat._getTracker("UA-10823334-1");
		pageTracker._trackPageview($("#ga-link").attr("href"));
	}
	catch(err) {}
	
	Qtips();
	
	PostMenopausal();
	$(".gender").click(function(){
		PostMenopausal()
	});
	
	Diabetic();
	$(".diabetic").click(function(){
		Diabetic()
	});
	
	EverSmoked();
	$(".ever-smoked").click(function(){
		EverSmoked()
	});
	
	PlanToQuitSmoking();
	$(".still-smoke").click(function(){
		PlanToQuitSmoking()
	});
	
	EKG();
	$(".ekg").click(function(){
		EKG()
	});
}

function Qtips()
{
	$(".info-right").qtip({style: { name: "blue", padding: 10, color: 'black', tip: 'rightTop' }, hide: { fixed: false }, position: { adjust: { x: 0, y: 4 }, corner: { target: "leftTop", tooltip: "rightTop" } } });
	$(".info-left").qtip({style: { name: "blue", padding: 10, color: 'black', tip: 'leftTop' }, hide: { fixed: false }, position: { adjust: { x: 0, y: 4 }, corner: { target: "rightTop", tooltip: "leftTop" } } });
}

function PostMenopausal(){
	$(".post-menopausal").hide();
	
	if ($(".gender input[value='Female']:checked").length){
		Show(".post-menopausal");
	}
	else {
		Hide(".post-menopausal");
	}
}

function Diabetic(){
	$(".pre-diabetic").hide();
	
	if ($(".diabetic input[value='false']:checked").length){
		Show(".pre-diabetic");
	}
	else {
		Hide(".pre-diabetic");
	}
}

function EverSmoked(){
	if ($(".ever-smoked input[value='true']:checked").length){
		Show(".still-smoke");
	}
	else if ($(".ever-smoked input[value='false']:checked").length){
		Hide(".still-smoke");
		Hide(".plan-quit");
		Hide(".quit-when");
	}
	else{
		Hide(".still-smoke");
		Hide(".plan-quit");
		Hide(".quit-when");
	}
}

function PlanToQuitSmoking(){
	if ($(".still-smoke input[value='true']:checked").length){
		Show(".plan-quit");
		Hide(".quit-when");
	}
	else if ($(".still-smoke input[value='false']:checked").length){
		Hide(".plan-quit");		
		Show(".quit-when");			
	}
	else{
		Hide(".plan-quit");
		Hide(".quit-when");
	}
}

function EKG(){
	if ($(".ekg input[value='Yes']:checked").length){
		Show(".ekg-result");
	}
	else if ($(".ekg input[value='No']:checked").length){
		Hide(".ekg-result");
	}
	else if ($(".ekg input[value='Unsure']:checked").length){
		Hide(".ekg-result");
	}
	else{
		Hide(".ekg-result");		
	}
}

function Hide(sel)
{
	$(sel).hide().find("input").removeAttr("checked");
}

function Show(sel)
{
	$(sel).show();
}
