﻿///<reference path="/_js/jQuery/1.4.1/jquery-1.4.1-vsdoc.js"/>

j$(document).ready(function () {
	var oldClass = "";

	j$("div.CourseDisplay .Header span").maxText({ rightOffset: 20 });

	j$("div.CourseDisplay .Header li").hover(function () {
		oldClass = j$(this).find("a").attr("class");
		if (oldClass != "selected")
			j$(this).find("a").attr("class", "hover");
	}, function () {
		if (j$(this).find("a").attr("class") != "selected") {
			j$(this).find("a").attr("class", "topNavHeader");
		}
	});

	j$("div.CourseDisplay .Header li a").click(function () {
		//hide the others
		var leftDiv = j$("div.CourseDisplay div.Content div.Left");
		leftDiv.children("div").hide();

		//show the next one
		var nextDiv = j$(this).attr("id") + "Content";
		leftDiv.children("div." + nextDiv).show();

		//turn the other selections off
		j$("div.CourseDisplay .Header li a").attr("class", "topNavHeader");

		//update the "selected" state
		j$(this).attr("class", "selected");
		footerCheck();
	});

	//this sets the main tab on page load.  It looks for the a tag with the title of "overview".  this can be changed.
	j$("div.CourseDisplay li a[id='btnOverview']").click();

	//for the qTips
	j$('img.b2bQuestion').qtip({
		content: {
			text: j$("div.b2bQTipContent")
		},
		style: {
			background: '#eae7e2',
			border: {
				'border-style': 'dotted',
				color: '#928f8a',
				width: 1
			},
			color: '#483f38',
			width: 173,
			tip: 'topRight'
		},
		show: 'mouseover',
		hide: {	when: 'mouseout', delay: 250 },
		position: {
			corner: {
				target: 'bottomLeft',
				tooltip: 'topRight'
			}
		}
	});
    //for online course the qTips
    j$('img.onlineQuestion').qtip({
        content: {
            text: j$("div.onlineQTipContent")
        },
        style: {
            background: '#eae7e2',
            border: {
                'border-style': 'dotted',
                color: '#928f8a',
                width: 1
            },
            color: '#483f38',
            width: 220,
            tip: 'topRight'
        },
        show: 'mouseover',
        hide: { when: 'mouseout', delay: 250 },
        position: {
            corner: {
                target: 'bottomLeft',
                tooltip: 'topRight'
            }
        }
    });
});

function showSilverlight() {
	j$("div.btnStatsContent div.stats").hide();
	j$("div.btnStatsContent #silverlightControlHost").show();
}

function showNormalStats() {
	j$("div.btnStatsContent #silverlightControlHost").hide();
	j$("div.btnStatsContent div.stats").show();
}

function ShowContactForm(directorID, coordinatorID, ami) {
	//j$("#courseContactLightbox input[id$='coursePageEmails']").val(email);
	//j$("#courseContactLightbox #contactName").html(name);
	//j$.fn.colorbox({ href: "#courseContactLightbox", inline: true, width: "750px", height: "500px", title: Title, onComplete: function () { j$("#colorbox #courseContactLightbox form2").replaceWith("<form id=\"courseContactForm\" action=\"/ajax/Register.aspx\" method=\"post\" onsubmit=\"javascript:return WebForm_OnSubmit();\">" + j$("#colorbox #courseContactLightbox form2").html() + "</form>"); } });

	HideSilverlightIfShowing();
	j$.fn.colorbox({ href: "/_lightbox/exed/Contact.aspx?type=2&directorID=" + directorID + "&coordinatorID=" + coordinatorID + "&ami=" + ami, width: "750px", height: "500px", iframe: true, onClosed: function () { ShowSilverlightIfHiding(); } });
}

function HideWebAd() {
	j$(".CourseDisplayWrapper .MessageArea").slideUp("slow");
}

function HideSilverlightIfShowing() {
	if (j$("div.btnStatsContent #silverlightControlHost").css("display") != "none")
		j$("div.btnStatsContent #silverlightControlHost").hide();
}

function ShowSilverlightIfHiding() {
	if (j$("div.btnStatsContent div.stats").css("display") == "none" && j$("div.btnStatsContent #silverlightControlHost").css("display") == "none") {
		j$("div.btnStatsContent #silverlightControlHost").show();
	}
}
