/*********************************************************************************

  Adjust container offsetHeight if media is smaller than available height...
  
**********************************************************************************/
	
function adjustS2() {


	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer

		windowWidth = self.innerWidth;

		windowHeight = self.innerHeight;

	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode

		windowWidth = document.documentElement.clientWidth;

		windowHeight = document.documentElement.clientHeight;

	} else if (document.body) { // other Explorers

		windowWidth = document.body.clientWidth;

		windowHeight = document.body.clientHeight;

	}	


	arrayPageSize = new Array(windowWidth,windowHeight);

	return arrayPageSize;
}
	  



function doAwp2() {

    var arrayPageSize = adjustS2();

    var opts1 = document.getElementById("fixedWrapperMe");
    var opts2 = document.getElementById("articleBgndMe");
    var opts3 = document.getElementById("footerMe");
    //var opts4 = document.getElementById("tools");
    
    //alert(arrayPageSize[1]);

    moveBy1 = opts1.offsetHeight;
    moveBy2 = opts2.offsetHeight;
    moveBy3 = opts3.offsetHeight;
    moveBy4 = moveBy1 + moveBy2;
    moveBy5 = arrayPageSize[1];
    moveBy6 = moveBy5 - moveBy4;
    moveBy7 = moveBy6 - moveBy3;
    

        if (/WebKit/i.test(navigator.userAgent)) {

            moveBy8 = moveBy7;// 13

        }
        
        else if (document.getElementById('iex7m')) {

            moveBy8 = moveBy7;

        }

        else { moveBy8 = moveBy7; }// 15
        

    var itr = document.getElementById('mediaHolder');

    imgh = itr.offsetHeight;
    

        if (imgh < moveBy8) {
        
            var mediaBox = document.getElementById("mediaBox");

            mediaBox.style.height = (moveBy8 + 'px');

            mediaBox.style.width = "auto";

            marg1 = moveBy8 - imgh;

            marg2 = 2;

            marg3 = marg1 / marg2;
            
             if (/WebKit/i.test(navigator.userAgent)) {
             
                if (document.getElementById('d3d'))  {

                    marg4 = marg3 + 10;
            
                }
                
                else {

                marg4 = marg3;// - 10
            
                }

            }
            
            else {

            marg4 = marg3;// - 10
            
            }

            itr.style.marginTop = (marg4 + 'px');

         }

        else {

            var mediaBox = document.getElementById("mediaBox");

            mediaBox.style.height = "auto";

            mediaBox.style.width = "auto";
            
            mediaBox.style.marginTop = "0";
            
            itr.style.marginTop = "0";
            
         }
         
         Exf();
}


/*********************************************************************************

adjust or resize while active tools
  
**********************************************************************************/


var exfChk = false;

function Exf() {

	if (exfChk) return;

	exfChk = true;

	checker5.init(); //alert('Exf');

}


checker5 = {};

var ExForce = false;


checker5.init = function() {

    if (ExForce) return;

	var ExForce = true;

    var art = document.getElementById("articleMe");

	aw = art.offsetWidth;

	var el5 = aw;
	
		if ( el5 ) {

			checker5.ofW5 = el5;
	
			interval5ID = setInterval(checker5.check5, 2000);
			
		}

}


checker5.check5 = function() {
	
    var art2 = document.getElementById("articleMe");

	aw2 = art2.offsetWidth;

	var el6 = aw2;
	

	if ( checker5.ofW5 != el6 ) {
	
		checker5.ofW5 = el6;

        doAwp2()
		      
	}

}

function ExfCheckerClear() {
 
        if (interval5ID) { clearInterval(interval5ID); exfChk = false; //alert("ExfCheckerClear() TOTALLY"); 
        
            return false; }

        else { return false; }

}


/*********************************************************************************

  Multiple window.onload
  
**********************************************************************************/

// addLoadEvent()

// Adds event to window.onload without overwriting currently assigned onload functions.

// Function found at Simon Willison's weblog - http://simon.incutio.com/


function addLoadEvent(func)

{	

	var oldonload = window.onload;

	if (typeof window.onload != 'function'){

    	window.onload = func;

	} else {

		window.onload = function(){

		oldonload();

		func();

		}

	}

}




addLoadEvent(doAwp2);
