var secondtime=false;

var $j = jQuery.noConflict();
function scroller(which) {
	if (!secondtime) {
		secondtime=true;
		//alert("hi");
		$j(".prev").hover(function() {
			$j(this).attr("src","/.images/button-prev2.gif");
		}, function() {
			$j(this).attr("src","/.images/button-prev.gif");
		});
		$j(".next").hover(function() {
			$j(this).attr("src","/.images/button-next2.gif");
		}, function() {
			$j(this).attr("src","/.images/button-next.gif");
		});
		$j("#portfolioNavigationThumbsContainer").jCarouselLite({
			//btnGo: ["#portfolioNavigationThumbsContainer .1", "#portfolioNavigationThumbsContainer .2", "#portfolioNavigationThumbsContainer .3", "#portfolioNavigationThumbsContainer .4", "#portfolioNavigationThumbsContainer .5", "#portfolioNavigationThumbsContainer .6", "#portfolioNavigationThumbsContainer .7", "#portfolioNavigationThumbsContainer .8", "#portfolioNavigationThumbsContainer .9", "#portfolioNavigationThumbsContainer .10", "#portfolioNavigationThumbsContainer .11"],
			btnPrev: ".prev",
			btnNext: ".next",
			visible: 6,
			scroll: 1,
			start: (which-1),
			circular: true
		});
		$j("div#fancy_wrap div#portfolioNavigationThumbs img#thumbIndicator").animate({left: "-199px"}, 0);
		
		$j("#portfolioNavigationThumbsContainer li img").unbind("click");
		$j("#portfolioNavigationThumbsContainer li img").click(function() {
			var offsetofthis=$j(this).offset();
			//alert(offsetofthis.left);
			var widthofscreen=$j(document).width();
			var howmuchoffset=offsetofthis.left-((widthofscreen/2)-34);
			if (jQuery.browser.msie) {
				if(parseInt(jQuery.browser.version) == 6) {
					//howmuchoffset=howmuchoffset-133;
				}
				else if(parseInt(jQuery.browser.version) == 7) {
					howmuchoffset=howmuchoffset+6;
				}
				else {
					//howmuchoffset=howmuchoffset-164;
				}
			}
			//console.log(howmuchoffset);
			$j("div#fancy_wrap div#portfolioNavigationThumbs img#thumbIndicator").animate({left: howmuchoffset+"px"}, 600);
		});
	}
}

$j(document).ready(function() {
	$j("a.fancybox").attr("src","#fancybox");
	$j("a.fancybox").fancybox();
});
function gotoPortfolio(which) {	
	webTrendsPortfolio(which);
	
	$j("div#fancy_wrap").show();
	if (which=="all") {
		which="1";
	}
	//$j("div#fancy_wrap div#portfolio").children().hide();
	//$j("div#fancy_wrap div#portfolio"+which).siblings().hide();
	//alert($j("div#fancy_wrap div#portfolioNavigationThumbs img#thumbIndicator").length);
	if (!secondtime) {
		$j("body div#fancy_wrap div#fancy_outer div#fancy_inner div#fancy_content").load("/portfolio/index.asp #portfolio"+which+", #portfolioNavigationThumbs",function(){/*$j("img#thumbIndicator").css("left",10+which*73+"px");*/scroller(which);});
		//$j("img#thumbIndicator").css("left",10+which*73+"px");
		//$j("body div#fancy_wrap div#fancy_outer div#fancy_inner div#fancy_content div#portfolioNavigationThumbs img#thumbIndicator").css("left",10+which*73+"px");
	}
	else {
		$j("div#fancy_wrap div.portfolioItem").load("/portfolio/index.asp #portfolio"+which+" div");
	}
	
		// if (!secondtime) {
			// secondtime=true;
			// gotoPortfolio(which);
			// alert(which);
		// }
		//$j("div#fancy_wrap div#portfolio"+which).fadeIn();
		//$j("div#fancy_wrap div#portfolioNavigationThumbs").show();
		//$j("div#fancy_wrap div#portfolioNavigationThumbs a#portfolioGoTo"+which).fadeTo("slow", 1);
		//$j("div#fancy_wrap div#portfolioNavigationThumbs img#thumbIndicator").animate({left: 10+which*73+"px"}, 600);
		//$j("div#fancy_wrap div#portfolioNavigationThumbs a#portfolioGoTo"+which).css("cursor","default");
		//$j("div#fancy_wrap div#portfolioNavigationThumbs a#portfolioGoTo"+which).siblings("a").fadeTo("slow", 0.4);
		//$j("div#fancy_wrap div#portfolioNavigationThumbs a#portfolioGoTo"+which).siblings("a").css("cursor","pointer");
		//$j("div#fancy_wrap div#portfolioNavigationThumbs a#portfolioGoTo"+which).siblings("a").css("background","");
}
function webTrendsPortfolio(which) {
	var sectionName="";
	if (which=='1') {sectionName="Phipps Conservatory";}
	else if (which=='2') {sectionName="Miller Welding";}
	else if (which=='3') {sectionName="Pittsburgh Technology Council";}
	else if (which=='4') {sectionName="Shady Lane";}
	else if (which=='5') {sectionName="Sophisticated Alloys";}
	else if (which=='6') {sectionName="Chromalox";}
	else if (which=='7') {sectionName="Pittsburgh Glass Center";}
	else if (which=='8') {sectionName="Duquesne MBA Sustainability";}
	else if (which=='9') {sectionName="Drexel Sacramento";}
	else if (which=='10') {sectionName="Pittsburgh 2050";}
	else if (which=='11') {sectionName="First Commonwealth";}
	else {sectionName="View All Phipps";}
	
	dcsMultiTrack('DCS.dcsuri', 'portfolio/index.asp', 'WT.ti', sectionName.replace(/ /g, "%20"), 'WT.cg_n', 'Portfolio', 'WT.cg_s', sectionName.replace(/ /g, "-"));
}