var STATE = '0.0';

function xTOGGLE(e) {
	var cDisplay = $(e).style.display;
	$(e).style.display = ((cDisplay=='') || (cDisplay=='none')) ? 'block' : 'none';
}
function hideAll() {
	$('contact').style.display='none';
	$('about').style.display='none';	
}
function xMAIL(name,domain,tld) {
	var wm = window.open('mailto:'+name+'@'+domain+'.'+tld);
	wm.window.close();
}

function SHOW(e) {
	var exSTATE = STATE;
	
	Element.setOpacity(e,0.0);
	
	if(e == 'about') {
		var oe = 'contact';
		STATE = '1.0';
	} else { 
		var oe = 'about';
		STATE = '0.1';
		$('test').value='user_is_not_a_bot';
	}

	if(exSTATE != '0.0') {
		$('close_'+ oe +'_panel').onclick = null;
		new Effect.Opacity(oe,
			{ duration: 0.5, 
			transition: Effect.Transitions.linear, 
			from: 0.9, to: 0.0,
			afterFinish: xALPHA }
		);
	} else xALPHA();
}

function HIDE(e) {
	STATE = '0.0';
	$('close_'+ e +'_panel').onclick = null;
	new Effect.Opacity(e,
		{ duration: 0.5, 
		transition: Effect.Transitions.linear, 
		afterFinish: DISP,
		from: 0.9, to: 0.0 }
	);	
}

function xALPHA() {
	var e = STATE == '1.0' ? 'about' : 'contact';
	var oe = STATE == '0.1' ? 'about' : 'contact';
	$(e).style.display = 'block';
	$(oe).style.display = 'none';
	$('close_'+ e +'_panel').onclick = function() {
		HIDE(e);
	}
	new Effect.Opacity(e,
		{ duration: 1, 
		transition: Effect.Transitions.linear, 
		from: 0.0, to: 0.9 }
	);
	if(e=='contact') $('name').focus();
}

function DISP() {
	$('about').style.display = 'none';
	$('contact').style.display = 'none';
}

function FOCUS(e) {
	$(e).style.borderColor = '#e9ddb5';
	$(e).style.background = '#fff';
	$('pfrm-'+ e).style.borderBottom = '1px solid #333';
	$('pfrm-'+ e).style.borderTop = '1px solid #333';
	$('pfrm-'+ e).style.backgroundColor = '#130501';
}
function BLUR(e) {
	$(e).style.borderColor = '';
	$(e).style.background = '';
	$('pfrm-'+ e).style.borderBottom = 'none';
	$('pfrm-'+ e).style.borderTop = 'none';
	$('pfrm-'+ e).style.backgroundColor = 'transparent';
}

function showErrors(fields) {
	var IDs = fields.split('|');
	$(IDs[0]).focus();
	for(var i=0;i<IDs.length;i++) {
		$(IDs[i]).style.borderColor='#FF9900';
	}
	
}
