<!--
/*======================================================================/*
// InstantForum.NET - Global JavaScript File							//
// (c) Ryan Healey © 2004 InstantASP Limited.							//
//																		//
// http://www.instantasp.co.uk/											//
// sales@instantasp.co.uk												//
\*======================================================================*/

// Get browser information

var if_userAgent = navigator.userAgent.toLowerCase();
var opera = (if_userAgent.indexOf('opera') != -1); // is opera
var ns4 = (document.layers) ? true : false; // is netscape 4
var ie4 = (document.all && !document.getElementById) ? true : false; // is IE 4
var ie5 = (document.all && document.getElementById) ? true : false; // is IE 5+
var ns6 = (!document.all && document.getElementById) ? true : false; // is netscape 6

// Set menu variables
var mnu_active = false; // determines if a menu is active
var mnu_items = new Array(); // holds a collection of current active menus
var mnu_left = 0;
var mnu_right = 0;
var mnu_top = 0;
var mnu_bottom = 0;

/* ----------------------------------------------------------- */
// Set-up document event handlers									   
/* ----------------------------------------------------------- */

if (ie4 || ie5 || opera) {
	document.onclick = if_hideAllMenusOnClick;
	document.onscroll = if_hideAllMenusOnClick;
}    
else if (ns6) { 
	document.addEventListener("mousedown", if_hideAllMenusOnClick, true);
} 
else if (ns4) {
	document.onmousedown = if_hideAllMenusOnClick;
	window.captureEvents(Event.MOUSEMOVE);
}

/* ----------------------------------------------------------- */
// Determine what object model we should use                   
/* ----------------------------------------------------------- */

function if_returnObjRef(objName)
{

	var objReturn = '';
		if (ie5 || ns6)
		{
			objReturn = document.getElementById(objName);
			if (!objReturn) {
				objReturn = document.getElementById(if_findInASPNETControlTree(objName));
			}
		}
		else if (ie4 || opera)
		{
			objReturn = document.all[objName];
			if (!objReturn) {
				objReturn = document.all[if_findInASPNETControlTree(objName)];
			}
		}
		else if (ns4)
		{
			objReturn = document.layers[objName];
			if (!objReturn) {
				objReturn = document.layers[if_findInASPNETControlTree(objName)];
			}
		}

	return objReturn

}

/* ----------------------------------------------------------- */
// If we cannot immediatly find a tbody object to hide a table this 
// will loop though all tbodies and find the object regardless of any
// asp.net control tree identifiers - things like _ctl1_objectID
/* ----------------------------------------------------------- */

function if_findInASPNETControlTree(strObjectName) {
	
	var strObjectOutput;
		tbodies = document.getElementsByTagName("tbody");
		for (var i = 0; i < tbodies.length; i++)
		{
			if (tbodies[i].id.indexOf(strObjectName) > 0) {
			strObjectOutput = tbodies[i].id;
			}
		}
		
	return strObjectOutput;
	
}

function if_openMenuMouseOver(caller_id, mnu_div_id, strForumSkin, mnu_width) {
	
	if (mnu_active) {
		if_openMenu(caller_id, mnu_div_id, strForumSkin, mnu_width)
	}
		
}

/* ----------------------------------------------------------- */
// Open Menu on MouseClick
/* ----------------------------------------------------------- */

