// JavaScript Document

function getElement(id) {
	var ele = null;

	if ( document.getElementById ) {
		ele = document.getElementById(id);
	} else if ( document.all ) {
		ele = document.all[id];
	} else if ( document.layers ) {
		ele = document.layers[id];
	}

	return ele;
}

tmpBox = 0;
function showBox(box) {
	ele = getElement(box);
	ele.style.display = "block";
	tmpBox = 1;
}

function hideBox(box) {
	setTimeout('doHideBox(\''+box+'\')', 1000);	
	tmpBox = 0;
}
function doHideBox(box) {
	if(tmpBox == 0) getElement(box).style.display = "none";	
}


function switchTxt(container, content) {
		for(i=1; i<=3; i++) {
			getElement("an"+i).style.backgroundPosition = "top left";
		}
	getElement("a"+content).style.backgroundPosition = "bottom left";
	getElement(container).innerHTML = getElement(content).innerHTML;
}


// slide div
// use of the slide script:
//<a href="javascript:Slide('mydiv').down();">Slide Down</a>
//<a href="javascript:Slide('mydiv').up();">Slide Down</a>
//<div id="mydiv" style="display:none; overflow:hidden; height:100px;">Hello world!</div>

var slideInUse = new Array();

function Slide(objId, options) {
	this.obj = document.getElementById(objId);
	this.duration = 1;
	this.height = parseInt(this.obj.style.height);

	if(typeof options != 'undefined') { this.options = options; } else { this.options = {}; }
	if(this.options.duration) { this.duration = this.options.duration; }
		
	this.up = function() {
		this.curHeight = this.height;
		this.newHeight = '1';
		if(slideInUse[objId] != true) {
			var finishTime = this.slide();
			window.setTimeout("Slide('"+objId+"').finishup("+this.height+");",finishTime);
		}
	}
	
	this.down = function() {
		this.newHeight = this.height;
		this.curHeight = '1';
		if(slideInUse[objId] != true) {
			this.obj.style.height = '1px';
			this.obj.style.display = 'block';
			this.slide();
		}
	}
	
	this.slide = function() {
		slideInUse[objId] = true;
		var frames = 30 * duration; // Running at 30 fps

		var tIncrement = (duration*1000) / frames;
		tIncrement = Math.round(tIncrement);
		var sIncrement = (this.curHeight-this.newHeight) / frames;

		var frameSizes = new Array();
		for(var i=0; i < frames; i++) {
			if(i < frames/2) {
				frameSizes[i] = (sIncrement * (i/frames))*4;
			} else {
				frameSizes[i] = (sIncrement * (1-(i/frames)))*4;
			}
		}
		
		for(var i=0; i < frames; i++) {
			this.curHeight = this.curHeight - frameSizes[i];
			window.setTimeout("document.getElementById('"+objId+"').style.height='"+Math.round(this.curHeight)+"px';",tIncrement * i);
		}
		
		window.setTimeout("delete(slideInUse['"+objId+"']);",tIncrement * i);
		
		if(this.options.onComplete) {
			window.setTimeout(this.options.onComplete, tIncrement * (i-2));
		}
		
		return tIncrement * i;
	}
	
	this.finishup = function(height) {
		this.obj.style.display = 'none';
		this.obj.style.height = height + 'px';
	}
	
	return this;
}

function fontsizeusability(sz) {
	if(!sz) sz = 100;
	getElement("mr_content").style.fontSize = sz+'%';
}

function switchContent(c) {
	getElement("txtDiv").innerHTML = getElement(c).innerHTML;
}

// popup window for Security & Inspections
// Paul L. Brown
// 949.285.6635
// paul@ginsbro.com
var nw;
function assetPopUp(url) {
nw = window.open(url, 'pop','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,title=0,width=543,height=400'); 
}

