﻿/*  @ Title:  Javascript specific to the homepage
This was added after the updates sent by Ben Copping from Concep.
Refer to Issue#613835 on @task
*/

$(document).ready(function() {

    var hpHero = $('.hpHero').height() + 20;
    //console.log('hpHero',hpHero);

    var homeNewsArticle = $('.home-news-article').height();
    //console.log('home news article',homeNewsArticle)

    var setCol2Height = hpHero + homeNewsArticle
    //	console.log('setCol2Height', setCol2Height)

    var col2 = $('.col2').height();
    //	console.log('col2', col2)

    var newsList = $('.col1 .newsList').height();
    var articleFeature = $('.col1 .articleFeature .articleFeature').height();

    var nlContent = $('.col1 .nlContent').height();
    //	console.log('nlContent height', nlContent)

    var afContent = $('.col1 .afContent').height();
    //	console.log('afContent height', afContent)

    if (newsList > articleFeature) {
        $('.col1 .afContent').css({ 'height': afContent + newsList - articleFeature });
    }

    if (articleFeature > newsList) {
        $('.col1 .nlContent').css({ 'height': nlContent + articleFeature - newsList });
    }

    if (setCol2Height == 20) {
        return;
    }
    else if (setCol2Height > col2) {
        $('.col2').css({ 'height': setCol2Height });
        //		console.log('col1 is higher')
    }

    var balanceLeftCol = col2 - setCol2Height
    //	console.log('balanceLeftCol', balanceLeftCol)

    if (col2 > setCol2Height) {

        //	console.log('col 2 is higher');	

        $('.col1 .nlContent').css({ 'height': col2 - hpHero - newsList + nlContent -5});
        $('.col1 .afContent').css({ 'height': col2 - hpHero - articleFeature + afContent -5});

    }

});

