// JavaScript Document
var domain;

function homeswitch(id){
	// Set Content 
	if($("#switch > div > h2").html()!=$(id).html()){
		$("#switch > div > h2").hide();
		$("#switch > div > p").hide();
		$("#switch > div > h2").html($(id).html());
		$("#switch > div > p").html($(id).attr("title"));
		// Change Image
		var y = $("#switch > ul > li > a").index(id) * ($("#switch > ul > li > a").length * 75);
		$("#switch").css("background-position","0px -" + y + "px");
		// Chaneg Switch Position
		$("#switch > ul > li > a").removeClass("sel");
		$(id).addClass("sel");
		// Show HTML
		$("#switch > div > h2").fadeIn(500);
		$("#switch > div > p").fadeIn(1000);
	}	
}

$(function(){
	// Add links to Portfolio Thumbs
	$("div.portfolio_list > a").hover(
	  function () {
		if(domain!=this.title){
			domain = this.title;
			$("div.portfolio_main > div").hide();
			var tmp = $("div.portfolio_main > div").toArray();
			for(var i=0, len=tmp.length; i<len; i++){
				if(this.title==tmp[i].title){
					$(tmp[i]).fadeIn(600);
				}
			}
		}
		$(this).fadeTo(0,1);
	  },
	  function () {
		$(this).fadeTo(600,0.7);
	  }
	);
	// Show first Portfolio Item
	$("div.portfolio_list > a").fadeTo(0,0.7);
	$("div.portfolio_main > div").hide();
	$("div.portfolio_main > div:first").fadeIn(600);	
	
	$('a[href^="http"]').click(function(){this.target = "_blank";});
	
	$("img").hide();
	$("img").fadeIn(900);
	
	if($("#switch").length){
		$("#switch > ul > li > a").hover(function(){ homeswitch(this);});
		homeswitch($("#switch > ul > li > a:first"));
	}
});

