
function ge(i) { return document.getElementById(i); }
function hd(i) { ge(i).style.display = 'none';      }
function sh(i) { ge(i).style.display = '';          }



function surInit(){
 var i,s,qs=document.getElementsByTagName('select');
 for(i=0;i<qs.length;i++){
  s=qs[i];
  if (s && s.onchange){
   s.onchange();
  }
 }
}
function surCh(id) { ge('na' + id).checked=false; }
function surDep(id,arr){
 var e,t,v,i,j,f,c=(ge('qu'+id).selectedIndex-1);

 ge('na' + id).checked=(c==-1);

 for (i=0;i<arr.length;i++){
  v=arr[i][1];
  t=arr[i][0];
  f=false;
  for(j=0;j<v.length;j++){
   if(c==v[j]){
    f=true;
   }
  }
  f ? $('#rw'+t).show() : $('#rw'+t).hide();
  if(ge('rwe'+t)){
   f ? $('#rwe'+t).show() : $('#rwe'+t).hide();
  }
  if(ge('rws'+t)){
   f ? $('#rws'+t).show() : $('#rws'+t).hide();
  }
  e = ge('qu'+t);
  if (!f && e && e.tagName.toLowerCase() == 'select'){
   e.selectedIndex = 0;
   e.onchange();
  }
 }
}
$(document).ready(function(){surInit();});



$(function(){
    // round the corners in a less DOM intensive way
    // leaves rancid browsers out of the picture.
   //Fudge to make sure long submenus dont go over main content
      if(navigator.userAgent.match(/i(Phone|Pod)/)){
        $('#content').css('margin-top', parseInt( $('#content').css('margin-top').replace('px', '') ) + parseInt( $('ul#sub, ul#subtag').height() + 20 ) + 'px');
   }else{
        $('#content').css('margin-top', parseInt( $('#content').css('margin-top').replace('px', '') ) + parseInt( $('ul#sub, ul#subtag').height() - 18 ) + 'px');
   }
    if (!jQuery.browser.msie || jQuery.browser.version > 6) {
    
        //<TOP MENU ROUNDED CORNERS>
        if(!navigator.userAgent.match(/i(Phone|Pod)/)){
        $('div#wrapper div#header div#menu ul#top li.selected').each(function() {
            if ($(this).children('span.right, span.left').length == 0) {
                $(this).prepend('<span class="right">&nbsp</span>')
                       .append('<span class="left">&nbsp</span>');
             }
        });
        }
        //</TOP MENU ROUNDED CORNERS>

        //<CORNERS FOR CONTENT BLOCKS WITH GREY SURROUND>
        $('div#leftBox, div#contWrap, div#search, div#home').prepend('<span class="tr">&nbsp</span>')
                           .prepend('<span class="tl">&nbsp</span>')
               .append('<span class="bl">&nbsp</span>')
                           .append('<span class="br">&nbsp</span>');
        //</CORNERS FOR CONTENT BLOCKS WITH GREY SURROUND>
        
        //<BOTTOM OF MAIN CONTENT WRAP (GREY BACKGROUND)>
        $('div#content').append('<span class="bl">&nbsp;</span>').append('<span class="br">&nbsp;</span>');
        //</BOTTOM OF MAIN CONTENT WRAP (GREY BACKGROUND)>
   }
   // fudge target _blank to all external links, to make page validate
   $('a').each(function() {if ($(this).attr('class') === 'external') {$(this).attr('target', '_blank');}});
   

});

