//------------------------------------
// Main Menu functions
//------------------------------------

function MainMenuOver1(aobject, linkcolor, bgcolor)
{			
	//
	// Set id
	//
	element = aobject.id.substring (0, aobject.id.length - 7);

	//
	// Set background
	//
	aobject.style.backgroundColor = bgcolor;
	aobject.style.cursor = "hand";
	
	//
	// Set link color
	//
	document.all.item(element + "_span").style.color = linkcolor;
}

function MainMenuOut1 (aobject, linkcolor, bgcolor)
{
	//
	// Get Element
	//
	element = aobject.id.substring (0, aobject.id.length - 7);			

	aobject.style.backgroundColor = bgcolor;

	//
	// Set link color
	//
	document.all.item(element + "_span").style.color = linkcolor;
}

// ----------------------------------------------------------------
// comment functions
// ----------------------------------------------------------------

function ToggleCommentEntry (id)
{
	if (document.all["CommentDiv_" + id].style.display == 'none')
	{
		document.all["CommentImg" + id].src = "/mtw2/images/symbols/collapse.gif";
		document.all["CommentDiv_" + id].style.display = "inline";
		document.all["CommentImg" + id].alt = "Hier klicken um diesen Beitrag anzuzeigen";
	}
	else
	{
		document.all["CommentImg" + id].src = "/mtw2/images/symbols/expand.gif";
		document.all["CommentDiv_" + id].style.display = "none";
		document.all["CommentImg" + id].alt = "Hier klicken um diesen Beitrag zu verstecken";
	}
}

function TogglePostingEntry (id)
{
	if (document.all["PostingDiv_" + id].style.display == 'none')
	{
		document.all["PostingImg_" + id].src = "/mtw2/images/symbols/collapse.gif";
		document.all["PostingDiv_" + id].style.display = "inline";
		document.all["PostingImg_" + id].alt = "Hier klicken um diesen Beitrag anzuzeigen";
	}
	else
	{
		document.all["PostingImg_" + id].src = "/mtw2/images/symbols/expand.gif";
		document.all["PostingDiv_" + id].style.display = "none";
		document.all["PostingImg_" + id].alt = "Hier klicken um diesen Beitrag zu verstecken";
	}
}

function ToggleFrontNews (id)
{
	if (document.all.item ("FrontNewsRow_" + id).style.display == 'none')
	{
		document.all.item("FrontNewsImg_" + id).src = "/mtw2/images/symbols/collapse.gif";
		document.all.item("FrontNewsRow_" + id).style.display = "inline";
		document.all.item("FrontNewsImg_" + id).alt = "Hier klicken um die weiteren Infos Beitrag anzuzeigen";
	}
	else
	{
		document.all["FrontNewsImg_" + id].src = "/mtw2/images/symbols/expand.gif";
		document.all["FrontNewsRow_" + id].style.display = "none";
		document.all["FrontNewsImg_" + id].alt = "Hier klicken um die weiteren Infos zu verstecken";
	}
}

function ToggleCompleteNews (id)
{
	if (document.all["newsrow1_" + id].style.display == 'none')
	{
		document.all["CompleteNewsImg_" + id].src = "/mtw2/images/symbols/collapse.gif";
		document.all["CompleteNewsImg_" + id].alt = "Hier klicken um die volle News anzuzeigen";	
	
		document.all["newsrow1_" + id].style.display = "inline";
		document.all["newsrow2_" + id].style.display = "inline";
		document.all["newsrow3_" + id].style.display = "inline";

		if (document.all.item("newsrow4_" + id) != null)
		{
			document.all["newsrow4_" + id].style.display = "inline";
		}
		
		if (document.all.item("newsrow5_" + id) != null)
		{
			document.all["newsrow5_" + id].style.display = "inline";
			document.all["newsrow6_" + id].style.display = "inline";
		}
	}
	else
	{
		document.all["CompleteNewsImg_" + id].src = "/mtw2/images/symbols/expand.gif";
		document.all["CompleteNewsImg_" + id].alt = "Hier klicken um nur den Titel anzuzeigen";
		
		document.all["newsrow1_" + id].style.display = "none";
		document.all["newsrow2_" + id].style.display = "none";
		document.all["newsrow3_" + id].style.display = "none";

		if (document.all.item("newsrow4_" + id) != null)
		{
			document.all["newsrow4_" + id].style.display = "none";
		}
		
		if (document.all.item("newsrow5_" + id) != null)
		{
			document.all["newsrow5_" + id].style.display = "none";
			document.all["newsrow6_" + id].style.display = "none";
		}
	}
}

