/*
dialogues.js
    dialogue manager for the Agility CMS 

*/

//presentDialogue: displays dialogue to user
function presentDialogue(paramTitle,paramMessage,paramConfirm, paramCancel, payload){
    //alert('presentDialogue');
    //setup the dialogue caption
    $('#dialogue h2').text(paramTitle);
    $("#payload").val(payload);
    $("#result").val('0'); // default to 'cancel or false'
    $("#actionConfirm").val(paramConfirm); // function to call if dialogue is confirmed
    $("#actionCancel").val(paramCancel); // function to call if dialogue is cancelled
    $("#dialogue input.no").bind('click',function(){handleDialogueResponse(paramCancel);});
    $("#dialogue input.yes").bind('click',function(){handleDialogueResponse(paramConfirm);});
    $('#dialogue p.message').html(paramMessage);
    //alert("prepare api / overlay");
//display the modal dialogue
/*
    var api=$("#dialogue").overlay({
        	// some expose tweaks suitable for facebox-looking dialogs
            effect: 'apple',
            speed: 'fast',
        	expose: {
        		color: '#000',
        		loadSpeed: 200,
        		opacity: 0.5
        	},
            close: $('#dialogue input.no'),
        	closeOnClick: false,
        	api: true
        });
        
        

        api.load();
*/
$("#dialogue").overlay({
            effect: 'apple',
            speed: 'fast',
            
        	expose: {
        		// you might also consider a "transparent" color for the mask
        		color: '#000',
        		// load mask a little faster
        		loadSpeed: 200,
        		// highly transparent
        		opacity: 0.5
        	},
        	// disable this for modal dialog-type of overlays
            close: $('#dialogue input.no'),
        	closeOnClick: true,
            api: true
        // load it immediately after the construction
        }).load();

//});



return void[0];
}

// confirmDelete: handles the preparation of a confirm delete dialogue
function confirmDelete(paramConfirm,paramID,optionalTitle, optionalMessage, optionalCallback){

    var url=$('#base').val();
    var params=''






    var title='Please confirm';
//    alert(title);
    if (arguments.length==3){
        title=optionalTitle;
    }
    
    var message='Are you sure you want to delete this record ?';
    if (arguments.length==4){
        message=optionalMessage;
    }
    $("#dialogue input.no").attr('value','no');
    $("#dialogue input.yes").attr('value','yes');
    $("#record").val(paramID);
    $("#actionCallback").val(optionalCallback);
    presentDialogue(title,message,'executeDelete();','cancelDelete();',params)
    return void[0];
}


//presentResult: performs ajax 'get' using params and populates the panel that is subsequently rendered
function presentResult(paramCaption,params){
    //setup the dialogue caption
    $('#dialogue h2').text(paramCaption);
    $("#dialogue input.no").hide();
    $("#dialogue input.yes").attr('value','close');
    $("#dialogue input.yes").bind('click',function(){handleDialogueResponse("javascript: void[0];");});
    $('#dialogue p.message').html('');
//display the modal dialogue
    var api=$("#dialogue").overlay({
        	// some expose tweaks suitable for facebox-looking dialogs
            effect: 'apple',
            speed: 'fast',
        	expose: {
        		color: '#000',
        		loadSpeed: 200,
        		opacity: 0.5
        	},
        	closeOnClick: true,
            onLoad: function(){
                   var d=new Date();
                   var url=$('#base').val() + "v2010/ajax.asp"
                   var data=params + '&KAV=' + d.toString()
                   var errorURL=url + "?" + data;
 //window.location.href=errorURL
                $('#dialogue p.message').load(url,data, function(response, status, xhr){  
                     if (status=='error')
                     { // handle error messaging here
                        // if in development environment we redirect to the url so we can get an idea of what the problem is
                        window.location.href=errorURL
                        
                     }
                     else
                     {//proceed with handling the results
                        
                     }
                
                });
            },
        	api: true
        });
        
        api.bind('onBeforeClose',function(){});

        api.load();


return void[0];

}

