/*
 * Project: Aura Silver Resources Inc.
 * Author: Rudy Affandi
 * Created: 01/18/2011
 * File name: functions.js
 */

// jQuery initialization and CSS settings
$(document).ready(function(){
   // Activate "class='active'" on current URL
   var path = location.pathname.substring(1).toLowerCase();
   if ( path )
   {
     $('#nav li a[href$="' + path + '"]').attr('class', 'active');
     $('.content_side ul li a[href$="' + path + '"]').attr('class', 'active');
   }

   // For URL with parameters
   var path2 = location.search.substring(1).toLowerCase();
   if ( path2 )
   {
     $('#nav li a[href$="' + path2 + '"]').attr('class', 'active');
     $('.content_side ul li a[href$="' + path2 + '"]').attr('class', 'active');
   }

   // Front map tooltip
   $('area').each(function(){
      $(this).qtip(
      {
         content: $(this).attr('alt'), // Use the ALT attribute of the area map
         style: {
            name: 'light', // Give it the preset light style
            color: '#003e77',
            border: {
               width: 0,
               radius: 4,
               color: '#6b6f73'
            }, 
            tip: true // Apply a tip at the default tooltip corner
         }, 
         position: { corner: { target: 'center', tooltip: 'leftMiddle' } }
      });
   });

   // Main navigation, please use #nav for your main UL
   sfHover = function() {
      var sfEls = document.getElementById("nav").getElementsByTagName("LI");
      for (var i=0; i<sfEls.length; i++) {
         sfEls[i].onmouseover=function() {
            this.className+=" sfhover";
         }
         sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
         }
      }
   }
   if (window.attachEvent) window.attachEvent("onload", sfHover);
});

// External link warning dialog
function extLink(link) {
   var answer = confirm('You are leaving Aura Silver Website')
   if (answer){
      window.location = link;
   }
   else {
      return false;
   }
}
