/*
 * Project: Bitterroot Resources Ltd.
 * Author: Rudy Affandi
 * Created: 03/27/2011
 * File name: functions.js
 */

// Basic settings
var companyName = 'Bitterroot Resources Ltd.';

// Main navigation drop down, 3rd level settings (please enter 'yes' or 'no')
var allow_main_3rd_level = 'yes';

// Side navigation drop down, 3rd level settings (please enter 'yes' or 'no')
var allow_side_3rd_level = 'yes';

// jQuery initialization and CSS settings, waiting for DOM tree to initialize
$(document).ready(function(){

   // Projects map tooltip using mouseover 
   $('.prj li.map a, .prj li.photo a').each(function(){
      var thumb = '<img src="' + $(this).attr('rel') + '" alt="Loading thumbnail..." />';
      $(this).qtip({
         content: thumb,
         style: {
            name: 'dark', // Give it the preset dark style
            color: '#000',
            background: '#fff',
            border: {
               width: 0,
               radius: 3,
               color: '#009ad9'
            }, 
            width: 170,
            tip: true // Apply a tip at the default tooltip corner
         }, 
         position: { corner: { target: 'rightMiddle', tooltip: 'leftMiddle' } }
      });
   });

   // Projects map tooltip using imagemap
   $('area').each(function(){
      $(this).qtip(
      {
         content: $(this).attr('alt'), // Use the ALT attribute of the area map
         style: {
            name: 'dark', // Give it the preset dark style
            color: '#fff',
            background: '#893f12',
            border: {
               width: 0,
               radius: 3,
               color: '#43210b'
            }, 
            tip: true // Apply a tip at the default tooltip corner
         }, 
         position: { corner: { target: 'topLeft', tooltip: 'bottomLeft' } }
      });
   });

   // Photo gallery settings
   $(".scrollable").scrollable();
   $("#image_wrap, .scrollable, .scrollable img").addClass('ui-corner-all');
   $(".items img").click(function() {

	// see if same thumb is being clicked
	if ($(this).hasClass("active")) { return; }

	// Get the large image filename from thumbnail
	var url = $(this).attr("src").replace("_sm", "");

   // add caption from TITLE tag
	var caption = $(this).attr("title");
   $("h4").text(caption);
   
	// get handle to element that wraps the image and make it semi-transparent
	var wrap = $("#image_wrap").fadeTo("medium", 0.5);

	// the large image from www.flickr.com
	var img = new Image();

   	// call this function after it's loaded
	img.onload = function() {

		// make wrapper fully visible
		wrap.fadeTo("fast", 1);

		// change the image
		wrap.find("img").attr("src", url);
	};

	// begin loading the image from source folder/path
	img.src = url;

	// activate item
	$(".items img").removeClass("active");
	$(this).addClass("active");

   // when page loads simulate a "click" on the first image
   }).filter(":first").click();

});

// Additional functions

/* Disabled until problem with z-index fixed
// Fix jQuery rounded corners in IE
   if ($.browser.msie && $.browser.version.substr(0,1)<=7) {
   $.uicornerfix = function(r){
     DD_roundies.addRule('.ui-corner-all', r);
     DD_roundies.addRule('.ui-corner-top', r+' '+r+' 0 0');
     DD_roundies.addRule('.ui-corner-bottom', '0 0 '+r+' '+r);
     DD_roundies.addRule('.ui-corner-right', '0 '+r+' '+r+' 0');
     DD_roundies.addRule('.ui-corner-left', r+' 0 0 '+r);
     DD_roundies.addRule('.ui-corner-tl', r+' 0 0 0');
     DD_roundies.addRule('.ui-corner-tr', '0 '+r+' 0 0');
     DD_roundies.addRule('.ui-corner-br', '0 0 '+r+' 0');
     DD_roundies.addRule('.ui-corner-bl', '0 0 0 '+r);
   };
   // Initiate IE rounded corners
   $.uicornerfix('4px');
}
*/
