<!--

/*======================================================================/*
// InstantForum.NET	© 2005 InstantASP Limited.							//
// http://www.instantasp.co.uk/											//
\*======================================================================*/

/* ----------------------------------------------------------- */
// Ensure browser is always aware of current page, this overcomes
// a problem with using URLRewrite and us overriding the action 
// attribute of the form tag when using __doPostBack
/* ----------------------------------------------------------- */

//var loc = '' + this.location;
//if (loc.toLowerCase().indexOf(".aspx") == -1) 
//{window.location = 'Default.aspx';}

/* ----------------------------------------------------------- */
// Initialize any menu constants					   
/* ----------------------------------------------------------- */

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;
var WinNum = 0; // init windows number

/* ----------------------------------------------------------- */
// Get browser information
/* ----------------------------------------------------------- */

var if_userAgent = navigator.userAgent.toLowerCase();
var opera = (if_userAgent.indexOf('opera') != -1); // is opera
var opera8 = ((if_userAgent.indexOf('opera 8') != -1 || if_userAgent.indexOf('opera/8') != -1) ? 1 : 0); // is opera8
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-up document event handlers									   
/* ----------------------------------------------------------- */

if (ie4 || ie5 || opera) {
	document.onclick = if_hideAllMenusOnClick;
	document.onscroll = if_hideAllMenusOnClick;
	window.onresize = if_winResize;
}    
else if (ns6) { 
	document.addEventListener("mousedown", if_hideAllMenusOnClick, true);
	window.addEventListener("onresize", if_winResize, true);
} 
else if (ns4) {
	document.onmousedown = if_hideAllMenusOnClick;
	window.captureEvents(Event.MOUSEMOVE);
}

/* ----------------------------------------------------------- */
// Pre-load drop down menu images so they display correctly					   
/* ----------------------------------------------------------- */

function if_PreloadImages(CurrentSkin) {
	if (document.images)
	{
		arImageList = new Array ();
		var arImageSrc = new Array(CurrentSkin + "Images/Misc_Rating1.gif",
		CurrentSkin + "Images/Misc_Rating2.gif",
		CurrentSkin + "Images/Misc_Rating3.gif",
		CurrentSkin + "Images/Misc_Rating4.gif",
		CurrentSkin + "Images/Misc_Rating5.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Bold.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Bullets.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Center.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Fontcolor.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_FontcolorPrompt.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Grab.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Highlight.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_HighlightPrompt.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Indent.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_InsertImg.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Italics.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Justify.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Left.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Link.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_NumList.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Quote.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Right.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Sep.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Strike.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Subscript.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Superscript.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Toolsep.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Underline.gif",
		CurrentSkin + "Images/RichTextBoxIcons/mnu_Unindent.gif",
		CurrentSkin + "Images/RichTextBoxIcons/tab_Edit_Off.gif",
		CurrentSkin + "Images/RichTextBoxIcons/tab_Edit_On.gif",
		CurrentSkin + "Images/RichTextBoxIcons/tab_Html_Off.gif",
		CurrentSkin + "Images/RichTextBoxIcons/tab_Html_On.gif");
			
		for (counter in arImageSrc) {
			arImageList[counter] = new Image();
			arImageList[counter].src = arImageSrc[counter];
		}
	}    
}

/* ----------------------------------------------------------- */
// Determine what object model we should use                   
/* ----------------------------------------------------------- */

function if_returnObjRef(objName) {

	var objReturn = '';
		if (ie5 || ns6 || opera)
		{
			objReturn = document.getElementById(objName);
		}
		else if (ie4)
		{
			objReturn = document.all[objName];
		}
		else if (ns4)
		{
			objReturn = document.layers[objName];
		}

	return objReturn

}

/* ----------------------------------------------------------- */
// Open Menu on MouseOver Event
/* ----------------------------------------------------------- */

function if_openMenuMouseOver(Caller, DivLayer, InnerHTML, Width) {

	if (mnu_active) {if_openMenu(Caller, DivLayer, InnerHTML, Width);}
		
}

/* ----------------------------------------------------------- */
// Open Menu on MouseClick Event
/* ----------------------------------------------------------- */

