var inPlaceOpt = { externalControlOnly:true, okControl: 'img', okText: '/ico/silk/accept.png',
					cancelControl: 'img', cancelText: '/ico/silk/cross.png',
					 onComplete:inPlaceSuccess, onFailure:inPlaceFailure };

var currentSection = null;

function setInPlace(host_, object_, id_, field_) {
	inPlaceOpt.externalControl = 'edit-'+object_+'-'+id_+'-'+field_;
	new Ajax.InPlaceEditor($(object_+'-'+id_+'-'+field_), host_+'/tajax/InPlaceEdit', inPlaceOpt);
}
function inPlaceSuccess(t_, e_) {
    $('echoBox').style.color = '#000';
    echo("Les donn&eacute;es ont &eacute;t&eacute; correctement modifi&eacute;es.  ");
	if(currentSection == 'fileControl')
		addHisto('Donnée modifiée : '+e_.parentNode.childNodes[1].attributes['alt'].value);
}
function inPlaceFailure() {
    $('echoBox').style.color = 'red';
    echo("Une erreur est survenue pendant l'enregistrement ; veuillez essayer &agrave; nouveau.");
}
function echo(msg_) {
	new Effect.Opacity('echoBox', { to:1, duration: 0.1 });
	$('echoBox').style.top = -65;
	$('echoBox').style.left = 0;
	$('echoBox').innerHTML = msg_;
	new Effect.Move('echoBox', { x: 0, y: 0, mode: 'absolute' });
	setTimeout(function() { $('echoBox').fade(); new Effect.Move('echoBox', { x: 0, y: -65, mode: 'absolute' }); }, 3000);
	$('echoBox').appear({ duration: 0.1 });
}

function sendMail(obj_) {
	window.location = 'mailto:'+$(obj_).innerHTML;
}


function checkSubmit() {
	complete = true;
	complete = checkInput('name') && complete;
	complete = checkInput('mail') && complete;
	complete = checkInput('phone') && complete;
	complete = checkInput('subject') && complete;
	complete = checkInput('msg') && complete;
	if(complete)
        $('formContact').submit();

	return complete;
}
function checkInput(id_) {
    if($(id_).value == '')
		return highlightInput(id_);
 	else
		return restoreInput(id_);
}

function highlightInput(id_) {
	check = $(id_);
	check.style.border = '1px solid #f00';
	return false;
}
function restoreInput(id_) {
	$(id_).style.border = '1px solid #999';
	return true;
}

var currentQuick = null;
function showQuick(type_) {
	if($(type_+'Detail').style.display == 'block') {
	    hideQuick(type_)
	    return;
	}

	if(currentQuick != null)
	    hideQuick(currentQuick)

	$(type_+'Display').style.background = '#eee';
	$(type_+'Detail').style.display = 'block';
	currentQuick = type_;
	
	if(type_ == 'option')
	    optionUpdate.stop();
    if(type_ == 'task')
	    taskUpdate.stop();
	
}
function hideQuick(type_) {
	$(type_+'Display').style.background = '#ddd';
	$(type_+'Detail').style.display = 'none';
	currentQuick = null;
	
	if(type_ == 'option')
	    optionUpdate.start();
    if(type_ == 'task')
	    taskUpdate.start();
}