/* NCMEDC.org Functions */

try { document.execCommand("BackgroundImageCache", false, true); } catch(e) {}

var varglobal = new Object();
var kcOpen = false;
var kcTimeout = null;
var loginTimeout = null;
var loginOpen = false;
var loaded = false;
var locked = false;
var headerImages = new Array(1);
var currentHeadImg = 0;
var currentHeadLayer = 2;

function openCOLC(lock,state) {
	
	if (lock == true) { locked = true; } else { locked = false; }

	// if knowledgeCenter element exists
	if ($('COLC') && $('COLCMenu')) {

		if (kcOpen == true) {
			clearTimeout(kcTimeout);
		} //end if

		if (state == 'open') {
		
			var thisPosition = Position.cumulativeOffset($('COLC'));
			//var thisWidth = $('COLC').getWidth();
			//var thisRight = screenSize('width')-(thisPosition[0]+thisWidth);
			
			//$('COLCMenu').style.width = thisWidth-2 + 'px';
			//$('COLCMenu').style.top = thisPosition[1] + 'px';
			$('COLCMenu').style.left = thisPosition[0] + 'px';
			
			$('COLCMenu').style.display='block';
			//$('knowledgeCenter').style.display='none';
			
			//var thisLeft = thisPosition[0];
			
			var thisLeft = thisPosition[0];// - (215 - thisWidth);
			new Effect.Morph('COLCMenu', { style:'height:178px;left:' + thisLeft + 'px;', duration:0.2, afterFinish:function() { kcOpen = true; } });
		} //end if
	} //end if

} //end function


function closeCOLC(loc) {

	// if knowledgeCenter element exists
	if ($('COLC') && $('COLCMenu')) {

		if (kcOpen == true && locked == false) {
			
			kcPosition = Position.cumulativeOffset($('COLC'));
			kcWidth = $('COLC').getWidth()-2;

			kcTimeout = setTimeout("new Effect.Morph('COLCMenu', { style:'height:1px;left:' + kcPosition[0] + 'px;', duration:0.2, afterFinish:function() { kcOpen = false;$('COLCMenu').style.display='none'; } });",400);
		} //end if
		//$('knowledgeCenterMenu').style.height='32px';
		//$('knowledgeCenterMenu').style.display='none';
	} //end if

} //end function



function kcRollImg(img) {
	if (img) {
		$('kcRollImage').src = img;		
	} else {
		$('kcRollImage').src = 'http://66.205.71.108/images/spacer.gif';
	} //end if-else
} //end function




/* Utility Functions */


function resizeWin() {
	loaded = true;
} //end function

function screenSize(axis) {

	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	  } else {
		if( document.documentElement &&
			( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		  //IE 6+ in 'standards compliant mode'
		  myWidth = document.documentElement.clientWidth;
		  myHeight = document.documentElement.clientHeight;
		} else {
		  if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		  }
		}
	  }

	if (axis == 'width') {
		return myWidth;
	} else {
		return myHeight;
	} // end if
} //end function

function startHeader() {
	if (headerImages.length > 1) {
		setTimeout("swapHeader();",4000);
	} //end if
}

function swapHeader() {

	if (headerImages.length > 1) {
		
		currentHeadImg = currentHeadImg + 1;
		if (currentHeadImg >= headerImages.length) { currentHeadImg = 0; }
		
		// Set layer 1
		if (currentHeadLayer == 2) {
			$('imgLayer1').style.backgroundImage = 'url(/images/headerImgs/' + headerImages[currentHeadImg] + ')';
			new Effect.Opacity('imgLayer2', {duration:1.0, from:1.0, to:0.0});
			currentHeadLayer = 1;
		
		// Set layer 2
		} else if (currentHeadLayer == 1) {
			$('imgLayer2').style.backgroundImage = 'url(/images/headerImgs/' + headerImages[currentHeadImg] + ')';
			new Effect.Opacity('imgLayer2', {duration:1.0, from:0.0, to:1.0});			
			currentHeadLayer = 2;
		} //end if


		setTimeout("swapHeader();",4000);
	} //end if

} //end function