function if_openMenu(caller_id, mnu_div_id, strForumSkin, mnu_width) {
		
		// determine if we can create elements dynamically
		
		if (!document.createElement) {return false;}
		
		// check to see if item is already within active menu array if so just quit and return false
				
		for (count = 0; count < mnu_items.length; count++)	{
			if (mnu_items[count] == mnu_div_id) {
				return false;
			}
		}
		
		// hide any menus that maybe open
		
		if_hideAllMenus();
		
		// add active menu to array and set active state to true
		
		mnu_items[mnu_items.length] = mnu_div_id;
		mnu_active = true;
		
		// create the div layer container for this menu
		
     	if_setDiv(mnu_div_id, strForumSkin, mnu_width);
     	
     	// get object references to div layer and div_layer that called this function
		
		var div_layer = if_returnObjRef(mnu_div_id);
     	var div_layer_caller = if_returnObjRef(caller_id);
     	
     	// set default offset for div layer from the caller div
     	
		var offsetTopDefault;
		offsetTopDefault = div_layer_caller.offsetHeight + 5;
		
		if ((ie4 || ie5) && !opera) {
			div_layer.filters.revealTrans.apply();
		}		
		
		// position div layer relative to the opening link
     	
     	div_layer.style.top = if_getAbsoluteOffsetTop(div_layer_caller) + offsetTopDefault;
     	div_layer.style.left = if_getAbsoluteOffsetLeft(div_layer_caller);   
     	
       	// get left, right, top and bottom co-ordinates for div layer
		
     	if (ie4 || ie5 || opera) { 
 			mnu_left = div_layer.style.posLeft;
			mnu_top = div_layer.style.posTop - offsetTopDefault; 
		}
		else if (ns6) {
			mnu_left = if_removePX(div_layer.style.left);
			mnu_top = if_removePX(div_layer.style.top);
		}
		
		mnu_right = parseInt(mnu_left) + parseInt(mnu_extent.x);			
		mnu_bottom = parseInt(mnu_top) + parseInt(mnu_extent.y);
		
		// attempt to keep menu on screen
			
		if (ie4 || ie5 || opera || ns6) { 
 			win_width = document.body.clientWidth;
			if (mnu_right > win_width)
			{div_layer.style.left = win_width - mnu_width - 10;}
		}
				
     	// play layer filter just before displaying   
     	
		if ((ie4 || ie5) && !opera) {div_layer.filters.revealTrans.play();}
		
		// hide select boxes
		
		if_toggleSelects('hidden')
		
		// finally display the menu
		
		div_layer.style.display = "";
		
}

/* ----------------------------------------------------------- */
// This funtion removes the px chars from top and left 
// properties for NS6 browsers and returns a int
/* ----------------------------------------------------------- */

function if_removePX(strInput)	{
	var strOutput = 0;
	strOutput = strInput.substr(0, strInput.length -2);
	return strOutput;	
}

/* ----------------------------------------------------------- */
// Hide all menus on click event of document
/* ----------------------------------------------------------- */

function if_hideAllMenusOnClick(event) {
	
	if (mnu_active) {
		
		// find the element that was clicked on.

		if (ie4 || ie5 || opera) {
			el = window.event.srcElement;
		}
		else {
			el = (event.target.tagName ? event.target : event.target.parentNode);
		}

		// if the element is not part of a menu, reset and clear the active button.

		if (if_getContainer(el, "DIV") == null) {
			if_hideAllMenus();
		}
	
	}
		
}

/* ----------------------------------------------------------- */
// Hide all active menus 
/* ----------------------------------------------------------- */

function if_hideAllMenus() {
	
	if (mnu_active) {	
		if_toggleSelects('visible');
		for (count = 0; count < mnu_items.length; count++)	{
			var div_layer = if_returnObjRef(mnu_items[count]);
			if (div_layer != null)	{
				div_layer.style.display = 'none';
				mnu_items[count] = '';
				mnu_active = false;
			}
		}			
	}
		
}

/* ----------------------------------------------------------- */
// Starting with the given node, find the nearest containing element
// with the specified tag name.
/* ----------------------------------------------------------- */

function if_getContainer(node, tagName) {

  while (node != null) {
    if (node.tagName != null && node.tagName == tagName)
      return node;
    node = node.parentNode;
  }

  return node;
}

/* ----------------------------------------------------------- */
// Hide select boxes when menus are expanded
/* ----------------------------------------------------------- */

function if_toggleSelects(state) {

	if (ie4 || ie5 || opera || ns6)	{
		selects = document.getElementsByTagName("select");
		for (var i = 0; i < selects.length; i++)
		{selects[i].style.visibility = state;}
	}

}

/* ----------------------------------------------------------- */
// Determine if the click occurs outside of active layer
/* ----------------------------------------------------------- */

