var explore = {
	boxID : 'index',
	navCaption : '',

	loadImage:function(clickedElement) {
		var sURL = $(clickedElement).attr('rel');
		$.ajax({
			async:	"true",
			type:	"GET",
			url:	sURL,
			success: function(sHTML){
				var sImgSrc = String(sHTML.match(/projectVisual" src="(.*?)"/gi));
				sImgSrc = sImgSrc.replace('projectVisual" src="', '');
				sImgSrc = sImgSrc.replace('"', '');
				$('#DetailImageContainer').html(sHTML);

				var sPrintContent = $('#projectDetailsContainerPrint').html();
				sPrintContent = sPrintContent.replace(/"media.php(.*?)"/gi, sImgSrc);
			 	$('#projectDetailsContainerPrint').html(sPrintContent);
			}
		});
	},

	injectProjectTitleHover:function() {
		explore.navCaption = $('.exploreContentHeader .selectedPInfo').text();

		$('.categoryOverview .box').each(function() {
			var sCaption = $(this).find('span.print').text();
			$(this).find('img').hover(
				function() {
					if (sCaption != '') {
						$('.exploreContentHeader .selectedPInfo').text(sCaption);
					}
				},
				function() {
					$('.exploreContentHeader .selectedPInfo').text(explore.navCaption);
				}
			);
		});
	},

	initialize:function() {

		$('.navigationLayer .btnInfo').live('click.showInfo', function() {
			$('.infoLayerContainer').show();
			return false;
		});

		$('.closeButton').live('click.hideInfo', function() {
			$('.infoLayerContainer').hide();
			return false;
		});

		$('.btnPrev, .btnNext').live('click.loadimage', function() {
			explore.loadImage(this);
			return false;
		});

		$(".cSelector").live("hover", function() {
		    $(this).toggleClass("hover");
		});

		$("#DetailImage").live("mouseover", function() {
		    $(this).addClass("hover");
		});
		$("#DetailImage").live("mouseout", function() {
		    $(this).removeClass("hover");
		});

		this.injectProjectTitleHover();
	}
}


function initPage() {
	explore.initialize();
}
