
function tt_close() {
	if(document.getElementById("tt_window") !== null) {

		$('#tt_window').remove();
		
		if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
			$("body","html").css({height: "auto", width: "auto"});
			$("html").css("overflow","");
		}
	}
}

function accordion_close() {
	$('.service').children('.panel:visible').slideUp('slow', function() {
		$(this).parent().removeClass('selected');
		$(this).siblings('h2').css('background-position', 'top left');
	});
}

$(document).ready(function() {
		
	// Accordion - start //

	$('.service').mouseenter(function() {
		if ($(this).children('.panel').is(':hidden')) {
			$(this).children('h2').css('background-position', '0px -26px');
		}
	});
	
	$('.service').mouseleave(function() {
		if ($(this).children('.panel').is(':hidden')) {
			$(this).children('h2').css('background-position', 'top left');
		}
	});
	
	
	$('.service').click(function() {
			
		if ($(this).children('.panel').is(':hidden')) {
			$(this).addClass('selected');
			$(this).children('h2').css('background-position', '0px -52px');
		
			$(this).children('.panel').slideDown('slow');
		}
		
		$(this).siblings('.service').children('.panel:visible').slideUp('slow', function() {
			$(this).parent().removeClass('selected');
			$(this).siblings('h2').css('background-position', 'top left');
		});
		
	}).children('.panel').hide();
	
	
	// Accordion - end //
	
	// Lightbox - start //
	
	tt_getflash_txt = '<div id="flashwarning"><img src="images/global/flashwarning.gif" /><h3>You require the Adobe Flash player to view this content.</h3><p>To download the free plug-in, <a href="http://www.adobe.com/go/getflashplayer">click here</a>. Alternatively, you can return to the site by clicking <a href="javascript:tt_close();">here.</a></p></div>';
	
	
	$('.project').click(function() {
				
		if(document.getElementById("tt_window") === null) {
			if (typeof document.body.style.maxHeight === "undefined") { //if IE 6
				$("body","html").css({height: "100%", width: "100%"});
				$("html").css("overflow","hidden");
			}
			
			$("body").append("<div id='tt_window'></div>");
			$("#tt_window").append("<div id='tt_relative'></div>");
			$("#tt_relative").append("<div id='tt_content' name='tt_content"+Math.round(Math.random()*1000)+"' style='width:100%;height:100%;' >"+tt_getflash_txt+"</div>");
						
			var flashvars = {projectRef: $(this).children('a:first').attr('id') };
			var params = {wmode: "transparent"};
			var attributes = {};
			attributes.id = "tt_content";
			swfobject.embedSWF('swf/project.swf', "tt_content", "100%", "100%", "9.0.0", 'swf/expressInstall.swf', flashvars, params, attributes);
			
			$("#tt_window").show();
		}
						
		return false;				 
	});
	
	// Lightbox - end //
});


