function closePopup(objRef, objContainerRef)
{
	document.getElementById(objContainerRef).style.display = 'none';
	document.getElementById(objRef).style.display = 'none';
	debug('Close Contact Form');
}

function setElementWidth(objRef, w)
{
	
	objRef.style.width = '' + w + 'px';
}

function setElementHeight(objRef, w)
{
	
	objRef.style.height = '' + w + 'px';
}

function openForm(objRef, objFade, maxWidth, maxHeight, startx, starty, fadeHeight)
{
	var obj = document.getElementById(objRef);
	var objF = document.getElementById(objFade);
	objF.style.height = fadeHeight;
	obj.style.display = 'inline';
	obj.style.top = startx;
	obj.style.left = starty;
	setElementWidth(obj, 20);
	setElementHeight(obj, 10);
	growForm(objRef, objFade, maxWidth, maxHeight);
	
}

function growForm(objRef, objFade, maxH, maxW)
{
	
	var obj = document.getElementById(objRef);
	var curH = parseInt(obj.style.height.substring(0, obj.style.height.length - 2));
	var curW = parseInt(obj.style.width.substring(0, obj.style.width.length - 2));
	debug('growing...curW = ' + curW);
	if(curH < maxH || curW < maxW)
	{
		if(curW < maxW) {
			obj.style.width = (curW + 10) + "px";
		}
		if(curH < maxH) {
			obj.style.height = (curH + 10) + "px";
		}
		debug("growForm('" + objRef + "', '" + maxH + "', '" + maxW + "'); - curW = " + curW + ". curH = " + curH);
		window.setTimeout("growForm('" + objRef + "', '" + objFade + "', '" + maxH + "', '" + maxW + "');", 10);
	} else {
		var innerObj = document.getElementById(objFade);
		innerObj.style.display = 'inline';
		setElementOpacity(innerObj, 0);
		fadeElementPopup(objFade, 0, 10);
	}
}
function fadeElementPopup(elId, opacity, level) {

		if ((document.getElementById(elId))) {
			obj = document.getElementById(elId);
				if ((opacity >= 0 && level < 0)|| (opacity <= 100 && level > 0)) {
					//alert('elId ' + elId + '. opacity = ' + opacity);
					setElementOpacity(obj, opacity);
					opacity += level;
					//debug("fadeElement('"+elId+"',"+opacity+","+ level +")")
					window.setTimeout("fadeElementPopup('"+elId+"',"+opacity+"," + level + ")", 10);
				}
		}
}
function setUnderline(objRef, b)
{
	var obj = document.getElementById(objRef);
	if(b)
	{
		obj.style.textDecoration  = 'underline';
	} else {
		obj.style.textDecoration  = 'none';
	}
}

function handleContact()
{
	closePopups();
	document.getElementById('contactContainer').style.display = 'none';
	document.getElementById('contactForm').style.display = 'none';
	openForm('contactForm', 'contactContainer', 340, 250, '165px', '682px', '310px');

}

function handleAbout() {
	closePopups();
	document.getElementById('aboutForm').style.display = 'none';
	document.getElementById('aboutContainer').style.display = 'none';
	openForm('aboutForm', 'aboutContainer', 320, 250, '165px', '642px', '290px');
}



function handleContactMouseOut()
{
	setUnderline('contact', false);
}

function handleAboutMouseOut()
{
	setUnderline('about', false);
}


function handleContactMouseOver()
{
	setUnderline('contact', true);
}

function handleAboutMouseOver()
{
	setUnderline('about', true);
}

function closePopups() {
	closePopup('contactForm', 'contactContainer');
	closePopup('aboutForm', 'aboutContainer');
}



