/****  PD_TABS.JS BROUGHT IN  ****/
/*
EASY TABS 1.2 Produced and Copyright by Koller Juergen
www.kollermedia.at | www.austria-media.at
Customized by Scott Gillam at Push Design
pushdesign.ca
*/

//EASY TABS 1.2 - MENU SETTINGS
//Set the id names of your tablinks (without a number at the end)
var tablink_idname = new Array("tablink")
//Set the id names of your tabcontentareas (without a number at the end)
var tabcontent_idname = new Array("tabcontent") 
//Set the number of your tabs in each menu
var tabcount = new Array("4")
//Set the Tabs wich should load at start (In this Example:Menu 1 -> Tab 2 visible on load, Menu 2 -> Tab 5 visible on load)
var loadtabs = new Array("1")  
//Set the Number of the Menu which should autochange (if you dont't want to have a change menu set it to 0)
var autochangemenu = 1;
//the speed in seconds when the tabs should change
var changespeed = 60;
//should the autochange stop if the user hover over a tab from the autochangemenu? 0=no 1=yes
var stoponhover = 1;
//END MENU SETTINGS
var noFlaLi = new Array();
for(i=1;i<=tabcount;i++) {
	noFlaLi[i]=('tablink'+i);
}
noFlaLi.push('pause_btn_a','play_btn_a');

/*Swich EasyTabs Functions - no need to edit something here*/
function easytabs(menunr, active) {
	if (menunr == autochangemenu){
		currenttab=active;
	}
	if ((menunr == autochangemenu)&&(stoponhover==1)) {
		stop_autochange()
	} else if ((menunr == autochangemenu)&&(stoponhover==0)) {
		counter=0;
	}
	menunr = menunr-1;
	for (i=1; i <= tabcount[menunr]; i++){
		document.getElementById(tablink_idname[menunr]+i).className='tab'+i;
		document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';
	}
	document.getElementById(tablink_idname[menunr]+active).className='tab'+active+' tabactive';
	document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';
}
var timer;
counter=0;
var totaltabs=tabcount[autochangemenu-1];
var currenttab=loadtabs[autochangemenu-1];

function start_autochange() {
	counter=counter+1;
	timer=setTimeout("start_autochange()",1000);
	if (counter == changespeed+1) {
		currenttab++;
		if (currenttab>totaltabs) {
			currenttab=1
		}
		easytabs(autochangemenu,currenttab);
		restart_autochange();
	}
}

function restart_autochange() {
	clearTimeout(timer);
	counter=0;
	start_autochange();
	var playBtn = document.getElementById("play_btn");
	playBtn.style.display = "none";
	var pauseBtn = document.getElementById("pause_btn");
	pauseBtn.style.display = "inline";
}

function stop_autochange() {
	clearTimeout(timer);
	counter=0;
	var playBtn = document.getElementById("play_btn");
	playBtn.style.display = "inline";
	var pauseBtn = document.getElementById("pause_btn");
	pauseBtn.style.display = "none";
}

/***  END OF PD_TABS.JS  ***/

