// (jQuery) loveliness
$(document).ready(function(){

	// Front page project fades
	
		// To allow users without javascript to still see a css rollover, amend css here.
		$("#otherProjects div.project div.projectDetails").css({'background-color' : '#000000', 'opacity' : '0', 'text-indent' : '0px'});
		$("#otherProjects div.project div.projectDetails a").css({'text-align' : 'right'});


		// When user hovers over the project div, fade in the projectDetails div		
		$("#otherProjects div.project").hover(function () {
			$(this).children('div').fadeTo("normal", 0.88);
		},
		// Then fadeout again
		function(){
			$(this).children('div').fadeTo("normal", 0);
		});
	

	// Design / Development hidden links
		$(".designLink").click(function () {
			$("body").css({'background-image' : 'url(/img/structure/pageLayout/gridbg.gif)', 'background-repeat' : 'repeat'});
			$("#header").css({'background-image' : 'url(/img/structure/pageLayout/hgridbg.gif)', 'background-repeat' : 'repeat'});
			$("#secondaryContainer").css({'background-image' : 'url(/img/structure/pageLayout/gridbg.gif)', 'background-repeat' : 'repeat'});	
			$(".content").css({'background-image' : 'url(/img/structure/pageLayout/hgridbg.gif)', 'background-repeat' : 'repeat'});
			$("h1").css({'color' : '#FFFFFF'});			
		});
		
		$(".developLink").click(function () {
			$("body").css({'background-image' : 'url(/img/structure/pageLayout/developerBG.gif)', 'background-repeat' : 'no-repeat'});
			$("#header").css({'background' : 'none'});
			$("#secondaryContainer").css({'background' : 'none'});	
			$(".content").css({'background' : 'none'});
			$("h1").css({'color' : '#000000'});			
		 });		


	// Lightbox plugin for client images
	// Check the clients id exists on this page
	if ( $("#clients").length > 0 ) { 	

		$('#clients .layout4-1 div.clientWebsite a').lightBox({
			imageLoading: '/js/jQuery/lightbox/images/lightbox-ico-loading.gif',
			imageBtnClose: '/js/jQuery/lightbox/images/lightbox-btn-close.gif',
			imageBtnPrev: '/js/jQuery/lightbox/images/lightbox-btn-prev.gif',
			imageBtnNext: '/js/jQuery/lightbox/images/lightbox-btn-next.gif'
	
		});
	};

	// Open / Close help panel 
		$(".helpButton").click(function() {
			$("#content").addClass("helpPanel")
			$('#helpPanel').show('slow')
			return false;
		});
	
		$("#helpPanelTitle").click(function() {
			$('#helpPanel').hide('slow');
			$("#content").removeClass("helpPanel")
			return false;		
		});	

	// Wordpress JS hooks
	// Check the comments form exists on this page
	if ( $("#commentform").length > 0 ) { 		
		$("#commentform").validate({
		  highlight: function(element, errorClass) {
			 $(element).addClass(errorClass);
			 $(element.form).find("label[for=" + element.id + "]")
							.addClass(errorClass);
		  },
		  unhighlight: function(element, errorClass) {
			 $(element).removeClass(errorClass);
			 $(element.form).find("label[for=" + element.id + "]")
							.removeClass(errorClass);
		  },

		  errorElement: "strong"

		});
	};

	// Check tabs exist on this page
	if ( $("#tabs").length > 0 ) { 	
		// Hook tab UI onto tabs div
		$("#tabs").tabs();
	}


});