function TogglePostingPane (id)
{
	if (document.all["PostingPaneTable_" + id].style.display == 'none')
	{
		document.all["PostingPaneImg_" + id].src = "/mtw2/images/symbols/collapse.gif";
		document.all["PostingPaneTable_" + id].style.display = "inline";
		document.all["PostingPaneImg_" + id].alt = "Hier klicken um die weiteren Infos ueber den Autor zu verstecken";
	}
	else
	{
		document.all["PostingPaneImg_" + id].src = "/mtw2/images/symbols/expand.gif";
		document.all["PostingPaneTable_" + id].style.display = "none";
		document.all["PostingPaneImg_" + id].alt = "Hier klicken um die weiteren Infos ueber den Autor anzuzeigen";
	}
}


function CommentPopup(url, height, comment_id, returnurl, type_id, type, comment_itemsperpage, comment_page)
{
	commentwindow = window.open('' + url + '?comment_id=' + comment_id + '&returnurl=' + returnurl + '&type_id=' + type_id + '&type=' + type + '&comment_itemsperpage=' + comment_itemsperpage + '&comment_page=' + comment_page +  '','commentwindow','toolbar=no, location=no, scrollbars=1, width=535, height=' + height + ', left=100, top=100, alwaysRaised=true');
	commentwindow.focus();
	
	if (commentwindow.opener == null)
	{
		commentwindow.opener = self;
	}
}

function boardjump()
{
	if(document.jumpform.board_id.options[document.jumpform.board_id.selectedIndex].value != -1) 
	{
		document.jumpform.submit();
	}
}

function ClearSearchBox ()
{
}

// ------------------------------------------------------------------
// forum functions
// ------------------------------------------------------------------
function ToggleForumCategory (id)
{
	if (document.all["ForumCategoryImg_" + id].src.indexOf ("/mtw2/images/symbols/expand.gif") > 0)
	{
		document.all["ForumCategoryImg_" + id].src = "/mtw2/images/symbols/collapse.gif";
		document.all["ForumCategoryImg_" + id].alt = "Hier klicken um diese Forum-Kategory anzuzeigen";

		//
		// hide all boards which belong to that forum
		//
		var items = this.document.all.tags("TR")

		for(i = 0; i < items.length; i++)
		{
			if (items(i).id.indexOf ('row_' + id) == 0)
			{
				items(i).style.display = 'inline';
			}
		}
	}
	else
	{
		document.all["ForumCategoryImg_" + id].src = "/mtw2/images/symbols/expand.gif";
		document.all["ForumCategoryImg_" + id].alt = "Hier klicken um diese Forum-Kategory zu verstecken";

		//
		// hide all boards which belong to that forum
		//
		var items = this.document.all.tags("TR")

		for(i = 0; i < items.length; i++)
		{
			if (items(i).id.indexOf ('row_' + id) == 0)
			{
				items(i).style.display = 'none';
			}
		}
	}
}


// --------------------------------------------------------------
// helper functions
// --------------------------------------------------------------
function PreviewPopup(url, width, height, input)
{
	previewwindow = window.open('' + url + '?&input=' + input + '','previewwindow','toolbar=no, location=no, scrollbars=1, width=' + width + ', height=' + height + ', left=100, top=100, alwaysRaised=true');
	previewwindow.focus();
	
	if (previewwindow.opener == null) 
		previewwindow.opener = self;
}

function CommonPopup(url, width, height, wndname)
{
	wnd = window.open(url, wndname,'toolbar=no, location=no, scrollbars=1, width=' + width + ', height=' + height + ', left=100, top=100, alwaysRaised=true');
	wnd.focus();
	
	if (wnd.opener == null)
	{ 
		wnd.opener = self;
	}
}

// 
// gets the value of an querystring variable
// 
function retVal(sName)
{
	/*
	get last loc. of ?
	right: find first loc. of sName
	+2
	retrieve value before next &
	*/
  
	var sURL	  = new String(window.location);
	var iQMark    = sURL.lastIndexOf('?');
	var iLensName = sName.length;

	//retrieve loc. of sName
	var iStart = sURL.indexOf('?' + sName + '='); //limitation 1
	
	if (iStart == -1)
	{
		//not found at start
		iStart = sURL.indexOf('&' + sName + '='); //limitation 1
		
		if (iStart == -1)
		{
			//not found at end
			return 0;
		}   
	}
	    
	iStart = iStart + iLensName + 2;
	
	var iTemp = sURL.indexOf('&', iStart); //next pair start
	
	if (iTemp ==-1)
	{
		//EOF
		iTemp = sURL.length;
	}  
	
	return sURL.slice(iStart, iTemp) ;
	
	sURL = null;
}