﻿//------------------------------------------------------------------------------
//Start of Column Equalization
//var mainDivAr = ["leftcolumn", "leftmiddle", "rightmiddle", "rightcolumn"]; //Includes all the Divs that need to be equal
//var mainDivAr = ["leftcolumn", "leftmiddle", "rightmiddle", "rightcolumn", "rightcombined"]; //Includes all the Divs that need to be equal

function primer(){
	checkRes();
	resetSearchInput();
	if(!document.getElementById('advsearch')){
		document.getElementById('asButton').style.width='133px';//Displays Advanced Search
		document.getElementById('asButton').style.paddingLeft='7px';//Displays Advanced Search
		//Adjust advanced search box visibility
		var asActivity = readCookie("wj_advsearchactive");
		document.getElementById('asBox').style.display='block';
		document.getElementById('asButton').style.backgroundImage="url(../Images/buttons/advanced_search_close_btn.gif)";
		if(asActivity=="false"||asActivity==null){
			toggleElement('asBox');
		}
		closeSearchResults();
	}

	//Adjust content font sizes based on cookie value
	var contentSizeValue = readCookie("wj_contentsize");
	document.getElementById('search').style.display='block';
	document.getElementById('contentresize').style.display='block';//Displays Font Resizing Tools
	if(contentSizeValue==null)contentSizeValue=0;
	resizeContent(contentSizeValue);
}

function initializeRestructure(divAr){
	//alert("resizing");
	var highest = 0;
	for (i = 0; i<divAr.length; i++){
		var targetDiv = document.getElementById(divAr[i]);
		var targetDivTop = findElementY(targetDiv);
		targetDiv.style.height='auto';
		//alert(divAr[i]+" : "+(targetDiv.offsetHeight+targetDivTop));
		if (highest<targetDiv.offsetHeight+targetDivTop){
			highest = targetDiv.offsetHeight+targetDivTop;
		}
		
	}
	for (i=0; i<divAr.length; i++){
		var targetDiv = document.getElementById(divAr[i]);
		var targetDivTop = findElementY(targetDiv);
		targetDiv.style.height = (highest-targetDivTop)+'px';
	}
}

function findElementY(e) {
	var distFromTop = 0;
	if (e.offsetParent) {
		distFromTop = e.offsetTop;
		while (e = e.offsetParent) {
			distFromTop += e.offsetTop
		}
	}
	return distFromTop;
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
addLoadEvent(primer);
