


function dcPageReload(name){

    var value = document.getElementById(name).value;

    if(value == "null" || value == "0:0"){
        document.cookie= name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT;";
    }
    else{
        document.cookie= name + "=" + value;
    }
        
    window.location.reload();
}

function dcResetCookies(){

    document.cookie= 'dcCourseId=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
    document.cookie= 'dcProjectId=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
    document.cookie= 'dcTag=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
    document.cookie= 'dcMonth=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
    document.cookie= 'dcCourseLeader=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
    document.cookie= 'dcSubjectId=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
    document.cookie= 'dcLength=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
    document.cookie= 'dcLocale=; expires=Thu, 01-Jan-70 00:00:01 GMT;';

    window.location.reload();

}

function dcGetCookie(name){
    var a_all_cookies = document.cookie.split(';');
    var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );

		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == name )
		{
            b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned

			return cookie_value;

			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}

}

function dcCourseFilter(){

    var filterId = "dcCourseId";
    var cookieValue = dcGetCookie(filterId);
    document.write('<form><select id="' + filterId + '" onChange=dcPageReload("' + filterId + '")></select></form>');
    var select = document.getElementById(filterId);
    select.add(new Option("any course", "null", 1));
            var arrayText = "Calm Your Nerves, Find Your Confidence";
        var arrayValue = "143";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "Stepping Out: Preparing Yourself for the Limelight";
        var arrayValue = "147";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "The (Nervous) Beginner`s Guide To Presenting";
        var arrayValue = "151";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
    }

function dcProjectFilter(){

    var filterId = "dcProjectId";
    var projectAlias = "";
    projectAlias ? projectAlias : "project";
    var cookieValue = dcGetCookie(filterId);
    document.write('<form><select id="' + filterId + '" onChange=dcPageReload("' + filterId + '")></select></form>');
    var select = document.getElementById(filterId);
    select.add(new Option("any " + projectAlias, "null", 1));
            var arrayText = "Calm Your Anxiety";
        var arrayValue = "33";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "Start Out Right";
        var arrayValue = "31";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
    }

function dcMonthFilter(){

    var filterId = "dcMonth";
    var cookieValue = dcGetCookie(filterId);
    document.write('<form><select id="' + filterId + '" onChange=dcPageReload("' + filterId + '")></select></form>');
    var select = document.getElementById(filterId);
    select.add(new Option("any month", "null", 1));
            var arrayText = "March";
        var arrayValue = "2012-03-01";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "April";
        var arrayValue = "2012-04-01";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "May";
        var arrayValue = "2012-05-01";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
    }

function dcLocaleFilter(){

    var filterId = "dcLocale";
    var cookieValue = dcGetCookie(filterId);
    document.write('<form><select id="' + filterId + '" onChange=dcPageReload("' + filterId + '")></select></form>');
    var select = document.getElementById(filterId);
    select.add(new Option("any locale", "null", 1));
            var arrayText = "London";
        var arrayValue = "London";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
    }

function dcLengthFilter(){

    var filterId = "dcLength";
    var cookieValue = dcGetCookie(filterId);
    document.write('<form><select id="' + filterId + '" onChange=dcPageReload("' + filterId + '")></select></form>');
    var select = document.getElementById(filterId);
    select.add(new Option("any length", "null", 1));
            var arrayText = "two-day workshop";
        var arrayValue = "12:1";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "one-day workshop";
        var arrayValue = "3:1";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
    }

function dcSubjectFilter(){

    var filterId = "dcSubjectId";
    var cookieValue = dcGetCookie(filterId);
    document.write('<form><select id="' + filterId + '" onChange=dcPageReload("' + filterId + '")></select></form>');
    var select = document.getElementById(filterId);
    select.add(new Option("any subject", "null", 1));
            var arrayText = "Leadership";
        var arrayValue = "75";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "Organisational Change";
        var arrayValue = "76";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "Voice Coaching";
        var arrayValue = "77";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "Improvisation";
        var arrayValue = "39";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "Anxiety and Confidence";
        var arrayValue = "79";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "The Art and Craft Of Storytelling";
        var arrayValue = "82";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "Swimming In The Sea Of Stories";
        var arrayValue = "83";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "Working With Your Audience";
        var arrayValue = "84";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "Preparing For Performance";
        var arrayValue = "85";
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
    }