function if_openMenu(Caller, DivLayer, InnerHTML, Width) {
		
		// create unique identity for generated div layer
		DivLayer = DivLayer + "_" + Caller
		
		// create iframe to hold menu, this ensures we render over dropdownlists
		var Iframe = DivLayer + "_Iframe"
		
		// 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] == DivLayer) {
				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] = DivLayer;
		mnu_active = true;
		
		// create the div layer container for this menu
		if_setDiv(InnerHTML, DivLayer, Iframe, Width);
     	
     	// get object references to div layer and div_layer that called this function
		var div_layer = if_returnObjRef(DivLayer);
     	var div_layerIframe = if_returnObjRef(Iframe);
     	var div_layer_caller = if_returnObjRef(Caller);
     	 	
         // set default offset for div layer from the caller div
     	var offsetTopDefault; offsetTopDefault = div_layer_caller.offsetHeight + 4;
		          	 	
		// position div layer relative to the opening link  
		var top = if_getAbsoluteOffsetTop(div_layer_caller) + offsetTopDefault;
		var left = if_getAbsoluteOffsetLeft(div_layer_caller); 

		// set position of controls
     	div_layer.style.top = top;
     	div_layer.style.left = left;
     	div_layerIframe.style.top = top;
     	div_layerIframe.style.left = left;
     	   	
       	//  calculate left and top positions of current 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);
		}
		
		// calculate right and bottom positions of current div layer
		mnu_right = parseInt(mnu_left) + parseInt(mnu_extent.x);			
		mnu_bottom = parseInt(mnu_top) + parseInt(mnu_extent.y);
		
		// now ensure Iframe sits tidy behind Div
		div_layerIframe.style.height = (mnu_bottom - mnu_top);
			    	
		// 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 - Width - 10;
				div_layerIframe.style.left = win_width - Width - 10;
			}
		}
				
		// finally display the menu		
		// if this is not IE we don't need to display the Iframe
		if ((ie4 || ie5 && !opera)) {div_layerIframe.style.display = "";}
		div_layer.style.display = "";
		
}


/* ----------------------------------------------------------- */
// Create div layer to hold menu
/* ----------------------------------------------------------- */

function if_setDiv(InnerHTML, DivLayer, Iframe, mnu_width) {     

	// create iframe to hold div later
    var frameDiv = document.createElement('iframe');     	
    frameDiv.id = Iframe;
    frameDiv.setAttribute('class','');
    frameDiv.setAttribute('src','blank.htm');
    frameDiv.style.position = 'absolute';
    frameDiv.style.zindex = 1;
    frameDiv.style.width = mnu_width;
    
	// create div layer container to holder table
    var elemDiv = document.createElement('div');     	
    elemDiv.id = DivLayer;
    elemDiv.setAttribute('class','');
    elemDiv.style.position = 'absolute';       
    elemDiv.style.zindex = 50;
	elemDiv.style.width = mnu_width;
	  
	// deteremine what table to apply as the innerHTML of the div layer container
	elemDiv.innerHTML = InnerHTML;
	
	// add elements to document
	document.body.appendChild(frameDiv);   
	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 
	frameDiv.style.display = "none";			
	elemDiv.style.display = "none";
		
}

/* ----------------------------------------------------------- */
// 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) {	
		for (count = 0; count < mnu_items.length; count++)	{
			var div_layer = if_returnObjRef(mnu_items[count]);
			var iframe_layer = if_returnObjRef(mnu_items[count] + "_Iframe");
			if (div_layer != null && iframe_layer != null)	{
				iframe_layer.style.display = 'none';
				div_layer.style.display = 'none';
				mnu_items[count] = '';
				mnu_active = false;
			}
		}			
	}
		
}

/* ----------------------------------------------------------- */  
// 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 - 7;
	
}

/* ----------------------------------------------------------- */
// Toggles and objects visibliity
/* ----------------------------------------------------------- */

function if_ToggleVisability(obj, visible) {

	obj = if_returnObjRef(obj);
	if (visible) {obj.style.display = "";}
	else {obj.style.display = "none";}
		
}

/* ----------------------------------------------------------- */
// 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;
}

/* ----------------------------------------------------------- */
// 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;	
}

/* ----------------------------------------------------------- */
// This funtion removes any trialing anchor points within a string
/* ----------------------------------------------------------- */

function if_removeBookmark(strInput) {
	var uri = new String(strInput)
	var strOutput; var intPos = uri.indexOf('#');
	if (intPos > 0) {strOutput = uri.substring(0, intPos);}
	else {strOutput = uri;} return strOutput;
}