//executeDelete: execute the delete routine
function executeDelete(){
    //alert("executeDelete");
    var paramID=$('#record').val(); 
    var optionalCallback= $("#actionCallback").val(); 
    var d=new Date();
    var target='#dump';
    var url=$('#base').val() + "v2010/ajax.asp"
    var data=$('#payload').val() + '&KAV=' + d.toString()
    var errorURL=url + "?" + data;
     if ($('#debugSave').length){
        if ($('#debugSave').attr('checked')==true){
                openExternalTool(errorURL);
                 return void[0];
        }
     }      

    //window.location.href=errorURL;
    //return void[0];
    //alert(data);
      $(target).load(url,data, function(response, status, xhr){      
                 if (status=='error')
                 { // handle error messaging here
                    // if in development environment we redirect to the url so we can get an idea of what the problem is
                    window.location.href=errorURL
                    
                 }
                 else
                 {//proceed with handling the results
                    if ($('#row' + paramID).length){
                        $('#row' + paramID).slideUp('fast');
                    }
                    if (optionalCallback!=''){
                        eval(optionalCallback);
                    }
                 }
         });
         return void[0];
    
}
//cancelDelete: cancel the delete function
function cancelDelete(){
    $("#result").val('0');  
}





//handleDialogueResponse: switchboard that gets triggered when user exits a modal dialogue
function handleDialogueResponse(paramContext){
    
  //alert(paramContext);
  eval(paramContext);  
    $("#dialogue input.no").unbind();
    $("#dialogue input.yes").unbind();
    $("#dialogue").overlay().close();

}

//toggleState: changes status of item from 'oldstate' to 'newstate' and updates icon & href accordingly
function toggleState(params,paramID){
    var d=new Date();
    var a='#state' + paramID;
    var url=$('#base').val() + "v2010/ajax.asp"
    var data=params + '&KAV=' + d.toString()
    var errorURL=url + "?" + data;
    var target='#dump';
     if ($('#debugSave').length){
        if ($('#debugSave').attr('checked')==true){
                openExternalTool(errorURL);
                 return void[0];
        }
     }      
    $.getJSON(errorURL, function(data) {
    
                 if (data.errors==1)
                 { // handle error messaging here
                    // if in development environment we redirect to the url so we can get an idea of what the problem is
                    alert(data.errorMessage);
                   // window.location.href=errorURL
                 }
                 else
                 {//proceed with handling the results
                        if ($(a).hasClass('state0')){
                                //currently 'off' 
                                $(a).removeClass('state0').addClass('state1');
                        }
                        else
                        {
                                //currently on
                                $(a).removeClass('state1').addClass('state0');
                        }
                    
                 }
      });
    

}


//manageXreferences: slides up a dialogue to enable management of xreferences
function manageXreferences(params,paramID, paramLoad,paramSubmit){
    
    var d=new Date();
    var target='#ajaxInteractive';
    var url=$('#base').val() + "v2010/ajax.asp"
    var data=params + '&KAV=' + d.toString()
    var errorURL=url + "?" + data;
    //window.location.href=errorURL
      $(target).load(url,data, function(response, status, xhr){      
                 if (status=='error')
                 { // handle error messaging here
                    // if in development environment we redirect to the url so we can get an idea of what the problem is
                    window.location.href=errorURL
                    
                 }
                 else
                 {
                 // alert("here");
                 //overlay dialogue
                         $(target).overlay({
                                    effect: 'apple',
                                    speed: 'fast',
                                	expose: {
                                		color: '#000',
                                		loadSpeed: 200,
                                		opacity: 0.5
                                	},
                                    //close: '.wrapButtons .cancelButton',
                                    onLoad: function(){ 
                                       // alert("here");
                                        
                                         $('.wrapButtons input.cancelButton').bind('click',function(){
                                            $('.wrapLHSScroll ul').sortable( "destroy");
                                            $(target).overlay().close();
                                          });                        
        
                                            if (paramSubmit.length!=0){
                                                $('#sortForm').submit(function(){
                                                    
                                                    if (eval(paramSubmit)){
                                                        generic_refresh_listing();
                                                        //api.close();
                                                    }
                                                    $(target).overlay().close();
                                                    return false;
                                                }); 
                                             }//end test if paramSubmit is valid
                                            eval(paramLoad);
                                    }, 
                                	closeOnClick: false,
                                    api: true
                                	
                                }).load();
                 }
         });
         return void[0];




}

//displayImage: simply pops the relevant image up into an ajax panel

