$(document).ready(function() {
	if($("#portfolioSide")) {
		$("#portfolioSide a").click(function() {
			preload = new Image();
			preload.src = $(this).attr("href");
			$("#portfolioSide a").removeClass("paged");
			$(this).addClass("paged");
			
			$("#portfolioImage img").fadeOut(200,function() {
				fadeImageIn(preload.src)
			});
			return false;
		});
	}
	
//	$(".servicesImg div").fadeTo(0,.5);
	var current = "";
	$(".services a").mouseover(function() {
		$(".services a").removeClass("link");
		$(this).addClass("link");
		if(current!="" && current!=this.title) {
			$("#"+current).animate(
			 { 
            height: 70,
				opacity: .5
          },300
			);
		}
		current = this.title;
		$("#"+this.title).animate(
			 { 
				height: 247,
				opacity: 1
			 }, 
			 { duration: 300 }
		); 
		return false;
  });
	
	// PROJECTS
	$(".projects").mouseover(function() {
		$(".projects").removeClass("link");
		$(this).addClass("link");
		var left = parseInt($(this).width()) + 20;
		var idNum = stripAlphaChars(this.id);

		$("#project"+idNum).css("left",left+"px");
		$("#project"+idNum).slideDown();
		if(current!="" && current!=idNum) {
			$("#project"+current).hide(150);
			$("#item"+current).animate(
			 { 
            height: 70,
				opacity: .5
          },300
			);
		}
		current = idNum;
		$("#item"+idNum).animate(
			 { 
				height: 247,
				opacity: 1
			 }, 
			 { duration: 300 }
		);
		return false;
  });
});

function fadeImageIn(image) {
	$("#portfolioImage img").attr("src",image);
	$("#portfolioImage img").fadeIn(400);
}

function stripAlphaChars(pstrSource)  { 
	var m_strOut = new String(pstrSource); 
	m_strOut = m_strOut.replace(/[^0-9]/g, ''); 
	return m_strOut; 
}