/* 

function if_outsideExtent(e) {
	
	var bolReturn = false;	

	if ((ie4 || ie5) || opera) {
		var x = window.event.clientX;
		var y = window.event.clientY;
		if (x < mnu_left || x > mnu_right) {bolReturn = true;}
		else if (y < mnu_top || y > mnu_bottom) {bolReturn = true;}
	}
	else if (ns6 || ns4) {
		var x = e.pageX;
		var y = e.pageY;				
		if (x < mnu_left || x > mnu_right) {bolReturn = true;}
		else if (y < mnu_top || y > mnu_bottom) {bolReturn = true;}
	}
	
	//alert("x: " + x + " y: " + y);
		
	return bolReturn;
	
}

*/ 

/* ----------------------------------------------------------- */
// Create div layer to hold menu
/* ----------------------------------------------------------- */

function if_setDiv(mnu_div_id, strForumSkin, mnu_width) {     

	// create div layer container to holder table
	
    var elemDiv = document.createElement('div');     	
    elemDiv.id = mnu_div_id;
    elemDiv.setAttribute('class','');
    elemDiv.style.position = 'absolute';       
    elemDiv.style.width = mnu_width;
    
    // if IE apply layer effects
    
    if ((ie4 || ie5) && !opera)	{
	elemDiv.style.filter += "progid:DXImageTransform.Microsoft.alpha(enabled=1,opacity=100)";
	elemDiv.style.filter += "progid:DXImageTransform.Microsoft.shadow(direction=135,color=#AAAAAA,strength=2)";
	elemDiv.style.filter += "revealTrans(duration=0.2,transition=5)";}		
	
	// deteremine what table to apply as the innerHTML of the div layer container
	
	if (mnu_div_id == "if_menu_search") 
	{elemDiv.innerHTML = if_InitSearch(strForumSkin);}
	else if (mnu_div_id == "if_menu_recent_topics") 
	{elemDiv.innerHTML = if_InitRecentPosts();}
	else if (mnu_div_id == "if_control_panel") 
	{elemDiv.innerHTML = if_InitControlPanel();}
	
	// add div layer to documents
	
	document.body.appendChild(elemDiv);    
	
	// get layer height now content has been added
	
	var mnu_height;
	
	if ((ie4 || ie5) || ns6)
		{mnu_height = elemDiv.offsetHeight;}
	else if (ns4)	
		{mnu_height = elemDiv.clip.height;}
	
	mnu_extent = {
		x : mnu_width,
		y : mnu_height
	};
		
	// finally hide the layer 
	
	elemDiv.style.display = "none";			
		
}

/* ----------------------------------------------------------- */
// Build Search Link 
/* ----------------------------------------------------------- */

function if_InitSearchLink(strForumSkin) {
	
	var strLink = '';
	if (ie4 || ie5 || ns6) {
	strLink += '<a href="javascript:void(\'\');" class="smllinks"><img src="';
	strLink += strForumSkin;
	strLink += 'navigation_search.gif" border="0" align="absmiddle">Search</a>';}
	else {
	strLink += '<a href="search.aspx" class="smllinks"><img src="';
	strLink += strForumSkin;
	strLink += 'navigation_search.gif" border="0" align="absmiddle">Search</a>';}
	document.write(strLink);
	
}

/* ----------------------------------------------------------- */
// Build Search Menu
/* ----------------------------------------------------------- */

function if_InitSearch(strForumSkin) {
 
	var tableCode = '';
	tableCode += '<form name="mnu_search" method="get" action="search.aspx">'
	tableCode += '<table width="100%" class="ForumsBackGroundTable" cellspacing="0" cellpadding="0">';
	tableCode += '<tr><td>'
	tableCode += '<table width="100%" cellspacing="1" cellpadding="5">'
	tableCode += '<tr><td class="ForumsHeader">'
	tableCode += 'Search Forums</td></tr>'
	tableCode += '<tr><td nowrap class="ForumsBody1">'
	tableCode += '<input type="text" class="FormInputText" name="query">&nbsp;'
	tableCode += '<input type="image" align="absmiddle" border="0" src="'
	tableCode +=  strForumSkin + 'button_go.gif"></a></td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="search.aspx?adv=1" class="smlLinks">Advanced Search</a></td></tr>'
	tableCode += '</table>'
	tableCode += '</td></tr>'
	tableCode += '</table></form>';			
	return tableCode;

}

