// ActionScript Document

function confirmAction(theMessage)
{
	
    // TODO: Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(theMessage);

    return is_confirmed;
}

// Return Media
function callback_upload(file, completed, num_uploads)
{
	window.location= './?a=media';
}


function request_ajax(url, methode, id_dom)
{
	new Ajax.Request(url, {asynchronous:true, evalScripts:true, method:'post', onSuccess:function(request){$('loading-mask').hide();}, onCreate:function(request){$('loading-mask').show();}, parameters:'is_ajax=1&methode='+methode+'&id_dom='+id_dom}); 
	return false;
}

function ajaxRequest(url, id_dom)
{
	new Ajax.Request(url, {asynchronous:true, evalScripts:true, method:'post', 
	onSuccess:function(request){
	$('loading-mask').hide();
	Element.update(id_dom, request.responseText);
	document.location.replace('#'+id_dom)
	}, onCreate:function(request){$('loading-mask').show();}, parameters:'isAjax=1'});
	return false;
		
}

function request_ajax_form(url, methode, id_dom, form)
{
	new Ajax.Request(url, {asynchronous:true, evalScripts:true, method:'post', onSuccess:function(request){$('loading-mask').hide();},onCreate:function(request){$('loading-mask').show();}, parameters:Form.serialize(form)+'&is_ajax=1&methode='+methode+'&id_dom='+id_dom}); 
	return false;
}


function request_ajax_auto(url, methode, id_dom, idfield)
{
	new Form.Element.Observer(idfield, 1, function(element, value) {
		new Ajax.Request(url, {asynchronous:true, evalScripts:true, onSuccess:function(request){$('loading-mask').hide();$(id_dom).show();}, onCreate:function(request){$('loading-mask').show();}, parameters:'is_ajax=1&methode='+methode+'&id_dom='+id_dom+'&'+idfield+'='+value})
	});
	return false;
}

function translateGoogle(text, sl, tl, field){
	new Ajax.Request('./translate.php?text='+text+'&sl='+sl+'&tl='+tl+'&field='+field, {asynchronous:true, evalScripts:true, method:'post',  onSuccess:function(request){$('loading-mask').hide();}, onCreate:function(request){$('loading-mask').show();}});
	return false;	
}


/******* Disable Form **********/
function toggleTB(what){
	document.edit_user.user_password.disabled= (what.checked) ? 0 : 1;
	document.edit_user.user_password_conf.disabled= (what.checked) ? 0 : 1;
	document.edit_user.user_pwd.disabled= (what.checked) ? 0 : 1;
}
