// JavaScript Document
$(document).ready(function() {
	insertPageIncludes();							   
});

function insertPageIncludes(){
	$("#pageHeader").load("includes/pageIncludes.html #pageHeaderInc");
	$("#pageFooter").load("includes/pageIncludes.html #pageFooterInc");
	$("#search").load("search.html");
	$("#menuRefs").load("includes/menus.html #menuRefsInc");
	$("#menu").load("includes/menus.html #menuItems",highlightMenus);
    if($(".faqans").length){
		$(".faqans").hide();
	}
}

function highlightMenus(){
	var menuItemsVar = $("#menuItems a");
	var bodyVar = $("var.mainMenu").text();
	for (j=0;j < menuItemsVar.length;j++){
		var atrributeVar = menuItemsVar[j].innerHTML;
		if (atrributeVar == bodyVar){
			menuItemsVar[j].className = "activeA";
			menuItemsVar[j].style.color = "#e15d5f";
		}
	}
	loadsubmenu();
}

function loadsubmenu(){
	if ($(".submenu").length){
		var subbodyid = $("var.subMenuVar").attr("id");	
		$(".submenu").load("includes/menus.html #sub"+subbodyid,highlightSubMenus);
	}
}

function highlightSubMenus(){
	var submenuItemsVar = $(".submenu a");
	var submenuVar = $("var.subMenuVar").text();
	for (j=0;j < submenuItemsVar.length;j++){
		var atrributeVar = submenuItemsVar[j].innerHTML;
		if (atrributeVar == submenuVar){
			submenuItemsVar[j].className = "activeSubA";
			submenuItemsVar[j].style.color = "#000";
		}
	}
}

/* GOOGLE CUSTOM SEARCH */
/* function for custom search box and watermark image in search box */
function customSearch() 
	{ 
	var f = document.getElementById('searchbox_000526952659465991201:adaqfwz6i-y'); 
	if (!f) 
		{ f = document.getElementById('searchbox_demo'); } 
	if (f && f.q) 
		{ 
		var q = f.q; 
		var n = navigator; 
		var l = location; 
		if (n.platform == 'Win32') 
			{ q.style.cssText = 'border: 1px solid #46461F; padding: 1px;'; } 
		var b = function() 
			{ 
			if (q.value == '') 
				{ q.style.background = '#FFFFFF url(http://www.google.com/coop/images/google_custom_search_watermark.gif) left no-repeat'; }
			}; 
		var f = function() 
			{ q.style.background = '#ffffff'; }; 
		q.onfocus = f; 
		q.onblur = b; 
		if (!/[&?]q=[^&]/.test(l.search)) 
			{ b(); } 
	} 
}


/* DIV SWAPPING w/ HIDE ALL OTHERS */
/* hide all DIVs like this one, then show the next one -- or -- hide this link's parent */
/* by Yury Borukhovich -- Thanks!!! */

function showFAQ(siblingDiv) {
	$(".faqans").hide();
    $(siblingDiv).next().show();
}


/* DIV SWAPPING */
/* show/hide a DIV (inline or layered); control styling through stylesheet */
/* originally from http://www.willmaster.com/blog/css/show-hide_floating_div.html */

function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "block";
}

function ReverseContentDisplay(d) {
	if(d.length < 1) { return; }
	if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
	else { document.getElementById(d).style.display = "none"; }
}