/**
 * SPINBOX (http://www.newxdesign.com)
 * A jQuery plugin for creating spinboxes form a list of elements.
 * 
 * Version 1.0
 * April 3th, 2009
 *
 * Copyright (c) 2009 newxdesign (http://www.newxdesign.com)
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 *
 **/ 
(function(){
jQuery.fn.spin = function() {
	var element = this;
	//$(element).load(function() {
		var ops = new Array();
		var c = 0;
		$(element).children().each(function(){
			ops.push($(this).html());		
		});
		$(element).hide().parent().append("<table cellpadding='0' cellspacing='0' style='display:-moz-inline-stack;  *display:inline; vertical-align:middle; margin:0 0 0 6px; padding:0px; display:inline; display:-moz-inline-box; display:inline-block; '><tr><td style='margin:0px;'><img id='setacima' src='img/up_arrow.jpg'></td></tr><tr><td><img id='setabaixo' src='img/down_arrow.jpg'></td></tr></table>");
		$("#searchType").val(ops[c]);
		$("#setacima").click(function() {
			if(c > 0) {
				c-=1;
				$("#searchType").val(ops[c]);
			}					  
		});
		$("#setabaixo").click(function() {
			if(c < ops.length-1) {
					c+=1;
					$("#searchType").val(ops[c]);
				}				  
		});
}
})(jQuery); 
