// --------------------- flash code -----------------------------------------

var flash_hidden = false;

function hpintro() {
	if (flash_hidden == true) return;
	//document.getElementById('body').style.visibility = "visible";
	fade('pagefade',100,0,.7);
	setTimeout("hideflash()",2000);
	flash_hidden = true;
}

function flashinit() {
	//document.getElementById('body').style.visibility = "hidden";

	var thiswinsize = window.winsize();
	var themask = document.getElementById('pagefade');
	var themaskw = document.body.offsetWidth;
	if (thiswinsize.h > document.body.offsetHeight) {
		var themaskh = thiswinsize.h;
	}
	else {
		var themaskh = document.body.offsetHeight;
	}

	themaskh = eval(themaskh) * 1.01;

	themask.style.width = themaskw + "px";
	themask.style.height = themaskh + "px";
	themask.style.display = "block";

	//document.getElementById('body').style.visibility = "visible";
	setTimeout("hpintro()",10000);
}

function hideflash() {
	document.getElementById('pagefade').style.display = "none";
	document.getElementById('flashshell').style.visibility = "hidden";
	document.getElementById('flashshell').style.display = "none";
}

function setopacity(thisdiv,percent,ignore) {
	thefadediv = document.getElementById(thisdiv);
	if (thefadediv) {
		thefadediv.style.opacity = (percent/101);
		thefadediv.style.MozOpacity = (percent/101);
		thefadediv.style.KhtmlOpacity = (percent/100);
		if (ignore != 'ignore_ie') thefadediv.style.filter = "alpha(opacity=" + percent + ")";
	}
}

function fade(thisdiv,start,end,dur,fps,ignore) {
	if (!fps) {
		fps = 15;
	}

	if (!ignore) {
		ignore = null;
	}

	if (!dur && fade_duration != null) {
		dur = fade_duration;
	}
	var fadesteps = (dur * fps);
	var fadestepdur = Math.round((dur * 1000) / fadesteps);

	fadeopac = start;
	if (start < end) {
		var opacstep = ((end - start) / fadesteps);
		for(i=0; i<=fadesteps; i++) {
			setTimeout("setopacity('" + thisdiv + "'," + fadeopac + ",'" + ignore + "')",(i * fadestepdur));
			fadeopac = (i==(fadesteps-1)) ? end : (fadeopac + opacstep);
		}
	}
	else if (start > end) {
		var opacstep = ((start - end) / fadesteps);
		for(i=0; i<=fadesteps; i++) {
			setTimeout("setopacity('" + thisdiv + "'," + fadeopac + ",'" + ignore + "')",(i * fadestepdur));
			fadeopac = (i==(fadesteps-1)) ? end : (fadeopac - opacstep);
		}
	}
}


window.winsize = function() {
	var winw = 0;
	var winh = 0;

	if (!window.innerWidth) { // IE

		if (!(document.documentElement.clientWidth == 0)) { // strict mode
			winw = document.documentElement.clientWidth;
			winh = document.documentElement.clientHeight;
		}
		
		else {// quirks mode
			winw = document.body.clientWidth;
			winh = document.body.clientHeight;
		}
	}
	else { // W3C
		winw = window.innerWidth;
		winh = window.innerHeight;
	}

	return {w:winw,h:winh};
}


// --------------------- homeboxes resize code -----------------------------------------

function setboxsize() {
	var sizearr = new Array();
	var boxdiv = document.getElementById('homeboxes');
	var boxes = boxdiv.getElementsByTagName("a");

	for(var i=0;i<boxes.length;i++) {
		if (boxes[i].className.indexOf("box") >= 0) {
			sizearr[i] = boxes[i].offsetHeight;
		}
	}

	sizearr.sort(function(a,b){return b - a})

	for(var i=0;i<boxes.length;i++) {
		if (boxes[i].className.indexOf("box") >= 0) {
			boxes[i].style.height = sizearr[0] + 'px';
		}
	}
}


// -------------------------------------------------------------------------------


window.onload=function() {
	flashinit();
	setboxsize();
}


