
	// 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;
	}
	
	function accents(string){
		string = string.replace(/á/g, "&aacute;");
		string = string.replace(/é/g, "&eacute;");
		string = string.replace(/í/g, "&iacute;");
		string = string.replace(/ó/g, "&oacute;");
		string = string.replace(/ú/g, "&uacute;");
		return string;
	}
	
	String.prototype.subChars = function(chars){
		var string = this;
		for(i = 0; i < chars.length; i++){
			var remove = chars.charAt(i);
			myRe = new RegExp("\\" + remove, "g");
			string = string.replace(myRe, "");
		}
		return string;
	}
	
	// arrays
	
	Array.prototype.inArray = function(element) {
		for(var i=0; i < this.length; i++){
			if(arguments.length > 1){
				if(this[i][arguments[1]] == element) return true;
			}else{
				if(this[i] == element) return true;
			}
		}
		return false;
	}
	
	Array.prototype.remove = function(s){
		for(var i = 0; i < this.length; i++){
			if(s == this[i]) this.splice(i, 1);
		}
	}
	
	Array.prototype.arrayElementIndex = function(element) {
		for(var i=0; i < this.length; i++){
			if(this[i] == element) return i;
		}
		return false;
	}
