﻿App = { init: function() { this.boxen(); this.tips(); this.map(); this.formSubmit(); this.toolBar(); $('a[href^="http://"]').attr("target", "_blank") }, boxen: function() { if ($('.boxen').length < 1) return; Layer.init(); $('.boxen').each(function() { var a = $(this).attr('href'); var b = $(this).attr('rel'); var c = b.split('|'); $(this).click(function() { Layer.show(a, c[0], c[1]); return false }) }) }, map: function() { if ($('#usmap').length < 1) return; var b = new Array(); $('#usmap a').each(function() { b.push($(this).attr('src').replace(/out/i, "over")) }); for (var i = 0; i < b.length; i++) { var c = new Image(); c.src = b[i] } $('#usmap a').mouseover(function() { var a = $(this).find('img'); $(a).attr('src', '/images/states/spacer.gif') }); $('#usmap a').mouseout(function() { var a = $(this).find('img'); $(a).attr('src', '/images/states/' + $(this).attr('rel') + '.gif') }); $('#usmap a').attr('target', '_blank') }, tips: function() { if ($('.tip').length < 1) return; $('.tip').each(function() { $(this).qtip({ content: $(this).next().html(), position: { adjust: { x: -20, screen: true }, corner: { target: 'topRight', tooltip: 'bottomMiddle'} }, style: { width: 270, paddingTop: 15, paddingBottom: 15, background: '#ffffff', color: '#686b72', border: { width: 3, radius: 0, color: '#16699D' }, tip: { corner: 'bottomMiddle', size: { x: 13, y: 7}}} }) }) }, toolBar: function() { if (!$('.tool-bar').length) return; BitlyCB.onResponse = function(a) { var b; for (var r in a.results) { b = a.results[r]; break } var c = b['shortUrl'].toString(); $('.tool-bar a').each(function() { $(this).attr('href', $(this).attr('href') + c) }); $('.tool-bar').show() }; BitlyClient.call('shorten', { 'longUrl': location.href }, 'BitlyCB.onResponse') }, formSubmit: function() { $('form').keypress(function(e) { if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) { this.submit(); return false } else { return true } }) } }; $().ready(function() { App.init() }); var w = 620; var h = 406; var content, layer, popup, popupDivert; var Layer = { init: function(a) { layer = $('<div id="layer"></div>').appendTo('body'); popup = $('<div id="popup"></div>').appendTo('body'); popupDivert = $('<div id="popupDivert"></div>').appendTo('body'); layer.focus(Layer.findFocus); popupDivert.focus(Layer.findFocus) }, show: function(a, b, c) { w = b > 0 ? b : w; h = c > 0 ? c : h; layer.attr('tabIndex', 0).show(); popup.attr('tabIndex', 0).addClass("popup"); popup.css('left', (960 - w) * .5 + 20); popupDivert.attr('tabIndex', 0); var d = window.setTimeout(function() { content = $('<iframe>').attr({ id: 'iframe_content' + a, width: w, height: h, frameBorder: 0, src: a }).appendTo(popup); popup.focus(); window.clearTimeout(d) }, 200) }, close: function(a) { layer.removeAttr('tabIndex').hide(); popupDivert.removeAttr("tabIndex"); popup.removeAttr('tabIndex').removeClass("popup"); popup.children().remove() }, findFocus: function(a) { $(content).contents().find('a.close').focus() } };