function displayImage(paramImage){
    
    
    var target='#ajaxInteractive';
    var img='<p class="wrapImage"><img src="' + paramImage + '" alt="" /></p>'
    img+='<p class="wrapLink"><a href="javascript: closeAPI(\'#ajaxInteractive\');">close this panel</a></p>';
    //window.location.href=errorURL
    $(target).html(img);
                    var api=$(target).overlay({
                            effect: 'apple',
                            speed: 'fast',
                        	expose: {
                        		color: '#000',
                        		loadSpeed: 200,
                        		opacity: 0.5
                        	},
 
                        	closeOnClick: true,
                        	api: true
                        });
                        api.load();
       
         return void[0];
}

//closeAPI: closes an overlay
function closeAPI(paramOverlay){
    //var api=$(paramOverlay).overlay()
    //api.unbind('onBeforeClose');
    //api.unbind('onLoad');
    //$(paramOverlay).overlay().unbind();
    $(paramOverlay).overlay().close();
}



// sortConsole: handles the preparation of a 'sort items' dialogue
function sortConsole(params,paramID,saveParams, optionalCallback){
    var d=new Date();
    var target='#ajaxInteractive';
    var url=$('#base').val() + "v2010/ajax.asp"
    var data=params + '&KAV=' + d.toString()
    var errorURL=url + "?" + data;
    //window.location.href=errorURL
      $(target).load(url,data, function(response, status, xhr){      
                 if (status=='error')
                 { // handle error messaging here
                    // if in development environment we redirect to the url so we can get an idea of what the problem is
                    window.location.href=errorURL
                    
                 }
                 else
                 {
                 //overlay dialogue
                 //alert(target);
                    $(target).overlay({
                            effect: 'apple',
                            speed: 'fast',
                        	expose: {
                        		color: '#000',
                        		loadSpeed: 200,
                        		opacity: 0.5
                        	},
                            onLoad:function(){
                                $('#params').val(params.replace('_sort','_saveSort'));
                               // $('.wrapScroll ul').unbind();
                                $('.wrapButtons input.cancelButton').bind('click',function(){
                                    $(target).overlay().close();
                                });                        
                                $('#sortForm').submit(function(){
                                                      if (postSortables()){
                                                        generic_refresh_listing();
                                                      }
                                                      $(target).overlay().close();
                                                      return false;
                                                      });//end handle submit
                                
                        
                                $('.wrapScroll ul').sortable();
                        
                            }, 
                        	closeOnClick: false,
                        	api: true
                        }).load();
                 }
         });
         return void[0];


}

//makeSortable: 
function makeSortable(){
  //  $('.dataListingArea ul').sortable();
}

//
function postSortables(){
    //loops through sortables
    var url=$('#base').val() + "v2010/ajax.asp"
    var base=$('#params').val()
    var data='';
    var d=new Date();
    var errorURL='';
    $('.wrapSort li').each(function(i){
        data=base + '&recordid=' + $(this).attr('id').replace('item','') + '&sequence=' + i + '&KAV=' + d.toString() 
        //alert(data);
        errorURL=url + '?' + data
        $.get(url,data);
    })
    return true;
}




// mediaConsole: handles the preparation of the 'asset management' dialogue
function mediaConsole(params,paramID){
    var d=new Date();
    var target='#ajaxInteractive';
    var url=$('#base').val() + "v2010/ajax.asp"
    var data=params + '&KAV=' + d.toString()
    var errorURL=url + "?" + data;
      if ($('#debugPanel').length){
         var html=$('#debugPanel').html() + '<br/><strong>mediaConsole</strong><br/>';
         html+='param_url: <a href="' + errorURL + '">click for url</a><br/>';
         html+='params: ' + params + '<br/>';
         html+='paramID: ' + paramID + '<br/>';
         $('#debugPanel').html(html);
      
      }
    //window.location.href=errorURL
      $(target).load(url,data, function(response, status, xhr){      
                 if (status=='error')
                 { // handle error messaging here
                    // if in development environment we redirect to the url so we can get an idea of what the problem is
                    window.location.href=errorURL
                    
                 }
                 else
                 {
                 //overlay dialogue
                 //alert(target);
                    $(target).overlay({
                            effect: 'apple',
                            speed: 'fast',
                        	expose: {
                        		color: '#000',
                        		loadSpeed: 200,
                        		opacity: 0.5
                        	},
                            
                            onLoad:function(){
                                        //bind to the close function
                                         $('#exit').bind('click',function(){
                                            $(target).overlay().close();
                                          });                        
                            
                            }, 
                        	closeOnClick: false,
                        	api: true
                        }).load();
                 }
         });
         return void[0];


}





