$(document).ready(function() {
	
	$('h3.green, h3.green-full, h3.dark, #cont .modFull h3.active, #cont .modFull h3.last, #bottom h3, #contact h3').addClass('cufonheader');
	$('.banner').addClass('cufonbanner');
	
	Cufon.replace('h3.green, h3.green-full, .banner, h3.dark, #cont .modFull h3.active, #cont .modFull h3.last, #bottom h3, #contact h3');
	
	hs.graphicsDir = jQueryImagesHref + '/highslide/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.outlineType = 'rounded-white';
	hs.wrapperClassName = 'controls-in-heading';
	hs.fadeInOut = true;
	hs.dimmingOpacity = 0.75;

	// Add the controlbar
	if (hs.addSlideshow) hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: false,
		overlayOptions: {
			opacity: 0.75,
			position: 'bottom center',
			hideOnMouseOut: false
		}
	});
	
	$('.highslide-full-expand').hide();


	
	 $('a.highslide').each(function() {
		    this.onclick = function() {
		      return hs.expand(this);
		    };
	 });

/*	
	$('a.fancybox').fancybox({
		'zoomOpacity'			: true,
		'overlayShow'			: true,
		'overlayOpacity'		: 0.4,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500
	});
*/
	
	 
	 /**
	  * Check if a link is external:
	  * load the frameset for external link!
	  */
	 $('a').click(function(event) {
		 var href= $(this).attr('href');
		 
		 // Check if this is a internal link
		 var pos = strpos(href, defaultHrefWithoutPrefix, 0);
		 // Check if this is a relative link
		 var pos2 = strpos(href, 'http://', 0);
		 // If external link and href is not '#'
		 if(pos === false && pos2 !== false && href !== '#') {
			event.preventDefault();
			window.location = defaultHref + '/external?url=' + $.base64Encode(href);
		 }
		 
	 });
	 
});


function strpos(haystack, needle, offset) {
    // Finds position of first occurrence of a string within another  
    // 
    // version: 909.322
    // discuss at: http://phpjs.org/functions/strpos
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Onno Marsman    
    // +   bugfixed by: Daniel Esteban
    // *     example 1: strpos('Kevin van Zonneveld', 'e', 5);
    // *     returns 1: 14
    var i = (haystack+'').indexOf(needle, (offset ? offset : 0));
    return i === -1 ? false : i;
}

