/*
 * Project: Orsa Ventures Corp.
 * Author: Rudy Affandi
 * Created: 11/06/2011
 * File name: functions.js
 */

// Basic settings
var companyName = 'Orsa Ventures 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
$.getScript('/cc/lib/jquery/plugins/jquery.url.js',function(){
	var lang_selector = jQuery.url.segment(0);
});

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

// jQuery initialization and CSS settings, waiting for DOM tree to initialize
$(document).ready(function(){

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

	// Preload images from CSS
	$.getScript('/cc/lib/jquery/plugins/preloadCssImages.jQuery_v5.js',function(){
		$.preloadCssImages();
	});

	// prettyPhoto set up
	if ($("a[rel^='prettyPhoto']").length > 0){
		$.getScript('/cc/lib/jquery/plugins/prettyphoto/jquery.prettyPhoto.js',function(){
			$("a[rel^='prettyPhoto']").prettyPhoto();
		});
	}

	// Banner slide show
	if ($('#slideshow').length > 0){
		$.getScript('/cc/lib/jquery/plugins/jquery.cycle.all.min.js',function(){
      $('#slideshow').cycle({
         fx: 'fade',
         speed: 'slow',
         pager: '#slidenav',
         timeout: 5000
      });

		});
	}

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

	// Projects map tooltip using imagemap
	if ($('.front_map area').length > 0){
		$.getScript('/cc/lib/jquery/plugins/jquery.qtip-1.0.0-rc3.min.js',function(){
			$('.front_map area').each(function(){
				$(this).qtip(
				{
					content: $(this).attr('alt'), // Use the ALT attribute of the area map
					style: {
						color: '#756940',
						background: '#fff',
						border: {
							width: 0,
							radius: 4,
							color: '#756940'
						},
						tip: true // Apply a tip at the default tooltip corner
					},
					position: { corner: { target: 'topRight', tooltip: $(this).attr('rel') } },
					hide: { when: 'mouseout', fixed: true }
				});
			});
		});
   }

	// Tabbed interface
	if ($('ul.tabs').length > 0){
		$.getScript('/cc/lib/jquery/plugins/jquery.tools.min.js',function(){
			$('ul.tabs').tabs('div.panes > div', { effect: 'fade' });
			$('.tab_name').unbind('click.jumpnm').bind('click.jumpnm', function(e){
				e.preventDefault();
				var tab_name = $(this).attr('href');
				$('.tabs').data('tabs').click(tab_name);
			});
			$('div.panes').show();
		});
   }

	// Show main menu
	$('.dropdown').delay(400).fadeIn('slow');

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

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



	// Experimental: IE6 stuff
	if ($.browser.msie  && parseInt($.browser.version) <= 6)
	{
   }

});
