
// Load the navigational images

var imgAboutTC2_off = new Image();
	imgAboutTC2_off.src = "img/gnav/about_tc2.jpg";
var imgAboutTC2_on = new Image();
	imgAboutTC2_on.src = "img/gnav/about_tc2_f2.jpg";
	
var imgOurServices_off = new Image();
	imgOurServices_off.src = "img/gnav/our_services.jpg";
var imgOurServices_on = new Image();
	imgOurServices_on.src = "img/gnav/our_services_f2.jpg";
	
var imgTC2Wisdom_off = new Image();
	imgTC2Wisdom_off.src = "img/gnav/tc2_wisdom.jpg";
var imgTC2Wisdom_on = new Image();
	imgTC2Wisdom_on.src = "img/gnav/tc2_wisdom_f2.jpg";
	
var imgTC2Leaders_off = new Image();
	imgTC2Leaders_off.src = "img/gnav/tc2_leaders.jpg";
var imgTC2Leaders_on = new Image();
	imgTC2Leaders_on.src = "img/gnav/tc2_leaders_f2.jpg";

var imgTC2InAction_off = new Image();
	imgTC2InAction_off.src = "img/gnav/tc2_in_action.jpg";
var imgTC2InAction_on = new Image();
	imgTC2InAction_on.src = "img/gnav/tc2_in_action_f2.jpg";
	
var imgBlog_off = new Image();
	imgBlog_off.src = "img/gnav/david_rohdes_blog.jpg";
var imgBlog_on = new Image();
	imgBlog_on.src = "img/gnav/david_rohdes_blog_f2.jpg";
	
var imgContactUs_off = new Image();
	imgContactUs_off.src = "img/gnav/contact_us.jpg";
var imgContactUs_on = new Image();
	imgContactUs_on.src = "img/gnav/contact_us_f2.jpg";
	
	
	
// This is called when submitting a form. It will go through the 
// form elements and disable all the buttons, submits and otherwise.
function DisableForm(objForm){
	for (var i = 0 ; i < objForm.elements.length ; i++){
		if (objForm.elements[i].tagName.toLowerCase() == "input"){
			if ((objForm.elements[i].type.toLowerCase() == "button") ||
				(objForm.elements[i].type.toLowerCase() == "submit") ||
				(objForm.elements[i].type.toLowerCase() == "image")
				){
				objForm.elements[i].disabled = true;
				objForm.elements[i].className = "button-disabled";
			}		
		}
		
		objForm.elements[i].onclick = null;
		objForm.elements[i].onchange = null;
	}
}


// Highlights keywords on a page. StrKeywords is a pipe-sepparated
// list of keywords. Sends the parent node to search. If none is
// provided, it gets the body tag.
var HighlightKeywordsSearchCount = 1;
var HighlightKeywordsSearchMatchCount = 1;
function HighlightKeywords(strKeywords, objNode){
	var arrKeywords = strKeywords.split("|");
	
	if (arrKeywords.length && (arrKeywords[0] != "")){
		
		if (!objNode && document.getElementById){
			objNode = document.getElementByTagName("body").items(0);
		}
		
		if (objNode){
			// Convert keywords to lowercase
			for (var i = 0 ; i < arrKeywords.length ; i++){
				RecurseKeywordSearch(objContentCol, arrKeywords[i].toLowerCase());
			}
			
			window.status += (" ... Matches: " + --HighlightKeywordsSearchMatchCount);
		}		
	}
	
	return;
}


// Recurses through a document and highlights the keyword
function RecurseKeywordSearch(objNode, strKeyword){
	var strLowerCase = "";
	var objParent = null;
	var objNextSibling = null;
	var objSpan = null;
	var objPrevText = null;
	var objNextText = null;
	var objHighlight = null;
	var intStart = -1;
	var intEnd = -1;
	
	window.status = ("Searching Document: " + HighlightKeywordsSearchCount++)
	
	// Check the kind of node we are looking at
	if (objNode.nodeType == 3){
		// Text node - highlight text
		strLowerCase = objNode.nodeValue.toLowerCase();
		
		// Check for matching keyword
		if (strLowerCase.indexOf(strKeyword) >= 0){
		
			// Increment search match count
			HighlightKeywordsSearchMatchCount++;
		
			// Get indexes of substring
			intStart = strLowerCase.indexOf(strKeyword);
			intEnd = (intStart + strKeyword.length);
		
			// Get surrounding nodes
			objParent = objNode.parentNode;
			objNextSibling = objNode.nextSibling;
			
			// Remove text node from doc
			objNode = objParent.removeChild(objNode);
			
			// Create container node
			objSpan = document.createElement("span");
			
			// Create highlight node
			objHighlight = document.createElement("span");
			objHighlight.className = "highlight";
			
			// Get prev text
			if (intStart > 0){
				objSpan.appendChild(document.createTextNode(objNode.nodeValue.substring(0, intStart)));
			}
			
			// Get highlihgted node
			objHighlight.appendChild(document.createTextNode(objNode.nodeValue.substring(intStart, intEnd)));	
			objSpan.appendChild(objHighlight);
			
			// Get next text
			if (intEnd < objNode.nodeValue.length){
				objSpan.appendChild(document.createTextNode(objNode.nodeValue.substring(intEnd, objNode.nodeValue.length)));
			}
			
			if (objNextSibling){
				objParent.insertBefore(objSpan, objNextSibling);
			} else {
				objParent.appendChild(objSpan);
			}
		}
		
	} else {
		// Element - Loop through children
		for (var i = 0 ; i < objNode.childNodes.length ; i++){
			RecurseKeywordSearch(objNode.childNodes[i], strKeyword);
		}		
	}	
}


// Swaps images in the document with javascript images
function SwapImages(){
	var Args = arguments;
	
	for (var i = 0 ; i < Args.length ; i+=2){
		document.images[ Args[i] ].src = Args[i+1].src;
	}
}


// Makes sending an email safe for spider-resistance
function To(strName, strDoman, strExt, strSubject){
	var strURL = ("mailto:" + strName + "@" + strDoman + "." + strExt);
	
	if (strSubject){
		strURL += ("?subject=" + strSubject);
	}
	
	// Set up them email
	window.location.href = strURL;
}


// Outputs the email address without the "mailto"
function ToName(strName, strDoman, strExt){
	var strEmailName = (strName + "@" + strDoman + "." + strExt);
	
	document.write(strEmailName);
}


function rollOn(id){
	document.getElementById(id).src='img/global/header_nav_bullet_over.jpg';
}

function rollOff(id){
	document.getElementById(id).src='img/global/header_nav_bullet.jpg';
}
