function isInteger(s) {
  return (s.toString().search(/^-?[0-9]+$/) == 0);
}

jQuery(document).ready(function(){

/*  ------------------------------------------------------------------
	Remove default value on Focus ------------------------------------ */
	jQuery("textarea")
		.bind("focus",function(){ if(this.value==this.title){ this.value=""; } })
		.bind("blur",function(){ if(this.value==""){ this.value=this.title; } });
		
	jQuery("input[type=text]")
		.bind("focus",function(){ if(this.value==this.title){ this.value=""; } })
		.bind("blur",function(){ if(this.value==""){ this.value=this.title; } });

		
		
	// set all a title from img title
	jQuery(".post a[href$=.jpg],.post a[href$=.png],.post a[href$=.gif]").attr('title', function(){
		return $("img", this).attr('title');
	});
	jQuery(".entry a[href$=.jpg],.entry a[href$=.png],.entry a[href$=.gif]").attr('title', function(){
		return $("img", this).attr('title');
	});
	jQuery(".article a[href$=.jpg],.article a[href$=.png],.article a[href$=.gif]").attr('title', function(){
		return $("img", this).attr('title');
	});
	
	$('a[rel=video]').each(function(index) {
		$(this).attr('rel','gallery');
		$(this).addClass('video');
	});
	
	// activate fancybox for IMAGES
	jQuery(".post a[href$=.jpg],.post a[href$=.png],.post a[href$=.gif]").fancybox();
	jQuery(".entry a[href$=.jpg],.entry a[href$=.png],.entry a[href$=.gif]").attr('rel', 'gallery');
	jQuery(".article a[href$=.jpg],.article a[href$=.png],.article a[href$=.gif]").attr('rel', 'gallery');
	
	$('a[rel=gallery]').fancybox();
	
	// VIMEO
	var fancy_video = {
		'cyclic'        : true,
		'autoScale'     : false,
		'width'         : 640,
		'height'        : 360,
		'type'          : 'swf',
		'showNavArrows' : true,
		'swf'           : 
		{
			'wmode'             : 'transparent',
			'allowfullscreen'   : 'true'
		}
	}; 

	
	$('a.video').each(function(index) {
	
		var href_video = $(this).attr('href');
		
		// set all a title from img title
		$(this).attr('title', function(){
			return $("img", this).attr('title');
		});
		
		$(this).fancybox(
			$.extend(fancy_video, {'href' : 'http://vimeo.com/moogaloop.swf?clip_id='+href_video+'&amp;fullscreen=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=85B819'})
		); 
	});
	
	$(function() {
    $('.comment-body a').click( function() {
        window.open(this.href);
        return false;
    });
});
});
