$(document).ready(function() {

	var prepareLinksForDemo = (function() {
		
		// Add rel=external to all links
		$("#componentList li a:not([href=#])").each(function() {
			$(this).attr('rel', 'external');
		});
		
		$("#backButton").attr({
			href: '../index.html',
			rel: 'external'
		});
			
	})();
	
	// Delete event from disabled link buttons
	$("a:not([href=#]):not([target]):not([rel=external])").die("click");

	// Reset classes for disabled link buttons
	$("a.ui-disabled").live({
		mouseover: function() {
			var theme = $(this).attr( "data-theme" );
			$(this).removeClass( "ui-btn-hover-" + theme ).addClass( "ui-btn-up-" + theme );
		},
		mousedown: function() {
			var theme = $(this).attr( "data-theme" );
			$(this).removeClass( "ui-btn-down-" + theme ).addClass( "ui-btn-up-" + theme );
		}
	});
	
	// Generic Toggle Button
	$("a.ui-btn-toggle").live({
		mouseover: function() {
			var theme = $(this).attr( "data-theme" );
			$(this).removeClass( "ui-btn-hover-" + theme ).addClass( "ui-btn-up-" + theme );
		},
		click: function() {
			var theme = $(this).attr( "data-theme" );
			var currentIcon = $(this).attr( "data-icon" );
			var altIcon = $(this).attr( "data-icon-alt" );
			
			$(this).toggleClass("ui-btn-toggle-down-" + theme );
			$(this).find(".ui-icon-" + currentIcon).toggleClass( "ui-icon-" + altIcon );
		}
	});
    
});