/* ====== request for /Oarbits/ajax.js ======= *//*---------- Copyright 2012 Neotek Limited (http://www.neotek.co.nz). All rights reserved. -----------*/
 
/* ---------- ajax.js ---------- */
var fileref=document.createElement("link");fileref.setAttribute("rel","stylesheet");fileref.setAttribute("type","text/css");fileref.setAttribute("href","/neotek/popup.css");document.getElementsByTagName("head")[0].appendChild(fileref);function msgbox(a,b){hideprocessing();var c={URL:"/neotek/alert.aspx?msgId="+b,Title:"",IncludeClose:false,Width:500,Height:100,DoFade:false,CloseOnLoseFocus:false};top.NeotekPopup.Show(c)}function CheckAll(c){var b=document.forms[0].getElementsByTagName("input");for(var a=b.length-1;a>1;a--){if(b[a].id.substring(0,3)=="row"){b[a].checked=c.checked}}}function emptySessionTable(){document.getElementById("sessions").innerHTML='<table><tr style="background-color:Silver;font-weight:bold;"><td width="24px">Reg</td><td width="48px">Session</td><td width="120px">Name</td><td width="56px">Duration</td><td width="30px">Type</td><td width="110px">Start time (GMT)</td><td width="36px">Boats</td><td width="78px">Class</td><td width="24px">In</td><td width="65px">Status</td><td width="44px"></td></tr></table><div id="scroller" style="width:100%;height:465px;overflow:auto;"><table id="oarbitsessions"><tr style="height:0px;display:none;"><td width="24px">Reg</td><td restrict="1" width="48px">Session</td><td restrict="1" width="120px">Name</td><td restrict="1" width="56px">Duration</td><td restrict="1" width="30px">Type</td><td restrict="1" width="110px">Start time (GMT)</td><td restrict="1" width="36px">Boats</td><td restrict="1" width="78px">Class</td><td restrict="1" width="24px">In</td><td restrict="1" width="65px">Status</td><td restrict="1" width="24px"></td></tr></table></div>'}function SessionContextMenuHandler(a,c,b){document.location.href="/regattaviewer/index.htm?id="+$(c).attr("sessionId")}function getSessions(b){try{if(b==null){if(document.getElementById("OnlineSessionStat")!=null){document.getElementById("OnlineSessionStat").innerHTML="";document.getElementById("OnlineFinishStat").innerHTML="";neotekscript("/neotek/oarbits.aspx?list=1","",DisplayStats)}if(document.getElementById("gmt")!=null){neotekscript("/neotek/oarbits.aspx?time=1","")}}if(document.getElementById("sessions")!=null){showprocessing();emptySessionTable();if(b==null){if(document.getElementById("Schedule")!=null){b="2"}if(document.getElementById("Results")!=null){b="3"}if(document.getElementById("LiveFeed")!=null){b="4"}}neotekscript("/neotek/oarbits.aspx?list="+b,"",DisplaySessions)}}catch(a){alert(a)}return false}function reg(a){sessionId=null;try{var c=readCookie("FullName");if(c!=""&&c!=null){var d;a=Event.Get(a);var f=a.src.checked;if(f==null){var f=race.getAttribute("checked")}if(f==true){d="Are you sure you want to register for this Session?"}else{d="Are you sure you want to unregister from this Session?"}if(confirm(d)){showprocessing();neotekscript("/neotek/oarbits.aspx?reg="+f+"&id="+a.src.getAttribute("raceId"),"")}}else{opensignin()}}catch(b){}cancelPropagation(a);return false}function setrowers(a,c){if(c==0){var b=document.getElementById("row"+a);b.parentNode.removeChild(b)}else{document.getElementById("rowers"+a).innerHTML=c}hideprocessing()}var regtooltip="Click to register for this session";var unregtooltip="Click to unregister from this session";function check(a){document.getElementById("session"+a).checked=true;document.getElementById("session"+a).title=unregtooltip}function uncheck(a){document.getElementById("session"+a).checked=false;document.getElementById("session"+a).title=regtooltip}var hr;var min;function setGMT(a,b){hr=a;min=b;updateGMT();setInterval("updateGMT()",60000)}function updateGMT(){min++;if(min==60){min=0;hr++;if(hr==24){hr=0}}document.getElementById("gmt").innerHTML=(hr<10?"0":"")+hr+":"+(min<10?"0":"")+min}var sessionId;var timeout=400;var timer;function rowers(a){sessionId=a;timer=setTimeout("showrowers()",timeout)}function showrowers(){var a={URL:"/neotek/rowers.aspx?Id="+sessionId,Title:"",IncludeClose:true,Width:300,Height:50,Rounded:false,ClassName:"neotekPopupOarbits",CloseOnLoseFocus:true};top.NeotekPopup.Show(a)}function norowers(){clearTimeout(timer);top.NeotekPopup.Close()}function popupSessionDetails(a){try{var c=readCookie("FullName");if(c!=""&&c==null){opensignin()}else{if(!window.focus){return true}var b=getTableRow(a);if(b==null){sessionId=0}else{sessionId=b.value}newWin=window.open("/Oarbits/SessionDetails.htm?id="+sessionId,"sessionDetails","width=550,height=600,top=100,left=200,scrollbars=yes");newWin.focus()}}catch(a){alert(a)}return false}function popupSendMessage(){try{var b=readCookie("FullName");if(b!=""&&b==null){opensignin()}else{if(!window.focus){return true}newWin=window.open("/Oarbits/SendMessage.htm","sessionDetails","width=550,height=600,top=100,left=200,scrollbars=yes");newWin.focus()}}catch(a){alert(a)}return false}function session(a){a=Event.Get(a);var b=a.src;var c=b.value;if(c!=null){sessionId=c;settings={URL:"/neotek/session.aspx?Id="+sessionId,Title:"",IncludeClose:true,Width:300,Height:5,ShowImmediately:true,Position:[a.clientX-312,a.clientY+10],DoFade:false,Rounded:false,ClassName:"neotekPopupOarbits",CloseOnLoseFocus:false};timer=setTimeout("showsession()",timeout)}cancelPropagation(a)}var settings;function showsession(){top.NeotekPopup.Show(settings)}function highlight(a){var b=getTableRow(a);b.className+=" highlight"}function getTableRow(a){var b;try{b=Event.Get(a).src;while(b.nodeName.toLowerCase()!="tr"){b=b.parentElement}}catch(c){b=null}return b}function unhighlight(a){var b=getTableRow(a);b.className=b.className.replace(" highlight","")}function nosession(){clearTimeout(timer);if(top.NeotekPopup._url!=null){if(top.NeotekPopup._url.startsWith("/neotek/session.aspx")){top.NeotekPopup.Close();sessionId=null}}}function DisplaySessions(p){if(p.readyState==4){if(p.status==200){var n=p.responseXML.getElementsByTagName("NewDataSet")[0].getElementsByTagName("Table");if(n!=null){emptySessionTable();var o=document.getElementById("oarbitsessions");for(var b=0;b<n.length;b++){try{var l=n[b];var c="";if(xpath(l,"Status")=="Open"){c=document.createElement("input");c.type="checkbox";c.setAttribute("raceId",xpath(l,"Id"));c.id="session"+xpath(l,"Id");c.name="session"+xpath(l,"Id");if(xpath(l,"PlayerStatus")=="1"){c.setAttribute("title",unregtooltip);c.checked=true}else{c.setAttribute("title",regtooltip)}Event.Add(c,"mouseover",cancelPropagation,false);Event.Add(c,"click",reg,false)}var f=document.createElement("div");f.value=xpath(l,"Id");Event.Add(f,"click",session,false);f.className="info";var m='<div id="rowers'+xpath(l,"Id")+'">'+xpath(l,"Players")+"</div>";var k=[c,xpath(l,"SessionNo"),xpath(l,"Name"),xpath(l,"Duration"),xpath(l,"Type"),xpath(l,"Scheduled"),xpath(l,"boattype"),xpath(l,"Class"),m,xpath(l,"Status"),f];var g;var h=o.insertRow(o.rows.length);h.id="row"+xpath(l,"Id");if(xpath(l,"Editable")=="1"){Event.Add(h,"click",popupSessionDetails,false);Event.Add(h,"mouseout",unhighlight,false);Event.Add(h,"mouseover",highlight,false);h.value=xpath(l,"Id");h.title="Click to edit"}if((o.rows.length%2)==0){h.className="alt"}h.className+=" cmenabled";h.setAttribute("neo-contextmenu","SessionContextMenu");h.setAttribute("sessionId",xpath(l,"Id"));for(var d=0;d<k.length;d++){g=h.insertCell(d);width=o.rows[0].cells[d].getAttribute("width").replace(/px,*\)*/g,"");restrict=o.rows[0].cells[d].getAttribute("restrict");g.style.width=width+"px";if(typeof(k[d])=="object"){checked=k[d].checked;g.appendChild(k[d]);if(checked){g.firstChild.checked=true}}else{if(restrict=="1"){width=width-3+"px";g.innerHTML='<div style="overflow:hidden;height:18px;width:'+width+'">'+k[d]+"</div>"}else{g.innerHTML=k[d]}}}}catch(a){alert(a)}}hideprocessing()}else{alert("Failed to get a response!")}}}}function xpath(c,b){var a=c.getElementsByTagName(b)[0];if(a==null){return""}return(a.textContent||a.text)}function addCommas(a){a+="";x=a.split(".");x1=x[0];x2=x.length>1?"."+x[1]:"";var b=/(\d+)(\d{3})/;while(b.test(x1)){x1=x1.replace(b,"$1,$2")}return x1+x2}function DisplayStats(c){if(c.readyState==4){if(c.status==200){var b=c.responseXML.getElementsByTagName("NewDataSet")[0];try{if(b!=null){document.getElementById("OnlineSessionStat").innerHTML=addCommas(xpath(b,"Sessions"));document.getElementById("OnlineFinishStat").innerHTML=addCommas(xpath(b,"Finishes"))}else{alert("Failed to get a response!")}}catch(a){alert(a)}hideprocessing()}}}addonloadcallback(getSessions);$(document).ready(function(){$(document).bind("contextmenu",showContextMenu)}); 
/* -------- ajax.js End -------- */
 
/*  Created in 15.6 milliseconds */