/* ----------------------------------------------------------- */
// This funtion removes any querystring from a string
/* ----------------------------------------------------------- */

function if_removeQueryString(strInput) {
	var uri = new String(strInput)
	var strOutput; var intPos = uri.indexOf('?');
	if (intPos > 0) {strOutput = uri.substring(0, intPos);}
	else {strOutput = uri;} return strOutput;
}

/* ----------------------------------------------------------- */
// This funtion expands and collapses a group of panel bars
/* ----------------------------------------------------------- */

function if_ExpandPanelBars(objName, bolState, strSkin) {

	if (ie4 || ie5 || opera || ns6)	{
	
		// toggle all table rows matching object name
		tr = document.getElementsByTagName("tr");
		for (var i = 0; i < tr.length; i++)
		{ 
			if (tr[i].id.indexOf(objName) >= 0) {
				if (bolState) 
					{tr[i].style.display = "";}
					else
					{tr[i].style.display = "none";}
			}
		
		}
		
		// toggle all tables matching object name
		table = document.getElementsByTagName("table");
		for (var i = 0; i < table.length; i++)
		{ 
			if (table[i].id.indexOf(objName) >= 0) {
				if (bolState) 
					{table[i].style.display = "";}
					else
					{table[i].style.display = "none";}
			}
		
		}
		
		// change all images matching object name
		input = document.getElementsByTagName("img");
		for (var i = 0; i < input.length; i++)
		{ 
			if (input[i].id.indexOf(objName) >= 0) {
				if (bolState) 
					{input[i].src = strSkin + "Images/Misc_Collapse.gif";}
					else
					{input[i].src = strSkin + "Images/Misc_Expand.gif";}
			}
		}
	}
}

/* ----------------------------------------------------------- */
// Inserts IFCode into the target textbox control
/* ----------------------------------------------------------- */

function if_InsertIFCode(startTag, middleTag, endTag, objTextBox) {

	if (ns4)	{
	
		objTextBox.value += startTag + middleTag + endTag;
		
	} else if (opera || opera8) {
	
		if (opera8) {
		
			objTextBox.focus();	var txt;
			var s = objTextBox.document.selection;
			if (s.type == "Text" || s.type == "None")	{
				var r = s.createRange(); r.colapse; 
				if (r.text.length > 0) {txt = startTag + r.text + endTag;}
				else {txt = startTag + middleTag + endTag;}
				r.text = txt;
				r.moveEnd("character", - (endTag.length));
				r.select();
			} else {alert(if_WYSIWYGPrompt);}
		}
		
		else {objTextBox.value += startTag + middleTag + endTag;}
	
	} else if (ie4 || ie5) {
	
		var s; objTextBox.focus();
		if (objTextBox.type != null) // we are working with the textarea
			{s = objTextBox.document.selection;}
			else // we are working with the iframe
			{objTextBox.focus(); 
			s = objTextBox.document.selection;}
		if (s.type == "Text" || s.type == "None")	{
			var txt; var r = s.createRange(); r.colapse;
			if (r.text.length > 0) 
				{txt = startTag + r.text + endTag;}
			else 
				{txt = startTag + middleTag + endTag;}
			if (r.parentElement().isMultiLine && r.parentElement().isContentEditable || objTextBox.type == "textarea") {	
				r.text = txt;
				r.moveEnd("character", - (endTag.length));
				r.select();
			}
		} else {alert(if_WYSIWYGPrompt);}
				        
	} else if (ns6) {
	
		if (objTextBox.selectionEnd) {
		
			var charPos; var charMiddle;
			var selStart = objTextBox.selectionStart;
			var selEnd = objTextBox.selectionEnd; if (selEnd <= 2) {selEnd = objTextBox.textLength;}
			var charStart = objTextBox.value.substring(0, selStart);
			var charEnd = objTextBox.value.substring(selEnd, objTextBox.textLength);
			
			// do we have a selection
			if (selStart != selEnd) {
				charMiddle = objTextBox.value.substring(selStart, selEnd);
				objTextBox.value = charStart + startTag + charMiddle + endTag + charEnd;
				charPos = selStart + (startTag.length + charMiddle.length);} 
			else {
				objTextBox.value = charStart + startTag + middleTag + endTag + charEnd;
				charPos = selStart + (startTag.length + middleTag.length);
			}
		
			objTextBox.selectionStart = charPos;
			objTextBox.selectionEnd = charPos;
			
	} else {
			objTextBox.value += startTag + middleTag + endTag;
			objTextBox.selectionStart = (startTag.length + middleTag.length);
			objTextBox.selectionEnd = (startTag.length + middleTag.length);
		}
		
	} 
	
	objTextBox.focus();
	
}

