// NetDocuments JS by Rhett Phillips

window.onload = function(){
	tgv = new Array();
	bodyonload();
	}

function d(t){return document.getElementById(t);}
function tag(t,e){return d(t).getElementsByTagName(e);}
function type(td){if(typeof(td)=='string'){e = d(td);}else{e = td;}return e;}
function hide(t){e = type(t);e.style.display='none';}function unhide(t){e = type(t);e.style.display='';}
function on(t){e = type(t);addClass('on',e);}function off(t){e = type(t);removeClass('on',e);}
function gif(t){d(t).innerHTML = '<img src="http://www.weberism.com/spring/loading.gif" style="margin:40px auto 40px auto" />';}
function href(url){window.location.assign(url);}
function showHide(what)
{
	value = (document.getElementById(what).style.display == 'none') ? 'block' : 'none';
	document.getElementById(what).style.display = value;
	/*clearTimeout(timer[theDiv]);
	delete timer[theDiv];*/

}
function resize(what,size)
{
document.getElementById(what).style.height="auto";
if(document.getElementById(what).offsetHeight < size) document.getElementById(what).style.height = size+"px";
}

//Twitter Limit Chars
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}


// Chat
function HelpTimer ( )
{
	
  	if(window.name!='nochat'){
    setTimeout ( "oStatus()", 1000 );}
}
function oStatus ( )
{
	if(window.kiloboat_onlinestate[0].isonline!=0){setTimeout ("AskHelp()", 1000);}
}
function AskHelp ( )
{
  d("theChat").style.display = ''}

function chat(){if(window.name!='nochat'){chatTime++;window.name=chatTime;if(window.kiloboat_onlinestate[0].isonline!=0 && chatTime>=30){d("theChat").style.display = '';d("theChat").style.top = (document.documentElement.clientHeight/2)+(document.body.scrollTop || document.documentElement.scrollTop)+'px';}var chatSet=setTimeout("chat()",3000);}}

function nochat(){d("theChat").style.display='none';window.name = 'nochat';}

function buzz(){if(d('buzzInput').value!=''){get('subscribe.aspx?email='+d('buzzInput').value+'&rand='+Math.random(9999),"d('ndbuzzword').innerHTML = ajax;fadein('ndbuzz');setTimeout(\"hide('ndbuzz')\",2000)");}else{alert('Please input email to subscribe.');}}

function jump(selObj){href(selObj.options[selObj.selectedIndex].value);}
function din(t)
	{
	var d1=t.getAttribute('default');
	if(d1==null)
	{
		d1=t.getAttribute('value');
	}
	var v1=t.value;
	if(d1==v1)
		{
		t.value='';
		t.className='';
		}
	if(v1=='')
		{
		t.value=d1;
		t.className='default';
		d('searchResults').style.display='none';
		}
	}
	
function iSearch(e)
	{ 
	sResults = d('searchResults');
	var term = d('searchInput').value;
	if(window.event)
		{
		var keynum=e.keyCode;
		}
		else if(e.which)
		{
		var keynum=e.which;
		}
	if(term=='')
		{
		d('searchResults').style.display='none';
		}
	if(keynum>40 || keynum<9)
	{
	sResults.innerHTML='';
 	if(term.length>1)
 		{
 		sResults.style.display='';
 		}
 	else
 		{
 		sResults.style.display='none';
 		}
 	patt = new RegExp(term,"gi");
 	searchTrue=0;
 	for(n=0;n<si.length;n++)
 		{
 		if(si[n][0].match(patt) || si[n][2].match(patt))
 			{
			newE = document.createElement('a');
			newE.setAttribute('href',si[n][1]);
			newE.innerHTML = si[n][0];
			sResults.appendChild(newE);searchTrue=1;
			}
		}
  		if(searchTrue!=1)
  			{
			//newE = document.createElement('a');newE.setAttribute('href','../../search.aspx#'+term);
			//newE.innerHTML = 'No Shortcuts Found';
			//sResults.appendChild(newE);
  			}
  
  		newE = document.createElement('a');
  		newE.setAttribute('href','../../search.aspx#'+term);
  		newE.setAttribute('class','s');
		newE.setAttribute('id','viewall');
		newE.innerHTML = 'View All Results &rarr;&nbsp;';
		sResults.appendChild(newE);
		aE=0;
		}
	aEs = sResults.getElementsByTagName('a');

	if(keynum==38 && aE>0)
		{
		if(aEs[aE-1])
			{
			removeClass('on',aEs[aE-1]);
			}
		if(aE==1)
			{
			aE=aEs.length+1;
			}
		aE--;
		addClass('on',aEs[aE-1]);
		}
			
	if(keynum==40 && aEs.length>=aE)
		{
		if(aEs[aE-1])
			{
			removeClass('on',aEs[aE-1]);
			}
		if(aE==aEs.length)
			{
			aE=0;}
			aE++;addClass('on',aEs[aE-1]);
			}
		if(keynum==13 && aE==0)
			{
			window.location.assign("../../search.aspx#"+term);
			}
		if(keynum==13)
			{
			window.location=aEs[aE-1].getAttribute('href');
			}
		}
 