//editConsole: setup and activate editing dialogue 
function editConsole(params){
        var target='ajax_results';
        //alert(params);
        generic_populate_panel('', params, target, 'setupTinyMCE();')
        return void[0];
}


//setupTinyMCE: create the html editor interface
function setupTinyMCE(){
    var css=$('#fck_css').val();
    var toolBar=$('#html_editor_to_use').val(); //defines what toolbar options are available
    //switch based on toolbar - here before creating editor
		$('textarea.tinymce').tinymce({
			// Location of TinyMCE script
			script_url : $('#base').val() + 'v2010/js/tinymce/jscripts/tiny_mce/tiny_mce.js',
            //document_base_url : $('#base').val() + 'v2010/',
			// Example content CSS (should be your site CSS)
			content_css : css,
			// General options
			theme : "advanced",
            body_id : "cms",
            width: "100%",
            height: "400px",
			plugins : "pagebreak,style,table,advhr,emotions,iespell,inlinepopups,insertdatetime,media,searchreplace,print,contextmenu,paste,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,advlist",
                        
                        
            			// Theme options
            			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,link,unlink,image,code,|,cut,copy,pastetext,|,insertdate,inserttime,|,bullist,numlist,|,justifyleft,justifycenter,justifyright,justifyfull,|,undo,redo,forecolor,backcolor,|,styleselect,|,fullscreen",
            			theme_advanced_buttons2 : "formatselect,|,search,replace,|,outdent,indent,|,tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,media,advhr,|,print",
            			theme_advanced_buttons3 : "",
//            			theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute",
            			theme_advanced_toolbar_location : "top",
            			theme_advanced_toolbar_align : "left",
            			theme_advanced_statusbar_location : "bottom",
            			theme_advanced_resizing : true,
                        
            
            			// Drop lists for link/image/media/template dialogs
            			//template_external_list_url : "lists/template_list.js",
            			//external_link_list_url : "lists/link_list.js",
            			//external_image_list_url : "lists/image_list.js",
            			//media_external_list_url : "lists/media_list.js",
            
            			// Replace values for the template plugin
            			template_replace_values : {
            				username : "Some User",
            				staffid : "991234"
            			}
            
            
            
		});
        //$.tinymce()
        

    if ($('.seoWrap').length){
        var captionSource=$('#seoCaptionSource').val();
        var narrativeSource=$('#seoNarrativeSource').val();
        $('#' + captionSource).bind('keyup',function(){
            $('#seopreviewtitle').text($(this).val());
        });
         $('#' + narrativeSource).bind('keyup',function(){
            
            if ($(this).val().length <=154){
                $('#seopreviewnarrative').text($(this).val());
            }
            
        });
        
    }
    //capture any payloads for elements that have to be synchronised
    $('#cancelButton').bind('click',function(e){
        e.preventDefault();
       // $('textarea.tinymce').remove();
       $("textarea.tinymce").each(function(index) {
               //alert($(this).attr('id'));
                    var c=tinyMCE.get($(this).attr('id')).getContent();
                    //alert(c);
                    tinyMCE.get($(this).attr('id')).remove();
					$(this).remove();             
            });
       
        eval('generic_refresh_listing();');
    });
    synchroniseFormPayloads();
    
    
}



//setupEditor: ensure that editing dialogue is configured
function setupEditor(){
    setupTinyMCE();
    return void[0];
    //alert("setup editing dialogue");
    var css=$('#fck_css').val();
    var toolBar=$('#html_editor_to_use').val();
    
   // alert(css);
    $('#txtHTML').ckeditor(function(){hackEditor();},
     {
        toolbar : toolBar,
        bodyId : 'cms',
        bodyClass : 'noborders',
        contentsCss : css
     });

    $('#cancelButton').bind('click',function(e){
        e.preventDefault();
        cleanUpEditors();
        eval('generic_refresh_listing();');
    });
    
    if ($('.seoWrap').length){
        var captionSource=$('#seoCaptionSource').val();
        var narrativeSource=$('#seoNarrativeSource').val();
        $('#' + captionSource).bind('keyup',function(){
            $('#seopreviewtitle').text($(this).val());
        });
         $('#' + narrativeSource).bind('keyup',function(){
            if ($(this).val().length <=154){
                $('#seopreviewnarrative').text($(this).val());
            }
            
        });
        
    }
    //capture any payloads for elements that have to be synchronised
    synchroniseFormPayloads();
    
    //setup tab tracking so that user can 'see' which element the focus is on
    //setupEditorTabTracking();
    //alert("here");
    return void[0];

}


