/*
 * Project: Cardero Resource Corp.
 * Author: Rudy Affandi
 * Created: 05/16/2011
 * File name: functions.js
 */

// Basic settings
var companyName = 'Cardero Resource Corp.';

// Main navigation drop down, 3rd level settings (please enter 'yes' or 'no')
var allow_main_3rd_level = 'no';

// Side navigation drop down, 3rd level settings (please enter 'yes' or 'no')
var allow_side_3rd_level = 'yes';

//Grab language selector from scripts alias
var lang_selector = jQuery.url.segment(0);

// jQuery initialization and CSS settings, waiting for DOM tree to initialize
$(document).ready(function(){

   // Set language information and retrieve associated content
   if (lang_selector == 'esp'){
      $('html').attr('lang', 'es');
      // Translate elements to Spanish
      $('.footer').translate('spanish');
   }
   else {
      $('html').attr('lang', 'en');
   }

   // Home page slide show (fade in/out style, random)
   /*
   $('.front_img').cycle({
      fx: 'fadeZoom', 
      random: 0, 
      speed: 4000,
      easeIn: 'easeInQuad',
      easeOut: 'easeOutQuad'
   });*/

   // Home page slide show (flash)
   $('.front_img').flash({
      src: '/i/common_2011/Cardero-anim2.swf',
      wmode: 'transparent',
      width: '700',
      height: '299'
   });

   // Photo gallery settings (Grid format)
 	$('.image_grid_format ul li a[href*="_sm"], .content_side ul ul li a[href*="_sm"]').each(function(){
 	   var href = $(this).attr('href').replace('_sm', '');
 	   $(this).attr('href', href);
   });   

   // Get section title and display in content header
   var sectionTitle = $('.content_side h2').text();
   $('.content_header').append('<h2>' + sectionTitle + '</h2>');

   // Projects section   
   if ($('.prj_format, .image_grid_format').length > 0){
      var related_info = $('.content_side ul ul:visible').html();
      var page_title = $('.prj_format h2:first').text();
      $('.content_side ul ul, .prj_format h2').hide();
      if (page_title != '') {
         $('.content_body h2:first').append(': ' + page_title);
      } else {
         var section_name = $('.content_side ul li a.has_sub.active:first').text();
         $('.content_body h2:first').prepend(section_name + ': ');
      }
      $('.content_side').after('<div class="content_side"></div>');
      $('.content_side:nth-child(2)').prepend('<h2>Related Information</h2>');
      $('.content_side:nth-child(2)').append('<ul>' + related_info + '</ul>');
   }

   // Projects map tooltip
   $('area').each(function(){
      $(this).qtip(
      {
         content: $(this).attr('alt'), // Use the ALT attribute of the area map
         style: {
            color: '#000',
            background: '#ffffff',
            border: {
               width: 0,
               radius: 4,
               color: '#ffffff'
            }, 
            tip: true // Apply a tip at the default tooltip corner
         }, 
         position: { corner: { target: 'topLeft', tooltip: 'leftMiddle' } },
         hide: { when: 'mouseout', fixed: true }
      });
   });


});




