var loadingImg = '<img src="http://www.brainboostcommunity.ca/img/loading.gif" title="Loading..." alt="Loading..." width="400" height="400" />';
var loadingImgMedium = '<img src="http://www.brainboostcommunity.ca/img/loading_medium.gif" title="Loading..." alt="Loading..." width="150" height="120" />';
var loadingImgSmall = '<img src="http://www.brainboostcommunity.ca/img/loading_small.gif" title="Loading..." alt="Loading..."  />';
var loadingImgShort = '<img src="http://www.brainboostcommunity.ca/img/loading_short.gif" title="Loading..." alt="Loading..." width="214" height="200" />';

function Reveal (it, box) {
	if (box.checked) {
		document.getElementById(it).style.display = "block";
	} else {
		document.getElementById(it).style.display = "none";
	}
}

function Hide (it, box) {
	if (box.checked) {
		document.getElementById(it).style.display = "none";
	} else {
		document.getElementById(it).style.display = "block";
	}
}

function showTab (section, tabsArray) {
	//var tabsArray = new Array('wire','link','file','event');
	
	var tabsNum = tabsArray.length;
	var tabName = '';
	
	for (var i = 0; i < tabsNum; i++) {
		tabId = '#' + tabsArray[i];
		tabName = tabsArray[i] + 'Tab';
		if (section == tabsArray[i]) {
			document.getElementById(tabName).className = "selected";
			//document.getElementById(tabsArray[i]).style.display = "block";
			$(tabId).show();
		} else {
			document.getElementById(tabName).className = "unselected";
			//document.getElementById(tabsArray[i]).style.display = "none";
			$(tabId).hide();
		}
	}
}

function ChangeColor(tableRow, highLight) {
	if (highLight) {
		tableRow.style.backgroundColor = '#E0EDC5';
	} else {
		tableRow.style.backgroundColor = 'white';
	}
}
function goToUrl(url) {
	document.location.href = url;
}
function DoNav(theUrl) {
	document.location.href = theUrl;
}

function showTabOld (tab, box) {
	document.getElementById(tab).className = "selected";
	document.getElementById(box).style.display = "block";
}

function hideTabOld (tab, box) {
	document.getElementById(tab).className = "unselected";
	document.getElementById(box).style.display = "none";
}

function widenScreen() {
	var windowWidth = window.screen.availWidth;
	var diff = parseInt(windowWidth - 1124);
	if (diff > 0) {		
		var searchWidth = diff - 10;
		searchWidth =  diff + "px";
		document.getElementById('contentInnerSearchPadding').style.width = searchWidth;
		
		if (document.getElementById('contentContainerMedium') != null) {
			var mediumWidth = 600 + diff;
			mediumWidth = mediumWidth + "px";
			document.getElementById('contentContainerMedium').style.width = mediumWidth;
		} else if (document.getElementById('contentContainerLarge') != null) {	
			var largeWidth = 790 + diff;
			largeWidth = largeWidth + "px";
			document.getElementById('contentContainerLarge').style.width = largeWidth;
		} else if (document.getElementById('contentContainerDiscussion') != null) {	
			var largeWidth = 790 + diff;
			largeWidth = largeWidth + "px";
			document.getElementById('contentContainerDiscussion').style.width = largeWidth;
		} else if (document.getElementById('contentContainerFull') != null) {	
			var fullWidth = 1024 + diff;
			fullWidth = fullWidth + "px";
			document.getElementById('contentContainerFull').style.width = fullWidth;
		}
		
		document.getElementById('widen').style.display = "none";
		document.getElementById('unwiden').style.display = "block";
		
	} else {
		alert('Sorry but your screen isn\'t large enough.');
	}
}
function unwidenScreen() {
	document.getElementById('contentInnerSearchPadding').style.width = "0px";
	
	if (document.getElementById('contentContainerMedium') != null) {
		document.getElementById('contentContainerMedium').style.width = "600px";
	} else if (document.getElementById('contentContainerLarge') != null) {	
		document.getElementById('contentContainerLarge').style.width = "810px";
	}
	
	document.getElementById('widen').style.display = "block";
	document.getElementById('unwiden').style.display = "none";
}

function showSubMenu(effect,submenu) {
	var options = {};	
	for (var i = 0; i < submenuNum; i++) {
		if (submenuArray[i] != submenu) {
			$(submenuArray[i]).hide();
		}
		
	}
	$(submenu).show(effect,options,200,callback);	
	function callback(){
		setTimeout(function(){
			$(submenu).hide();
		}, 3000);
	};
};

function showNavMenu() {
	var effect = 'blind';
	var options = {};
	var menuImg = document.getElementById('navMenuOpenClose');
	var menuStatus = document.getElementById('navMenuOpenClose');
	if (menuStatus.className == "closedMenu") { 
		$('#navMenu').show(effect,options,200);	
		menuImg.src = "http://www.brainboostcommunity.ca/img/minus.png";
		menuStatus.className = "openMenu";
	} else {
		$('#navMenu').hide(effect,options,200);	
		menuImg.src = "http://www.brainboostcommunity.ca/img/plus.png";
		menuStatus.className = "closedMenu";
	};
};
	
$(document).ready(function() {
	$('#loadingScreen').hide();
});

jQuery(function() {
	jQuery("#mainSearch").suggest("http://www.brainboostcommunity.ca/search/main_search.php",{
	resultsDiv:'#mainResults',
	resultsClass:'search_results',
	selectClass:'search_over',
	matchClass:'search_match'
	});
});