
// CUFON
Cufon.replace('h1', { fontFamily: 'DIN' });
Cufon.replace('h2', { fontFamily: 'DIN' });
Cufon.replace('.body-overview-right-box a', { fontFamily: 'DIN' });
Cufon.replace('.bottom-three-home-left-header', { fontFamily: 'DIN' });
Cufon.replace('.bottom-three-home-middle-header', { fontFamily: 'DIN' });
Cufon.replace('.bottom-three-home-right-header', { fontFamily: 'DIN' });

function changeTab(tabId) {
	$tabs.tabs('select', tabId); // switch to third tab
	return false;
}

function navigateToURL(url, target) {
	if(target) {
		window.open(url, target)
	} else {
		window.location.href = url;
	}
}
		
$(document).ready(function() {
		
	// JSCROLLPANE
	$('.scroll').jScrollPane({
		showArrows: true,
		scrollbarWidth: 9
	});					
	
	// UNIT PNG FIX
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		fixPng();
	}
	
	// SUPERFISH
	$('ul.sf-menu').superfish({
		dropShadows: false, 
		autoArrows: false,
		disableHI: false,  
		speed: 0
	});
	
	// FANCYBOX
	$("a.iframe").fancybox({
		transitionIn: "elastic",
		transitionOut: "elastic",
		speedIn: 400,
		overlayColor: "#000",
		overlayOpacity: 0.8,
		width: 400,
		height: 420,
		titleShow: false,
		padding: 0,
		scrolling: "no"
	});
	$("a.gallery").fancybox({
		transitionIn: "elastic",
		transitionOut: "elastic",
		speedIn: 400,
		overlayColor: "#000",
		overlayOpacity: 0.8,
		titleShow: false,
		padding: 0,
		scrolling: "no"
	});
	
	// ANCHOR NAV
	$(".body-left-content").anchorNavigation({
		wrapper: "#sidenav-anchor",
		outputTarget: ".sidenav-anchor #jQueryTarget",
		onNavHiddenByScroll: {
			
		}
	});
	
	// LOCALSCROLL
	$(".body-right").localScroll({
		target: window,
		hash: true,
		duration: 800
	});
	
	// EMAIL CLOAKING
	$(".emailCloak").each(function(){
		var ats, dots, address, i, foundDots;
		ats = [ ' at ', ' (at) ', ' [at] ' ];
		dots = [ ' dot ', ' (dot) ', ' [dot] ' ];
		address = $(this).html();
		for ( i = 0; i < ats.length; i++ ) {
			address = address.replace(ats[i], '@');
		}
		for ( i = 0; i < dots.length; i++ ) {
			foundDots = [];
			foundDots = address.split(dots[i]);
			for(var j=1; j<foundDots.length; j++) {
				address = address.replace(dots[i], '.');
			}
		}
		$(this).html('<a href="mailto:' + address + '">' + address + '</a>');
	});
	
	//TABS
	var $tabs = $(".tabs").tabs();
	
	
});
