
var state = 'none'; 

function showDiv(layer_ref) {

	$('div.our-work-pic-box').hide();
    var showDiv = "#" + layer_ref;
	
	$(showDiv).show();
	
	var firstImg = $(showDiv + " .our-work-pic-box-image-thumb a").attr("href");
	$("#full-image").attr({ src: firstImg});	  
	$('#main-display').show();
}



$(document).ready(function(){
	var layer_ref = GetAnchor();
	$('div.our-work-pic-box').hide();
	$('#main-display').hide();
	if (layer_ref == ''){
		showDiv('div1');
	}
	else{
		layer_ref = layer_ref.replace('image', 'div');
		showDiv(layer_ref);
	}			
		   
	// Attach to the click of a link and show the image in the main img
	$(".our-work-pic-box-image-thumb a").click(function(){
		var largePath = $(this).attr("href");
		//var largeAlt = $(this).attr("title");
		$("#full-image").attr({ src: largePath});
		return false;
		});
	$("a.our-work-pic-box-close").click(function(){
	    $('div#imageContainer').show();
		$('div.our-work-pic-box').hide();
		$('div#imageContainer img:not(:first)').hide();
	
		$('#main-display').hide();
		return false;
	   });
	
});

function GetAnchor(){
	var anchorValue = '';
	var url = document.location;
	var strippedUrl = url.toString().split("#");
	if(strippedUrl.length > 1)
	anchorValue = strippedUrl[1];
	return anchorValue;
}
