function cpFormat(FM, FL){
$("#"+FL).change(function(){ $("#"+FM).val( $(this).val() ); });
$(function(){$("#"+FL).val( $("#"+FM).val() );});	
}
function dialogEdit(url,title){
$("body").append("<div id=\"editlight\" title=\""+title+"\">"+
"<iframe id=\"iEdit\" src=\""+url+"\">editor non supportato <\/iframe><\/div>");
$("#editlight").dialog({width:940,height:300,resizable:false,draggable:false,modal:true,
beforeClose: function(event, ui) {$("#editlight").remove()}
});
}
function dialogTable(id){
$("body").append("<div id=\"divdet\" title=\"zoom cella\"><textarea id=\"det\" name=\"det\" style=\"width:750px;height:300px\" > <\/textarea><\/div>");
$("#det").val( $("#"+id).val() );
CKdestroyInstance("det");
$("#divdet").dialog({width:800,height:450,resizable:false,draggable:false,
buttons:{
"Chiudi Dettaglio": function(){ CKdestroyInstance("det");$("#"+id).val( $("#det").val() );$("#divdet").remove(); },
"Apri/Chiudi Editor": function(){ if (CKEDITOR.instances["det"]){CKdestroyInstance("det");}else{CKEDITOR.replace("det",ckfull);} }									
},
beforeClose: function(event, ui) { CKdestroyInstance("det");$("#"+id).val( $("#det").val() );$("#divdet").remove(); }
});
}
function CKdestroyInstance(i){
if (CKEDITOR.instances[i])
CKEDITOR.instances[i].destroy();
}
function inputColor(id){
clr = $("#"+id).val();
if (clr == '')
clr = '000000'
$("#"+id).css("border-right", "20px solid #"+clr );
$("#"+id).ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
$(el).val(hex);
$(el).ColorPickerHide();
$(el).css("border-right", "20px solid #"+$(el).val() );
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
}										
});	
}
function labelEditor(LABEL, LBFLD, FIELD) {
$('#pageType').change(function(){
if ($(this).val() == 'M' ){
$('#'+LBFLD).removeAttr('readonly');
$('#'+LABEL).removeAttr('for');
}else{
$('#'+LBFLD).attr('readonly', 'readonly');
$('#'+LABEL).attr('for', FIELD);
 }
}).ready(function(){
$('#'+LBFLD).attr('rows', parseInt( $('#'+LBFLD).val().length / 30 ) + 1);
if ($('#pageType').val() == 'M'){
$('#'+LBFLD).css('background-color', '#FFF');
$('#'+LBFLD).css('border', '1px solid #999');
$('#'+LBFLD).removeAttr('readonly');
$('#'+LABEL).removeAttr('for');
}else{
$('#'+LBFLD).attr('readonly', 'readonly');
$('#'+LABEL).attr('for', FIELD);
}
});
}
function evalCheckForDisabled(idcheck,idtext){
$('#'+idcheck).click(function(){
if ($(this).is(':checked') )
$('#'+idtext).removeAttr('disabled');
else
$('#'+idtext).attr('disabled', 'disabled');
}).ready(function(){
if ($('#'+idcheck).is(':checked') )
$('#'+idtext).removeAttr('disabled');
else
$('#'+idtext).attr('disabled', 'disabled');
});
}
function activeObject(thischeck, num, clscolor) {
if (thischeck.checked==true){
$('#Div_'+num).removeClass(clscolor);		
$('#Div_'+num).addClass('ui-state-highlight');
}else{
$('#Div_'+num).removeClass('ui-state-highlight');
$('#Div_'+num).addClass(clscolor);
}
}
function msgSendLabel(){
try{
window.scrollTo(0,0);
$('#progressmsg').html('Invio Dati al Server');
$('#loadbox').show();
$('#msgloadbox').fadeIn();
}catch(e){}	
}
function DeletePag(){
if ($('#dac').is(':checked'))
return confirm('Confermi la cancellazione della Pagina?');
return true;
}
function checkAll(){
var n = document.getElementById('n_OggEdit').value;
for (i = 1; i <= n; i++){
if (i < 10)
var ix = '00' + i;
else if (i >= 100)
var ix = i;
else if (i >= 10)
var ix = '0' + i;
if (document.getElementById('Check_' + ix).checked == false)
document.getElementById('Check_' + ix).click();
}
}
function uncheckAll(){
var n = document.getElementById('n_OggEdit').value;
for (i = 1; i <= n; i++){
if (i < 10)
var ix = '00' + i;
else if (i >= 100)
var ix = i;
else if (i >= 10)
var ix = '0' + i;
if (document.getElementById('Check_' + ix).checked == true)
document.getElementById('Check_' + ix).click();
}
}
