<!--
var anchorTo = "";
//

function leftPanelHt(){
	if(navigator.platform.toLowerCase().indexOf('ipad') != -1 || navigator.platform.toLowerCase().indexOf('iphone') != -1 || navigator.platform.toLowerCase().indexOf('ipod') != -1)
	{
		//alert($(document).height() + "-" + $('body').height());
		$("#footer").css({position:'absolute','top': $(document).height()-$('#footer').height()+"px"});
		$("#leftMainBttmNav").css({position:'absolute','top': $(document).height()-($('#relatedLinks').height()+100)+"px"});
	};
	
	//$("#footer").css({position:'absolute','top': $(window).scrollTop() + $(window).height()-$("#footer").height() + "px"});
	$("#leftpanel").height($(window).height()-$("#footer").height());

}
function setPageLoadAnimateAnchor( a ) {
	anchorTo = a;
}
function animateToAnchor() {
	$("#"+anchorTo).click();
}
function redirectPage() {
	window.location = linkLocation;
}	
madebymade = {};
madebymade.rollover =
{
	init: function()
	{
		this.preload();

		$(".ro").hover(
		   function () { $(this).attr( 'src', madebymade.rollover.newimage($(this).attr('src')) ); },
		   function () { $(this).attr( 'src', madebymade.rollover.oldimage($(this).attr('src')) ); }
		);
	},
	preload: function()
	{
		$(window).bind('load', function() {
		   $('.ro').each( function( key, elm ) { $('<img>').attr( 'src', madebymade.rollover.newimage( $(this).attr('src') ) ); });
		});
	},
	newimage: function( src ) { return src.substring( 0, src.search(/(\.[a-z]+)/) ) + '_o' + src.match(/(\.[a-z]+)/)[0]; },
	oldimage: function( src ){ return src.replace(/_o/, ''); }
};


/**/

$(document).ready(function () 
{
	// For left panel related link positioning

	leftPanelHt();
	
	madebymade.rollover.init();
	
	$('a').click( function( event ){
		if( this.href == "" || this.href == null ) { event.preventDefault(); return; }

		if( (this.href.indexOf("#") == -1) && (this.href.indexOf("mailto:") == -1) && (this.href.indexOf("javascript:") == -1) && (this.target != "_blank") ) {
			event.preventDefault();
			linkLocation = this.href;
			$("body").fadeOut(600, redirectPage);
		}
	});
	
	// For home page slider

	$("#slider").easySlider({

		auto: true, 

		continuous: true,

		controlsShow: false,

		nextId: "sliderNext",

		prevId: "sliderPrev"

	});


	var currentSlide = 1;

	var totalImages = $("#sliderImages").children().length - 2;

	

	$("#totalImg").text(totalImages);

	

	$('#sliderPrev').click(function() {

		$("#caption"+currentSlide).addClass('hide');

		if(currentSlide > 1){

			$("#currImg").text(--currentSlide);

		}else{

			currentSlide = $("#sliderImages").children().length - 2;

			$("#currImg").text(currentSlide);

		}

		$("#caption"+currentSlide).removeClass('hide');

	});



	$('#sliderNext').click(function() {

		$("#caption"+currentSlide).addClass('hide');

		if(currentSlide < totalImages){

			$("#currImg").text(++currentSlide);

		}else{

			currentSlide = 1;

			$("#currImg").text(currentSlide);

		}		

		$("#caption"+currentSlide).removeClass('hide');

	});	

	

	// For Overview animation

	animatedcollapse.addDiv('overview_more','fade=0,speed=400,hide=1')

	animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted

		//$: Access to jQuery

		//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID

		//state: "block" or "none", depending on state

		if(state == "block"){

			$('#moreText').css('display','none');

			$('#closeText').css('display','');

		}else{

			$('#moreText').css('display','');

			$('#closeText').css('display','none');

		}

	}

	animatedcollapse.init();

	



	// For project image captioning

	$('#main_content2 img').jcaption({

		copyStyle: false,

		animate: true,

		//Assign a width to the wrapper that matches the image

	    autoWidth: true,

		show: {height: "show"},

		hide: {height: "hide"}

	});
	

	// For Project Tab highlighting

	$("a.anchorLink").anchorAnimate();

	$("a.anchorLink").click(function(){
		$("a.anchorLink").removeClass('selected');

		$(this).addClass('selected');		

	});		
	$("a.anchorProjectLink").anchorProjectLink();	
	//
	$("body").css("display", "none");
   	//		
	if( anchorTo != "" ) {
		$("body").fadeIn( 600,animateToAnchor );
	} else {
		$("body").fadeIn( 600,function () {} );
	}
	
	$(window).resize(function() {
		leftPanelHt();
	});	
	$(window).scroll(function() {
		leftPanelHt();
	});
	$(window).load(function () {
	  leftPanelHt();
	});	
	

});

//-->




