function isDefined(object) {
	return (typeof object !== 'undefined');
}


/**
 * Function which compacts a text block. It toggles the block text when the
 * block title is clicked.
 * @param string block CSS3 Selector (jQuery) for compactable blocks
 * @param string title CSS3 Selector for the clickable titles inside
 * compactable blocks.
 * @param string text CSS3 Selector for the togglable text element
 * inside the compactable block.
 */
function compactBuyLinks(block, title, text){
	$(block)
		.find(text)
			.hide()
			.end()
		.find(title)
			.hover(
				function(){
					$(this).addClass('fakelink');
				},  
				function(){
					$(this).removeClass('fakelink');
				} 
			)
			.click(
				function(){
					$(this).next().slideToggle('fast');
				}
			)
		;
}


/**
 * Função para acomodar o "link externo" para webstandard uasndo jQuery
 */
function externalLinks() {
	$("a[rel='external']")
		.addClass("external")
		.unbind('click')
		.click(
			function() {
				window.open($(this).attr("href"));
				return false;
			}
		);
	$("a[target='_blank']")
		.addClass("external")
		.unbind('click')
		.click(
			function() {
				window.open($(this).attr("href"));
				return false;
			}
		)
		.removeAttr('target');
}


/**
 * Read a page's GET URL variables and return them as an associative array.
 * Uses string.js (stripTags function)
 */
$.extend({
	getUrlVars: function(){
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++) {
			hash = hashes[i].split('=');
			vars.push(stripTags(hash[0]));
			vars[hash[0]] = stripTags(hash[1]);
		}
		return vars;
	},
	getUrlVar: function(name) {
		return $.getUrlVars()[name];
	}
});