function dcTagFilter(){

    var filterId = "dcTag";
    var tagAlias = "theme";
    tagAlias = (tagAlias != "") ? tagAlias : "tag";
    var cookieValue = dcGetCookie(filterId);
    document.write('<form><select id="' + filterId + '" onChange=dcPageReload("' + filterId + '")></select></form>');
    var select = document.getElementById(filterId);
    select.add(new Option("any " + tagAlias, "null", 1));
            var arrayText = "confidence";
        arrayText = arrayText.replace(/^\s+|\s+$/g, "");
        var arrayValue = "confidence";
        arrayValue = arrayValue.replace(/^\s+|\s+$/g, "");
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "presenting";
        arrayText = arrayText.replace(/^\s+|\s+$/g, "");
        var arrayValue = "presenting";
        arrayValue = arrayValue.replace(/^\s+|\s+$/g, "");
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
            var arrayText = "speaking";
        arrayText = arrayText.replace(/^\s+|\s+$/g, "");
        var arrayValue = "speaking";
        arrayValue = arrayValue.replace(/^\s+|\s+$/g, "");
        selected = (arrayValue == cookieValue) ? 1 : 0;
        select.add(new Option(arrayText, arrayValue, 0, selected));
    }

function dcCourseLeaderFilter(){

    var filterId = "dcCourseLeader";
    var cookieValue = dcGetCookie(filterId);
    document.write('<form><select id="' + filterId + '" onChange=dcPageReload("' + filterId + '")></select></form>');
    var select = document.getElementById(filterId);
    select.add(new Option("any course leader", "null", 1));
    }


function dcCalendarFilters(showCourse, showProject, showSubject, showTag, showCourseLeader, showLength, showMonth, showLocale){

    if(!showCourse && !showProject && !showSubject && !showTag && !showCourseLeader && !showLength && !showMonth && !showLocale){
        showCourse = 1;
        showProject = 0;
        showSubject = 0;
        showTag = 0;
        showCourseLeader = 0;
        showLength = 1;
        showMonth = 1;
        showLocale = 1;
    }

    document.write('<div id="dcCalendarFilters">');
    showCourse ? dcCourseFilter() : "";
    showProject ? dcProjectFilter() : "";
    showSubject ? dcSubjectFilter() : "";
    showTag ? dcTagFilter() : "";
    showMonth ? dcMonthFilter() : "";
    showLength ? dcLengthFilter() : "";
    showCourseLeader ? dcCourseLeaderFilter() : "";
    showLocale ? dcLocaleFilter() : "";
            document.write('<input type="submit" id="reset" onClick ="dcResetCookies();" value="show all...">');
        document.write('</div>');
}

