$(document).ready(function(){	

	// THIS FUNCTION IS TO INJECT THE MARGIN BOTTOM FOR SUB_MENU WHEN "BACK TO LIST" LINK IS BEING SHOWED
	if($("div.news-single-backlink").text() != ""){	  
	 var cssObj = {
		   'margin-bottom' : '100px'
		 }
		 
	 $("#sub-navigation ul").css(cssObj);    
	}
	
	//THIS FUNCTION IS TO EXPAND THE MARGIN-BOTTOM FOR SUB-NAV
	$("a#bookingbutton").click(function(){
		$("#onlinebooking").toggle();
		return false;
	});
	
	
	//THIS BIT IS TO CROP IMAGE FOR EVENTS, NEWS IMAGES ON HOMEPAGE
	$(".news-latest-Image img").each(function(){                       
	$(this).replaceWith(
		$(this)
			.clone()
			.attr('src', '/grayscale.php?w=62&h=62&url=' + this.src + '_gray.jpg')
			.load(function(){
				$(this).closest("#show-me-when-done").css({visibility: 'visible'});
				$(this).closest("#show-me-when-done img").css({width:'62px;'});
		})
	)
	});
	
	
	//events listing under prioject detail page
	$(".event-body img").each(function(){                       
	$(this).replaceWith(
		$(this)
			.clone()
			.attr('src', '/grayscale.php?w=62&h=62&url=' + this.src + '_gray.jpg')
			.load(function(){
				$(this).closest(".event-image").css({visibility: 'visible'});
		})
	)
	});
	
	
	$(".news-list-item img").each(function(){                       
	$(this).replaceWith(
		$(this)
			.clone()
			.attr('src', '/grayscale.php?w=115&h=115&url=' + this.src + '_grey.jpg')
			.load(function(){
				$(this).closest(".news-list").css({visibility: 'visible'});
		})
	)
	});
	
	
	//THIS BIT IS TO CROP IMAGE FOR PROJECT HIGHTLIGHT ON HOMEPAGE
	$("#project-highlight-home img").each(function(){                       
	$(this).replaceWith(
		$(this)
			.clone()
			.attr('src', '/grayscale.php?w=115&h=115&url=' + this.src + '_gray.jpg')
			.load(function(){
				$(this).closest(".project-hightlight-image").css({visibility: 'visible'});
		})
	)
	});
	
	
	//	THIS BIT IS TO CROP IMAGE FOR RESOURCES PAGE
	//	http://lcf.kdwebserver.co.uk/resources/overview/
	
	$("#resource-list img").each(function(){                       
	$(this).replaceWith(
		$(this)
			.clone()
			.attr('src', '/grayscale.php?w=64&h=64&url=' + this.src + '_gray.jpg')
			.load(function(){
				$(this).closest(".resource-image").css({visibility: 'visible'});
		})
	)
	});
	
	
	$(".news-single-img img").each(function(){                       
	$(this).replaceWith(
		$(this)
			.clone()
			.attr('src', '/grayscale.php?url=' + this.src + '_gray.jpg')
			.load(function(){
				$(this).closest(".news-single-img").css({visibility: 'visible'});
		})
	)
	});
	
	
	
	
	$("#project-highlight img").each(function(){                       
	$(this).replaceWith(
		$(this)
			.clone()
			.attr('src', '/grayscale.php?w=115&h=115&url=' + this.src + '_gray.jpg')
			.load(function(){
				$(this).closest(".project-image").css({visibility: 'visible'});
		})
	)
	});	
});	




