
	// extensions

	$.fn.extend({
		findPos : function() {
			obj = $(this).get(0);
			var curleft = obj.offsetLeft || 0;
			var curtop = obj.offsetTop || 0;
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
			return {x:curleft, y:curtop};
		}
	});
	
	$.fn.extend({
		visible : function() {
			if($(this).css("display") == "block" || $(this).css("display") == "") return true;
			return false;
		}
	});
	
	
	// cross-browser opacity
	$.fn.extend({
		opacity : function(value) {
			$(this)
				.css("opacity", value)
				.css("-moz-opacity", value)
				.css("filter", "alpha(opacity = " + (value * 100) + ")")
				.css("zoom", "1"); // ie7
		}
	});
	
	// toggle
	$.fn.extend({
		toggleVisible : function() {
			if($(this).visible()) $(this).hide();
			else $(this).show();
		}
	});
	
	// check if element exists
	$.fn.extend({
		exists : function() {
			var obj = $(this).get(0);
			if(obj) return true;
			else return false;
		}
	});
	
	// utilities
	
	function randomString(length){
	  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
	  for(var x = 0, pass = ""; x < length; x++){
		i = Math.floor(Math.random() * 62);
		pass += chars.charAt(i);
	  }
	  return pass;
	}

	function getUniqueId(){
		var now = new Date();
		return(now.getTime());
	}
	
	function thisFormTrigger(){
		tinyMCE.triggerSave(false,true);
	}
	
	function ajaxIndicator(text, loader){
		$("#search-box input").toggleClass("ajax");	
	}
	
	function currentPage(){
		var page = location.href.split("/");
		return page[page.length - 1].split("?")[0];
	}
	
	function ask(url){
		if(!confirm("Estas seguro?")) return false;
		self.location = url;
	}
