function open_date_selection(date,call_back_function){
   w=250;
   h=250;
   return open_centered_dialog_("pages/dialogs/date_request.php",
                                "&date="+date+
                                "&call_back_function="+call_back_function,
                                "",
                                w,
                                h,
                                "_date_selector");
}

function open_file_selection(id_tipo_file,call_back_function,language){
   w=400;
   h=400;
   return open_centered_dialog_("pages/dialogs/select_file.php",
                                "&id_tipo_file="+id_tipo_file+
                                "&call_back_function="+call_back_function+
                                "&language="+language,
                                "scrollbars=yes",
                                w,
                                h,
                                "_select_file");
}

function open_preview(file_name){
   width=screen.availWidth/2;
   height=screen.availHeight/2;
   _preview=window.open(file_name,"_preview","resizable=1,scrollbars=1,width="+width+",height="+height+",top="+((screen.availHeight-height)/2)+",left="+((screen.availWidth-width)/2));
   _preview.focus();
}

function open_directory(dir){
   w=300;
   h=400;
   open_window("/pages/dialogs/open_directory.php?dir="+dir+"","open_directory","width="+w+",height="+h+",top="+((screen.availHeight-h)/2)+",left="+((screen.availWidth-w)/2));
}

function open_file(dir){
   w=300;
   h=400;
   open_window("/pages/dialogs/open_file.php?dir="+dir+"","open_directory","scrollbars=yes,width="+w+",height="+h+",top="+((screen.availHeight-h)/2)+",left="+((screen.availWidth-w)/2));
}

var _db_wnd;
function open_db_select_dialog(title,query,key,fields,separator,multi_selection,width,height,callback_function,sid,selected_values){
//   if (_db_wnd) _db_wnd.close();
   _db_wnd=open_window("/pages/dialogs/open_db_select.php?"+
                       "query="+query+
                       "&title="+title+
                       "&keys="+key+
                       "&fields="+fields+
                       "&multi_selection="+multi_selection+
                       "&separator="+separator+
                       "&callback_function="+callback_function+
                       "&selected_values="+selected_values+
                       "&"+sid,
                   title.replace(/ /g,"_"),
                   "width="+width+",height="+height+",top="+((screen.availHeight-height)/2)+",left="+((screen.availWidth-width)/2));
    _db_wnd.focus();
}

function open_db_select_dialog_(settings,multi_selection,width,height,callback_function,sid,window_name,selected_values){
//   if (_db_wnd) _db_wnd.close();
   _db_wnd=open_window("/pages/template/dialog.php?content_page=pages/dialogs/open_db_select.php"+
                       "&settings="+settings+
                       "&multi_selection="+multi_selection+
                       "&callback_function="+callback_function+
                       "&selected_values="+selected_values+
                       "&"+sid,
                   window_name,
                   "width="+width+",height="+height+",top="+((screen.availHeight-height)/2)+",left="+((screen.availWidth-width)/2));
    _db_wnd.focus();
}

var _dlg_wnd;
function open_dialog(url,parameters,settings){
//   if (_dlg_wnd) _dlg_wnd.close();
   _dlg_wnd=open_window("/pages/template/dialog.php?content_page="+url+"&"+parameters,"",settings);
//    return _dlg_wnd;
}

function open_centered_dialog_(url,parameters,settings,width,height,window_name){
    _centered_wnd=open_window("/pages/template/dialog.php?content_page="+url+'&'+parameters,
                        window_name,
                       settings+",resizable=1,width="+width+",height="+height+",top="+((screen.availHeight-height)/2)+",left="+((screen.availWidth-width)/2));
//    return _centered_wnd;
}

function open_centered_dialog(url,parameters,settings,width,height,window_name){
    _centered_wnd=open_window(url+"?"+parameters,
                        window_name,
                       settings+",resizable=1,width="+width+",height="+height+",top="+((screen.availHeight-height)/2)+",left="+((screen.availWidth-width)/2));
//    return _centered_wnd;
}


