﻿// JScript File

var projectspage = false;
var currentID = "";

$(document).ready(function() {
	if ($(".photo")) {
		if ($(".photo").attr("src") != null && $(".photo").attr("src").indexOf("projects") > -1) {
			projectspage = true;
		}
		//currentID = $(".photo").attr("src").replace("/images/aboutitem/", "").replace("/Images/Projects/400/", "").replace(".jpg", "");
		//alert(currentID);
	}
});


function ChangeImage(newid)
{
	document.getElementById('ctl00_cphContent_img').src = "images/projects/" + newid + "-400.jpg";
}

function setImage(id) {
	//$(".photo").hide();
	$(".photo").attr("src", "/images/aboutitem/" + id + ".jpg");
	//$(".photo").fadeIn('slow');

	$("#item" + currentID).removeClass("currentnumber");
	$("#item" + id).addClass("currentnumber");
	currentID = id;
	
	//document.getElementById(holder).src = "/images/aboutitem/" + id + ".jpg";
}

function setProjectImage(id) {
	//$(".photo").hide();
	$(".photo").attr("src", "/images/projects/400/" + id + ".jpg");
	//$(".photo").fadeIn('slow');

	$("#item" + currentID).removeClass("currentnumber");
	$("#item" + id).addClass("currentnumber");
	currentID = id;
	
	//document.getElementById(holder).src = "/images/projects/400/" + id + ".jpg";
}

$(function() {
	// Bind an event to window.onhashchange that, when the hash changes, gets the
	// hash and adds the class "selected" to any matching nav link.
	$(window).bind('hashchange', function() {
		var hash = location.hash;
		if (hash != "") {
			//alert(hashvars[1] + " - " + hashvars[0]);
			if (projectspage)
				setProjectImage(hash.replace("#", ""));
			else
				setImage(hash.replace("#", ""));
		}
	})

	// Since the event is only triggered when the hash changes, we need to trigger
	// the event now, to handle the hash the page may have loaded with.
	$(window).trigger('hashchange');
})