// 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 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();}, 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;	
}


function cadre(x) {
	if((x/10)<1) x="0"+x;
	var ids = new Array("imglh","imgch","imgrh","imglc","imgrc","imglb","imgcb","imgrb");
	for(i=0;i<ids.length;i++) {
		$(ids[i]).src = "./images/cadres/"+x+"_0"+(i+1)+".jpg";
	}
	return false;
}

function sizeCanva(l){
	var sizeCanva = $('sizeCanva');
	var v = (l) ? (parseInt(sizeCanva.value)+1) : (parseInt(sizeCanva.value)-1);
	if((v >= 0) && (v <= 3)){
		var g = (v*10);
		sizeCanva.value = v;
		$('imglh').width = g;
		$('imglh').height = g;
		$('imgch').height = g;
		$('imgrh').width = g;
		$('imgrh').height = g;
		$('imglc').width = g;
		$('imgrc').width = g;
		$('imglb').width = g;
		$('imglb').height = g;
		$('imgcb').height = g;
		$('imgrb').width = g;
		$('imgrb').height = g;	
	}
	
	return false;
}

function printPage(obj, title)
{
      // Définit la zone à imprimer
      var zi = document.getElementById(obj).innerHTML;
      var Headers = '<!DOCTYPE HTML PUBLIC ><HTML><HEAD><link href="./styles/style.css" rel="stylesheet" type="text/css" /></HEAD><BODY style="background:#FFFFFF;color:black; background-color:#FFFFFF; padding:5px;" onload="window.print();window.close()">';
      var Footers = "</body></html>";
      // Ouvre une nouvelle fenetre
      var f = window.open("", title, "height=913, width=710,toolbar=0, menubar=0, scrollbars=1, resizable=1, status=0, location=0, left=10, top=10");

      // Définit le Style de la page
      f.document.body.style.color = '#000000';
      f.document.body.style.backgroundColor = '#FFFFFF';
      f.document.body.style.padding = "10px";

      // Ajoute les Données
      f.document.write ("" + Headers + zi +Footers);
      f.document.close();
      // Imprime et ferme la fenetre
      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;
}