﻿/// <reference path="../jquery-1.3.2-vsdoc.js" />
/// <reference path="../dsbo.js" />

/*
	Updates to this file must be run through the compressor at:
	http://javascriptcompressor.com/
	save output to signin.min.js
*/

/*global $, jQuery */

jQuery.Namespace.Register('jQuery.DSBO.Search');

(function($) {
	// save search
	$('#save').unbind('click');
	$('#save').attr({ 'rel': 'facebox', 'href': '#popup' });
	$('#save').facebox();
	$('#save').click(function(e) {
		$.DSBO.Search.SignIn();
	});

	// favorite
	$('a.favorite').each(function(i, el) {
		$(el).unbind('click');
		$(el).attr({ 'rel': 'facebox', 'href': '#popup' });
		$(el).facebox();
		$(el).click(function(e) {
			$.DSBO.Search.SignIn();
		});
	});
})(jQuery);

jQuery.DSBO.Search.SignIn = function() {
	$.DSBO.LoadPopupPage('popup', '/User/SignIn', $('#spinner'));

	// close button
	$('#facebox').find('.footer').append(
		$('<input>').attr('type', 'button').val('Close').click(function() {
			$(document).trigger('close.facebox');
		})
	);

	// set the focus
	$('.login').find('#Email').focus();

	return false;
};
