/****************************************************************************
*
* Copyright 2007 dynamIt Technologies, LLC.
*
* The following code is for the exclusive use of dynamIt Technologies, LLC.
* Any use of this code with written permission from dynamIt is prohibited.
*
* Report an abuse of this copyright to
*	dynamIt Technologies, LLC
*	4612 Sawmill Road
*	Columbus, Ohio 43220 USA
*	+1.614.538.0095
*
****************************************************************************/



/**************************************
* This method takes in a reference to an html element
* and returns the element obj. If the parameter passed
* is the object it self, it will simply return it back
* to the caller. Otherwise, this function will attempt
* to retrieve the element by ID. Thus, this method also
* serves as an alias for document.getElementById().
**************************************/
function dynamItElem(obj) {
	if(typeof(obj) == 'object') return obj;
	else return document.getElementById(obj);
}

/************************************
* The following methods deal with showing and hiding
* elements on the page.
************************************/
function dynamItShowMe(objId) {
	dynamItElem(objId).style.visibility = 'visible';
}
function dynamItBlockMe(objId) {
	dynamItElem(objId).style.display = 'block';
}
function dynamItNoneMe(objId) {
	dynamItElem(objId).style.display = 'none';
}

function dynamItHideMe(objId) {
	dynamItElem(objId).style.visibility = 'hidden';
}

function dynamItHTMLMe(objId) {
	dynamItElem(objId).style.innerHTML = 'Please wait a moment while your changes are processed.';
}

function dynamItShowImg(objId, newImg) {
	dynamItElem(objId).src = newImg;
}

function dynamItDevalueMe(objId) {
	dynamItElem(objId).value = '';
}

function dynamItBlankMe(objId) {
	dynamItElem(objId).innerHTML = '';
}

function dynamItToggleMe(objId) {
	if(dynamItElem(objId).style.visibility == 'hidden') dynamItShowMe(objId);
	else dynamItHideMe(objId);
	
}


function searchSite() {
	if(dynamItElem('SearchTerm').value != '' && dynamItElem('SearchTerm').value !='Keyword Search'){
		dynamItElem('searchForm').submit();
	}
}



/****************************************
 * Functions for Homepage Promolinks
 ****************************************/
var rotationGo = true;

function startRotation(num) {
	if(dynamItElem('link_' + num)) rotateMe(num);
}

function stopRotation(num) {
	rotationGo = false;
	
	// Turn off all Links
	for(j=1; j<=10; j++) {
		if(dynamItElem('rotate_'+j)) {
			dynamItElem('link_' + j).style.color = 'ffffff';
			dynamItElem('arrow_' + j).style.visibility = 'hidden';
		}
	}

	// Turn on this link and set this image
	dynamItElem('imgRotate').src = rImg[num];
	dynamItElem('arrow_' + num).style.visibility = 'visible';
	dynamItElem('link_' + num).style.color = 'FBE438';
}

function restartRotation(num) {
	rotationGo = true;
	dynamItElem('link_' + num).style.color = 'ffffff';
	dynamItElem('arrow_' + num).style.visibility = 'hidden';
}

function rotateMe(num) {
	if(rotationGo) {
		var last;
		var next;
		
		// Turn off all links
		for(j=1; j<=10; j++) {
			if(dynamItElem('rotate_' + j)) {
				last = j;
				dynamItElem('link_' + j).style.color = 'ffffff';
				dynamItElem('arrow_' + j).style.visibility = 'hidden';
			}	
		}
		
		// Turn this link on
		dynamItElem('link_' + num).style.color = 'FBE438';
		dynamItElem('imgRotate').src = rImg[num];
		dynamItElem('arrow_' + num).style.visibility = 'visible';
		
		// Set rotation for the next link
		next = num + 1;
		if(next > last) next = 1;
		setTimeout('rotateMe(' + next + ')', 4000);
	} else setTimeout('rotateMe(' + num + ')', 6000);
}