/* ----------------------------------------------------------- */
// Build Recent Posts Link 
/* ----------------------------------------------------------- */

function if_InitRecentTopicsLink() {
	
	var strLink = '';
	if (ie4 || ie5 || ns6) {
	strLink += '<a href="javascript:void(\'\');" class="smllinks">Recent Topics</a>&nbsp;|&nbsp;';}
	else {
	strLink += '<a href="miscellaneous.aspx?show=misc24" class="smllinks">Recent Topics</a>&nbsp;|&nbsp;';
	}
	
	document.write(strLink);
	
}

/* ----------------------------------------------------------- */
// Build Recent Posts Menu
/* ----------------------------------------------------------- */

 function if_InitRecentPosts() {
 
	var tableCode = '';
	tableCode += '<table width="100%" class="ForumsBackGroundTable" cellspacing="0" cellpadding="0">';
	tableCode += '<tr><td>'		
	tableCode += '<table width="100%" cellspacing="1" cellpadding="5">'
	tableCode += '<tr><td class="ForumsHeader">'
	tableCode += 'Select View</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="miscellaneous.aspx?show=lastvisit" class="smlLinks">Posts since my last visit</a>'
	tableCode += '</td></tr><tr><td class="ForumsBody1">'
	tableCode += '<a href="miscellaneous.aspx?show=misc12" class="smlLinks">Posts from last 12 hours</a>'
	tableCode += '</td></tr><tr><td class="ForumsBody1">'
	tableCode += '<a href="miscellaneous.aspx?show=misc24" class="smlLinks">Posts from last 24 hours</a>'
	tableCode += '</td></tr><tr><td class="ForumsBody1">'
	tableCode += '<a href="miscellaneous.aspx?show=misc48" class="smlLinks">Posts from last 48 hours</a>'
	tableCode += '</td></tr></table>'		
	tableCode += '</td></tr>'
	tableCode += '</table>';			
	return tableCode;

}

/* ----------------------------------------------------------- */
// Build Control Panel Link 
/* ----------------------------------------------------------- */

function if_InitControlPanelLink() {
	
	var strLink = '';
	if (ie4 || ie5 || ns6) {
	strLink += '<a href="javascript:void(\'\');" class="smllinks"><b>Control Panel</b></a>&nbsp;|&nbsp;';}
	else {
	strLink += '<a href="profile" class="smllinks"><b>Control Panel</b></a>&nbsp;|&nbsp;';
	}
	
	document.write(strLink);
	
}

/* ----------------------------------------------------------- */
// Build Control Panel Menu
/* ----------------------------------------------------------- */

 function if_InitControlPanel() {
 
	var tableCode = '';
	tableCode += '<table width="100%" class="ForumsBackGroundTable" cellspacing="0" cellpadding="0">';
	tableCode += '<tr><td>'		
	tableCode += '<table width="100%" cellspacing="1" cellpadding="5">'
	tableCode += '<tr><td class="ForumsHeader">'
	tableCode += 'Control Panel</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="profile.aspx" class="smlLinks">Profile Summary</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumGroupHeader">'
	tableCode += 'Your Controls'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="customize.aspx" class="smlLinks">Forum Settings</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="privatemessages.aspx?Folder=InBox" class="smlLinks">Goto PM InBox</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="privatemessages.aspx?Folder=SentItems" class="smlLinks">Goto PM Sent Items</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="subscriptions.aspx" class="smlLinks">Topic Subscriptions</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="buddies.aspx" class="smlLinks">Buddies List</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="ignore.aspx" class="smlLinks">Ignore List</a>'
	tableCode += '</td></tr>'	
	tableCode += '<tr><td class="ForumGroupHeader">'
	tableCode += 'Your Profile'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="contact.aspx" class="smlLinks">Contact Information</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="personal.aspx" class="smlLinks">Personal Information</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="signature.aspx" class="smlLinks">Message Signature</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="avatar.aspx" class="smlLinks">Edit Avatar Image</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="photo.aspx" class="smlLinks">Edit Personal Photo</a>'
	tableCode += '</td></tr>'	
	tableCode += '<tr><td class="ForumsBody1">'
	tableCode += '<a href="logininfo.aspx" class="smlLinks">Registration Details</a>'
	tableCode += '</td></tr>'
	tableCode += '<tr><td class="ForumGroupHeader">'
	tableCode += '</table></td></tr>'
	tableCode += '</table>';			
	return tableCode;

}
/* ----------------------------------------------------------- */  
// Get top location of menu link to position menu
/* ----------------------------------------------------------- */

