System.Extend.League.tableNameEdit = function(selector,id,column,catId,itemId){            this.args = {        selector: selector,        id: id,        column: column,        controllerPath: System.Env.siteUrl + "controller_admin.php",        controllerAction: "action=LeagueTableNameReplace&catId="+catId+"&itemId="+itemId,        tdAction: "onClick='javascript: System.Extend.League.tableNameEdit("+'"'+selector+'","'+id+'","'+column+'","'+catId+'","'+itemId+'"'+")'"    }            new System.UI.Table.cellValueEdit(this.args);}System.Extend.League.tableAddRow = function(catId,itemId,TableInstance){    var id = '';    var checkedIDs = TableInstance.checkedItemsExists();          if(checkedIDs){        id = checkedIDs[0];    }    var progress = {};    jQuery.ajax({        beforeSend: function(){            progress = new System.UI.Windows.Progress();        },        url: System.Env.siteUrl + "controller_admin.php",         type: 'GET',        data: "action=LeagueTableAddRow&catId="+catId+"&itemId="+itemId+"&id="+id,        success: function(data){            //alert(data);            progress.destroy();            TableInstance.reset();        },        error: function(jqXHR, textStatus, errorThrown){            progress.destroy();            System.UI.Windows.Msg(errorThrown,true);                              }    });}System.Extend.League.Round.tableAddRow = function(itemId,TableInstance){    var id = '';    var checkedIDs = TableInstance.checkedItemsExists();          if(checkedIDs){        id = checkedIDs[0];    }    var progress = {};    jQuery.ajax({        beforeSend: function(){            progress = new System.UI.Windows.Progress();        },                url: System.Env.siteUrl + "controller_admin.php",         type: 'GET',        data: "action=LeagueRoundTableAddRow&itemId="+itemId+"&id="+id,        success: function(data){            //alert(data);            progress.destroy();            if(System.trim(data) == "success"){                TableInstance.reset();            }else{                System.UI.Windows.Msg(data,true);            }        },        error: function(jqXHR, textStatus, errorThrown){            progress.destroy();            System.UI.Windows.Msg(errorThrown,true);                             }    });}System.Extend.League.moveRow = function(itemId,id,dir,TableInstance,type){	if(typeof(type) == 'undefined'){type = 'league';}    if(typeof(TableInstance) == 'string'){		TableInstance = System.getVariableByName(TableInstance);	}    var action = 'action=LeagueTableMoveRow';    if(type == 'league'){        action = 'action=LeagueTableMoveRow';    }else if(type == 'round'){        action = 'action=LeagueRoundTableMoveRow';    }    var progress = {};    jQuery.ajax({        beforeSend: function(){            progress = new System.UI.Windows.Progress();        },                url: System.Env.siteUrl + "controller_admin.php",         type: 'GET',        data: action+"&itemId="+itemId+"&id="+id+"&dir="+dir,        success: function(data){			progress.destroy();            if(System.trim(data) == "success"){						TableInstance.reset();                          }else{                TableInstance.reset();				//System.UI.Windows.Msg(data,true);            }        },        error: function(jqXHR, textStatus, errorThrown){            progress.destroy();            System.UI.Windows.Msg(errorThrown,true);                             }    });}System.Extend.League.Round.moveRow = function(itemId,id,dir,TableInstance){	System.Extend.League.moveRow(itemId,id,dir,TableInstance,'round');   }System.Extend.League.Round.tableNameEdit = function(selector,id,column,catId,itemId){        var MsgTranslations = new System.Translations({id:"System",container:"Msg"});        jQuery.ajax({        url: System.Env.siteUrl + "controller_admin.php",        type: "GET",        dataType: "json",        data: "action=LeagueGetNamesList&catId="+catId+"&itemId="+itemId,        success: function(data){                this.args = {                    selector: selector,                    id: id,                    column: column,                    autocomplete: true,                    autocompleteSource: data,                    controllerPath: System.Env.siteUrl + "controller_admin.php",                    controllerAction: "action=LeagueRoundTableNameReplace&catId="+catId+"&itemId="+itemId,                    tdAction: "onClick='javascript: System.Extend.League.Round.tableNameEdit("+'"'+selector+'","'+id+'","'+column+'","'+catId+'","'+itemId+'"'+")'"                }                                    new System.UI.Table.cellValueEdit(this.args);                        },        error: function(jqXHR, textStatus, errorThrown){            if(System.trim(errorThrown) == 'Invalid JSON: error_access_denied'){                System.UI.Windows.Msg("<p class='sys-msg-err'>"+MsgTranslations['error_access_denied']+"</p><p>"+MsgTranslations['text_log_in']+"</p>",true);            }else{                System.UI.Windows.Msg("<p class='sys-msg-err'>"+errorThrown+"</p>",true);                        }        }    });    }System.Extend.League.Round.addItem = function(itemId,name,ControlsInstance){    	var MsgTranslations = new System.Translations({id:"System",container:"Msg"});                 				 				 jQuery.ajax({                    url: System.Env.siteUrl + "controller_admin.php",                    type: "GET",                    data: "action=LeagueRoundItemAdd&itemId="+itemId+"&name="+name,                    success: function(data){                        if(System.trim(data) == 'error_access_denied'){                                      							System.UI.Windows.Msg("<p class='sys-msg-err'>"+MsgTranslations[data]+"</p><p>"+MsgTranslations['text_log_in']+"</p>",true);                         						}else if(System.trim(data) == "success"){                            ControlsInstance.reset();                                 }else{                            System.UI.Windows.Msg(data,true);                        }                    },                    error: function(jqXHR, textStatus, errorThrown){                        System.UI.Windows.Msg(errorThrown,true);                           }                                     });}System.Extend.League.Round.Controls = function(argsObj){        var self = this;    var UITranslations = new System.Translations({id:"UI"});    var LgTranslations = new System.Translations({id:"league"});    var MsgTranslations = new System.Translations({id:"System",container:"Msg"});		this.utilWindow = {};        this.args = {        autoInit: true,        controllerPath: System.Env.siteUrl + "controller_admin.php"    }        for(i in argsObj){this.args[i] = argsObj[i];}        var nameContainerSelector = "#Liga_"+this.args.catId+"_"+this.args.itemId+"_Round_Name";    //alert(nameContainerSelector);    var Table = self.args.table;     var ID = System.generateID();    var selectorSelect = "round_select_"+ID;    var selectorBtnAdd = "round_btn_add"+ID;    var selectorBtnSelect = "round_btn_change_"+ID;    var selectorBtnDelete = "round_btn_delete_"+ID;    var selectorBtnPublicDefId = "round_btn_public_def_id_" + ID;    var self = this;    this.init = function(errors){		if(typeof(errors) == 'undefined'){errors = true;}        self.html = '<button id="'+selectorBtnAdd+'">'+UITranslations.btnAdd+'</button>';           self.html += '<button id="'+selectorBtnDelete+'">'+UITranslations.btnDel+'</button>';            self.html += '<select style="margin-left:5px;margin-right:5px;" name="'+selectorSelect+'">';          jQuery.ajax({            url: self.args.controllerPath,            type: "GET",            dataType: "json",            data: "action=GetLeagueRoundItems&itemId="+self.args.itemId,            success: function(data){                for(var i=0;i<data.length;i++){                    self.html += '<option value="'+data[i].id+'">'+data[i].name+'. '+LgTranslations.round+'</option>';                }                self.html += '</select>';                   self.html += '<button id="'+selectorBtnSelect+'">'+UITranslations.btnSelect+'</button>';                                   jQuery(self.args.container).html(self.html);                   //self.nameUpdate(errors);                self.events(); 				self.Events.selectAction();            },            error: function(jqXHR, textStatus, errorThrown){				if(errors == true){					if(System.trim(errorThrown) == 'Invalid JSON: error_access_denied'){						System.UI.Windows.Msg("<p class='sys-msg-err'>"+MsgTranslations['error_access_denied']+"</p><p>"+MsgTranslations['text_log_in']+"</p>",true);					}else{						System.UI.Windows.Msg("<p class='sys-msg-err'>"+errorThrown+"</p>",true);            					}				}            }                    });    }        this.nameUpdate = function(errors){		self.setRoundId();        if(typeof(errors) == 'undefined'){errors = true;}        jQuery(nameContainerSelector).html(" "+System.UI.Elements.Loaders["LoaderFBSmallGrey"]);                 jQuery.ajax({            url: self.args.controllerPath,             type: "GET",               data: "action=GetLeagueRoundName&id="+Table.DataContainer.roundId,            success: function(data){                var name = System.trim(data);                if(name == 'error_access_denied'){                                       					if(errors == true){						System.UI.Windows.Msg("<p class='sys-msg-err'>"+MsgTranslations[data]+"</p><p>"+MsgTranslations['text_log_in']+"</p>",true); 					}				}else if(name == ('0' || 0)){                    name = ' -';                }                if(name != "error" && name != "error_access_denied"){                    jQuery(nameContainerSelector).html(" "+name);                }else{                    jQuery(nameContainerSelector).html(" -");                                    }            },            error: function(jqXHR, textStatus, errorThrown){                System.UI.Windows.Msg(errorThrown,true);                   }                    });              }    	this.setRoundId = function(){		Table.DataContainer.roundId = jQuery("[name="+selectorSelect+"] option:selected").val();	}		    this.Events = {		selectAction: function(){                self.setRoundId();                Table.args.controllerActionTable = "action=LeagueRoundTableContent&catId="+self.args.catId+"&itemId="+self.args.itemId+"&id="+Table.DataContainer.roundId;                jQuery("#"+Table.args.tableHolderID).children().remove();                //jQuery("#"+Table.args.loaderHolderID).children().remove();                self.nameUpdate(false);                Table.reset();				},        select: function(){            jQuery("#"+selectorBtnSelect).click(function(){               				self.Events.selectAction();            });                 },		addAction: function(){                 var addInputSelector = "round_input_"+ID;                 var utilWindowHtml = '<div style="width:100%;padding-top:20px;text-align:center;"><input type="text" size="11" id="'+addInputSelector+'"/></div>';                 var buttons = {};                 buttons[UITranslations.btnSave] = function(){                    var name = jQuery("#"+addInputSelector).val();                    System.Extend.League.Round.addItem(self.args.itemId,name,self);                    self.utilWindow.close();                 }                 self.utilWindow = new System.UI.Window(utilWindowHtml,{                    title: LgTranslations.newRound,                    buttons: buttons,                    modal: true,					onClose: function(){						//self.Events.selectAction();					}                 });				},        add: function(){           jQuery("#"+selectorBtnAdd).click(function(){				self.Events.addAction();            });                },		delAction: function(){                 var delContainerId = "round_del" + ID;                 var delContainerSelector = "#" + delContainerId;                 var delLoaderId = "round_del_loader" + ID;                 var delLoaderSelector = "#" + delLoaderId;                 var delWindowHtml = '<div style="width:100%;padding-top:20px;text-align:center;" id="'+delContainerId+'">'/*+'<div id="'+delLoaderId+'">'+System.UI.Elements.Loaders["32Red"]+'</div>'*/;                    delWindowHtml += '<div id="'+"round_items_table_wrap" + ID +'">';                        delWindowHtml += '<table class="UI-table-top"><tr>';                        delWindowHtml += '<td><div class="UI-table-loader" id="'+"round_items_table_loader_" + ID+'"></div></td>';                        delWindowHtml += '</tr></table>';                                               delWindowHtml += '<div id="'+"round_items_table_" + self.args.catId + "_" + self.args.itemId + '"></div>';                    delWindowHtml += '</div>';                 delWindowHtml += '</div>';                 var buttons = {};                 var tableName = "Rounds"+self.args.catId+self.args.itemId+"Table";                 buttons[UITranslations.btnDel] = function(){                    window[tableName].deleteChecked();                 }                 self.utilWindow = new System.UI.Window(delWindowHtml,{                    title: LgTranslations.deleteRounds,                    buttons: buttons,                    modal: true,                    onOpen: function(){                        self.getRoundItemsTable(tableName);                    },                    onClose: function(){						//self.Events.selectAction();						self.reset(false);                    }                 });					},        del: function(){            jQuery("#"+selectorBtnDelete).click(function(){        				self.Events.delAction();            });                  }    }            this.events = function(){						this.Events.select();			this.Events.add();			this.Events.del();            }        this.getRoundItemsTable = function(tableObjName){            //var tableObjName = "Rounds"+self.args.catId+self.args.itemId+"Table";        var tableHolderId = "round_items_table_" + self.args.catId + "_" + self.args.itemId;        var tableId = "rounds_table_" + self.args.catId + "_" + self.args.itemId;        var tablePaginationId = "round_items_table_pagination_" + ID;        var tableLoaderId = "round_items_table_loader_" + ID;        var tableSelector = "#" + tableId;        var tableHolderSelector = "#" + tableHolderId;        var tablePaginationSelector = "#" + tablePaginationId;        var tableLoaderSelector = "#" + tableLoaderId;                var TableArgs = {            controllerScriptPath : self.args.controllerPath,            paginationHolderID : tablePaginationId,            tableHolderID : tableHolderId,            loaderHolderID: tableLoaderId,            itemsCheckSelector: "td.UI_table-cell-check",            paginate: false,            //controllerActionPagination : "action=GetLeagueRoundsTableContent&tableObj="+"RoundsTable" + ID+"&catId="+self.args.catId+"&itemId="+self.args.itemId,            controllerActionTable : "action=LeagueRoundItemsTableContent&catId="+self.args.catId+"&itemId="+self.args.itemId,            controllerActionItemsDelete : "action=LeagueRoundItemsTableItemsDelete&catId="+self.args.catId+"&itemId="+self.args.itemId,            customErrors : true,            debug:false,            onAfterInit: function(){            },			onError: function(){				self.utilWindow.close();			}        }                window[tableObjName] = new System.UI.Table(TableArgs);                   }        this.reset = function(errors){		if(typeof(errors) == 'undefined'){errors = true;}        self.fade('out');        self.init(errors);        self.fade('in');    }        this.fade = function(dir){        if(dir == 'out'){            jQuery(self.args.container).animate({opacity:0.5});        }else if(dir == 'in'){            jQuery(self.args.container).animate({opacity:1});        }    }            if(this.args.autoInit){        this.init();    }    }/*System.Extend.League.Round.Controls = function(argsObj){        var self = this;        this.args = {        selector: "",        catId = "",        itemId = "",        controllerPath: System.Env.siteUrl + "controller_admin.php",    }           for(i in argsObj){this.args[i] = argsObj[i];}         this.ID = System.generateID();    this.selectID = "UI_select_"+this.ID;    this.html = '';        this.        this.init = function(){        jQuery(self.args.selector).html(System.UI.Elements.Loaders["LoaderFBSmallGrey"]);        self.html += '<select id="'+self.selectID+'">';        jQuery.ajax({            url: self.args.controllerPath,            type: "GET",            data: "action=GetLeagueRounds&catId="+self.args.catId+"&itemId="+self.args.itemId,            success: function(data){                        },            error: function(jqXHR, textStatus, errorThrown){                            }        });        jQuery.ajax({            url: self.args.controllerPath,            type: "GET",            data: self.args.controllerAction+"&catId="self.args.catId+"&itemId="+self.args.itemId,            success: function(data){                alert(data);                            },            error: function(jqXHR, textStatus, errorThrown){                            }        });        self.html += '</select>';     }        if(self.args.autoInit){        self.init();    }}*/
