﻿$(document).ready(function() {
	ListToggle(".basicsGlossary dt");	//Basics/Glossary.aspx
	ListToggle(".basicsFAQs dt");	//Basics/FAQs.aspx
	ListToggle(".networkFAQs dt");	//Resources/NativeNetwork/NetworkFAQs.aspx
	ListToggle(".networkGlossaryTerms dt");	//Resources/NativeNetwork/NetworkGlossary.aspx
	ListToggle(".overviewFAQs dt");	//Resources/Roster/OverviewFAQs.aspx
	ListToggle(".searchReferralFAQs dt");	//Resources/Roster/SearchReferralFAQs.aspx
	ListToggle(".rosterApplicationFAQs dt");	//Resources/Roster/RosterApplicationFAQs.aspx
	ListToggle(".rosterDetailedSearchInstructions dt"); //Resources/Roster/DetailedSearchInstructions.aspx
	ListToggle(".rosterGlossaryTerms dt"); //Resources/Roster/Glossary.aspx
	
	TextToggle(".rosterToggler");	//Resources/Roster/Roster.aspx
	TextToggle(".rosterApplicationFAQsToggler");	//Resources/Roster/RosterApplicationFAQs.aspx
	
	ProjectAssessmentReports();	//Projects/ProjectAssementReports.aspx
	WorkingWithUs("ED");	//AnnouncementsEvents/WorkingWithUs.aspx
	WorkingWithUs("C1");	//AnnouncementsEvents/WorkingWithUs.aspx
	WorkingWithUs("D1");	//AnnouncementsEvents/WorkingWithus.aspx
	WorkingWithUs("E1");    //AnnouncementsEvents/WorkingWithUs.aspx
	WorkingWithUs("E2");    //AnnouncementsEvents/WorkingWithUs.aspx
	
	if (document.location.href.indexOf('/ECR2008/Schedule.aspx') != -1) {
		ConferenceSchedule();
	}
	
	if (document.location.href.indexOf('/ECR2008/Presenters.aspx') != -1) {
		Presenters();
	}
	
	if (document.location.href.indexOf('/Training/Training.aspx') != -1) {
	    QuestionToggle();
	}
});

function QuestionToggle() {
    $(".question").click(function() {
        $(this).children("span").text() == "+" ? $(this).children("span").text("-") : $(this).children("span").text("+");
        $(this).next().css("display") == "none" ? $(this).next().css("display", "") : $(this).next().css("display", "none");
    }).css("cursor","pointer").next().css("display", "none");
}

function ListToggle(Selector) {
	$(Selector).each(function() {
		$(this).attr("class","collapsed");
		$(this).click(function() {
			if ($(this).attr("class") == "collapsed") {
				$(this).attr("class","expanded");
			}
			else {
				$(this).attr("class","collapsed");
			}
			$(this).next().slideToggle("fast");
		});
	}).next().hide();
}

function TextToggle(Selector) {
	$(Selector).each(function() {
		$(this).click(function() {
			$(this).parent().next().slideToggle("fast");
			if ($(this).parent().next().css("height") == "1px") {
				$(this).text("Less...");
			}
			else {
				$(this).text("More...");
			}
		});
	}).parent().next().hide();
}

function ProjectAssessmentReports() {
	$(".projectAssessmentReports li span:even").each(function() {
		$(this).attr("class", "collapsed");
		$(this).click(function() {
			if ($(this).attr("class") == "collapsed") {
				$(this).attr("class","expanded");
			}
			else {
				$(this).attr("class","collapsed");
			}
			$(this).next().next().slideToggle("fast");
		});
	}).next().next().hide();
}

function WorkingWithUs(Selector) {
	var link = "#lnk" + Selector;
	var teaser = "#" + Selector + "a";
	var body = "#" + Selector + "c";
	
	$(body).hide();
	$(link).click(function() {
		if ($(teaser + ":visible").length > 0) {
			$(body).show();
			$(teaser).hide();
			$(link).text("Less...");
		}
		else {
			$(body).hide();
			$(teaser).show();
			$(link).text("More...");
		}
		return false;
	});
}

function ChargeWindow(OrgID) {
	window.open('https://128bit.clickandpledge.com/Default.asp?ID='+OrgID,'ChargeWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=710,height=600');
}

function ConferenceSchedule() {
	$("#btnExpandAll").click(function() {
		$("h2:not(.single)").attr("class", "dateExpanded").next().slideDown("fast");
		$("h3:not(.single)").attr("class", "timeExpanded").next().slideDown("fast");
	});
	
	$("#btnCollapseAll").click(function() {
		$("h2:not(.single)").attr("class", "dateCollapsed").next().slideUp("fast");
		$("h3:not(.single)").attr("class", "timeCollapsed").next().slideUp("fast");
	});
	
	$("h2:not(.single)").addClass("dateCollapsed");
	$("h3:not(.single)").addClass("timeCollapsed");
	$("h2:not(.single), h3:not(.single)").each(function() {
		$(this).css("cursor", "pointer");
		$(this).mouseover(function() {
			$(this).css("text-decoration", "underline");
		});
		$(this).mouseout(function() {
			$(this).css("text-decoration", "none");
		});
		$(this).click(function() {
			$(this).next().slideToggle("fast");
			switch ($(this).attr("class")) {
				case "dateExpanded":
					$(this).attr("class", "dateCollapsed");
					break;
				case "dateCollapsed":
					$(this).attr("class", "dateExpanded");
					break;
				case "timeExpanded":
					$(this).attr("class", "timeCollapsed");
					break;
				case "timeCollapsed":
					$(this).attr("class", "timeExpanded");
					break;
				default:
					break;
			}
		});
	}).next().hide();
}

function Presenters() {
	$("#btnExpandAll").click(function() {
		$("h2:not(.single)").attr("class", "alphaExpanded").next().slideDown("fast");
	});
	
	$("#btnCollapseAll").click(function() {
		$("h2:not(.single)").attr("class", "alphaCollapsed").next().slideUp("fast");
	});

	$("h2:not(.single)").addClass("alphaCollapsed");
	$("h2:not(.single)").each(function() {
		$(this).css("cursor", "pointer");
		$(this).mouseover(function() {
			$(this).css("text-decoration", "underline");
		});
		$(this).mouseout(function() {
			$(this).css("text-decoration", "none");
		});
		$(this).click(function() {
			$(this).next().slideToggle("fast");
			switch ($(this).attr("class")) {
				case "alphaExpanded":
					$(this).attr("class", "alphaCollapsed");
					break;
				case "alphaCollapsed":
					$(this).attr("class", "alphaExpanded");
					break;
				default:
					break;
			}
		});
	}).next().slideUp("fast");
	$("h2:first").next().slideDown();
	$("h2:first").attr("class", "alphaExpanded");
}

function ConfirmDeleteRegistration() {
    return confirm("Are you sure you want to delete this registration?");
}
