﻿// This code corrects the CSS layout if a video clip is present

// Check for IE6 where the offset height doesn't include the margin
var IE = ((navigator.appVersion.indexOf("MSIE6") != -1) && !window.opera) ? true : false; 

var subpages = document.getElementById('subpages');
var images = document.getElementById('images');
var attachments = document.getElementById('attachments');

var totalheight = 0;

if(subpages)
    totalheight += (!IE) ? subpages.offsetHeight : parseInt(subpages.offsetHeight) + parseInt(subpages.style.marginTop);

if(images) 
    totalheight += (!IE) ? images.offsetHeight : parseInt(images.offsetHeight) + parseInt(images.style.marginTop);

if(attachments) 
    totalheight += (!IE) ? attachments.offsetHeight : parseInt(attachments.offsetHeight) + parseInt(attachments.style.marginTop);

// If the height of everything on the right exceeds the
// video height, swap the margins
if(totalheight > 238)
{
    document.getElementById('video').style.marginRight = '0';
    
    if(subpages) subpages.style.marginLeft = '20px';
    if(images) images.style.marginLeft = '20px';
    if(attachments) attachments.style.marginLeft = '20px';
}