
function SetRadio(field,setto){var x=document.forms['canalform'].elements[field];for(i=0;i<x.length;i++){if(x[i].value==setto){x[i].checked=true;}else{x[i].checked=false;}}
if(field=="opt_dist_fmt")
change_calculation_unit();}
function SetCheckbox(field){var x=document.forms['canalform'].elements[field];x.checked=!(x.checked);}
function MapCheckbox(wh){if(document.forms['canalform'].elements[wh].checked==true){document.forms['canalform'].elements['maincheck_map'].checked=true;}}
function MapChecktext(field){var x=document.forms['canalform'].elements[field];x.checked=!(x.checked);if(x.checked==true)
document.forms['canalform'].elements['maincheck_map'].checked=true;}
function ToggleBox(field){var toswap=document.forms['canalform'].elements[field];toswap.checked=!toswap.checked;}
function Preload(Path,Name,Txt){imagelist[Name]=new Image;imagelist[Name].src="../images/icons/"+Path+"s/"+Name+".gif";imagelist["shadow"+Name]=new Image;imagelist["shadow"+Name].src="../images/icons/"+Path+"shadow/"+Name+".gif";promptlist[Name]=Txt;}
function PreloadLocal(Path,Name,Txt){imagelist[Name]=new Image;imagelist[Name].src="../images/icons/"+Path+"s/"+Name+".gif";imagelist["shadow"+Name]=new Image;imagelist["shadow"+Name].src="../images/icons/"+Path+"shadow/"+Name+".gif";promptlist[Name]=Txt;}
function PreloadMulti(Path,File,Name,Txt){imagelist[Name]=new Image;imagelist[Name].src="../images/icons/"+Path+"s/"+File+".gif";imagelist["shadow"+Name]=new Image;imagelist["shadow"+Name].src="../images/icons/"+Path+"shadow/"+File+".gif";promptlist[Name]=Txt;}
function ShadowImage(Name){if(document.images){document.images[Name].src=imagelist["shadow"+Name].src;}
window.status=promptlist[Name];}
function ResetImage(Name){if(document.images){document.images[Name].src=imagelist[Name].src;}
window.status='';}
function subit(what){if(what=="==close=="){window.close();return;}
document.forms['canalform'].elements['command'].value=what;document.forms['canalform'].submit();}
function subgaz(what){document['canalform'].elements['command'].value=what;document['canalform']._submit.click();}
function WriteButton(name,file,subas,text,btxt){document.writeln('<td><A HREF="javascript:subit',"('",subas,"')",'"');document.writeln(' onmouseover="ShadowImage(',"'",name,"')",'" onmouseout="ResetImage(',"'",name,"')",'">');document.writeln('<img src="../images/icons/buttons/',file,'.gif" alt="',text,'" name="',name,'" border="0"></A></td>');if(text=="")return;document.writeln('<td><A HREF="javascript:subit(\'',subas,'\')"');document.writeln('onmouseover="ShadowImage(\'',name,'\')" onmouseout="ResetImage(\'',name,'\')">',btxt,'</td>');}
function WriteLinkButton(name,file,link,text,btxt){document.writeln('<td><A HREF="',link,'"');document.writeln(' onmouseover="ShadowImage(',"'",name,"')",'" onmouseout="ResetImage(',"'",name,"')",'">');document.writeln('<img src="../images/icons/buttons/',file,'.gif" alt="',text,'" name="',name,'" border="0"></A></td>');if(text=="")return;document.writeln('<td><A HREF="',link,'"');document.writeln('onmouseover="ShadowImage(\'',name,'\')" onmouseout="ResetImage(\'',name,'\')">',btxt,'</td>');}
function inserthere(n){var rv=perhaps_expand(do_insert(n));document.canalform["PLACE"+n].focus();return rv;}
function perhaps_expand(resetflag){if(resetflag){document.forms['canalform'].elements._submit[0].value="Update_Mainform";document.forms['canalform'].elements._submit[0].click();}}
function do_insert(n){var num=document.canalform["PLACE_NUMBER"].value;resetflag=false;if(document.canalform["PLACE"+num].value!=""){var x=num;x++;document.canalform["PLACE_NUMBER"].value=x;document.canalform["PLACE"+x].value=document.canalform["PLACE"+num].value;resetflag=true;}
for(i=num-1;i>=n;i--){x=i+1;ss="PLACE"+x;st="PLACE"+i;document.canalform[ss].value=document.canalform[st].value;}
document.canalform["PLACE"+n].value="";return resetflag;}
function deletehere(n){var num=1*document.canalform["PLACE_NUMBER"].value;var i=new Number;for(i=n;i<num;i++){var x=i;x++;ss="PLACE"+i;st="PLACE"+x;document.canalform[ss].value=document.canalform[st].value;}
document.canalform["PLACE"+num].value="";document.canalform["PLACE"+n].focus();}
function clearhere(n){document.canalform["PLACE"+n].value="";document.canalform["PLACE"+n].focus();}
function pop_up(contents){var newwindow=window.open(contents,"Whatsnew","scrollbars=yes");newwindow.focus();}
function ToggleShow(item){var thisone=document.getElementById(item).style;if(thisone.display=="block")
thisone.display="none";else
thisone.display="block";}
function ShowBlock(item){var thisone=document.getElementById(item).style.display="block";}
function HideBlock(item){var thisone=document.getElementById(item).style.display="none";}
function OptionsBlock(thing){if(document.forms['canalform'].elements['opt_'+thing].value=="hide"){document.getElementById(thing+"-off").style.display="none";document.getElementById(thing+"-on").style.display="block";document.canalform['opt_'+thing].value="show";}else{document.getElementById(thing+"-off").style.display="block";document.getElementById(thing+"-on").style.display="none";document.canalform['opt_'+thing].value="hide";}}
function synchronise_hpd(altered,other){document.forms['canalform'].elements[other].value=document.forms['canalform'].elements[altered].value;return false;}
function change_calculation_unit(chgto){var x=document.forms['canalform'].elements['opt_dist_fmt'];var y=document.forms['canalform'].elements['lastunit'];for(var i=0;i<x.length;i++){if(x[i].checked==true){if(x[i].value!=y.value){document.forms['canalform'].elements.submit[0].value="javaopts";document.forms['canalform'].elements.submit[0].click();return;}}}}
function ringdetails(numb){document.forms['canalform'].elements['_submit'].value='Show Ring Details';document.forms['canalform'].elements['detailsofwhat'].value=numb;document.forms['canalform'].elements['PL_START'][0].click();}
function PopUpCal(yy,mm,dd){var fm=document.forms['canalform'].elements;var yv=fm[yy].options[fm[yy].selectedIndex].text;var mv=fm[mm].options[fm[mm].selectedIndex].text;var dv=fm[dd].options[fm[dd].selectedIndex].text;var dt=dv+'/'+mv+'/'+yv;var win=window.open("../cgi-bin/showcal.cgi?t="+dt+";y="+yy+";m="+mm+";d="+dd,"popcal","width=200,height=170,toolbar=no,menubar=no,scrollbars=0,resizable=no");}
function setone(what,to){for(i=0;i<what.length;i++){if(what.options[i].text==to)
what.selectedIndex=i;}}
var pm_stuff={currentmenu:null,which_place:null,lastcurrentmenu:null,timer:null}
function PlaceMenu(pc,what,flg){var menu=document.getElementById(what)
var inbox=document.getElementById(pc);if(flg){var x=0,y=0;clearTimeout(pm_stuff.timer);y=inbox.offsetHeight;while(inbox.offsetParent){x=x+inbox.offsetLeft;y=y+inbox.offsetTop;inbox=inbox.offsetParent;}
menu.style.display="block";menu.style.left=x+"px";menu.style.top=y+"px";pm_stuff.which_place=pc;}else{pm_stuff.currentmenu=menu;pm_stuff.lastcurrentmenu=menu;pm_stuff.timer=setTimeout(HideMenu,1000);;}}
function HideMenu(){if(pm_stuff.currentmenu)
pm_stuff.currentmenu.style.display="none";}
function KillMenu(){if(pm_stuff.lastcurrentmenu)
pm_stuff.lastcurrentmenu.style.display="none";}
function KeepMenu(what,flg){var menu=document.getElementById(what);if(flg){pm_stuff.currentmenu=null;menu.style.display="block";}else{menu.style.display="none";}}
function place_clear(where){document['canalform'].elements[where].value='';KillMenu();document['canalform'].elements[where].focus();return false;}
function place_delete(where){var fm=document['canalform'].elements;var n,i;if(where=='PL_START'){fm[where].value=fm['PLACE1'].value;deletehere(1);}else if(where=='PL_END'){n=0;for(i=fm['PLACE_NUMBER'].value;i>0;i--){if(fm['PLACE'+i].value!=''&&n==0);n=i;}
if(n){fm[where].value=fm['PLACE'+n].value;fm['PLACE'+n].value='';}else{fm[where].value='';}}else{var n=where.replace(/PLACE/,"");deletehere(n);}
KillMenu();fm[where].focus();return false;}
function place_moreplaces(where){document.forms['canalform'].elements._submit[0].value="Extra_Places";document.forms['canalform'].elements._submit[0].click();}
function place_insert(where){var fm=document.forms['canalform'].elements;var n,i,rf;if(where=='PL_START'){rf=do_insert(1);fm['PLACE1'].value=fm[where].value;fm[where].value='';}else if(where=='PL_END'){n=0;for(i=1*fm['PLACE_NUMBER'].value;i>0;i--){if(fm['PLACE'+i].value!=''&&n==0){n=i+1;}}
if(n){fm['PLACE'+n].value=fm[where].value;fm[where].value='';if(n>1*fm['PLACE_NUMBER'].value){fm['PLACE_NUMBER'].value=n;rf=true;}}else{fm['PLACE1'].value=fm[where].value;fm[where].value='';}}else{var n=where.replace(/PLACE/,'');rf=do_insert(n);}
KillMenu();fm[where].focus();perhaps_expand(rf);return false;}
function place_lookup(where){var fm=document.forms['canalform'].elements
if(fm[where].value==''){KillMenu();document.forms['canalform'].elements[where].focus();return false;}
fm._submit[0].value='operate';fm['changeplace'].value='find';fm['unkpl'].value=fm[where].value;fm['fieldtochange'].value=where;KillMenu();fm._submit[0].click();}
function place_replace(where){var fm=document.forms['canalform'].elements;fm._submit[0].value='operate';fm['changeplace'].value='replace';fm['unkpl'].value=fm[where].value;fm['fieldtochange'].value=where;fm['lastsub'].value='';KillMenu();fm._submit[0].click();}
function place_overnight(where){alert(where);}
function place_tidyup(where){var fm=document.forms['canalform'].elements;var num=fm['PLACE_NUMBER'].value;var j=1;for(i=1;i<=num;i++){fm['PLACE'+j].value=fm['PLACE'+i].value;if(fm['PLACE'+j].value!='')
++j;}
for(;j<=num;j++)
fm['PLACE'+j].value=''
KillMenu();document.forms['canalform'].elements._submit[0].value="Update_Mainform";document.forms['canalform'].elements._submit[0].click();return false;}
function place_clearinter(where){var fm=document.forms['canalform'].elements;var num=fm['PLACE_NUMBER'].value;for(i=1;i<=num;i++)
fm['PLACE'+i].value='';KillMenu();return true;}
function place_reverse(where){var fm=document.forms['canalform'].elements;var num=1*fm['PLACE_NUMBER'].value;var swapem=fm['PL_START'].value;fm['PL_START'].value=fm['PL_END'].value;fm['PL_END'].value=swapem;for(i=1;i<=num/2;i++){swindex=num+1-i;swapem=fm['PLACE'+i].value;fm['PLACE'+i].value=fm['PLACE'+swindex].value;fm['PLACE'+swindex].value=swapem;}
var j=1;for(i=1;i<=num;i++){fm['PLACE'+j].value=fm['PLACE'+i].value;if(fm['PLACE'+j].value!='')
++j;}
for(;j<=num;j++){fm['PLACE'+j].value='';}
KillMenu();return true;}