function dcCalendarContent(format, showTags, showSynopsis){

    var errMsg = "";
    var selectedCourseId = dcGetCookie('dcCourseId');
    var selectedProjectId = dcGetCookie('dcProjectId');
    var selectedTag = dcGetCookie('dcTag');
    var selectedMonth = dcGetCookie('dcMonth');
    var selectedCourseLeader = dcGetCookie('dcCourseLeader');
    var selectedSubjectId = dcGetCookie('dcSubjectId');
    var selectedLength = dcGetCookie('dcLength');
    var selectedLocale = dcGetCookie('dcLocale');

    if(!format){
        format = "blocks";
    }

    if(!showTags && !showSynopsis){
        showTags = 0;
        showSynopsis = 1;
    }

    var allHidden = 1;
    var nothingToShow = 0;

    var nothingToShowMsg = '<div class="noCourseDates">(no course dates)</div>';
    var courseClass;
    var oddOrEven;

    if(format == "rows"){
        document.write('<div id="dcCalendarRows">');
        document.write('<table>');
    }
    else{
        document.write('<div id="dcCalendarBlocks">');
    }


    
            var i = 1;

            var deliveryId = 151;
            var courseId = 151;
            var projectId = 33;
            var courseReference = 'NervousBeginners';
            var tag = 'themes: ';
            var month = '2012-03-01';
            var courseLeaders = '';
            var subjectId = 79;
            var length = '12:1';
            var locale = 'London';
            var startDate = 'Mar 20 (Tue)';
            var courseTitle = '<a href="http://www.jimpirrie.com/calm-your-anxiety/the-nervous-beginners-guide-to-presenting.html">The (Nervous) Beginner`s Guide To Presenting</a>';
            var pricesButton = '<form action="http://www.jimpirrie.docourses.com/process/pricing.php" method="POST"><input type="hidden" name="table" value="client_project_course_delivery"><input type="hidden" name="id" value=151><input type="submit" name="do_prices" value="prices..."></form>';
            var courseSummary = 'Anxiety and Confidence: a two-day workshop';
            var courseSynopsis = 'If you are anxious about speaking, then giving a presentation can be a bit of an ordeal! This course gives you some practical ways to make it all much easier. ';
            var learnMore = '<a href="http://www.jimpirrie.com/calm-your-anxiety/the-nervous-beginners-guide-to-presenting.html">(learn more about this course...)</a>';
            var timings = 'Tue 20/03/12 (09:00) - Wed 21/03/12 (17:00) (<a href="http://www.jimpirrie.docourses.com/process/dates_and_times.php?table=client_project_course_delivery&id=151">details...</a>)';
            var shortTimings = '<a href="http://www.jimpirrie.docourses.com/process/dates_and_times.php?table=client_project_course_delivery&id=151">20/03/12 (09:00) - 21/03/12 (17:00)</a>';
            var venue = 'London';
            var availabilityMsg = '';

            var hide = 0;
            hide = (selectedCourseId && courseId != selectedCourseId) ? 1 : hide;
            hide = (selectedProjectId && projectId != selectedProjectId) ? 1 : hide;
            hide = (selectedTag && tag.indexOf(selectedTag) < 0) ? 1 : hide;
            hide = (selectedMonth && month != selectedMonth) ? 1 : hide;
            hide = (selectedCourseLeader && courseLeaders.indexOf(selectedCourseLeader) < 1) ? 1 : hide;
            hide = (selectedSubjectId && subjectId != selectedSubjectId) ? 1 : hide;
            hide = (selectedLength && length != selectedLength) ? 1 : hide;
            hide = (selectedLocale && locale != selectedLocale) ? 1 : hide;

            if(!hide){

                allHidden = "";
                courseClass = "p" + projectId + '_' + courseReference;

                oddOrEven = (oddOrEven == "even") ? "odd" : "even";

                if(format == "rows"){
                    document.write('<tr class="' + oddOrEven + '"><td valign="top" class="courseStartDate">' + startDate + '</td><td valign="top" class="courseTitle">' + courseTitle + '</td><td valign="top" class="courseTimings">' + shortTimings + '</td><td valign="top" class="courseVenue">' + venue + '</td><td valign="top" class="pricesButton">' + pricesButton + '</td></tr>');
                }
                else{
                    document.write('<div class="courseBlock ' + oddOrEven + ' ' + courseClass + '">');
                    document.write('<table>');
                    document.write('<tr><td rowspan="2" valign="top" class="courseStartDate">' + startDate + '</td><td valign="top" class="courseTitle">' + courseTitle + '</td><td valign="top" rowspan="2" class="pricesButton">' + pricesButton + '</td></tr>');
                    document.write('<tr><td class="courseSummary">' + courseSummary + '</td></tr>');
                    if(courseLeaders){
                        document.write('<tr><td></td></td><td class="courseLeaders"> with ' +  courseLeaders + '</td><td></td></tr>');
                    }
                    if(courseSynopsis && showSynopsis){
                        document.write('<tr><td></td><td class="courseSynopsis">' + courseSynopsis + '</td><td></td></tr>');
                    }
                    if(tag && showTags){
                        document.write('<tr><td></td><td class="courseTags">' +  tag + '.</td><td></td></tr>');
                    }
                    if(learnMore){
                        document.write('<tr><td></td><td class="courseLearnMore">' + learnMore + '</td><td></td></tr>');
                    }
                    if(availabilityMsg){
                        document.write('<tr><td></td><td class="courseAvailability">' +  availabilityMsg + '</td><td></td></tr>');
                    }
                    document.write('<tr><td></td><td class="courseTimings">' + timings + '</td><td></td></tr>');
                    document.write('<tr><td></td><td class="courseVenue">' + venue + '</td><td></td></tr>');
                    document.write("</table>");
                    document.write("</div>");
                }
            }
    
            var i = 2;

            var deliveryId = 150;
            var courseId = 143;
            var projectId = 33;
            var courseReference = 'CalmYourNerves';
            var tag = 'themes: confidence, presenting, speaking';
            var month = '2012-04-01';
            var courseLeaders = '';
            var subjectId = 79;
            var length = '3:1';
            var locale = 'London';
            var startDate = 'Apr 19 (Thu)';
            var courseTitle = '<a href="http://www.jimpirrie.com/calm-your-anxiety/calm-your-nerves-find-your-confidence.html">Calm Your Nerves, Find Your Confidence</a>';
            var pricesButton = '<form action="http://www.jimpirrie.docourses.com/process/pricing.php" method="POST"><input type="hidden" name="table" value="client_project_course_delivery"><input type="hidden" name="id" value=150><input type="submit" name="do_prices" value="prices..."></form>';
            var courseSummary = 'Anxiety and Confidence: a one-day workshop';
            var courseSynopsis = 'If you are one of those people who are terrified wt the thought of standing up and speaking or presenting, then this one is for you...';
            var learnMore = '<a href="http://www.jimpirrie.com/calm-your-anxiety/calm-your-nerves-find-your-confidence.html">(learn more about this course...)</a>';
            var timings = 'Thu 19/04/12 (09:00 - 17:00) (<a href="http://www.jimpirrie.docourses.com/process/dates_and_times.php?table=client_project_course_delivery&id=150">details...</a>)';
            var shortTimings = '<a href="http://www.jimpirrie.docourses.com/process/dates_and_times.php?table=client_project_course_delivery&id=150">19/04/12 (09:00 - 17:00)</a>';
            var venue = 'London';
            var availabilityMsg = '';

            var hide = 0;
            hide = (selectedCourseId && courseId != selectedCourseId) ? 1 : hide;
            hide = (selectedProjectId && projectId != selectedProjectId) ? 1 : hide;
            hide = (selectedTag && tag.indexOf(selectedTag) < 0) ? 1 : hide;
            hide = (selectedMonth && month != selectedMonth) ? 1 : hide;
            hide = (selectedCourseLeader && courseLeaders.indexOf(selectedCourseLeader) < 1) ? 1 : hide;
            hide = (selectedSubjectId && subjectId != selectedSubjectId) ? 1 : hide;
            hide = (selectedLength && length != selectedLength) ? 1 : hide;
            hide = (selectedLocale && locale != selectedLocale) ? 1 : hide;

            if(!hide){

                allHidden = "";
                courseClass = "p" + projectId + '_' + courseReference;

                oddOrEven = (oddOrEven == "even") ? "odd" : "even";

                if(format == "rows"){
                    document.write('<tr class="' + oddOrEven + '"><td valign="top" class="courseStartDate">' + startDate + '</td><td valign="top" class="courseTitle">' + courseTitle + '</td><td valign="top" class="courseTimings">' + shortTimings + '</td><td valign="top" class="courseVenue">' + venue + '</td><td valign="top" class="pricesButton">' + pricesButton + '</td></tr>');
                }
                else{
                    document.write('<div class="courseBlock ' + oddOrEven + ' ' + courseClass + '">');
                    document.write('<table>');
                    document.write('<tr><td rowspan="2" valign="top" class="courseStartDate">' + startDate + '</td><td valign="top" class="courseTitle">' + courseTitle + '</td><td valign="top" rowspan="2" class="pricesButton">' + pricesButton + '</td></tr>');
                    document.write('<tr><td class="courseSummary">' + courseSummary + '</td></tr>');
                    if(courseLeaders){
                        document.write('<tr><td></td></td><td class="courseLeaders"> with ' +  courseLeaders + '</td><td></td></tr>');
                    }
                    if(courseSynopsis && showSynopsis){
                        document.write('<tr><td></td><td class="courseSynopsis">' + courseSynopsis + '</td><td></td></tr>');
                    }
                    if(tag && showTags){
                        document.write('<tr><td></td><td class="courseTags">' +  tag + '.</td><td></td></tr>');
                    }
                    if(learnMore){
                        document.write('<tr><td></td><td class="courseLearnMore">' + learnMore + '</td><td></td></tr>');
                    }
                    if(availabilityMsg){
                        document.write('<tr><td></td><td class="courseAvailability">' +  availabilityMsg + '</td><td></td></tr>');
                    }
                    document.write('<tr><td></td><td class="courseTimings">' + timings + '</td><td></td></tr>');
                    document.write('<tr><td></td><td class="courseVenue">' + venue + '</td><td></td></tr>');
                    document.write("</table>");
                    document.write("</div>");
                }
            }
    
            var i = 3;

            var deliveryId = 146;
            var courseId = 147;
            var projectId = 31;
            var courseReference = 'SteppingOut';
            var tag = 'themes: confidence, speaking, presenting';
            var month = '2012-05-01';
            var courseLeaders = '';
            var subjectId = 85;
            var length = '3:1';
            var locale = 'London';
            var startDate = 'May 02 (Wed)';
            var courseTitle = '<a href="http://www.jimpirrie.com/start-out-right/stepping-out-preparing-yourself-for-the-limelight.html">Stepping Out: Preparing Yourself for the Limelight</a>';
            var pricesButton = '<form action="http://www.jimpirrie.docourses.com/process/pricing.php" method="POST"><input type="hidden" name="table" value="client_project_course_delivery"><input type="hidden" name="id" value=146><input type="submit" name="do_prices" value="prices..."></form>';
            var courseSummary = 'Preparing For Performance: a one-day workshop';
            var courseSynopsis = 'When you\'re stepping out to give an important speech or presentation, it really pays to know how to prepare yourself physically and emotionally: learn the tricks of the performers trade (and a few things even they don\'t know)...';
            var learnMore = '<a href="http://www.jimpirrie.com/start-out-right/stepping-out-preparing-yourself-for-the-limelight.html">(learn more about this course...)</a>';
            var timings = 'Wed 02/05/12 (09:00 - 17:00) (<a href="http://www.jimpirrie.docourses.com/process/dates_and_times.php?table=client_project_course_delivery&id=146">details...</a>)';
            var shortTimings = '<a href="http://www.jimpirrie.docourses.com/process/dates_and_times.php?table=client_project_course_delivery&id=146">02/05/12 (09:00 - 17:00)</a>';
            var venue = 'London';
            var availabilityMsg = '';

            var hide = 0;
            hide = (selectedCourseId && courseId != selectedCourseId) ? 1 : hide;
            hide = (selectedProjectId && projectId != selectedProjectId) ? 1 : hide;
            hide = (selectedTag && tag.indexOf(selectedTag) < 0) ? 1 : hide;
            hide = (selectedMonth && month != selectedMonth) ? 1 : hide;
            hide = (selectedCourseLeader && courseLeaders.indexOf(selectedCourseLeader) < 1) ? 1 : hide;
            hide = (selectedSubjectId && subjectId != selectedSubjectId) ? 1 : hide;
            hide = (selectedLength && length != selectedLength) ? 1 : hide;
            hide = (selectedLocale && locale != selectedLocale) ? 1 : hide;

            if(!hide){

                allHidden = "";
                courseClass = "p" + projectId + '_' + courseReference;

                oddOrEven = (oddOrEven == "even") ? "odd" : "even";

                if(format == "rows"){
                    document.write('<tr class="' + oddOrEven + '"><td valign="top" class="courseStartDate">' + startDate + '</td><td valign="top" class="courseTitle">' + courseTitle + '</td><td valign="top" class="courseTimings">' + shortTimings + '</td><td valign="top" class="courseVenue">' + venue + '</td><td valign="top" class="pricesButton">' + pricesButton + '</td></tr>');
                }
                else{
                    document.write('<div class="courseBlock ' + oddOrEven + ' ' + courseClass + '">');
                    document.write('<table>');
                    document.write('<tr><td rowspan="2" valign="top" class="courseStartDate">' + startDate + '</td><td valign="top" class="courseTitle">' + courseTitle + '</td><td valign="top" rowspan="2" class="pricesButton">' + pricesButton + '</td></tr>');
                    document.write('<tr><td class="courseSummary">' + courseSummary + '</td></tr>');
                    if(courseLeaders){
                        document.write('<tr><td></td></td><td class="courseLeaders"> with ' +  courseLeaders + '</td><td></td></tr>');
                    }
                    if(courseSynopsis && showSynopsis){
                        document.write('<tr><td></td><td class="courseSynopsis">' + courseSynopsis + '</td><td></td></tr>');
                    }
                    if(tag && showTags){
                        document.write('<tr><td></td><td class="courseTags">' +  tag + '.</td><td></td></tr>');
                    }
                    if(learnMore){
                        document.write('<tr><td></td><td class="courseLearnMore">' + learnMore + '</td><td></td></tr>');
                    }
                    if(availabilityMsg){
                        document.write('<tr><td></td><td class="courseAvailability">' +  availabilityMsg + '</td><td></td></tr>');
                    }
                    document.write('<tr><td></td><td class="courseTimings">' + timings + '</td><td></td></tr>');
                    document.write('<tr><td></td><td class="courseVenue">' + venue + '</td><td></td></tr>');
                    document.write("</table>");
                    document.write("</div>");
                }
            }
    
    if(errMsg){
            if(format == "rows"){
                document.write('<tr><td class="noCourseDates">' + errMsg + '</td></tr>');
            }
            else{
                document.write('<div class="noCourseDates">' + errMsg + '</div>');
            }
    }
    if(nothingToShow || allHidden){
        if(format == "rows"){
            document.write('<tr><td class="noCourseDates">' + nothingToShowMsg + '</td></tr>');
        }
        else{
            document.write('<div class="noCourseDates">' + nothingToShowMsg + '</div>');
        }
    }

    if(format == "rows"){
        document.write('</table>');
    }

    document.write('</div>');

}

