//Function to jump to another forum
function ForumJump(URL) {
	
	if (URL.options[URL.selectedIndex].value != "") self.location.href = URL.options[URL.selectedIndex].value;	
	return true;
}

//Function to open preview post window
function OpenPreviewWindow(targetPage, formName){
	
	now = new Date  
	
	//Open the window first 	
   	openWin('','preview','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=680,height=400')
   		
   	//Now submit form to the new window
   	formName.action = targetPage + "?ID=" + now.getTime();	
	formName.target = "preview";
	formName.submit();
}
function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}
function run_preloadImgs() {
 FP_preloadImgs('../images/banner_jensmiles.gif','../images/mpitc.jpg','../images/nav_bar/top-left.gif','../images/nav_bar/bottom-bg.gif','../images/nav_bar/bottom-left.gif','../images/nav_bar/bottom-right.gif','../images/nav_bar/box_shadow.gif','../images/nav_bar/left-side-table-bg.gif','../images/nav_bar/right-side-table-bg.gif','../images/nav_bar/top-bg.gif','../images/nav_bar/top-right.gif')
}
function OpenChat() 
{
var popup = window.open('./Chat/','windowName','width=630,height=450');
if (!popup.opener) popup.opener = self;
}

function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}
function bus_onchange(BusCat) { 
   BusCat.submit(); 
} 
function launch(URL) {  remote = open(URL, "map","width=700,height=800,left=100,top=50,scrollbars=1,resizable=1");} 

function openWin(theURL,winName,features) {
  	window.open(theURL,winName,features);
}

function reDo() {
  window.location.reload();  } 

window.onresize = reDo; 
//Define global variables 
var timerID = null; 
var timerOn = false; 
var timecount = 800; 
// Change this to the time delay that you desire 
var what = null; 
var newbrowser = true; 
var check = false; 

function init() {
  if (document.layers) {
  layerRef="document.layers";  
styleSwitch="";  
visibleVar="show";  
screenSize = window.innerWidth;  
what ="ns4";  
}  else if(document.all) {
  layerRef="document.all";  
styleSwitch=".style";  
visibleVar="visible";  
screenSize = document.body.clientWidth + 18;  
what ="ie4";  
}  else if(document.getElementById) {
  layerRef="document.getElementByID";  
styleSwitch=".style";  
visibleVar="visible";  
what="dom1";  }  else {
  what="none";  newbrowser = false;  
} 
check = true; 
} 

// Toggles the layer visibility on 
function showLayer(layerName) {  
if(check) {
  if (what =="none") {  
return;  
}  else if (what == "dom1") {
  document.getElementById(layerName).style.visibility="visible";  
}  else {
  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');  
}  
}  else {
  return;  
}  
} 

// Toggles the layer visibility off 
function hideLayer(layerName) {
  if(check) {  
if (what =="none") {
  return;  
}  else if (what == "dom1") {
  document.getElementById(layerName).style.visibility="hidden";  
}  else {
  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');  
}  
}  else {
  return;  
}  
} 

function hideAll() {
hideLayer('commpop');   
hideLayer('buspop');
hideLayer('classpop');
hideLayer('helppop');
hideLayer('calpop');
hideLayer('forpop');
hideLayer('homepop');
} 

function startTime() {
  if (timerOn == false) {
  timerID=setTimeout( "hideAll()" , timecount);  
timerOn = true;  
}  
} 

function stopTime() {
  if (timerOn) {
  clearTimeout(timerID);  
timerID = null;  
timerOn = false;  
}  
} 

function onLoad() {
  init();  
} 

// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>

function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}


function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}
function setDiv(Aname,Dname) {
	var c = getAnchorPosition(Aname);
	if (document.getElementById) {
		var o = document.getElementById(Dname);
		if (o.style) {
			o.style.left = c.x;
			o.style.top = c.y + 25;
			}
		}
	}
function get_Popup(Aname,Dname) {
        hideAll(); 
        setDiv(Aname,Dname); 
        showLayer(Dname); 
        stopTime()
	}