
$(document).ready(function() 
{
	$(".bacgroundStretch").each( function() { AdjustHeight($(this)) } );
	
	$(window).resize( function() { AdjustHeight($(".bacgroundStretch")) } );
	$(window).scroll( function() { AdjustHeight($(".bacgroundStretch")) } );
	
	$("iframe").attr("ALLOWTRANSPARENCY", "true");
	
	$("iframe").load(function()
	{
		 var iFrameBody = document.getElementById("jstPressReleaseFrame").contentWindow.document.body;
		 $(iFrameBody).parents("html").css("background-color", "transparent");
		 $(iFrameBody).css("background-color", "transparent");
		 $(iFrameBody).attr("bgColor", "transparent");
		 $(iFrameBody).children("table").width("99%");
		 $(iFrameBody).find("tr td:nth-child(1)").width("1%");
		 $(iFrameBody).find("tr td:nth-child(2)").width("60%");
		 $(iFrameBody).find("tr td:nth-child(3)").width("38%");
		 $(iFrameBody).find("tr td:nth-child(3) img").attr({"align": "center", "background-color": "#fff", "border": "1px solid #ccc"});
		 $(iFrameBody).find("img").attr("src", function() { return "http://www.pilotmax.co.uk/pages/" + $(this).attr("src") });
		 $(iFrameBody).find("hr").css({"color": "#dde15e", "background-color": "#dde15e"});
	});
	
	$(".overlayLink").openDOMWindow(
	{
		height: 400,
		width: 600, 
		eventType:'click',
		windowSource:'iframe',
		loader:1, 
		loaderImagePath:'animationProcessing.gif', 
		loaderHeight:16, 
		loaderWidth:17 
	});
	
	$(".closeDOMWindow").click(function() 
	{
		parent.document.location.href = parent.document.location.href;
		return false;
	});
});

function AdjustHeight(target)
{
	var newHeight = 0;
	newHeight = $(target).parent().height();
	if ($(window).height() > newHeight + $(target).offset().top)
		newHeight = $(window).height() - $(target).offset().top;
	
	$(target).css({ "height": newHeight});	
}
