jQuery(document).ready(function($){
	// Enable plugins which require activation
	$('[placeholder]').placeholder();

	// IE Cleanup
	$('.ie6 .dropdown-link, .ie7 .dropdown-link').append(' &#x25bc;');
	
	// Login form logic
	login_settings = {
		url : '/scripts/ajaxLogin.php',
		success : function(response,status,xhr,$form){
			if(response == '') {
				window.location.href = 'https://scuref.org/dashboard';
			} else {
				$.colorbox({
					initialWidth : "30px",
					initialHeight : "30px",
					html: '<div id="register-form-content" style="color:black;padding:5px"><h1 style="color:black;">Login Failure</h1><div style="color:black;"text-align:center;"><p style="margin-bottom:20px;">'+response+'</p><button class="close-button">Close</button></div></div>',
					onComplete : function(){
						$('.close-button').click(function(event){
							$.colorbox.close();
						});
					}
				});
			}
		}
	};
	$('#signin').ajaxForm(login_settings);
	$('#signin_other').ajaxForm(login_settings);
	$('#signin_right').ajaxForm(login_settings);
	
	// Logout button logic
	$('.logout-button').click(function(event){
		$.post('/scripts/ajaxLogout.php',function(data){
			window.location.href = '/index?logout=true';
		});
		event.preventDefault();
	});
	
	$('a.colorbox').colorbox({
		initialWidth : "30px",
		initialHeight : "30px",
		onComplete : function(){
			//dialogCallbacks();
		}
	});
	
	// FAQ page logic
	$('#leftcol a').click(function(event){
		var href = $(this).attr('href')+' #data'
		var $main = $('#main_col')
		$main.slideUp(function(){
			$main.load(href, function(){
				$main.slideDown();
			});
		});
		event.preventDefault();
	});
	
	$('#main_col dt').live('click', function(){
		$(this).next('dd').slideToggle();
	});
});

