1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Affero General Public License version 3 as published by the
7 * Free Software Foundation with the addition of the following permission added
8 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
9 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
10 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * You should have received a copy of the GNU Affero General Public License along with
18 * this program; if not, see http://www.gnu.org/licenses or write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
23 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU Affero General Public License version 3.
29 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
32 * technical reasons, the Appropriate Legal Notices must display the words
33 * "Powered by SugarCRM".
34 ********************************************************************************/
40 var current_child_field = '';
41 var current_subpanel_url = '';
42 var child_field_loaded = new Object();
43 var request_map = new Object();
45 function get_module_name()
47 if(typeof(window.document.forms['DetailView']) == 'undefined') {
51 //check to see if subpanel_parent_module input exists. If so override module name
52 //this is used in the case when the subpanel contents are of the same module as the current module
53 //and the record in $_REQUEST is of the parent object. By specifying the subpanel_parent_module,
54 //you allow normal processing to continue. For an example, see trackdetailview.html/php in campaigns module
55 if(typeof(window.document.forms['DetailView'].elements['subpanel_parent_module']) != 'undefined' &&
56 window.document.forms['DetailView'].elements['subpanel_parent_module'].value != ''){
57 return window.document.forms['DetailView'].elements['subpanel_parent_module'].value;
59 return window.document.forms['DetailView'].elements['module'].value;
62 /*this function will take in three parameters, m,i,a and recreate navigation
65 * a = action (detail/edit)
66 * t = element to be modified
67 * r = relationship to update after edit.
68 * This is done to minimize page size
70 function subp_nav(m,i,a,t,r){
71 if(t.href.search(/#/) < 0){
72 //no need to process if url has already been converted
80 url = "index.php?module="+m+"&action="+a+"&record="+i+"&parent_module="+get_module_name()+"&parent_id="+get_record_id()+"&return_module="+get_module_name()+"&return_id="+get_record_id()+"&return_action=DetailView";
83 url += "&return_relationship=" + r;
89 /*this function will take in three parameters, m,i,a and recreate navigation
92 * a = action (detail/edit)
93 * This is done to minimize page size
95 function sub_p_rem(sp,lf,li,rp){
96 return_url = "index.php?module="+get_module_name()+"&action=SubPanelViewer&subpanel="+sp+"&record="+get_record_id()+"&sugar_body_only=1&inline=1";
98 remove_url = "index.php?module="+ get_module_name()
99 + "&action=DeleteRelationship"
100 + "&record="+ get_record_id()
101 + "&linked_field="+ lf //$linked_field"
102 + "&linked_id="+ li //$record"
103 + "&return_url=" + escape(escape(return_url))
104 + "&refresh_page=" + rp;//$refresh_page"
105 showSubPanel(sp,remove_url,true);
107 function sp_rem_conf(){
108 return confirm(SUGAR.language.get('app_strings', 'NTC_REMOVE_CONFIRMATION'))
112 function get_record_id()
114 return window.document.forms['DetailView'].elements['record'].value;
116 function get_layout_def_key()
118 if(typeof(window.document.forms['DetailView'].elements['layout_def_key']) == 'undefined')return '';
119 return window.document.forms['DetailView'].elements['layout_def_key'].value;
122 function save_finished(args)
124 var child_field = request_map[args.request_id];
125 delete (child_field_loaded[child_field] );
126 showSubPanel(child_field);
129 function set_return_and_save_background(popup_reply_data)
131 var form_name = popup_reply_data.form_name;
132 var name_to_value_array = popup_reply_data.name_to_value_array;
133 var passthru_data = popup_reply_data.passthru_data;
134 var select_entire_list = typeof( popup_reply_data.select_entire_list ) == 'undefined' ? 0 : popup_reply_data.select_entire_list;
135 var current_query_by_page = popup_reply_data.current_query_by_page;
136 // construct the POST request
137 var query_array = new Array();
138 if (name_to_value_array != 'undefined') {
139 for (var the_key in name_to_value_array)
141 if(the_key == 'toJSON')
147 query_array.push(the_key+"="+name_to_value_array[the_key]);
151 //construct the muulti select list
152 var selection_list = popup_reply_data.selection_list;
153 if (selection_list != 'undefined') {
154 for (var the_key in selection_list)
156 query_array.push('subpanel_id[]='+selection_list[the_key])
159 var module = get_module_name();
160 var id = get_record_id();
162 query_array.push('value=DetailView');
163 query_array.push('module='+module);
164 query_array.push('http_method=get');
165 query_array.push('return_module='+module);
166 query_array.push('return_id='+id);
167 query_array.push('record='+id);
168 query_array.push('isDuplicate=false');
169 query_array.push('action=Save2');
170 query_array.push('inline=1');
171 query_array.push('select_entire_list='+select_entire_list);
172 if(select_entire_list == 1){
173 query_array.push('current_query_by_page='+current_query_by_page);
175 var refresh_page = escape(passthru_data['refresh_page']);
176 for (prop in passthru_data) {
177 if (prop=='link_field_name') {
178 query_array.push('subpanel_field_name='+escape(passthru_data[prop]));
180 if (prop=='module_name') {
181 query_array.push('subpanel_module_name='+escape(passthru_data[prop]));
183 query_array.push(prop+'='+escape(passthru_data[prop]));
188 var query_string = query_array.join('&');
189 request_map[request_id] = passthru_data['child_field'];
191 var returnstuff = http_fetch_sync('index.php',query_string);
193 got_data(returnstuff, true);
194 if(refresh_page == 1){
195 document.location.reload(true);
199 function got_data(args, inline)
202 var list_subpanel = document.getElementById('list_subpanel_'+request_map[args.request_id].toLowerCase());
203 //this function assumes that we are always working with a subpanel..
204 //add a null check to prevent failures when we are not.
205 if (list_subpanel != null) {
206 var subpanel = document.getElementById('subpanel_'+request_map[args.request_id].toLowerCase());
207 var child_field = request_map[args.request_id].toLowerCase();
211 //if this is an inline operation, get the original buttons in the td element
212 //so that we may replace them later
214 trEls = list_subpanel.getElementsByTagName('tr');
215 if(trEls && trEls.length > 0) {
217 if(trEls[x] && trEls[x].className == 'pagination') {
218 tableEls = trEls[x].getElementsByTagName('table');
219 tdEls = tableEls[0].getElementsByTagName('td');
220 span = tdEls[0].getElementsByTagName('span');
222 buttonHTML = span[0].innerHTML;
229 child_field_loaded[child_field] = 2;
230 list_subpanel.innerHTML='';
231 list_subpanel.innerHTML=args.responseText;
233 //now if the trPagination element is set then let's replace the new tr element with this
234 if(buttonHTML != '') {
235 list_subpanel = document.getElementById('list_subpanel_'+request_map[args.request_id].toLowerCase());
236 trEls = list_subpanel.getElementsByTagName('tr');
238 if(trEls[x] && trEls[x].className == 'pagination') {
239 tableEls = trEls[x].getElementsByTagName('table');
240 tdEls = tableEls[0].getElementsByTagName('td');
241 span = tdEls[0].getElementsByTagName('span');
242 span[0].innerHTML = buttonHTML;
249 child_field_loaded[child_field] = 1;
250 subpanel.innerHTML='';
251 subpanel.innerHTML=args.responseText;
253 /* walk into the DOM and insert the list_subpanel_* div */
254 var inlineTable = subpanel.getElementsByTagName('table');
255 inlineTable = inlineTable[1];
256 inlineTable = subpanel.removeChild(inlineTable);
257 var listDiv = document.createElement('div');
258 listDiv.id = 'list_subpanel_'+request_map[args.request_id].toLowerCase();
259 subpanel.appendChild(listDiv);
260 listDiv.appendChild(inlineTable);
262 subpanel.style.display = '';
263 set_div_cookie(subpanel.cookie_name, '');
265 if (current_child_field != '' && child_field != current_child_field)
267 // commented out for now. this was originally used by tab UI of subpanels
268 //hideSubPanel(current_child_field);
270 current_child_field = child_field;
274 function showSubPanel(child_field,url,force_load,layout_def_key)
277 if ( typeof(force_load) == 'undefined' || force_load == null)
282 if (force_load || typeof( child_field_loaded[child_field] ) == 'undefined')
284 request_map[request_id] = child_field;
285 if ( typeof (url) == 'undefined' || url == null)
287 var module = get_module_name();
288 var id = get_record_id();
289 if ( typeof(layout_def_key) == 'undefined' || layout_def_key == null ) {
290 layout_def_key = get_layout_def_key();
293 url = 'index.php?sugar_body_only=1&module='+module+'&subpanel='+child_field+'&action=SubPanelViewer&inline=' + inline + '&record='+id + '&layout_def_key='+ layout_def_key;
296 if ( url.indexOf('http://') != 0 && url.indexOf('https://') != 0)
301 current_subpanel_url = url;
302 // http_fetch_async(url,got_data,request_id++);
303 var returnstuff = http_fetch_sync(url+ '&inline=' + inline + '&ajaxSubpanel=true');
305 got_data(returnstuff, inline);
309 var subpanel = document.getElementById('subpanel_'+child_field);
310 subpanel.style.display = '';
312 set_div_cookie(subpanel.cookie_name, '');
314 if (current_child_field != '' && child_field != current_child_field)
316 hideSubPanel(current_child_field);
319 current_child_field = child_field;
321 if(typeof(url) != 'undefined' && url != null && url.indexOf('refresh_page=1') > 0){
322 document.location.reload();
327 function markSubPanelLoaded(child_field){
328 child_field_loaded[child_field] = 2;
330 function hideSubPanel(child_field)
332 var subpanel = document.getElementById('subpanel_'+child_field);
333 subpanel.style.display = 'none';
334 set_div_cookie(subpanel.cookie_name, 'none');
336 var sub_cookie_name = get_module_name() + '_divs';
337 var temp = Get_Cookie(sub_cookie_name);
338 var div_cookies = new Array();
340 if(temp && typeof(temp) != 'undefined'){
341 div_cookies = get_sub_cookies(temp);
343 function set_div_cookie(name, display){
344 div_cookies[name] = display;
345 Set_Cookie(sub_cookie_name, subs_to_cookie(div_cookies), 3000, false, false,false);
349 function local_open_popup(name, width, height,arg1, arg2, arg3, params)
351 return open_popup(name, width, height,arg1,arg2,arg3, params);
354 SUGAR.subpanelUtils = function() {
355 var originalLayout = null;
356 var subpanelContents = {};
357 var subpanelLocked = {};
361 // get the current subpanel layout
362 getLayout: function(asString, ignoreHidden) {
363 subpanels = document.getElementById('subpanel_list');
364 subpanelIds = new Array();
365 for(wp = 0; wp < subpanels.childNodes.length; wp++) {
366 if(typeof subpanels.childNodes[wp].id != 'undefined' && subpanels.childNodes[wp].id.match(/whole_subpanel_[\w-]*/) && (typeof ignoreHidden == 'undefined' || subpanels.childNodes[wp].style.display != 'none')) {
367 subpanelIds.push(subpanels.childNodes[wp].id.replace(/whole_subpanel_/,''));
370 if(asString) return subpanelIds.join(',');
371 else return subpanelIds;
374 // called when subpanel is picked up
375 onDrag: function(e, id) {
376 originalLayout = SUGAR.subpanelUtils.getLayout(true, true);
379 // called when subpanel is dropped
380 onDrop: function(e, id) {
381 newLayout = SUGAR.subpanelUtils.getLayout(true, true);
382 if(originalLayout != newLayout) { // only save if the layout has changed
383 SUGAR.subpanelUtils.saveLayout(newLayout);
387 // save the layout of the subpanels
388 saveLayout: function(order) {
389 ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVING_LAYOUT'));
391 if(typeof SUGAR.subpanelUtils.currentSubpanelGroup != 'undefined') {
392 var orderList = SUGAR.subpanelUtils.getLayout(false, true);
393 var currentGroup = SUGAR.subpanelUtils.currentSubpanelGroup;
395 var success = function(data) {
396 ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVED_LAYOUT'));
397 window.setTimeout('ajaxStatus.hideStatus()', 2000);
398 if(typeof SUGAR.subpanelUtils.currentSubpanelGroup != 'undefined') {
399 SUGAR.subpanelUtils.reorderSubpanelSubtabs(currentGroup, orderList);
403 url = 'index.php?module=Home&action=SaveSubpanelLayout&layout=' + order + '&layoutModule=' + currentModule;
404 if(typeof SUGAR.subpanelUtils.currentSubpanelGroup != 'undefined') {
405 url = url + '&layoutGroup=' + encodeURI(SUGAR.subpanelUtils.currentSubpanelGroup);
407 var cObj = YAHOO.util.Connect.asyncRequest('GET', url, {success: success, failure: success});
410 // call when an inline create is saved
411 // buttonName is the id of the originating 'save' button - we determine the associated subpanel name by climbing the DOM from this point
412 // We require the subpanel name to refresh the subpanel contents and to close the subpanel after the save. However, the code the generates the button
413 // doesn't have access to the subpanel name, only the module name. Hence this rather long-winded mechanism.
414 inlineSave: function(theForm, buttonName) {
415 ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVING'));
416 var success = function(data) {
417 var element = document.getElementById(buttonName);
419 element = element.parentNode;
420 } while ( element.className != 'quickcreate' && element.parentNode ) ;
422 if (element.className == 'quickcreate') {
423 var subpanel = element.id.slice(9,-7) ; // retrieve the subpanel name from the div id - the name is encoded as 'subpanel_<subpanelname>_newdiv'
424 SUGAR.subpanelUtils.cancelCreate(buttonName);
426 var module = get_module_name();
427 var id = get_record_id();
428 var layout_def_key = get_layout_def_key();
430 eval('result = ' + data.responseText);
435 if (typeof(result) != 'undefined' && result != null && typeof(result['status']) != 'undefined' && result['status'] !=null && result['status'] == 'dupe') {
436 document.location.href = "index.php?" + result['get'].replace(/&/gi,'&').replace(/</gi,'<').replace(/>/gi,'>').replace(/'/gi,'\'').replace(/"/gi,'"').replace(/\r\n/gi,'\n');
439 showSubPanel(subpanel, null, true);
440 ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVED'));
441 window.setTimeout('ajaxStatus.hideStatus()', 1000);
442 if(reloadpage) window.location.reload(false);
446 // reload page if we are setting status to Held
447 var reloadpage = false;
448 if ((buttonName == 'Meetings_subpanel_save_button' || buttonName == 'Calls_subpanel_save_button' ) && document.getElementById(theForm).status[document.getElementById(theForm).status.selectedIndex].value == 'Held') {
451 YAHOO.util.Connect.setForm(theForm, true, true);
452 var cObj = YAHOO.util.Connect.asyncRequest('POST', 'index.php', {success: success, failure: success, upload:success});
456 sendAndRetrieve: function(theForm, theDiv, loadingStr) {
457 function success(data) {
458 theDivObj = document.getElementById(theDiv);
459 subpanelContents[theDiv] = new Array();
460 subpanelContents[theDiv]['list'] = theDivObj;
462 subpanelContents[theDiv]['newDiv'] = document.createElement('div');
463 dataToDOMAvail = false;
464 subpanelContents[theDiv]['newDiv'].innerHTML = '<script type="text/javascript">dataToDOMAvail=true;</script>' + data.responseText; // fill the div
465 subpanelContents[theDiv]['newDiv'].id = theDiv + '_newDiv';
466 subpanelContents[theDiv]['newDiv'].className = 'quickcreate' ;
468 theDivObj.style.display = 'none';
469 theDivObj.parentNode.insertBefore(subpanelContents[theDiv]['newDiv'], theDivObj);
470 if (!dataToDOMAvail) {
471 SUGAR.util.evalScript(data.responseText);
473 subpanelLocked[theDiv] = false;
474 setTimeout("enableQS(false)",500);
475 ajaxStatus.hideStatus();
479 if(typeof subpanelLocked[theDiv] != 'undefined' && subpanelLocked[theDiv]) return false;
480 subpanelLocked[theDiv] = true;
482 if(typeof loadingStr == 'undefined') loadingStr = SUGAR.language.get('app_strings', 'LBL_LOADING');
483 ajaxStatus.showStatus(loadingStr);
484 YAHOO.util.Connect.setForm(theForm);
485 var cObj = YAHOO.util.Connect.asyncRequest('POST', 'index.php', {success: success, failure: success});
490 cancelCreate: function(buttonName) {
491 var element = document.getElementById(buttonName);
493 var theForm = element.form;
494 var confirmMsg = onUnloadEditView(theForm);
497 element = element.parentNode;
498 } while ( element.className != 'quickcreate' && element.parentNode ) ;
500 var theDiv = element.id.substr(0,element.id.length-7);
502 if (typeof(subpanelContents[theDiv]) == 'undefined')
505 if ( confirmMsg != null ) {
506 if ( !confirm(confirmMsg) ) {
509 disableOnUnloadEditView(theForm);
513 subpanelContents[theDiv]['newDiv'].parentNode.removeChild(subpanelContents[theDiv]['newDiv']);
514 subpanelContents[theDiv]['list'].style.display = '';
519 loadSubpanelGroupFromMore: function(group){
520 SUGAR.subpanelUtils.updateSubpanelMoreTab(group);
521 SUGAR.subpanelUtils.loadSubpanelGroup(group);
524 updateSubpanelMoreTab: function(group){
526 var moreTab = document.getElementById(SUGAR.subpanelUtils.subpanelMoreTab + '_sp_tab');
527 moreTab.id = group + '_sp_tab';
528 moreTab.getElementsByTagName('a')[0].innerHTML = group;
529 moreTab.getElementsByTagName('a')[0].href = "javascript:SUGAR.subpanelUtils.loadSubpanelGroup('"+group+"');";
532 var menuLink = document.getElementById(group+'_sp_mm');
533 menuLink.id = SUGAR.subpanelUtils.subpanelMoreTab+'_sp_mm';
534 menuLink.href = "javascript:SUGAR.subpanelUtils.loadSubpanelGroupFromMore('"+SUGAR.subpanelUtils.subpanelMoreTab+"');";
535 menuLink.innerHTML = SUGAR.subpanelUtils.subpanelMoreTab;
537 SUGAR.subpanelUtils.subpanelMoreTab = group;
541 /* construct set of needed subpanels */
542 /* if we have not yet loaded this subpanel group, */
543 /* set loadedGroups[group] */
544 /* for each subpanel in subpanelGroups[group] */
545 /* if document.getElementById('whole_subpanel_'+subpanel) doesn't exist */
546 /* then add subpanel to set of needed subpanels */
547 /* if we need to load any subpanels, send a request for them */
548 /* with updateSubpanels as the callback. */
549 /* otherwise call updateSubpanels */
550 /* call setGroupCookie */
552 loadSubpanelGroup: function(group){
553 if(group == SUGAR.subpanelUtils.currentSubpanelGroup) return;
554 if(SUGAR.subpanelUtils.loadedGroups[group]){
555 SUGAR.subpanelUtils.updateSubpanel(group);
557 SUGAR.subpanelUtils.loadedGroups.push(group);
558 var needed = Array();
559 for(group_sp in SUGAR.subpanelUtils.subpanelGroups[group]){
560 if(typeof(SUGAR.subpanelUtils.subpanelGroups[group][group_sp]) == 'string' && !document.getElementById('whole_subpanel_'+SUGAR.subpanelUtils.subpanelGroups[group][group_sp])){
561 needed.push(SUGAR.subpanelUtils.subpanelGroups[group][group_sp]);
564 var success = function(){
565 SUGAR.subpanelUtils.updateSubpanelEventHandlers(needed);
566 SUGAR.subpanelUtils.updateSubpanels(group);
568 /* needed to retrieve each of the specified subpanels and install them ...*/
569 /* load them in bulk, insert via innerHTML, then sort nodes later. */
571 ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_LOADING'));
572 SUGAR.util.retrieveAndFill(SUGAR.subpanelUtils.requestUrl + needed.join(','),'subpanel_list', null, success, null, true);
574 SUGAR.subpanelUtils.updateSubpanels(group);
577 SUGAR.subpanelUtils.setGroupCookie(group);
581 /* for each child node of subpanel_list */
582 /* let subpanel name be id.match(/whole_subpanel_(\w*)/) */
583 /* if the subpanel name is in the list of subpanels for the current group, show it */
584 /* otherwise hide it */
585 /* swap nodes to suit user's order */
586 /* call updateSubpanelTabs */
588 updateSubpanels: function(group){
589 var sp_list = document.getElementById('subpanel_list');
590 for(sp in sp_list.childNodes){
591 if(sp_list.childNodes[sp].id){
592 sp_list.childNodes[sp].style.display = 'none';
595 for(group_sp in SUGAR.subpanelUtils.subpanelGroups[group]){
596 if ( typeof(SUGAR.subpanelUtils.subpanelGroups[group][group_sp]) != 'string' ) continue;
597 var cur = document.getElementById('whole_subpanel_'+SUGAR.subpanelUtils.subpanelGroups[group][group_sp]);
599 cur.style.display = 'block';
600 /* use YDD swapNodes this and first, second, etc. */
602 YAHOO.util.DDM.swapNode(cur, sp_list.getElementsByTagName('LI')[group_sp]);
607 SUGAR.subpanelUtils.updateSubpanelTabs(group);
610 updateSubpanelTabs: function(group){
611 if(SUGAR.subpanelUtils.showLinks){
612 SUGAR.subpanelUtils.updateSubpanelSubtabs(group);
613 document.getElementById('subpanelSubTabs').innerHTML = SUGAR.subpanelUtils.subpanelSubTabs[group];
616 oldTab = document.getElementById(SUGAR.subpanelUtils.currentSubpanelGroup+'_sp_tab');
618 oldTab.className = '';
619 oldTab.getElementsByTagName('a')[0].className = '';
622 mainTab = document.getElementById(group+'_sp_tab');
623 mainTab.className = 'active';
624 mainTab.getElementsByTagName('a')[0].className = 'current';
626 SUGAR.subpanelUtils.currentSubpanelGroup = group;
627 ajaxStatus.hideStatus();
630 updateSubpanelEventHandlers: function(){
631 if(SubpanelInitTabNames){
632 SubpanelInitTabNames(SUGAR.subpanelUtils.getLayout(false));
636 reorderSubpanelSubtabs: function(group, order){
637 SUGAR.subpanelUtils.subpanelGroups[group] = order;
638 if(SUGAR.subpanelUtils.showLinks==1){
639 SUGAR.subpanelUtils.updateSubpanelSubtabs(group);
640 if(SUGAR.subpanelUtils.currentSubpanelGroup == group){
641 document.getElementById('subpanelSubTabs').innerHTML = SUGAR.subpanelUtils.subpanelSubTabs[group];
646 // Re-renders the contents of subpanelSubTabs[group].
647 // Does not immediately affect what's on the screen.
648 updateSubpanelSubtabs: function(group){
650 var preMore = SUGAR.subpanelUtils.subpanelGroups[group].slice(0, SUGAR.subpanelUtils.subpanelMaxSubtabs);
652 SUGAR.subpanelUtils.subpanelSubTabs[group] = '<table border="0" cellpadding="0" cellspacing="0" height="20" width="100%" class="subTabs"><tr>';
654 for(var sp_key = 0; sp_key < preMore.length; sp_key++){
656 SUGAR.subpanelUtils.subpanelSubTabs[group] += '<td width="1"> | </td>';
660 SUGAR.subpanelUtils.subpanelSubTabs[group] += '<td nowrap="nowrap"><a href="#'+preMore[sp_key]+'" class="subTabLink">'+SUGAR.subpanelUtils.subpanelTitles[preMore[sp_key]]+'</a></td>';
662 if(document.getElementById('MoreSub'+group+'PanelMenu')){
663 SUGAR.subpanelUtils.subpanelSubTabs[group] += '<td nowrap="nowrap"> | <span class="subTabMore" id="MoreSub'+group+'PanelHandle" style="margin-left:2px; cursor: pointer; cursor: hand;" align="absmiddle" onmouseover="SUGAR.subpanelUtils.menu.tbspButtonMouseOver(this.id,\'\',\'\',0);">>></span></td>';
665 SUGAR.subpanelUtils.subpanelSubTabs[group] += '<td width="100%"> </td></tr></table>';
667 // Update the more menu for the current group
668 var postMore = SUGAR.subpanelUtils.subpanelGroups[group].slice(SUGAR.subpanelUtils.subpanelMaxSubtabs);
669 var subpanelMenu = document.getElementById('MoreSub'+group+'PanelMenu');
671 if(postMore && subpanelMenu){
672 subpanelMenu.innerHTML = '';
673 for(var sp_key = 0; sp_key < postMore.length; sp_key++){
674 subpanelMenu.innerHTML += '<a href="#'+postMore[sp_key]+'" class="menuItem" parentid="MoreSub'+group+'PanelMenu" onmouseover="hiliteItem(this,\'yes\'); closeSubMenus(this);" onmouseout="unhiliteItem(this);">'+SUGAR.subpanelUtils.subpanelTitles[postMore[sp_key]]+'</a>';
676 subpanelMenu += '</div>';
680 setGroupCookie: function(group){
681 Set_Cookie(SUGAR.subpanelUtils.tabCookieName, group, 3000, false, false,false);
686 SUGAR.subpanelUtils.menu = function(){
688 tbspButtonMouseOver : function(id,top,left,leftOffset){ //*//
689 closeMenusDelay = eraseTimeout(closeMenusDelay);
690 if (openMenusDelay == null){
691 openMenusDelay = window.setTimeout("SUGAR.subpanelUtils.menu.spShowMenu('"+id+"','"+top+"','"+left+"','"+leftOffset+"')", delayTime);
694 spShowMenu : function(id,top,left,leftOffset){ //*//
695 openMenusDelay = eraseTimeout(openMenusDelay);
696 var menuName = id.replace(/Handle/i,'Menu');
697 var menu = getLayer(menuName);
698 //if (menu) menu.className = 'tbButtonMouseOverUp';
702 SUGAR.subpanelUtils.menu.spPopupMenu(id, menu, top,left,leftOffset);
704 spPopupMenu : function(handleID, menu, top, left, leftOffset){ //*//
705 var bw = checkBrowserWidth();
706 var menuName = handleID.replace(/Handle/i,'Menu');
708 var imgWidth = document.getElementById(handleID).width;
710 var menuHandle = getLayer(handleID);
714 while(p&&p.tagName.toUpperCase()!='BODY'){
718 left+=parseInt(leftOffset);
724 while(p&&p.tagName.toUpperCase()!='BODY'){
729 if (left+menuWidth>bw) {
730 left = left-menuWidth+imgWidth;
732 setMenuVisible(menu, left, top, false);