$(function(){
        
        var name = $( "#name" ),
			email = $( "#email" ),
			password = $( "#password" ),
			allFields = $( [] ).add( name ).add( email ).add( password ),
			tips = $( ".validateTips" );

		function updateTips( t ) {
			tips
				.text( t )
				.addClass( "ui-state-highlight" );
			setTimeout(function() {
				tips.removeClass( "ui-state-highlight", 1500 );
			}, 500 );
		}

		function checkLength( o, n, min, max ) {
			if ( o.val().length > max || o.val().length < min ) {
				o.addClass( "ui-state-error" );
				updateTips( "Length of " + n + " must be between " +
					min + " and " + max + "." );
				return false;
			} else {
				return true;
			}
		}

		function checkRegexp( o, regexp, n ) {
			if ( !( regexp.test( o.val() ) ) ) {
				o.addClass( "ui-state-error" );
				updateTips( n );
				return false;
			} else {
				return true;
			}
		}
		
		// Dialog Link loginpop
    	$('#loginpop').click(function(){
    		$('#dialog').dialog('open');
    		return false;
    	});
    	
    	// Dialog			
		$('#dialog').dialog({
			autoOpen: false,
			width: 300,
			modal: true,
			draggable: false,
			resizable: false,
			zIndex: 10,
			show: 'fade',
			buttons: {
            
                "Cancel": function() { 
                     $(this).dialog("close"); 
                 },
				"Login": function() { 


					$("#login").submit();
				} 
			}
		});
		
		// Makes last button in dialog pane the FOCUS, so 'clicks' on enter press:
		$(window).keypress(function(e) {
            if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
                $(".ui-dialog:visible").find('.ui-dialog-buttonpane').find('button:last').click();
                return false;
            }
        });

		
        //      // Dialog Link loginpop
        //      $('.passRemind').click(function(){
        //          $('#reminderDiag').dialog('open');
        //          return false;
        //      });
        // 
        //      // Dialog           
        // $('#reminderDiag').dialog({
        //  autoOpen: false,
        //  width: 300,
        //  height: 300,
        //  modal: true,
        //  draggable: false,
        //  resizable: false,
        //  zIndex: 10,
        //  show: 'fade',
        //  buttons: {
        //      "Send Reminder": function() { 
        //          $(this).dialog("close"); 
        //      }, 
        //      "Cancel": function() { 
        //          $(this).dialog("close"); 
        //      } 
        //  }
        // });
		
		// Accordion
		$("#accordion").accordion({ header: "h3" });

		// Tabs
		$('#tabs').tabs();

		// Datepicker
		$('#datepicker').datepicker({
			inline: true
		});
		
		// Slider
		$('#slider').slider({
			range: true,
			values: [17, 67]
		});
		
		// Progressbar
		$("#progressbar").progressbar({
			value: 20 
		});
		
		//hover states on the static widgets
		$('#dialog_link, ul#icons li').hover(
			function() { $(this).addClass('ui-state-hover'); }, 
			function() { $(this).removeClass('ui-state-hover'); }
		);
		
	});

