$.fn.extend({
			positionOfobject:function(C){
				var position = $(this).position()
				switch(C){
					case 'left'||'<-':
						return  position.left
					break
					case 'right'||'->':
						return position.right
					break
				}
			},
			eOfc:function(A){
				$.ajaxSetup({dataType:'json',type:'GET',async: false}) 
				var div = '<div></div>',
					img = '<img />',
					not = 'undefined',
					target = $(this),
					__whiteSpace = typeof A.style.__whiteSpace != not ? A.style.__whiteSpace : 0,
					// Structure of Exchange
					structure = {
						body:$(div),
						block:new Array(),
						group:new Array(),
						init:function(A,B){
							var css = {position:'absolute'}
							this.block[0] = $(div).appendTo(this.body).css(css) 
							this.block[1] = $(div).appendTo(this.body).css(css)
							this.group[0] = $(div).appendTo(this.block[0]).css(css)
							this.group[1] = $(div).appendTo(this.block[0]).css(css)
							this.group[2] = $(div).appendTo(this.block[0]).css(css)
							this.body.appendTo(A)
						},
						fixup:function(){
							var isto = this,max=0
							$.each(this.group,function(i,item){
								max<item.height() ? max=item.height() : '' 
								if(i!=0)
									item.css({	left: isto.group[(i-1)].width() + isto.group[(i-1)].positionOfobject('left') + __whiteSpace})
							})
							this.block[0].css({height:max})
							this.block[1].css({top:max+10+__whiteSpace})						
						}
					},
					Component = {
						init:function(A){
							switch(typeof this.Element[A]){
								case not:			return not;						break;
								case 'function':	return new this.Element[A];		break;
								case 'object':		return this.Element[A];			break
								default:			return not;						break
							}
						},
						Element:function(){},
						Add:function(Name,Func){	this.Element[Name] = Func		},
						Out:function(Name){			delete this.Element[Name]		}
					}
					Component.Add('View',{
						init:function(B){
							return new this.run({
								target:B.target,
								limit:B.limit != not ? B.limit : '',
								column:B.column != not ? B.column : '',
								data:this.ajax(B.url),
								style:B.style != not ?  B.style : {
									__gif:'../img/16-1.gif',
									__whiteSpace:10,
									width:200,
									height:200 
								},
								structure: ( typeof B.structure != not ) ? B.structure : function(R){
									return 'No Structure'
								} 
							})
						},
						run:function(D){
							this.data = D.data
							this.size = this.data.length
							this.current = 0
							this.confThumbnail = {
								target:D.target,
								limit:D.limit != not ? D.limit : '',
								column:D.column != not ? D.column : '',
								style:D.style != not ?  D.style : {__whiteSpace:10,width:200,height:200},
								structure: ( typeof D.structure != not ) ? D.structure : function(R){
									return 'No Structure'
								}
							}
							var newThumbnail = new thumbnail(this.confThumbnail)
							this.run = function(){
								newThumbnail.run(this.data[this.current])
							}
							this.next = function(){
								if (this.current < (this.size - 1)) {
									this.current++
									this.run()
								}
							}
							this.previous = function(){
								if (this.current > 0) {
									this.current--
									this.run()
								}
							}
							this.change = function(i){
								this.current = i 
								this.run()
							}	
						},
						ajax:function(url){	return eval($.ajax({url: url}).responseText )	}
					})
					
					
					
					
					'Tipo de Json. Ex.: [{cabelo:"liso",cor:"preto"}]'
					//Select = Component.init('Select')
					//slt = Select.init({type:'ajax',url:'php.php?a',structure:function(item){return item.cabelo}})
					Component.Add('Select',{
						init:function(A){
							switch(A.type){
								case 'ajax':
									return new this.structure({
																dados:this.ajax(A.url),
																structure:A.structure
																})
								break
								default :
									return new this.structure({
														dados:A.dados,
														structure:A.structure
														})
								break
							}
						},
						ajax:function(url){	return eval($.ajax({url: url}).responseText )	},
						structure:function(B){
							var slt = $('<select></select>')
							$.each(B.dados,function(i,item){$('<option></option>').html(B.structure(item)).appendTo(slt).attr('value',i)})
							return slt
						}
					})
					
					
					
					
					/*
					Button = Component.init('Button')
					bt = Button.init({type:'text',text:'Ok'}).appendTo(target)
					 */
					Component.Add('Button',{
						init:function(A){
							switch(A.type){
								case 'image':	return new this.Image(A.url);		break
								case 'text':	return new this.Text(A.text);		break
							}
						},
						Image:function(url){	return $('<img src="'+url+'"/>').css({cursor:'pointer'})			},
						Text:function(Txt){		return $('<a></a>').attr('href','javascript:void(0);').html(Txt)	}
					})
					
					
					
					
					
					
					var Control = {
						init:function(){
							structure.init(target)
							structure.group[0].html(typeof A.style.__title != not ? A.style.__title : '')
							var __Select = Component.init('Select'),
								__View = Component.init('View'),
								__Button = Component.init('Button'),
								buttonPrevious 	=	__Button.init(typeof A.style.__ButtonPrevious != not ? A.style.__ButtonPrevious : {type:'text',text:'Previous'})
														.appendTo(structure.group[2]).css({position: 'absolute'}).css(typeof A.style.__ButtonPrevious.css != not ? A.style.__ButtonPrevious : {width:20,height:20}),
								buttonNext 		=	__Button.init(typeof A.style.__ButtonNext != not ? A.style.__ButtonNext : {type:'text',text:'Next'})
														.appendTo(structure.group[2]).css({position: 'absolute',left:buttonPrevious.width()}).css(typeof A.style.__ButtonNext.css != not ? A.style.__ButtonNext.css : {width:20,height:20,position:'absolute'}),
								view = __View.init({
									target:structure.block[1],
									limit:typeof A.limit != not ? A.limit : '',
									column:typeof A.column != not ? A.column : 3,
									url:A.url,
									style:typeof A.style != not ? A.style : {__whiteSpace:10,	width:200,		height:200},
									structure:typeof A.style.str != not ? A.style.str : function(R){
										return 'No Structure'
											
									} 
								})
								switch(A.type){
									case 0:
									structure.fixup()
										view.run()
										buttonNext.click(function(){
											view.next()
										})
										buttonPrevious.click(function(){
											view.previous()
										})
										structure.fixup()									
									break
									case 1:
										select = __Select.init({
											type:'ajax',
											url:A.ComponentURL,
											structure:typeof A.ComponentStr != not ?  A.ComponentStr : 	function(R){
												return 'No Structure'
											} 
										}).appendTo(structure.group[1])
													
										structure.fixup()
										view.run()
										select.change(function(){
											view.change($(this).val())
										})
										buttonNext.click(function(){
											view.next()
											select.val(view.current)
										})
										buttonPrevious.click(function(){
											view.previous()
											select.val(view.current)
										})
										structure.fixup()
									break
								}
						}
						
					}
					Control.init()
			}
		})