/* jQuery plugin themeswitcher
---------------------------------------------------------------------*/
$.fn.themeswitcher = function(settings){
	var options = jQuery.extend({
		loadTheme: null,
		initialText: 'Selecione',
		width: 195,
		height: 170,
		buttonPreText: '',
		closeOnSelect: true,
		buttonHeight: 16,
		cookieName: 'jquery-ui-theme',
		onOpen: function(){},
		onClose: function(){},
		onSelect: function(){}
	}, settings);
/*
Com&eacute;rcio<br>
Ind&uacute;stria<br>
Agropecu&aacute;ria<br>
Servi&ccedil;o<br>
Cooperativa<br>
Sindicato
*/
	//markup 
	var button = $('<a href="#" class="jquery-ui-themeswitcher-trigger"><span class="jquery-ui-themeswitcher-icon"></span><span class="jquery-ui-themeswitcher-title">'+ options.initialText +'</span></a>');
	var switcherpane = $('<div class="jquery-ui-themeswitcher"><div id="themeGallery"><ul><li><a href="Associados.asp"><span class="themeName"><img src="Layout/Bullet_1.png" /> Com&eacute;rcio</span></a></li>	<li><a href="Associados.asp?id=2"><span class="themeName"><img src="Layout/Bullet_2.png" /> Ind&uacute;stria</span></a></li><li><a href="Associados.asp?id=4"><span class="themeName"><img src="Layout/Bullet_3.png" /> Agropecu&aacute;ria</span></a></li><li><a href="Associados.asp?id=5"><span class="themeName"><img src="Layout/Bullet_4.png" /> Servi&ccedil;o</span></a></li><li><a href="Associados.asp?id=6"><span class="themeName"><img src="Layout/Bullet_5.png" /> Cooperativa</span></a></li><li><a href="Associados.asp?id=7"><span class="themeName"><img src="Layout/Bullet_6.png" /> Sindicato</span></a></li></ul></div></div>').find('div').removeAttr('id');
	
	//button events
	button.click(
		function(){
			if(switcherpane.is(':visible')){ switcherpane.spHide(); }
			else{ switcherpane.spShow(); }
					return false;
		}
	);
	
	//menu events (mouseout didn't work...)
	switcherpane.hover(
		function(){},
		function(){if(switcherpane.is(':visible')){$(this).spHide();}}
	);

	//show/hide panel functions
	$.fn.spShow = function(){ $(this).css({top: button.offset().top + options.buttonHeight + 6, left: button.offset().left}).slideDown(50); button.css(button_active); options.onOpen(); }
	$.fn.spHide = function(){ $(this).slideUp(50, function(){options.onClose();}); button.css(button_default); }
	
		
	
	/* Inline CSS 
	---------------------------------------------------------------------*/
	var button_default = {
		fontFamily: 'Arial, Helvetica, sans-serif',
		fontSize: '12px',
		color: '#fff',
		background: '#1B4687',
		border: 'none',
		'-moz-border-radius': '0px',
		'-webkit-border-radius': '0px',
		textDecoration: 'none',
		padding: '3px 3px 3px 8px',
		width: options.width - 11,//minus must match left and right padding 
		display: 'block',
		height: options.buttonHeight,
		outline: '0'
	};
	var button_hover = {
		'borderColor':'#bbb',
		'background': '#1B4687',
		cursor: 'pointer',
		color: '#DAE6F8'
	};
	var button_active = {
		color: '#DAE6F8',
		background: '#1B4687',
		border: 'none',
		borderBottom: 0,
		'-moz-border-radius-bottomleft': 0,
		'-webkit-border-bottom-left-radius': 0,
		'-moz-border-radius-bottomright': 0,
		'-webkit-border-bottom-right-radius': 0,
		outline: '0'
	};
	
	
	
	//button css
	button.css(button_default)
	.hover(
		function(){ 
			$(this).css(button_hover); 
		},
		function(){ 
		 if( !switcherpane.is(':animated') && switcherpane.is(':hidden') ){	$(this).css(button_default);  }
		}	
	)
	.find('.jquery-ui-themeswitcher-icon').css({
		float: 'right',
		width: '16px',
		height: '16px',
		background: 'url(http://jqueryui.com/themeroller/themeswitchertool/images/icon_color_arrow.gif) 50% 50% no-repeat'
	});	
	//pane css
	switcherpane.css({
		position: 'absolute',
		float: 'left',
		fontFamily: 'Arial, Helvetica, sans-serif',
		fontSize: '12px',
		background: '#1B4687',
		color: '#fff',
		padding: '8px 3px 3px',
		border: 'none',
		'-moz-border-radius-bottomleft': '0px',
		'-webkit-border-bottom-left-radius': '0px',
		'-moz-border-radius-bottomright': '0px',
		'-webkit-border-bottom-right-radius': '0px',
		borderTop: 0,
		zIndex: 999999,
		width: options.width-6//minus must match left and right padding
	})
	.find('ul').css({
		listStyle: 'none',
		margin: '0',
		padding: '0',
		overflow: 'auto',
		height: options.height
	}).end()
	.find('li').hover(
		function(){ 
			$(this).css({
				'borderColor':'#333355',
				'background': '#1F5098',
				cursor: 'pointer'
			}); 
		},
		function(){ 
			$(this).css({
				'borderColor':'#111',
				'background': '#1B4687',
				cursor: 'auto'
			}); 
		}
	).css({
		width: options.width-30,
		height: '',
		padding: '2px',
		margin: '1px',
		border: 'none',
		'-moz-border-radius': '0px',
		clear: 'left',
		float: 'left'
	}).end()
	.find('a').css({
		color: '#DAE6F8',
		textDecoration: 'none',
		float: 'left',
		width: '100%',
		outline: '0'
	}).end()
	.find('img').css({
		float: 'left',
		border: 'none',
		margin: '0 2px'
	}).end()
	.find('.themeName').css({
		float: 'left',
		margin: '3px 0'
	}).end();
	


	$(this).append(button);
	$('body').append(switcherpane);
	switcherpane.hide();


	return this;
};






