	
	banner_debug_mode = false;

    function display_top_banner ( ) {
        dhtmlLoadScript ( populate_top_banner ( ) );
    }

    function display_side_banners ( param_languages, param_sectors, param_locations ) {
        var totalHeight     = calculate_contentHeight ( );
        var bannerHeight    = 53;
        dhtmlLoadScript ( populate_side_banners ( totalHeight, bannerHeight, param_languages, param_sectors, param_locations ) );
    }

	function calculate_contentHeight ( ) {
		var obj_featRecruits = document.getElementById ( "FeaturedRecruiters" );
		var obj_contentLeft = document.getElementById ( "contentleft" );
		var obj_contentCenter = document.getElementById ( "contentcenter" );
		var obj_opinionPoll = document.getElementById ( "miniPoll" );
		
		// get the height of the three columns
		var int_contentLeftHeight = obj_contentLeft.offsetHeight;
		var int_contentCenterHeight = obj_contentCenter.offsetHeight;
		var int_contentBannersHeight = obj_featRecruits.offsetHeight;
		
		if ( int_contentBannersHeight >= int_contentLeftHeight && int_contentBannersHeight >= int_contentCenterHeight ) {
			// The banners are the longest side, so do nothing
			if ( true === banner_debug_mode ) {
				alert ( "BannerLoader: Banners are the longest column, so I will not proceed to do anything" );
			}
			return;
		}
		
		var int_highestVal = int_contentCenterHeight;
		if ( int_contentLeftHeight > int_contentCenterHeight ) {
			// Left menu bar is the longest column on page, so use that as the max height
			if ( true === banner_debug_mode ) {
				alert ( "BannerLoader: The menu bar is the longest column, so use that height to determine the offset for the banners, instead of the center content" );
			}
			int_highestVal = int_contentLeftHeight;
		}
		
		// Check if opinion poll exists at all and deduct height
		var int_deductHeight = 0;
		if ( obj_opinionPoll ) {
			if ( true === banner_debug_mode ) {
				alert ( "BannerLoader: Deduct the opinion poll height from our calculation" );
			}
			int_deductHeight = obj_opinionPoll.offsetHeight;
		}
		
		var tmp_result_val = (int_highestVal - int_deductHeight);
		obj_featRecruits.style.height = 'auto';
		return (tmp_result_val!=0)?tmp_result_val:false;
	}
	
	function get_height_of_banner_item ( ) {
		var obj_featRecruits = document.getElementById ( "FeaturedRecruiters" );
		var dont_check_anylonger = false;
		var the_height = 0;
		for( var x = 0; x < obj_featRecruits.childNodes.length && false === dont_check_anylonger; x++ ) {
			if( obj_featRecruits.childNodes[x].nodeName.toLowerCase() == 'ul' ) {
				dont_check_anylonger = true;
				for( var y = 0; y < obj_featRecruits.childNodes[x].childNodes.length; y++ ) {
					if( obj_featRecruits.childNodes[x].childNodes[y].nodeName.toLowerCase() == 'li' ) {
						the_height = obj_featRecruits.childNodes[x].childNodes[y].offsetHeight;
						break;
					}
				}
			}
		}
		return (the_height!=0)?the_height:false;
	}
	
	function populate_side_banners ( param_totalHeight, param_eachHeight, param_languages, param_sectors, param_locations ) {
        // 25 is to account for height of the title
		var amount = Math.floor ( ( ( param_totalHeight - 25 ) / param_eachHeight ) ); // calculate how many we need to create
		// limit amount to a sensible number
		//amount = Math.min ( amount, 22 );
        if ( typeof ( param_languages ) == 'undefined' ) { param_languages = ''; }
        if ( typeof ( param_sectors ) == 'undefined' ) { param_sectors = ''; }
        if ( typeof ( param_locations ) == 'undefined' ) { param_locations = ''; }
        return "/templates/tlj_v2/scripts/banner_loader.php?action=get_banners&amount=" + amount.toString() + "&searchlanguages=" + param_languages + "&searchsectors=" + param_sectors + "&searchlocations=" + param_locations;
	}
	
	
	function showinner () {
		var obj_featRecruits = document.getElementById ( "FeaturedRecruiters" );
		alert ( obj_featRecruits.innerHTML.toString() );
	}
	
		
	function dhtmlLoadScript ( url ) {
		var e = document.createElement("script");
		e.src = url;
		e.type="text/javascript";
		document.getElementsByTagName("head")[0].appendChild(e);
	}

    function populate_top_banner ( ) {
        return "/templates/tlj_v2/scripts/banner_loader.php?action=get_topbanner";
    }