// Class Methods
function addClass(c,t){ e = type(t);e.className += ' '+c;}
function removeClass(c,t){ e = type(t);
	var cA = e.className.split(' ');var endC = new String();
	for(cN=0;cN<cA.length;cN++){ if(cA[cN]!=c){endC += cA[cN]+' ';}}
	e.className = endC;}
function getByClass(theClass,theId,theTag){
	if(!theId){theId = document;}else{theId = type(theId);}
	if(!theTag){theTag='*';}
	var allElements = theId.getElementsByTagName(theTag);
	var allClass = new Array();var aC=0;
	for (aT=0;aT<allElements.length;aT++){if(allElements[aT].className.match(theClass)){allClass[aC]=allElements[aT];aC++;}}
	return allClass;}
function matchClass(e,c){
	ca = d(e).className.split(' ');for(cm=0;cm<ca.length;cm++){if(ca[cm].match(c)){cr=true;break;}cr=false;}return cr;}
	
// TabGroup
function tg(g,n){
	if(tgv[g]){var oldTab = d('t-'+g+'-'+tgv[g]);var oldPage = d('p-'+g+'-'+tgv[g]);
	removeClass('on',oldTab);addClass('dn',oldPage);}
	var newTab = d('t-'+g+'-'+n);var newPage = d('p-'+g+'-'+n);
	addClass('on',newTab);removeClass('dn',newPage);tgv[g] = n;}
	
function new_win(url,w,h,tool,loc,scroll,resize){var p;
	p = "width="+w+",height="+h+",toolbar="+tool+",location="+loc+",scrollbars="+scroll+",resizable="+resize;window.open(url,'',p);}
	
// Fade In
function fadein(imageId){image = document.getElementById(imageId);setOpacity(image, 0);image.style.visibility = "visible";init(imageId,0);}
function init(objId,opacity){if(document.getElementById){obj = document.getElementById(objId);if(opacity <= 100){setOpacity(obj, opacity);opacity += 10;window.setTimeout("init('"+objId+"',"+opacity+")", 25);}}}
function setOpacity(obj, opacity){opacity = (opacity == 100)?99.999:opacity;obj.style.filter = "alpha(opacity:"+opacity+")";obj.style.KHTMLOpacity = opacity/100;obj.style.MozOpacity = opacity/100;obj.style.opacity = opacity/100;}

// Ajax Get
function get(url,callBack){if(window.XMLHttpRequest){req = new XMLHttpRequest();req.onreadystatechange = function(){done(callBack);};req.open("GET", url, true);req.send(null);}else if(window.ActiveXObject){req = new ActiveXObject("Microsoft.XMLHTTP");if(req){req.onreadystatechange = function(){done(callBack);};req.open("GET", url, true);req.send();}}}
function done(callBack){if(req.readyState == 4){if(req.status == 200 || req.status == 304){var ajax=req.responseText;eval(callBack);}else{alert("Unable to Retrieve Data:\n"+req.statusText);}}}

function nextPage()
{	
	pageNum = document.getElementById('pageNum').innerHTML;	
	newPage = pageNum+1;
	url = newPage+".aspx";
	document.getElementById('menuContent').innerHTML = url;
	pageNum = 0;
}
function prevPage(x)
{
	document.write('here');
}
function scroller(xcoord,ycoord)
{
	window.scroll(xcoord,ycoord);
}