/*
 * Extensiones jQuery para Vexlan
 * Copyright 2008 Jose Miguel Pérez - josemiguel@perezruiz.com
 */

//=============================================================================
$.fn.wait = function(time, type) {
	time = time || 1000;
	type = type || "fx";
	return this.queue(type, function() {
				var self = this;
				setTimeout(function() {
					$(self).dequeue();
				}, time);
		});
};

//=============================================================================
$.fn.fadeUp = function(time) {
	time = time || 300;
	return this.animate({
			height: "show", opacity: "show"
		}, time);
};

//=============================================================================
$.fn.fadeDown = function(time) {
	time = time || 300;
	return this.animate({
			height: "hide", opacity: "hide"
		}, time);
};

//=============================================================================
$.fn.slideOut = function(time, pos) {
	time = time || 200;
	pos = pos || -20;
	return this.animate({
			left: pos, opacity: "hide"
		}, time);
};

//=============================================================================
$.fn.slideIn = function(time, pos) {
	time = time || 300;
	pos  = pos  || 20;
	this.css( { "left" : pos + "px", "opacity" : 0, "visibility" : "visible", "display" : "block" });
	return this.animate({
			left: 0, opacity: 1
		}, time);
};


//=============================================================================
$.fn.hilite = function(color, time) {
	time = time || 300;
	color = color || "#FFFFCC"
	return this.animate({
			backgroundColor: color
		}, time).animate({
			backgroundColor: "#FFFFFF"
		});
};

//=============================================================================
$.fn.autosubmit = function() {
	var prueba = this.find("input.autosubmit, select.autosubmit");
	prueba.change(function(){
		$(this)[0].form.submit();
	});
	return this;
};

