<!--
var anchorTo = "";
//
function leftPanelHt(){
		$("#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/, ''); }
};


if (typeof $ !== 'function' && typeof jQuery === 'function') {
    $ = jQuery; 
}
/* */
$(document).ready(function () 
{
   // $('body').append('<div style="display:none" id="sink"></div>');
    // revision 3 removes the vertical scroll and just shows a single random row.
    /*$('#vertical_scroller').addClass('jCarousel').jCarouselLite({                           
        scroll:1,
        circular:true,
        vertical:true,
        auto:10000,
        easing:'easeOutBounce',
        speed:2000
    });*/
   
   
	
	
	
	
	// 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(50, redirectPage);
		}
	});*/
   
	// v. simple jquery email obfuscation (removal) plugin
     $('a.hiddenemailaddress,a#hiddenemailaddress,a[href$=#hiddenemailaddress]').each(function(){        
        var email = $(this).html().replace(/\s+at\s+/, "@");
        if (email && email.length>0){
    		$(this).attr('href','mailto:' + email).attr('title','Email ' + email).attr('rel','nofollow').text(email);
        }
     });    

    
    $('.has_rollover_set').each(function(){        
        replace = $(this).children('img.rollover').filter(function(){return !$(this).hasClass('first')});            
        if(replace.length>0){                           
            $(this).children('img.first').each(function(){                    
                $(this).attr('data-replace',replace.attr('src'));
                $(this).attr('data-original',$(this).attr('src'));                    
            }).hover(function(){                       
                $(this).attr('src',$(this).attr('data-replace'));                    
              },function(){                    
                $(this).attr('src', $(this).attr('data-original'));
            });
            $(replace).remove();
        }      
    });
    
	// 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( 50,animateToAnchor );
	//} else {
	//	$("body").fadeIn( 50,function () {} );
///	  }
	if( anchorTo != "" ) animateToAnchor();
});
//-->


