/* Copyright 2005-12, D. Oziem, MELONET Internet Consultancy */

var _objCache=[];function _Find(id){if(!_Def(_objCache[id])||_objCache[id]==null){var ux=document.getElementById(id);_objCache[id]=ux;return ux;}else{return _objCache[id];}}
function _Def(obj){if(typeof obj==="undefined"){return 0;}else{return 1;}}
function _Uncache(id){_objCache[id]=null;}
function _Value(id){ux=_Find(id);if(ux!=null){return ux.value;}else{return GetRadio(id);}}
function _Int(id){var v=_Value(id);if(v==""){return 0;}else{return parseInt(v,10);}}
function _Double(id){return parseFloat(_Value(id));}
function _Style(id){return _Find(id).style;}
function _Hide(id){var ux=_Find(id);if(ux){ux.style.display='none';}}
function _Show(id){var ux=_Find(id);if(ux){ux.style.display='block';}}
function _ShowInline(id){var ux=_Find(id);if(ux){ux.style.display='inline';}}
function _ShowTable(id){document.getElementById(id).style.display='table';}
function _V2Date(id){var ux=_Find(id);if(ux!=null){return DateToEncodeString(ux.value);}}
function _Switch(id){if(_Find(id)!==null&&_Style(id).display=='none'){_Show(id);}else{_Hide(id);}}
function _InHtml(id,tx){var ux=_Find(id);if(ux){ux.innerHTML=tx;}}
function _SwitchTblRow(id){if(_Find(id)!=null&&_Style(id).display=='none'){_ShowTblRow(id);}else{_HideTblRow(id);}}
function _ShowTblRow(id){document.getElementById(id).style.display='';}
function _HideTblRow(id){document.getElementById(id).style.display='none';}
function _Text(id){return _Find(id).options[_Find(id).selectedIndex].text;}
function urlencode(str){return escape(str).replace(/\+/g,'%2B').replace(/%20/g,'+').replace(/\*/g,'%2A').replace(/\//g,'%2F').replace(/@/g,'%40');}
function _SetSelected(id,val){var ux=_Find(id);var len=ux.length;for (i=0;i<len;i++){if(val==ux.options(i).text){ux.options(i).selected=true;return;}}}
function _Div(id,c){var d=document.createElement("div");if(_Def(id)&&id!==""&&id!=null){d.id=id;}
if(_Def(c)&&c!==""&&c!=null){d.className=c;}
return d;}
function _Ping(){ajax_callback_return_js("handlers/ajax.ping.php","");if(__isLive){setTimeout(_Ping,60000);}}
setTimeout(_Ping,60000);function _GotoStop(e,url){_ShowLoad();top.location=_GuRl(url);if(!e){e=window.event;}
e.cancelBubble=true;if(e.stopPropagation){e.stopPropagation();}}
function _Goto(url){_ShowLoad();top.location=_GuRl(url);}
function _GotoNoLoader(url){top.location=_GuRl(url);}
function _Loc(url){_ShowLoad();document.location=_GuRl(url);}
function _GuRl(url){if(url.substr(0,7)=="http://"){}else{var b=document.getElementsByTagName('base');if(b&&b[0]&&b[0].href){if(b[0].href.substr(b[0].href.length-1)=='/'&&url.charAt(0)=='/'){url=url.substr(1);}
url=b[0].href + url;}}
return url;}
function _SwitchClass(id){var obj=_Find("txt"+id);if(obj!=null&&obj.innerHTML.substring(0,1)=="S"){obj.innerHTML=obj.innerHTML.replace("Show","Hide");}else{obj.innerHTML=obj.innerHTML.replace("Hide","Show");}}
function _ShowLoad(){var c=document.createElement('div');c.setAttribute('id','qloader');c.innerHTML="<div><img src='http://esblib.com/skin/1/loading.gif' /></div>";document.body.appendChild(c);_ShowMask(5);}
function _HMS(sec){var h=Math.floor(sec/3600);var m=Math.floor((sec-(h*3600))/60);var s=Math.floor(10*(sec-(m*60)-(h*3600)))/10;if(h>0){return h+"h:"+_NN(m)+"m:"+_NN(s)+"s";}else if(m>0){return m+"m:"+_NN(s)+"s";}else{return s+"s";}}
function _MWD(sec){var m=Math.floor(sec/2419200);var w=Math.floor((sec-(m*2419200))/604800);var d=Math.floor((sec-(w*604800)-(m*2419200))/86400);var output="";if(m>1){output+=m+" Months";}
if(m==1){output+=m+" Month";}
if(m>0&&(w>0||d>0)){output+=", ";} 
if(w>1){output+=w+" Weeks";}
if(w==1){output+=w+" Week";}
if(w>0&&d>0){output+=", ";}
if(d>1){output+=d+" Days";}
if(d==1){output+=d+" Day";}
return output;}
function _NN(i){if(i<10){return "0"+i;}else{return i;}}
function GetRadio(id){var list=document.getElementsByName(id);var len=list.length;for (var i=0;i<len;i++){if(list[i].checked){return list[i].value;}}
return null;}
function addEvent(el,eType,h,mode){if(document.addEventListener){el.addEventListener(eType,h,mode);}else{el.attachEvent('on'+eType,h);}}
function removeEvent(el,eType,h,mode){if(document.removeEventListener){el.removeEventListener(eType,h,mode);}else{el.removeEvent('on'+eType,h);}}
function _WindowSize(){var w=0, h=0;if(typeof window.innerWidth==="number"){w=window.innerWidth;h=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){w=document.documentElement.clientWidth;h=document.documentElement.clientHeight;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){w=document.body.clientWidth;h=document.body.clientHeight;}
return{x:w, y:h};}
function DateToString(date){var da=new Date(date);var db=da.toGMTString();var dc=db.split(" ");if(eval(dc[3])<1970){dc[3]=eval(dc[3])+100;}
return dc[1] + " " + dc[2] + " " + dc[3];}
function DateToEncodeString(date){var ml={jan:"01",feb:"02",mar:"03",apr:"04",may:"05",jun:"06",jul:"07",aug:"08",sep:"09",oct:"10",nov:"11",dec:"12"};try{if(date.length==11){return ""+date.substring(7,11)+ml[date.substring(3,6).toLowerCase()]+date.substring(0,2);}}catch(err){}
var da=new Date(date);dout=da.getFullYear();mo=da.getMonth()+1;if(mo<10){dout +="0"+mo;}else{dout +=mo;}
day=da.getDate();if(day<10){dout +="0"+day;}else{dout +=day;}  
return dout;}
function SCWtoDate(date){var ml={jan:"01",feb:"02",mar:"03",apr:"04",may:"05",jun:"06",jul:"07",aug:"08",sep:"09",oct:"10",nov:"11",dec:"12"};try{if(date.length==11){return ""+date.substring(7,11)+"/"+ml[date.substring(3,6).toLowerCase()]+"/"+date.substring(0,2);}}catch(err){}
return "";}
function FindPos(obj,limit){var curleft=curtop=0;if(obj.offsetParent){do{if(obj.id==limit){return [curleft,curtop];}
curleft +=obj.offsetLeft;curtop +=obj.offsetTop;} while (obj=obj.offsetParent);}
return [parseInt(curleft,10),parseInt(curtop,10)];}
var _CM={_menus : new Array,
_attachedElement : null,
_menuElement : null,
_preventDefault : 1,
_preventForms : 1,
_menuWidth : 0,
_clickId : "",
_origClass : new Array,    
_propagateCssClass : 1,
setup:function(conf){if( document.all&&document.getElementById&&!window.opera ){_CM.IE=1;}
if( !document.all&&document.getElementById&&!window.opera ){_CM.FF=1;}
if( document.all&&document.getElementById&&window.opera ){_CM.OP=1;}
if( _CM.IE||_CM.FF ){document.oncontextmenu=_CM._show;document.onclick=_CM._hide;if(conf&&_Def(conf.preventDefault)){_CM._preventDefault=conf.preventDefault;}
if(conf&&_Def(conf.preventForms)){_CM._preventForms=conf.preventForms;}}},
attach:function(classNames, menuId, width, propagate){if(propagate!=null){_CM._propagateCssClass=propagate;}
_CM._menuWidth=width;if(typeof classNames==="string"){_CM._menus[classNames]=menuId;}
if(typeof classNames==="object"){for (x=0; x < classNames.length; x++){_CM._menus[classNames[x]]=menuId;}}},
_getMenuElementId:function(e){if(_CM.IE){_CM._attachedElement=event.srcElement;} 
else{_CM._attachedElement=e.target;}
while(_CM._attachedElement !=null){var className=_CM._attachedElement.className;_CM._clickId=_CM._attachedElement['id'];if( _Def(className) ){className=className.replace(/^\s+/g, "").replace(/\s+$/g, "");var classArray=className.split(/[ ]+/g);for (i=0; i < classArray.length; i++){if(_CM._menus[classArray[i]]){return _CM._menus[classArray[i]];}}}
if(_CM.IE){_CM._attachedElement=_CM._attachedElement.parentElement;} 
else{_CM._attachedElement=_CM._attachedElement.parentNode;}}
return null;},
_getReturnValue:function(e){var returnValue=1;var evt=_CM.IE ? window.event : e;if(evt.button !=1){if(evt.target){var el=evt.target;} 
else if(evt.srcElement){var el=evt.srcElement;}
var tname=el.tagName.toLowerCase();if(tname=="input"||tname=="textarea"){if(!_CM._preventForms){returnValue=1;} 
else{returnValue=false;}} 
else{if(!_CM._preventDefault){returnValue=1;} 
else{returnValue=false;}}}
return returnValue;},
_checkWidth:function(p){var size=_WindowSize();var end=(p.x+_CM._menuWidth+16);if( end > size.x ){p.x=p.x-_CM._menuWidth+16;}
return p;},
_highlight:function(){if( _CM._clickId ){var temp=_Find(_CM._clickId);_CM._origClass[0]=temp.className;temp.className +='hover';if(_CM._propagateCssClass){tr=temp.firstChild;cnt=1;while(tr){if( _Def(tr["style"]) ){_CM._origClass[cnt]=tr.className;if(tr.className!=""){tr.className +='highlight';}}
tr=tr.nextSibling;cnt++;}}}},
_unhighlight:function(){if( _CM._clickId ){temp=_Find(_CM._clickId);temp.className=_CM._origClass[0];if(_CM._propagateCssClass){tr=temp.firstChild;cnt=1;while(tr){if( _Def(tr["style"]) ){tr.className=_CM._origClass[cnt];}
tr=tr.nextSibling;cnt++;}}}},
_show:function(e){_CM._hide();var menuElementId=_CM._getMenuElementId(e);if(menuElementId&&_CM._clickId){var p=_CM._getMousePosition(e);p=_CM._checkWidth(p);_CM._menuElement=_Find(menuElementId);_CM._highlight();if(_CM._menuElement!=null){_CM._menuElement.style.left=p.x + 'px';_CM._menuElement.style.top=p.y + 'px';_CM._menuElement.style.display='block';}
return false;}
return _CM._getReturnValue(e);},
_hide:function(){_CM._unhighlight();if(_CM._menuElement){_CM._menuElement.style.display='none';}},
_getMousePosition:function(e){e=e||window.event;var cursor={x:0, y:0};if(e.pageX||e.pageY){mX=e.pageX;mY=e.pageY;}else{var de=document.documentElement;var b=document.body;mX=e.clientX +(de.scrollLeft||b.scrollLeft) - (de.clientLeft||0);mY=e.clientY +(de.scrollTop||b.scrollTop) - (de.clientTop||0);}
return{x:mX, y:mY};}}
_CM.setup({'preventDefault':false, 'preventForms':false});function GetScroll(){var y=document.body.scrollTop;if(y==0){if(window.pageYOffset){return  window.pageYOffset;}else{return (document.body.parentElement)?document.body.parentElement.scrollTop:0;}}
return y;}
function SetScroll(y){window.scrollTo(0,y);}
function confirm_op(p,t){if(confirm("Are you sure you wish to "+t+"?")){_Loc(p);}}
function confirm_link(t){if(confirm("Are you sure you wish to "+t+"?")){return true;}
return false;}
var httpreq=create_http_request();function ajax_callback(t,x){try{httpreq.open("POST",t,true);httpreq.send(x);}catch(e){return;}}
function create_http_request(){try{if(window.XMLHttpRequest){return new XMLHttpRequest();}else if(window.ActiveXObject){return new ActiveXObject("Microsoft.XMLHTTP");}}catch(e){return null;}}
var ajax_inProgress=0;var ajax_queue=[];function ajax_next_inqueue(){if(!ajax_inProgress&&ajax_queue.length>0){var t=ajax_queue.pop();ajax_callback_return_js(t[0],t[1]);}}
function ajax_callback_return_js(target,xml){if(ajax_inProgress){var t=[target,xml];ajax_queue.push(t);return;}
ajax_inProgress=1;try{httpreq.open("POST",target,true);httpreq.onreadystatechange=callbackFunction;httpreq.send(xml);}catch(e){return;}}
function callbackFunction(){if(httpreq.readyState!=4){return;}
ajax_inProgress=0;try{var sc=httpreq.responseText;if(sc!==null&&sc!==""){eval(sc);}}catch(e){}
ajax_next_inqueue();}
function ajax_ad_click(i){ajax_callback("handlers/ajax.adclick.php",i);}
function sSubGrid(name){var tr=null;var row=_Find(name);if(row.className=="sport"){row.className="sportzoom";_Find("im_"+name).src='ims/dropdownbw_wide.png';tr=_Find("charttr_"+name);if(tr){tr.style.display='table-row';}}else{row.className="sport";_Find("im_"+name).src='ims/dropdownbw_wideright.png';tr=_Hide("charttr_"+name);}
for(var i=1;i<100;i++){if(_Find(name+i)!=null){if(_Style(name+i).display=='none'){_Style(name+i).display='table-row';}else{_Hide(name+i);}}else{return;}}}
function _ShowMask(a){if(!_Def(a)){a=8;}
var m=document.createElement('div');m.setAttribute('id', 'qblur');m.style.opacity=a/10;m.style.filter='alpha(opacity=' + a*10 + ')';m.style.display="block";document.body.appendChild(m);_FitMask();addEvent(window,"load",_FitMask);addEvent(window,"resize",_FitMask);}
function _FitMask(){var m=_Find("qblur");var y=GetDocHeight();m.style.height=y+"px";}
function _HideMask(){removeEvent(window,"load",_FitMask);removeEvent(window,"resize",_FitMask);var obj=document.getElementById("qblur");document.body.removeChild(obj);_Uncache("qblur");}
function GetDocHeight(){var D=document;return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight));}
function dragQForm(e){var ev=e||window.event;$window_object.style.left=(ev.clientX-$window_mouse_offset.x) + "px";$window_object.style.top=(ev.clientY-$window_mouse_offset.y) + "px";}
var $window_object=null;var $window_mouse_offset={x:0,y:0};function startDragQForm(e){var ev=e||window.event;addEvent(window,'mouseup',endDragQForm,false);addEvent(window,'mousemove',dragQForm,false);$window_object=_Find("qlaunch");$window_object.className="dragging";$window_mouse_offset.x=ev.clientX - parseInt($window_object.style.left,10);$window_mouse_offset.y=ev.clientY - parseInt($window_object.style.top,10);}
function endDragQForm(ev){$window_object.className="";removeEvent(window,'mouseup',endDragQForm,false);removeEvent(window,'mousemove',dragQForm,false);}
var $window_iframe_name="qiframe";function createForm(url,title,top,width,height){var container=_Div("qlaunch","");if(_Def(width)&&width!=null){container.style.width=width+"px";}
if(_Def(height)&&height!=null){container.style.height=height+"px";}
container.style.left=80+"px";container.style.top=80+"px";var win=_Div("qwin","fwin");var header=_Div("qheader","qheader");header.innerHTML="<img src='http://esblib.com/skin/1/close_bl2.png' width='16' height='16' title='Close window' onclick='closeForm();' /><span>"+title+"</span>";header.onmousedown=startDragQForm;header.onselectstart=function (){return false;}
header.ondragstart=function (){return false;}
header.ondrag=function (){return false;}        
var dragfix=document.createElement('div');dragfix.className="dragfix";var iframe=document.createElement('iframe');$window_iframe_name="qiframe"+new Date().getTime();iframe.id=$window_iframe_name;iframe.name=$window_iframe_name;iframe.setAttribute('id', $window_iframe_name);iframe.src=url;iframe.frameBorder=0;if(_Def(width)&&width!=null){iframe.style.width=(width-6)+"px";}
if(_Def(height)&&height!=null){iframe.style.height=(height-35)+"px";}
win.appendChild(header);win.appendChild(dragfix);win.appendChild(iframe);_ShowMask(6);container.appendChild(win);document.body.appendChild(container);}
function submittedForm(){}
function closeAndCreateForm(url,title,top,width,height){closeForm();createForm(url,title,top,width,height);}
function closeForm(){var obj=document.getElementById($window_iframe_name);document.getElementById("qwin").removeChild(obj);_Uncache($window_iframe_name);obj=document.getElementById("qlaunch");document.body.removeChild(obj);_Uncache("qlaunch");_HideMask();}
var currentRace=new Number(0);var clockcntr=new Number(0);var races_ls=new Array();var races_dt=new Array();function tickClock(){var dt=races_dt[currentRace];if(dt!=null){var now=new Date();var diff=(dt.getTime()-now.getTime())/1000;var weeks=Math.floor( diff/(604800) );var week_s=weeks*604800;_InHtml("vweek",_NN(weeks));var days=Math.floor( (diff-week_s)/(86400) );var day_s=days*86400;_InHtml("vday",_NN(days));var hours=Math.floor( (diff-week_s-day_s)/(3600) );var hour_s=hours*3600;_InHtml("vhour",_NN(hours));var mins=Math.floor( (diff-week_s-day_s-hour_s)/(60) );var min_s=mins*60;_InHtml("vmin",_NN(mins));var secs=Math.floor( (diff-week_s-day_s-hour_s-min_s) );var sec_s=secs;_InHtml("vsec",_NN(secs));var ms=Math.floor((diff-week_s-day_s-hour_s-min_s-sec_s)*1000);clockcntr++;if(clockcntr>25){clockcntr=0;nextClock();}
setTimeout(tickClock,ms);}else{setTimeout(tickClock,600);}}
var cntdwn_letter=0;function writeClockTitle(){var title=races_ls[currentRace];if(title!=null){_Find("vtitle").innerHTML +=title.charAt(cntdwn_letter);cntdwn_letter++;if(cntdwn_letter<title.length){setTimeout(writeClockTitle,70);}}else{setTimeout(writeClockTitle,600);}}
function nextClock(){currentRace++;if(currentRace>=races_ls.length){currentRace=0;}	
_InHtml("vweek","00");_InHtml("vday","00");_InHtml("vhour","00");_InHtml("vmin","00");_InHtml("vsec","00");_InHtml("vtitle","&nbsp;");cntdwn_letter=0;writeClockTitle();}
function starReg(id){var val=_Find(id).value;var s="l";for(var i=5;i<=50;i+=5){if(i==5){j="05";}else{j=i;}
if((i/10)<=val){_Find('star'+j+id).className=s+'star_sel';}else{_Find('star'+j+id).className=s+'star';}
if(s=="l"){s="r";}else{s="l";}}}
function starShow(id,val){val=val/10;var s="l";for(var i=5;i<=50;i+=5){if(i==5){j="05";}else{j=i;}
if((i/10)<=val){_Find('star'+j+id).className=s+'star_sel';}else{_Find('star'+j+id).className=s+'star';}
if(s=="l"){s="r";}else{s="l";}}}
function starClick(id,val){val=val/10;var s="l";for(var i=5;i<=50;i+=5){if(i==5){j="05";}else{j=i;}
nm='star'+j+id;ux=_Find(nm);if((i/10)<=val){ux.className=s+'star_sel';}else{ux.className=s+'star';}
ux.onmouseover=function (){};ux.onmouseout=function (){};ux.onclick=function (){};if(s=="l"){s="r";}else{s="l";}}
_Find(id).value=val;_Find(id).onchange();}
var $mb_message;var $mb_type;var $mb_cheight;var $mb_scrollmode;var $mb_wn_maw=null;var $mb_wn_ms=null;var $mb_wn_mci=null;function $mb_draw(){var ani=_Div("MessageAnimationWindow","MessageAnimationWindow");_Find("esBody").appendChild(ani);$mb_wn_maw=ani;var sh=_Div("MessageShadow","MessageShadow");ani.appendChild(sh);$mb_wn_ms=sh;var c=_Div("MessageContainer","BottomMessage");if($mb_type=='m'){c.className +=" MessageContainer";} 
else if($mb_type=='e'){c.className +=" ErrorContainer";} 
if($mb_type=='m'){icon="information.png";} 
else if($mb_type=='e'){icon="error.png";}     
var ic=_Div("MessageContainerInner","CenteredSection MessageInner");ic.innerHTML="<img src=\"ims/"+icon+"\" /><br/>"+$mb_message;c.appendChild(ic);$mb_wn_mci=ic;var fc=ic.firstChild;var cl=_Div("MessageClose","MessageClose");cl.onclick=$mb_close;if($mb_type=='m'){cl.innerHTML="<div>close <img src=\"ims/close_bl.png\" /></div>";} 
else if($mb_type=='e'){cl.innerHTML="<div>close <img src=\"ims/close_wh.png\" /></div>";}         
ic.insertBefore(cl,fc);ani.appendChild(c);$mb_cheight=0;$mb_scrollmode=4;$mb_scroll();setTimeout($mb_close,5000);}
function $mb_close(){if($mb_wn_maw===null){return;}
var mclose=_Find("MessageClose");var mcontainer=_Find("MessageContainerInner");if(mclose&&mcontainer){mcontainer.removeChild( mclose );}
_Uncache("MessageClose");$mb_scrollmode=-3;$mb_scroll();}
function $mb_scroll(){if($mb_wn_maw===null){return;}
$mb_cheight+=$mb_scrollmode;if($mb_cheight>95){$mb_cheight=95;}
if($mb_cheight<0){$mb_cheight=0;}
$mb_wn_maw.style.height=$mb_cheight+"px";if($mb_cheight==95){return;}
if($mb_cheight==0){$mb_end();return;}
setTimeout($mb_scroll,16);return;}
function $mb_end(){if($mb_wn_maw===null){return;}
$mb_wn_ms=null;$mb_wn_maw=null;$mb_wn_mci=null;ux=_Find("MessageAnimationWindow");if(ux){_Find("esBody").removeChild(ux);}
_Uncache("MessageAnimationWindow");}

