
$(function() {
	//Video links
	$(".kcVideo").click(function() {
		getVideo(this);							 
	});
	//Article Links
	$(".kcArticle").click(function() {
		getInfo(this);							 
	});
});


/*
* Get the parameter from the url and select the correct content to display on the page.
*/
function getUrlInfo(defaultInfo, dontScroll) {
	var isDefault = true;
	
	//Get article content
	var qt = getURLParam("qt");	
	//Get video content.
	var vd = getURLParam("vd");
	
	//Get the id of the element
	var elemId = null;
	if( isNotNullEmpty(qt) ) {
		elemId = "#"+qt;
	} else if( isNotNullEmpty(vd) ) {
		elemId = "#"+vd;
	} else {
		//Default
		elemId = "#"+defaultInfo;
	}
	
	$(elemId).click();
	
}

/*
* Get the infor from the id passed.
*/
function getInfo(selectInfo, dontScroll) {

	var page = $(selectInfo).parent().attr("info");
	kcHighlightSelection(selectInfo) ;
	var curPage = "";
	if ($("#helpWin").length > 0 ) {
		 curPage = $("#helpWin").attr("answer");
	}
	var url = document.location.pathname;
	var section;
	if ( url.indexOf("learnMore.jsp") >= 0 )  {
		section = "learnMore";
	} else if ( url.indexOf("designCenter.jsp") >= 0 )  {
		section = "designCenter";
	}
	
	
	//Determine where the information is coming from

	$.ajax({
	   type: "post",
	   url: "/"+section+"/" + page+"?hw="+curPage,
	   dataType: "html",
	   success: function(data){ 
			$(".kcContentMain").html(data);	
			if (dontScroll) {
				//Do nothing
			} else {
				gotoElement($("body"));	
			}
			
			
		},
		error :  function (XMLHttpRequest, textStatus, errorThrown) {
			

		}
	 });
	
	
	
}


function getVideo(selectInfo, dontScroll) {
	var page = $(selectInfo).parent().attr("info");
	kcHighlightSelection(selectInfo) ;	
	var w = $(selectInfo).parent().attr("w");
	var h = $(selectInfo).parent().attr("h");
	var data = '<iframe id="movieContent" scrolling="no" frameborder="0" src="/movies/'+page+'" width="600px" height="500px"></iframe>';	
	$(".kcContentMain").html(data);	
	if (dontScroll) {
		//Do nothing
	} else {
		gotoElement($("body"));	
	}
	
}


