/*
TelTech.com
Karl Glasgow
12/2008
code@keg4.com
*/

function Toggle(imageId, setting) 
{
	var image = document.getElementById(imageId);
	if (typeof image != "undefined") 
	{
		var reStatus = /_(off|on)_/i;
		setting = setting.toLowerCase();
		image.src = image.src.replace(reStatus, ("_" + setting + "_")); 
	}
}


var aryDivHeight = new Array();
function ExpandDiv(divId) 
{
	divTarget = document.getElementById('div_' + divId);
	divExpandCtrl = document.getElementById('div_' + divId + '_expand');
	divShrinkCtrl = document.getElementById('div_' + divId + '_shrink');
	
	if (divTarget) 
	{
		aryDivHeight[divId] = divTarget.style.height;
		divTarget.style.height = 'auto';
		if (divExpandCtrl && divShrinkCtrl) 
		{
			divExpandCtrl.style.display = 'none';
			divShrinkCtrl.style.display = 'block';
		}
	}
}
function ShrinkDiv(divId) 
{
	divTarget = document.getElementById('div_' + divId);
	divExpandCtrl = document.getElementById('div_' + divId + '_expand');
	divShrinkCtrl = document.getElementById('div_' + divId + '_shrink');
	
	if (divTarget) 
	{
		if (typeof aryDivHeight[divId] == 'undefined') 
		{
			aryDivHeight[divId] = '100px'; // default height
		}
		divTarget.style.height = aryDivHeight[divId];
		if (divExpandCtrl && divShrinkCtrl) 
		{
			divShrinkCtrl.style.display = 'none';
			divExpandCtrl.style.display = 'block';
		}
	}
}

function windowOpener(windowHeight, windowWidth, windowName, windowUrl, flexible)
{
    var centerWidth = (window.screen.width - windowWidth) / 2;
    var centerHeight = (window.screen.height - windowHeight) / 2;
	
	var newWindow = null;
	if (typeof flexible == 'undefined' || flexible == false) 
	{
		newWindow = window.open(windowUrl, windowName, 
			'resizable=0, scrollbars=0, menubar=0, location=0, status=0' +
			', width=' + windowWidth + 
			', height=' + windowHeight + 
			', left=' + centerWidth + 
			', top=' + centerHeight);
	}
	else 
	{
		newWindow = window.open(windowUrl, windowName, 
			'resizable=1, scrollbars=1, menubar=0, location=0, status=0' +
			', width=' + windowWidth + 
			', height=' + windowHeight + 
			', left=' + centerWidth + 
			', top=' + centerHeight);
	}

    newWindow.focus();
    return newWindow.name;
}

function addLoadEvent(func) 
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	} 
	else 
	{
		window.onload = function() 
		{
			if (oldonload) 
			{
				oldonload();
			}
			func();
		}
	}
}

