//Twitter Configuration\\

//when the dom is ready	
$(document).ready(function(){
	//configuration
	var screen_name = 'mayraveronica';
	var count = "200";
	var selector = "#tweet";
	
	//get tweets
	var json_uri = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name="+screen_name+"&count="+count+"&include_entities=false&callback=?";
	$.getJSON(json_uri, function(data){
		//print non mentions tweets
		$.each(data, function(i,data){
			var msg = data.text;
			var msg_start = msg.charAt(0);
			if(msg_start != "@"){
				//log(msg);
				var this_li = '<p>'+ify.clean(msg)+'</p>';
				$(selector).append(this_li);	
			}
		});
		
		//cycle 'n fx
		$('#tweet').cycle({ 
			fx:      'fade', 
			speed:    300, 
			timeout:  5000 
		});		
	});
	//galleria
	/*Galleria.loadTheme('js/themes/dots/galleria.dots.js');
	var api_key = '776131d0960703b19c5f9d910d549a7f';
	var flickr = new Galleria.Flickr(api_key);
	var photoset = '72157625420405336';

	flickr.setOptions({
		size: 'big'
	});
	
	flickr.getSet(photoset, function(data){
		$('#home_rotator').galleria({
			data_source: data,
			transition:  'fade',
			image_margin: 0,
			image_crop: 'width'
		});
	
	});*/
	var photoset = '72157625698611249';
	var api_key = "56cd7c67164ddd984b0b58899873daaf";
	var json_url = 'http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key='+api_key+'&photoset_id='+photoset+'&format=json&jsoncallback=?';
	$.getJSON(json_url,function(data){
		$.each(data.photoset.photo, function(i,photo){
			var this_thumb = 'http://farm'+photo.farm+'.static.flickr.com/'+photo.server+'/'+photo.id+'_'+photo.secret+'_b.jpg';
			$("#home_rotator").prepend('<img src="'+this_thumb+'" />');
		});

		//galleria jquery plugin
		Galleria.loadTheme('js/themes/dots/galleria.dots.js');
		$('#home_rotator').galleria({
			transition:  'fade',
			image_margin: 0,
			image_crop: 'width'
		});
   });
	
	
	//detect the iphone
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))){ 
		$('#thumbs_li_inside a').each(function(){
			$(this).removeAttr('class');
			var href = $(this).attr('href');
			href = href.split('=');
			href = href[1];
			href = 'http://www.youtube.com/watch?v='+href;
			$(this).attr('href',href);
		});
	}
});

//thanks to Dustin Diaz: http://www.dustindiaz.com/basement/ify.html
var ify = function() {
  return {
	"link": function(t) {
	  return t.replace(/(^|\s+)(https*\:\/\/\S+[^\.\s+])/g, function(m, m1, link) {
		return m1 + '<a href=' + link + '>' + ((link.length > 25) ? link.substr(0, 24) + '...' : link) + '</a>';
	  });
	},
	"at": function(t) {
	  return t.replace(/(^|\s+)\@([a-zA-Z0-9_]{1,15})/g, function(m, m1, m2) {
		return m1 + '@<a href="http://twitter.com/' + m2 + '">' + m2 + '</a>';
	  });
	},
	"hash": function(t) {
	  return t.replace(/(^|\s+)\#([a-zA-Z0-9_]+)/g, function(m, m1, m2) {
		return m1 + '#<a href="http://search.twitter.com/search?q=%23' + m2 + '">' + m2 + '</a>';
	  });
	},
	"clean": function(tweet) {
	  return this.hash(this.at(this.link(tweet)));
	}
  };
}();


























