// JavaScript Document
function addLoadListener(fn)
{
	if(typeof window.addEventListener != 'undefined')
	{
		window.addEventListener('load',fn,false);
	}
	else if (typeof document.addEventListener != 'undefined')
	{
		document.addEventListener('load', fn, false);
	}
	else if (typeof window.attachEvent != 'undefined')
	{
		window.attachEvent('onload', fn);
	}
	else
	{
		var oldfn = window.onload;
		if(typeof window.onload != 'function')
		{
			window.onload = fn;
		}
		else
		{
			window.onload = function()
			{
				oldfn();
				fn();
			};
		}
	}
};
function attachEventListener(target, eventType, functionRef, capture){
	if(typeof target.addEventListener != "undefined"){
		target.addEventListener(eventType, functionRef, capture);
	}
	else if (typeof target.attachEvent != "undefined"){
		target.attachEvent("on" + eventType, functionRef);
	}
	else {
		eventType = "on" + eventType;
		
		if(typeof target [evetType] == "function"){
			var oldListener = target[eventType];
			target[eventType] = function(){
				oldListener();
				return functionRef;
			};
		}
		else {
			target[eventType] = functionRef;
		}
	}
}

function resizeDiv(){
	attachEventListener(window, "resize", getSize, false);
};
function getSize(){
	var inblockdiv=document.getElementById('inblock');
	var innerdivs=inblockdiv.getElementsByTagName('div');
	var contentdiv=document.getElementById('middle');
	var myWidth = contentdiv.offsetWidth;
	var newWidth = ((myWidth-402)/3);
	inblockdiv.style.width=myWidth-420+'px';
	for(var i=0; i<innerdivs.length; i++){
		if(innerdivs[i].getAttributeNode("class").value=="inner"){
			innerdivs[i].style.width=newWidth-7+'px';
		}
	}
}
function inner(){
	var inblockdiv=document.getElementById('inblock');
	var innerdivs=inblockdiv.getElementsByTagName('div');
	var contentdiv=document.getElementById('middle');
	var myWidth = contentdiv.offsetWidth;
	var newWidth = ((myWidth-402)/3);
	for(var i=0; i<innerdivs.length; i++){
		if(innerdivs[i].getAttributeNode("class").value=="inner"){
			innerdivs[i].style.width=newWidth-7+'px';
		}
	}
}
addLoadListener(resizeDiv);
addLoadListener(getSize);
