Interface.Globals = {
	checkCanvas: function() {
		var horizon = $('#horizon');
		if ($(window).outerHeight() >= $('#wrapper').outerHeight())
			horizon.css({ top: '50%', marginTop: ((horizon.outerHeight()/2)*-1) + 'px' });
		
		if (horizon.get(0).offsetTop < 0)
			horizon.css({ top: 0, marginTop: 0 });
	},
	
	saveZipCode: function(zipCode) {
		$.cookie('zipCode', zipCode, { expires: Config.storeZipDays });
	},
	
	getZipCode: function() {
		return $.cookie('zipCode') || '';
	},
	
	// direction is either 'in' or 'out'
	/*fadeContent: function(direction) {
		var settings  = Config.FadeContentArea;
		var fadeOutDiv = $('#fadeOutContentDiv');
		fadeOutDiv.css('height', $('#contentWrapperScrollWindow').outerHeight() + 'px');
		if (direction.toLowerCase().indexOf('in') > -1) {
			if (sewellInterface.home && sewellInterface.home.slideShow) sewellInterface.home.slideShow.pause();
			fadeOutDiv.css('display', 'block').fadeTo(settings.duration, settings.opacity);
		} else {
			if (sewellInterface.home && sewellInterface.home.slideShow) sewellInterface.home.slideShow.play();
			fadeOutDiv.fadeTo(settings.duration, 0, function(){ fadeOutDiv.css('display', 'none'); });
		}
	},*/
	
	changeFontSize: function(a) {
		sewellInterface.footer.close(); // close footer buttons
		
		var li = $(a).parent('li');
		
		if ($.cookie('fontSize') == 'medium') {
			$('body').css('fontSize', 'small');
			li.removeClass().addClass('fontSizeSTL');
			a.setAttribute('title', 'Increase the font size');
			//$.cookie('fontSize', '', { expires: -1 });
		} else {
			$('body').css('fontSize', '108%');
			li.removeClass().addClass('fontSizeLTS');
			a.setAttribute('title', 'Decrease the font size');
			//$.cookie('fontSize', 'medium', { expires: 100 });
		}
		
		sewellInterface.scrollWindow.reload();
	},
	
	updateSelect: function(select, options) {
		select.innerHTML = '';
		select.disabled = true;
		for (var i=0; i<options.length; i++)
			select.options[i] = new Option($.trim(options[i].name), $.trim(options[i].value));
		select.disabled = false;
	},
	
	// type is: U=preowned, N=new, M=model
	loadBrands: function(type, select, callback) {
		$.getJSON('/Make.aspx', { Type: type }, function(json) {
			Interface.Globals.updateSelect(select, json.options);
			if (callback) callback();
		});
	},
	
	// type is: U=preowned, N=new, M=model
	loadModels: function(type, brand, select, callback) {
		$.getJSON('/Model.aspx', { Type: type, Make: brand }, function(json) {
			Interface.Globals.updateSelect(select, json.options);
			if (callback) callback();
		});
	},
	
	// brand can be null to pull back all dealerships
	loadDealerships: function(brand, select, callback) {
		$.getJSON('/Dealership.aspx', ((brand) ? { Brand: brand } : {}), function(json) {
			Interface.Globals.updateSelect(select, json.options);
			if (callback) callback();
		});
	},
	
	loadYears: function(type, brand, model, select, toYear, callback) {
		var params = { Type: type, Make: brand, Model: model };
		if (toYear) $.extend(params, { To: 'true' });
		$.getJSON('/Year.aspx', params, function(json) {
			Interface.Globals.updateSelect(select, json.options);
			if (callback) callback();
		});
	}
};