/* Menu-buttons mouseover script */
function doMOv(obj){  obj.src = obj.src.replace (".png", "_mo.png" ); }
function doMOff(obj){ obj.src = obj.src.replace ("_mo.png", ".png" ); }
function pgLoad(){ // set button for current page/topic
	if(document.getElementById('pgIdent'))
	{	obj = document.getElementById(document.getElementById('pgIdent').innerHTML);
		if(obj.src.indexOf("_mo")==-1) // in case they are hovering over at the time!
			obj.src = obj.src.replace (".png", "_mo.png" );
		obj.onmouseover="";// remove mouse over events from highlighted button
		obj.onmouseout="";
	}
	// see if #xxx is used to move to correct location
	// fixed header workaround
	pgURL = window.location.href;
			if(pgURL.match(/#/))
			 { // see if HI (Hidden Item) exists
				if(pgURL.match(/HI$/))
					{	bareHash=location.hash.replace(/#/, "");
						bits=bareHash.split("!");
						document.getElementById(bits[0]).style.display='block';
						listItems = document.getElementById(bits[1]).getElementsByTagName('li');
						//listItems[bits[0].replace(/\D+/,"")].className = bits[1] + 'HL';
						listItems[bits[0].replace(/\D+/,"")].className = listItems[bits[0].replace(/\D+/,"")].className.replace(/matAll/,'matAllHL');
					}
			 	else {	//eL = document.getElementById(location.hash.replace(/#/,""));
			 			//eL.scrollIntoView(true);
			 			if(pgURL.match(/resources/i)) // check if its the resources page - this is more for coming back from cart (i=case insensitive)
			 				{ // if there is a hash, show that div
			 					if(location.hash != '')
			 						swapRes(location.hash.replace(/#/,""));		 }
			 			else {	setTimeout("window.scrollBy(0,-140)",200); 		 }
			 		}
			 }
 			// for the google map on contacts page - maybe others (training) coming soon
			// we need to fire the map api
			if (location.href.indexOf("company/") != -1)
					{	load();
						window.onunload="GUnload();"			}
				try {  // test for the existence of imgSrc variable - if its not set then do nout!
					if(imgSrc) 	{ 	doTimer();		} // fires the timer function for image rotation
				}catch(err){}
}

//function to goTo an anchor then scroll down a bit past the header
function goAnc(anc) {
document.getElementById(anc).scrollIntoView(true);
window.scrollBy(0,-140);
}
// submit a javascript location.href via an a link
function goA(pg) {
if(navigator.appVersion.indexOf("MSIE") != -1 )
{ // MSIE
a = document.getElementById('goAlink');
a.href = pg;
a.click()
}
else {location.replace(pg);}
}

function clickHref(h){
if(navigator.appVersion.indexOf("MSIE") != -1 )
{document.getElementById(h).click();} // MSIE
else{location.replace(document.getElementById(h).href);}
}
function hlRow(rW) {
rW.parentNode.style.backgroundColor="#cccccc";
}
function unhlRow(rW) {
rW.parentNode.style.backgroundColor="";
}
/* did this one for the tr highlight as an alternative */
function hltr(rW) {rW.style.backgroundColor="#cccccc";}
function unhltr(rW) {rW.style.backgroundColor="";}


function swapRange(show, liItem) {
uL=liItem.parentNode;
listItems=uL.getElementsByTagName("li");
numItems=listItems.length;
itemName = show.replace(/\d+/, ""); 
for(i=0;i<numItems;i++){if(document.getElementById(itemName+i)){document.getElementById(itemName+i).style.display='none';}}
for (i=0; i<numItems; i++){listItems[i].className=listItems[i].className.replace(/matAllHL/,'matAll');}
sD=document.getElementById(show);
sD.style.display='block';
liItem.className=liItem.className.replace(/matAll/,'matAllHL') //uL.id+'HL';
// This stops history from clogging up with useless hashes
// pgloc=window.location.href.split("#");
// location.replace(pgloc[0] + '#' + show + '!' + uL.id + '!' + 'HI');
location.hash='#'+show+'!'+uL.id+'!'+'HI';
}

function layerSwap(show, hide) {
document.getElementById(hide).style.display='none';
document.getElementById(show).style.display='block';
}
function hideLayer(e){document.getElementById(e).style.display='none';}
function showLayer(e){document.getElementById(e).style.display='block';}

function swapRes(show) {
// for resources page - swaps div around
document.getElementById('softwareGuides').style.display='none';
document.getElementById('insetPacks').style.display='none';
document.getElementById('projects').style.display='none';
document.getElementById('solidProfessor').style.display='none';
location.hash = '#'+show;
document.getElementById(show).style.display='block';
}
function popUp(objName){
document.getElementById('blanket').style.display='block';
document.getElementById(objName).style.display = 'block';
centerDiv(objName);
}
function popUpNB(objName){
document.getElementById(objName).style.display = 'block';
centerDiv(objName);
}
function closePop(objName){
document.getElementById('blanket').style.display='none';
document.getElementById(objName).style.display='none';
}
function getStyleProperty(obj, IEStyleProp, CSSStyleProp)
{
if (obj.currentStyle) //IE
return obj.currentStyle[IEStyleProp];
else if (window.getComputedStyle) //W3C
return window.getComputedStyle(obj,
"").getPropertyValue(CSSStyleProp);

return null;
}
window.size = function()
{	var w = 0;
	var h = 0;
	//IE
	if(!window.innerWidth)
	{	//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{	w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}

function enlargeVid() {
obj = document.getElementById('media1');
pDiv = obj.parentNode;
link = document.getElementById('media1Link');
ppDiv = pDiv.parentNode;
obj.style.width = '360';
obj.style.height = '288';
pDiv.style.backgroundColor = '#CCCCCC';
pDiv.style.padding='15';
link.style.width='360';
link.innerHTML = '<a href="javascript:shrinkVid();">Shrink Video</a>';
ppDiv.style.height = '573';
}
function shrinkVid() {
obj = document.getElementById('media1');
pDiv = obj.parentNode;
link = document.getElementById('media1Link');
ppDiv = pDiv.parentNode;
obj.style.width = '166';
obj.style.height = '170';
pDiv.style.backgroundColor = '';
pDiv.style.padding='0';
link.style.width='167';
link.innerHTML = '<a href="javascript:enlargeVid();">Enlarge Video</a>';
ppDiv.style.height = '455';
}

function fullScreen()
{
   var player=document.getElementById("media1"); 
   player.DisplaySize=3;
}

function loadVid(vidName, tarDiv) {
content = '<div class="ar"><img src="_layout_img/close-button.png" alt="Close" onmouseover="doMOv(this);" onmouseout="doMOff(this);" onclick="unloadVid(\''+tarDiv+'\');" /></div>';
content+= '<div class="pad40"><object id="media1" height="288" type="video/x-ms-wmv" width="360">';
content+= '<param name="filename" value="/videos/' + vidName + '.wmv" />';
content+= '<param name="WindowlessVideo" value="-1" />';
content+= '<param name="wmode" value="opaque" />';
content+= '</object></div>';
document.getElementById(tarDiv).innerHTML = content;
popUp(tarDiv);
}
function unloadVid(tarDiv) {
document.getElementById(tarDiv).innerHTML = '';
closePop(tarDiv);
}
function centerDiv(objName)
{
obj=document.getElementById(objName);
	centerXY = getViewportXY();
	/*
	if(obj.offsetWidth > centerXY[0])
		obj.style.width = (centerXY[0] -40) + 'px';
	if(obj.offsetHeight > centerXY[1])
		obj.style.height = (centerXY[1] -40) + 'px';
	*/
	centerXY[0] = centerXY[0] / 2;
	centerXY[1] = centerXY[1] / 2;
	divWidth = obj.offsetWidth;
	divHeight = obj.offsetHeight;
	XYoffset = getScrollXY();
	_x = (centerXY[0] + XYoffset[0]) - (divWidth/2);
	_y = (centerXY[1] + XYoffset[1]) - (divHeight/2);
obj.style.top=_y;
obj.style.left=_x;
// alert('Avail Width: ' + (centerXY[0] * 2) + ' x ' + (centerXY[1] * 2) + ' | div WxH: ' + divWidth + ' x ' + divHeight + 'CenterX: ' + centerXY[0] + ' Y: ' + centerXY[1] + 'Xoffset: ' + XYoffset[0] + ' Y: ' +XYoffset[1]);
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [scrOfX,scrOfY];
}

function getViewportXY(){
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 // older versions of IE
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
return [viewportwidth,viewportheight];
}




function tabOv(obj){  
		if(obj.src.indexOf("_act")!=-1)
		{	// do nothing
		}
		else obj.src = obj.src.replace (".png", "_mo.png" );
}
function tabOff(obj){ obj.src = obj.src.replace ("_mo.png", ".png" ); }

