$(document).ready(function(){
     var jsonUrl ="http://search.twitter.com/search.json?from=BrianOqr&rpp=1&callback=?";	
	  $.getJSON(jsonUrl,function(data){
		 var tweet_raw_text = data.results[0].text;
		 tweet_raw_text = linkUrl(tweet_raw_text);
         tweet_raw_text = linkUser(tweet_raw_text);
         tweet_raw_text = linkHash(tweet_raw_text);
        //  alert(tweet_raw_text);
		  $('#detweet').html(tweet_raw_text);
		
	});
	  $("#projectlink").click(function(){
	    width =$("#maincontent").width()+23;
	    $("#maincontent").animate({"left": "-="+width+"px"}, "slow");
	    $("#projects").css("left",width+5+"px");
	    $("#projects").show();
	    $("#projects").animate({"left": "-="+width+"px"}, "slow");
	     return false;
	  });
	  $("#maincontentlink").click(function(){
	    width =$("#maincontent").width()+23;
	    $("#maincontent").animate({"left": "+="+width+"px"}, "slow");
	    $("#projects").animate({"left": "+="+width+"px"}, "slow");
	     return false;
	  });
	  $("#projects li a").click(function(){
	     $("#projects").animate({"left": "-="+width+"px"}, "slow");
	     width =$("#maincontent").width()+23;
	     layer = $(this).attr("href");
	    $(layer).css("left",width+5+"px");
	    $(layer).show();
	     $(layer).animate({"left": "-="+width+"px"}, "slow");
	     return false;
	  });
	    $(".backprojectlink").click(function(){
	     layer= "#"+$(this).parents("div").attr("id");
	      width =$("#maincontent").width()+23;
	     $("#projects").animate({"left": "+="+width+"px"}, "slow");
	       $(layer).animate({"left": "+="+width+"px"}, "slow");
	   return false;
	  });
	  initSuperSize();
});
//http://twitpic.com/show/full/4hjo8d
var showImages = Array();
function initSuperSize(){
	  var jsonUrl ="http://api.twitpic.com/2/users/show.jsonp?username=brianoqr&callback=?";	
	  $.getJSON(jsonUrl,function(data){
			for(i=0;i<data.images.length;i++){
        if(i<4){
				showImages[showImages.length]={image : 'http://twitpic.com/show/full/'+data.images[i].short_id, title : '', url : ''}
      }
     }
		/* 
				//Slideshow Images
														{image : 'http://buildinternet.s3.amazonaws.com/projects/supersized/3.1/slides/quietchaos-kitty.jpg', title : 'Quiet Chaos by Kitty Gallannaugh', url : 'http://www.nonsensesociety.com/2010/12/kitty-gallannaugh/'},  
														{image : 'http://buildinternet.s3.amazonaws.com/projects/supersized/3.1/slides/wanderers-kitty.jpg', title : 'Wanderers by Kitty Gallannaugh', url : 'http://www.nonsensesociety.com/2010/12/kitty-gallannaugh/'},  
														{image : 'http://buildinternet.s3.amazonaws.com/projects/supersized/3.1/slides/apple-kitty.jpg', title : 'Applewood by Kitty Gallannaugh', url : 'http://www.nonsensesociety.com/2010/12/kitty-gallannaugh/'}  
												
		
		var tweet_raw_text = data.results[0].text;
		 tweet_raw_text = linkUrl(tweet_raw_text);
         tweet_raw_text = linkUser(tweet_raw_text);
         tweet_raw_text = linkHash(tweet_raw_text);
        //  alert(tweet_raw_text);
		  $('#detweet').html(tweet_raw_text);*/
		if(showImages.length > 0){
		startTwitPicSlide();
		}
	});
	  
}
function startTwitPicSlide(){
 $.supersized({
				
					//Functionality
					slideshow               :   1,		//Slideshow on/off
					autoplay				:	1,		//Slideshow starts playing automatically
					start_slide             :   1,		//Start slide
					slide_interval          :   15000,	//Length between transitions
					transition              :   1, 		//0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
					transition_speed		:	2000,	//Speed of transition
					new_window				:	1,		//Image links open in new window/tab
					pause_hover             :   0,		//Pause slideshow on hover
					keyboard_nav            :   0,		//Keyboard navigation on/off
					performance				:	1,		//0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
 
					//Size & Position
					min_width		        :   0,		//Min width allowed (in pixels)
					min_height		        :   0,		//Min height allowed (in pixels)
					vertical_center         :   1,		//Vertically center background
					horizontal_center       :   1,		//Horizontally center background
					fit_portrait         	:   0,		//Portrait images will not exceed browser height
					fit_landscape			:   0,		//Landscape images will not exceed browser width
					
					//Components
					navigation              :   0,		//Slideshow controls on/off
					thumbnail_navigation    :   0,		//Thumbnail navigation
					slide_counter           :   0,		//Display slide numbers
					slide_captions          :   0,		//Slide caption (Pull from "title" in slides array)
					slides 					:  showImages
												
				});
}
 function linkUser(strToLink) {
        var regexp = /[\@]+([A-Za-z0-9-_]+)/gi;
        strToLink = strToLink.replace(regexp,"<a href=\"http://www.twitter.com/$1\">@$1</a>");  
        return strToLink
      }
 function linkHash(strToLink) {
        var regexp = /(?:^| )[\#]+([A-Za-z0-9-_]+)/gi;
        strToLink= strToLink.replace(regexp, '<a href="http://search.twitter.com/search?q=&tag=$1&lang=all">#$1</a>');
        return strToLink;
      }
function linkUrl(stringToLink){
	 var regexp = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?Â«Â»ââââ]))/gi;
        stringToLink = stringToLink.replace(regexp,
                                      function(match) {
                                        var url = (/^[a-z]+:/i).test(match) ? match : "http://"+match;
                                        return "<a href=\""+url+"\">"+match+"</a>";
                                      });
		return stringToLink;
}
      
	  
