jQuery(function($){

	//Examples of how to assign the ColorBox event to elements
	$("a[rel='example1']").colorbox();
	$("a[rel='example2']").colorbox({transition:"fade"});
	$("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
	$("a[rel='example4']").colorbox({slideshow:true});
	$(".single").colorbox({}, function(){
	alert('Howdy, this is an example callback.');
	});
	$(".colorbox").colorbox();
	$(".youtube").colorbox({iframe:true, width:650, height:550});
	$(".iframe").colorbox({width:"80%", height:"80%", iframe:true});
	$(".inline").colorbox({width:"50%", inline:true, href:"#inline_example1"});
	
	externalLinks();

	$('#h3_scandinavia').hover(
		function(){
			$('#h4_agent').css('background','url(/_graphics/flat2.gif) -2392px -497px no-repeat');
		},
		function(){
			$('#h4_agent').css('background','url(/_graphics/flat2.gif) -3010px -497px no-repeat');
		}
	);

	$('#h3_uk').hover(
		function(){
			$('#h4_agent').css('background','url(/_graphics/flat2.gif) -1778px -497px no-repeat');
		},
		function(){
			$('#h4_agent').css('background','url(/_graphics/flat2.gif) -3010px -497px no-repeat');
		}
	);
	
	$('#h3_fra').hover(
		function(){
			$('#h4_agent').css('background','url(/_graphics/flat2.gif) -1164px -497px no-repeat');
		},
		function(){
			$('#h4_agent').css('background','url(/_graphics/flat2.gif) -3010px -497px no-repeat');
		}
	);

	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.demos.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */

	// The default axis is 'y', but in this demo, I want to scroll both
	// You can modify any default like this
	$.localScroll.defaults.axis = 'xy';
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#div_col2', // Could be a selector or a jQuery object too.
		queue:true,
		duration:1500
	});
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */
	$.localScroll({
		target: '#div_col2', // could be a selector or a jQuery object too.
		queue:true,
		duration:1000,
		hash:true,
		onBefore:function(e,anchor,$target){
			// The 'this' is the settings object, can be modified
		},
		onAfter:function(anchor,settings){			
			// The 'this' contains the scrolled element (#content)
		}
	});
});

function externalLinks(){
	$('a[rel="external"]').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
}

function UnCryptMailto(s){
	var n = 0;
	var r = "";
	for(var i = 0; i < s.length; i++){
		n = s.charCodeAt(i);
		if( n >= 8364 ){
			n = 128;
		}
		r += String.fromCharCode( n - 1 );
	}
	return r;
}

function linkTo_UnCryptMailto(s){
	location.href=UnCryptMailto(s);
}

jQuery.preloadImages = function(){
  for(var i = 0; i<arguments.length; i++){
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$.preloadImages("/_graphics/flat.gif");