
// Init google analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6515692-1']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

$(document).ready( function() {

	// Init sliding top menu
	var nav = $("#topNav");

	//add indicator and hovers to submenu parents
	nav.find("li").each(function() {

		if ($(this).find("ul").length > 0) {
			$("<span>").text("").appendTo($(this).children(":first"));
			//show subnav on hover
			$(this).mouseenter(function() {
			$(this).find("ul").stop(true, true).slideDown();
			});
			//hide submenus on exit
			$(this).mouseleave(function() {
			$(this).find("ul").stop(true, true).slideUp();
			});
		}

	});

	// Init main top image slider (Company pictures)
	$("#slider").easySlider({
		loop: true,                           // Looping
		orientation: 'fade',                  // Fading
		autoplayDuration: 8000,               // Autoplay with 1 second intervals
		autogeneratePagination: true,         // Automatically generate pagination links
		restartDuration: 2500,                // In case of user interaction, restart the autoplay after 2.5 seconds
		nextId: 'nextBtn',
		prevId: 'prevBtn',
		pauseable: true,
		prevText: '',
		nextText: ''
	});

	// Init bottom image slider (References)
	$("#slider2").easySlider({
		loop: true,
		easing: 'linear',
		autoplayDuration: 6000,
		autogeneratePagination: true,
		prevText: '',
		nextText: '',
		prevId: 'prevBtn2',
		nextId: 'nextBtn2',
		pauseable: true,
		restartDuration: 2500
	});

	$(".jq_inline_label").live('click', function(event) {

		// Store inital value
		if(!$(event.currentTarget).hasClass('jq_init')) {
			inlinelabelvalue = $(event.currentTarget).attr('value');
			$(event.currentTarget).addClass('jq_init');
		}

		// If initial value is set then clear it, because it is the label (not true if a posted value is re-set in the input on reload)
		if($(event.currentTarget).attr('value') == inlinelabelvalue) {
			$(event.currentTarget).attr('value','');
		}

	});

	$(".jq_inline_label").blur(function(event) {

		// When nothing is entered in the box, re-set the inlinelabelvalue that is defined on first-time click
		if($(event.currentTarget).attr('value') == '') {
			$(event.currentTarget).attr('value',inlinelabelvalue);
		}

	});

});
