// apply anchor to container
jQuery('.nugget, .side-nug').click(function(){
	link = jQuery(this).find('a').attr('href');
	window.location = link;
});

// pie
$(function() {
	if (window.PIE) {
		$('.rounded-10px').each(function() {
			PIE.attach(this);
		});
	}
});

function propergateformfeild(idname,valuetext){

	values = jQuery(idname).attr('value');

	if(values != valuetext && values == ''){

		jQuery(idname).attr('value',valuetext);

		jQuery(idname).click(function(){
			current_value = jQuery(idname).attr('value');

			if(current_value == valuetext && values == ''){

				jQuery(idname).attr('value','');

			}

		});


		jQuery(idname).blur(function(){
			current_value = jQuery(idname).attr('value');

			if(current_value == ''){

				jQuery(idname).attr('value',valuetext);

			}

		});

	}

}

//gallery image change
function clickdisplay(classe,ide){
i = 1;
jQuery(classe).each(function(){

jQuery(this).attr('title',i);
i++;

});
jQuery(classe).click(function(){
var_title = jQuery(this).attr('title');
jQuery(ide+' li').hide();
jQuery(ide+var_title).fadeIn('slow');
});
}



$(document).ready(function(){

	jQuery(".testimonial_slider").cycle({ 
	    	fx:     'fade', 
		    speed:  'slow', 
	    	timeout: 18000,
			slideExpr:	' .testimonial_slide',
			pause: true
	 	
	});
	

	// tabbed box
	// when a link is clicked
	$(".tab").click(function () {

		// switch all tabs off
		$(".active").removeClass("active");

		// switch this tab on
		$(this).addClass("active");

		// slide all content up
		$(".content").slideUp();

		// slide this content up
		var content_show = $(this).attr("rel");
		$("#"+content_show).slideDown();

	});

	//contact form

	propergateformfeild("#contact-form-name", "Name *");
	propergateformfeild("#contact-form-email", "Email *");
	propergateformfeild("#contact-form-telephone", "Telephone *");


	//slideshow

	jQuery('#main-image-wrap ul').innerfade({speed:2000,timeout:5000,type:'sequence',containerheight:'332px'});


	//gallery

	clickdisplay(".gal_item_thumb","#pen");



	jQuery('#getintouch_virtualoffice').appendTo('.offers_content');
	jQuery('.offers_content #getintouch_virtualoffice').css('display', 'block');


});


// add class 'final-nav' to final li in top-nav to remove border
$('#top-nav li').last().addClass("final-nav");

	// for cycle.js
	jQuery('#team_profile').cycle({ 
	timeout: 'disable',
	pager:  '.team_images',
	pauseOnPagerHover: true,
	pagerAnchorBuilder: function(idx, slide) { 
		// return selector string for existing anchor 
		return '.team_images a:eq(' + idx + ')'; 
	}

});
