/**
* jquery.tcktools 0.0.1
*
*  jquery.tcktools is freely distributable under
*  the terms of an MIT-style license.
*
*--------------------------------------------------------------------------*/
(function($) {

	// static constructs
	$.tcktools = $.tcktools || {version: {}};
	$.tcktools.version = '0.0.1';

/**
* General functions
*--------------------------------------------------------------------------*/

/**
* Reverse hack
*--------------------------------------------------------------------------*/
jQuery.fn.reverse = [].reverse;


/**
* $(wadus).coordinate()
* returns the x and y coordinate of an object in the screen
*--------------------------------------------------------------------------*/
$.prototype.coordinate = function(){
    e = this[0];
    var y = 0, x = 0;
    do {
        y += e.offsetTop || 0;
        x += e.offsetLeft || 0;
        e = e.offsetParent;
        if (e) {
            if(e.tagName.toLowerCase() == 'body') break;
            var p = $(e).position();
            if (p == 'relative' || p == 'absolute') break;
        }
    } while (e);
	return {x:x, y:y};
}

/**
* $(wadus).activate()
* add class active, very common for us
*--------------------------------------------------------------------------*/
$.prototype.activate = function(){
	$(this).addClass("active");
}

/**
* $(wadus).activate()
* add class active, very common for us
*--------------------------------------------------------------------------*/
$.prototype.deactivate = function(){
	$(this).hasClass("active") ? $(this).removeClass("active") : false;
}

/**
* $(wadus).rounded_corners()
* add 4 spans with some markup that we usually use for make rounded corners
*--------------------------------------------------------------------------
$.prototype.rounded_corners = function(){
	// generate html for spans
    var spans = "<span class='rc ne'></span>";
    spans += "<span class='rc nw'></span>";
    spans += "<span class='rc se'></span>";
    spans += "<span class='rc sw'></span>";

    $(this).reverse().each(function(){
        $(this).html( $(this).html() + spans );
    });
}
*/

/**
* $(wadus).share_on_facebook()
* open a 'share on facebook window'
*--------------------------------------------------------------------------*/
$.prototype.share_on_facebook = function(){
	var u = location.href;
	var t = document.title;
	this.click(function(e){
		e.preventDefault();
		window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	})
}

/**
* Table functions
*
*--------------------------------------------------------------------------*/

}) (jQuery);