function BackgroundWorkNotifier(){this.TIMEOUT=2E3;this.timer=this.task=null;this.appendTask=function(c){this.task=c;$("#notifier .notifier-message").text(c);c=($(document).width()-$("#notifier").width())/2;$("#notifier").css("left",c+"px");c=this;this.timer=window.setTimeout(function(){$("#notifier").animate({top:"0px"},"slow")},this.TIMEOUT)};this.removeTask=function(){if(this.task){if(this.timer!=null){window.clearTimeout(this.timer);this.timer=null}$("#notifier").offset().top>-$("#notifier").height()&&
$("#notifier").animate({top:"-"+$("#notifier").height()+"px"});this.task=null}}}function ModalDialog(){this.error=function(c){$("#dlg_error .content").html(c);$("#dlg_error").modal({opacity:60,overlayCss:{backgroundColor:"#3B5A9B"}})};this.info=function(c){$("#dlg_info .content").html(c);$("#dlg_info").modal({opacity:60,overlayCss:{backgroundColor:"#3B5A9B"}})};$("#dlg_info .footer input").click($.modal.close);$("#dlg_error .footer input").click($.modal.close)}
function connectServer(c,b,e,d){$.ajax({type:"POST",url:c,dataType:"json",data:b,error:d,success:e})};var TIMER_TICK=3E3;
function UserProfile(c){this.logged=c.logged;this.login_url=c.login_url;this.logout_url=c.logout_url;this.username=c.nickname;this.userid=c.user_id;this.uwindowsets=[];this.__addUserWindowSet=function(d,a){d=new UserWindowSet(this,d);this.uwindowsets.push(d);$("#"+d.webid).after($("#newTabButton"));a&&d.select()};this.addUserWindowSet=function(d,a){notifier.appendTask("Adding new empty window list.");d.windows=[];d.sequence_num=this.uwindowsets.length>0?this.uwindowsets[this.uwindowsets.length-1].sequence_num+
1:0;if(this.logged){var f=this;connectServer("/uws/add",d,function(g){if(g.status=="Well"){d.id=g.data;f.__addUserWindowSet(d,a);notifier.removeTask()}else{notifier.removeTask();dialog.error(g.data)}},function(g,h,i){notifier.removeTask();dialog.error("There was an error while adding a new tab: "+(h||i)+". Please try again.")})}else{d.id=-100-d.sequence_num;this.__addUserWindowSet(d,a);notifier.removeTask()}};this.__deleteUserWindowSet=function(d){d=$.inArray(d,this.uwindowsets);assert(d>=0,"ind >= 0");
if(d<0)dialog.error("Tab not found.","message=tab was not found while deleting");else{this.uwindowsets[d].__remove();this.uwindowsets.splice(d,1);d>=this.uwindowsets.length&&d--;assert(d>=0&&d<this.uwindowsets.length,"ind >= 0 && ind < this.uwindowsets.length");this.uwindowsets[d].select()}};this.deleteUserWindowSet=function(d){if(this.uwindowsets.length<=1)dialog.info("You can't remove your only list.");else if(d.deleting)dialog.error("This set is being deleted. Please wait for server response.");
else{d.deleting=true;notifier.appendTask("Deleting window list...");if(this.logged){var a=this;connectServer("/uws/remove",{id:d.id},function(f){if(f.status=="Well"){a.__deleteUserWindowSet(d);notifier.removeTask()}else{notifier.removeTask();dialog.error("There was an error while deleting this tab: "+f.data);d.deleting=false}},function(f,g,h){notifier.removeTask();dialog.error("There was an error while deleting this tab: "+(g||h)+". Please try again.");d.deleting=false})}else{this.__deleteUserWindowSet(d);
notifier.removeTask()}}};c=c.window_sets;if(c!=null&&c.length>0){for(var b=0;b<c.length;b++){var e=new UserWindowSet(this,c[b]);this.uwindowsets.push(e);$("#"+e.webid).after($("#newTabButton"))}this.uwindowsets[0].select()}}
function UserWindowSet(c,b){if(UserWindowSet.container==null)UserWindowSet.container=new (function(){this.selectedSet=null;this.selectSet=function(f){this.selectedSet!=null&&this.selectedSet.deselect();this.selectedSet=f;this.updateListMenu()};this.updateListMenu=function(){if(a.selectedSet!=null)if(a.selectedSet.is_active){$("#lnk_listDisable span:first").addClass("ic16-stop");$('#lnk_listDisable span[name="val"]').text("Disable list")}else{$("#lnk_listDisable span").removeClass("ic16-stop");$('#lnk_listDisable span[name="val"]').text("Enable list")}};
this.addwindowdlg=new AddWindowDlg;this.optwindowsetdlg=new OptWindowSetDlg(c);var a=this;$("#lnk_addwindow").click(function(){assert(a.selectedSet!=null,"instance.selectedSet != null");a.selectedSet==null?dialog.error("No list selected. You must select a list to add a new window to it."):a.addwindowdlg.show(a.selectedSet)});$("#lnk_listOptions").click(function(){assert(a.selectedSet!=null,"instance.selectedSet != null");a.selectedSet==null?dialog.error("No list selected."):a.optwindowsetdlg.show(a.selectedSet)});
$("#lnk_listDelete").click(function(){assert(a.selectedSet!=null,"instance.selectedSet != null");a.selectedSet==null?dialog.error("No list selected."):c.deleteUserWindowSet(a.selectedSet)});$("#lnk_listDisable").click(function(){assert(a.selectedSet!=null,"instance.selectedSet != null");if(a.selectedSet==null)dialog.error("No list selected.");else a.selectedSet.is_active?a.selectedSet.disable():a.selectedSet.enable()});$("#newTabButton button").click(function(){c.logged?a.optwindowsetdlg.show():dialog.info('Only logged user can use multiple lists. Please <a href="'+
c.login_url+'">sign in</a>.')})});this.HEADER_TEMPLATE='<li id="##ID##"><button class="left"></button><button class="center">##TITLE##</button><button class="right"></button></li>';this.uprofile=c;this.id=b.id;this.webid=("uws_"+this.id).replace(/:/g,"_");this.name=b.name;this.reloader=b.reloader;this.sequence_num=b.sequence_num;this.is_active=true;this.deleting=false;this.windowQueue=[];this.handler=this.currentWindow=null;this.title="sitereloadersiteshow"+this.sequence_num;this.window_options="location=yes,menubar=yes,resizable=yes,scrollbars=yes,titlebar=yes";
$("#tabsView").append(this.HEADER_TEMPLATE.replace("##TITLE##",this.name).replace("##ID##",this.webid));var e=this;$("#"+this.webid+" button").click(function(){e.select()});this.__remove=function(){$("#"+this.webid).remove();if(this.reloader=="SITE_SHOW"){$.each(this.windows,function(){this.__remove()});this.windows.length>0&&this.currentWindow!=null&&this.__closeBrowserWindow(this.currentWindow.website_url,this.title,this)}else $.each(this.windows,function(){this.__remove();this.parent.__closeBrowserWindow(this.website_url,
this.title,this)})};this.__disable=function(){assert(this.is_active,"this.is_active");this.is_active=false;UserWindowSet.container.updateListMenu();$("#"+this.webid+" button").addClass("inactive");if(this.reloader=="SITE_SHOW"){$.each(this.windows,function(){this.disable()});this.currentWindow!=null&&this.__closeBrowserWindow(this.currentWindow.website_url,this.title,this)}else $.each(this.windows,function(){this.disable();this.parent.__closeBrowserWindow(this.website_url,this.title,this)})};this.disable=
function(){if(this.is_active){notifier.appendTask("Disabling window list...");if(this.uprofile.logged){var a=this;connectServer("/uws/modify",{id:this.id,is_active:""},function(f){if(f.status=="Well"){a.__disable();notifier.removeTask()}else{notifier.removeTask();dialog.error("There was an error while disabling window list: "+f.data)}},function(f,g,h){notifier.removeTask();dialog.error("There was an error while disabling window list: "+(g||h)+". Please try again.")})}else{this.__disable();notifier.removeTask()}}};
this.__enable=function(){assert(!this.is_active,"!this.is_active");this.is_active=true;UserWindowSet.container.updateListMenu();$("#"+this.webid+" button").removeClass("inactive");$.each(this.windows,function(){this.enable()})};this.enable=function(){if(!this.is_active){notifier.appendTask("Enabling window list...");if(this.uprofile.logged){var a=this;connectServer("/uws/modify",{id:this.id,is_active:"ok"},function(f){if(f.status=="Well"){a.__enable();notifier.removeTask()}else{notifier.removeTask();
dialog.error("There was an error while enabling window list: "+f.data)}},function(f,g,h){notifier.removeTask();dialog.error("There was an error while enabling window list: "+(g||h)+". Please try again.")})}else{this.__enable();notifier.removeTask()}}};this.select=function(){UserWindowSet.container.selectSet(this);$("#"+this.webid+" button").addClass("selected");$.each(this.windows,function(){this.show()})};this.deselect=function(){$("#"+this.webid+" button").removeClass("selected");$.each(this.windows,
function(){this.hide()})};this.__setName=function(a){if(this.name!=a){this.name=a;$("#"+e.webid+' button[class~="center"]').text(e.name)}};this.__setReloader=function(a){if(this.reloader!=a){this.reloader=a;if(a=="SITE_SHOW")$.each(this.windows,function(){this.parent.__closeBrowserWindow(this.website_url,this.title,this)});else{this.currentWindow!=null&&this.__closeBrowserWindow(this.currentWindow.website_url,this.title,this);this.currentWindow=null}}};this.modify=function(a){notifier.appendTask("Saving window list options...");
var f=this.reloader,g=this.name;if(a.hasOwnProperty("reloader"))f=a.reloader;if(a.hasOwnProperty("name"))g=a.name;if(this.reloader!=f||this.name!=g)if(this.uprofile.logged){var h=this;a.id=this.id;connectServer("/uws/modify",a,function(i){if(i.status=="Well"){h.__setName(g);h.__setReloader(f);notifier.removeTask()}else{notifier.removeTask();dialog.error("There was an error while saving list options: "+i.data)}},function(i,j,k){notifier.removeTask();dialog.error("There was an error while saving list options: "+
(j||k)+". Please try again.")})}else{this.__setName(g);this.__setReloader(f);notifier.removeTask()}};this.__deleteWindow=function(a){var f=$.inArray(a,this.windows);assert(f>=0,"ind >= 0");if(f<0)dialog.error("Window not found.");else{this.windows.splice(f,1);a.paused=true;if(this.reloader=="SITE_SHOW"){f=$.inArray(a,this.windowQueue);this.windowQueue.splice(f,1);this.windows.length==0&&this.currentWindow&&this.__closeBrowserWindow(this.currentWindow.website_url,this.title,this);if(this.currentWindow==
a)this.currentWindow=null}else this.__closeBrowserWindow(a.website_url,a.title,a);a.__remove()}};this.deleteWindow=function(a){if(a.deleting)dialog.error("This window is being deleted. Please wait for server response.");else{a.deleting=true;notifier.appendTask("Deleting window...");if(this.uprofile.logged){var f=this;connectServer("/uw/remove",{id:a.id},function(g){if(g.status=="Well"){f.__deleteWindow(a);notifier.removeTask()}else{notifier.removeTask();dialog.error("There was an error while deleting window: "+
g.data);a.deleting=false}},function(g,h,i){notifier.removeTask();dialog.error("There was an error while deleting window: "+(h||i)+". Please try again.");a.deleting=false})}else this.__deleteWindow(a)}};this.__addUserWindow=function(a){a=new UserWindow(this,a);this.windows.push(a);this.is_active||a.disable();this!=UserWindowSet.container.selectedSet&&a.hide();this.reloader=="SITE_SHOW"&&this.windowQueue.push(a)};this.addUserWindow=function(a){notifier.appendTask("Adding new window...");a.uws_id=this.id;
a.sequence_num=this.windows.length>0?this.windows[this.windows.length-1].sequence_num+1:0;var f=this;if(this.uprofile.logged){var g=this;connectServer("/uw/add",a,function(h){if(h.status=="Well"){a.id=h.id;a.website_id=h.website_id;g.__addUserWindow(a);notifier.removeTask()}else{notifier.removeTask();dialog.error("There was an error while adding a new website: "+h.data+". Please try again.")}},function(h,i,j){notifier.removeTask();dialog.error("There was an error while adding a new website: "+(i||
j)+". Please try again.")})}else{a.id=-100-a.sequence_num;this.__addUserWindow(a);notifier.removeTask()}};this.__openBrowserTab=function(a,f,g){assert(g!=null,"objWithHandler != null");if(g&&g.handler&&!g.handler.closed)g.handler.location.href=a;else{var h=null;h=$.browser.mozilla?document.getElementsByName("flx_tabopen")[0]:document.getElementById("flx_tabopen");if(h!=null){h=h.open_intab(a,f);assert(h,"Could not open the tab window.");g&&window.setTimeout(function(){g.handler=window.open(a,f)},
1E3)}}};this.__openBrowserWindow=function(a,f,g){assert(g!=null,"objWithHandler != null");if(g&&g.handler&&!g.handler.closed)g.handler.location.href=a;else{a=window.open(a,f,this.window_options,true);if(g)g.handler=a}};this.__reloadSiteShow=function(){assert(this.is_active&&this.windows!=null,"this.is_active && this.windows != null");for(var a=false,f=0;f<this.windows.length;f++)if(this.currentWindow==this.windows[f])a=this.windows[f].tick();else this.windows[f].tick();if(this.currentWindow==null||
this.currentWindow.paused||a){if(this.windowQueue==null||this.windowQueue.length==0)this.windowQueue=this.windows.slice(0);this.currentWindow=this.windowQueue.shift();if(!this.currentWindow.paused){this.__openBrowserTab(this.currentWindow.website_url,this.title,this);this.currentWindow.afterReload()}}};this.__reloadMultiWindow=function(){assert(this.is_active&&this.windows!=null,"this.is_active && this.windows != null");$.each(this.windows,function(){if(this.tick()){this.open_mode=="IN_TAB"?this.parent.__openBrowserTab(this.website_url,
this.title,this):this.parent.__openBrowserWindow(this.website_url,this.title,this);this.afterReload()}})};this.reload=function(){if(this.is_active){assert(this.windows!=null,"this.windows != null");this.reloader=="SITE_SHOW"?this.__reloadSiteShow():this.__reloadMultiWindow()}};this.__closeBrowserWindow=function(a,f,g){g&&g.handler&&!g.handler.closed&&g.handler.close()};this.exit=function(){this.is_active&&this.__disable()};this.windows=[];b.is_active||this.__disable();if(b.windows!=null)for(var d=
0;d<b.windows.length;d++)this.__addUserWindow(b.windows[d])}
function UserWindow(c,b){if(UserWindow.wsmenu==null)UserWindow.wsmenu=new WSMenu;if(UserWindow.timerbox==null)UserWindow.timerbox=new TimerBox;this.TEMPLATE='<li id="##ID##"><span name="url" style="font-weight: bold; font-size: 14px"></span>, <span name="update">not yet shown</span>&nbsp;&nbsp;<a href="#" name="pause"><span class="icon-holder16 ic16-play ic16-pause"></span><span name="val">pause</span></a><br /><span style="font-size: 12px">Reloaded every: </span><a href="#" name="timer"><span class="icon-holder16" style="background-position: -32px -92px"></span><span name="val"></span></a> ,&nbsp;<a href="#" name="more" style="text-decoration: none"><span style="text-decoration: underline">more options</span><span style="font-size: 11px">\u25bc</span></a> </li>';this.id=
b.id;this.webid=("uw_"+this.id).replace(/:/g,"_");this.website_id=b.website_id;this.website_url=b.url;this.open_mode=b.open_mode;this.reload_rate=b.reload_rate;this.sequence_num=b.sequence_num;this.parent=c;this.opened=false;this.handler=null;this.paused=this.deleting=false;this.title="sistreloader"+this.parent.sequence_num+"c"+this.sequence_num;this.timerTicks=this.reload_rate;this.__setReloadRate=function(d){if(this.reload_rate!=d){this.reload_rate=d;$("#"+this.webid+' a[name="timer"] span[name="val"]').text(printInterval(this.reload_rate))}};
this.setReloadRate=function(d){if(this.reload_rate!=d)if(this.parent.uprofile.logged){notifier.appendTask("Changing window reload rate...");var a=this;connectServer("/uw/modify",{id:this.id,reload_rate:d},function(f){if(f.status=="Well"){a.__setReloadRate(d);notifier.removeTask()}else{notifier.removeTask();dialog.error("There was an error while changing reload rate: "+f.data+". Please try again.")}},function(f,g,h){notifier.removeTask();dialog.error("There was an error while changing reload rate: "+
(g||h)+". Please try again.")})}else this.__setReloadRate(d)};this.__setOpenMode=function(d){if(this.open_mode!=d){this.open_mode=d;this.parent.reloader=="MULTI_WINDOW"&&this.parent.__closeBrowserWindow(this.website_url,this.title,this)}};this.setOpenMode=function(d){if(this.open_mode!=d){notifier.appendTask("Changing window open mode...");if(this.parent.uprofile.logged){var a=this;connectServer("/uw/modify",{id:this.id,open_mode:d},function(f){if(f.status=="Well"){a.__setOpenMode(d);notifier.removeTask()}else{notifier.removeTask();
dialog.error("There was an error while changing window open mode: "+f.data+". Please try again.")}},function(f,g,h){notifier.removeTask();dialog.error("There was an error while changing window open mode: "+(g||h)+". Please try again.")})}else{this.__setOpenMode(d);notifier.removeTask()}}};this.__remove=function(){UserWindow.wsmenu.uwindow==this&&UserWindow.wsmenu.close();UserWindow.timerbox.uwindow==this&&UserWindow.timerbox.hide();$("#"+this.webid).remove()};this.show=function(){$("#"+this.webid).css("display",
"block")};this.hide=function(){$("#"+this.webid).css("display","none")};this.disable=function(){$("#"+this.webid+' a[name="pause"]').hide();$("#"+this.webid+' span[name="update"]').hide();this.paused||$("#"+this.webid).addClass("inactive");this.opened=false};this.enable=function(){this.timerTicks=this.reload_rate;$("#"+this.webid+' a[name="pause"]').show();$("#"+this.webid+' span[name="update"]').text("not yet shown");$("#"+this.webid+' span[name="update"]').show();this.paused||$("#"+this.webid).removeClass("inactive")};
this.tick=function(){var d=false;this.timerTicks+=TIMER_TICK;this.paused||(d=this.timerTicks>=this.reload_rate);if(this.opened){var a=printInterval(this.timerTicks);$("#"+this.webid+' span[name="update"]').text("last shown "+a+" ago")}return d};this.afterReload=function(){this.timerTicks=0;$("#"+this.webid+' span[name="update"]').text("last shown 0s ago");this.opened=true};this.pause=function(){if(this.paused=!this.paused){$("#"+this.webid+' a[name="pause"] span:first').removeClass("ic16-pause");
$("#"+this.webid+' a[name="pause"] span[name="val"]').text("play");$("#"+this.webid).addClass("inactive")}else{$("#"+this.webid+' a[name="pause"] span:first').addClass("ic16-pause");$("#"+this.webid+' a[name="pause"] span[name="val"]').text("pause");$("#"+this.webid).removeClass("inactive")}};var e=this;$("#windowlist ul").append(this.TEMPLATE.replace("##ID##",this.webid));$("#"+this.webid+' span[name="url"]').attr("title",this.website_url);this.website_url.length>60?$("#"+this.webid+' span[name="url"]').text(this.website_url.substr(0,
57)+"..."):$("#"+this.webid+' span[name="url"]').text(this.website_url);$("#"+this.webid+' a[name="pause"]').click(function(){e.pause()});$("#"+this.webid+' a[name="timer"] span[name="val"]').text(printInterval(this.reload_rate));$("#"+this.webid+' a[name="timer"]').click(function(d){assert(UserWindow.timerbox!=null,"UserWindow.timerbox != null");UserWindow.timerbox!=null&&UserWindow.timerbox.show(e,this)});$("#"+this.webid+' a[name="more"]').click(function(d){d.stopPropagation();d=$(this).offset().left;
var a=$(this).offset().top+$(this).height()+5;assert(UserWindow.wsmenu!=null,"UserWindow.wsmenu != null");UserWindow.wsmenu!=null&&UserWindow.wsmenu.show(e,d,a)})};var re=/^(?:(\d+)(?:hours|hour|h.|h))*\s*(?:(\d+)(?:minutes|mins|min\.?|m))*\s*(?:(\d+)(?:seconds|second|sec\.?|s)?)*$/i;function parseInterval(c){c=c.replace(" ","");if(c=="")return-1;c=re.exec(c);if(c==null)return-1;if(c!=null){var b=0,e=new Number(c[1]);isNaN(e)||(b+=e*36E5);e=new Number(c[2]);isNaN(e)||(b+=e*6E4);e=new Number(c[3]);isNaN(e)||(b+=e*1E3);return b}return-1}
function printInterval(c){var b=c;c=Math.floor(b/36E5);b-=c*36E5;var e=Math.floor(b/6E4);b-=e*6E4;b=b/1E3;var d="";if(c>0)d+=c+"h ";if(e>0)d+=e+"m ";if(b>0)d+=b+"s ";d||(d="0s");return d.replace(/\s+$/g,"")};function AddWindowDlg(){if(AddWindowDlg.re==null)AddWindowDlg.re=/^((?:https?|ftp|gopher|telnet|file|notes|ms-help):(?:(?:\/\/)|(?:\\\\))+)?[\w\d:#@%\/;$()~_?\+-=\\\.&]+$/i;this.uset=null;this.show=function(b){this.uset=b;$("#dlg_addwindow").modal({opacity:60,overlayCss:{backgroundColor:"#3B5A9B"},onShow:function(){$("#rbintab").attr("checked",true);document.getElementById("txt_url").focus()}})};this.submit=function(){var b=this.validate_url();if(b==null)document.getElementById("txt_url").focus();
else{var e=this.validate_interval();if(e<0)document.getElementById("txt_interval").focus();else if($("#dlg_addwindow input:checked").length!=0){var d=$("#dlg_addwindow input:checked").val();$.modal.close();assert(this.uset!=null,"this.uset");this.uset!=null&&this.uset.addUserWindow({url:b,open_mode:d,reload_rate:e})}}};this.validate_url=function(){var b=$.trim($("#txt_url").val());if(b==""){$("#txt_url").css("background-color","#F18D7B");return null}if(b.indexOf("sitereloader.appspot.com",0)>=0||
b.indexOf("sitereloader.com",0)>=0){$("#txt_url").css("background-color","#F18D7B");return null}var e=AddWindowDlg.re.exec(b);if(!e[1]){b="http://"+b;$("#txt_url").val(b)}if(e==null){$("#txt_url").css("background-color","#F18D7B");return null}$("#txt_url").css("background-color","#B5D65D");return b};this.validate_interval=function(){var b=parseInterval($("#txt_interval").val());if(b<=0){$("#txt_interval").css("background-color","#F18D7B");return-1}$("#txt_interval").css("background-color","#B5D65D");
return b};var c=this;$("#btn_addwindow_cancel").click(function(){$.modal.close()});$("#txt_interval").keydown(function(b){if(b.which==13)c.submit();else b.which==9?c.validate_interval():$("#txt_interval").css("background-color","white")});$("#txt_interval").change(function(){c.validate_interval()});$("#txt_url").keydown(function(b){if(b.which==13)c.submit();else b.which==9?c.validate_url():$("#txt_url").css("background-color","white")});$("#txt_url").change(function(){c.validate_url()});$("#btn_addwindow_submit").click(function(){c.submit()})}
function TimerBox(){this.timerUI=this.prevValue=this.uwindow=null;this.show=function(b,e){this.cancel();this.uwindow=b;this.timerUI=e;this.prevValue=$(e).text();$("#timerbox input").val(this.prevValue);$(e).after($("#timerbox"));$(e).hide();$("#timerbox").show();document.getElementById("txt_timerval").focus()};this.cancel=function(){this.hide()};this.accept=function(){var b=$("#timerbox input"),e=parseInterval(b.val());if(e>0){b.css("background-color","#B5D65D");this.uwindow.setReloadRate(e);this.hide()}else b.css("background-color",
"#F18D7B")};this.hide=function(){with(this){$("#timerbox").hide();$("#timerbox input").css("background-color","white");timerUI!=null&&$(timerUI).show();prevValue=timerUI=uwindow=null;$("#windowlist").after($("#timerbox"))}};var c=this;$('#timerbox button[name="timerAccept"]').click(function(){c.accept()});$('#timerbox button[name="timerReject"]').click(function(){c.cancel()});$("#timerbox input").keydown(function(b){if(b.which==13)c.accept();else b.which==27&&c.cancel()})}
function WSMenu(){this.timeout=500;this.uwindow=this.wssubmenuitem=this.wsmenuitem=this.closetimer=null;this.show=function(b,e,d){$("#wsmenu").css({visibility:"visible",left:e,top:d});this.uwindow=b;$('#wsmenu a > input[value="'+b.open_mode+'"]').attr("checked",true)};this.expand=function(b){if(this.wsmenuitem==null||b.attr("name")!=this.wsmenuitem.attr("name")){var e=b.children("ul");this.wssubmenuitem!=null&&this.wssubmenuitem.css("visibility","hidden");if(e.length>0){var d=b.offset();this.wssubmenuitem=
e.css({left:b.width()+"px",top:"0px",visibility:"visible"})}this.wsmenuitem=b}this.cancelTimer()};this.close=function(){if(this.wssubmenuitem!=null){this.wssubmenuitem.css("visibility","hidden");this.wssubmenuitem=null}$("#wsmenu").css("visibility","hidden");this.uwindow=this.wsmenuitem=null};this.startTimer=function(){var b=this;this.closetimer=window.setTimeout(function(){b.close()},this.timeout)};this.cancelTimer=function(){if(this.closetimer){window.clearTimeout(this.closetimer);this.closetimer=
null}};var c=this;$("#wsmenu > li").bind("mouseover",function(){c.expand($(this))});$("#wsmenu > li").bind("mouseout",function(){c.wsmenuitem!=null&&$(this).attr("name")==c.wsmenuitem.attr("name")&&c.startTimer()});$("#wsmenu li").bind("click",function(b){b.stopPropagation()});$(document).click(function(){c.close()});$("#lnk_wsintab").click(function(){var b=$("#lnk_wsintab input");b.attr("checked",true);assert(c.uwindow!=null,"uwindow != null");c.uwindow!=null&&c.uwindow.setOpenMode(b.val())});$("#lnk_wsinwindow").click(function(){var b=
$("#lnk_wsinwindow input");b.attr("checked",true);assert(c.uwindow!=null,"uwindow != null");c.uwindow!=null&&c.uwindow.setOpenMode(b.val())});$("#lnk_wsdelete").click(function(){assert(c.uwindow!=null,"uwindow != null");c.uwindow!=null&&c.uwindow.parent.deleteWindow(c.uwindow)})};function OptWindowSetDlg(c){this.uset=null;this.uprofile=c;this.show=function(){this.show(null)};this.show=function(e){this.uset=e;$("#dlg_optwindowset").modal({opacity:60,overlayCss:{backgroundColor:"#3B5A9B"},onShow:function(){if(e==null){$("#dlg_optwindowset .title .titletext").text("Add window list");$("#rbmultiwindow").attr("checked",true)}else{$("#dlg_optwindowset .title .titletext").text("Window list options");$("#txt_listname").val(e.name);$('#dlg_optwindowset input[value="'+e.reloader+'"]').attr("checked",
true)}}})};this.validate_name=function(){var e=$.trim($("#txt_listname").val());if(e==""){$("#txt_listname").css("background-color","#F18D7B");return null}if(e.length>20||!e.match(/^[\w\d\s]+$/)){$("#txt_listname").css("background-color","#F18D7B");return null}$("#txt_listname").css("background-color","#B5D65D");return e};this.submit=function(){var e=this.validate_name();if(e==null)document.getElementById("txt_listname").focus();else if($("#dlg_optwindowset input:checked").length!=0){var d=$("#dlg_optwindowset input:checked").val();
$.modal.close();e={name:e,reloader:d,is_active:true};if(this.uset==null){assert(this.uprofile!=null,"this.uprofile != null");this.uprofile!=null&&this.uprofile.addUserWindowSet(e,true)}else this.uset.modify(e)}};var b=this;$("#btn_windowlist_submit").click(function(){b.submit()});$("#btn_windowlist_cancel").click(function(){$.modal.close()});$("#txt_listname").keydown(function(e){if(e.which==13)b.submit();else e.which==9?b.validate_name():$("#txt_listname").css("background-color","white")})};

