function initThriveInspireVideoGrid(catID,firstVid) {
	window['thriveInspireVideoGridDefaultVideo'+catID]=firstVid
	window['thriveInspireVideoGridCurrentVideo'+catID]=firstVid;
	window['thriveInspireVideoGridHiddenVideos'+catID]=new Array();
	thriveInspireVideoGridHideVideos(catID);
	thriveInspireVideoGridAttachClickHandlers(catID);
}

function thriveInspireVideoGridHideVideos(catID) {
	var container=document.getElementById("thriveInspireVideoGridVideos"+catID);
	var videos=container.getElementsByTagName("div");
	for(var i=0;i<videos.length;i++) {
		var thisID=parseInt(videos[i].id.replace("thriveInspireVideoGridVideo",""));
		if(videos[i].id!="thriveInspireVideoGridVideo"+window['thriveInspireVideoGridDefaultVideo'+catID]) {
			window['thriveInspireVideoGridHiddenVideos'+catID][thisID]=container.removeChild(videos[i]);
			i--;
		}
	}
	container.style.display='';
}
function thriveInspireVideoGridAttachClickHandlers(catID) {
	var flashVersion = swfobject.getFlashPlayerVersion();
	var doCheck = true;
	if(window.location.search.indexOf("disableAllFlash=1") != -1){
		doCheck = false;
	}
	if(doCheck && flashVersion.major >= 7){
		var container=document.getElementById("thriveInspireVideoGridGrid"+catID);
		var thumbs=container.getElementsByTagName("div");
		for(var i=0;i<thumbs.length;i++) {
			if(thumbs[i].id=="thriveInspireVideoGridThumb"+catID+window['thriveInspireVideoGridDefaultVideo'+catID]) {
				thumbs[i].className = "thriveInspireVideoGridThumb thriveInspireVideoGridThumbActive";
			}
			var anchors=thumbs[i].getElementsByTagName("a");
			for(var j=0;j<anchors.length;j++) {
				anchors[j].attributes.removeNamedItem("onclick");
				anchors[j].onclick=thriveInspireVideoGridBuildClickHandler(catID,parseInt(thumbs[i].id.replace("thriveInspireVideoGridThumb"+catID,"")));
			}
		}
	}
}
function thriveInspireVideoGridBuildClickHandler(catID,newID) {
	return function(){
		thriveInspireVideoGridSwapVid(catID,newID);
		return false;
	};
}
function thriveInspireVideoGridSwapVid(catID,newID) {
	if(newID != window['thriveInspireVideoGridCurrentVideo'+catID]) {
		var container=document.getElementById("thriveInspireVideoGridVideos"+catID);
		var newVideo=window['thriveInspireVideoGridHiddenVideos'+catID][newID];
		var oldVideo=container.getElementsByTagName("div")[0];
		var oldID=parseInt(oldVideo.id.replace("thriveInspireVideoGridVideo",""));
		var oldThumb=document.getElementById("thriveInspireVideoGridThumb"+catID+oldID);
		var newThumb=document.getElementById("thriveInspireVideoGridThumb"+catID+newID);
		oldThumb.className = "thriveInspireVideoGridThumb";
		newThumb.className = "thriveInspireVideoGridThumb thriveInspireVideoGridThumbActive";
		window['thriveInspireVideoGridHiddenVideos'+catID][oldID]=container.replaceChild(newVideo,oldVideo);
		window['thriveInspireVideoGridCurrentVideo'+catID]=newID;
	}
}