//synchroniseFormPayloads: capture any payloads for elements that have to be synchronised
function synchroniseFormPayloads(){
    $('#save :input.datapayload').each(function( e, item ){
        var synchElement='#input' + $(this).attr('id').replace('Data','');
        //alert(synchElement);
        $(synchElement).val($(this).val());
        
    });
    //check for 'link type' special handler required
    if ($('#inputLinkTypeSelector').length){
            var linkTypes = ['_linkToContentAreas', '_linkToBrands', '_linkToCategories','_linkToCollections','_linkToDepartments','_linkToProducts','_linkToPromotions','_linkToThemes', '_linkToCWSCategory', '_linkToCWSDistillery', '_linkToCWSProduct', '_linkToCWSBrand', '_linkToCWSCountry', '_linkToCWSGroup', '_linkCWSContentAreas','_linkToMedia','_linkToExternal'];
            var linkValues= ['recordid','brand','category','collection','department','product','promotion','theme', 'catalogue','distillery','brand','country','group', 'recordid' ,'iamges' ,'http']
            var linkInformation=$('#inputLinkTypeSelectorData').val().toString();
            //alert(linkInformation);
            //for backwards compatibility we need to test if this data payload uses the pre-2009 format of sourceKey and sourceID
            if ((linkInformation.length==0) && ($('#inputLinkTypeSelectorDataType').length)){
                //this is possibly the old format, further checking
                if (parseInt($('#inputLinkTypeSelectorDataID').val()) !=0){
                    // source id > 0 ==> $('#inputLinkTypeSelectorDataType).val()='_linkToContentAreas'
                    if ($('#inputLinkTypeSelectorDataType').val()=='_linkToContentAreas'){
                        dialogueMatchLinkTypeID(parseInt($('#inputLinkTypeSelectorDataID').val()));
                    }
                }
                
                return false;
            }
            
            
             jQuery.each(linkValues, function(index, value) {
                    //alert(value);
                    var patt1=new RegExp(value);
                    if (patt1.test(linkInformation)){
                        dialogueMatchLinkType(linkTypes[index])
                        return false;
                    }
                    //fail safe; if we get to here then the link type did not match pre-defined patterns so default to external link
                    dialogueMatchLinkType('_linkToExternal');
             });
             return false;            
        
    }

}

  //dialogueMatchLinkType: loop thru' contents of the typeOfLink list and select the appropriate match (if any)
  function dialogueMatchLinkType(str){
        var patt1=new RegExp(str);
        var linkInformation=$('#inputLinkTypeSelectorData').val();
        $('option',$('#inputLinkTypeSelector')).each(function(){
            var u=$(this).val();
            //alert(u);
            if (patt1.test(u)){
                $('#inputLinkTypeSelector').val($(this).val());
                 var html='<span style="margin: 0 24px;">please wait ... loading</span><span><img src="spinner.gif" alt="please wait a moment" style="border:0px;"/></span>';
                 $('#inputLinkTypeSelectorOptions').html(html);
                
                $('#inputLinkTypeSelectorOptions').load(u, function(){
               //match the url
                     $('#linkMapList').val(linkInformation);
                });
                return true;
            }
        });
        return false;
  }

   //dialogueMatchLinkTypeID: loop thru' contents of the typeOfLink list and select the appropriate match 
  function dialogueMatchLinkTypeID(paramID){
        var patt1=new RegExp("_linkToContentAreas");
        var linkInformation='';
        $('option',$('#inputLinkTypeSelector')).each(function(){
            var u=$(this).val();
            //alert(u);
            if (patt1.test(u)){
                $('#inputLinkTypeSelector').val($(this).val());
                 var html='<span style="margin: 0 24px;">please wait ... loading</span><span><img src="spinner.gif" alt="please wait a moment" style="border:0px;"/></span>';
                 $('#inputLinkTypeSelectorOptions').html(html);
                
                $('#inputLinkTypeSelectorOptions').load(u, function(){
               //match the url
                     var patt2=new RegExp("recordid-" + paramID);
                     $('option',$('#linkMapList')).each(function(){
                            var u=$(this).val();
                            if (patt2.test(u)){
                                linkInformation=u
                            }
                        });                        
                     $('#linkMapList').val(linkInformation);
                });
                return true;
            }
        });
        return false;
  }



