// JavaScript Document
if(navigator.userAgent.indexOf("MSIE")!=-1){
   document.write('<link href="include/iebody.css" rel="stylesheet" type="text/css"/>');
}
else{
  document.write('<link href="include/ffbody.css" rel="stylesheet" type="text/css"/>');
}


/* Ajax */

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
  	{
  		// Firefox, Opera 8.0+, Safari
  		xmlHttp=new XMLHttpRequest();
  	}
	catch (e)
  	{
  		// Internet Explorer
  		try
    	{
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
  		catch (e)
    	{
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
  	}
	return xmlHttp;
}

function contentStateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("content").innerHTML=xmlHttp.responseText;
	}
}

var currentAction=null;

//function getContent(action)
//{	
//    if(currentAction!=null)
//		document.getElementById(currentAction).className='tdNav';
//    document.getElementById(action).className='tdNavCurrent';
//	currentAction=action;
//							
//	xmlHttp=GetXmlHttpObject();
//  	if (xmlHttp==null)
//  	{
//    	window.location="http://dwbar.com?action="+action;
//  	} 
//	xmlHttp.onreadystatechange=contentStateChanged;
//  	xmlHttp.open("GET","ajax.php?action="+action,true);
//  	xmlHttp.send(null);
//}

function setButtonIn(action)
{
	document.getElementById(action).className='tdNavCurrent';
}

function getContent(action)
{	
    if(currentAction!=null)
		document.getElementById(currentAction).className='tdNav';
    document.getElementById(action).className='tdNavCurrent';
	  currentAction=action;
							
	  xmlHttp=null;//GetXmlHttpObject();
  	if (xmlHttp==null)
  	{
    	//window.location="http://dwbar.com?action="+action;
			window.location="index.php?action="+action;
		  return;
  	} 
	  xmlHttp.onreadystatechange=contentStateChanged;
  	xmlHttp.open("GET","ajax.php?action="+action,true);
  	xmlHttp.send(null);
}

 
 function setLocation() 
  {
		// Get height of left nav
  	NavY=document.getElementById("leftNav").offsetHeight;
		
		// Get height of content
	  ContentY=document.getElementById("content").offsetHeight;

    setInterval("checkLocation()",10);
	}
	
	function checkLocation() 
	{    		
	
  	// Get visible window height
		// document.all defined only in IE 
		// http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
		if(document.all)
  	  DocY=document.documentElement.clientHeight;
		else
		  DocY=window.innerHeight;
			
		el=document.getElementById("leftNav");
		
		NavT=el.offsetTop;
		NavB=NavT+NavY;
		
		// Get distance document is scrolled up
 		y=document.documentElement.scrollTop;
		
		if((DocY+y>NavB && NavB<=ContentY) || (y<NavT))
		{		  
		  el.style.marginTop=y+"px";
		}
	}
	
 function setLocationSmall() 
  {
		// Get height of left nav
  	NavY=document.getElementById("leftNavSmall").offsetHeight;
		
		// Get height of content
	  ContentY=document.getElementById("content").offsetHeight;

    setInterval("checkLocationSmall()",10);
		
	}
	
	function checkLocationSmall() 
	{    		
	
  	// Get visible window height
		// document.all defined only in IE 
		// http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
		if(document.all)
  	  DocY=document.documentElement.clientHeight;
		else
		  DocY=window.innerHeight;
			
		el=document.getElementById("leftNavSmall");
		
		NavT=el.offsetTop;
		NavB=NavT+NavY;
		
		// Get distance document is scrolled up
 		y=document.documentElement.scrollTop;
		if(y!=NavT)
		{
		  NavT=(NavT<y)?NavT+=1:NavT-=1;
		  el.style.marginTop=NavT+"px";
		}
		/*
		if((DocY+y>NavB && NavB<=ContentY) || (y<NavT))
		{		  
		  el.style.marginTop=y+"px";
		}
		*/
	}	