function if_getAbsoluteOffsetTop(obj) {

	var top = obj.offsetTop;
	var parent = obj.offsetParent;
	while (parent != document.body) {
	top += parent.offsetTop;
	parent = parent.offsetParent;	}
	return top;
	
}

/* ----------------------------------------------------------- */
// Get left location of menu link to position menu
/* ----------------------------------------------------------- */

function if_getAbsoluteOffsetLeft(obj) {

	var left = obj.offsetLeft;
	var parent = obj.offsetParent;
	while (parent != document.body) {
	left += parent.offsetLeft;
	parent = parent.offsetParent;	}
	return left;
	
}

/* ----------------------------------------------------------- */
// Toggle display of forum group					           
/* ----------------------------------------------------------- */

function if_toggleDisplay(objName, strStylePath)
{

	obj = if_returnObjRef("if_obj_Group_" + objName);
	img = if_returnObjRef("if_obj_Image_" + objName);
	gft = if_returnObjRef("if_obj_Footer_" + objName);
	
	if (obj.style.display == "none" || gft.style.display == "none")
	{
		obj.style.display = "";
		gft.style.display = "";
		img.src = strStylePath + "misc_collapse.gif"
		if_update_cookie(objName, false);

	}
	else
	{
		obj.style.display = "none";
		gft.style.display = "none";
		img.src = strStylePath + "misc_expand.gif"
		if_update_cookie(objName, true);
	
	}
	return false;
}

/* ----------------------------------------------------------- */
// Save snapshot of forum groups into cookie		           
/* ----------------------------------------------------------- */

function if_update_cookie(objName, bolSave)
{
	var ckName = "InstantForum_Groups";
	var ckColl = if_get_cookie(ckName);		
	var arrLocTemp = new Array();
	
	if (ckColl != null) // if cookie exists
	{
		arrColl = ckColl.split(","); // split cookie into array
		
		for (i in arrColl) // loop array
		{
			/* if item does not match objName or is blank */
			if (arrColl[i] != objName && arrColl[i] != "") 
			{
				arrLocTemp[arrLocTemp.length] = arrColl[i];
			}
		}
	}

	if (bolSave) // if item is expanded save groupid to array
	{
		arrLocTemp[arrLocTemp.length] = objName;
	}

	if_set_cookie(ckName, arrLocTemp.join(",")); // save cookie
}

/* ----------------------------------------------------------- */
// Standard Cookie Functions                       	           
/* ----------------------------------------------------------- */

function if_set_cookie(name, value)
{
	expire = " expires=Wed, 1 Jan 2020 00:00:00 GMT;";
	document.cookie = name + "=" + value + "; path=/;" + expire;
}

/* ----------------------------------------------------------- */

function if_get_cookie(name)
{
	ckName = name + '=';
	ckPos  = document.cookie.indexOf(ckName);
	
	if ( ckPos != -1 )
	{
		ckStart = ckPos + ckName.length;
		ckEnd   = document.cookie.indexOf(";", ckStart);
		
		if (ckEnd == -1)
		{
			ckEnd = document.cookie.length;
		}
		
		return unescape( document.cookie.substring(ckStart, ckEnd) );
	}
	
	return null;
}

//-->

