NCS = new Object();

NCS.is_safari = (document.childNodes)&&(!document.all)&&(!navigator.taintEnabled)&&(!navigator.accentColorName)?true:false;
NCS.is_ie55 = (document.all && document.fireEvent && !document.createComment);
NCS.win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);

$(document).ready(function() {

  //only need this function for ie 6 or less
  if(NCS.win_ie_ver && NCS.win_ie_ver < 7)NCS.tabRollvers();
 externalLinks();
 NCS.checkedboxes();
NCS.showbox('#Fax');
NCS.showbox('#Email');
NCS.showbox('#Post');
});

options = {
height: 'show',
opacity: 'show',
speed: 500,
show_hint: 1

};



function externalLinks(){
    if (document.getElementsByTagName){
        var objAnchors = document.getElementsByTagName('a');
        for (var iCounter=0; iCounter<objAnchors.length; iCounter++){
            if (objAnchors[iCounter].getAttribute('href') && objAnchors[iCounter].getAttribute('rel') == 'external'){
                objAnchors[iCounter].onclick = function(event){return launchWindow(this, event);};
                objAnchors[iCounter].onkeypress = function(event){return launchWindow(this, event);};
            }
        }
    }
}
function launchWindow(objAnchor, objEvent){
    var iKeyCode;
    if (objEvent && objEvent.type == 'keypress'){
        if (objEvent.keyCode)
            iKeyCode = objEvent.keyCode;
        else if (objEvent.which)
            iKeyCode = objEvent.which;
        if (iKeyCode != 13 && iKeyCode != 32)
        return true;
}

return !window.open(objAnchor);
}

//rollovers for browser that can't do hover
NCS.tabRollvers = function(){

$("#topnav_list").children('li').each(function(i){
if(this.className.match('roll')){
  $(this).mouseover(function() { this.className = this.className+'on';});
  $(this).mouseout(function() {  this.className=this.className.replace(new RegExp("on\\b"), ""); });
  }
});



};

NCS.boxes = ['Fax','Email','Post'];

NCS.hideboxes = function(){
$.each(NCS.boxes, function(){
  var boxname = '#'+this+'box';
  if($(boxname))
  $(boxname).hide();
});
}
NCS.checkedboxes = function(){
  $.each(NCS.boxes, function(){
    var box = '#'+this;
    var boxname = box+'box';
    if($(box).attr('checked') == true){
if($(boxname))
    $(boxname).show();
    }
  });
}

NCS.showbox = function(element){
$(element).click(function(){
NCS.hideboxes();
var boxname = element+'box';
if($(boxname))
$(boxname).show();
});

}
