/*
 * Project: Masuparia Gold Corporation
 * Author: Rudy Affandi
 * Created: 09/27/2011
 * File name: functions.js
 */

// Basic settings
var companyName = 'Masuparia Gold Corporation';

// 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';

// Grab language selector from scripts alias
var lang_selector = jQuery.url.segment(0);

// Cufon usage in main navigation
var cufon_nav = 'yes';

// jQuery initialization and CSS settings, waiting for DOM tree to initialize
$(document).ready(function(){
	// Preload images
	$.preLoadImages('/i/common/header_corp.jpg', '/i/common/header_prj.jpg', '/i/common/header_inv.jpg', '/i/common/header_contact.jpg', '/i/common/header_news.jpg', '/i/common/header_misc.jpg', '/i/common/header_misc2.jpg', '/i/common/banner1.jpg', '/i/common/banner2.jpg', '/i/common/banner3.jpg', '/i/common/banner4.jpg', '/i/common/banner5.jpg', '/i/common/banner6.jpg', '/i/common/banner7.jpg', '/i/common/banner8.jpg', '/i/common/banner9.jpg', '/i/common/banner10.jpg');

   // Set language information, default to English
   $('html').attr('lang', 'en');

	// Set h tag margin
   $('.content_body h2:first, .content_body h3:first').not('.col h2').css('margin-top', '0');

	// Financials, check if PDF exist
	$('.fs_format div.link a').each(function() {
		if	( $(this).attr('href').length <= 0 )
		{
			$(this).hide();
		}
	});

   // Home page slideshow
   var path = $(location).attr('href');
   var filename = path.match(/.*\/([^/]+)\.([^?]+)/i)[1];
   filename = filename.toLowerCase();
   if (filename == 'home')
   {
      $('.front_header_img').cycle({
         fx: 'fade',
         speed: 'slow',
         random: '1',
         timeout: 7000
      });

		// Projects map tooltip using imagemap
		$('.front_map area').each(function(){
			$(this).qtip(
			{
				content: $(this).attr('alt'), // Use the ALT attribute of the area map
				style: {
					color: '#000',
					background: '#d5c994',
					border: {
						width: 0,
						radius: 4,
						color: '#6b5b34'
					},
					tip: true // Apply a tip at the default tooltip corner
				},
				position: { corner: { target: 'center', tooltip: $(this).attr('rel') } },
				hide: { when: 'mouseout', fixed: true }
			});
		});

   }

   // Fix Cufon refresh issue with navigation colour
   if (cufon_nav == 'yes')
   {
		$('.dropdown li a').ready(function(){
			Cufon.refresh();
		});

		$('.dropdown li').mouseout(function(){
			Cufon.refresh();
		});
   }

   // Validate form
   $('#signupform').validate();
   //$('#signupform input:text:first').focus();

   // Initiate shadowbox
    Shadowbox.init();
});

