// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Philip Myers :: http://virtualipod.tripod.com/bookmark.html */

function supportsBookmarking() {
  return (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4);
}

function bookmark(){
  if (window.sidebar) {
    window.sidebar.addPanel(document.title, location.href, "");
  } else if( document.all ) {
    window.external.AddFavorite(location.href, document.title);
  } else if( window.opera && window.print ) {
    alert("Press CTRL-D (Netscape/Firefox) or CTRL-T (Opera) to bookmark");
  }
}

function mailto() {
  subject = "Deliver.com"
  body = "I thought you might be interested in this:\n\n" + location.href + "\n";
  link = "mailto:?subject=" + escape(subject) + "&body=" + escape(body);
  win = window.open(link, 'emailWindow');
  if (win && win.open && !win.closed) win.close(); 
}

function getCityForZip() {
  id = this.id;
  $.get("/zip_code", {zip: this.value}, function(data) {
    $("#" + id + "_city_state").html(data);
  }); 
}

function defaultTime() {
  // Set initial hour for time
/*
    var suffix = "AM";
    var hours = new Date().getHours() + 1;

    if (hours == 24) {
        hours = 12;
        $('#datepicker').each(function() {
            var curr = Date.fromString($(this).val());
            curr = curr.addDays(1).asString();
            $(this).val(curr);
        });
    } else if (hours >= 12) {
        suffix = "PM";
        hours = hours == 12 ? 12 : hours - 12;
    }
*/
    var curDate = new Date();
    var hr = curDate.getHours();
    var ap = hr > 11 ? 'PM' : 'AM';
    hr = hr % 12;
    if (hr == 0) { hr = 12; }
    mn = curDate.getMinutes();
    if (mn < 10) { mn = "0" + mn; }
  return hr + ":" + mn + " " + ap;
  //return hours + ":00 " + suffix
}

function openInNewWindow() {
    // Change "_blank" to something like "newWindow" to load all links in the same new window
    var newWindow = window.open(this.getAttribute('href'), '_blank', 'height=400,width=700,top=400,left=500,menubar=0,status=0,resizable=1,toolbar=1,scrollbars=1');
    newWindow.focus();
    return false;
}

/* ------------------------- Begin the UserVoice functions  -------------------------------- */
var uservoiceOptions = {
    /* required */
    key: 'deliver',
    host: 'deliver.uservoice.com',
    forum: '35399',
    showTab: true,
    /* optional */
    alignment: 'left',
    background_color: '#757476',
    text_color: 'white',
    hover_color: '#a8c338',
    lang: 'en'
};

function _loadUserVoice() {
    var s = document.createElement('script');
    s.setAttribute('type', 'text/javascript');
    s.setAttribute('src', ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.uservoice.com/javascripts/widgets/tab.js");
    document.getElementsByTagName('head')[0].appendChild(s);
}

/* ------------------------- End the UserVoice functions  -------------------------------- */

$(document).ready(function() {
$("a#Login").fancybox({
        'padding' : 0,
        'hideOnContentClick': false
    });
});
