$(function(){
	
	// WYSIWYG EDITOR
	$('textarea.wysiwyg').wysiwyg({
  		controls: {
    		strikeThrough : { visible : true },
    		underline     : { visible : true },
      
   			separator00 : { visible : true },
      
     		justifyLeft   : { visible : true },
      		justifyCenter : { visible : true },
     		justifyRight  : { visible : true },
     		justifyFull   : { visible : true },
      
 			separator01 : { visible : true },
      
   			indent  : { visible : true },
			outdent : { visible : true },
      
     		separator02 : { visible : true },
      
    		subscript   : { visible : true },
    		superscript : { visible : true },
      
   			separator03 : { visible : true },
  	    
  			undo : { visible : true },
   			redo : { visible : true },
      
    		separator04 : { visible : true },
      
     		insertOrderedList    : { visible : true },
    		insertUnorderedList  : { visible : true },
    		insertHorizontalRule : { visible : true },
      
    		h4mozilla : { visible : true && $.browser.mozilla, className : 'h4', command : 'heading', arguments : ['h4'], tags : ['h4'], tooltip : "Header 4" },
     		h5mozilla : { visible : true && $.browser.mozilla, className : 'h5', command : 'heading', arguments : ['h5'], tags : ['h5'], tooltip : "Header 5" },
     		h6mozilla : { visible : true && $.browser.mozilla, className : 'h6', command : 'heading', arguments : ['h6'], tags : ['h6'], tooltip : "Header 6" },
      
     		h4 : { visible : true && !( $.browser.mozilla ), className : 'h4', command : 'formatBlock', arguments : ['<H4>'], tags : ['h4'], tooltip : "Header 4" },
     		h5 : { visible : true && !( $.browser.mozilla ), className : 'h5', command : 'formatBlock', arguments : ['<H5>'], tags : ['h5'], tooltip : "Header 5" },
   			h6 : { visible : true && !( $.browser.mozilla ), className : 'h6', command : 'formatBlock', arguments : ['<H6>'], tags : ['h6'], tooltip : "Header 6" },
      
   			separator07 : { visible : true },
      
     		cut   : { visible : true },
     		copy  : { visible : true },
     		paste : { visible : true }
   		}
  	});
				
	// SUPERFISH FOR MENU ( DROP-DOWN )
	$("ul.nav").superfish({
		animation:{
			height: "show",
			width: "show"
		}, speed : 500
	});
					
	// TOOLTIPS
	$(".tooltip").easyTooltip();
		
	// CHECK ALL CHECKBOX WHEN HEADER ONE IS PRESSED
	$('.checkall').click(
		function(){
			$(this).parent().parent().parent().parent().find("input[type='checkbox']").attr('checked', $(this).is(':checked'));   
		}
	);
	
	// CLOSE NOTIFICATION MESSAGES WHEN CLICKED
	$(".close").click(
		function () {
			$(this).fadeTo(400, 0, function () { // Links with the class "close" will close parent
			$(this).slideUp(400);
		});
		return false;
		}
	);

				
	// SORTABLE, PORTLETS
	$(".column").sortable({
		connectWith: '.column'
	});
				
	$(".sort").sortable({
		connectWith: '.sort'
	});		

	$(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
			.find(".portlet-header")
			.addClass("ui-widget-header ui-corner-all")
			.prepend('<span class="ui-icon ui-icon-circle-arrow-s"></span>')
			.end()
			.find(".portlet-content");

	$(".portlet-header .ui-icon").click(function() {
		$(this).toggleClass("ui-icon-minusthick");
		$(this).parents(".portlet:first").find(".portlet-content").toggle();
	});

	$(".column").disableSelection();

	// ACCORDION
	$("#accordion").accordion({ header: "h3" });
	
	// TABS
	//$('#tabs').tabs();
	$("#tabs").tabs({
            event: 'mouseover'
    });
	// DIALOG			
	$('#dialog').dialog({
		autoOpen: false,
		width: 500,
		buttons: {
			"Ok": function() { 
				$(this).dialog("close"); 
			}, 
			"Cancel": function() { 
				$(this).dialog("close"); 
			} 
		}
	});
				
	// DIALOG LINK
	$('#dialog_link').click(function(){
		$('#dialog').dialog('open');
		return false;
	});

	// DATEPICKER
	$('#datepicker').datepicker({
		inline: true
	});
				
	// SLIDER
	$('#slider').slider({
		range: true,
		values: [20, 70]
	});
				
	// PROGRESSBAR
	$("#progressbar").progressbar({
		value: 40 
	});
				
	// HOVER STATES ON STATIC WIDGETS
	$('#dialog_link, ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); }, 
		function() { $(this).removeClass('ui-state-hover'); }
	);
	
	// LIGHTBOX
	//$('a[@rel*=lightbox]').lightBox();
	$('a.lightbox').lightBox(); // all items with Lightbox class
	
	// Convert Links to buttons	
	$( "#buttonlink" ).button( "option", "icons", {primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'} );
	//$("button, input:submit, a", ".main").button();
	$("button, input:submit, a", ".main","ui-button").button("option", "icons", {primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'});
	

});

/* Added by JD */

$().ready(function() {
	$.fn.themeswitcher && $('<div/>').css({
		position: "absolute",
		right: 150,
		top: 10
	}).appendTo(document.body).themeswitcher();
})


//$(function() {
		//$("button, input:submit, a", ".main").button();
		// $( ".buttonlink" ).button( { icons: {primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'} } );
		//getter
		//var icons = $( "#buttonlink" ).button( "option", "icons" );
		//setter
		//$( "#buttonlink" ).button( "option", "icons", {primary:'ui-icon-gear',secondary:'ui-icon-triangle-1-s'} );
	//});

