$(function ()
{    
    $('*').removeClass('active');
    markActiveLink();
    if (Modernizr.canvas) 
    {    	
    	makeClock();
    }   
    MakeTwitterLink();
    //setTimeout(function(){MakeHeightSame();}, 200);
    
});

function markActiveLink()
{
    $(".tabs a").filter(function ()
    {    	
        var currentURL = window.location.toString();
        var l = currentURL.length - 1;
        if (currentURL.lastIndexOf('/') === l)
        {
            currentURL = currentURL.substring(0, l);
        }
        currentURL = currentURL.split("/");
        if (currentURL.length >= 4 && $.trim(currentURL[currentURL.length - 1]) != "") return $(this).attr("href").indexOf(currentURL[currentURL.length - 1]) != -1;
        else return false;
        
    }).parent().addClass("active");
    
    if ($('.tabs li.active').size() <= 0)
    {
    	$('.tabs li').first().addClass('active');	
    }
}

function makeClock()
{
	var canvas = document.getElementById("clock");
	// attaching the sketchProc function to the canvas
	var p = new Processing(canvas, sketchClock);
	// p.exit(); to detach it
}

function MakeTwitterLink()
{
	$('.twitterList li').click(function(){
		 window.open( "http://twitter.com/abhinav_rastogi" ); return false;});
	$('.twitterList li').hover(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')});
}
function MakeHeightSame()
{
	var mainHeight = $('.span12').height();
	var sideHeight = $('.span4').height();
	if(mainHeight > sideHeight)
	{		
		$('.span4').height(mainHeight);
	}
	else
	{
		$('.innerContent').height(sideHeight);
	}
}