/* ----------------------------------------------------------- */
// This function handles a window resize to ensure menus display correctly
/* ----------------------------------------------------------- */

function if_winResize() {

	if_hideAllMenus();

}

/* ----------------------------------------------------------- */
// This function handles a selectedIndex changed events for the 
// forum jump drop down list
/* ----------------------------------------------------------- */

function if_ForumJump(location) {

	// ensure we have a URL
	if (location != "" && location != null)
	{window.location = location;}

}

/* ----------------------------------------------------------- */
// Opens a window within the forums. Used for printtopic.aspx
/* ----------------------------------------------------------- */

function if_wOpen(Url, Width, Height, Scroll, ToolBar, Location, Status, MenuBar, Resizeable, Unique) {	
	var String;
	var winName = Width.toString() + Height.toString()
   	String =  "toolbar=" + ToolBar + ",location=" + Location 
   	String += ", directories=0,status=" + Status + ",menubar=" + MenuBar + ","
	String += "scrollbars=" + Scroll + ",resizable=" + Resizeable + ",copyhistory=0,";
   	String += ",width=";
   	String += Width;
   	String += ",height=";
   	String += Height;
   	
   	// should we center popup window
   	if (ie4 || ie5 || opera || ns6)	{
	WndTop  = (screen.height - Height) / 2;
	WndLeft = (screen.width  - Width)  / 2;
	String += ",top=";
   	String += WndTop;
   	String += ",left=";
   	String += WndLeft;}
   	
   	// should we display single popup or allow multiple
   	try {
   		if (Unique == true) {WinPic = window.open(Url,WinNum++,String);}
   		else {WinPic = window.open(Url,winName,String);WinPic.focus();}}
   	catch (e) {};
}

/* ----------------------------------------------------------- */
// Forum logout confirmation alert
/* ----------------------------------------------------------- */

function if_logOut() {

	if (ie4 || ie5 || opera || ns6)	{
		ht = document.getElementsByTagName("body");
		ht[0].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=55)";
		if (confirm(if_strLogoutAlertText)) {return true;}
		else {ht[0].style.filter = ""; return false;}
	}
	else {
		if (confirm(if_strLogoutAlertText)) {return true;}
		else {return false;}
	}
	
}

/* ----------------------------------------------------------- */
// EmotIcons Functions
/* ----------------------------------------------------------- */

function if_InsertEmotIconPopup(uri, ControlID) {
	if_wOpen(uri+"?ControlID="+ControlID,250,500,1,0,0,0,0,1,false);
}

/* ----------------------------------------------------------- */
// Insert IFCode from Model Dialog Window
/* ----------------------------------------------------------- */

function if_InsertIFCodePopup(uri, ControlID) {
	if_wOpen(uri+"?ControlID="+ControlID,535,500,1,0,0,0,0,1,false);
}

/* ----------------------------------------------------------- */
// Attachment Functions
/* ----------------------------------------------------------- */

function if_EditAttachments(uri) {				
	if_wOpen(uri,525,375,1,0,0,0,0,1,false);
}

/* ----------------------------------------------------------- */
// User Detail Functions
/* ----------------------------------------------------------- */

function if_UserDetail(uri) {				
	if_wOpen(uri,525,375,1,0,0,0,0,1,false);
}

/* ----------------------------------------------------------- */
// Attachment Functions
/* ----------------------------------------------------------- */

function if_PrintTopic(uri) {	
	var WinNum = 1;
	window.open(uri,WinNum++);
}


/* ----------------------------------------------------------- */
// Prompt to grab direct link to post
/* ----------------------------------------------------------- */

function if_PostLink(uri) {
	var link = if_removeQueryString(uri);
	var linkDialog = prompt(if_linkPrompt,link); 
}

/* ----------------------------------------------------------- */
// Prompt displayed with unread private messages
/* ----------------------------------------------------------- */

function if_UnreadPrivateMessagePrompt(uri) {
	if (confirm(if_UnreadPrivateMessages))
	{location = uri;} else {return false;}
}

//-->

