/*
	Javascritp for the most commonly used functions in forum
*/
var TimerId;
var ForumId;

function fjsReport(id, itemid, sTitle)
{
	if(id > 0 && itemid > 0)
	{
		var url = "forum/report.asp?id=" + id + "&itemId=" + itemid + "&strInfoId=" + sTitle;
		window.open(url, "Rapporter", "width=440,height=280,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes")				
	}
}
function fjsSetFrameHeight(iHeight)
{
	document.getElementById("ForumLogin").style.height = iHeight + "px";
}
/*
	this function is called by the ifram that generates the list of forum-entries
	It clears the div-element and copies the content from the iframe-node.
*/
function fjsAddForumEntries(node, id)
{
	TimerId = 0;
	ForumId = id;
	var objDiv = document.getElementById('ForumEntries');		
	if(document.importNode)
	{
		var nodeX = document.importNode(node, true);			
	}
	else{
		var nodeX = document._importNode(node, true);
	}	
	if(document.getElementById('ForumEntries')){
		
		while(objDiv.firstChild){
			objDiv.removeChild(objDiv.firstChild);
		}			
		objDiv.appendChild(nodeX);			
	}
	TimerId = setTimeout("fjsTimedCount()", 20000);
}
function fjsTimedCount()
{
	document.getElementById("ForumFrame").src = "forum/iframe_forum_list.asp?iItemId=" + ForumId;	
	clearTimeout(TimerId);
	TimerId = setTimeout("fjsTimedCount()", 20000);
}

function fjsReloadForum(itemid)
{	
	document.getElementById("ForumFrame").src = "forum/iframe_forum_list.asp?iItemId=" + itemid;
}
function fjsUpdateForum(link)
{	
	document.getElementById("ForumFrame").src = link;
}

if(!document.importNode)
{
	document._importNode = function(oNode, bImportChildren)
	{
		var oNew;
        var attr;
        
		if(oNode.nodeType == 1){
			oNew = document.createElement(oNode.nodeName);
			/*
			for(var i = 0; i < oNode.attributes.length; i++){
				oNew.setAttribute(oNode.attributes[i].name, oNode.attributes[i].value);
			}
			*/
			for (var i = 0; i < oNode.attributes.length; i++)
            {
                attr = oNode.attributes[i];
                if (attr.nodeValue != null && attr.nodeValue != '')
                {
                    //oNew.setAttribute(attr.name, attr.nodeValue);
                    fjsToolBox_setAttribute(oNew, attr.name, attr.nodeValue);
                }
            }
			oNew.style.cssText = oNode.style.cssText;
		} else if(oNode.nodeType == 3){
			oNew = document.createTextNode(oNode.nodeValue);
		}
    	
		if(bImportChildren && oNode.hasChildNodes()){
			for(var oChild = oNode.firstChild; oChild; oChild = oChild.nextSibling){
				oNew.appendChild(document._importNode(oChild, true));
			}
		}
		        	
		return oNew;
	}
}