//setupEditorTabTracking:setup tab tracking so that user can 'see' which element the focus is on
function setupEditorTabTracking(){
    $('#save :input').each(function( e, item ){
        var elementClassName=$(this).attr('class');
        switch (elementClassName){
            case '': // no class specified so ignore
                break;
            default: //follow focus / blur events
                $(this).bind('focus',function(){
                    $(this).closest('tr').toggleClass('focused');
                });
                $(this).bind('blur',function(){
                    $(this).closest('tr').removeClass('focused');
                });
            
        }
    
    
    });//end loop thru elements
}


//hackEditor: disable tabs on the link dialogue
function hackEditor(){
//alert("here");
//return void[0];
CKEDITOR.on( 'dialogDefinition', function( ev )
	{
		// Take the dialog name and its definition from the event data.
		var dialogName = ev.data.name;
		var dialogDefinition = ev.data.definition;
 
		// Check if the definition is from the dialog we're
		// interested on (the Link dialog).
		if ( dialogName == 'link' )
		{
			// FCKConfig.LinkDlgHideAdvanced = true
			dialogDefinition.removeContents( 'advanced' );
 
			// FCKConfig.LinkDlgHideTarget = true
			dialogDefinition.removeContents( 'target' );
/*
Enable this part only if you don't remove the 'target' tab in the previous block.
 
			// FCKConfig.DefaultLinkTarget = '_blank'
			// Get a reference to the "Target" tab.
			var targetTab = dialogDefinition.getContents( 'target' );
			// Set the default value for the URL field.
			var targetField = targetTab.get( 'linkTargetType' );
			targetField[ 'default' ] = '_blank';
*/
		}
 
		if ( dialogName == 'image' )
		{
			// FCKConfig.ImageDlgHideAdvanced = true	
			dialogDefinition.removeContents( 'advanced' );
			// FCKConfig.ImageDlgHideLink = true
			dialogDefinition.removeContents( 'Link' );
		}
 
		if ( dialogName == 'flash' )
		{
			// FCKConfig.FlashDlgHideAdvanced = true
			dialogDefinition.removeContents( 'advanced' );
		}
 
	});
    
    
}


//genericDialogue: populates ajaxInteractive with whatever is requested in 'params'
function genericDialogue(params,paramOnLoad,paramForm, paramSubmit){
    var d=new Date();
    var target='#ajaxInteractive';
    var url=$('#base').val() + "v2010/ajax.asp"
    var data=params + '&KAV=' + d.toString()
    var errorURL=url + "?" + data;
    //window.location.href=errorURL
      $(target).load(url,data, function(response, status, xhr){      
                 if (status=='error')
                 { // handle error messaging here
                    // if in development environment we redirect to the url so we can get an idea of what the problem is
                    window.location.href=errorURL
                    
                 }
                 else
                 {
                 // alert("here");
                 //overlay dialogue
                         $(target).overlay({
                                    effect: 'apple',
                                    speed: 'fast',
                                	expose: {
                                		color: '#000',
                                		loadSpeed: 200,
                                		opacity: 0.5
                                	},
                                    //close: '.wrapButtons .cancelButton',
                                    onLoad: function(){ 
                                         $('.wrapButtons input.cancelButton').bind('click',function(){
                                            $(target).overlay().close();
                                          });                        
                                          if (paramOnLoad.length!=0){eval(paramLoad);}
                                          if (paramForm.length!=0){
                                                $(paramForm).submit(function(){
                                                    
                                                    if (eval(paramSubmit)){
                                                        generic_refresh_listing();
                                                    }
                                                    else{
                                                        return false;
                                                    }
                                                    $(target).overlay().close();
                                                    return false;
                                                }); 
                                             }//
                                    }, 
                                	closeOnClick: false,
                                    api: true
                                	
                                }).load();
                 }
         });
         return void[0];

}



