function SetWebContentHeight()
{
    var leftblockHeight = 0;
    if ( document.getElementById("leftblockdiv") != null )
    {
		leftblockHeight = document.getElementById("leftblockdiv").offsetHeight;
	}
	
    var rightblockHeight = 0;
    if ( document.getElementById("rightblockdiv") != null )
    {
		rightblockHeight = document.getElementById("rightblockdiv").offsetHeight;
	}
    
    var pagecontainerHeight = document.getElementById("pagecontainerdiv").offsetHeight;
		
    var highest = Math.max( Math.max( leftblockHeight, rightblockHeight), pagecontainerHeight );
    //var pagefooter = document.getElementById("pagefooterinnerdiv")
    var pagefooterOffset = 0;
    //if ( pagefooter == null )
    //{
	//	pagefooterOffset = -20;
	//}
	
	if ( leftblockHeight > 0 )
	{
		document.getElementById("leftblockdiv").style.height = String(highest + pagefooterOffset) + "px";
	}
	
	if ( rightblockHeight > 0 )
	{	
		document.getElementById("rightblockdiv").style.height = String(highest + pagefooterOffset) + "px";
	}
    
    // This is for the vertical line in left block edge
    if ( leftblockHeight > 0 )
	{
		document.getElementById("leftblockinnerdiv").style.height = String(highest + pagefooterOffset) + "px";
	}
    
    // This is for the vertical line in right block edge
    if ( rightblockHeight > 0 )
	{
		var rightblockboxesdiv = document.getElementById("rightblockboxesdiv").offsetHeight;
		var rightblock_shortcutsdiv = document.getElementById("rightblock_shortcutsdiv");
		if ( rightblock_shortcutsdiv != null )
			var new_rightblockboxesdiv = highest - rightblock_shortcutsdiv.offsetHeight;
		else
			var new_rightblockboxesdiv = highest;

		document.getElementById("rightblockboxesdiv").style.height = String(new_rightblockboxesdiv + pagefooterOffset) + "px";
	}
}

function SetTargets(strText)
{
	var elements = document.body.getElementsByTagName("a");
	for (x = 0; x < elements.length; x++)
	{
		if (elements[x].target == "_blank")
		{
			elements[x].title = elements[x].title + strText;
		}
	}
}

function printPage() 
{
	var da = (document.all) ? 1 : 0;
    var pr = (window.print) ? 1 : 0;
    
    if(!pr)
	    return;

    var printArea = document.getElementById("pagediv");
	
    if(printArea == null && da) 
	    printArea = document.all.pagediv;
	
    if(printArea) 
    {
		var sStart = "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"<%=Configuration.RootDir%>lerum_styles/structure.css\"><link rel=\"stylesheet\" type=\"text/css\" href=\"<%=Configuration.RootDir%>lerum_styles/editor.css\"><link rel=\"stylesheet\" type=\"text/css\" href=\"<%=Configuration.RootDir%>lerum_styles/units.css\"><link rel=\"stylesheet\" type=\"text/css\" href=\"<%=Configuration.RootDir%>lerum_styles/print.css\"><style type='text/css' media='print'>.noPrint {display:none;}</style></head><body onload=\"javascript:window.print();\">";
		var sStop = "</body></html>";
	    var sCloseLink = "<table class='noPrint' border='0' cellspacing='5' cellpadding='5' width='100%'><tr><td align='right'><a href='#' class='normal' onclick='window.close();'>Stäng</a></td></tr></table>";
	
	    var w = window.open('about:blank','printWin','width=650,height=440,scrollbars=yes');
	
	    wdoc = w.document;
	    wdoc.open();
	
	    wdoc.write( sStart + sCloseLink + printArea.innerHTML ) ;
	
	    wdoc.writeln( sStop );
	    wdoc.close();
    }
}

/*
strPage: The EpiServer page that sent the request to open this window 
strReceiver: The name of the receiver
strToType: 
	"group": If it is a groupmail defined in dynamic properties in Epi
	"person": If the email address should be received from Mark´s AD (via Radius)
*/
function contact(strPageID, strTo, strEmail, strToType) 
{
	var page = "/lerum_templates/Contact.aspx?pageid=" + strPageID + "&to=" + strTo + "&toType=" + strToType + "&epslanguage=" + '<%=CurrentPage["PageLanguageID"].ToString()%>';
	
	if ( strEmail != "" )
	{
		page = page + "&toemail=" + strEmail;
	}
	
	window.open(page, "Contact", "width=400,height=400,scrollbars=no,resizable=yes");
}

function openHelpWindow(file) 
{
	window.open(file,'','scrollbars=yes,menubar=no,height=600,width=500,resizable=yes,toolbar=no,location=no,status=no');
}

function ToggleItem( elementID )
{
    var element = document.getElementById( elementID );
    
    if ( element.style.display == 'none' )
        element.style.display = '';
    else
        element.style.display = 'none'
        
    // Img arrows
    var elementImgDown = document.getElementById( 'IMGARROWDOWN' + elementID );
    var elementImgRight = document.getElementById( 'IMGARROWRIGHT' + elementID );
    
    if (elementImgDown != null)
    {
        elementImgDown.style.display = element.style.display;
    }
    
    if (elementImgRight != null)
    {
        if ( element.style.display == 'none' )
            elementImgRight.style.display = '';
        else
            elementImgRight.style.display = 'none'
        
    }
}