function equalColumns() {
	var colIDs = new Array('floatContent','floatContent1','floatContent2','homeHighlights');
	var i;
	var maxHeightLeftCol;
	var cols;
	var indexRightCol;
	var topLeftCol;
	var topRightCol;
	var initWinHeightWidth = isResized();
	
	//start of code specific to the flash div
	var theDiv = document.getElementById("imagestrip"); 
	var theHeight = Math.floor(theDiv.offsetWidth)*.3120915;
	theDiv.style.height = theHeight + "px";
	//end of code specific to flash div
	
	//start of code specific to the flash div alternative content
	if (document.getElementById("tabbedcontent")) {
		var menucount=loadtabs.length;
		var a = 0;
		var b = 1;
		do {
			easytabs(b, loadtabs[a]);
			a++;
			b++;
		} while (b<=menucount);
		if (autochangemenu!=0) {
			start_autochange();
		}
	
		var noFlashDiv = document.getElementById("tabbedcontent");
		var noFlashMenu = document.getElementById("tabmenu");
		var tabMenuHeight = Math.round(theHeight*.1885);
		noFlashDiv.style.display = "block";
		noFlashDiv.style.height = (theHeight-tabMenuHeight) + "px";
		noFlashMenu.style.display = "block";
		noFlashMenu.style.height = tabMenuHeight + "px";
		for(i=1;i<=tabcount;i++) {
			document.getElementById(noFlaLi[i]).style.lineHeight = tabMenuHeight + "px";
			var theWidth = Math.round(theDiv.offsetWidth)*.19;
			document.getElementById(noFlaLi[i]).style.width = theWidth + "px";
			var noFlashMenuBkgd = document.getElementById('tabmenu');
			var moveBkgd = theWidth*tabcount-3;
			noFlashMenuBkgd.style.backgroundPosition=moveBkgd+'px 0';
		}
		var noFlaPlay = document.getElementById("play_btn_a");
		var noFlaPause = document.getElementById("pause_btn_a");
		noFlaPlay.style.width = noFlaPause.style.width = theWidth*.7 + "px";
		noFlaPlay.style.lineHeight = noFlaPause.style.lineHeight = tabMenuHeight*.7 + "px";
		noFlaPlay.style.height = noFlaPause.style.height = tabMenuHeight*.7 + "px";
		noFlaPlay.style.margin = noFlaPause.style.margin = tabMenuHeight*.15 + "px";
		//end of code specific to the flash div alternative content
	}
	cols = new Array(colIDs.length);
	indexRightCol = colIDs.length - 1;
	maxHeightLeftCol = 0;
	externalLinks();

	// Find max height of first 3 columns;
	for(i=0;i<indexRightCol;i++)  {
		cols[i] = document.getElementById(colIDs[i]);
		// Setting height property to auto, offsetHeight gets reset.
		// Otherwise, offsetHeight keeps previous max value. 
		cols[i].style.height = 'auto';
		cols[i].style.height = cols[i].offsetHeight;
		if(maxHeightLeftCol < cols[i].offsetHeight) {
			maxHeightLeftCol = cols[i].offsetHeight;
		}
	}
	cols[indexRightCol] = document.getElementById(colIDs[indexRightCol]);
	cols[indexRightCol].style.height = 'auto';

	// Find top offset difference between 3 (left) columns and 4th column (righ):
	var topLeftCol = findTop(cols[0]);
	var topRightCol = findTop(cols[indexRightCol]);
	dif = topLeftCol - topRightCol;

	// If right column is larger than left columns plus differnece:
	if(maxHeightLeftCol + dif < cols[indexRightCol].offsetHeight) {
		for(i=0;i<indexRightCol;i++) {
			cols[i].style.height = (cols[indexRightCol].offsetHeight - dif) + 'px';
			// resolve in a case padding is pressent offsetHeight = sytle.height + padding;
			if(cols[i].offsetHeight > (cols[indexRightCol].offsetHeight - dif)) {
				cols[i].style.height = ((2 * (cols[indexRightCol].offsetHeight - dif)) - cols[i].offsetHeight) + 'px';
			}
		}
	} else {
		cols[indexRightCol].style.height = (maxHeightLeftCol + dif) + 'px';
		// resolve in a case padding is pressent offsetHeight = sytle.height + padding;
		if(cols[indexRightCol].offsetHeight > (maxHeightLeftCol + dif)) {
			cols[indexRightCol].style.height = (2 * maxHeightLeftCol - cols[indexRightCol].offsetHeight) + 'px';
		}
		for(i=0;i<indexRightCol;i++) {
			cols[i].style.height = maxHeightLeftCol + "px";
			// resolve in a case padding is pressent offsetHeight = sytle.height + padding;
			if(cols[i].offsetHeight > maxHeightLeftCol) {
				cols[i].style.height = (2 * maxHeightLeftCol - cols[i].offsetHeight) + 'px';
			}
		}
	}
}

function findTop(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop;
		}
	}
	return curtop;
}

function reloadWindow() {
	if(isResized()) {
		window.document.location = window.document.location;
	}
	return true;
}

var winHeight = 0;
var winWidth = 0;

function isResized() {
	var myWidth = 0, myHeight = 0;
	
	if(typeof( window.innerWidth ) == 'number') {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if(document.body && ( document.body.clientWidth || document.body.clientHeight)) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	if((winHeight != myHeight) || (winWidth != myWidth)) {
		winHeight = myHeight;
		winWidth = myWidth;
		return true;
	} else {
		return false;
	}
}

window.onload=equalColumns; 
window.onresize=reloadWindow;

