function browser_window() {
	var w = 0;
	var h = 0;
	if(!window.innerWidth) { //IE
		if(!(document.documentElement.clientWidth == 0)) { //strict mode
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		} else { //quirks mode
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	} else { //w3c
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}

function init() {
	//center website in browser window
	var bWindow = browser_window();
	var canvas = document.getElementById("canvas").style;
	var lim = document.getElementById("lim").style;
	var box = document.getElementById("box").style;
	var bl = document.getElementById("bl").style;

	canvas.marginTop = 0 + 'px';
	canvas.marginLeft = 0 + 'px';
	bl.top = 0 + 'px';
	box.marginTop = 0 + 'px';
	box.marginLeft = 0 + 'px';
	
	var mLeft = 72;
	var mTop = 515;
	
	if (bWindow.height < 600) {
		canvas.top = 0 + 'px';
		lim.top = 73 + 'px';	
		bl.height = mTop + 'px';
		box.top = 0 + 'px';
	} else {
		canvas.top = (bWindow.height / 2) - 300 + 'px';
		lim.top = (bWindow.height / 2) - 227 + 'px';		
		bl.left = (bWindow.width-1000)/2 + mLeft + 'px';
		bl.height = (bWindow.height-600)/2 + mTop + 'px';
		box.top = (bWindow.height / 2) - 300 + 'px';
	}
			
	if (bWindow.width < 1000) {
		canvas.left = 0 + 'px'; 
		lim.width = 0 + 'px';		
		bl.left = mLeft + 'px';
		bl.width = bWindow.width - 71 + 'px';
		box.left = 0 + 'px';
	} else {
		canvas.left = (bWindow.width / 2) - 500 + 'px';
		lim.width = (bWindow.width / 2) - 500 + 'px';
		bl.left = (bWindow.width-1000)/2 + mLeft + 'px';
		bl.width = bWindow.width-(bWindow.width-1000)/2 - 74 + 'px';
		box.left = (bWindow.width / 2) - 500 + 'px';		
	}
	scrollbar('scroll_but_con','content');
}
//show hide submenu
var timer;
var opac = 0;
function opacity(obj,d,s) {
	var sub = document.getElementById(obj);
	(d == "in") ? opac += s : opac -= s;
	set_opacity_all(sub, opac);
	timer = setTimeout('opacity("'+obj+'","'+d+'",'+s+')', 15);
	if (d == "in" && opac >= 100) {
		clearTimeout(timer);
	} else if (d == "out" && opac <= 0) {
		clearTimeout(timer);
		sub.style.display = "none";
	}
}
function set_opacity_all(obj, opac) {
	obj.style['opacity'] = opac / 100;
	obj.style['-moz-opacity'] = opac / 100;
	if(obj.filters) obj.filters.alpha.opacity = opac;
} 
function show_sub(obj) {
	clearTimeout(timer);
	var parentDiv = document.getElementById('nav');
	var mainNav = document.getElementById('m_'+obj);
	var subNav = document.getElementById('s_'+obj);
	divArr = parentDiv.getElementsByTagName('div');
	for (var i=0;i<divArr.length;i++) {
		if (divArr[i].style.display == 'block' && divArr[i].id != 's_'+obj) {
			set_opacity_all(divArr[i], 0);
			divArr[i].style.display = 'none';
		}
	}
	subNav.style.top = 0 - parentDiv.offsetTop + 'px';
	subNav.style.display = "block";
	var subNavTop = mainNav.offsetTop + 20;
	var subNavBottom = parentDiv.offsetTop + subNavTop + subNav.offsetHeight;
	if (subNavBottom > 600) {
		var topCorrection = subNavBottom - (600-15);
		subNav.style.top = subNavTop - topCorrection + 'px';
	} else {
		subNav.style.top = subNavTop + 'px';
	}
	opacity(subNav.id,"in",5);
}
function hide_sub(obj) {
	clearTimeout(timer);
	opacity('s_'+obj,"out",5);
}
//scroll up/down
var step = 3;
function scrollDivDown(id){ 
	document.getElementById(id).scrollTop += step;
	timerDown = setTimeout("scrollDivDown('" + id + "')",10);
} 
function scrollDivUp(id){ 
	document.getElementById(id).scrollTop -= step; 
	timerUp = setTimeout("scrollDivUp('" + id + "')",10);
}
//scroll on/off
function scrollbar(but, obj) {
	var divHeight = document.getElementById(obj).clientHeight;
	var divScrollHeight = document.getElementById(obj).scrollHeight;
	if (divScrollHeight > divHeight) {
		document.getElementById(but).style.display = "block";
	} else {
		document.getElementById(but).style.display = "none";
	}
}


