var jq = jQuery.noConflict();

// section toggle, start hidden
jq(document).ready(function () {
	jq("#toggle_text").hide();
	jq("#toggle_control").click(function () {
		var str = jq("#toggle_control").text();
		if (str.toLowerCase().indexOf("show") > -1) {
			jq("#toggle_control").text("<< Hide details...");
		} else {
			jq("#toggle_control").text(">> Show details...");
		}
		jq("#toggle_text").toggle(500);
		return false;
	});
});

// Search field disappearing text
jq(document).ready(function () {
	var initial = "Search...";
	var empty = "";
	jq(".SearchTextBox").val(initial);
	jq(".SearchTextBox").focus(function () {
		if (jq(this).val() == initial) {
			jq(this).val("");
		}
	}).blur(function () {
		if (jq(this).val() == empty) {
			jq(this).val(initial);
		}
	});
});


// Fancybox initialization (recent projects, small gallery)
jq(document).ready(function () {
	if (jq('.mini_gallery').length == 0) { return }
	jq(".wsc_recent_projects ul li a[rel=wsc_group]").fancybox({
		'transitionIn': 'elastic',
		'transitionOut': 'elastic',
		'overlayColor': '#000'
	});
	jq(".mini_gallery ul li a[rel=wsc_group]").fancybox({
		'transitionIn': 'elastic',
		'transitionOut': 'elastic',
		'overlayColor': '#000'
	});
});


// Creating additional blocks for feedback send button
jq(document).ready(function () {
	jq(".Feedback_CommandButtons a.CommandButton").addClass("button3").wrapInner("<span><strong></strong></span>");
});


// Initialise cycle slideshow (fading banner slider)
jq(document).ready(function () {
	if (jq('.slideshow').length == 0) { return }
	jq('.slideshow').cycle({
		fx: 'fade',
		pause: 0,     // true to enable "pause on hover" 
		pauseOnPagerHover: 0,
		timeout: '5000'
	});
	jq('#ss_startstop').click(function () {
		if (jq('#ss_startstop').text() == "Click to stop.") {
			jq('.slideshow').cycle('pause');
			jq('#ss_startstop').text('Click to start.');
			jq('.ss_hide').removeClass('ss_hide').addClass('ss_show');
		} else {
			jq('.slideshow').cycle('resume');
			jq('#ss_startstop').text('Click to stop.');
			jq('.ss_show').removeClass('ss_show').addClass('ss_hide');
		}
	});
	jq('#ss_next').click(function () {
		jq('.slideshow').cycle('next');
	});
	jq('#ss_prev').click(function () {
		jq('.slideshow').cycle('prev');
	});

});


// Initialise font settings
Cufon.replace('h1, h2, h3, h4, h5', { fontFamily: 'Gothic', marginBottom: '-10px' });
Cufon.replace('ul#PfNavMega .Column > ul > li > a', { fontFamily: 'Gothic' });
jq(document).ready(function () {
	jq('h1, h2, h3, h4, h5, ul#PfNavMega .Column > ul > li > a').addClass("cufonApplied");
});
