diff --git a/README.md b/README.md
index 34981849af1f420236229466374cba706e0351e3..4d97925949c0c7e4fff49c52ab5c8b445572f171 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,25 @@ Follow the usual install instructions (beginning from Manual Installation
 above), except, don't delete the setup/ folder. For this reason, such an
 installation is not recommended for a public-facing support system.
 
+Upgrading
+---------
+osTicket supports upgrading from 1.6-rc1 and later versions. As with any
+upgrade, strongly consider a backup of your attachment files, database, and
+osTicket codebase before embarking on an upgrade.
+
+To trigger the update process, fetch the osTicket-1.7 tarball from either
+the osTicket [github](http://github.com/osTicket/osTicket-1.7) page or from
+the osTicket website. Extract the tarball into the folder of you osTicket
+codebase. This can also be accomplished with the zip file, and a FTP client
+can of course be used to upload the new source code to your server. 
+
+Any way you choose your adventure, when you have your codebase upgraded to
+osTicket-1.7, visit the /scp page of you ticketing system. The upgrader will
+be presented and will walk you through the rest of the process. (The couple
+clicks needed to go through the process are pretty boring to describe).
+
+View the UPGRADING.txt file for other todo items to complete your upgrade.
+
 Help
 ----
 Visit the [wiki](http://osticket.com/wiki/Home) or the
diff --git a/UPGRADING.txt b/UPGRADING.txt
new file mode 100644
index 0000000000000000000000000000000000000000..bdb477299beaf64ef7c96435116bf31d4c2ad6ec
--- /dev/null
+++ b/UPGRADING.txt
@@ -0,0 +1,90 @@
+Welcome to osTicket 1.7
+=======================
+Some tasks are better left to a system administrator rather than a mindless
+upgrade script. These are those remaining things that we'd rather you take
+care of:
+
+  * Verify that your attachments have been successfully migrated to the
+    database and removed from your server's filesystem. Once you're
+    comfortable that they're all migrated, and that the remaining files are
+    all failed uploads or orphans from deleted tickets, remove the folder
+    where attachments were uploaded to.
+
+  * Remove codebase files no longer utilized in osTicket 1.7. If you have
+    console access to your server, a codebase-cleanup.sh script is provided
+    for you in the setup/ folder to help you automatically take care of this.
+    Otherwise, you may safely remove the following files from your codebase if
+    they exist:
+
+    * Removed in osTicket-1.6-rc5
+      ostconfig.php
+
+    * Removed in osTicket-1.6.0
+      images/button.jpg
+      images/logo.jpg
+      images/new_ticket_title.jpg
+      images/ticket_status_title.jpg
+      include/settings.php
+
+    * Removed in osTicket-1.7.0
+      images/bg.gif
+      images/fibres.png
+      images/home.gif
+      images/icons
+      images/lipsum.png
+      images/logo2.jpg
+      images/logout.gif
+      images/my_tickets.gif
+      images/new_ticket.gif
+      images/new_ticket_icon.jpg
+      images/poweredby.jpg
+      images/rainbow.png
+      images/refresh_btn.gif
+      images/ticket_status.gif
+      images/ticket_status_icon.jpg
+      images/verticalbar.jpg
+      images/view_closed_btn.gif
+      images/view_open_btn.gif
+      include/class.msgtpl.php
+      include/class.sys.php
+      include/client/index.php
+      include/client/viewticket.inc.php
+      include/ost-config.sameple.php
+      include/staff/api.inc.php
+      include/staff/changepasswd.inc.php
+      include/staff/dept.inc.php
+      include/staff/depts.inc.php
+      include/staff/editticket.inc.php
+      include/staff/mypref.inc.php
+      include/staff/myprofile.inc.php
+      include/staff/newticket.inc.php
+      include/staff/premade.inc.php
+      include/staff/reply.inc.php
+      include/staff/smtp.inc.php
+      include/staff/viewticket.inc.php
+      scp/css/autosuggest_inquisitor.css
+      scp/css/datepicker.css
+      scp/css/main.css
+      scp/css/style.css
+      scp/css/tabs.css
+      scp/images/alert.png
+      scp/images/bg-login-box.gif
+      scp/images/icons/email_settings.gif
+      scp/images/logo-support.gif
+      scp/images/minus.gif
+      scp/images/ostlogo.jpg
+      scp/images/pagebg.jpg
+      scp/images/plus.gif
+      scp/images/refresh.gif
+      scp/images/tab.jpg
+      scp/images/view_closed.gif
+      scp/images/view_open.gif
+      scp/js/ajax.js
+      scp/js/autolock.js
+      scp/js/bsn.AutoSuggest_2.1.3.js
+      scp/js/calendar.js
+      scp/js/datepicker.js
+      scp/js/tabber.js
+
+  * Remove the setup/ folder. This contains code you won't need for a live
+    ticketing system.
diff --git a/api/.htaccess b/api/.htaccess
index e230ac6e186f66ada37cca3809396e32b98473e1..e73e2eb3b9c3f1204223b4426274817c0200e279 100644
--- a/api/.htaccess
+++ b/api/.htaccess
@@ -1,4 +1,3 @@
-Options +FollowSymLinks
 RewriteEngine On
 
 RewriteBase /api/
diff --git a/api/pipe.php b/api/pipe.php
index b4e5e5ad5c247cb93de0dad36281651d2d2a365d..a35d2af2099ec60ae77edece8a1b2d0416f42773 100644
--- a/api/pipe.php
+++ b/api/pipe.php
@@ -87,7 +87,7 @@ $var['emailId']=$emailId?$emailId:$cfg->getDefaultEmailId();
 $var['subject']=$subj?$subj:'[No Subject]';
 $var['message']=utf8_encode(Format::stripEmptyLines($body));
 $var['header']=$parser->getHeader();
-$var['pri']=$cfg->useEmailPriority()?$parser->getPriority():0;
+$var['priorityId']=$cfg->useEmailPriority()?$parser->getPriority():0;
 
 $ticket=null;
 if(preg_match ("[[#][0-9]{1,10}]",$var['subject'],$regs)) {
@@ -123,7 +123,7 @@ if($cfg->allowEmailAttachments()) {
         //print_r($attachments);
         foreach($attachments as $k=>$attachment){
             if($attachment['filename'] && $cfg->canUploadFileType($attachment['filename'])) {
-                $ticket->saveAttachment($attachment['filename'],$attachment['body'],$msgid,'M');
+                $ticket->saveAttachment(array('name' => $attachment['filename'], 'data' => $attachment['body']),$msgid,'M');
             }
         }
     }
diff --git a/include/ajax.reports.php b/include/ajax.reports.php
index 8b09100225f0d875c93476253a7eab4ae81873b4..9d002eb52c698a6788e33635f5576c22560d93df 100644
--- a/include/ajax.reports.php
+++ b/include/ajax.reports.php
@@ -35,8 +35,12 @@ class OverviewReportAjaxAPI extends AjaxController {
     }
 
     function getData() {
-        $start = $this->get('start', strtotime('last month'));
-        $stop = $this->get('stop', time());
+        $start = $this->get('start', 'last month');
+        $stop = $this->get('stop', 'now');
+        if (substr($stop, 0, 1) == '+')
+            $stop = $start . $stop;
+        $start = 'FROM_UNIXTIME('.strtotime($start).')';
+        $stop = 'FROM_UNIXTIME('.strtotime($stop).')';
 
         $groups = array(
             "dept" => array(
@@ -67,45 +71,51 @@ class OverviewReportAjaxAPI extends AjaxController {
         $info = $groups[$group];
         # XXX: Die if $group not in $groups
 
-        $res = db_query(
-            'SELECT ' . $info['fields'] . ','
-                .'(SELECT COUNT(A1.ticket_id) FROM '.TICKET_TABLE
-                    .' A1 WHERE A1.'.$info['pk'].' = T1.'.$info['pk']
-                    .'   AND A1.status=\'open\') AS Open,'
-                .'(SELECT COUNT(A1.ticket_id) FROM '.TICKET_TABLE
-                    .' A1 WHERE A1.'.$info['pk'].' = T1.'.$info['pk']
-                    .'   AND (A1.staff_id > 0 OR A1.team_id > 0)'
-                    .'   AND A1.status=\'open\') AS Assigned,'
-                .'(SELECT COUNT(A1.ticket_id) FROM '.TICKET_TABLE
-                    .' A1 WHERE A1.'.$info['pk'].' = T1.'.$info['pk']
-                    .'   AND (A1.staff_id = 0 AND A1.team_id = 0)'
-                    .'   AND A1.status=\'open\') AS Unassigned,'
-                .'(SELECT COUNT(A1.ticket_id) FROM '.TICKET_TABLE
-                    .' A1 WHERE A1.'.$info['pk'].' = T1.'.$info['pk']
-                    .'   AND A1.isanswered = 0'
-                    .'   AND A1.status=\'open\') AS Unanswered,'
-                .'(SELECT COUNT(A1.ticket_id) FROM '.TICKET_TABLE
-                    .' A1 WHERE A1.'.$info['pk'].' = T1.'.$info['pk']
-                    .'   AND A1.isoverdue = 1'
-                    .'   AND A1.status=\'open\') AS Overdue,'
-                .'(SELECT COUNT(A1.ticket_id) FROM '.TICKET_TABLE
-                    .' A1 WHERE A1.'.$info['pk'].' = T1.'.$info['pk']
-                    .'   AND A1.status=\'closed\') AS Closed,'
-                .'(SELECT COUNT(A1.ticket_id) FROM '.TICKET_TABLE
-                    .' A1 WHERE A1.'.$info['pk'].' = T1.'.$info['pk']
-                    .'   AND A1.reopened is not null) AS Reopened,'
-                .'(SELECT FORMAT(AVG(DATEDIFF(A1.closed, A1.created)),1) FROM '.TICKET_TABLE
-                    .' A1 WHERE A1.'.$info['pk'].' = T1.'.$info['pk']
-                    .'   AND A1.status=\'closed\') AS ServiceTime'
-            .' FROM ' . $info['table'] . ' T1'
+        $queries=array(
+            array(5, 'SELECT '.$info['fields'].',
+                COUNT(*)-COUNT(NULLIF(A1.state, "created")) AS Opened,
+                COUNT(*)-COUNT(NULLIF(A1.state, "assigned")) AS Assigned,
+                COUNT(*)-COUNT(NULLIF(A1.state, "overdue")) AS Overdue,
+                COUNT(*)-COUNT(NULLIF(A1.state, "closed")) AS Closed,
+                COUNT(*)-COUNT(NULLIF(A1.state, "reopened")) AS Reopened
+            FROM '.$info['table'].' T1 LEFT JOIN '.TICKET_TABLE.' T2 USING ('.$info['pk'].')
+                LEFT JOIN '.TICKET_EVENT_TABLE.' A1 USING (ticket_id)
+            WHERE A1.timestamp BETWEEN '.$start.' AND '.$stop.'
+            GROUP BY '.$info['fields'].'
+            ORDER BY '.$info['fields']),
+
+            array(1, 'SELECT '.$info['fields'].',
+                FORMAT(AVG(DATEDIFF(T2.closed, T2.created)),1) AS ServiceTime
+            FROM '.$info['table'].' T1 LEFT JOIN '.TICKET_TABLE.' T2 USING ('.$info['pk'].')
+            WHERE T2.closed BETWEEN '.$start.' AND '.$stop.'
+            GROUP BY '.$info['fields'].'
+            ORDER BY '.$info['fields']),
+
+            array(1, 'SELECT '.$info['fields'].',
+                FORMAT(AVG(DATEDIFF(B2.created, B1.created)),1) AS ResponseTime
+            FROM '.$info['table'].' T1 LEFT JOIN '.TICKET_TABLE.' T2 USING ('.$info['pk'].')
+                LEFT JOIN '.TICKET_THREAD_TABLE.' B2 ON (B2.ticket_id = T2.ticket_id
+                    AND B2.thread_type="R")
+                LEFT JOIN '.TICKET_THREAD_TABLE.' B1 ON (B2.pid = B1.id)
+            WHERE B1.created BETWEEN '.$start.' AND '.$stop.'
+            GROUP BY '.$info['fields'].'
+            ORDER BY '.$info['fields'])
         );
         $rows = array();
-        while ($row = db_fetch_row($res)) {
-            $rows[] = $row;
+        foreach ($queries as $q) {
+            list($c, $sql) = $q;
+            $res = db_query($sql);
+            $i = 0;
+            while ($row = db_fetch_row($res)) {
+                if (count($rows) <= $i)
+                    $rows[] = array_slice($row, 0, count($row) - $c);
+                $rows[$i] = array_merge($rows[$i], array_slice($row, -$c));
+                $i++;
+            }
         }
         return array("columns" => array_merge($info['headers'],
-                        array('Open','Assigned','Unassigned','Unanswered',
-                              'Overdue','Closed','Reopened','Service Time')),
+                        array('Open','Assigned','Overdue','Closed','Reopened',
+                              'Service Time','Response Time')),
                      "data" => $rows);
     }
 
diff --git a/include/ajax.upgrader.php b/include/ajax.upgrader.php
new file mode 100644
index 0000000000000000000000000000000000000000..fa0b50a99c9c8271caf96e927c6032bbde4b9eee
--- /dev/null
+++ b/include/ajax.upgrader.php
@@ -0,0 +1,68 @@
+<?php
+/*********************************************************************
+    ajax.upgrader.php
+
+    AJAX interface for Upgrader
+
+    Peter Rotich <peter@osticket.com>
+    Copyright (c)  2006-2012 osTicket
+    http://www.osticket.com
+
+    Released under the GNU General Public License WITHOUT ANY WARRANTY.
+    See LICENSE.TXT for details.
+
+    vim: expandtab sw=4 ts=4 sts=4:
+**********************************************************************/
+
+if(!defined('INCLUDE_DIR')) die('403');
+require_once INCLUDE_DIR.'class.upgrader.php';
+
+class UpgraderAjaxAPI extends AjaxController {
+
+    function upgrade() {
+        global $thisstaff, $ost;
+
+        if(!$thisstaff or !$thisstaff->isAdmin() or !$ost)
+            Http::response(403, 'Access Denied');
+
+        $upgrader = new Upgrader($ost->getDBSignature(), TABLE_PREFIX, PATCH_DIR);
+
+        //Just report the next action on the first call.
+        if(!$_SESSION['ost_upgrader'] || !$_SESSION['ost_upgrader'][$upgrader->getShash()]['progress']) {
+            $_SESSION['ost_upgrader'][$upgrader->getShash()]['progress'] = $upgrader->getNextAction();
+            Http::response(200, $upgrader->getNextAction());
+            exit;
+        }
+
+        if($upgrader->isAborted()) {
+            Http::response(416, "We have a problem ... wait a sec.");
+            exit;
+        }
+
+        if($upgrader->getNumPendingTasks() && $upgrader->doTasks()) {
+            //More pending tasks - doTasks returns the number of pending tasks
+            Http::response(200, $upgrader->getNextAction());
+            exit;
+        } elseif($ost->isUpgradePending() && $upgrader->isUpgradable()) {
+            $version = $upgrader->getNextVersion();
+            if($upgrader->upgrade()) {
+                //We're simply reporting progress here - call back will report next action'
+                Http::response(200, "Upgraded to $version ... post-upgrade checks!");
+                exit;
+            }
+        } elseif(!$ost->isUpgradePending()) {
+            $upgrader->setState('done');
+            session_write_close();
+            Http::response(201, "We're done!");
+            exit;
+        }
+
+        if($upgrader->isAborted() || $upgrader->getErrors()) {
+            Http::response(416, "We have a problem ... wait a sec.");
+            exit;
+        }
+
+        Http::response(200, $upgrader->getNextAction());
+    }
+}
+?>
diff --git a/include/class.config.php b/include/class.config.php
index cb7cd40aed575013ee1db136d15037438d6b34fb..e293908d61637c923ba1c9cb4120b210065b0cc2 100644
--- a/include/class.config.php
+++ b/include/class.config.php
@@ -77,12 +77,18 @@ class Config {
         return THIS_VERSION;
     }
 
+    //Used to detect version prior to 1.7 (useful during upgrade)
+    function getDBVersion() {
+        return $this->config['ostversion'];
+    }
+
     function getSchemaSignature() {
 
         if($this->config['schema_signature'])
             return $this->config['schema_signature'];
-        elseif($this->config['ostversion']) //old version 1.6 st.
-            return md5(strtoupper($this->config['ostversion']));
+
+        if($this->config['ostversion']) //old version 1.6 RC[1-5]-ST
+            return md5(strtoupper(trim($this->config['ostversion'])));
 
         return null;
     }
diff --git a/include/class.export.php b/include/class.export.php
index 7d6a7e7ec87b5939d8a7657370ea61626c06700c..a47a6f6f99c2eba77597694d22b2d69e1820407b 100644
--- a/include/class.export.php
+++ b/include/class.export.php
@@ -16,18 +16,18 @@
 
 class Export {
     
-    /* static */ function dumpQuery($sql, $headers, $how='csv') {
+    /* static */ function dumpQuery($sql, $headers, $how='csv', $filter=false) {
         $exporters = array(
             'csv' => CsvResultsExporter,
             'json' => JsonResultsExporter
         );
-        $exp = new $exporters[$how]($sql, $headers);
+        $exp = new $exporters[$how]($sql, $headers, $filter);
         return $exp->dump();
     }
 
     # XXX: Think about facilitated exporting. For instance, we might have a
     #      TicketExporter, which will know how to formulate or lookup a
-    #      formatl query (SQL), and cooperate with the output process to add
+    #      format query (SQL), and cooperate with the output process to add
     #      extra (recursive) information. In this funciton, the top-level
     #      SQL is exported, but for something like tickets, we will need to
     #      export attached messages, reponses, and notes, as well as
@@ -60,8 +60,11 @@ class Export {
 }
 
 class ResultSetExporter {
-    function ResultSetExporter($sql, $headers) {
+    function ResultSetExporter($sql, $headers, $filter=false) {
         $this->headers = array_values($headers);
+        if ($s = strpos(strtoupper($sql), ' LIMIT '))
+            $sql = substr($sql, 0, $s);
+        # TODO: If $filter, add different LIMIT clause to query
         $this->_res = db_query($sql);
         if ($row = db_fetch_array($this->_res)) {
             $query_fields = array_keys($row);
diff --git a/include/class.file.php b/include/class.file.php
index b9bfbe1b7d2975ebdcc467bfb826ed35b8f1ec75..891a8b5bfb851415c1ab3cbe804284ae5217f229 100644
--- a/include/class.file.php
+++ b/include/class.file.php
@@ -172,10 +172,18 @@ class AttachmentFile {
             .',type='.db_input($file['type'])
             .',size='.db_input($file['size'])
             .',name='.db_input($file['name'])
-            .',hash='.db_input($file['hash'])
-            .',filedata='.db_input($file['data']);
+            .',hash='.db_input($file['hash']);
 
-        return db_query($sql)?db_insert_id():0;
+        if (!(db_query($sql) && ($id=db_insert_id())))
+            return false;
+
+        foreach (str_split($file['data'], 1024*100) as $chunk) {
+            if (!db_query('UPDATE '.FILE_TABLE.' SET filedata = CONCAT(filedata,'
+                    .db_input($chunk).') WHERE id='.db_input($id)))
+                # Remove partially uploaded file contents
+                return false;
+        }
+        return $id;
     }
 
     /* Static functions */
diff --git a/include/class.filter.php b/include/class.filter.php
index 9c3065c10aba5aa1e359e4c36a67e4de83aec9fe..a749e5eaeabc6c08d0a44d29fa30782511313bac 100644
--- a/include/class.filter.php
+++ b/include/class.filter.php
@@ -99,6 +99,10 @@ class Filter {
         return $this->ht['team_id'];
     }
 
+    function getCannedResponse() {
+        return $this->ht['canned_response_id'];
+    }
+
     function stopOnMatch(){
         return ($this->ht['stop_on_match']);
     }
@@ -274,6 +278,8 @@ class Filter {
             if ($email['reply-to-name']) 
                 $ticket['name'] = $email['reply-to-name'];
         }
+        if ($this->getCannedResponse())
+            $ticket['cannedResponseId'] = $this->getCannedResponse();
     }
 
     function update($vars,&$errors){
@@ -395,6 +401,7 @@ class Filter {
              ',reject_email='.db_input(isset($vars['reject_email'])?1:0).
              ',use_replyto_email='.db_input(isset($vars['use_replyto_email'])?1:0).
              ',disable_autoresponder='.db_input(isset($vars['disable_autoresponder'])?1:0).
+             ',canned_response_id='.db_input($vars['canned_response']).
              ',notes='.db_input($vars['notes']);
        
 
diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php
index a353b690be55c3f9cbd3740b6edcc7164dabc16e..248a6ba81b6f52d9397414c1a08db92e5b88336e 100644
--- a/include/class.mailfetch.php
+++ b/include/class.mailfetch.php
@@ -283,7 +283,7 @@ class MailFetcher {
         $var['mid']=$mailinfo['mid'];
 
         if($cfg->useEmailPriority())
-            $var['pri']=$this->getPriority($mid);
+            $var['priorityId']=$this->getPriority($mid);
        
         $ticket=null;
         $newticket=true;
@@ -330,7 +330,7 @@ class MailFetcher {
             if($ticket && $cfg->canUploadFileType($filename) && $cfg->getMaxFileSize()>=$part->bytes) {
                 //extract the attachments...and do the magic.
                 $data=$this->decode($part->encoding, imap_fetchbody($this->mbox,$mid,$index));
-                $ticket->saveAttachment($filename,$data,$ticket->getLastMsgId(),'M');
+                $ticket->saveAttachment(array('name'=>$filename, 'data'=>$data),$ticket->getLastMsgId(),'M');
                 return;
             }
             //TODO: Log failure??
diff --git a/include/class.migrater.php b/include/class.migrater.php
new file mode 100644
index 0000000000000000000000000000000000000000..04f38be2af9c46c7705591e550bb993096d723d2
--- /dev/null
+++ b/include/class.migrater.php
@@ -0,0 +1,288 @@
+<?php
+/*********************************************************************
+    class.migrater.php
+
+    Migration utils required by upgrader.
+    
+    Jared Hancock <jared@osticket.com>
+    Copyright (c)  2006-2012 osTicket
+    http://www.osticket.com
+
+    Released under the GNU General Public License WITHOUT ANY WARRANTY.
+    See LICENSE.TXT for details.
+
+    vim: expandtab sw=4 ts=4 sts=4:
+**********************************************************************/
+
+
+/*
+    DatabaseMigrater.
+
+    SQL database migrater. This provides the engine capable of rolling the
+    database for an osTicket installation forward (and perhaps even
+    backward) in time using a set of included migration scripts. Each script
+    will roll the database between two database checkpoints. Where possible,
+    the migrater will roll several checkpoint scripts into one to be applied
+    together.
+
+*/
+
+class DatabaseMigrater {
+
+    var $start;
+    var $end;
+    var $sqldir;
+
+    function DatabaseMigrater($start, $end, $sqldir) {
+       
+        $this->start = $start;
+        $this->end = $end;
+        $this->sqldir = $sqldir;
+       
+    }
+
+    function getPatches($stop=null) {
+
+        $start= $this->start;
+        $stop = $stop?$stop:$this->end;
+
+        $patches = array();
+        while (true) {
+            $next = glob($this->sqldir . substr($start, 0, 8)
+                         . '-*.patch.sql');
+            if (count($next) == 1) {
+                $patches[] = $next[0];
+                $start = substr(basename($next[0]), 9, 8);
+            } elseif (count($next) == 0) {
+                # There are no patches leaving the current signature. We
+                # have to assume that we've applied all the available
+                # patches.
+                break;
+            } else {
+                # Problem -- more than one patch exists from this snapshot.
+                # We probably need a graph approach to solve this.
+                break;
+            }
+
+            # Break if we've reached our target stop.
+            if(!$start || !strncasecmp($start, $stop, 8))
+                break;
+        }
+
+        return $patches;
+    }
+}
+
+
+/*
+    AttachmentMigrater
+
+    Attachment migration from file-based attachments in pre-1.7 to
+    database-backed attachments in osTicket v1.7. This class provides the
+    hardware to find and retrieve old attachments and move them into the new
+    database scheme with the data in the actual database.
+
+    Copyright (c)  2006-2012 osTicket
+    http://www.osticket.com
+
+    Released under the GNU General Public License WITHOUT ANY WARRANTY.
+    See LICENSE.TXT for details.
+
+    vim: expandtab sw=4 ts=4 sts=4:
+*/
+
+include_once(INCLUDE_DIR.'class.file.php');
+
+class AttachmentMigrater {
+
+
+    function AttachmentMigrater() {
+        $this->queue = &$_SESSION['ost_upgrader']['AttachmentMigrater']['queue'];
+        $this->skipList = &$_SESSION['ost_upgrader']['AttachmentMigrater']['skip'];
+        $this->errorList = array();
+    }
+
+
+    /**
+     * Process the migration for a unit of time. This will be used to
+     * overcome the execution time restriction of PHP. This instance can be
+     * stashed in a session and have this method called periodically to
+     * process another batch of attachments
+     *
+     * Returns:
+     * Number of pending attachments to migrate.
+     */
+    function do_batch($time=30, $max=0) {
+
+        if(!$this->queueAttachments($max) || !$this->getQueueLength())
+            return 0;
+
+        $count = 0;
+        $start = Misc::micro_time();
+        while ($this->getQueueLength() && (Misc::micro_time()-$start) < $time)
+            if($this->next() && $max && ++$count>=$max)
+                break;
+
+        return $this->queueAttachments($max);
+
+    }
+
+    function getSkipList() {
+        return $this->skipList;
+    }
+
+    function enqueue($fileinfo) {
+        $this->queue[] = $fileinfo;
+    }
+
+    function getQueue() {
+        return $this->queue;
+    }
+
+    function getQueueLength() { return count($this->queue); }
+    /**
+     * Processes the next item on the work queue. Emits a JSON messages to
+     * indicate current progress.
+     *
+     * Returns:
+     * TRUE/NULL if the migration was successful
+     */
+    function next() {
+        # Fetch next item -- use the last item so the array indices don't
+        # need to be recalculated for every shift() operation.
+        $info = array_pop($this->queue);
+        # Attach file to the ticket
+        if (!($info['data'] = @file_get_contents($info['path']))) {
+            # Continue with next file
+            return $this->skip($info['attachId'],
+                sprintf('%s: Cannot read file contents', $info['path']));
+        }
+        # Get the mime/type of each file
+        # XXX: Use finfo_buffer for PHP 5.3+
+        if(function_exists('mime_content_type')) { 
+            //XXX: function depreciated in newer versions of PHP!!!!!
+            $info['type'] = mime_content_type($info['path']);
+        } elseif (function_exists('finfo_file')) { // PHP 5.3.0+
+            $finfo = finfo_open(FILEINFO_MIME_TYPE);
+            $info['type'] = finfo_file($finfo, $info['path']);
+        }
+        # TODO: Add extension-based mime-type lookup
+
+        if (!($fileId = AttachmentFile::save($info))) {
+            return $this->skip($info['attachId'],
+                sprintf('%s: Unable to migrate attachment', $info['path']));
+        }
+        # Update the ATTACHMENT_TABLE record to set file_id
+        db_query('update '.TICKET_ATTACHMENT_TABLE
+                .' set file_id='.db_input($fileId)
+                .' where attach_id='.db_input($info['attachId']));
+        # Remove disk image of the file. If this fails, the migration for
+        # this file would not be retried, because the file_id in the
+        # TICKET_ATTACHMENT_TABLE has a nonzero value now
+        if (!@unlink($info['path'])) //XXX: what should we do on failure?
+            $this->error(
+                sprintf('%s: Unable to remove file from disk',
+                $info['path']));
+        # TODO: Log an internal note to the ticket?
+        return true;
+    }
+    /**
+     * From (class Ticket::fixAttachments), used to detect the locations of
+     * attachment files
+     */
+    /* static */ function queueAttachments($limit=0){
+        global $cfg, $ost;
+
+        # Since the queue is persistent - we want to make sure we get to empty 
+        # before we find more attachments.
+        if(($qc=$this->getQueueLength()))
+            return $qc;
+
+        $sql='SELECT attach_id, file_name, file_key, Ti.created'
+            .' FROM '.TICKET_ATTACHMENT_TABLE.' TA'
+            .' INNER JOIN '.TICKET_TABLE.' Ti ON (Ti.ticket_id=TA.ticket_id)'
+            .' WHERE NOT file_id ';
+
+        if(($skipList=$this->getSkipList()))
+            $sql.= ' AND attach_id NOT IN('.implode(',', db_input($skipList)).')';
+
+        if($limit && is_numeric($limit))
+            $sql.=' LIMIT '.$limit;
+
+        //XXX: Do a hard fail or error querying the database?
+        if(!($res=db_query($sql)))
+            return $this->error('Unable to query DB for attached files to migrate!');
+
+        $ost->logDebug('Found '.db_num_rows($res).' attachments to migrate');
+        if(!db_num_rows($res))
+            return 0;  //Nothing else to do!!
+
+        $dir=$cfg->getUploadDir();
+        if(!$dir || !is_dir($dir)) //XXX: Abort the upgrade??? Attachments are obviously critical!
+            return $this->error("Attachment directory [$dir] is invalid - aborting attachment migration");
+
+        //Clear queue
+        $this->queue = array();
+        while (list($id,$name,$key,$created)=db_fetch_row($res)) {
+            $month=date('my',strtotime($created));
+            $info=array(
+                'name'=>        $name,
+                'attachId'=>    $id,
+            );
+            $filename15=sprintf("%s/%s_%s",rtrim($dir,'/'),$key,$name);
+            $filename16=sprintf("%s/%s/%s_%s",rtrim($dir,'/'),$month,$key,$name); //new destination.
+            if (file_exists($filename15)) { 
+                $info['path'] = $filename15;
+            } elseif (file_exists($filename16)) {  
+                $info['path'] = $filename16;
+            } else {
+                # XXX Cannot find file for attachment
+                $this->skip($id,
+                        sprintf('%s: Unable to locate attachment file',
+                            $name));
+                # No need to further process this file
+                continue;
+            }
+            # TODO: Get the size and mime/type of each file.
+            #
+            # NOTE: If filesize() fails and file_get_contents() doesn't,
+            # then the AttachmentFile::save() method will automatically
+            # estimate the filesize based on the length of the string data
+            # received in $info['data'] -- ie. no need to do that here.
+            #
+            # NOTE: The size is done here because it should be quick to
+            # lookup out of file inode already loaded. The mime/type may
+            # take a while because it will require a second IO to read the
+            # file data.  To ensure this will finish before the
+            # max_execution_time, perform the type match in the ::next()
+            # method since the entire file content will be read there
+            # anyway.
+            $info['size'] = @filesize($info['path']);
+            # Coroutines would be nice ..
+            $this->enqueue($info);
+        }
+
+        return $this->queueAttachments($limit);
+    }
+
+    function skip($attachId, $error) {
+
+        $this->skipList[] = $attachId;
+
+        return $this->error($error." (ID #$attachId)");
+    }
+
+    function error($what) {
+        global $ost;
+
+        $this->errors++;
+        $this->errorList[] = $what;
+        $ost->logDebug('Upgrader: Attachment Migrater', $what);
+        # Assist in returning FALSE for inline returns with this method
+        return false;
+    }
+    function getErrors() {
+        return $this->errorList;
+    }
+}
+?>
diff --git a/include/class.misc.php b/include/class.misc.php
index 409e4bac6f84eee1c73b1d040eda18455c0f4954..9fd6744ba8913061a5e34c2b10bf705216d286fa 100644
--- a/include/class.misc.php
+++ b/include/class.misc.php
@@ -58,6 +58,13 @@ class Misc {
         return time()-date('Z');
     }
 
+    /* Needed because of PHP 4 support */
+    function micro_time() {
+        list($usec, $sec) = explode(" ", microtime());
+
+        return ((float)$usec + (float)$sec);
+    }
+
     //Current page
     function currentURL() {
         
diff --git a/include/class.nav.php b/include/class.nav.php
index ce3623d37acccb57d0eae500360a5579789683b5..a5ce84cb07affcec52e9ecec88460b790ece4fb6 100644
--- a/include/class.nav.php
+++ b/include/class.nav.php
@@ -181,7 +181,7 @@ class AdminNav extends StaffNav{
             $subnav=array();
             switch(strtolower($k)){
                 case 'dashboard':
-                    $subnav[]=array('desc'=>'System&nbsp;Logs','href'=>'syslogs.php','iconclass'=>'logs');
+                    $subnav[]=array('desc'=>'System&nbsp;Logs','href'=>'logs.php','iconclass'=>'logs');
                     break;
                 case 'settings':
                     $subnav[]=array('desc'=>'Settings&nbsp;&amp;&nbsp;Preferences','href'=>'settings.php','iconclass'=>'preferences');
diff --git a/include/class.osticket.php b/include/class.osticket.php
index 78e249d50436b451acabe7a90db69d578d502c2c..66938cc7c4cfba0db80439e1de5e9c010923116e 100644
--- a/include/class.osticket.php
+++ b/include/class.osticket.php
@@ -35,7 +35,14 @@ class osTicket {
 
     function osTicket($cfgId) {
         $this->config = Config::lookup($cfgId);
-        $this->session = osTicketSession::start(SESSION_TTL); // start_session 
+
+        //DB based session storage was added starting with v1.7
+        // which does NOT have DB Version
+        if($this->config && !$this->getConfig()->getDBVersion())
+            $this->session = osTicketSession::start(SESSION_TTL); // start DB based session
+        else
+            session_start();
+
     }
 
     function isSystemOnline() {
@@ -43,7 +50,7 @@ class osTicket {
     }
 
     function isUpgradePending() {
-        return (defined('SCHEMA_SIGNATURE') && strcasecmp($this->getConfig()->getSchemaSignature(), SCHEMA_SIGNATURE));
+        return (defined('SCHEMA_SIGNATURE') && strcasecmp($this->getDBSignature(), SCHEMA_SIGNATURE));
     }
 
     function getSession() {
@@ -59,6 +66,14 @@ class osTicket {
         return $this->getConfig()?$this->getConfig()->getId():0;
     }
 
+    function getDBSignature() {
+        return $this->getConfig()->getSchemaSignature();
+    }
+
+    function getVersion() {
+        return THIS_VERSION;
+    }
+
     function addExtraHeader($header) {
         $this->headers[md5($header)] = $header;
     }
@@ -122,6 +137,10 @@ class osTicket {
         if(!($to=$this->getConfig()->getAdminEmail()))
             $to=ADMIN_EMAIL;
 
+
+        //append URL to the message
+        $message.="\n\n".THISPAGE;
+
         //Try getting the alert email.
         $email=null;
         if(!($email=$this->getConfig()->getAlertEmail())) 
@@ -155,6 +174,14 @@ class osTicket {
         return $this->log(LOG_ERR, $title, $error, $alert);
     }
 
+    function logDBError($title, $error, $alert=true) {
+
+        if($alert && !$this->getConfig()->alertONSQLError())
+            $alert =false;
+
+        return $this->log(LOG_ERR, $title, $error, $alert);
+    }
+
     function log($priority, $title, $message, $alert=false) {
 
         //We are providing only 3 levels of logs. Windows style.
@@ -180,8 +207,8 @@ class osTicket {
         if($alert)
             $this->alertAdmin($title, $message);
 
-
-        if($this->getConfig()->getLogLevel()<$level)
+        //Logging everything during upgrade.
+        if($this->getConfig()->getLogLevel()<$level && !$this->isUpgradePending())
             return false;
 
         //Save log based on system log level settings.
diff --git a/include/class.ostsession.php b/include/class.ostsession.php
index 0bcd9449fb234c6b9a895da6b046527f7a7909a4..08cac02ce306f616ad0d6329e6a51436a78d9e7d 100644
--- a/include/class.ostsession.php
+++ b/include/class.ostsession.php
@@ -67,10 +67,13 @@ class osTicketSession {
     function write($id, $data){
         global $thisstaff;
 
+        $ttl = ($this && get_class($this) == 'osTicketSession') 
+            ? $this->getTTL() : SESSION_TTL;
+
         $sql='REPLACE INTO '.SESSION_TABLE.' SET session_updated=NOW() '.
              ',session_id='.db_input($id).
              ',session_data='.db_input($data).
-             ',session_expire=(NOW() + INTERVAL '.$this->getTTL().' SECOND)'.
+             ',session_expire=(NOW() + INTERVAL '.$ttl.' SECOND)'.
              ',user_id='.db_input($thisstaff?$thisstaff->getId():0).
              ',user_ip='.db_input($_SERVER['REMOTE_ADDR']).
              ',user_agent='.db_input($_SERVER['HTTP_USER_AGENT']);
diff --git a/include/class.pdf.php b/include/class.pdf.php
index 87e68a7d5277450dfb87eb7bfa54637449f1e105..2257dcc17aa6641fabeeac32a3fcecc28bd7b2c0 100644
--- a/include/class.pdf.php
+++ b/include/class.pdf.php
@@ -17,7 +17,6 @@
 define('THIS_DIR', str_replace('\\\\', '/', realpath(dirname(__FILE__))) . '/'); //Include path..
 define('FPDF_DIR', THIS_DIR . 'fpdf/');
 define('FPDF_FONTPATH', FPDF_DIR . 'font/'); //fonts directory.
-session_cache_limiter('private');
 require (FPDF_DIR . 'fpdf.php');
 
 class Ticket2PDF extends FPDF
@@ -29,10 +28,11 @@ class Ticket2PDF extends FPDF
 	
     var $ticket = null;
 
-	function Ticket2PDF($ticket, $notes=false) {
+	function Ticket2PDF($ticket, $psize='Letter', $notes=false) {
         global $thisstaff;
 
-        parent::FPDF('P', 'mm', $thisstaff->getDefaultPaperSize());
+
+        parent::FPDF('P', 'mm', $psize);
 
         $this->ticket = $ticket;
 
@@ -184,7 +184,7 @@ class Ticket2PDF extends FPDF
                         'R'=>array(255, 224, 179),
                         'N'=>array(250, 250, 210));
         //Get ticket thread
-        if(($entries = $ticket->getThreadWithNotes())) { 
+        if(($entries = $ticket->getThread(($this->includenotes)))) { 
             foreach($entries as $entry) {
 
                 $color = $colors[$entry['thread_type']];
diff --git a/setup/inc/class.setup.php b/include/class.setup.php
similarity index 92%
rename from setup/inc/class.setup.php
rename to include/class.setup.php
index 438eca54505302a30d6da9575067c90b296369dc..e566f2bf019ae55e913c0b1d460cb9389be1c0ac 100644
--- a/setup/inc/class.setup.php
+++ b/include/class.setup.php
@@ -21,14 +21,17 @@ Class SetupWizard {
                         'mysql' => '4.4');
 
     //Version info - same as the latest version.
-    var $version ='1.7-dpr3';
-    var $version_verbose='1.7 DPR 3';
+    
+    var $version =THIS_VERSION;
+    var $version_verbose = THIS_VERSION;
 
     //Errors
     var $errors=array();
 
     function SetupWizard(){
         $this->errors=array();
+        $this->version_verbose = ('osTicket v'. strtoupper(THIS_VERSION));
+
     }
 
     function load_sql_file($file, $prefix, $abort=true, $debug=false) {
@@ -55,6 +58,7 @@ Class SetupWizard {
 
         @mysql_query('SET SESSION SQL_MODE =""');
         foreach($statements as $k=>$sql) {
+            //Note that we're not using db_query - because we want to control how errors are reported.
             if(mysql_query($sql)) continue;
             $error = "[$sql] ".mysql_error();
             if($abort)
diff --git a/include/class.staff.php b/include/class.staff.php
index 2f5726d012d3e6f59e7b23faee48a54023766960..b95329fa69c3191c69fdc65006785fc420ff2ed0 100644
--- a/include/class.staff.php
+++ b/include/class.staff.php
@@ -13,6 +13,7 @@
 
     vim: expandtab sw=4 ts=4 sts=4:
 **********************************************************************/
+include_once(INCLUDE_DIR.'class.ticket.php');
 include_once(INCLUDE_DIR.'class.dept.php');
 include_once(INCLUDE_DIR.'class.team.php');
 include_once(INCLUDE_DIR.'class.group.php');
@@ -25,6 +26,7 @@ class Staff {
 
     var $dept;
     var $teams;
+    var $timezone;
     var $stats;
     
     function Staff($var) {
@@ -37,13 +39,11 @@ class Staff {
         if(!$var && !($var=$this->getId()))
             return false;
 
-        $sql='SELECT staff.*, grp.*, tz.offset as tz_offset '
-            .' ,TIME_TO_SEC(TIMEDIFF(NOW(),IFNULL(staff.passwdreset,staff.created))) as passwd_change_sec '
+        $sql='SELECT staff.*, staff.created as added, grp.* '
             .' FROM '.STAFF_TABLE.' staff '
-            .' LEFT JOIN '.GROUP_TABLE.' grp ON(grp.group_id=staff.group_id) '
-            .' LEFT JOIN '.TIMEZONE_TABLE.' tz ON(tz.id=staff.timezone_id) ';
+            .' LEFT JOIN '.GROUP_TABLE.' grp ON(grp.group_id=staff.group_id) ';
 
-        $sql.=sprintf('WHERE %s=%s',is_numeric($var)?'staff_id':'username',db_input($var));
+        $sql.=sprintf(' WHERE %s=%s',is_numeric($var)?'staff_id':'username',db_input($var));
 
         if(!($res=db_query($sql)) || !db_num_rows($res))
             return NULL;
@@ -51,11 +51,18 @@ class Staff {
         
         $this->ht=db_fetch_array($res);
         $this->id  = $this->ht['staff_id'];
-        $this->teams =$this->ht['teams']=$this->getTeams();
-
-        $this->teams=array();
+        $this->teams = $this->ht['teams']= array();
         $this->stats=array();
 
+        //WE have to patch info here to support upgrading from old versions.
+        if(($time=strtotime($this->ht['passwdreset']?$this->ht['passwdreset']:$this->ht['added'])))
+            $this->ht['passwd_change'] = time()-$time; //XXX: check timezone issues.
+
+        if($this->ht['timezone_id'])
+            $this->ht['tz_offset'] = Timezone::getOffsetById($this->ht['timezone_id']);
+        elseif($this->ht['timezone_offset'])
+            $this->ht['tz_offset'] = $this->ht['timezone_offset'];
+
         return ($this->id);
     }
 
@@ -96,7 +103,7 @@ class Staff {
     function isPasswdResetDue() {
         global $cfg;
         return ($cfg && $cfg->getPasswdResetPeriod() 
-                    && $this->ht['passwd_change_sec']>($cfg->getPasswdResetPeriod()*30*24*60*60));
+                    && $this->ht['passwd_change']>($cfg->getPasswdResetPeriod()*30*24*60*60));
     }
 
     function isPasswdChangeDue() {
@@ -169,7 +176,7 @@ class Staff {
 
     function getDepts() {
         //Departments the user is allowed to access...based on the group they belong to + user's dept.
-        return array_filter(array_unique(array_merge(explode(',', $this->ht['dept_access']), array($this->dept_id)))); //Neptune help us
+        return array_filter(array_unique(array_merge(explode(',', $this->ht['dept_access']), array($this->getDeptId())))); //Neptune help us
     }
 
     function getDepartments() {
@@ -582,7 +589,7 @@ class Staff {
         if(!$vars['lastname'])
             $errors['lastname']='Last name required';
             
-        if(!$vars['username'] || strlen($vars['username'])<3)
+        if(!$vars['username'] || strlen($vars['username'])<2)
             $errors['username']='Username required';
         elseif(($uid=Staff::getIdByUsername($vars['username'])) && $uid!=$id)
             $errors['username']='Username already in-use';
diff --git a/include/class.team.php b/include/class.team.php
index 1f663880de038a1364e7fc4a1473c9a12226e8ca..cdf4cffcd3148fab082b2dd69f24733481aaeca0 100644
--- a/include/class.team.php
+++ b/include/class.team.php
@@ -80,6 +80,13 @@ class Team {
         return $this->members;
     }
 
+    function hasMember($staff) {
+        return db_count(
+             'SELECT COUNT(*) FROM '.TEAM_MEMBER_TABLE
+            .' WHERE team_id='.db_input($this->getId())
+            .'   AND staff_id='.db_input($staff->getId())) !== 0;
+    }
+
     function getLeadId(){
         return $this->ht['lead_id'];
     }
diff --git a/include/class.ticket.php b/include/class.ticket.php
index 6b933239de4bcc181f82a2b88724789e3cc5454c..7e53ec51bd10247932fbd6e416e4afed1939deee 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -1552,10 +1552,12 @@ class Ticket{
     }
 
     //Print ticket... export the ticket thread as PDF.
-    function pdfExport() {
-        $pdf = new Ticket2PDF($this, true);
+    function pdfExport($psize='Letter', $notes=false) {
+        $pdf = new Ticket2PDF($this, $psize, $notes);
         $name='Ticket-'.$this->getExtId().'.pdf';
         $pdf->Output($name, 'I');
+        //Remember what the user selected - for autoselect on the next print.
+        $_SESSION['PAPER_SIZE'] = $psize;
         exit;
     }
 
@@ -1751,7 +1753,7 @@ class Ticket{
         global $cfg;
         
         /* Unknown or invalid staff */
-        if(!$staff || (!is_object($staff) && !($staff=Staff::lookup($staff))) || !$staff->isStaff())
+        if(!$staff || (!is_object($staff) && !($staff=Staff::lookup($staff))) || !$staff->isStaff() || $cfg->getDBVersion())
             return null;
 
 
@@ -1773,12 +1775,11 @@ class Ticket{
         if(($teams=$staff->getTeams()))
             $sql.=' OR ticket.team_id IN('.implode(',', array_filter($teams)).')';
 
-        if(!$staff->showAssignedOnly()) //Staff with limited access just see Assigned tickets.
-            $sql.=' OR ticket.dept_id IN('.implode(',',$staff->getDepts()).') ';
+        if(!$staff->showAssignedOnly() && ($depts=$staff->getDepts())) //Staff with limited access just see Assigned tickets.
+            $sql.=' OR ticket.dept_id IN('.implode(',', $depts).') ';
 
         $sql.=')';
 
-
         if(!$cfg || !($cfg->showAssignedTickets() || $staff->showAssignedTickets()))
             $sql.=' AND (ticket.staff_id=0 OR ticket.staff_id='.db_input($staff->getId()).') ';
 
@@ -2004,10 +2005,28 @@ class Ticket{
             $autorespond=false;
         }
 
+        // If a canned-response is immediately queued for this ticket,
+        // disable the autoresponse
+        if ($vars['cannedResponseId'])
+            $autorespond=false;
+
         /***** See if we need to send some alerts ****/
 
         $ticket->onNewTicket($vars['message'], $autorespond, $alertstaff);
 
+        if ($vars['cannedResponseId']
+                && ($canned = Canned::lookup($vars['cannedResponseId']))) {
+            $files = array();
+            foreach ($canned->getAttachments() as $file)
+                $files[] = $file['id'];
+            $ticket->postReply(array(
+                    'msgId'     => $msgid,
+                    'response'  =>
+                        $ticket->replaceTemplateVars($canned->getResponse()),
+                    'cannedattachments' => $files
+                ), null, $errors, true);
+        }
+
         /************ check if the user JUST reached the max. open tickets limit **********/
         if($cfg->getMaxOpenTickets()>0
                     && ($client=$ticket->getClient())
diff --git a/include/class.timezone.php b/include/class.timezone.php
new file mode 100644
index 0000000000000000000000000000000000000000..cdff816345a2048b667b1385cdd73df35c500862
--- /dev/null
+++ b/include/class.timezone.php
@@ -0,0 +1,71 @@
+<?php
+/*********************************************************************
+    class.timezone.php
+
+    Time zone get utils.
+
+    Peter Rotich <peter@osticket.com>
+    Copyright (c)  2006-2012 osTicket
+    http://www.osticket.com
+
+    Released under the GNU General Public License WITHOUT ANY WARRANTY.
+    See LICENSE.TXT for details.
+
+    vim: expandtab sw=4 ts=4 sts=4:
+**********************************************************************/
+
+class Timezone {
+
+    var $id;
+    var $ht;
+
+    function Timezone($id){
+        $this->id=0;
+        return $this->load($id);
+    }
+
+    function load($id=0) {
+
+        if(!$id && !($id=$this->getId()))
+            return false;
+
+        $sql='SELECT * FROM '.TIMEZONE_TABLE.' WHERE id='.db_input($id);
+        if(!($res=db_query($sql)) || !db_num_rows($res))
+            return false;
+
+        $this->ht=db_fetch_array($res);
+        $this->id=$this->ht['id'];
+        
+        return $this->id;
+    }
+
+    function reload() {
+        return $this->load();
+    }
+
+    function getId() { 
+        return $this->id;
+    }
+        
+    function getOffset() {
+        return $this->ht['offset'];    
+    }
+
+    function getName() {
+        return $this->info['timezone'];
+    }
+
+    function getDesc() {
+        return $this->getName();
+    }
+
+    /* static functions */
+    function lookup($id) {
+        return ($id && is_numeric($id) && ($tz= new Timezone($id)) && $tz->getId()==$id)?$tz:null;
+    }
+
+    function getOffsetById($id) {
+        return ($tz=Timezone::lookup($id))?$tz->getOffset():0;
+    }
+}
+?>
diff --git a/setup/inc/class.upgrader.php b/include/class.upgrader.php
similarity index 62%
rename from setup/inc/class.upgrader.php
rename to include/class.upgrader.php
index 891d472d9264a78501bac8ec6d7a4d28abf8553c..4487e53b26844c8094b72406c5f739cb67702bf3 100644
--- a/setup/inc/class.upgrader.php
+++ b/include/class.upgrader.php
@@ -14,8 +14,8 @@
     vim: expandtab sw=4 ts=4 sts=4:
 **********************************************************************/
 
-require_once INC_DIR.'class.setup.php';
-require_once INC_DIR.'class.migrater.php';
+require_once INCLUDE_DIR.'class.setup.php';
+require_once INCLUDE_DIR.'class.migrater.php';
 
 class Upgrader extends SetupWizard {
 
@@ -31,8 +31,12 @@ class Upgrader extends SetupWizard {
         $this->sqldir = $sqldir;
         $this->errors = array();
 
+        //Disable time limit if - safe mode is set.
+        if(!ini_get('safe_mode'))
+            set_time_limit(0);
+
         //Init persistent state of upgrade.
-        $this->state = &$_SESSION['ost_upgrader'][$this->getShash()]['state'];
+        $this->state = &$_SESSION['ost_upgrader']['state'];
 
         //Init the task Manager.
         if(!isset($_SESSION['ost_upgrader'][$this->getShash()]))
@@ -45,16 +49,29 @@ class Upgrader extends SetupWizard {
         $this->migrater = new DatabaseMigrater($this->signature, SCHEMA_SIGNATURE, $this->sqldir);
     }
 
-    function getStops() {
-        return array('7be60a84' => 'migrateAttachments2DB');
-    }
-
     function onError($error) {
-        global $ost;
+        global $ost, $thisstaff;
 
         $ost->logError('Upgrader Error', $error);
         $this->setError($error);
         $this->setState('aborted');
+
+        //Alert staff upgrading the system - if the email is not same as admin's
+        // admin gets alerted on error log (above)
+        if(!$thisstaff || !strcasecmp($thisstaff->getEmail(), $ost->getConfig()->getAdminEmail()))
+            return;
+
+        $email=null;
+        if(!($email=$ost->getConfig()->getAlertEmail()))
+            $email=$ost->getConfig()->getDefaultEmail(); //will take the default email.
+
+        $subject = 'Upgrader Error';
+        if($email) {
+            $email->send($thistaff->getEmail(), $subject, $error);
+        } else {//no luck - try the system mail.
+            Email::sendmail($thistaff->getEmail(), $subject, $error, sprintf('"osTicket Alerts"<%s>', $thistaff->getEmail()));
+        }
+
     }
 
     function isUpgradable() {
@@ -177,10 +194,14 @@ class Upgrader extends SetupWizard {
 
     function doTasks() {
 
+        global $ost;
         if(!($tasks=$this->getPendingTasks()))
             return true; //Nothing to do.
 
+        $ost->logDebug('Upgrader', sprintf('There are %d pending upgrade tasks', count($tasks)));
+        $start_time = Misc::micro_time();
         foreach($tasks as $k => $task) {
+            //TODO: check time used vs. max execution - break if need be
             if(call_user_func(array($this, $task['func']), $k)===0) {
                 $this->tasks[$k]['done'] = true;
             } else { //Task has pending items to process.
@@ -188,7 +209,7 @@ class Upgrader extends SetupWizard {
             }
         }
 
-        return (!$this->getPendingTasks());
+        return $this->getPendingTasks();
     }
     
     function upgrade() {
@@ -197,7 +218,12 @@ class Upgrader extends SetupWizard {
         if($this->getPendingTasks() || !($patches=$this->getPatches()))
             return false;
 
+        $start_time = Misc::micro_time();
+        if(!($max_time = ini_get('max_execution_time')))
+            $max_time = 300; //Apache/IIS defaults.
+
         foreach ($patches as $patch) {
+            //TODO: check time used vs. max execution - break if need be
             if (!$this->load_sql_file($patch, $this->getTablePrefix()))
                 return false;
 
@@ -214,14 +240,24 @@ class Upgrader extends SetupWizard {
             $ost->logDebug('Upgrader - Patch applied', $logMsg);
             
             //Check if the said patch has scripted tasks
-            if(!($tasks=$this->getTasksForPatch($phash)))
+            if(!($tasks=$this->getTasksForPatch($phash))) {
+                //Break IF elapsed time is greater than 80% max time allowed.
+                if(($elapsedtime=(Misc::micro_time()-$start_time)) && $max_time && $elapsedtime>($max_time*0.80))
+                    break;
+
                 continue;
 
+            }
+
             //We have work to do... set the tasks and break.
             $shash = substr($phash, 9, 8);
             $_SESSION['ost_upgrader'][$shash]['tasks'] = $tasks;
             $_SESSION['ost_upgrader'][$shash]['state'] = 'upgrade';
+            
+            $ost->logDebug('Upgrader', sprintf('Found %d tasks to be executed for %s',
+                            count($tasks), $shash));
             break;
+
         }
 
         return true;
@@ -232,25 +268,35 @@ class Upgrader extends SetupWizard {
 
         $tasks=array();
         switch($phash) { //Add  patch specific scripted tasks.
-            case 'd4fe13b1-7be60a84': //V1.6 ST- 1.7 *
+            case 'c00511c7-7be60a84': //V1.6 ST- 1.7 * {{MD5('1.6 ST') -> c00511c7c1db65c0cfad04b4842afc57}}
                 $tasks[] = array('func' => 'migrateAttachments2DB',
                                  'desc' => 'Migrating attachments to database, it might take a while depending on the number of files.');
+                $tasks[] = array('func' => 'migrateSessionFile2DB',
+                                 'desc' => 'Transitioning to db-backed sessions');
+                break;
+            case '98ae1ed2-e342f869': //v1.6 RC1-4 -> v1.6 RC5
+                $task[] = array('func' => 'migrateAPIKeys',
+                                'desc' => 'Migrating API keys to a new table');
                 break;
         }
 
-        //Check if cleanup p 
+        //Check IF SQL cleanup is exists. 
         $file=$this->getSQLDir().$phash.'.cleanup.sql';
         if(file_exists($file)) 
-            $tasks[] = array('func' => 'cleanup', 'desc' => 'Post-upgrade cleanup!');
+            $tasks[] = array('func' => 'cleanup', 'desc' => 'Post-upgrade cleanup!',
+                        'phash' => $phash);
 
 
         return $tasks;
     }
 
     /************* TASKS **********************/
-    function cleanup($tId=0) {
+    function cleanup($taskId) {
+        global $ost;
+
+        $phash = $this->tasks[$taskId]['phash'];
+        $file=$this->getSQLDir().$phash.'.cleanup.sql';
 
-        $file=$this->getSQLDir().$this->getShash().'-cleanup.sql';
         if(!file_exists($file)) //No cleanup script.
             return 0;
 
@@ -258,17 +304,46 @@ class Upgrader extends SetupWizard {
         if($this->load_sql_file($file, $this->getTablePrefix(), false, true))
             return 0;
 
-        //XXX: ???
-        return false;
+        $ost->logDebug('Upgrader', sprintf("%s: Unable to process cleanup file",
+                        $phash));
+        return 0;
     }
-    
 
-    function migrateAttachments2DB($tId=0) {
-        echo "Process attachments here - $tId";
+    function migrateAttachments2DB($taskId) {
+        global $ost;
+        
+        if(!($max_time = ini_get('max_execution_time')))
+            $max_time = 30; //Default to 30 sec batches.
+
         $att_migrater = new AttachmentMigrater();
-        $att_migrater->start_migration();
-        # XXX: Loop here (with help of task manager)
-        $att_migrater->do_batch();
+        if($att_migrater->do_batch(($max_time*0.9), 100)===0)
+            return 0;
+
+        return $att_migrater->getQueueLength();
+    }
+
+    function migrateSessionFile2DB($taskId) {
+        # How about 'dis for a hack?
+        osTicketSession::write(session_id(), session_encode()); 
+        return 0;
+    }
+
+    function migrateAPIKeys($taskId) {
+
+        $res = db_query('SELECT api_whitelist, api_key FROM '.CONFIG_TABLE.' WHERE id=1');
+        if(!$res || !db_num_rows($res))
+            return 0;  //Reporting success.
+
+        list($whitelist, $key) = db_fetch_row($res);
+
+        $ips=array_filter(explode(',', ereg_replace(' ', '', $whitelist)));
+        foreach($ips as $ip) {
+            $sql='INSERT INTO '.API_KEY_TABLE.' SET created=NOW(), updated=NOW(), isactive=1 '
+                .',ipaddr='.db_input($ip)
+                .',apikey='.db_input(strtoupper(md5($ip.md5($key))));
+            db_query($sql);
+        }
+
         return 0;
     }
 }
diff --git a/include/class.validator.php b/include/class.validator.php
index d41bf027fe826c855893146dfee680c578598feb..addbfac4df3be2333c986ea26e76cac5b43e5dce 100644
--- a/include/class.validator.php
+++ b/include/class.validator.php
@@ -109,8 +109,8 @@ class Validator {
                     $this->errors[$k]=$field['error'].' (5 chars min)';
                 break;
             case 'username':
-                if(strlen($this->input[$k])<3)
-                    $this->errors[$k]=$field['error'].' (3 chars min)';
+                if(strlen($this->input[$k])<2)
+                    $this->errors[$k]=$field['error'].' (2 chars min)';
                 break;
             case 'zipcode':
                 if(!is_numeric($this->input[$k]) || (strlen($this->input[$k])!=5))
@@ -172,10 +172,15 @@ class Validator {
             return false;
       
         $ip=trim($ip);
-        if(preg_match("/^[0-9]{1,3}(.[0-9]{1,3}){3}$/",$ip)) {
-            foreach(explode(".", $ip) as $block)
-                if($block<0 || $block>255 )
-                    return false;
+        # Thanks to http://stackoverflow.com/a/1934546
+        if (function_exists('inet_pton')) { # PHP 5.1.0
+            # Let the built-in library parse the IP address
+            return @inet_pton($ip) !== false;
+        } else if (preg_match(
+            '/^(?>(?>([a-f0-9]{1,4})(?>:(?1)){7}|(?!(?:.*[a-f0-9](?>:|$)){7,})'
+            .'((?1)(?>:(?1)){0,5})?::(?2)?)|(?>(?>(?1)(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){5,})'
+            .'(?3)?::(?>((?1)(?>:(?1)){0,3}):)?)?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])'
+            .'(?>\.(?4)){3}))$/iD', $ip)) {
             return true;
         }
         return false;
diff --git a/include/mysql.php b/include/mysql.php
index 71ea2f073cbcd054853fb6a8f26eacd8d78bd3ea..06489242a71d78d7e8fae590ed8960ddfa74dee8 100644
--- a/include/mysql.php
+++ b/include/mysql.php
@@ -88,9 +88,9 @@
    	    }
                 
         if(!$result && $ost) { //error reporting
-            $alert='['.$query.']'."\n\n".db_error();
-            $ost->logError('DB Error #'.db_errno(), $alert, ($ost->alertONSQLError()));
-            //echo $alert; #uncomment during debuging or dev.
+            $msg='['.$query.']'."\n\n".db_error();
+            $ost->logDBError('DB Error #'.db_errno(), $msg);
+            //echo $msg; #uncomment during debuging or dev.
         }
 
         return $result;
diff --git a/include/staff/filter.inc.php b/include/staff/filter.inc.php
index 22622e6c8db8786b12ad20bb167c8e9e1980c302..89ca2c41ffc3b02945bdb4619391ea815cf13821 100644
--- a/include/staff/filter.inc.php
+++ b/include/staff/filter.inc.php
@@ -182,6 +182,29 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
                     <strong>Disable</strong> auto-response. <em>(Overwrites Dept. settings)</em>
             </td>
         </tr>
+        <tr>
+            <td width="180">
+                Canned Response:
+            </td>
+                <td>
+                <select name="canned_response">
+                    <option value="">&mdash; None &mdash;</option>
+                    <?php
+                    $sql='SELECT canned_id,title FROM '.CANNED_TABLE.' ORDER by title';
+                    if ($res=db_query($sql)) {
+                        while (list($id,$title)=db_fetch_row($res)) {
+                            $selected=($info['canned_response'] &&
+                                    $id==$info['canned_response'])
+                                ? 'selected="selected"' : '';
+                            echo sprintf('<option value="%d" %s>%s</option>',
+                                $id, $selected, $title);
+                        }
+                    }
+                    ?>
+                </select>
+                <em>(Automatically respond with this canned attachment)</em>
+            </td>
+        </tr>
         <tr>
             <td width="180">
                 Department:
diff --git a/include/staff/footer.inc.php b/include/staff/footer.inc.php
index 2591a55af87caf67b56208c27e7c9ceab678b6cc..d789c14474ef63caf5c06f61d60cdfb6df881bcc 100644
--- a/include/staff/footer.inc.php
+++ b/include/staff/footer.inc.php
@@ -12,5 +12,6 @@ if(is_object($thisstaff) && $thisstaff->isStaff()) { ?>
 <?php
 } ?>
 </div>
+<div id="overlay"></div>
 </body>
 </html>
diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php
index f5bbd6102567be3fa5becde4392cf34c23187007..2e3b647fc835f0931689a3ed8cb24c754fe01b03 100644
--- a/include/staff/header.inc.php
+++ b/include/staff/header.inc.php
@@ -2,6 +2,8 @@
 <html>
 <head>
     <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+    <meta http-equiv="cache-control" content="no-cache" />
+    <meta http-equiv="pragma" content="no-cache" />
     <title>osTicket Staff Control Panel</title>
     <!--[if IE]>
     <style type="text/css">
@@ -24,7 +26,7 @@
     csrf_enable_ajax();
     ?>
 </head>
-<body>
+<body onunload="">
 <div id="container">
     <div id="header">
         <a href="index.php" id="logo">osTicket - Customer Support System</a>
diff --git a/include/staff/syslogs.inc.php b/include/staff/syslogs.inc.php
index 944652a8547fda240e9d05d28f5d752c5ec16266..ead5cf544932569261cecf166bfa0f152d309a76 100644
--- a/include/staff/syslogs.inc.php
+++ b/include/staff/syslogs.inc.php
@@ -73,7 +73,7 @@ $total=db_count("SELECT count(*) $qfrom $qwhere");
 $page = ($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1;
 //pagenate
 $pageNav=new Pagenate($total, $page, PAGE_LIMIT);
-$pageNav->setURL('syslogs.php',$qstr);
+$pageNav->setURL('logs.php',$qstr);
 $qstr.='&order='.($order=='DESC'?'ASC':'DESC');
 $query="$qselect $qfrom $qwhere ORDER BY $order_by LIMIT ".$pageNav->getStart().",".$pageNav->getLimit();
 $res=db_query($query);
@@ -85,7 +85,7 @@ else
 
 <h2>System Logs</h2>
 <div id='filter' >
- <form action="syslogs.php" method="get">
+ <form action="logs.php" method="get">
     <div style="padding-left:2px;">
         <b>Date Span</b>:
         &nbsp;From&nbsp;<input class="dp" id="sd" size=15 name="startDate" value="<?php echo Format::htmlchars($_REQUEST['startDate']); ?>" autocomplete=OFF>
@@ -104,18 +104,18 @@ else
     </div>
  </form>
 </div>
-<form action="syslogs.php" method="POST" name="logs" onSubmit="return checkbox_checker(this,1,0);">
- <?php csrf_token(); ?>
+<form action="logs.php" method="POST" name="logs" onSubmit="return checkbox_checker(this,1,0);">
+<?php csrf_token(); ?>
  <input type="hidden" name="do" value="mass_process" >
  <table class="list" border="0" cellspacing="1" cellpadding="0" width="940">
     <caption><?php echo $showing; ?></caption>
     <thead>
         <tr>
             <th width="7">&nbsp;</th>        
-            <th width="320"><a <?php echo $title_sort; ?> href="syslogs.php?<?php echo $qstr; ?>&sort=title">Log Title</a></th>
-            <th width="100"><a  <?php echo $type_sort; ?> href="syslogs.php?<?php echo $qstr; ?>&sort=type">Log Type</a></th>
-            <th width="200" nowrap><a  <?php echo $date_sort; ?>href="syslogs.php?<?php echo $qstr; ?>&sort=date">Log Date</a></th>
-            <th width="120"><a  <?php echo $ip_sort; ?> href="syslogs.php?<?php echo $qstr; ?>&sort=ip">IP Address</a></th>
+            <th width="320"><a <?php echo $title_sort; ?> href="logs.php?<?php echo $qstr; ?>&sort=title">Log Title</a></th>
+            <th width="100"><a  <?php echo $type_sort; ?> href="logs.php?<?php echo $qstr; ?>&sort=type">Log Type</a></th>
+            <th width="200" nowrap><a  <?php echo $date_sort; ?>href="logs.php?<?php echo $qstr; ?>&sort=date">Log Date</a></th>
+            <th width="120"><a  <?php echo $ip_sort; ?> href="logs.php?<?php echo $qstr; ?>&sort=ip">IP Address</a></th>
         </tr>
     </thead>
     <tbody>
diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php
index feb98294bbf36259369567dad47aa79777e36ac2..94f2cac6df1c0769d6f4f6a10d2dc25e7faee1ff 100644
--- a/include/staff/ticket-view.inc.php
+++ b/include/staff/ticket-view.inc.php
@@ -20,7 +20,10 @@ $lock  = $ticket->getLock();  //Ticket lock obj
 $id    = $ticket->getId();    //Ticket ID.
 
 //Useful warnings and errors the user might want to know!
-if($ticket->isAssigned() && $staff->getId()!=$thisstaff->getId())
+if($ticket->isAssigned() && (
+            ($staff && $staff->getId()!=$thisstaff->getId())
+         || ($team && !$team->hasMember($thisstaff))
+        ))
     $warn.='&nbsp;&nbsp;<span class="Icon assignedTicket">Ticket is assigned to '.implode('/', $ticket->getAssignees()).'</span>';
 if(!$errors['err'] && ($lock && $lock->getStaffId()!=$thisstaff->getId()))
     $errors['err']='This ticket is currently locked by '.$lock->getStaffName();
@@ -40,8 +43,12 @@ if($ticket->isOverdue())
                 <a href="tickets.php?id=<?php echo $ticket->getId(); ?>" title="Reload" class="reload">Reload</a></h2>
         </td>
         <td width="50%" class="right_align">
-            <a href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=print" title="Print Ticket" class="print">Print Ticket</a>
-            <a href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=edit" title="Edit Ticket" class="edit">Edit Ticket</a>
+            <a href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=print" title="Print Ticket" class="print" id="ticket-print">Print Ticket</a>
+            <?php
+            if($thisstaff->canEditTickets()) { ?>
+             <a href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=edit" title="Edit Ticket" class="edit">Edit Ticket</a>
+            <?php
+            } ?>
         </td>
     </tr>
 </table>
@@ -236,12 +243,13 @@ if(!$cfg->showNotesInline()) { ?>
             <tr>
                 <th width="200"><?php echo Format::db_datetime($entry['created']);?></th>
                 <th width="440"><span><?php echo Format::htmlchars($entry['title']); ?></span></th>
-                <th width="300" class="tmeta"><?php echo Format::htmlchars($entry['poster']); ?></th></tr>
-            <tr><td colspan=2><?php echo Format::display($entry['body']); ?></td></tr>
+                <th width="300" class="tmeta"><?php echo Format::htmlchars($entry['poster']); ?></th>
+            </tr>
+            <tr><td colspan=3><?php echo Format::display($entry['body']); ?></td></tr>
             <?php
             if($entry['attachments'] && ($links=$ticket->getAttachmentsLinks($entry['id'], $entry['thread_type']))) {?>
             <tr>
-                <td class="info" colspan=2><?php echo $links; ?></td>
+                <td class="info" colspan=3><?php echo $links; ?></td>
             </tr>
             <?php
             }?>
@@ -601,4 +609,41 @@ if(!$cfg->showNotesInline()) { ?>
     <?php
     } ?>
 </div>
+<div style="display:none;" id="print-options">
+    <h3>Ticket Print Options</h3>
+    <a class="close" href="">&times;</a>
+    <hr/>
+    <form action="tickets.php?id=<?php echo $ticket->getId(); ?>" method="post" id="print-form" name="print-form">
+        <input type="hidden" name="a" value="print">
+        <input type="hidden" name="id" value="<?php echo $ticket->getId(); ?>">
+        <fieldset class="notes">
+            <label for="notes">Print Notes:</label>
+            <input type="checkbox" id="notes" name="notes" value="1"> Print <b>Internal</b> Notes/Comments
+        </fieldset>
+        <fieldset>
+            <label for="psize">Paper Size:</label>
+            <select id="psize" name="psize">
+                <option value="">&mdash; Select Print Paper Size &mdash;</option>
+                <?php
+                  $options=array('Letter', 'Legal', 'A4', 'A3');
+                  $psize =$_SESSION['PAPER_SIZE']?$_SESSION['PAPER_SIZE']:$thisstaff->getDefaultPaperSize();
+                  foreach($options as $v) {
+                      echo sprintf('<option value="%s" %s>%s</option>',
+                                $v,($psize==$v)?'selected="selected"':'', $v);
+                  }
+                ?>
+            </select>
+        </fieldset>
+        <hr style="margin-top:3em"/>
+        <p class="full-width">
+            <span class="buttons" style="float:left">
+                <input type="reset" value="Reset">
+                <input type="button" value="Cancel" class="close">
+            </span>
+            <span class="buttons" style="float:right">
+                <input type="submit" value="Print">
+            </span>
+         </p>
+    </form>
+</div>
 <script type="text/javascript" src="js/ticket.js"></script>
diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php
index 2c01180495fb73096c9d09555e848177697768c6..63f2fb31c4a871f60ca13d3fff0f66e5a2c11ae9 100644
--- a/include/staff/tickets.inc.php
+++ b/include/staff/tickets.inc.php
@@ -467,7 +467,7 @@ $negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting..
     } ?>
     </form>
 </div>
-<div id="overlay"></div>
+<div id="search_overlay"></div>
 <div style="display:none;" id="advanced-search">
     <h3>Advanced Ticket Search</h3>
     <a class="close" href="">&times;</a>
diff --git a/setup/inc/upgrade-aborted.inc.php b/include/upgrader/aborted.inc.php
similarity index 66%
rename from setup/inc/upgrade-aborted.inc.php
rename to include/upgrader/aborted.inc.php
index 8624590d35710a42906952afab82b2688f028315..44e065b14f87ede8644f284ff1a923e08963f4e1 100644
--- a/setup/inc/upgrade-aborted.inc.php
+++ b/include/upgrader/aborted.inc.php
@@ -1,10 +1,12 @@
 <?php
-if(!defined('SETUPINC')) die('Kwaheri!');
+if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 ?>    
-<div id="main">
+<div id="upgrader">
+   <div id="main">
     <h1 style="color:#FF7700;">Upgrade Aborted!</h1>
     <div id="intro">
-        <p>Upgrade aborted due to errors. Any errors at this stage are fatal. Please note the error(s), if any, when contacting us.<p>
+        <p><strong>Upgrade aborted due to errors. Any errors at this stage are fatal.</strong></p>
+        <p>Please note the error(s), if any, when <a target="_blank" href="http://osticket.com/support/">seeking help</a>.<p>
         <?php
         if($upgrader && ($errors=$upgrader->getErrors())) {
             if($errors['err'])
@@ -18,11 +20,15 @@ if(!defined('SETUPINC')) die('Kwaheri!');
             echo '<b><font color="red">Internal error occurred - get technical help.</font></b>';
         }
         ?>
+        <p><b>For detailed - please view <a href="logs.php">system logs</a> or check your email.</b></p>
+        <br>
         <p>Please, refer to the <a target="_blank" href="http://osticket.com/wiki/Upgrade_and_Migration">Upgrade Guide</a> on the wiki for more information.</p>
     </div>
-    <p><strong>Need Help?</strong> We provide <a target="_blank" href="http://osticket.com/support/professional_services.php"><u>professional upgrade services</u></a> and commercial support. <a target="_blank" href="http://osticket.com/support/">Contact us</a> today for expedited help.</p>
-</div>    
-<div id="sidebar">
+    <p><strong>Need Help?</strong> We provide <a target="_blank" href="http://osticket.com/support/professional_services.php"><u>professional upgrade services</u></a> and commercial support. <a target="_blank" href="http://osticket.com/support/">Contact us</a> today for <u>expedited</u> help.</p>
+  </div>    
+  <div id="sidebar">
     <h3>What to do?</h3>
-    <p>Restore your previous version from backup and try again or <a target="_blank" href="http://osticket.com/support/">seek help</a>.</p>    
+    <p>Restore your previous version from backup and try again or <a target="_blank" href="http://osticket.com/support/">seek help</a>.</p>
+  </div>
+  <div class="clear"></div>
 </div>
diff --git a/include/upgrader/done.inc.php b/include/upgrader/done.inc.php
new file mode 100644
index 0000000000000000000000000000000000000000..ddd5cab75e09b7d5c654b41284860038d5d6387b
--- /dev/null
+++ b/include/upgrader/done.inc.php
@@ -0,0 +1,27 @@
+<?php
+if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
+?> 
+<div id="upgrader">
+    <div id="main">
+        <h1 style="color:green;">Upgrade Completed!</h1>
+        <div id="intro">
+        <p>Congratulations osTicket upgrade has been completed successfully.</p>
+        <p>Please refer to <a href="http://osticket.com/wiki/Release_Notes" target="_blank">Release Notes</a> for more information about changes and/or new features.</p>
+        </div>
+        <p>Once again, thank you for choosing osTicket.</p>
+        <p>Please feel free to <a target="_blank" href="http://osticket.com/support/">let us know</a> of any other improvements and features you would like to see in osTicket, so that we may add them in the future as we continue to develop better and better versions of osTicket.</p>
+        <p>We take user feedback seriously and we're dedicated to making changes based on your input.</p>
+        <p>Good luck.<p>
+        <p>osTicket Team.</p>
+        <br>
+        <p><b>PS</b>: Don't just make customers happy, make happy customers!</p>
+    </div>
+    <div id="sidebar">
+            <h3>What's Next?</h3>
+            <p><b>Post-upgrade</b>: You can now go to <a href="scp/settings.php" target="_blank">Admin Panel</a> to enable the system and explore the new features. For complete and upto date release notes see <a href="http://osticket.com/wiki/Release_Notes" target="_blank">osTicket wiki</a></p>
+            <p><b>Stay up to date</b>: It's important to keep your osTicket installation up to date. Get announcements, security updates and alerts delivered directly to you! 
+            <a target="_blank" href="http://osticket.com/support/subscribe.php">Get in the loop</a> today and stay informed!</p>
+            <p><b>Commercial support available</b>: Get guidance and hands-on expertise to address unique challenges and make sure your osTicket runs smoothly, efficiently, and securely. <a target="_blank" href="http://osticket.com/support/commercial_support.php.php">Learn More!</a></p>
+   </div>
+   <div class="clear"></div>
+</div>
diff --git a/setup/inc/sql/02decaa2-60fcbee1.patch.sql b/include/upgrader/patches/02decaa2-60fcbee1.patch.sql
similarity index 100%
rename from setup/inc/sql/02decaa2-60fcbee1.patch.sql
rename to include/upgrader/patches/02decaa2-60fcbee1.patch.sql
diff --git a/include/upgrader/patches/15af7cd3-98ae1ed2.patch.sql b/include/upgrader/patches/15af7cd3-98ae1ed2.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..775509266684bec3f34284603fbd69da87f407c2
--- /dev/null
+++ b/include/upgrader/patches/15af7cd3-98ae1ed2.patch.sql
@@ -0,0 +1,8 @@
+/*
+ * @version=1.6RC1-4
+ * 
+ * Stage RC2 for 1.6RC5 upgrade
+ */
+
+UPDATE `%TABLE_PREFIX%config`
+    SET `ostversion`='1.6 RC1-4';
diff --git a/include/upgrader/patches/2e20a0eb-98ae1ed2.patch.sql b/include/upgrader/patches/2e20a0eb-98ae1ed2.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..49d1e93623337eebc83463dbfe2c4686d518825e
--- /dev/null
+++ b/include/upgrader/patches/2e20a0eb-98ae1ed2.patch.sql
@@ -0,0 +1,8 @@
+/*
+ * @version=1.6RC1-4
+ * 
+ * Stage RC4 for 1.6RC5 upgrade
+ */
+
+UPDATE `%TABLE_PREFIX%config`
+    SET `ostversion`='1.6 RC1-4';
diff --git a/setup/inc/sql/49478749-c2d2fabf.patch.sql b/include/upgrader/patches/49478749-c2d2fabf.patch.sql
similarity index 100%
rename from setup/inc/sql/49478749-c2d2fabf.patch.sql
rename to include/upgrader/patches/49478749-c2d2fabf.patch.sql
diff --git a/setup/inc/sql/522e5b78-02decaa2.patch.sql b/include/upgrader/patches/522e5b78-02decaa2.patch.sql
similarity index 100%
rename from setup/inc/sql/522e5b78-02decaa2.patch.sql
rename to include/upgrader/patches/522e5b78-02decaa2.patch.sql
diff --git a/include/upgrader/patches/60fcbee1-f8856d56.patch.sql b/include/upgrader/patches/60fcbee1-f8856d56.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..624e88968ef3f673bea2f1a96d4b1733fbff9c8a
--- /dev/null
+++ b/include/upgrader/patches/60fcbee1-f8856d56.patch.sql
@@ -0,0 +1,61 @@
+DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket_event`;
+CREATE TABLE `%TABLE_PREFIX%ticket_event` (
+  `ticket_id` int(11) unsigned NOT NULL default '0',
+  `staff_id` int(11) unsigned NOT NULL,
+  `team_id` int(11) unsigned NOT NULL,
+  `dept_id` int(11) unsigned NOT NULL,
+  `topic_id` int(11) unsigned NOT NULL,
+  `state` enum('created','closed','reopened','assigned','transferred','overdue') NOT NULL,
+  `staff` varchar(255) NOT NULL default 'SYSTEM',
+  `timestamp` datetime NOT NULL,
+  KEY `ticket_state` (`ticket_id`, `state`, `timestamp`),
+  KEY `ticket_stats` (`timestamp`, `state`)
+) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
+
+DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket_history`;
+DROP TABLE IF EXISTS `%TABLE_PREFIX%history`;
+
+-- Transfer ticket statistics from the %ticket table (inaccurate)
+-- REOPENED
+INSERT INTO `%TABLE_PREFIX%ticket_event`
+    (`ticket_id`, `staff_id`, `team_id`, `dept_id`, `topic_id`,
+        `state`, `staff`, `timestamp`)
+    SELECT `ticket_id`, T1.`staff_id`, `team_id`, T1.`dept_id`, `topic_id`,
+        'reopened', T2.`username`, `reopened`
+    FROM `%TABLE_PREFIX%ticket` T1
+        INNER JOIN `%TABLE_PREFIX%staff` T2
+        ON (T1.`staff_id` = T2.`staff_id`)
+    WHERE `status` = 'open' and `reopened` is not null;
+
+-- CLOSED
+INSERT INTO `%TABLE_PREFIX%ticket_event`
+    (`ticket_id`, `staff_id`, `team_id`, `dept_id`, `topic_id`,
+        `state`, `staff`, `timestamp`)
+    SELECT `ticket_id`, T1.`staff_id`, `team_id`, T1.`dept_id`, `topic_id`,
+        'closed', COALESCE(T2.`username`,'unknown'), `closed`
+    FROM `%TABLE_PREFIX%ticket` T1
+        LEFT JOIN `%TABLE_PREFIX%staff` T2
+        ON (T1.`staff_id` = T2.`staff_id`)
+    WHERE `status` = 'closed' and `closed` is not null;
+
+-- OVERDUE
+INSERT INTO `%TABLE_PREFIX%ticket_event`
+    (`ticket_id`, `staff_id`, `team_id`, `dept_id`, `topic_id`,
+        `state`, `staff`, `timestamp`)
+    SELECT `ticket_id`, T1.`staff_id`, `team_id`, T1.`dept_id`, `topic_id`,
+        'overdue', 'SYSTEM', `duedate`
+    FROM `%TABLE_PREFIX%ticket` T1
+        INNER JOIN `%TABLE_PREFIX%staff` T2
+        ON (T1.`staff_id` = T2.`staff_id`)
+    WHERE `status` = 'open' and `isoverdue`;
+
+-- OPENED
+INSERT INTO `%TABLE_PREFIX%ticket_event`
+    (`ticket_id`, `staff_id`, `team_id`, `dept_id`, `topic_id`,
+        `state`, `staff`, `timestamp`)
+    SELECT `ticket_id`, 0, 0, 0, `topic_id`,
+        'created', 'SYSTEM', T1.`created`
+    FROM `%TABLE_PREFIX%ticket` T1;
+
+UPDATE `%TABLE_PREFIX%config`
+    SET `schema_signature`='f8856d56e51c5cc3416389de78b54515';
diff --git a/include/upgrader/patches/7be60a84-522e5b78.patch.sql b/include/upgrader/patches/7be60a84-522e5b78.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..a31af302d3b10908fdded3c2359b61b426c5a87d
--- /dev/null
+++ b/include/upgrader/patches/7be60a84-522e5b78.patch.sql
@@ -0,0 +1,9 @@
+/**
+ * No longer necessary -- don't clobber email templates for previous
+ * osTicket administrators
+ *
+ * @version v1.7-DPR1 (P1)
+ */
+
+UPDATE `%TABLE_PREFIX%config`
+    SET `schema_signature`='522e5b783c2824c67222260ee22baa93';
diff --git a/include/upgrader/patches/98ae1ed2-e342f869.cleanup.sql b/include/upgrader/patches/98ae1ed2-e342f869.cleanup.sql
new file mode 100644
index 0000000000000000000000000000000000000000..90cf207f5354b3f40aec3cfab8e3c385e7bbc410
--- /dev/null
+++ b/include/upgrader/patches/98ae1ed2-e342f869.cleanup.sql
@@ -0,0 +1,10 @@
+ALTER TABLE `%TABLE_PREFIX%department` DROP `noreply_autoresp`;
+
+ALTER TABLE `%TABLE_PREFIX%config`
+    DROP `noreply_email`,
+    DROP `alert_email`,
+    DROP `api_whitelist`;
+
+-- %email_pop3 migrated to %email table
+TRUNCATE TABLE `%TABLE_PREFIX%email_pop3`;
+DROP TABLE `%TABLE_PREFIX%email_pop3`;
diff --git a/include/upgrader/patches/98ae1ed2-e342f869.patch.sql b/include/upgrader/patches/98ae1ed2-e342f869.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..4fc011ce8a01ec56e8dfafa0d4da9a5300335b4c
--- /dev/null
+++ b/include/upgrader/patches/98ae1ed2-e342f869.patch.sql
@@ -0,0 +1,163 @@
+/**
+ * @version v1.6 RC5
+ * @signature e342f869c7a537ab3ee937fb6e21cdd4
+ *
+ *  Upgrade from 1.6 RC1-4 to 1.6 RC5
+ *  
+ */
+
+ALTER TABLE `%TABLE_PREFIX%config`
+    CHANGE `default_priority` `default_priority_id` TINYINT( 2 ) UNSIGNED NOT NULL DEFAULT '2',
+    CHANGE `default_template` `default_template_id` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '1',
+    CHANGE `default_email` `default_email_id` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0',
+    CHANGE `default_dept` `default_dept_id` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '0',
+    CHANGE `enable_pop3_fetch` `enable_mail_fetch` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0',
+    CHANGE `api_key` `api_passphrase` VARCHAR( 125 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL;
+
+ALTER TABLE `%TABLE_PREFIX%config`
+    ADD `note_alert_active` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `message_alert_dept_manager`,
+    ADD `note_alert_laststaff` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `note_alert_active`,
+    ADD `note_alert_assigned` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `note_alert_laststaff`,
+    ADD `note_alert_dept_manager` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `note_alert_assigned`,
+    ADD `alert_email_id` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `overdue_grace_period`,
+    ADD `default_smtp_id` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `default_template_id`,
+    ADD `spoof_default_smtp` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `default_smtp_id`,
+    ADD `log_level` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '2' AFTER `random_ticket_ids`,
+    ADD `staff_max_logins` TINYINT UNSIGNED NOT NULL DEFAULT '4' AFTER `enable_daylight_saving`,
+    ADD `staff_login_timeout` INT UNSIGNED NOT NULL DEFAULT '2' AFTER `staff_max_logins`,
+    ADD `client_max_logins` TINYINT UNSIGNED NOT NULL DEFAULT '4' AFTER `staff_session_timeout`,
+    ADD `client_login_timeout` INT UNSIGNED NOT NULL DEFAULT '2' AFTER `client_max_logins`,
+    ADD `show_answered_tickets` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `show_assigned_tickets`,
+    ADD `hide_staff_name` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `show_answered_tickets`,
+    ADD `log_graceperiod` INT UNSIGNED NOT NULL DEFAULT '12' AFTER `log_level`;
+
+ALTER TABLE `%TABLE_PREFIX%email` 
+    ADD `userid` VARCHAR( 125 ) NOT NULL AFTER `name` ,
+    ADD `userpass` VARCHAR( 125 ) NOT NULL AFTER `userid`,
+    ADD `mail_active` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `userpass` ,
+    ADD `mail_host` VARCHAR( 125 ) NOT NULL AFTER `mail_active` ,
+    ADD `mail_protocol` ENUM( 'POP', 'IMAP' ) NOT NULL AFTER `mail_host` ,
+    ADD `mail_encryption` ENUM( 'NONE', 'SSL' ) NOT NULL AFTER `mail_protocol` ,
+    ADD `mail_port` INT( 6 ) NULL AFTER `mail_encryption` ,
+    ADD `mail_fetchfreq` TINYINT( 3 ) NOT NULL DEFAULT '5' AFTER `mail_port` ,
+    ADD `mail_fetchmax` TINYINT( 4 ) NOT NULL DEFAULT '30' AFTER `mail_fetchfreq` ,
+    ADD `mail_delete` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `mail_fetchmax` ,
+    ADD `mail_errors` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `mail_delete` ,
+    ADD `mail_lasterror` DATETIME NULL AFTER `mail_errors` ,
+    ADD `mail_lastfetch` DATETIME NULL AFTER `mail_lasterror` ,
+    ADD `smtp_active` TINYINT( 1 ) NOT NULL AFTER `mail_lastfetch` ,
+    ADD `smtp_host` VARCHAR( 125 ) NOT NULL AFTER `smtp_active` ,
+    ADD `smtp_port` INT( 6 ) NULL AFTER `smtp_host` ,
+    ADD `smtp_auth` TINYINT( 1 ) NOT NULL DEFAULT '1' AFTER `smtp_port` ;
+
+-- Transfer old POP3 settings to "new" email table
+UPDATE `%TABLE_PREFIX%email` as T1 JOIN `%TABLE_PREFIX%email_pop3` as T2 ON(T1.email_id = T2.`email_id`)
+    SET 
+     `updated`=NOW(),
+     `mail_protocol`='POP',
+     `mail_encryption`='NONE',
+     `mail_port`=110,
+     `mail_active`=0,
+     `mail_delete`=T2.`delete_msgs`,
+     `mail_host`=T2.`pophost`,
+     `mail_fetchfreq`=T2.`fetchfreq`,
+     `userid`=T2.`popuser`,
+     `userpass`=T2.`poppasswd`;
+
+-- Transfer alert email configuration
+INSERT INTO `%TABLE_PREFIX%email` (`created`, `updated`, `priority_id`,
+    `dept_id`, `name`, `email`)
+    SELECT NOW(), NOW(), 2, COALESCE(`default_dept_id`, 1), 'osTicket Alerts',
+        `alert_email`
+    FROM `%TABLE_PREFIX%config` WHERE `id`=1;
+
+UPDATE `%TABLE_PREFIX%config` SET `alert_email_id` = last_insert_id()
+    WHERE id=1;
+
+ALTER TABLE `%TABLE_PREFIX%department`
+    ADD `autoresp_email_id` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `email_id`,
+    ADD `tpl_id` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `dept_id`,
+    ADD INDEX ( `tpl_id` ),
+    ADD INDEX ( `autoresp_email_id` ) ;
+
+-- Transfer no-reply email configuration
+INSERT INTO `%TABLE_PREFIX%email` (`created`, `updated`, `priority_id`,
+    `dept_id`, `name`, `email`)
+    SELECT NOW(), NOW(), 2, COALESCE(`default_dept_id`, 1), 'No Reply',
+        `noreply_email`
+    FROM `%TABLE_PREFIX%config` WHERE `id`=1;
+
+UPDATE `%TABLE_PREFIX%department` SET `autoresp_email_id` = last_insert_id()
+    WHERE noreply_autoresp=1;
+
+ALTER TABLE `%TABLE_PREFIX%groups` ADD `can_edit_tickets` TINYINT UNSIGNED NOT NULL DEFAULT '0' AFTER `dept_access` ;
+
+UPDATE `%TABLE_PREFIX%groups`  SET `can_edit_tickets`=1 WHERE `can_delete_tickets`=1;
+
+ALTER TABLE `%TABLE_PREFIX%ticket`
+    ADD `phone_ext` VARCHAR( 8 ) NULL DEFAULT NULL AFTER `phone`,
+    ADD `topic`  VARCHAR(64) NULL DEFAULT NULL AFTER `subject`,
+    ADD `duedate` DATETIME NULL AFTER `isoverdue`,
+    ADD `isanswered` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `isoverdue`,
+    ADD `lastmessage` DATETIME NULL AFTER `closed`,
+    ADD `lastresponse` DATETIME NULL AFTER `lastmessage`,
+    ADD INDEX ( `duedate` ) ;
+
+ALTER TABLE `%TABLE_PREFIX%ticket` 
+    CHANGE `source` `source` ENUM( 'Web', 'Email', 'Phone', 'Other' ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'Other' ;
+ 
+ALTER TABLE `%TABLE_PREFIX%email_template` 
+    ADD `note_alert_subj` VARCHAR( 255 ) NOT NULL AFTER `message_alert_body` ,
+    ADD `note_alert_body` TEXT NOT NULL AFTER `note_alert_subj`,
+    ADD `notes` TEXT NULL AFTER `name`;
+
+UPDATE `%TABLE_PREFIX%email_template`  SET  `note_alert_subj` = 'New Internal Note Alert',
+       `note_alert_body` = '%staff,\r\n\r\nInternal note appended to ticket #%ticket\r\n\r\n----------------------\r\nName: %name\r\n\r\n%note\r\n-------------------\r\n\r\nTo view/respond to the ticket, please login to the support ticket system.\r\n\r\nYour friendly,\r\n\r\nCustomer Support System - powered by osTicket.';
+
+-- Update path and variables on email templates
+UPDATE `%TABLE_PREFIX%email_template`
+    SET `ticket_autoresp_body` = REPLACE(`ticket_autoresp_body`, 'view.php', 'ticket.php'),
+        `message_autoresp_body` = REPLACE(`message_autoresp_body`, 'view.php', 'ticket.php'),
+        `ticket_overlimit_body` = REPLACE(`ticket_overlimit_body`, 'view.php', 'ticket.php'),
+        `ticket_reply_body` = REPLACE(
+                REPLACE(`ticket_reply_body`, 'view.php', 'ticket.php'),
+            '%message', '%response');
+
+ALTER TABLE `%TABLE_PREFIX%ticket_message` 
+    ADD `messageId` VARCHAR( 255 ) NULL AFTER `ticket_id`,
+    ADD INDEX ( `messageId` ) ;
+
+ALTER TABLE `%TABLE_PREFIX%ticket_message` ADD FULLTEXT (`message`);
+
+ALTER TABLE `%TABLE_PREFIX%ticket_response` ADD FULLTEXT (`response`);
+
+ALTER TABLE `%TABLE_PREFIX%ticket_note` ADD FULLTEXT (`note`);
+  
+DROP TABLE IF EXISTS `%TABLE_PREFIX%api_key`;
+CREATE TABLE `%TABLE_PREFIX%api_key` (
+  `id` int(10) unsigned NOT NULL auto_increment,
+  `isactive` tinyint(1) NOT NULL default '1',
+  `ipaddr` varchar(16) NOT NULL,
+  `apikey` varchar(255) NOT NULL,
+  `updated` datetime NOT NULL default '0000-00-00 00:00:00',
+  `created` datetime NOT NULL default '0000-00-00 00:00:00',
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `ipaddr` (`ipaddr`)
+) ENGINE=MyISAM;
+
+DROP TABLE IF EXISTS `%TABLE_PREFIX%syslog`;
+CREATE TABLE `%TABLE_PREFIX%syslog` (
+  `log_id` int(11) unsigned NOT NULL auto_increment,
+  `log_type` enum('Debug','Warning','Error') NOT NULL,
+  `title` varchar(255) NOT NULL,
+  `log` text NOT NULL,
+  `logger` varchar(64) NOT NULL,
+  `ip_address` varchar(16) NOT NULL,
+  `created` datetime NOT NULL default '0000-00-00 00:00:00',
+  `updated` datetime NOT NULL default '0000-00-00 00:00:00',
+  PRIMARY KEY  (`log_id`),
+  KEY `log_type` (`log_type`)
+) ENGINE=MyISAM;
+
+UPDATE `%TABLE_PREFIX%config`
+    SET `ostversion`='1.6 RC5';
diff --git a/include/upgrader/patches/a67ba35e-98ae1ed2.patch.sql b/include/upgrader/patches/a67ba35e-98ae1ed2.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..750eb1e293b7144565016e1ed5e754e0c9ec36b6
--- /dev/null
+++ b/include/upgrader/patches/a67ba35e-98ae1ed2.patch.sql
@@ -0,0 +1,8 @@
+/*
+ * @version=1.6RC1-4
+ * 
+ * Stage RC3 for 1.6RC5 upgrade
+ */
+
+UPDATE `%TABLE_PREFIX%config`
+    SET `ostversion`='1.6 RC1-4';
diff --git a/include/upgrader/patches/aa4664af-b19dc97d.patch.sql b/include/upgrader/patches/aa4664af-b19dc97d.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..8b5ce9eb37fd24d4257f7e14ed1f7f4f962e1597
--- /dev/null
+++ b/include/upgrader/patches/aa4664af-b19dc97d.patch.sql
@@ -0,0 +1,23 @@
+/**
+ * Change IP address columns to have sufficient room to store IPv6 address
+ *
+ * @version 1.7-rc1 ipv6-addresses
+ */
+
+ALTER TABLE `%TABLE_PREFIX%api_key`
+    CHANGE `ipaddr` `ipaddr` varchar(64) NOT NULL;
+
+ALTER TABLE `%TABLE_PREFIX%session`
+    CHANGE `user_id` `user_id` int(10) unsigned NOT NULL default '0'
+        COMMENT 'osTicket staff ID',
+    CHANGE `user_ip` `user_ip` varchar(64) NOT NULL;
+
+ALTER TABLE `%TABLE_PREFIX%syslog`
+    CHANGE `ip_address` `ip_address` varchar(64) NOT NULL;
+
+ALTER TABLE `%TABLE_PREFIX%ticket`
+    CHANGE `ip_address` `ip_address` varchar(64) NOT NULL default '';
+
+-- Finished with patch
+UPDATE `%TABLE_PREFIX%config`
+    SET `schema_signature`='b19dc97d19f7a30f59663c812d1f3ddc';
diff --git a/setup/inc/sql/abe9c0cb-bbb021fb.patch.sql b/include/upgrader/patches/abe9c0cb-bbb021fb.patch.sql
similarity index 100%
rename from setup/inc/sql/abe9c0cb-bbb021fb.patch.sql
rename to include/upgrader/patches/abe9c0cb-bbb021fb.patch.sql
diff --git a/include/upgrader/patches/aee589ab-98ae1ed2.patch.sql b/include/upgrader/patches/aee589ab-98ae1ed2.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..f786bbb22b34bb33c53c76321be16d558caa3044
--- /dev/null
+++ b/include/upgrader/patches/aee589ab-98ae1ed2.patch.sql
@@ -0,0 +1,8 @@
+/*
+ * @version=1.6RC1-4
+ * 
+ * Stage RC1 for 1.6RC5 upgrade
+ */
+
+UPDATE `%TABLE_PREFIX%config`
+    SET `ostversion`='1.6 RC1-4';
diff --git a/include/upgrader/patches/b19dc97d-435c62c3.patch.sql b/include/upgrader/patches/b19dc97d-435c62c3.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..b908348a728445778725b9215eebe432e270e9dc
--- /dev/null
+++ b/include/upgrader/patches/b19dc97d-435c62c3.patch.sql
@@ -0,0 +1,16 @@
+/**
+ * Support canned response definition for email filters
+ *
+ * @version 1.7-rc1 canned-response-in-filter
+ */
+
+ALTER TABLE `%TABLE_PREFIX%email_filter`
+    ADD `canned_response_id` int(11) unsigned NOT NULL default '0'
+        AFTER `disable_autoresponder`;
+
+-- Add index for linking responses to messages quickly
+ALTER TABLE `%TABLE_PREFIX%ticket_thread` ADD KEY `pid` (`pid`);
+
+-- Finished with patch
+UPDATE `%TABLE_PREFIX%config`
+    SET `schema_signature`='435c62c3b23795529bcfae7e7371d82e';
diff --git a/setup/inc/sql/bbb021fb-49478749.patch.sql b/include/upgrader/patches/bbb021fb-49478749.patch.sql
similarity index 100%
rename from setup/inc/sql/bbb021fb-49478749.patch.sql
rename to include/upgrader/patches/bbb021fb-49478749.patch.sql
diff --git a/include/upgrader/patches/c00511c7-7be60a84.cleanup.sql b/include/upgrader/patches/c00511c7-7be60a84.cleanup.sql
new file mode 100644
index 0000000000000000000000000000000000000000..01d69e2d72b732b2d7c3f618fd6e595ccb7c67f7
--- /dev/null
+++ b/include/upgrader/patches/c00511c7-7be60a84.cleanup.sql
@@ -0,0 +1,25 @@
+-- Drop columns we nolonger need - (must be at the very bottom or after session table is created)
+ALTER TABLE `%TABLE_PREFIX%config`
+    DROP COLUMN `ostversion`,
+    DROP COLUMN `timezone_offset`,
+    DROP COLUMN `api_passphrase`;
+
+-- Drop fields we no longer need in the reference table.
+ALTER TABLE `%TABLE_PREFIX%ticket_attachment`
+    DROP `file_size`,
+    DROP `file_name`,
+    DROP `file_key`,
+    DROP `updated`,
+    DROP `isdeleted`;
+
+-- Drop fields we no longer need in staff table.
+ALTER TABLE `%TABLE_PREFIX%staff`
+    DROP `append_signature`,
+    DROP `timezone_offset`;
+
+-- Drop fields we no longer need in department table.
+ALTER TABLE `%TABLE_PREFIX%department`
+    DROP `can_append_signature`;
+
+-- Banlist table has been migrated to the email_filter_rule table
+DROP TABLE `%TABLE_PREFIX%email_banlist`;
diff --git a/setup/inc/sql/v1.6st-1.7-upgrade-mysql.sql b/include/upgrader/patches/c00511c7-7be60a84.patch.sql
similarity index 92%
rename from setup/inc/sql/v1.6st-1.7-upgrade-mysql.sql
rename to include/upgrader/patches/c00511c7-7be60a84.patch.sql
index 3a2acf2295170c9b6263b33f05d649c378ed5dbb..638248b976019a670c773578b564d99a3daacc6a 100644
--- a/setup/inc/sql/v1.6st-1.7-upgrade-mysql.sql
+++ b/include/upgrader/patches/c00511c7-7be60a84.patch.sql
@@ -1,3 +1,9 @@
+/**
+ * @version v1.7
+ *
+ * @schema c00511c7c1db65c0cfad04b4842afc57
+ */
+
 -- Add a table to contain the attachment file contents
 DROP TABLE IF EXISTS `%TABLE_PREFIX%file`;
 CREATE TABLE `%TABLE_PREFIX%file` (
@@ -65,8 +71,8 @@ ALTER TABLE `%TABLE_PREFIX%config`
 ALTER TABLE `%TABLE_PREFIX%staff` 
     ADD `passwdreset` DATETIME NULL DEFAULT NULL AFTER `lastlogin`;
 
-DROP TABLE IF EXISTS `%TICKET_PREFIX%sla`;
-CREATE TABLE IF NOT EXISTS `%TICKET_PREFIX%sla` (
+DROP TABLE IF EXISTS `%TABLE_PREFIX%sla`;
+CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%sla` (
     `id` int(11) unsigned NOT NULL auto_increment,
     `isactive` tinyint(1) unsigned NOT NULL default '1',
     `enable_priority_escalation` tinyint(1) unsigned NOT NULL default '1',
@@ -102,8 +108,16 @@ CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%team` (
 ) ENGINE=MyISAM;
 
 -- Create a default TEAM
-INSERT INTO `%TABLE_PREFIX%team` (`lead_id`, `isenabled`, `noalerts`, `name`, `notes`)
-    VALUES (0, 1, 0, 'Level I Support', '');
+INSERT INTO `%TABLE_PREFIX%team` (`lead_id`, `isenabled`, `noalerts`, `name`, `notes`, `created`, `updated`)
+    VALUES (0, 1, 0, 'Level I Support', '', NOW(), NOW());
+
+DROP TABLE IF EXISTS `%TABLE_PREFIX%team_member`;
+CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%team_member` (
+  `team_id` int(10) unsigned NOT NULL default '0',
+  `staff_id` int(10) unsigned NOT NULL,
+  `updated` datetime NOT NULL,
+  PRIMARY KEY  (`team_id`,`staff_id`)
+) ENGINE=MyISAM;
 
 ALTER TABLE `%TABLE_PREFIX%department`
     ADD sla_id INT UNSIGNED NOT NULL DEFAULT '0' AFTER tpl_id;
@@ -120,10 +134,10 @@ UPDATE `%TABLE_PREFIX%staff` SET timezone_id =
     (SELECT id FROM `%TABLE_PREFIX%timezone` WHERE offset = `%TABLE_PREFIX%staff`.timezone_offset);
 
 ALTER TABLE `%TABLE_PREFIX%groups`
-    ADD notes TEXT NULL AFTER can_manage_kb,
     CHANGE `can_manage_kb` `can_manage_premade` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
     ADD `can_manage_faq` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `can_manage_premade`,
-    ADD `can_assign_tickets` TINYINT( 1 ) UNSIGNED NOT NULL default '1' AFTER `can_close_tickets`;
+    ADD `can_assign_tickets` TINYINT( 1 ) UNSIGNED NOT NULL default '1' AFTER `can_close_tickets`,
+    ADD notes TEXT NULL AFTER can_manage_faq;
 
 -- Add new columns to the templates table
 ALTER TABLE `%TABLE_PREFIX%email_template`
@@ -195,7 +209,7 @@ CREATE TABLE `%TABLE_PREFIX%email_filter_rule` (
   `what` enum('name','email','subject','body','header') NOT NULL,
   `how` enum('equal','not_equal','contains','dn_contain') NOT NULL,
   `val` varchar(255) NOT NULL,
-  `isactive` tinytext( 1 ) UNSIGNED NOT NULL DEFAULT '1',
+  `isactive` tinyint( 1 ) UNSIGNED NOT NULL DEFAULT '1',
   `notes` tinytext NOT NULL,
   `created` datetime NOT NULL,
   `updated` datetime NOT NULL,
@@ -205,8 +219,8 @@ CREATE TABLE `%TABLE_PREFIX%email_filter_rule` (
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 
 -- SYSTEM BAN LIST was the first filter created, with ID of '1'
-INSERT INTO `%TABLE_PREFIX%email_filter_rule` (`filter_id`, `what`, `how`, `val`) VALUES
-SELECT 1, 'email', 'equals', email FROM `%TABLE_PREFIX%email_banlist`;
+INSERT INTO `%TABLE_PREFIX%email_filter_rule` (`filter_id`, `what`, `how`, `val`) 
+    SELECT 1, 'email', 'equals', email FROM `%TABLE_PREFIX%email_banlist`;
 
 -- Create table session
 DROP TABLE IF EXISTS `%TABLE_PREFIX%session`;
@@ -259,12 +273,12 @@ CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%canned_attachment` (
 
 -- Rename kb_premade to canned_response
 ALTER TABLE `%TABLE_PREFIX%kb_premade`
-  ADD `notes` TEXT NOT NULL AFTER `answer`,
   CHANGE `premade_id` `canned_id` int(10) unsigned NOT NULL auto_increment,
   CHANGE `title` `title` VARCHAR( 255 ) NOT NULL DEFAULT '',
-  CHANGE `answer` `response` TEXT NOT NULL.
-  DROP INDEX `title` ,
-  ADD FULLTEXT `resp` (`title` ,`answer`);
+  CHANGE `answer` `response` TEXT NOT NULL,
+  ADD `notes` TEXT NOT NULL AFTER `response`,
+  DROP INDEX `title`,
+  ADD FULLTEXT `resp` (`title` ,`response`);
   
 ALTER TABLE `%TABLE_PREFIX%kb_premade` RENAME TO `%TABLE_PREFIX%canned_response`;
 
@@ -287,3 +301,7 @@ CREATE TABLE IF NOT EXISTS `%TABLE_PREFIX%faq_topic` (
   `topic_id` int(10) unsigned NOT NULL,
   PRIMARY KEY  (`faq_id`,`topic_id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+UPDATE `%TABLE_PREFIX%config`
+    SET `schema_signature`='7be60a8432e44989e782d5914ef784d2'; 
diff --git a/setup/inc/sql/c2d2fabf-aa4664af.patch.sql b/include/upgrader/patches/c2d2fabf-aa4664af.patch.sql
similarity index 100%
rename from setup/inc/sql/c2d2fabf-aa4664af.patch.sql
rename to include/upgrader/patches/c2d2fabf-aa4664af.patch.sql
diff --git a/include/upgrader/patches/e342f869-c00511c7.patch.sql b/include/upgrader/patches/e342f869-c00511c7.patch.sql
new file mode 100644
index 0000000000000000000000000000000000000000..8f393a295b9a055e63c014b4e9b6f31d6d56975d
--- /dev/null
+++ b/include/upgrader/patches/e342f869-c00511c7.patch.sql
@@ -0,0 +1,47 @@
+/**
+ * @version v1.6 ST
+ * @signature c00511c7c1db65c0cfad04b4842afc57
+ *
+ *  Upgrade from 1.6 RC5 to 1.6 ST
+ *  
+ */
+
+ALTER TABLE `%TABLE_PREFIX%ticket` 
+    CHANGE `topic` `helptopic` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+    ADD `topic_id` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `priority_id`,
+    ADD INDEX ( `topic_id` );
+
+ALTER TABLE `%TABLE_PREFIX%groups` 
+    ADD `can_create_tickets` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `dept_access`;
+
+ALTER TABLE `%TABLE_PREFIX%staff` 
+    ADD `auto_refresh_rate` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `max_page_size`,
+    CHANGE `signature` `signature` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
+
+ALTER TABLE `%TABLE_PREFIX%department`
+    CHANGE `dept_signature` `dept_signature` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
+
+ALTER TABLE `%TABLE_PREFIX%config`
+    ADD `ticket_notice_active` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `message_autoresponder`,
+    ADD `enable_captcha` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `use_email_priority`,
+    ADD `log_ticket_activity` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `strip_quoted_reply`,
+    ADD `staff_ip_binding` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `enable_daylight_saving`;
+
+
+ALTER TABLE `%TABLE_PREFIX%email_template`
+    ADD `ticket_notice_subj` VARCHAR( 255 ) NOT NULL AFTER `ticket_autoresp_body` ,
+    ADD `ticket_notice_body` TEXT NOT NULL AFTER `ticket_notice_subj`;
+
+UPDATE `%TABLE_PREFIX%email_template` SET updated=NOW(),
+    `ticket_notice_subj` = '[#%ticket] %subject',
+    `ticket_notice_body` = '%name,\r\n\r\nOur customer care team personnel has created a ticket #%ticket on your behalf, with the following message:\r\n\r\n%message\r\n\r\nIf you wish to provide additional comments or information regarding this issue, please don''t open a new ticket. You can update or view this ticket''s progress online here: %url/view.php?e=%email&t=%ticket.\r\n\r\n%signature';
+
+UPDATE `%TABLE_PREFIX%email_template`
+    SET `ticket_overlimit_subj` = REPLACE(`ticket_overlimit_subj`, '%id', '%ticket'),
+        `ticket_overlimit_body` = REPLACE(`ticket_overlimit_body`, '%id', '%ticket');
+
+INSERT INTO `%TABLE_PREFIX%kb_premade` (`premade_id`, `dept_id`, `isenabled`, `title`, `answer`, `created`, `updated`) 
+    VALUES ('', 0, 1, 'Sample (with variables)', '\r\n%name,\r\n\r\nYour ticket #%ticket created on %createdate is in %dept department.\r\n\r\n', NOW(), NOW());
+
+UPDATE `%TABLE_PREFIX%config`
+    SET `ostversion`='1.6 ST';
diff --git a/setup/inc/sql/f8856d56-abe9c0cb.patch.sql b/include/upgrader/patches/f8856d56-abe9c0cb.patch.sql
similarity index 85%
rename from setup/inc/sql/f8856d56-abe9c0cb.patch.sql
rename to include/upgrader/patches/f8856d56-abe9c0cb.patch.sql
index a5f54aa8516aaaaf268e363b8ae58674725b61af..c0e5dd298482de89fda33bb04edf011d478f0b4d 100644
--- a/setup/inc/sql/f8856d56-abe9c0cb.patch.sql
+++ b/include/upgrader/patches/f8856d56-abe9c0cb.patch.sql
@@ -23,12 +23,13 @@ CREATE TABLE `%TABLE_PREFIX%ticket_thread` (
   `ip_address` varchar(64) NOT NULL default '',
   `created` datetime NOT NULL,
   `updated` datetime NOT NULL,
-  -- Temporary columns for conversion
   `old_pk` int(11) unsigned NOT NULL,
   `old_pid` int(11) unsigned,
   PRIMARY KEY  (`id`),
   KEY `ticket_id` (`ticket_id`),
   KEY `staff_id` (`staff_id`),
+  KEY `old_pk` (`old_pk`),
+  KEY `created` (`created`),
   FULLTEXT KEY `body` (`body`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 
@@ -58,7 +59,12 @@ INSERT INTO `%TABLE_PREFIX%ticket_thread`
 
 -- Connect responses to (new) messages
 CREATE TABLE `%TABLE_PREFIX%T_resp_links`
-    SELECT `id`, `old_pk`, `old_pid` FROM `%TABLE_PREFIX%ticket_thread`;
+    SELECT `id`, `old_pk`
+      FROM `%TABLE_PREFIX%ticket_thread`
+     WHERE `thread_type` = 'M';
+
+-- Add an index to speed up the linking process
+ALTER TABLE `%TABLE_PREFIX%T_resp_links` ADD KEY `old_pk` (`old_pk`, `id`);
 
 UPDATE `%TABLE_PREFIX%ticket_thread`
     SET `pid` = ( SELECT T2.`id` FROM `%TABLE_PREFIX%T_resp_links` T2
@@ -70,14 +76,13 @@ DROP TABLE `%TABLE_PREFIX%T_resp_links`;
 
 -- Transfer notes
 INSERT INTO `%TABLE_PREFIX%ticket_thread`
-  (`ticket_id`, `staff_id`, `thread_type`, `body`, `title`,
-    `source`, `poster`, `created`, `updated`, `old_pk`)
-  SELECT `ticket_id`, `staff_id`, 'N', `note`, `title`,
-    `source`, ( SELECT CONCAT_WS(' ', T2.`firstname`, T2.`lastname`)
-                FROM `%TABLE_PREFIX%staff` T2
-                WHERE T2.`staff_id` = `staff_id` ),
-    `created`, NOW(), `note_id`
-    FROM `%TABLE_PREFIX%ticket_note`;
+ (`ticket_id`, `staff_id`, `thread_type`, `body`, `title`,
+   `source`, `poster`, `created`, `updated`, `old_pk`)
+ SELECT `ticket_id`, N.staff_id, 'N', `note`, `title`,
+   `source`, CONCAT_WS(' ', S.`firstname`, S.`lastname`),
+   N.created, NOW(), `note_id`
+   FROM `%TABLE_PREFIX%ticket_note` N
+   LEFT JOIN `%TABLE_PREFIX%staff` S ON(S.staff_id=N.staff_id);
 
 -- Transfer email information from messages
 INSERT INTO `%TABLE_PREFIX%ticket_email_info`
diff --git a/setup/inc/upgrade-prereq.inc.php b/include/upgrader/prereq.inc.php
similarity index 78%
rename from setup/inc/upgrade-prereq.inc.php
rename to include/upgrader/prereq.inc.php
index 5f60cece25500679de83b01981ea05ac634949e9..814c76fff32403b227efbf26bcf490f757dc8d83 100644
--- a/setup/inc/upgrade-prereq.inc.php
+++ b/include/upgrader/prereq.inc.php
@@ -1,10 +1,10 @@
 <?php
-if(!defined('SETUPINC')) die('Kwaheri!');
-
+if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 ?>
+<h2>osTicket Upgrader</h2>
+<div id="upgrader">
+    
     <div id="main">
-            <h1>osTicket Upgrade!</h1>
-            <font color="red"><b><?php echo $errors['err']; ?></b></font>
             <div id="intro">
              <p>Thank you for being a loyal osTicket user!</p>
              <p>The upgrade wizard will guide you every step of the way in the upgrade process. While we try to ensure that the upgrade process is straightforward and painless, we can't guarantee it will be the case for every user.</p>
@@ -12,7 +12,7 @@ if(!defined('SETUPINC')) die('Kwaheri!');
             <h2>Getting ready!</h2>
             <p>Before we begin, we'll check your server configuration to make sure you meet the minimum requirements to run the latest version of osTicket.</p>
             <h3>Prerequisites: <font color="red"><?php echo $errors['prereq']; ?></font></h3>
-            These items are necessary in order to use osTicket the latest version of osTicket.
+            These items are necessary in order to run the latest version of osTicket.
             <ul class="progress">
                 <li class="<? echo $upgrader->check_php()?'yes':'no'; ?>">
                 PHP v4.3 or greater - (<small><b><?php echo PHP_VERSION; ?></b></small>)</li>
@@ -22,7 +22,6 @@ if(!defined('SETUPINC')) die('Kwaheri!');
             <h3>Higly Recommended:</h3>
             We hightly recommend that you follow the steps below.
             <ul>
-                <li>Take osTicket offline momentarily during upgrade.</li>
                 <li>Backup the current database, if you haven't done so already.</li>
                 <li>Be patient the upgrade process will take a couple of seconds.</li>
             </ul>
@@ -36,15 +35,17 @@ if(!defined('SETUPINC')) die('Kwaheri!');
     <div id="sidebar">
             <h3>Upgrade Tips</h3>
             <p>1. Remember to backup your osTicket database</p>
-            <p>2. Take osTicket offline momentarily</p>
+            <p>2. Refer to <a href="http://osticket.com/wiki/Upgrade_and_Migration" target="_blank">Upgrade Guide</a> for the latest tips</a>
             <p>3. If you experience any problems, you can always restore your files/dabase backup.</p>
             <p>4. We can help, feel free to <a href="http://osticket.com/support/" target="_blank">contact us </a> for professional help.</p>
 
     </div>
-
-    <div id="overlay"></div>
-    <div id="loading">
-        <h4>Doing stuff!</h4>
-        Please wait... while we upgrade your osTicket installation!
-        <div id="udb"></div>
-    </div>
+    <div class="clear"></div>
+</div>
+    
+<div id="overlay"></div>
+<div id="loading">
+    <h4>Doing stuff!</h4>
+    Please wait... while we upgrade your osTicket installation!
+    <div id="msg"></div>
+</div>
diff --git a/include/upgrader/rename.inc.php b/include/upgrader/rename.inc.php
new file mode 100644
index 0000000000000000000000000000000000000000..6d449567f247902466e73878d752949b97f52c0c
--- /dev/null
+++ b/include/upgrader/rename.inc.php
@@ -0,0 +1,33 @@
+<?php
+if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
+?>
+<div id="upgrader">
+    <br>
+    <h2 style="color:#FF7700;">Configuration file rename required!</h2>
+    <div id="main">
+            <div id="intro">
+             <p>To avoid possible conflicts, please take a minute to rename configuration file as shown below.</p>
+            </div>
+            <h3>Solution:</h3>
+            Rename file <b>include/settings.php</b> to <b>include/ost-config.php</b> and click continue below.
+            <ul>
+                <li><b>CLI:</b><br><i>mv include/settings.php include/ost-config.php</i></li>
+                <li><b>FTP:</b><br> </li>
+                <li><b>Cpanel:</b><br> </li>
+            </ul>
+            <p>Please refer to the <a target="_blank" href="http://osticket.com/wiki/Upgrade_and_Migration">Upgrade Guide</a> for more information.</p>
+            <div id="bar">
+                <form method="post" action="upgrade.php">
+                    <input type="hidden" name="s" value="prereq">
+                    <input class="btn" type="submit" name="submit" value="Continue &raquo;">
+                </form>
+            </div>
+    </div>
+    <div id="sidebar">
+            <h3>Need Help?</h3>
+            <p>
+            If you are looking for a greater level of support, we provide <u>professional upgrade</u> and commercial support with guaranteed response times, and access to the core development team. We can also help customize osTicket or even add new features to the system to meet your unique needs. <a target="_blank" href="http://osticket.com/support/professional_services.php">Learn More!</a>
+            </p>
+    </div>
+    <div class="clear"></div>
+</div>
diff --git a/setup/inc/upgrade.inc.php b/include/upgrader/upgrade.inc.php
similarity index 80%
rename from setup/inc/upgrade.inc.php
rename to include/upgrader/upgrade.inc.php
index 6f05cd169c66d49163908d8a6c6bef9d5b9a1a18..9e95af3ff030e87d3f1af20881f44b842fc7c769 100644
--- a/setup/inc/upgrade.inc.php
+++ b/include/upgrader/upgrade.inc.php
@@ -1,14 +1,13 @@
 <?php
-if(!defined('SETUPINC') || !$upgrader)  die('Kwaheri!');
+if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
 $action=$upgrader->getNextAction();
-
 ?>
+<h2>osTicket Upgrade</h2>
+<div id="upgrader">
     <div id="main">
-            <h1>osTicket Upgrade</h1>
             <div id="intro">
              <p>Thank you for taking the time to upgrade your osTicket intallation!</p>
-             <p>Please don't cancel or close the browser, any errors at this
-              stage will be fatal.</p>
+             <p>Please don't cancel or close the browser, any errors at this stage will be fatal.</p>
             </div>
             <h2><?php echo $action ?></h2>
             <p>The upgrade wizard will now attempt to upgrade your database and core settings!</p>
@@ -27,14 +26,15 @@ $action=$upgrader->getNextAction();
     </div>
     <div id="sidebar">
             <h3>Upgrade Tips</h3>
-            <p>1. Be patient the process will take a couple of seconds.</p>
-            <p>2. If you experience any problems, you can always restore your files/dabase backup.</p>
+            <p>1. Be patient the process will take a couple of minutes.</p>
+            <p>2. If you experience any problems, you can always restore your files/database backup.</p>
             <p>3. We can help, feel free to <a href="http://osticket.com/support/" target="_blank">contact us </a> for professional help.</p>
     </div>
-
-    <div id="overlay"></div>
+    <div class="clear"></div>
     <div id="loading">
         <h4><?php echo $action; ?></h4>
         Please wait... while we upgrade your osTicket installation!
         <div id="msg" style="font-weight: bold;padding-top:10px;">Smile!</div>
     </div>
+</div>
+<div class="clear"></div>`
diff --git a/main.inc.php b/main.inc.php
index 3660625d6b1280b9e7b2ab7b836cbf8ce5f23399..1de9c91a3185d6a740cf9832069be71c0a29a805 100644
--- a/main.inc.php
+++ b/main.inc.php
@@ -33,7 +33,7 @@
     #Disable session ids on url.
     ini_set('session.use_trans_sid', 0);
     #No cache
-    ini_set('session.cache_limiter', 'nocache');
+    session_cache_limiter('nocache');
     #Cookies
     //ini_set('session.cookie_path','/osticket/');
 
@@ -55,20 +55,26 @@
     define('INCLUDE_DIR',ROOT_DIR.'include/'); //Change this if include is moved outside the web path.
     define('PEAR_DIR',INCLUDE_DIR.'pear/');
     define('SETUP_DIR',INCLUDE_DIR.'setup/');
-  
+
+    define('UPGRADE_DIR', INCLUDE_DIR.'upgrader/');
+    define('PATCH_DIR', UPGRADE_DIR.'patches/');
+
     /*############## Do NOT monkey with anything else beyond this point UNLESS you really know what you are doing ##############*/
 
     #Current version && schema signature (Changes from version to version)
     define('THIS_VERSION','1.7-DPR4'); //Shown on admin panel
-    define('SCHEMA_SIGNATURE','aa4664afc3b43d4068eb2e82684fc28e'); //MD5 signature of the db schema. (used to trigger upgrades)
+    define('SCHEMA_SIGNATURE','435c62c3b23795529bcfae7e7371d82e'); //MD5 signature of the db schema. (used to trigger upgrades)
 
     #load config info
     $configfile='';
     if(file_exists(ROOT_DIR.'ostconfig.php')) //Old installs prior to v 1.6 RC5
         $configfile=ROOT_DIR.'ostconfig.php';
-    elseif(file_exists(INCLUDE_DIR.'settings.php')) //OLD config file.. v 1.6 RC5
+    elseif(file_exists(INCLUDE_DIR.'settings.php')) { //OLD config file.. v 1.6 RC5
         $configfile=INCLUDE_DIR.'settings.php';
-    elseif(file_exists(INCLUDE_DIR.'ost-config.php')) //NEW config file v 1.6 stable ++
+        //Die gracefully on upgraded v1.6 RC5 installation - otherwise script dies with confusing message. 
+        if(!strcasecmp(basename($_SERVER['SCRIPT_NAME']), 'settings.php'))
+            die('Please rename config file include/settings.php to include/ost-config.php to continue!');
+    } elseif(file_exists(INCLUDE_DIR.'ost-config.php')) //NEW config file v 1.6 stable ++
         $configfile=INCLUDE_DIR.'ost-config.php';
     elseif(file_exists(ROOT_DIR.'setup/'))
         header('Location: '.ROOT_PATH.'setup/');
@@ -98,6 +104,7 @@
     require(INCLUDE_DIR.'class.log.php');
     require(INCLUDE_DIR.'class.mcrypt.php');
     require(INCLUDE_DIR.'class.misc.php');
+    require(INCLUDE_DIR.'class.timezone.php');
     require(INCLUDE_DIR.'class.http.php');
     require(INCLUDE_DIR.'class.nav.php');
     require(INCLUDE_DIR.'class.format.php'); //format helpers
diff --git a/offline.php b/offline.php
index 24f8401a14c9710de2f9bf7af3a13985a47a099d..8c09a20010c4e6348e625ff7688ecab912bb0824 100644
--- a/offline.php
+++ b/offline.php
@@ -14,7 +14,7 @@
     vim: expandtab sw=4 ts=4 sts=4:
 **********************************************************************/
 require_once('client.inc.php');
-if($cfg && !$cfg->isHelpDeskOffline()) { 
+if(is_object($ost) && $ost->isSystemOnline()) {
     @header('Location: index.php'); //Redirect if the system is online.
     include('index.php');
     exit;
diff --git a/scp/admin.inc.php b/scp/admin.inc.php
index 89e234e2f13e14204701348fa2222ae195930ea2..28db6fab7ba04c5100a26e6dadc615deb121b7be 100644
--- a/scp/admin.inc.php
+++ b/scp/admin.inc.php
@@ -20,19 +20,34 @@ if(!$ost or !$thisstaff or !$thisstaff->isAdmin()){
     require('index.php'); // just in case!
     exit;
 }
+//Define some constants.
+define('OSTADMININC',TRUE); //checked by admin include files
+define('ADMINPAGE',TRUE);   //Used by the header to swap menus.
 
 //Some security related warnings - bitch until fixed!!! :)
 if($ost->isUpgradePending()) {
-    $errors['err']=$sysnotice='System upgrade is pending <a href="../setup/upgrade.php">Upgrade Now</a>';
+    $errors['err']=$sysnotice='System upgrade is pending <a href="upgrade.php">Upgrade Now</a>';
+    if(!in_array(basename($_SERVER['SCRIPT_NAME']), array('upgrade.php', 'logs.php'))) {
+        header('Location: upgrade.php');
+        require('upgrade.php');
+        exit;
+    }
 } else {
     
-    if(file_exists('../setup/')) {
+    if(!strcasecmp(basename(CONFIG_FILE), 'settings.php')) {
+        $sysnotice=sprintf('Please rename config file include/%s to include/ost-config.php to avoid possible conflicts',
+                                basename(CONFIG_FILE));
+        //Die gracefully - otherwise upgraded RC5 installations will die with confusing message. 
+        if(!strcasecmp(basename($_SERVER['SCRIPT_NAME']), 'settings.php'))
+            die($sysnotice);
+
+    } elseif(file_exists('../setup/')) {
         $sysnotice='Please take a minute to delete <strong>setup/install</strong> directory (../setup/) for security reasons.';
     } elseif(CONFIG_FILE && file_exists(CONFIG_FILE) && is_writable(CONFIG_FILE)) {
             //Confirm for real that the file is writable by group or world.
             clearstatcache(); //clear the cache!
             $perms = @fileperms(CONFIG_FILE);
-            if(($perms & 0x0002) || ($perms & 0x0010)) { 
+            if(($perms & 0x0002) || ($perms & 0x0010)) {
                 $sysnotice=sprintf('Please change permission of config file (%s) to remove write access. e.g <i>chmod 644 %s</i>',
                                 basename(CONFIG_FILE), basename(CONFIG_FILE));
             }
@@ -42,9 +57,6 @@ if($ost->isUpgradePending()) {
         $sysnotice='Please consider turning off register globals if possible';
 }
 
-//Define some constants.
-define('OSTADMININC',TRUE); //checked by admin include files
-define('ADMINPAGE',TRUE);   //Used by the header to swap menus.
 //Admin navigation - overwrites what was set in staff.inc.php
 $nav = new AdminNav($thisstaff);
 ?>
diff --git a/scp/admin.php b/scp/admin.php
index d84edfed805878660e72fa9712270168bc6a6107..ffe48ee59a99816ec27ceba32e8956cc375bd456 100644
--- a/scp/admin.php
+++ b/scp/admin.php
@@ -1,4 +1,4 @@
 <?php
-header('Location: syslogs.php');
-require('syslogs.php');
+header('Location: settings.php');
+require('./settings.php');
 ?>
diff --git a/scp/ajax.php b/scp/ajax.php
index d14727c85a6dac30e5b74f59a287dc89a45ecb47..8ffa515402f907b6525b1f74786bf6e1a0378c98 100644
--- a/scp/ajax.php
+++ b/scp/ajax.php
@@ -52,12 +52,6 @@ $dispatcher = patterns('',
         url_get('^table/export$', 'downloadTabularData'),
         url_get('^table$', 'getTabularData')
     )),
-    url('^/report/overview/', patterns('ajax.reports.php:OverviewReportAjaxAPI',
-        # Send
-        url_get('^graph$', 'getPlotData'),
-        url_get('^table/groups$', 'enumTabularGroups'),
-        url_get('^table$', 'getTabularData')
-    )),
     url_get('^/users$', array('ajax.users.php:UsersAjaxAPI', 'search')),
     url('^/tickets/', patterns('ajax.tickets.php:TicketsAjaxAPI',
         url_get('^(?P<tid>\d+)/preview', 'previewTicket'),
@@ -66,7 +60,8 @@ $dispatcher = patterns('',
         url_post('^(?P<tid>\d+)/lock/(?P<id>\d+)/release', 'releaseLock'),
         url_get('^lookup', 'lookup'),
         url_get('^search', 'search')
-    ))
+    )),
+    url_post('^/upgrader', array('ajax.upgrader.php:UpgraderAjaxAPI', 'upgrade'))
 );
 
 # Call the respective function
diff --git a/scp/css/bootstrap.css b/scp/css/bootstrap.css
index 27de4b50704514f22930e034d004b27a707c35ea..596bdd56453bc4187ae7e1368c80d7f9918fb652 100644
--- a/scp/css/bootstrap.css
+++ b/scp/css/bootstrap.css
@@ -7,136 +7,17 @@
  *
  * Designed and built with all the love in the world @twitter by @mdo and @fat.
  */
-
-article,
-aside,
-details,
-figcaption,
-figure,
-footer,
-header,
-hgroup,
-nav,
-section {
-  display: block;
-}
-
-audio,
-canvas,
-video {
-  display: inline-block;
-  *display: inline;
-  *zoom: 1;
-}
-
-audio:not([controls]) {
-  display: none;
-}
-
-html {
-  font-size: 100%;
-  -webkit-text-size-adjust: 100%;
-      -ms-text-size-adjust: 100%;
-}
-
-a:focus {
-  outline: thin dotted #333;
-  outline: 5px auto -webkit-focus-ring-color;
-  outline-offset: -2px;
-}
-
-a:hover,
-a:active {
-  outline: 0;
-}
-
-sub,
-sup {
-  position: relative;
-  font-size: 75%;
-  line-height: 0;
-  vertical-align: baseline;
-}
-
-sup {
-  top: -0.5em;
-}
-
-sub {
-  bottom: -0.25em;
-}
-
-img {
-  max-width: 100%;
-  vertical-align: middle;
-  border: 0;
-  -ms-interpolation-mode: bicubic;
-}
-
-#map_canvas img {
-  max-width: none;
-}
-
-button,
-input,
-select,
-textarea {
-  margin: 0;
-  font-size: 100%;
-  vertical-align: middle;
-}
-
-button,
-input {
-  *overflow: visible;
-  line-height: normal;
-}
-
-button::-moz-focus-inner,
-input::-moz-focus-inner {
-  padding: 0;
-  border: 0;
-}
-
-button,
-input[type="button"],
-input[type="reset"],
-input[type="submit"] {
-  cursor: pointer;
-  -webkit-appearance: button;
-}
-
-input[type="search"] {
-  -webkit-box-sizing: content-box;
-     -moz-box-sizing: content-box;
-          box-sizing: content-box;
-  -webkit-appearance: textfield;
-}
-
-input[type="search"]::-webkit-search-decoration,
-input[type="search"]::-webkit-search-cancel-button {
-  -webkit-appearance: none;
-}
-
-textarea {
-  overflow: auto;
-  vertical-align: top;
-}
-
 .clearfix {
   *zoom: 1;
 }
-
 .clearfix:before,
 .clearfix:after {
   display: table;
   content: "";
 }
-
 .clearfix:after {
   clear: both;
 }
-
 .hide-text {
   font: 0/0 a;
   color: transparent;
@@ -144,298 +25,28 @@ textarea {
   background-color: transparent;
   border: 0;
 }
-
 .input-block-level {
   display: block;
   width: 100%;
   min-height: 28px;
   -webkit-box-sizing: border-box;
-     -moz-box-sizing: border-box;
-      -ms-box-sizing: border-box;
-          box-sizing: border-box;
-}
-
-body {
-  margin: 0;
-  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
-  font-size: 13px;
-  line-height: 18px;
-  color: #333333;
-  background-color: #ffffff;
-}
-
-a {
-  color: #0088cc;
-  text-decoration: none;
-}
-
-a:hover {
-  color: #005580;
-  text-decoration: underline;
-}
-
-.row {
-  margin-left: -20px;
-  *zoom: 1;
-}
-
-.row:before,
-.row:after {
-  display: table;
-  content: "";
-}
-
-.row:after {
-  clear: both;
-}
-
-[class*="span"] {
-  float: left;
-  margin-left: 20px;
-}
-
-.container,
-.navbar-fixed-top .container,
-.navbar-fixed-bottom .container {
-  width: 940px;
-}
-
-.span12 {
-  width: 940px;
-}
-
-.span11 {
-  width: 860px;
-}
-
-.span10 {
-  width: 780px;
-}
-
-.span9 {
-  width: 700px;
-}
-
-.span8 {
-  width: 620px;
-}
-
-.span7 {
-  width: 540px;
-}
-
-.span6 {
-  width: 460px;
-}
-
-.span5 {
-  width: 380px;
-}
-
-.span4 {
-  width: 300px;
-}
-
-.span3 {
-  width: 220px;
-}
-
-.span2 {
-  width: 140px;
-}
-
-.span1 {
-  width: 60px;
-}
-
-.offset12 {
-  margin-left: 980px;
-}
-
-.offset11 {
-  margin-left: 900px;
-}
-
-.offset10 {
-  margin-left: 820px;
-}
-
-.offset9 {
-  margin-left: 740px;
-}
-
-.offset8 {
-  margin-left: 660px;
-}
-
-.offset7 {
-  margin-left: 580px;
-}
-
-.offset6 {
-  margin-left: 500px;
-}
-
-.offset5 {
-  margin-left: 420px;
-}
-
-.offset4 {
-  margin-left: 340px;
-}
-
-.offset3 {
-  margin-left: 260px;
-}
-
-.offset2 {
-  margin-left: 180px;
-}
-
-.offset1 {
-  margin-left: 100px;
-}
-
-.row-fluid {
-  width: 100%;
-  *zoom: 1;
-}
-
-.row-fluid:before,
-.row-fluid:after {
-  display: table;
-  content: "";
-}
-
-.row-fluid:after {
-  clear: both;
-}
-
-.row-fluid [class*="span"] {
-  display: block;
-  float: left;
-  width: 100%;
-  min-height: 28px;
-  margin-left: 2.127659574%;
-  *margin-left: 2.0744680846382977%;
-  -webkit-box-sizing: border-box;
-     -moz-box-sizing: border-box;
-      -ms-box-sizing: border-box;
-          box-sizing: border-box;
-}
-
-.row-fluid [class*="span"]:first-child {
-  margin-left: 0;
-}
-
-.row-fluid .span12 {
-  width: 99.99999998999999%;
-  *width: 99.94680850063828%;
-}
-
-.row-fluid .span11 {
-  width: 91.489361693%;
-  *width: 91.4361702036383%;
-}
-
-.row-fluid .span10 {
-  width: 82.97872339599999%;
-  *width: 82.92553190663828%;
-}
-
-.row-fluid .span9 {
-  width: 74.468085099%;
-  *width: 74.4148936096383%;
-}
-
-.row-fluid .span8 {
-  width: 65.95744680199999%;
-  *width: 65.90425531263828%;
-}
-
-.row-fluid .span7 {
-  width: 57.446808505%;
-  *width: 57.3936170156383%;
-}
-
-.row-fluid .span6 {
-  width: 48.93617020799999%;
-  *width: 48.88297871863829%;
-}
-
-.row-fluid .span5 {
-  width: 40.425531911%;
-  *width: 40.3723404216383%;
-}
-
-.row-fluid .span4 {
-  width: 31.914893614%;
-  *width: 31.8617021246383%;
+  -moz-box-sizing: border-box;
+  -ms-box-sizing: border-box;
+  box-sizing: border-box;
 }
-
-.row-fluid .span3 {
-  width: 23.404255317%;
-  *width: 23.3510638276383%;
-}
-
-.row-fluid .span2 {
-  width: 14.89361702%;
-  *width: 14.8404255306383%;
-}
-
-.row-fluid .span1 {
-  width: 6.382978723%;
-  *width: 6.329787233638298%;
-}
-
-.container {
-  margin-right: auto;
-  margin-left: auto;
-  *zoom: 1;
-}
-
-.container:before,
-.container:after {
-  display: table;
-  content: "";
-}
-
-.container:after {
-  clear: both;
-}
-
-.container-fluid {
-  padding-right: 20px;
-  padding-left: 20px;
-  *zoom: 1;
-}
-
-.container-fluid:before,
-.container-fluid:after {
-  display: table;
-  content: "";
-}
-
-.container-fluid:after {
-  clear: both;
-}
-
 p {
   margin: 0 0 9px;
 }
-
 p small {
   font-size: 11px;
   color: #999999;
 }
-
 .lead {
   margin-bottom: 18px;
   font-size: 20px;
   font-weight: 200;
   line-height: 27px;
 }
-
 h1,
 h2,
 h3,
@@ -448,7 +59,6 @@ h6 {
   color: inherit;
   text-rendering: optimizelegibility;
 }
-
 h1 small,
 h2 small,
 h3 small,
@@ -458,183 +68,147 @@ h6 small {
   font-weight: normal;
   color: #999999;
 }
-
 h1 {
   font-size: 30px;
   line-height: 36px;
 }
-
 h1 small {
   font-size: 18px;
 }
-
 h2 {
   font-size: 24px;
   line-height: 36px;
 }
-
 h2 small {
   font-size: 18px;
 }
-
 h3 {
   font-size: 18px;
   line-height: 27px;
 }
-
 h3 small {
   font-size: 14px;
 }
-
 h4,
 h5,
 h6 {
   line-height: 18px;
 }
-
 h4 {
   font-size: 14px;
 }
-
 h4 small {
   font-size: 12px;
 }
-
 h5 {
   font-size: 12px;
 }
-
 h6 {
   font-size: 11px;
   color: #999999;
   text-transform: uppercase;
 }
-
 .page-header {
   padding-bottom: 17px;
   margin: 18px 0;
   border-bottom: 1px solid #eeeeee;
 }
-
 .page-header h1 {
   line-height: 1;
 }
-
 ul,
 ol {
   padding: 0;
   margin: 0 0 9px 25px;
 }
-
 ul ul,
 ul ol,
 ol ol,
 ol ul {
   margin-bottom: 0;
 }
-
 ul {
   list-style: disc;
 }
-
 ol {
   list-style: decimal;
 }
-
-li {
-  /* line-height: 18px; */
-}
-
+/*li {
+  line-height: 18px;
+}*/
 ul.unstyled,
 ol.unstyled {
   margin-left: 0;
   list-style: none;
 }
-
 dl {
   margin-bottom: 18px;
 }
-
 dt,
 dd {
   line-height: 18px;
 }
-
 dt {
   font-weight: bold;
   line-height: 17px;
 }
-
 dd {
   margin-left: 9px;
 }
-
 .dl-horizontal dt {
   float: left;
   width: 120px;
-  overflow: hidden;
   clear: left;
   text-align: right;
+  overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
 }
-
 .dl-horizontal dd {
   margin-left: 130px;
 }
-
 hr {
   margin: 18px 0;
   border: 0;
   border-top: 1px solid #eeeeee;
   border-bottom: 1px solid #ffffff;
 }
-
 strong {
   font-weight: bold;
 }
-
 em {
   font-style: italic;
 }
-
 .muted {
   color: #999999;
 }
-
 abbr[title] {
   cursor: help;
   border-bottom: 1px dotted #999999;
 }
-
 abbr.initialism {
   font-size: 90%;
   text-transform: uppercase;
 }
-
 blockquote {
   padding: 0 0 0 15px;
   margin: 0 0 18px;
   border-left: 5px solid #eeeeee;
 }
-
 blockquote p {
   margin-bottom: 0;
   font-size: 16px;
   font-weight: 300;
   line-height: 22.5px;
 }
-
 blockquote small {
   display: block;
   line-height: 18px;
   color: #999999;
 }
-
 blockquote small:before {
   content: '\2014 \00A0';
 }
-
 blockquote.pull-right {
   float: right;
   padding-right: 15px;
@@ -642,4342 +216,1374 @@ blockquote.pull-right {
   border-right: 5px solid #eeeeee;
   border-left: 0;
 }
-
 blockquote.pull-right p,
 blockquote.pull-right small {
   text-align: right;
 }
-
 q:before,
 q:after,
 blockquote:before,
 blockquote:after {
   content: "";
 }
-
 address {
   display: block;
   margin-bottom: 18px;
   font-style: normal;
   line-height: 18px;
 }
-
 small {
   font-size: 100%;
 }
-
 cite {
   font-style: normal;
 }
-
-code,
-pre {
-  padding: 0 3px 2px;
-  font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
-  font-size: 12px;
-  color: #333333;
+.label,
+.badge {
+  font-size: 10.998px;
+  font-weight: bold;
+  line-height: 14px;
+  color: #ffffff;
+  vertical-align: baseline;
+  white-space: nowrap;
+  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+  background-color: #999999;
+}
+.label {
+  padding: 1px 4px 2px;
   -webkit-border-radius: 3px;
-     -moz-border-radius: 3px;
-          border-radius: 3px;
+  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
-
-code {
-  padding: 2px 4px;
-  color: #d14;
-  background-color: #f7f7f9;
-  border: 1px solid #e1e1e8;
+.badge {
+  padding: 1px 9px 2px;
+  -webkit-border-radius: 9px;
+  -moz-border-radius: 9px;
+  border-radius: 9px;
 }
-
-pre {
-  display: block;
-  padding: 8.5px;
-  margin: 0 0 9px;
-  font-size: 12.025px;
-  line-height: 18px;
-  word-break: break-all;
-  word-wrap: break-word;
-  white-space: pre;
-  white-space: pre-wrap;
-  background-color: #f5f5f5;
-  border: 1px solid #ccc;
-  border: 1px solid rgba(0, 0, 0, 0.15);
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
+a.label:hover,
+a.badge:hover {
+  color: #ffffff;
+  text-decoration: none;
+  cursor: pointer;
 }
-
-pre.prettyprint {
-  margin-bottom: 18px;
+.label-important,
+.badge-important {
+  background-color: #b94a48;
 }
-
-pre code {
-  padding: 0;
-  color: inherit;
-  background-color: transparent;
-  border: 0;
+.label-important[href],
+.badge-important[href] {
+  background-color: #953b39;
 }
-
-.pre-scrollable {
-  max-height: 340px;
-  overflow-y: scroll;
+.label-warning,
+.badge-warning {
+  background-color: #f89406;
 }
-
-form {
-  margin: 0 0 18px;
+.label-warning[href],
+.badge-warning[href] {
+  background-color: #c67605;
 }
-
-fieldset {
-  padding: 0;
-  margin: 0;
-  border: 0;
+.label-success,
+.badge-success {
+  background-color: #468847;
 }
-
-legend {
-  display: block;
-  width: 100%;
-  padding: 0;
-  margin-bottom: 27px;
-  font-size: 19.5px;
-  line-height: 36px;
-  color: #333333;
-  border: 0;
-  border-bottom: 1px solid #e5e5e5;
+.label-success[href],
+.badge-success[href] {
+  background-color: #356635;
 }
-
-legend small {
-  font-size: 13.5px;
-  color: #999999;
+.label-info,
+.badge-info {
+  background-color: #3a87ad;
 }
-
-label,
-input,
-button,
-select,
-textarea {
-  font-size: 13px;
-  font-weight: normal;
-  line-height: 18px;
+.label-info[href],
+.badge-info[href] {
+  background-color: #2d6987;
 }
-
-input,
-button,
-select,
-textarea {
-  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+.label-inverse,
+.badge-inverse {
+  background-color: #333333;
 }
-
-label {
-  display: block;
-  margin-bottom: 5px;
+.label-inverse[href],
+.badge-inverse[href] {
+  background-color: #1a1a1a;
 }
-
-select,
-textarea,
-input[type="text"],
-input[type="password"],
-input[type="datetime"],
-input[type="datetime-local"],
-input[type="date"],
-input[type="month"],
-input[type="time"],
-input[type="week"],
-input[type="number"],
-input[type="email"],
-input[type="url"],
-input[type="search"],
-input[type="tel"],
-input[type="color"],
-.uneditable-input {
-  display: inline-block;
-  height: 18px;
-  padding: 4px;
-  margin-bottom: 9px;
-  font-size: 13px;
-  line-height: 18px;
-  color: #555555;
+table {
+  max-width: 100%;
+  background-color: transparent;
+  border-collapse: collapse;
+  border-spacing: 0;
 }
-
-input,
-textarea {
-  width: 210px;
+.table {
+  width: 100%;
+  margin-bottom: 18px;
 }
-
-textarea {
-  height: auto;
+.table th,
+.table td {
+  padding: 8px;
+  line-height: 18px;
+  text-align: left;
+  vertical-align: top;
+  border-top: 1px solid #dddddd;
 }
-
-textarea,
-input[type="text"],
-input[type="password"],
-input[type="datetime"],
-input[type="datetime-local"],
-input[type="date"],
-input[type="month"],
-input[type="time"],
-input[type="week"],
-input[type="number"],
-input[type="email"],
-input[type="url"],
-input[type="search"],
-input[type="tel"],
-input[type="color"],
-.uneditable-input {
-  background-color: #ffffff;
-  border: 1px solid #cccccc;
-  -webkit-border-radius: 3px;
-     -moz-border-radius: 3px;
-          border-radius: 3px;
-  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-     -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-          box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-  -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
-     -moz-transition: border linear 0.2s, box-shadow linear 0.2s;
-      -ms-transition: border linear 0.2s, box-shadow linear 0.2s;
-       -o-transition: border linear 0.2s, box-shadow linear 0.2s;
-          transition: border linear 0.2s, box-shadow linear 0.2s;
+.table th {
+  font-weight: bold;
 }
-
-textarea:focus,
-input[type="text"]:focus,
-input[type="password"]:focus,
-input[type="datetime"]:focus,
-input[type="datetime-local"]:focus,
-input[type="date"]:focus,
-input[type="month"]:focus,
-input[type="time"]:focus,
-input[type="week"]:focus,
-input[type="number"]:focus,
-input[type="email"]:focus,
-input[type="url"]:focus,
-input[type="search"]:focus,
-input[type="tel"]:focus,
-input[type="color"]:focus,
-.uneditable-input:focus {
-  border-color: rgba(82, 168, 236, 0.8);
-  outline: 0;
-  outline: thin dotted \9;
-  /* IE6-9 */
-
-  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
-     -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
-          box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
+.table thead th {
+  vertical-align: bottom;
 }
-
-input[type="radio"],
-input[type="checkbox"] {
-  margin: 3px 0;
-  *margin-top: 0;
-  /* IE7 */
-
-  line-height: normal;
-  cursor: pointer;
+.table caption + thead tr:first-child th,
+.table caption + thead tr:first-child td,
+.table colgroup + thead tr:first-child th,
+.table colgroup + thead tr:first-child td,
+.table thead:first-child tr:first-child th,
+.table thead:first-child tr:first-child td {
+  border-top: 0;
 }
-
-input[type="submit"],
-input[type="reset"],
-input[type="button"],
-input[type="radio"],
-input[type="checkbox"] {
-  width: auto;
+.table tbody + tbody {
+  border-top: 2px solid #dddddd;
 }
-
-.uneditable-textarea {
-  width: auto;
-  height: auto;
+.table-condensed th,
+.table-condensed td {
+  padding: 4px 5px;
 }
-
-select,
-input[type="file"] {
-  height: 28px;
-  /* In IE7, the height of the select element cannot be changed by height, only font-size */
-
-  *margin-top: 4px;
-  /* For IE7, add top margin to align select with labels */
-
-  line-height: 28px;
-}
-
-select {
-  width: 220px;
-  border: 1px solid #bbb;
-}
-
-select[multiple],
-select[size] {
-  height: auto;
-}
-
-select:focus,
-input[type="file"]:focus,
-input[type="radio"]:focus,
-input[type="checkbox"]:focus {
-  outline: thin dotted #333;
-  outline: 5px auto -webkit-focus-ring-color;
-  outline-offset: -2px;
-}
-
-.radio,
-.checkbox {
-  min-height: 18px;
-  padding-left: 18px;
-}
-
-.radio input[type="radio"],
-.checkbox input[type="checkbox"] {
-  float: left;
-  margin-left: -18px;
-}
-
-.controls > .radio:first-child,
-.controls > .checkbox:first-child {
-  padding-top: 5px;
+.table-bordered {
+  border: 1px solid #dddddd;
+  border-collapse: separate;
+  *border-collapse: collapsed;
+  border-left: 0;
+  -webkit-border-radius: 4px;
+  -moz-border-radius: 4px;
+  border-radius: 4px;
 }
-
-.radio.inline,
-.checkbox.inline {
-  display: inline-block;
-  padding-top: 5px;
-  margin-bottom: 0;
-  vertical-align: middle;
+.table-bordered th,
+.table-bordered td {
+  border-left: 1px solid #dddddd;
 }
-
-.radio.inline + .radio.inline,
-.checkbox.inline + .checkbox.inline {
-  margin-left: 10px;
+.table-bordered caption + thead tr:first-child th,
+.table-bordered caption + tbody tr:first-child th,
+.table-bordered caption + tbody tr:first-child td,
+.table-bordered colgroup + thead tr:first-child th,
+.table-bordered colgroup + tbody tr:first-child th,
+.table-bordered colgroup + tbody tr:first-child td,
+.table-bordered thead:first-child tr:first-child th,
+.table-bordered tbody:first-child tr:first-child th,
+.table-bordered tbody:first-child tr:first-child td {
+  border-top: 0;
 }
-
-.input-mini {
-  width: 60px;
+.table-bordered thead:first-child tr:first-child th:first-child,
+.table-bordered tbody:first-child tr:first-child td:first-child {
+  -webkit-border-top-left-radius: 4px;
+  border-top-left-radius: 4px;
+  -moz-border-radius-topleft: 4px;
 }
-
-.input-small {
-  width: 90px;
+.table-bordered thead:first-child tr:first-child th:last-child,
+.table-bordered tbody:first-child tr:first-child td:last-child {
+  -webkit-border-top-right-radius: 4px;
+  border-top-right-radius: 4px;
+  -moz-border-radius-topright: 4px;
 }
-
-.input-medium {
-  width: 150px;
+.table-bordered thead:last-child tr:last-child th:first-child,
+.table-bordered tbody:last-child tr:last-child td:first-child {
+  -webkit-border-radius: 0 0 0 4px;
+  -moz-border-radius: 0 0 0 4px;
+  border-radius: 0 0 0 4px;
+  -webkit-border-bottom-left-radius: 4px;
+  border-bottom-left-radius: 4px;
+  -moz-border-radius-bottomleft: 4px;
 }
-
-.input-large {
-  width: 210px;
+.table-bordered thead:last-child tr:last-child th:last-child,
+.table-bordered tbody:last-child tr:last-child td:last-child {
+  -webkit-border-bottom-right-radius: 4px;
+  border-bottom-right-radius: 4px;
+  -moz-border-radius-bottomright: 4px;
 }
-
-.input-xlarge {
-  width: 270px;
+.table-striped tbody tr:nth-child(odd) td,
+.table-striped tbody tr:nth-child(odd) th {
+  background-color: #f9f9f9;
 }
-
-.input-xxlarge {
-  width: 530px;
+.table tbody tr:hover td,
+.table tbody tr:hover th {
+  background-color: #f5f5f5;
 }
-
-input[class*="span"],
-select[class*="span"],
-textarea[class*="span"],
-.uneditable-input[class*="span"],
-.row-fluid input[class*="span"],
-.row-fluid select[class*="span"],
-.row-fluid textarea[class*="span"],
-.row-fluid .uneditable-input[class*="span"] {
+table .span1 {
   float: none;
+  width: 44px;
   margin-left: 0;
 }
-
-.input-append input[class*="span"],
-.input-append .uneditable-input[class*="span"],
-.input-prepend input[class*="span"],
-.input-prepend .uneditable-input[class*="span"],
-.row-fluid .input-prepend [class*="span"],
-.row-fluid .input-append [class*="span"] {
-  display: inline-block;
-}
-
-input,
-textarea,
-.uneditable-input {
+table .span2 {
+  float: none;
+  width: 124px;
   margin-left: 0;
 }
-
-input.span12,
-textarea.span12,
-.uneditable-input.span12 {
-  width: 930px;
-}
-
-input.span11,
-textarea.span11,
-.uneditable-input.span11 {
-  width: 850px;
-}
-
-input.span10,
-textarea.span10,
-.uneditable-input.span10 {
-  width: 770px;
+table .span3 {
+  float: none;
+  width: 204px;
+  margin-left: 0;
 }
-
-input.span9,
-textarea.span9,
-.uneditable-input.span9 {
-  width: 690px;
+table .span4 {
+  float: none;
+  width: 284px;
+  margin-left: 0;
 }
-
-input.span8,
-textarea.span8,
-.uneditable-input.span8 {
-  width: 610px;
+table .span5 {
+  float: none;
+  width: 364px;
+  margin-left: 0;
 }
-
-input.span7,
-textarea.span7,
-.uneditable-input.span7 {
-  width: 530px;
+table .span6 {
+  float: none;
+  width: 444px;
+  margin-left: 0;
 }
-
-input.span6,
-textarea.span6,
-.uneditable-input.span6 {
-  width: 450px;
+table .span7 {
+  float: none;
+  width: 524px;
+  margin-left: 0;
 }
-
-input.span5,
-textarea.span5,
-.uneditable-input.span5 {
-  width: 370px;
+table .span8 {
+  float: none;
+  width: 604px;
+  margin-left: 0;
 }
-
-input.span4,
-textarea.span4,
-.uneditable-input.span4 {
-  width: 290px;
+table .span9 {
+  float: none;
+  width: 684px;
+  margin-left: 0;
 }
-
-input.span3,
-textarea.span3,
-.uneditable-input.span3 {
-  width: 210px;
+table .span10 {
+  float: none;
+  width: 764px;
+  margin-left: 0;
 }
-
-input.span2,
-textarea.span2,
-.uneditable-input.span2 {
-  width: 130px;
+table .span11 {
+  float: none;
+  width: 844px;
+  margin-left: 0;
 }
-
-input.span1,
-textarea.span1,
-.uneditable-input.span1 {
-  width: 50px;
+table .span12 {
+  float: none;
+  width: 924px;
+  margin-left: 0;
 }
-
-input[disabled],
-select[disabled],
-textarea[disabled],
-input[readonly],
-select[readonly],
-textarea[readonly] {
-  cursor: not-allowed;
-  background-color: #eeeeee;
-  border-color: #ddd;
+table .span13 {
+  float: none;
+  width: 1004px;
+  margin-left: 0;
 }
-
-input[type="radio"][disabled],
-input[type="checkbox"][disabled],
-input[type="radio"][readonly],
-input[type="checkbox"][readonly] {
-  background-color: transparent;
+table .span14 {
+  float: none;
+  width: 1084px;
+  margin-left: 0;
 }
-
-.control-group.warning > label,
-.control-group.warning .help-block,
-.control-group.warning .help-inline {
-  color: #c09853;
+table .span15 {
+  float: none;
+  width: 1164px;
+  margin-left: 0;
 }
-
-.control-group.warning .checkbox,
-.control-group.warning .radio,
-.control-group.warning input,
-.control-group.warning select,
-.control-group.warning textarea {
-  color: #c09853;
-  border-color: #c09853;
+table .span16 {
+  float: none;
+  width: 1244px;
+  margin-left: 0;
 }
-
-.control-group.warning .checkbox:focus,
-.control-group.warning .radio:focus,
-.control-group.warning input:focus,
-.control-group.warning select:focus,
-.control-group.warning textarea:focus {
-  border-color: #a47e3c;
-  -webkit-box-shadow: 0 0 6px #dbc59e;
-     -moz-box-shadow: 0 0 6px #dbc59e;
-          box-shadow: 0 0 6px #dbc59e;
-}
-
-.control-group.warning .input-prepend .add-on,
-.control-group.warning .input-append .add-on {
-  color: #c09853;
-  background-color: #fcf8e3;
-  border-color: #c09853;
-}
-
-.control-group.error > label,
-.control-group.error .help-block,
-.control-group.error .help-inline {
-  color: #b94a48;
-}
-
-.control-group.error .checkbox,
-.control-group.error .radio,
-.control-group.error input,
-.control-group.error select,
-.control-group.error textarea {
-  color: #b94a48;
-  border-color: #b94a48;
-}
-
-.control-group.error .checkbox:focus,
-.control-group.error .radio:focus,
-.control-group.error input:focus,
-.control-group.error select:focus,
-.control-group.error textarea:focus {
-  border-color: #953b39;
-  -webkit-box-shadow: 0 0 6px #d59392;
-     -moz-box-shadow: 0 0 6px #d59392;
-          box-shadow: 0 0 6px #d59392;
-}
-
-.control-group.error .input-prepend .add-on,
-.control-group.error .input-append .add-on {
-  color: #b94a48;
-  background-color: #f2dede;
-  border-color: #b94a48;
-}
-
-.control-group.success > label,
-.control-group.success .help-block,
-.control-group.success .help-inline {
-  color: #468847;
-}
-
-.control-group.success .checkbox,
-.control-group.success .radio,
-.control-group.success input,
-.control-group.success select,
-.control-group.success textarea {
-  color: #468847;
-  border-color: #468847;
-}
-
-.control-group.success .checkbox:focus,
-.control-group.success .radio:focus,
-.control-group.success input:focus,
-.control-group.success select:focus,
-.control-group.success textarea:focus {
-  border-color: #356635;
-  -webkit-box-shadow: 0 0 6px #7aba7b;
-     -moz-box-shadow: 0 0 6px #7aba7b;
-          box-shadow: 0 0 6px #7aba7b;
-}
-
-.control-group.success .input-prepend .add-on,
-.control-group.success .input-append .add-on {
-  color: #468847;
-  background-color: #dff0d8;
-  border-color: #468847;
-}
-
-input:focus:required:invalid,
-textarea:focus:required:invalid,
-select:focus:required:invalid {
-  color: #b94a48;
-  border-color: #ee5f5b;
-}
-
-input:focus:required:invalid:focus,
-textarea:focus:required:invalid:focus,
-select:focus:required:invalid:focus {
-  border-color: #e9322d;
-  -webkit-box-shadow: 0 0 6px #f8b9b7;
-     -moz-box-shadow: 0 0 6px #f8b9b7;
-          box-shadow: 0 0 6px #f8b9b7;
-}
-
-.form-actions {
-  padding: 17px 20px 18px;
-  margin-top: 18px;
-  margin-bottom: 18px;
-  background-color: #f5f5f5;
-  border-top: 1px solid #e5e5e5;
-  *zoom: 1;
-}
-
-.form-actions:before,
-.form-actions:after {
-  display: table;
-  content: "";
-}
-
-.form-actions:after {
-  clear: both;
-}
-
-.uneditable-input {
-  overflow: hidden;
-  white-space: nowrap;
-  cursor: not-allowed;
-  background-color: #ffffff;
-  border-color: #eee;
-  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
-     -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
-          box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
-}
-
-:-moz-placeholder {
-  color: #999999;
-}
-
-:-ms-input-placeholder {
-  color: #999999;
-}
-
-::-webkit-input-placeholder {
-  color: #999999;
-}
-
-.help-block,
-.help-inline {
-  color: #555555;
-}
-
-.help-block {
-  display: block;
-  margin-bottom: 9px;
-}
-
-.help-inline {
-  display: inline-block;
-  *display: inline;
-  padding-left: 5px;
-  vertical-align: middle;
-  *zoom: 1;
-}
-
-.input-prepend,
-.input-append {
-  margin-bottom: 5px;
-}
-
-.input-prepend input,
-.input-append input,
-.input-prepend select,
-.input-append select,
-.input-prepend .uneditable-input,
-.input-append .uneditable-input {
-  position: relative;
-  margin-bottom: 0;
-  *margin-left: 0;
-  vertical-align: middle;
-  -webkit-border-radius: 0 3px 3px 0;
-     -moz-border-radius: 0 3px 3px 0;
-          border-radius: 0 3px 3px 0;
-}
-
-.input-prepend input:focus,
-.input-append input:focus,
-.input-prepend select:focus,
-.input-append select:focus,
-.input-prepend .uneditable-input:focus,
-.input-append .uneditable-input:focus {
-  z-index: 2;
-}
-
-.input-prepend .uneditable-input,
-.input-append .uneditable-input {
-  border-left-color: #ccc;
-}
-
-.input-prepend .add-on,
-.input-append .add-on {
-  display: inline-block;
-  width: auto;
-  height: 18px;
-  min-width: 16px;
-  padding: 4px 5px;
-  font-weight: normal;
-  line-height: 18px;
-  text-align: center;
-  text-shadow: 0 1px 0 #ffffff;
-  vertical-align: middle;
-  background-color: #eeeeee;
-  border: 1px solid #ccc;
-}
-
-.input-prepend .add-on,
-.input-append .add-on,
-.input-prepend .btn,
-.input-append .btn {
-  margin-left: -1px;
-  -webkit-border-radius: 0;
-     -moz-border-radius: 0;
-          border-radius: 0;
-}
-
-.input-prepend .active,
-.input-append .active {
-  background-color: #a9dba9;
-  border-color: #46a546;
-}
-
-.input-prepend .add-on,
-.input-prepend .btn {
-  margin-right: -1px;
-}
-
-.input-prepend .add-on:first-child,
-.input-prepend .btn:first-child {
-  -webkit-border-radius: 3px 0 0 3px;
-     -moz-border-radius: 3px 0 0 3px;
-          border-radius: 3px 0 0 3px;
-}
-
-.input-append input,
-.input-append select,
-.input-append .uneditable-input {
-  -webkit-border-radius: 3px 0 0 3px;
-     -moz-border-radius: 3px 0 0 3px;
-          border-radius: 3px 0 0 3px;
-}
-
-.input-append .uneditable-input {
-  border-right-color: #ccc;
-  border-left-color: #eee;
-}
-
-.input-append .add-on:last-child,
-.input-append .btn:last-child {
-  -webkit-border-radius: 0 3px 3px 0;
-     -moz-border-radius: 0 3px 3px 0;
-          border-radius: 0 3px 3px 0;
-}
-
-.input-prepend.input-append input,
-.input-prepend.input-append select,
-.input-prepend.input-append .uneditable-input {
-  -webkit-border-radius: 0;
-     -moz-border-radius: 0;
-          border-radius: 0;
-}
-
-.input-prepend.input-append .add-on:first-child,
-.input-prepend.input-append .btn:first-child {
-  margin-right: -1px;
-  -webkit-border-radius: 3px 0 0 3px;
-     -moz-border-radius: 3px 0 0 3px;
-          border-radius: 3px 0 0 3px;
-}
-
-.input-prepend.input-append .add-on:last-child,
-.input-prepend.input-append .btn:last-child {
-  margin-left: -1px;
-  -webkit-border-radius: 0 3px 3px 0;
-     -moz-border-radius: 0 3px 3px 0;
-          border-radius: 0 3px 3px 0;
-}
-
-.search-query {
-  padding-right: 14px;
-  padding-right: 4px \9;
-  padding-left: 14px;
-  padding-left: 4px \9;
-  /* IE7-8 doesn't have border-radius, so don't indent the padding */
-
-  margin-bottom: 0;
-  -webkit-border-radius: 14px;
-     -moz-border-radius: 14px;
-          border-radius: 14px;
-}
-
-.form-search input,
-.form-inline input,
-.form-horizontal input,
-.form-search textarea,
-.form-inline textarea,
-.form-horizontal textarea,
-.form-search select,
-.form-inline select,
-.form-horizontal select,
-.form-search .help-inline,
-.form-inline .help-inline,
-.form-horizontal .help-inline,
-.form-search .uneditable-input,
-.form-inline .uneditable-input,
-.form-horizontal .uneditable-input,
-.form-search .input-prepend,
-.form-inline .input-prepend,
-.form-horizontal .input-prepend,
-.form-search .input-append,
-.form-inline .input-append,
-.form-horizontal .input-append {
-  display: inline-block;
-  *display: inline;
-  margin-bottom: 0;
-  *zoom: 1;
-}
-
-.form-search .hide,
-.form-inline .hide,
-.form-horizontal .hide {
-  display: none;
-}
-
-.form-search label,
-.form-inline label {
-  display: inline-block;
-}
-
-.form-search .input-append,
-.form-inline .input-append,
-.form-search .input-prepend,
-.form-inline .input-prepend {
-  margin-bottom: 0;
-}
-
-.form-search .radio,
-.form-search .checkbox,
-.form-inline .radio,
-.form-inline .checkbox {
-  padding-left: 0;
-  margin-bottom: 0;
-  vertical-align: middle;
-}
-
-.form-search .radio input[type="radio"],
-.form-search .checkbox input[type="checkbox"],
-.form-inline .radio input[type="radio"],
-.form-inline .checkbox input[type="checkbox"] {
-  float: left;
-  margin-right: 3px;
-  margin-left: 0;
-}
-
-.control-group {
-  margin-bottom: 9px;
-}
-
-legend + .control-group {
-  margin-top: 18px;
-  -webkit-margin-top-collapse: separate;
-}
-
-.form-horizontal .control-group {
-  margin-bottom: 18px;
-  *zoom: 1;
-}
-
-.form-horizontal .control-group:before,
-.form-horizontal .control-group:after {
-  display: table;
-  content: "";
-}
-
-.form-horizontal .control-group:after {
-  clear: both;
-}
-
-.form-horizontal .control-label {
-  float: left;
-  width: 140px;
-  padding-top: 5px;
-  text-align: right;
-}
-
-.form-horizontal .controls {
-  *display: inline-block;
-  *padding-left: 20px;
-  margin-left: 160px;
-  *margin-left: 0;
-}
-
-.form-horizontal .controls:first-child {
-  *padding-left: 160px;
-}
-
-.form-horizontal .help-block {
-  margin-top: 9px;
-  margin-bottom: 0;
-}
-
-.form-horizontal .form-actions {
-  padding-left: 160px;
-}
-
-table {
-  max-width: 100%;
-  background-color: transparent;
-  border-collapse: collapse;
-  border-spacing: 0;
-}
-
-.table {
-  width: 100%;
-  margin-bottom: 18px;
-}
-
-.table th,
-.table td {
-  padding: 8px;
-  line-height: 18px;
-  text-align: left;
-  vertical-align: top;
-  border-top: 1px solid #dddddd;
-}
-
-.table th {
-  font-weight: bold;
-}
-
-.table thead th {
-  vertical-align: bottom;
-}
-
-.table caption + thead tr:first-child th,
-.table caption + thead tr:first-child td,
-.table colgroup + thead tr:first-child th,
-.table colgroup + thead tr:first-child td,
-.table thead:first-child tr:first-child th,
-.table thead:first-child tr:first-child td {
-  border-top: 0;
-}
-
-.table tbody + tbody {
-  border-top: 2px solid #dddddd;
-}
-
-.table-condensed th,
-.table-condensed td {
-  padding: 4px 5px;
-}
-
-.table-bordered {
-  border: 1px solid #dddddd;
-  border-collapse: separate;
-  *border-collapse: collapsed;
-  border-left: 0;
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
-}
-
-.table-bordered th,
-.table-bordered td {
-  border-left: 1px solid #dddddd;
-}
-
-.table-bordered caption + thead tr:first-child th,
-.table-bordered caption + tbody tr:first-child th,
-.table-bordered caption + tbody tr:first-child td,
-.table-bordered colgroup + thead tr:first-child th,
-.table-bordered colgroup + tbody tr:first-child th,
-.table-bordered colgroup + tbody tr:first-child td,
-.table-bordered thead:first-child tr:first-child th,
-.table-bordered tbody:first-child tr:first-child th,
-.table-bordered tbody:first-child tr:first-child td {
-  border-top: 0;
-}
-
-.table-bordered thead:first-child tr:first-child th:first-child,
-.table-bordered tbody:first-child tr:first-child td:first-child {
-  -webkit-border-top-left-radius: 4px;
-          border-top-left-radius: 4px;
-  -moz-border-radius-topleft: 4px;
-}
-
-.table-bordered thead:first-child tr:first-child th:last-child,
-.table-bordered tbody:first-child tr:first-child td:last-child {
-  -webkit-border-top-right-radius: 4px;
-          border-top-right-radius: 4px;
-  -moz-border-radius-topright: 4px;
-}
-
-.table-bordered thead:last-child tr:last-child th:first-child,
-.table-bordered tbody:last-child tr:last-child td:first-child {
-  -webkit-border-radius: 0 0 0 4px;
-     -moz-border-radius: 0 0 0 4px;
-          border-radius: 0 0 0 4px;
-  -webkit-border-bottom-left-radius: 4px;
-          border-bottom-left-radius: 4px;
-  -moz-border-radius-bottomleft: 4px;
-}
-
-.table-bordered thead:last-child tr:last-child th:last-child,
-.table-bordered tbody:last-child tr:last-child td:last-child {
-  -webkit-border-bottom-right-radius: 4px;
-          border-bottom-right-radius: 4px;
-  -moz-border-radius-bottomright: 4px;
-}
-
-.table-striped tbody tr:nth-child(odd) td,
-.table-striped tbody tr:nth-child(odd) th {
-  background-color: #f9f9f9;
-}
-
-.table tbody tr:hover td,
-.table tbody tr:hover th {
-  background-color: #f5f5f5;
-}
-
-table .span1 {
-  float: none;
-  width: 44px;
-  margin-left: 0;
-}
-
-table .span2 {
-  float: none;
-  width: 124px;
-  margin-left: 0;
-}
-
-table .span3 {
-  float: none;
-  width: 204px;
-  margin-left: 0;
-}
-
-table .span4 {
-  float: none;
-  width: 284px;
-  margin-left: 0;
-}
-
-table .span5 {
-  float: none;
-  width: 364px;
-  margin-left: 0;
-}
-
-table .span6 {
-  float: none;
-  width: 444px;
-  margin-left: 0;
-}
-
-table .span7 {
-  float: none;
-  width: 524px;
-  margin-left: 0;
-}
-
-table .span8 {
-  float: none;
-  width: 604px;
-  margin-left: 0;
-}
-
-table .span9 {
-  float: none;
-  width: 684px;
-  margin-left: 0;
-}
-
-table .span10 {
-  float: none;
-  width: 764px;
-  margin-left: 0;
-}
-
-table .span11 {
-  float: none;
-  width: 844px;
-  margin-left: 0;
-}
-
-table .span12 {
-  float: none;
-  width: 924px;
-  margin-left: 0;
-}
-
-table .span13 {
-  float: none;
-  width: 1004px;
-  margin-left: 0;
-}
-
-table .span14 {
-  float: none;
-  width: 1084px;
-  margin-left: 0;
-}
-
-table .span15 {
-  float: none;
-  width: 1164px;
-  margin-left: 0;
-}
-
-table .span16 {
-  float: none;
-  width: 1244px;
-  margin-left: 0;
-}
-
-table .span17 {
-  float: none;
-  width: 1324px;
-  margin-left: 0;
-}
-
-table .span18 {
-  float: none;
-  width: 1404px;
-  margin-left: 0;
-}
-
-table .span19 {
-  float: none;
-  width: 1484px;
-  margin-left: 0;
-}
-
-table .span20 {
-  float: none;
-  width: 1564px;
-  margin-left: 0;
-}
-
-table .span21 {
-  float: none;
-  width: 1644px;
-  margin-left: 0;
-}
-
-table .span22 {
-  float: none;
-  width: 1724px;
-  margin-left: 0;
-}
-
-table .span23 {
-  float: none;
-  width: 1804px;
-  margin-left: 0;
-}
-
-table .span24 {
-  float: none;
-  width: 1884px;
-  margin-left: 0;
-}
-
-[class^="icon-"],
-[class*=" icon-"] {
-  display: inline-block;
-  width: 14px;
-  height: 14px;
-  *margin-right: .3em;
-  line-height: 14px;
-  vertical-align: text-top;
-  background-image: url("../img/glyphicons-halflings.png");
-  background-position: 14px 14px;
-  background-repeat: no-repeat;
-}
-
-[class^="icon-"]:last-child,
-[class*=" icon-"]:last-child {
-  *margin-left: 0;
-}
-
-.icon-white {
-  background-image: url("../img/glyphicons-halflings-white.png");
-}
-
-.icon-glass {
-  background-position: 0      0;
-}
-
-.icon-music {
-  background-position: -24px 0;
-}
-
-.icon-search {
-  background-position: -48px 0;
-}
-
-.icon-envelope {
-  background-position: -72px 0;
-}
-
-.icon-heart {
-  background-position: -96px 0;
-}
-
-.icon-star {
-  background-position: -120px 0;
-}
-
-.icon-star-empty {
-  background-position: -144px 0;
-}
-
-.icon-user {
-  background-position: -168px 0;
-}
-
-.icon-film {
-  background-position: -192px 0;
-}
-
-.icon-th-large {
-  background-position: -216px 0;
-}
-
-.icon-th {
-  background-position: -240px 0;
-}
-
-.icon-th-list {
-  background-position: -264px 0;
-}
-
-.icon-ok {
-  background-position: -288px 0;
-}
-
-.icon-remove {
-  background-position: -312px 0;
-}
-
-.icon-zoom-in {
-  background-position: -336px 0;
-}
-
-.icon-zoom-out {
-  background-position: -360px 0;
-}
-
-.icon-off {
-  background-position: -384px 0;
-}
-
-.icon-signal {
-  background-position: -408px 0;
-}
-
-.icon-cog {
-  background-position: -432px 0;
-}
-
-.icon-trash {
-  background-position: -456px 0;
-}
-
-.icon-home {
-  background-position: 0 -24px;
-}
-
-.icon-file {
-  background-position: -24px -24px;
-}
-
-.icon-time {
-  background-position: -48px -24px;
-}
-
-.icon-road {
-  background-position: -72px -24px;
-}
-
-.icon-download-alt {
-  background-position: -96px -24px;
-}
-
-.icon-download {
-  background-position: -120px -24px;
-}
-
-.icon-upload {
-  background-position: -144px -24px;
-}
-
-.icon-inbox {
-  background-position: -168px -24px;
-}
-
-.icon-play-circle {
-  background-position: -192px -24px;
-}
-
-.icon-repeat {
-  background-position: -216px -24px;
-}
-
-.icon-refresh {
-  background-position: -240px -24px;
-}
-
-.icon-list-alt {
-  background-position: -264px -24px;
-}
-
-.icon-lock {
-  background-position: -287px -24px;
-}
-
-.icon-flag {
-  background-position: -312px -24px;
-}
-
-.icon-headphones {
-  background-position: -336px -24px;
-}
-
-.icon-volume-off {
-  background-position: -360px -24px;
-}
-
-.icon-volume-down {
-  background-position: -384px -24px;
-}
-
-.icon-volume-up {
-  background-position: -408px -24px;
-}
-
-.icon-qrcode {
-  background-position: -432px -24px;
-}
-
-.icon-barcode {
-  background-position: -456px -24px;
-}
-
-.icon-tag {
-  background-position: 0 -48px;
-}
-
-.icon-tags {
-  background-position: -25px -48px;
-}
-
-.icon-book {
-  background-position: -48px -48px;
-}
-
-.icon-bookmark {
-  background-position: -72px -48px;
-}
-
-.icon-print {
-  background-position: -96px -48px;
-}
-
-.icon-camera {
-  background-position: -120px -48px;
-}
-
-.icon-font {
-  background-position: -144px -48px;
-}
-
-.icon-bold {
-  background-position: -167px -48px;
-}
-
-.icon-italic {
-  background-position: -192px -48px;
-}
-
-.icon-text-height {
-  background-position: -216px -48px;
-}
-
-.icon-text-width {
-  background-position: -240px -48px;
-}
-
-.icon-align-left {
-  background-position: -264px -48px;
-}
-
-.icon-align-center {
-  background-position: -288px -48px;
-}
-
-.icon-align-right {
-  background-position: -312px -48px;
-}
-
-.icon-align-justify {
-  background-position: -336px -48px;
-}
-
-.icon-list {
-  background-position: -360px -48px;
-}
-
-.icon-indent-left {
-  background-position: -384px -48px;
-}
-
-.icon-indent-right {
-  background-position: -408px -48px;
-}
-
-.icon-facetime-video {
-  background-position: -432px -48px;
-}
-
-.icon-picture {
-  background-position: -456px -48px;
-}
-
-.icon-pencil {
-  background-position: 0 -72px;
-}
-
-.icon-map-marker {
-  background-position: -24px -72px;
-}
-
-.icon-adjust {
-  background-position: -48px -72px;
-}
-
-.icon-tint {
-  background-position: -72px -72px;
-}
-
-.icon-edit {
-  background-position: -96px -72px;
-}
-
-.icon-share {
-  background-position: -120px -72px;
-}
-
-.icon-check {
-  background-position: -144px -72px;
-}
-
-.icon-move {
-  background-position: -168px -72px;
-}
-
-.icon-step-backward {
-  background-position: -192px -72px;
-}
-
-.icon-fast-backward {
-  background-position: -216px -72px;
-}
-
-.icon-backward {
-  background-position: -240px -72px;
-}
-
-.icon-play {
-  background-position: -264px -72px;
-}
-
-.icon-pause {
-  background-position: -288px -72px;
-}
-
-.icon-stop {
-  background-position: -312px -72px;
-}
-
-.icon-forward {
-  background-position: -336px -72px;
-}
-
-.icon-fast-forward {
-  background-position: -360px -72px;
-}
-
-.icon-step-forward {
-  background-position: -384px -72px;
-}
-
-.icon-eject {
-  background-position: -408px -72px;
-}
-
-.icon-chevron-left {
-  background-position: -432px -72px;
-}
-
-.icon-chevron-right {
-  background-position: -456px -72px;
-}
-
-.icon-plus-sign {
-  background-position: 0 -96px;
-}
-
-.icon-minus-sign {
-  background-position: -24px -96px;
-}
-
-.icon-remove-sign {
-  background-position: -48px -96px;
-}
-
-.icon-ok-sign {
-  background-position: -72px -96px;
-}
-
-.icon-question-sign {
-  background-position: -96px -96px;
-}
-
-.icon-info-sign {
-  background-position: -120px -96px;
-}
-
-.icon-screenshot {
-  background-position: -144px -96px;
-}
-
-.icon-remove-circle {
-  background-position: -168px -96px;
-}
-
-.icon-ok-circle {
-  background-position: -192px -96px;
-}
-
-.icon-ban-circle {
-  background-position: -216px -96px;
-}
-
-.icon-arrow-left {
-  background-position: -240px -96px;
-}
-
-.icon-arrow-right {
-  background-position: -264px -96px;
-}
-
-.icon-arrow-up {
-  background-position: -289px -96px;
-}
-
-.icon-arrow-down {
-  background-position: -312px -96px;
-}
-
-.icon-share-alt {
-  background-position: -336px -96px;
-}
-
-.icon-resize-full {
-  background-position: -360px -96px;
-}
-
-.icon-resize-small {
-  background-position: -384px -96px;
-}
-
-.icon-plus {
-  background-position: -408px -96px;
-}
-
-.icon-minus {
-  background-position: -433px -96px;
-}
-
-.icon-asterisk {
-  background-position: -456px -96px;
-}
-
-.icon-exclamation-sign {
-  background-position: 0 -120px;
-}
-
-.icon-gift {
-  background-position: -24px -120px;
-}
-
-.icon-leaf {
-  background-position: -48px -120px;
-}
-
-.icon-fire {
-  background-position: -72px -120px;
-}
-
-.icon-eye-open {
-  background-position: -96px -120px;
-}
-
-.icon-eye-close {
-  background-position: -120px -120px;
-}
-
-.icon-warning-sign {
-  background-position: -144px -120px;
-}
-
-.icon-plane {
-  background-position: -168px -120px;
-}
-
-.icon-calendar {
-  background-position: -192px -120px;
-}
-
-.icon-random {
-  background-position: -216px -120px;
-}
-
-.icon-comment {
-  background-position: -240px -120px;
-}
-
-.icon-magnet {
-  background-position: -264px -120px;
-}
-
-.icon-chevron-up {
-  background-position: -288px -120px;
-}
-
-.icon-chevron-down {
-  background-position: -313px -119px;
-}
-
-.icon-retweet {
-  background-position: -336px -120px;
-}
-
-.icon-shopping-cart {
-  background-position: -360px -120px;
-}
-
-.icon-folder-close {
-  background-position: -384px -120px;
-}
-
-.icon-folder-open {
-  background-position: -408px -120px;
-}
-
-.icon-resize-vertical {
-  background-position: -432px -119px;
-}
-
-.icon-resize-horizontal {
-  background-position: -456px -118px;
-}
-
-.icon-hdd {
-  background-position: 0 -144px;
-}
-
-.icon-bullhorn {
-  background-position: -24px -144px;
-}
-
-.icon-bell {
-  background-position: -48px -144px;
-}
-
-.icon-certificate {
-  background-position: -72px -144px;
-}
-
-.icon-thumbs-up {
-  background-position: -96px -144px;
-}
-
-.icon-thumbs-down {
-  background-position: -120px -144px;
-}
-
-.icon-hand-right {
-  background-position: -144px -144px;
-}
-
-.icon-hand-left {
-  background-position: -168px -144px;
-}
-
-.icon-hand-up {
-  background-position: -192px -144px;
-}
-
-.icon-hand-down {
-  background-position: -216px -144px;
-}
-
-.icon-circle-arrow-right {
-  background-position: -240px -144px;
-}
-
-.icon-circle-arrow-left {
-  background-position: -264px -144px;
-}
-
-.icon-circle-arrow-up {
-  background-position: -288px -144px;
-}
-
-.icon-circle-arrow-down {
-  background-position: -312px -144px;
-}
-
-.icon-globe {
-  background-position: -336px -144px;
-}
-
-.icon-wrench {
-  background-position: -360px -144px;
-}
-
-.icon-tasks {
-  background-position: -384px -144px;
-}
-
-.icon-filter {
-  background-position: -408px -144px;
-}
-
-.icon-briefcase {
-  background-position: -432px -144px;
-}
-
-.icon-fullscreen {
-  background-position: -456px -144px;
-}
-
-.dropup,
-.dropdown {
-  position: relative;
-}
-
-.dropdown-toggle {
-  *margin-bottom: -3px;
-}
-
-.dropdown-toggle:active,
-.open .dropdown-toggle {
-  outline: 0;
-}
-
-.caret {
-  display: inline-block;
-  width: 0;
-  height: 0;
-  vertical-align: top;
-  border-top: 4px solid #000000;
-  border-right: 4px solid transparent;
-  border-left: 4px solid transparent;
-  content: "";
-  opacity: 0.3;
-  filter: alpha(opacity=30);
-}
-
-.dropdown .caret {
-  margin-top: 8px;
-  margin-left: 2px;
-}
-
-.dropdown:hover .caret,
-.open .caret {
-  opacity: 1;
-  filter: alpha(opacity=100);
-}
-
-.dropdown-menu {
-  position: absolute;
-  top: 100%;
-  left: 0;
-  z-index: 1000;
-  display: none;
-  float: left;
-  min-width: 160px;
-  padding: 4px 0;
-  margin: 1px 0 0;
-  list-style: none;
-  background-color: #ffffff;
-  border: 1px solid #ccc;
-  border: 1px solid rgba(0, 0, 0, 0.2);
-  *border-right-width: 2px;
-  *border-bottom-width: 2px;
-  -webkit-border-radius: 5px;
-     -moz-border-radius: 5px;
-          border-radius: 5px;
-  -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-     -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-          box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-  -webkit-background-clip: padding-box;
-     -moz-background-clip: padding;
-          background-clip: padding-box;
-}
-
-.dropdown-menu.pull-right {
-  right: 0;
-  left: auto;
-}
-
-.dropdown-menu .divider {
-  *width: 100%;
-  height: 1px;
-  margin: 8px 1px;
-  *margin: -5px 0 5px;
-  overflow: hidden;
-  background-color: #e5e5e5;
-  border-bottom: 1px solid #ffffff;
-}
-
-.dropdown-menu a {
-  display: block;
-  padding: 3px 15px;
-  clear: both;
-  font-weight: normal;
-  line-height: 18px;
-  color: #333333;
-  white-space: nowrap;
-}
-
-.dropdown-menu li > a:hover,
-.dropdown-menu .active > a,
-.dropdown-menu .active > a:hover {
-  color: #ffffff;
-  text-decoration: none;
-  background-color: #0088cc;
-}
-
-.open {
-  *z-index: 1000;
-}
-
-.open > .dropdown-menu {
-  display: block;
-}
-
-.pull-right > .dropdown-menu {
-  right: 0;
-  left: auto;
-}
-
-.dropup .caret,
-.navbar-fixed-bottom .dropdown .caret {
-  border-top: 0;
-  border-bottom: 4px solid #000000;
-  content: "\2191";
-}
-
-.dropup .dropdown-menu,
-.navbar-fixed-bottom .dropdown .dropdown-menu {
-  top: auto;
-  bottom: 100%;
-  margin-bottom: 1px;
-}
-
-.typeahead {
-  margin-top: 2px;
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
-}
-
-.well {
-  min-height: 20px;
-  padding: 19px;
-  margin-bottom: 20px;
-  background-color: #f5f5f5;
-  border: 1px solid #eee;
-  border: 1px solid rgba(0, 0, 0, 0.05);
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
-  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-     -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-          box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-}
-
-.well blockquote {
-  border-color: #ddd;
-  border-color: rgba(0, 0, 0, 0.15);
-}
-
-.well-large {
-  padding: 24px;
-  -webkit-border-radius: 6px;
-     -moz-border-radius: 6px;
-          border-radius: 6px;
-}
-
-.well-small {
-  padding: 9px;
-  -webkit-border-radius: 3px;
-     -moz-border-radius: 3px;
-          border-radius: 3px;
-}
-
-.fade {
-  opacity: 0;
-  -webkit-transition: opacity 0.15s linear;
-     -moz-transition: opacity 0.15s linear;
-      -ms-transition: opacity 0.15s linear;
-       -o-transition: opacity 0.15s linear;
-          transition: opacity 0.15s linear;
-}
-
-.fade.in {
-  opacity: 1;
-}
-
-.collapse {
-  position: relative;
-  height: 0;
-  overflow: hidden;
-  -webkit-transition: height 0.35s ease;
-     -moz-transition: height 0.35s ease;
-      -ms-transition: height 0.35s ease;
-       -o-transition: height 0.35s ease;
-          transition: height 0.35s ease;
-}
-
-.collapse.in {
-  height: auto;
-}
-
-.close {
-  float: right;
-  font-size: 20px;
-  font-weight: bold;
-  line-height: 18px;
-  color: #000000;
-  text-shadow: 0 1px 0 #ffffff;
-  opacity: 0.2;
-  filter: alpha(opacity=20);
-}
-
-.close:hover {
-  color: #000000;
-  text-decoration: none;
-  cursor: pointer;
-  opacity: 0.4;
-  filter: alpha(opacity=40);
-}
-
-button.close {
-  padding: 0;
-  cursor: pointer;
-  background: transparent;
-  border: 0;
-  -webkit-appearance: none;
-}
-
-.btn {
-  display: inline-block;
-  *display: inline;
-  padding: 4px 10px 4px;
-  margin-bottom: 0;
-  *margin-left: .3em;
-  font-size: 13px;
-  line-height: 18px;
-  *line-height: 20px;
-  color: #333333;
-  text-align: center;
-  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
-  vertical-align: middle;
-  cursor: pointer;
-  background-color: #f5f5f5;
-  *background-color: #e6e6e6;
-  background-image: -ms-linear-gradient(top, #ffffff, #e6e6e6);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
-  background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
-  background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
-  background-image: linear-gradient(top, #ffffff, #e6e6e6);
-  background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
-  background-repeat: repeat-x;
-  border: 1px solid #cccccc;
-  *border: 0;
-  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
-  border-color: #e6e6e6 #e6e6e6 #bfbfbf;
-  border-bottom-color: #b3b3b3;
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0);
-  filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-  *zoom: 1;
-  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-     -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-          box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-}
-
-.btn:hover,
-.btn:active,
-.btn.active,
-.btn.disabled,
-.btn[disabled] {
-  background-color: #e6e6e6;
-  *background-color: #d9d9d9;
-}
-
-.btn:active,
-.btn.active {
-  background-color: #cccccc \9;
-}
-
-.btn:first-child {
-  *margin-left: 0;
-}
-
-.btn:hover {
-  color: #333333;
-  text-decoration: none;
-  background-color: #e6e6e6;
-  *background-color: #d9d9d9;
-  /* Buttons in IE7 don't get borders, so darken on hover */
-
-  background-position: 0 -15px;
-  -webkit-transition: background-position 0.1s linear;
-     -moz-transition: background-position 0.1s linear;
-      -ms-transition: background-position 0.1s linear;
-       -o-transition: background-position 0.1s linear;
-          transition: background-position 0.1s linear;
-}
-
-.btn:focus {
-  outline: thin dotted #333;
-  outline: 5px auto -webkit-focus-ring-color;
-  outline-offset: -2px;
-}
-
-.btn.active,
-.btn:active {
-  background-color: #e6e6e6;
-  background-color: #d9d9d9 \9;
-  background-image: none;
-  outline: 0;
-  -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-     -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-          box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-}
-
-.btn.disabled,
-.btn[disabled] {
-  cursor: default;
-  background-color: #e6e6e6;
-  background-image: none;
-  opacity: 0.65;
-  filter: alpha(opacity=65);
-  -webkit-box-shadow: none;
-     -moz-box-shadow: none;
-          box-shadow: none;
-}
-
-.btn-large {
-  padding: 9px 14px;
-  font-size: 15px;
-  line-height: normal;
-  -webkit-border-radius: 5px;
-     -moz-border-radius: 5px;
-          border-radius: 5px;
-}
-
-.btn-large [class^="icon-"] {
-  margin-top: 1px;
-}
-
-.btn-small {
-  padding: 5px 9px;
-  font-size: 11px;
-  line-height: 16px;
-}
-
-.btn-small [class^="icon-"] {
-  margin-top: -1px;
-}
-
-.btn-mini {
-  padding: 2px 6px;
-  font-size: 11px;
-  line-height: 14px;
-}
-
-.btn-primary,
-.btn-primary:hover,
-.btn-warning,
-.btn-warning:hover,
-.btn-danger,
-.btn-danger:hover,
-.btn-success,
-.btn-success:hover,
-.btn-info,
-.btn-info:hover,
-.btn-inverse,
-.btn-inverse:hover {
-  color: #ffffff;
-  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
-}
-
-.btn-primary.active,
-.btn-warning.active,
-.btn-danger.active,
-.btn-success.active,
-.btn-info.active,
-.btn-inverse.active {
-  color: rgba(255, 255, 255, 0.75);
-}
-
-.btn {
-  border-color: #ccc;
-  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
-}
-
-.btn-primary {
-  background-color: #0074cc;
-  *background-color: #0055cc;
-  background-image: -ms-linear-gradient(top, #0088cc, #0055cc);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0055cc));
-  background-image: -webkit-linear-gradient(top, #0088cc, #0055cc);
-  background-image: -o-linear-gradient(top, #0088cc, #0055cc);
-  background-image: -moz-linear-gradient(top, #0088cc, #0055cc);
-  background-image: linear-gradient(top, #0088cc, #0055cc);
-  background-repeat: repeat-x;
-  border-color: #0055cc #0055cc #003580;
-  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#0088cc', endColorstr='#0055cc', GradientType=0);
-  filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-primary:hover,
-.btn-primary:active,
-.btn-primary.active,
-.btn-primary.disabled,
-.btn-primary[disabled] {
-  background-color: #0055cc;
-  *background-color: #004ab3;
-}
-
-.btn-primary:active,
-.btn-primary.active {
-  background-color: #004099 \9;
-}
-
-.btn-warning {
-  background-color: #faa732;
-  *background-color: #f89406;
-  background-image: -ms-linear-gradient(top, #fbb450, #f89406);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
-  background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
-  background-image: -o-linear-gradient(top, #fbb450, #f89406);
-  background-image: -moz-linear-gradient(top, #fbb450, #f89406);
-  background-image: linear-gradient(top, #fbb450, #f89406);
-  background-repeat: repeat-x;
-  border-color: #f89406 #f89406 #ad6704;
-  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fbb450', endColorstr='#f89406', GradientType=0);
-  filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-warning:hover,
-.btn-warning:active,
-.btn-warning.active,
-.btn-warning.disabled,
-.btn-warning[disabled] {
-  background-color: #f89406;
-  *background-color: #df8505;
-}
-
-.btn-warning:active,
-.btn-warning.active {
-  background-color: #c67605 \9;
-}
-
-.btn-danger {
-  background-color: #da4f49;
-  *background-color: #bd362f;
-  background-image: -ms-linear-gradient(top, #ee5f5b, #bd362f);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f));
-  background-image: -webkit-linear-gradient(top, #ee5f5b, #bd362f);
-  background-image: -o-linear-gradient(top, #ee5f5b, #bd362f);
-  background-image: -moz-linear-gradient(top, #ee5f5b, #bd362f);
-  background-image: linear-gradient(top, #ee5f5b, #bd362f);
-  background-repeat: repeat-x;
-  border-color: #bd362f #bd362f #802420;
-  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ee5f5b', endColorstr='#bd362f', GradientType=0);
-  filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-danger:hover,
-.btn-danger:active,
-.btn-danger.active,
-.btn-danger.disabled,
-.btn-danger[disabled] {
-  background-color: #bd362f;
-  *background-color: #a9302a;
-}
-
-.btn-danger:active,
-.btn-danger.active {
-  background-color: #942a25 \9;
-}
-
-.btn-success {
-  background-color: #5bb75b;
-  *background-color: #51a351;
-  background-image: -ms-linear-gradient(top, #62c462, #51a351);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351));
-  background-image: -webkit-linear-gradient(top, #62c462, #51a351);
-  background-image: -o-linear-gradient(top, #62c462, #51a351);
-  background-image: -moz-linear-gradient(top, #62c462, #51a351);
-  background-image: linear-gradient(top, #62c462, #51a351);
-  background-repeat: repeat-x;
-  border-color: #51a351 #51a351 #387038;
-  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#62c462', endColorstr='#51a351', GradientType=0);
-  filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-success:hover,
-.btn-success:active,
-.btn-success.active,
-.btn-success.disabled,
-.btn-success[disabled] {
-  background-color: #51a351;
-  *background-color: #499249;
-}
-
-.btn-success:active,
-.btn-success.active {
-  background-color: #408140 \9;
-}
-
-.btn-info {
-  background-color: #49afcd;
-  *background-color: #2f96b4;
-  background-image: -ms-linear-gradient(top, #5bc0de, #2f96b4);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4));
-  background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4);
-  background-image: -o-linear-gradient(top, #5bc0de, #2f96b4);
-  background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4);
-  background-image: linear-gradient(top, #5bc0de, #2f96b4);
-  background-repeat: repeat-x;
-  border-color: #2f96b4 #2f96b4 #1f6377;
-  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#5bc0de', endColorstr='#2f96b4', GradientType=0);
-  filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-info:hover,
-.btn-info:active,
-.btn-info.active,
-.btn-info.disabled,
-.btn-info[disabled] {
-  background-color: #2f96b4;
-  *background-color: #2a85a0;
-}
-
-.btn-info:active,
-.btn-info.active {
-  background-color: #24748c \9;
-}
-
-.btn-inverse {
-  background-color: #414141;
-  *background-color: #222222;
-  background-image: -ms-linear-gradient(top, #555555, #222222);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#555555), to(#222222));
-  background-image: -webkit-linear-gradient(top, #555555, #222222);
-  background-image: -o-linear-gradient(top, #555555, #222222);
-  background-image: -moz-linear-gradient(top, #555555, #222222);
-  background-image: linear-gradient(top, #555555, #222222);
-  background-repeat: repeat-x;
-  border-color: #222222 #222222 #000000;
-  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#555555', endColorstr='#222222', GradientType=0);
-  filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-}
-
-.btn-inverse:hover,
-.btn-inverse:active,
-.btn-inverse.active,
-.btn-inverse.disabled,
-.btn-inverse[disabled] {
-  background-color: #222222;
-  *background-color: #151515;
-}
-
-.btn-inverse:active,
-.btn-inverse.active {
-  background-color: #080808 \9;
-}
-
-button.btn,
-input[type="submit"].btn {
-  *padding-top: 2px;
-  *padding-bottom: 2px;
-}
-
-button.btn::-moz-focus-inner,
-input[type="submit"].btn::-moz-focus-inner {
-  padding: 0;
-  border: 0;
-}
-
-button.btn.btn-large,
-input[type="submit"].btn.btn-large {
-  *padding-top: 7px;
-  *padding-bottom: 7px;
-}
-
-button.btn.btn-small,
-input[type="submit"].btn.btn-small {
-  *padding-top: 3px;
-  *padding-bottom: 3px;
-}
-
-button.btn.btn-mini,
-input[type="submit"].btn.btn-mini {
-  *padding-top: 1px;
-  *padding-bottom: 1px;
-}
-
-.btn-group {
-  position: relative;
-  *margin-left: .3em;
-  *zoom: 1;
-}
-
-.btn-group:before,
-.btn-group:after {
-  display: table;
-  content: "";
-}
-
-.btn-group:after {
-  clear: both;
-}
-
-.btn-group:first-child {
-  *margin-left: 0;
-}
-
-.btn-group + .btn-group {
-  margin-left: 5px;
-}
-
-.btn-toolbar {
-  margin-top: 9px;
-  margin-bottom: 9px;
-}
-
-.btn-toolbar .btn-group {
-  display: inline-block;
-  *display: inline;
-  /* IE7 inline-block hack */
-
-  *zoom: 1;
-}
-
-.btn-group > .btn {
-  position: relative;
-  float: left;
-  margin-left: -1px;
-  -webkit-border-radius: 0;
-     -moz-border-radius: 0;
-          border-radius: 0;
-}
-
-.btn-group > .btn:first-child {
-  margin-left: 0;
-  -webkit-border-bottom-left-radius: 4px;
-          border-bottom-left-radius: 4px;
-  -webkit-border-top-left-radius: 4px;
-          border-top-left-radius: 4px;
-  -moz-border-radius-bottomleft: 4px;
-  -moz-border-radius-topleft: 4px;
-}
-
-.btn-group > .btn:last-child,
-.btn-group > .dropdown-toggle {
-  -webkit-border-top-right-radius: 4px;
-          border-top-right-radius: 4px;
-  -webkit-border-bottom-right-radius: 4px;
-          border-bottom-right-radius: 4px;
-  -moz-border-radius-topright: 4px;
-  -moz-border-radius-bottomright: 4px;
-}
-
-.btn-group > .btn.large:first-child {
-  margin-left: 0;
-  -webkit-border-bottom-left-radius: 6px;
-          border-bottom-left-radius: 6px;
-  -webkit-border-top-left-radius: 6px;
-          border-top-left-radius: 6px;
-  -moz-border-radius-bottomleft: 6px;
-  -moz-border-radius-topleft: 6px;
-}
-
-.btn-group > .btn.large:last-child,
-.btn-group > .large.dropdown-toggle {
-  -webkit-border-top-right-radius: 6px;
-          border-top-right-radius: 6px;
-  -webkit-border-bottom-right-radius: 6px;
-          border-bottom-right-radius: 6px;
-  -moz-border-radius-topright: 6px;
-  -moz-border-radius-bottomright: 6px;
-}
-
-.btn-group > .btn:hover,
-.btn-group > .btn:focus,
-.btn-group > .btn:active,
-.btn-group > .btn.active {
-  z-index: 2;
-}
-
-.btn-group .dropdown-toggle:active,
-.btn-group.open .dropdown-toggle {
-  outline: 0;
-}
-
-.btn-group > .dropdown-toggle {
-  *padding-top: 4px;
-  padding-right: 8px;
-  *padding-bottom: 4px;
-  padding-left: 8px;
-  -webkit-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-     -moz-box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-          box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.125), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-}
-
-.btn-group > .btn-mini.dropdown-toggle {
-  padding-right: 5px;
-  padding-left: 5px;
-}
-
-.btn-group > .btn-small.dropdown-toggle {
-  *padding-top: 4px;
-  *padding-bottom: 4px;
-}
-
-.btn-group > .btn-large.dropdown-toggle {
-  padding-right: 12px;
-  padding-left: 12px;
-}
-
-.btn-group.open .dropdown-toggle {
-  background-image: none;
-  -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-     -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-          box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-}
-
-.btn-group.open .btn.dropdown-toggle {
-  background-color: #e6e6e6;
-}
-
-.btn-group.open .btn-primary.dropdown-toggle {
-  background-color: #0055cc;
-}
-
-.btn-group.open .btn-warning.dropdown-toggle {
-  background-color: #f89406;
-}
-
-.btn-group.open .btn-danger.dropdown-toggle {
-  background-color: #bd362f;
-}
-
-.btn-group.open .btn-success.dropdown-toggle {
-  background-color: #51a351;
-}
-
-.btn-group.open .btn-info.dropdown-toggle {
-  background-color: #2f96b4;
-}
-
-.btn-group.open .btn-inverse.dropdown-toggle {
-  background-color: #222222;
-}
-
-.btn .caret {
-  margin-top: 7px;
-  margin-left: 0;
-}
-
-.btn:hover .caret,
-.open.btn-group .caret {
-  opacity: 1;
-  filter: alpha(opacity=100);
-}
-
-.btn-mini .caret {
-  margin-top: 5px;
-}
-
-.btn-small .caret {
-  margin-top: 6px;
-}
-
-.btn-large .caret {
-  margin-top: 6px;
-  border-top-width: 5px;
-  border-right-width: 5px;
-  border-left-width: 5px;
-}
-
-.dropup .btn-large .caret {
-  border-top: 0;
-  border-bottom: 5px solid #000000;
-}
-
-.btn-primary .caret,
-.btn-warning .caret,
-.btn-danger .caret,
-.btn-info .caret,
-.btn-success .caret,
-.btn-inverse .caret {
-  border-top-color: #ffffff;
-  border-bottom-color: #ffffff;
-  opacity: 0.75;
-  filter: alpha(opacity=75);
-}
-
-.alert {
-  padding: 8px 35px 8px 14px;
-  margin-bottom: 18px;
-  color: #c09853;
-  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
-  background-color: #fcf8e3;
-  border: 1px solid #fbeed5;
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
-}
-
-.alert-heading {
-  color: inherit;
-}
-
-.alert .close {
-  position: relative;
-  top: -2px;
-  right: -21px;
-  line-height: 18px;
-}
-
-.alert-success {
-  color: #468847;
-  background-color: #dff0d8;
-  border-color: #d6e9c6;
-}
-
-.alert-danger,
-.alert-error {
-  color: #b94a48;
-  background-color: #f2dede;
-  border-color: #eed3d7;
-}
-
-.alert-info {
-  color: #3a87ad;
-  background-color: #d9edf7;
-  border-color: #bce8f1;
-}
-
-.alert-block {
-  padding-top: 14px;
-  padding-bottom: 14px;
-}
-
-.alert-block > p,
-.alert-block > ul {
-  margin-bottom: 0;
-}
-
-.alert-block p + p {
-  margin-top: 5px;
-}
-
-.nav {
-  margin-bottom: 18px;
-  margin-left: 0;
-  list-style: none;
-}
-
-.nav > li > a {
-  display: block;
-}
-
-.nav > li > a:hover {
-  text-decoration: none;
-  background-color: #eeeeee;
-}
-
-.nav > .pull-right {
-  float: right;
-}
-
-.nav .nav-header {
-  display: block;
-  padding: 3px 15px;
-  font-size: 11px;
-  font-weight: bold;
-  line-height: 18px;
-  color: #999999;
-  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
-  text-transform: uppercase;
-}
-
-.nav li + .nav-header {
-  margin-top: 9px;
-}
-
-.nav-list {
-  padding-right: 15px;
-  padding-left: 15px;
-  margin-bottom: 0;
-}
-
-.nav-list > li > a,
-.nav-list .nav-header {
-  margin-right: -15px;
-  margin-left: -15px;
-  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
-}
-
-.nav-list > li > a {
-  padding: 3px 15px;
-}
-
-.nav-list > .active > a,
-.nav-list > .active > a:hover {
-  color: #ffffff;
-  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
-  background-color: #0088cc;
-}
-
-.nav-list [class^="icon-"] {
-  margin-right: 2px;
-}
-
-.nav-list .divider {
-  *width: 100%;
-  height: 1px;
-  margin: 8px 1px;
-  *margin: -5px 0 5px;
-  overflow: hidden;
-  background-color: #e5e5e5;
-  border-bottom: 1px solid #ffffff;
-}
-
-.nav-tabs,
-.nav-pills {
-  *zoom: 1;
-}
-
-.nav-tabs:before,
-.nav-pills:before,
-.nav-tabs:after,
-.nav-pills:after {
-  display: table;
-  content: "";
-}
-
-.nav-tabs:after,
-.nav-pills:after {
-  clear: both;
-}
-
-.nav-tabs > li,
-.nav-pills > li {
-  float: left;
-}
-
-.nav-tabs > li > a,
-.nav-pills > li > a {
-  padding-right: 12px;
-  padding-left: 12px;
-  margin-right: 2px;
-  line-height: 14px;
-}
-
-.nav-tabs {
-  border-bottom: 1px solid #ddd;
-}
-
-.nav-tabs > li {
-  margin-bottom: -1px;
-}
-
-.nav-tabs > li > a {
-  padding-top: 8px;
-  padding-bottom: 8px;
-  line-height: 18px;
-  border: 1px solid transparent;
-  -webkit-border-radius: 4px 4px 0 0;
-     -moz-border-radius: 4px 4px 0 0;
-          border-radius: 4px 4px 0 0;
-}
-
-.nav-tabs > li > a:hover {
-  border-color: #eeeeee #eeeeee #dddddd;
-}
-
-.nav-tabs > .active > a,
-.nav-tabs > .active > a:hover {
-  color: #555555;
-  cursor: default;
-  background-color: #ffffff;
-  border: 1px solid #ddd;
-  border-bottom-color: transparent;
-}
-
-.nav-pills > li > a {
-  padding-top: 8px;
-  padding-bottom: 8px;
-  margin-top: 2px;
-  margin-bottom: 2px;
-  -webkit-border-radius: 5px;
-     -moz-border-radius: 5px;
-          border-radius: 5px;
-}
-
-.nav-pills > .active > a,
-.nav-pills > .active > a:hover {
-  color: #ffffff;
-  background-color: #0088cc;
-}
-
-.nav-stacked > li {
-  float: none;
-}
-
-.nav-stacked > li > a {
-  margin-right: 0;
-}
-
-.nav-tabs.nav-stacked {
-  border-bottom: 0;
-}
-
-.nav-tabs.nav-stacked > li > a {
-  border: 1px solid #ddd;
-  -webkit-border-radius: 0;
-     -moz-border-radius: 0;
-          border-radius: 0;
-}
-
-.nav-tabs.nav-stacked > li:first-child > a {
-  -webkit-border-radius: 4px 4px 0 0;
-     -moz-border-radius: 4px 4px 0 0;
-          border-radius: 4px 4px 0 0;
-}
-
-.nav-tabs.nav-stacked > li:last-child > a {
-  -webkit-border-radius: 0 0 4px 4px;
-     -moz-border-radius: 0 0 4px 4px;
-          border-radius: 0 0 4px 4px;
-}
-
-.nav-tabs.nav-stacked > li > a:hover {
-  z-index: 2;
-  border-color: #ddd;
-}
-
-.nav-pills.nav-stacked > li > a {
-  margin-bottom: 3px;
-}
-
-.nav-pills.nav-stacked > li:last-child > a {
-  margin-bottom: 1px;
-}
-
-.nav-tabs .dropdown-menu {
-  -webkit-border-radius: 0 0 5px 5px;
-     -moz-border-radius: 0 0 5px 5px;
-          border-radius: 0 0 5px 5px;
-}
-
-.nav-pills .dropdown-menu {
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
-}
-
-.nav-tabs .dropdown-toggle .caret,
-.nav-pills .dropdown-toggle .caret {
-  margin-top: 6px;
-  border-top-color: #0088cc;
-  border-bottom-color: #0088cc;
-}
-
-.nav-tabs .dropdown-toggle:hover .caret,
-.nav-pills .dropdown-toggle:hover .caret {
-  border-top-color: #005580;
-  border-bottom-color: #005580;
-}
-
-.nav-tabs .active .dropdown-toggle .caret,
-.nav-pills .active .dropdown-toggle .caret {
-  border-top-color: #333333;
-  border-bottom-color: #333333;
-}
-
-.nav > .dropdown.active > a:hover {
-  color: #000000;
-  cursor: pointer;
-}
-
-.nav-tabs .open .dropdown-toggle,
-.nav-pills .open .dropdown-toggle,
-.nav > li.dropdown.open.active > a:hover {
-  color: #ffffff;
-  background-color: #999999;
-  border-color: #999999;
-}
-
-.nav li.dropdown.open .caret,
-.nav li.dropdown.open.active .caret,
-.nav li.dropdown.open a:hover .caret {
-  border-top-color: #ffffff;
-  border-bottom-color: #ffffff;
-  opacity: 1;
-  filter: alpha(opacity=100);
-}
-
-.tabs-stacked .open > a:hover {
-  border-color: #999999;
-}
-
-.tabbable {
-  *zoom: 1;
-}
-
-.tabbable:before,
-.tabbable:after {
-  display: table;
-  content: "";
-}
-
-.tabbable:after {
-  clear: both;
-}
-
-.tab-content {
-  overflow: auto;
-}
-
-.tabs-below > .nav-tabs,
-.tabs-right > .nav-tabs,
-.tabs-left > .nav-tabs {
-  border-bottom: 0;
-}
-
-.tab-content > .tab-pane,
-.pill-content > .pill-pane {
-  display: none;
-}
-
-.tab-content > .active,
-.pill-content > .active {
-  display: block;
-}
-
-.tabs-below > .nav-tabs {
-  border-top: 1px solid #ddd;
-}
-
-.tabs-below > .nav-tabs > li {
-  margin-top: -1px;
-  margin-bottom: 0;
-}
-
-.tabs-below > .nav-tabs > li > a {
-  -webkit-border-radius: 0 0 4px 4px;
-     -moz-border-radius: 0 0 4px 4px;
-          border-radius: 0 0 4px 4px;
-}
-
-.tabs-below > .nav-tabs > li > a:hover {
-  border-top-color: #ddd;
-  border-bottom-color: transparent;
-}
-
-.tabs-below > .nav-tabs > .active > a,
-.tabs-below > .nav-tabs > .active > a:hover {
-  border-color: transparent #ddd #ddd #ddd;
-}
-
-.tabs-left > .nav-tabs > li,
-.tabs-right > .nav-tabs > li {
+table .span17 {
   float: none;
+  width: 1324px;
+  margin-left: 0;
 }
-
-.tabs-left > .nav-tabs > li > a,
-.tabs-right > .nav-tabs > li > a {
-  min-width: 74px;
-  margin-right: 0;
-  margin-bottom: 3px;
-}
-
-.tabs-left > .nav-tabs {
-  float: left;
-  margin-right: 19px;
-  border-right: 1px solid #ddd;
-}
-
-.tabs-left > .nav-tabs > li > a {
-  margin-right: -1px;
-  -webkit-border-radius: 4px 0 0 4px;
-     -moz-border-radius: 4px 0 0 4px;
-          border-radius: 4px 0 0 4px;
-}
-
-.tabs-left > .nav-tabs > li > a:hover {
-  border-color: #eeeeee #dddddd #eeeeee #eeeeee;
-}
-
-.tabs-left > .nav-tabs .active > a,
-.tabs-left > .nav-tabs .active > a:hover {
-  border-color: #ddd transparent #ddd #ddd;
-  *border-right-color: #ffffff;
-}
-
-.tabs-right > .nav-tabs {
-  float: right;
-  margin-left: 19px;
-  border-left: 1px solid #ddd;
-}
-
-.tabs-right > .nav-tabs > li > a {
-  margin-left: -1px;
-  -webkit-border-radius: 0 4px 4px 0;
-     -moz-border-radius: 0 4px 4px 0;
-          border-radius: 0 4px 4px 0;
+table .span18 {
+  float: none;
+  width: 1404px;
+  margin-left: 0;
 }
-
-.tabs-right > .nav-tabs > li > a:hover {
-  border-color: #eeeeee #eeeeee #eeeeee #dddddd;
+table .span19 {
+  float: none;
+  width: 1484px;
+  margin-left: 0;
 }
-
-.tabs-right > .nav-tabs .active > a,
-.tabs-right > .nav-tabs .active > a:hover {
-  border-color: #ddd #ddd #ddd transparent;
-  *border-left-color: #ffffff;
+table .span20 {
+  float: none;
+  width: 1564px;
+  margin-left: 0;
 }
-
-.navbar {
-  *position: relative;
-  *z-index: 2;
-  margin-bottom: 18px;
-  overflow: visible;
+table .span21 {
+  float: none;
+  width: 1644px;
+  margin-left: 0;
 }
-
-.navbar-inner {
-  min-height: 40px;
-  padding-right: 20px;
-  padding-left: 20px;
-  background-color: #2c2c2c;
-  background-image: -moz-linear-gradient(top, #333333, #222222);
-  background-image: -ms-linear-gradient(top, #333333, #222222);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#333333), to(#222222));
-  background-image: -webkit-linear-gradient(top, #333333, #222222);
-  background-image: -o-linear-gradient(top, #333333, #222222);
-  background-image: linear-gradient(top, #333333, #222222);
-  background-repeat: repeat-x;
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);
-  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
-     -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
-          box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
+table .span22 {
+  float: none;
+  width: 1724px;
+  margin-left: 0;
 }
-
-.navbar .container {
-  width: auto;
+table .span23 {
+  float: none;
+  width: 1804px;
+  margin-left: 0;
 }
-
-.nav-collapse.collapse {
-  height: auto;
+table .span24 {
+  float: none;
+  width: 1884px;
+  margin-left: 0;
 }
-
-.navbar {
-  color: #999999;
+form {
+  margin: 0 0 18px;
 }
-
-.navbar .brand:hover {
-  text-decoration: none;
+fieldset {
+  padding: 0;
+  margin: 0;
+  border: 0;
 }
-
-.navbar .brand {
+legend {
   display: block;
-  float: left;
-  padding: 8px 20px 12px;
-  margin-left: -20px;
-  font-size: 20px;
-  font-weight: 200;
-  line-height: 1;
+  width: 100%;
+  padding: 0;
+  margin-bottom: 27px;
+  font-size: 19.5px;
+  line-height: 36px;
+  color: #333333;
+  border: 0;
+  border-bottom: 1px solid #e5e5e5;
+}
+legend small {
+  font-size: 13.5px;
   color: #999999;
 }
-
-.navbar .navbar-text {
-  margin-bottom: 0;
-  line-height: 40px;
+label,
+input,
+button,
+select,
+textarea {
+  font-size: 13px;
+  font-weight: normal;
+  line-height: 18px;
 }
-
-.navbar .navbar-link {
-  color: #999999;
+input,
+button,
+select,
+textarea {
+  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
 }
-
-.navbar .navbar-link:hover {
-  color: #ffffff;
+label {
+  display: block;
+  margin-bottom: 5px;
 }
-
-.navbar .btn,
-.navbar .btn-group {
-  margin-top: 5px;
+select,
+textarea,
+input[type="text"],
+input[type="password"],
+input[type="datetime"],
+input[type="datetime-local"],
+input[type="date"],
+input[type="month"],
+input[type="time"],
+input[type="week"],
+input[type="number"],
+input[type="email"],
+input[type="url"],
+input[type="search"],
+input[type="tel"],
+input[type="color"],
+.uneditable-input {
+  display: inline-block;
+  height: 18px;
+  padding: 4px;
+  margin-bottom: 9px;
+  font-size: 13px;
+  line-height: 18px;
+  color: #555555;
 }
-
-.navbar .btn-group .btn {
-  margin: 0;
+input,
+textarea {
+  width: 210px;
 }
-
-.navbar-form {
-  margin-bottom: 0;
-  *zoom: 1;
+textarea {
+  height: auto;
 }
-
-.navbar-form:before,
-.navbar-form:after {
-  display: table;
-  content: "";
+textarea,
+input[type="text"],
+input[type="password"],
+input[type="datetime"],
+input[type="datetime-local"],
+input[type="date"],
+input[type="month"],
+input[type="time"],
+input[type="week"],
+input[type="number"],
+input[type="email"],
+input[type="url"],
+input[type="search"],
+input[type="tel"],
+input[type="color"],
+.uneditable-input {
+  background-color: #ffffff;
+  border: 1px solid #cccccc;
+  -webkit-border-radius: 3px;
+  -moz-border-radius: 3px;
+  border-radius: 3px;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+  -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+  -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
+  -moz-transition: border linear 0.2s, box-shadow linear 0.2s;
+  -ms-transition: border linear 0.2s, box-shadow linear 0.2s;
+  -o-transition: border linear 0.2s, box-shadow linear 0.2s;
+  transition: border linear 0.2s, box-shadow linear 0.2s;
 }
+textarea:focus,
+input[type="text"]:focus,
+input[type="password"]:focus,
+input[type="datetime"]:focus,
+input[type="datetime-local"]:focus,
+input[type="date"]:focus,
+input[type="month"]:focus,
+input[type="time"]:focus,
+input[type="week"]:focus,
+input[type="number"]:focus,
+input[type="email"]:focus,
+input[type="url"]:focus,
+input[type="search"]:focus,
+input[type="tel"]:focus,
+input[type="color"]:focus,
+.uneditable-input:focus {
+  border-color: rgba(82, 168, 236, 0.8);
+  outline: 0;
+  outline: thin dotted \9;
+  /* IE6-9 */
 
-.navbar-form:after {
-  clear: both;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6);
+  -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6);
+  box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(82,168,236,.6);
 }
+input[type="radio"],
+input[type="checkbox"] {
+  margin: 3px 0;
+  *margin-top: 0;
+  /* IE7 */
 
-.navbar-form input,
-.navbar-form select,
-.navbar-form .radio,
-.navbar-form .checkbox {
-  margin-top: 5px;
+  line-height: normal;
+  cursor: pointer;
 }
-
-.navbar-form input,
-.navbar-form select {
-  display: inline-block;
-  margin-bottom: 0;
+input[type="submit"],
+input[type="reset"],
+input[type="button"],
+input[type="radio"],
+input[type="checkbox"] {
+  width: auto;
 }
-
-.navbar-form input[type="image"],
-.navbar-form input[type="checkbox"],
-.navbar-form input[type="radio"] {
-  margin-top: 3px;
+.uneditable-textarea {
+  width: auto;
+  height: auto;
 }
+select,
+input[type="file"] {
+  height: 28px;
+  /* In IE7, the height of the select element cannot be changed by height, only font-size */
 
-.navbar-form .input-append,
-.navbar-form .input-prepend {
-  margin-top: 6px;
-  white-space: nowrap;
-}
+  *margin-top: 4px;
+  /* For IE7, add top margin to align select with labels */
 
-.navbar-form .input-append input,
-.navbar-form .input-prepend input {
-  margin-top: 0;
+  line-height: 28px;
 }
-
-.navbar-search {
-  position: relative;
-  float: left;
-  margin-top: 6px;
-  margin-bottom: 0;
+select {
+  width: 220px;
+  border: 1px solid #bbb;
 }
-
-.navbar-search .search-query {
-  padding: 4px 9px;
-  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
-  font-size: 13px;
-  font-weight: normal;
-  line-height: 1;
-  color: #ffffff;
-  background-color: #626262;
-  border: 1px solid #151515;
-  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);
-     -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);
-          box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.15);
-  -webkit-transition: none;
-     -moz-transition: none;
-      -ms-transition: none;
-       -o-transition: none;
-          transition: none;
+select[multiple],
+select[size] {
+  height: auto;
 }
-
-.navbar-search .search-query:-moz-placeholder {
-  color: #cccccc;
+select:focus,
+input[type="file"]:focus,
+input[type="radio"]:focus,
+input[type="checkbox"]:focus {
+  outline: thin dotted #333;
+  outline: 5px auto -webkit-focus-ring-color;
+  outline-offset: -2px;
 }
-
-.navbar-search .search-query:-ms-input-placeholder {
-  color: #cccccc;
+.radio,
+.checkbox {
+  min-height: 18px;
+  padding-left: 18px;
 }
-
-.navbar-search .search-query::-webkit-input-placeholder {
-  color: #cccccc;
+.radio input[type="radio"],
+.checkbox input[type="checkbox"] {
+  float: left;
+  margin-left: -18px;
 }
-
-.navbar-search .search-query:focus,
-.navbar-search .search-query.focused {
-  padding: 5px 10px;
-  color: #333333;
-  text-shadow: 0 1px 0 #ffffff;
-  background-color: #ffffff;
-  border: 0;
-  outline: 0;
-  -webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
-     -moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
-          box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
+.controls > .radio:first-child,
+.controls > .checkbox:first-child {
+  padding-top: 5px;
 }
-
-.navbar-fixed-top,
-.navbar-fixed-bottom {
-  position: fixed;
-  right: 0;
-  left: 0;
-  z-index: 1030;
+.radio.inline,
+.checkbox.inline {
+  display: inline-block;
+  padding-top: 5px;
   margin-bottom: 0;
+  vertical-align: middle;
 }
-
-.navbar-fixed-top .navbar-inner,
-.navbar-fixed-bottom .navbar-inner {
-  padding-right: 0;
-  padding-left: 0;
-  -webkit-border-radius: 0;
-     -moz-border-radius: 0;
-          border-radius: 0;
+.radio.inline + .radio.inline,
+.checkbox.inline + .checkbox.inline {
+  margin-left: 10px;
 }
-
-.navbar-fixed-top .container,
-.navbar-fixed-bottom .container {
-  width: 940px;
+.input-mini {
+  width: 60px;
 }
-
-.navbar-fixed-top {
-  top: 0;
+.input-small {
+  width: 90px;
 }
-
-.navbar-fixed-bottom {
-  bottom: 0;
+.input-medium {
+  width: 150px;
 }
-
-.navbar .nav {
-  position: relative;
-  left: 0;
-  display: block;
-  float: left;
-  margin: 0 10px 0 0;
+.input-large {
+  width: 210px;
 }
-
-.navbar .nav.pull-right {
-  float: right;
+.input-xlarge {
+  width: 270px;
 }
-
-.navbar .nav > li {
-  display: block;
-  float: left;
+.input-xxlarge {
+  width: 530px;
 }
-
-.navbar .nav > li > a {
+input[class*="span"],
+select[class*="span"],
+textarea[class*="span"],
+.uneditable-input[class*="span"],
+.row-fluid input[class*="span"],
+.row-fluid select[class*="span"],
+.row-fluid textarea[class*="span"],
+.row-fluid .uneditable-input[class*="span"] {
   float: none;
-  padding: 9px 10px 11px;
-  line-height: 19px;
-  color: #999999;
-  text-decoration: none;
-  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+  margin-left: 0;
 }
-
-.navbar .btn {
+.input-append input[class*="span"],
+.input-append .uneditable-input[class*="span"],
+.input-prepend input[class*="span"],
+.input-prepend .uneditable-input[class*="span"],
+.row-fluid .input-prepend [class*="span"],
+.row-fluid .input-append [class*="span"] {
   display: inline-block;
-  padding: 4px 10px 4px;
-  margin: 5px 5px 6px;
-  line-height: 18px;
-}
-
-.navbar .btn-group {
-  padding: 5px 5px 6px;
-  margin: 0;
 }
-
-.navbar .nav > li > a:hover {
-  color: #ffffff;
-  text-decoration: none;
-  background-color: transparent;
-}
-
-.navbar .nav .active > a,
-.navbar .nav .active > a:hover {
-  color: #ffffff;
-  text-decoration: none;
-  background-color: #222222;
+input,
+textarea,
+.uneditable-input {
+  margin-left: 0;
 }
-
-.navbar .divider-vertical {
-  width: 1px;
-  height: 40px;
-  margin: 0 9px;
-  overflow: hidden;
-  background-color: #222222;
-  border-right: 1px solid #333333;
+input.span12, textarea.span12, .uneditable-input.span12 {
+  width: 930px;
 }
-
-.navbar .nav.pull-right {
-  margin-right: 0;
-  margin-left: 10px;
+input.span11, textarea.span11, .uneditable-input.span11 {
+  width: 850px;
 }
-
-.navbar .btn-navbar {
-  display: none;
-  float: right;
-  padding: 7px 10px;
-  margin-right: 5px;
-  margin-left: 5px;
-  background-color: #2c2c2c;
-  *background-color: #222222;
-  background-image: -ms-linear-gradient(top, #333333, #222222);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#333333), to(#222222));
-  background-image: -webkit-linear-gradient(top, #333333, #222222);
-  background-image: -o-linear-gradient(top, #333333, #222222);
-  background-image: linear-gradient(top, #333333, #222222);
-  background-image: -moz-linear-gradient(top, #333333, #222222);
-  background-repeat: repeat-x;
-  border-color: #222222 #222222 #000000;
-  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);
-  filter: progid:dximagetransform.microsoft.gradient(enabled=false);
-  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
-     -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
-          box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.075);
+input.span10, textarea.span10, .uneditable-input.span10 {
+  width: 770px;
 }
-
-.navbar .btn-navbar:hover,
-.navbar .btn-navbar:active,
-.navbar .btn-navbar.active,
-.navbar .btn-navbar.disabled,
-.navbar .btn-navbar[disabled] {
-  background-color: #222222;
-  *background-color: #151515;
+input.span9, textarea.span9, .uneditable-input.span9 {
+  width: 690px;
 }
-
-.navbar .btn-navbar:active,
-.navbar .btn-navbar.active {
-  background-color: #080808 \9;
+input.span8, textarea.span8, .uneditable-input.span8 {
+  width: 610px;
 }
-
-.navbar .btn-navbar .icon-bar {
-  display: block;
-  width: 18px;
-  height: 2px;
-  background-color: #f5f5f5;
-  -webkit-border-radius: 1px;
-     -moz-border-radius: 1px;
-          border-radius: 1px;
-  -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
-     -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
-          box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
+input.span7, textarea.span7, .uneditable-input.span7 {
+  width: 530px;
 }
-
-.btn-navbar .icon-bar + .icon-bar {
-  margin-top: 3px;
+input.span6, textarea.span6, .uneditable-input.span6 {
+  width: 450px;
 }
-
-.navbar .dropdown-menu:before {
-  position: absolute;
-  top: -7px;
-  left: 9px;
-  display: inline-block;
-  border-right: 7px solid transparent;
-  border-bottom: 7px solid #ccc;
-  border-left: 7px solid transparent;
-  border-bottom-color: rgba(0, 0, 0, 0.2);
-  content: '';
+input.span5, textarea.span5, .uneditable-input.span5 {
+  width: 370px;
 }
-
-.navbar .dropdown-menu:after {
-  position: absolute;
-  top: -6px;
-  left: 10px;
-  display: inline-block;
-  border-right: 6px solid transparent;
-  border-bottom: 6px solid #ffffff;
-  border-left: 6px solid transparent;
-  content: '';
+input.span4, textarea.span4, .uneditable-input.span4 {
+  width: 290px;
 }
-
-.navbar-fixed-bottom .dropdown-menu:before {
-  top: auto;
-  bottom: -7px;
-  border-top: 7px solid #ccc;
-  border-bottom: 0;
-  border-top-color: rgba(0, 0, 0, 0.2);
+input.span3, textarea.span3, .uneditable-input.span3 {
+  width: 210px;
 }
-
-.navbar-fixed-bottom .dropdown-menu:after {
-  top: auto;
-  bottom: -6px;
-  border-top: 6px solid #ffffff;
-  border-bottom: 0;
+input.span2, textarea.span2, .uneditable-input.span2 {
+  width: 130px;
 }
-
-.navbar .nav li.dropdown .dropdown-toggle .caret,
-.navbar .nav li.dropdown.open .caret {
-  border-top-color: #ffffff;
-  border-bottom-color: #ffffff;
+input.span1, textarea.span1, .uneditable-input.span1 {
+  width: 50px;
 }
-
-.navbar .nav li.dropdown.active .caret {
-  opacity: 1;
-  filter: alpha(opacity=100);
+input[disabled],
+select[disabled],
+textarea[disabled],
+input[readonly],
+select[readonly],
+textarea[readonly] {
+  cursor: not-allowed;
+  background-color: #eeeeee;
+  border-color: #ddd;
 }
-
-.navbar .nav li.dropdown.open > .dropdown-toggle,
-.navbar .nav li.dropdown.active > .dropdown-toggle,
-.navbar .nav li.dropdown.open.active > .dropdown-toggle {
+input[type="radio"][disabled],
+input[type="checkbox"][disabled],
+input[type="radio"][readonly],
+input[type="checkbox"][readonly] {
   background-color: transparent;
 }
-
-.navbar .nav li.dropdown.active > .dropdown-toggle:hover {
-  color: #ffffff;
-}
-
-.navbar .pull-right .dropdown-menu,
-.navbar .dropdown-menu.pull-right {
-  right: 0;
-  left: auto;
-}
-
-.navbar .pull-right .dropdown-menu:before,
-.navbar .dropdown-menu.pull-right:before {
-  right: 12px;
-  left: auto;
-}
-
-.navbar .pull-right .dropdown-menu:after,
-.navbar .dropdown-menu.pull-right:after {
-  right: 13px;
-  left: auto;
-}
-
-.breadcrumb {
-  padding: 7px 14px;
-  margin: 0 0 18px;
-  list-style: none;
-  background-color: #fbfbfb;
-  background-image: -moz-linear-gradient(top, #ffffff, #f5f5f5);
-  background-image: -ms-linear-gradient(top, #ffffff, #f5f5f5);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#f5f5f5));
-  background-image: -webkit-linear-gradient(top, #ffffff, #f5f5f5);
-  background-image: -o-linear-gradient(top, #ffffff, #f5f5f5);
-  background-image: linear-gradient(top, #ffffff, #f5f5f5);
-  background-repeat: repeat-x;
-  border: 1px solid #ddd;
-  -webkit-border-radius: 3px;
-     -moz-border-radius: 3px;
-          border-radius: 3px;
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff', endColorstr='#f5f5f5', GradientType=0);
-  -webkit-box-shadow: inset 0 1px 0 #ffffff;
-     -moz-box-shadow: inset 0 1px 0 #ffffff;
-          box-shadow: inset 0 1px 0 #ffffff;
-}
-
-.breadcrumb li {
-  display: inline-block;
-  *display: inline;
-  text-shadow: 0 1px 0 #ffffff;
-  *zoom: 1;
+.control-group.warning > label,
+.control-group.warning .help-block,
+.control-group.warning .help-inline {
+  color: #c09853;
 }
-
-.breadcrumb .divider {
-  padding: 0 5px;
-  color: #999999;
+.control-group.warning .checkbox,
+.control-group.warning .radio,
+.control-group.warning input,
+.control-group.warning select,
+.control-group.warning textarea {
+  color: #c09853;
+  border-color: #c09853;
 }
-
-.breadcrumb .active a {
-  color: #333333;
+.control-group.warning .checkbox:focus,
+.control-group.warning .radio:focus,
+.control-group.warning input:focus,
+.control-group.warning select:focus,
+.control-group.warning textarea:focus {
+  border-color: #a47e3c;
+  -webkit-box-shadow: 0 0 6px #dbc59e;
+  -moz-box-shadow: 0 0 6px #dbc59e;
+  box-shadow: 0 0 6px #dbc59e;
 }
-
-.pagination {
-  height: 36px;
-  margin: 18px 0;
+.control-group.warning .input-prepend .add-on,
+.control-group.warning .input-append .add-on {
+  color: #c09853;
+  background-color: #fcf8e3;
+  border-color: #c09853;
 }
-
-.pagination ul {
-  display: inline-block;
-  *display: inline;
-  margin-bottom: 0;
-  margin-left: 0;
-  -webkit-border-radius: 3px;
-     -moz-border-radius: 3px;
-          border-radius: 3px;
-  *zoom: 1;
-  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
-     -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
-          box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+.control-group.error > label,
+.control-group.error .help-block,
+.control-group.error .help-inline {
+  color: #b94a48;
 }
-
-.pagination li {
-  display: inline;
+.control-group.error .checkbox,
+.control-group.error .radio,
+.control-group.error input,
+.control-group.error select,
+.control-group.error textarea {
+  color: #b94a48;
+  border-color: #b94a48;
 }
-
-.pagination a {
-  float: left;
-  padding: 0 14px;
-  line-height: 34px;
-  text-decoration: none;
-  border: 1px solid #ddd;
-  border-left-width: 0;
+.control-group.error .checkbox:focus,
+.control-group.error .radio:focus,
+.control-group.error input:focus,
+.control-group.error select:focus,
+.control-group.error textarea:focus {
+  border-color: #953b39;
+  -webkit-box-shadow: 0 0 6px #d59392;
+  -moz-box-shadow: 0 0 6px #d59392;
+  box-shadow: 0 0 6px #d59392;
 }
-
-.pagination a:hover,
-.pagination .active a {
-  background-color: #f5f5f5;
+.control-group.error .input-prepend .add-on,
+.control-group.error .input-append .add-on {
+  color: #b94a48;
+  background-color: #f2dede;
+  border-color: #b94a48;
 }
-
-.pagination .active a {
-  color: #999999;
-  cursor: default;
+.control-group.success > label,
+.control-group.success .help-block,
+.control-group.success .help-inline {
+  color: #468847;
 }
-
-.pagination .disabled span,
-.pagination .disabled a,
-.pagination .disabled a:hover {
-  color: #999999;
-  cursor: default;
-  background-color: transparent;
+.control-group.success .checkbox,
+.control-group.success .radio,
+.control-group.success input,
+.control-group.success select,
+.control-group.success textarea {
+  color: #468847;
+  border-color: #468847;
 }
-
-.pagination li:first-child a {
-  border-left-width: 1px;
-  -webkit-border-radius: 3px 0 0 3px;
-     -moz-border-radius: 3px 0 0 3px;
-          border-radius: 3px 0 0 3px;
+.control-group.success .checkbox:focus,
+.control-group.success .radio:focus,
+.control-group.success input:focus,
+.control-group.success select:focus,
+.control-group.success textarea:focus {
+  border-color: #356635;
+  -webkit-box-shadow: 0 0 6px #7aba7b;
+  -moz-box-shadow: 0 0 6px #7aba7b;
+  box-shadow: 0 0 6px #7aba7b;
 }
-
-.pagination li:last-child a {
-  -webkit-border-radius: 0 3px 3px 0;
-     -moz-border-radius: 0 3px 3px 0;
-          border-radius: 0 3px 3px 0;
+.control-group.success .input-prepend .add-on,
+.control-group.success .input-append .add-on {
+  color: #468847;
+  background-color: #dff0d8;
+  border-color: #468847;
 }
-
-.pagination-centered {
-  text-align: center;
+input:focus:required:invalid,
+textarea:focus:required:invalid,
+select:focus:required:invalid {
+  color: #b94a48;
+  border-color: #ee5f5b;
 }
-
-.pagination-right {
-  text-align: right;
+input:focus:required:invalid:focus,
+textarea:focus:required:invalid:focus,
+select:focus:required:invalid:focus {
+  border-color: #e9322d;
+  -webkit-box-shadow: 0 0 6px #f8b9b7;
+  -moz-box-shadow: 0 0 6px #f8b9b7;
+  box-shadow: 0 0 6px #f8b9b7;
 }
-
-.pager {
+.form-actions {
+  padding: 17px 20px 18px;
+  margin-top: 18px;
   margin-bottom: 18px;
-  margin-left: 0;
-  text-align: center;
-  list-style: none;
+  background-color: #f5f5f5;
+  border-top: 1px solid #e5e5e5;
   *zoom: 1;
 }
-
-.pager:before,
-.pager:after {
+.form-actions:before,
+.form-actions:after {
   display: table;
   content: "";
 }
-
-.pager:after {
+.form-actions:after {
   clear: both;
 }
-
-.pager li {
-  display: inline;
+.uneditable-input {
+  overflow: hidden;
+  white-space: nowrap;
+  cursor: not-allowed;
+  background-color: #ffffff;
+  border-color: #eee;
+  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
+  -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
+  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.025);
 }
-
-.pager a {
-  display: inline-block;
-  padding: 5px 14px;
-  background-color: #fff;
-  border: 1px solid #ddd;
-  -webkit-border-radius: 15px;
-     -moz-border-radius: 15px;
-          border-radius: 15px;
+:-moz-placeholder {
+  color: #999999;
 }
-
-.pager a:hover {
-  text-decoration: none;
-  background-color: #f5f5f5;
+:-ms-input-placeholder {
+  color: #999999;
 }
-
-.pager .next a {
-  float: right;
+::-webkit-input-placeholder {
+  color: #999999;
 }
-
-.pager .previous a {
-  float: left;
+.help-block,
+.help-inline {
+  color: #555555;
 }
-
-.pager .disabled a,
-.pager .disabled a:hover {
-  color: #999999;
-  cursor: default;
-  background-color: #fff;
+.help-block {
+  display: block;
+  margin-bottom: 9px;
 }
+.help-inline {
+  display: inline-block;
+  *display: inline;
+  /* IE7 inline-block hack */
 
-.modal-open .dropdown-menu {
-  z-index: 2050;
+  *zoom: 1;
+  vertical-align: middle;
+  padding-left: 5px;
 }
-
-.modal-open .dropdown.open {
-  *z-index: 2050;
+.input-prepend,
+.input-append {
+  margin-bottom: 5px;
 }
-
-.modal-open .popover {
-  z-index: 2060;
+.input-prepend input,
+.input-append input,
+.input-prepend select,
+.input-append select,
+.input-prepend .uneditable-input,
+.input-append .uneditable-input {
+  position: relative;
+  margin-bottom: 0;
+  *margin-left: 0;
+  vertical-align: middle;
+  -webkit-border-radius: 0 3px 3px 0;
+  -moz-border-radius: 0 3px 3px 0;
+  border-radius: 0 3px 3px 0;
 }
-
-.modal-open .tooltip {
-  z-index: 2070;
+.input-prepend input:focus,
+.input-append input:focus,
+.input-prepend select:focus,
+.input-append select:focus,
+.input-prepend .uneditable-input:focus,
+.input-append .uneditable-input:focus {
+  z-index: 2;
 }
-
-.modal-backdrop {
-  position: fixed;
-  top: 0;
-  right: 0;
-  bottom: 0;
-  left: 0;
-  z-index: 1040;
-  background-color: #000000;
+.input-prepend .uneditable-input,
+.input-append .uneditable-input {
+  border-left-color: #ccc;
 }
-
-.modal-backdrop.fade {
-  opacity: 0;
+.input-prepend .add-on,
+.input-append .add-on {
+  display: inline-block;
+  width: auto;
+  height: 18px;
+  min-width: 16px;
+  padding: 4px 5px;
+  font-weight: normal;
+  line-height: 18px;
+  text-align: center;
+  text-shadow: 0 1px 0 #ffffff;
+  vertical-align: middle;
+  background-color: #eeeeee;
+  border: 1px solid #ccc;
 }
-
-.modal-backdrop,
-.modal-backdrop.fade.in {
-  opacity: 0.8;
-  filter: alpha(opacity=80);
+.input-prepend .add-on,
+.input-append .add-on,
+.input-prepend .btn,
+.input-append .btn {
+  margin-left: -1px;
+  -webkit-border-radius: 0;
+  -moz-border-radius: 0;
+  border-radius: 0;
 }
-
-.modal {
-  position: fixed;
-  top: 50%;
-  left: 50%;
-  z-index: 1050;
-  width: 560px;
-  margin: -250px 0 0 -280px;
-  overflow: auto;
-  background-color: #ffffff;
-  border: 1px solid #999;
-  border: 1px solid rgba(0, 0, 0, 0.3);
-  *border: 1px solid #999;
-  -webkit-border-radius: 6px;
-     -moz-border-radius: 6px;
-          border-radius: 6px;
-  -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
-     -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
-          box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
-  -webkit-background-clip: padding-box;
-     -moz-background-clip: padding-box;
-          background-clip: padding-box;
+.input-prepend .active,
+.input-append .active {
+  background-color: #a9dba9;
+  border-color: #46a546;
 }
-
-.modal.fade {
-  top: -25%;
-  -webkit-transition: opacity 0.3s linear, top 0.3s ease-out;
-     -moz-transition: opacity 0.3s linear, top 0.3s ease-out;
-      -ms-transition: opacity 0.3s linear, top 0.3s ease-out;
-       -o-transition: opacity 0.3s linear, top 0.3s ease-out;
-          transition: opacity 0.3s linear, top 0.3s ease-out;
+.input-prepend .add-on,
+.input-prepend .btn {
+  margin-right: -1px;
 }
-
-.modal.fade.in {
-  top: 50%;
+.input-prepend .add-on:first-child,
+.input-prepend .btn:first-child {
+  -webkit-border-radius: 3px 0 0 3px;
+  -moz-border-radius: 3px 0 0 3px;
+  border-radius: 3px 0 0 3px;
 }
-
-.modal-header {
-  padding: 9px 15px;
-  border-bottom: 1px solid #eee;
+.input-append input,
+.input-append select,
+.input-append .uneditable-input {
+  -webkit-border-radius: 3px 0 0 3px;
+  -moz-border-radius: 3px 0 0 3px;
+  border-radius: 3px 0 0 3px;
 }
-
-.modal-header .close {
-  margin-top: 2px;
+.input-append .uneditable-input {
+  border-right-color: #ccc;
+  border-left-color: #eee;
 }
-
-.modal-body {
-  max-height: 400px;
-  padding: 15px;
-  overflow-y: auto;
+.input-append .add-on:last-child,
+.input-append .btn:last-child {
+  -webkit-border-radius: 0 3px 3px 0;
+  -moz-border-radius: 0 3px 3px 0;
+  border-radius: 0 3px 3px 0;
 }
-
-.modal-form {
-  margin-bottom: 0;
+.input-prepend.input-append input,
+.input-prepend.input-append select,
+.input-prepend.input-append .uneditable-input {
+  -webkit-border-radius: 0;
+  -moz-border-radius: 0;
+  border-radius: 0;
 }
-
-.modal-footer {
-  padding: 14px 15px 15px;
-  margin-bottom: 0;
-  text-align: right;
-  background-color: #f5f5f5;
-  border-top: 1px solid #ddd;
-  -webkit-border-radius: 0 0 6px 6px;
-     -moz-border-radius: 0 0 6px 6px;
-          border-radius: 0 0 6px 6px;
-  *zoom: 1;
-  -webkit-box-shadow: inset 0 1px 0 #ffffff;
-     -moz-box-shadow: inset 0 1px 0 #ffffff;
-          box-shadow: inset 0 1px 0 #ffffff;
+.input-prepend.input-append .add-on:first-child,
+.input-prepend.input-append .btn:first-child {
+  margin-right: -1px;
+  -webkit-border-radius: 3px 0 0 3px;
+  -moz-border-radius: 3px 0 0 3px;
+  border-radius: 3px 0 0 3px;
 }
-
-.modal-footer:before,
-.modal-footer:after {
-  display: table;
-  content: "";
+.input-prepend.input-append .add-on:last-child,
+.input-prepend.input-append .btn:last-child {
+  margin-left: -1px;
+  -webkit-border-radius: 0 3px 3px 0;
+  -moz-border-radius: 0 3px 3px 0;
+  border-radius: 0 3px 3px 0;
 }
+.search-query {
+  padding-right: 14px;
+  padding-right: 4px \9;
+  padding-left: 14px;
+  padding-left: 4px \9;
+  /* IE7-8 doesn't have border-radius, so don't indent the padding */
 
-.modal-footer:after {
-  clear: both;
+  margin-bottom: 0;
+  -webkit-border-radius: 14px;
+  -moz-border-radius: 14px;
+  border-radius: 14px;
 }
+.form-search input,
+.form-inline input,
+.form-horizontal input,
+.form-search textarea,
+.form-inline textarea,
+.form-horizontal textarea,
+.form-search select,
+.form-inline select,
+.form-horizontal select,
+.form-search .help-inline,
+.form-inline .help-inline,
+.form-horizontal .help-inline,
+.form-search .uneditable-input,
+.form-inline .uneditable-input,
+.form-horizontal .uneditable-input,
+.form-search .input-prepend,
+.form-inline .input-prepend,
+.form-horizontal .input-prepend,
+.form-search .input-append,
+.form-inline .input-append,
+.form-horizontal .input-append {
+  display: inline-block;
+  *display: inline;
+  /* IE7 inline-block hack */
 
-.modal-footer .btn + .btn {
+  *zoom: 1;
   margin-bottom: 0;
-  margin-left: 5px;
 }
-
-.modal-footer .btn-group .btn + .btn {
-  margin-left: -1px;
+.form-search .hide,
+.form-inline .hide,
+.form-horizontal .hide {
+  display: none;
 }
-
-.tooltip {
-  position: absolute;
-  z-index: 1020;
-  display: block;
-  padding: 5px;
-  font-size: 11px;
-  opacity: 0;
-  filter: alpha(opacity=0);
-  visibility: visible;
+.form-search label,
+.form-inline label {
+  display: inline-block;
 }
-
-.tooltip.in {
-  opacity: 0.8;
-  filter: alpha(opacity=80);
+.form-search .input-append,
+.form-inline .input-append,
+.form-search .input-prepend,
+.form-inline .input-prepend {
+  margin-bottom: 0;
 }
-
-.tooltip.top {
-  margin-top: -2px;
+.form-search .radio,
+.form-search .checkbox,
+.form-inline .radio,
+.form-inline .checkbox {
+  padding-left: 0;
+  margin-bottom: 0;
+  vertical-align: middle;
 }
-
-.tooltip.right {
-  margin-left: 2px;
+.form-search .radio input[type="radio"],
+.form-search .checkbox input[type="checkbox"],
+.form-inline .radio input[type="radio"],
+.form-inline .checkbox input[type="checkbox"] {
+  float: left;
+  margin-right: 3px;
+  margin-left: 0;
 }
-
-.tooltip.bottom {
-  margin-top: 2px;
+.control-group {
+  margin-bottom: 9px;
 }
-
-.tooltip.left {
-  margin-left: -2px;
+legend + .control-group {
+  margin-top: 18px;
+  -webkit-margin-top-collapse: separate;
 }
-
-.tooltip.top .tooltip-arrow {
-  bottom: 0;
-  left: 50%;
-  margin-left: -5px;
-  border-top: 5px solid #000000;
-  border-right: 5px solid transparent;
-  border-left: 5px solid transparent;
+.form-horizontal .control-group {
+  margin-bottom: 18px;
+  *zoom: 1;
 }
-
-.tooltip.left .tooltip-arrow {
-  top: 50%;
-  right: 0;
-  margin-top: -5px;
-  border-top: 5px solid transparent;
-  border-bottom: 5px solid transparent;
-  border-left: 5px solid #000000;
+.form-horizontal .control-group:before,
+.form-horizontal .control-group:after {
+  display: table;
+  content: "";
 }
-
-.tooltip.bottom .tooltip-arrow {
-  top: 0;
-  left: 50%;
-  margin-left: -5px;
-  border-right: 5px solid transparent;
-  border-bottom: 5px solid #000000;
-  border-left: 5px solid transparent;
+.form-horizontal .control-group:after {
+  clear: both;
 }
-
-.tooltip.right .tooltip-arrow {
-  top: 50%;
-  left: 0;
-  margin-top: -5px;
-  border-top: 5px solid transparent;
-  border-right: 5px solid #000000;
-  border-bottom: 5px solid transparent;
+.form-horizontal .control-label {
+  float: left;
+  width: 140px;
+  padding-top: 5px;
+  text-align: right;
 }
-
-.tooltip-inner {
-  max-width: 200px;
-  padding: 3px 8px;
-  color: #ffffff;
-  text-align: center;
-  text-decoration: none;
-  background-color: #000000;
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
+.form-horizontal .controls {
+  *display: inline-block;
+  *padding-left: 20px;
+  margin-left: 160px;
+  *margin-left: 0;
 }
-
-.tooltip-arrow {
-  position: absolute;
-  width: 0;
-  height: 0;
+.form-horizontal .controls:first-child {
+  *padding-left: 160px;
 }
-
-.popover {
-  position: absolute;
-  top: 0;
-  left: 0;
-  z-index: 1010;
-  display: none;
-  padding: 5px;
+.form-horizontal .help-block {
+  margin-top: 9px;
+  margin-bottom: 0;
 }
-
-.popover.top {
-  margin-top: -5px;
+.form-horizontal .form-actions {
+  padding-left: 160px;
 }
-
-.popover.right {
-  margin-left: 5px;
+.nav {
+  margin-left: 0;
+  margin-bottom: 18px;
+  list-style: none;
 }
-
-.popover.bottom {
-  margin-top: 5px;
+.nav > li > a {
+  display: block;
 }
-
-.popover.left {
-  margin-left: -5px;
+.nav > li > a:hover {
+  text-decoration: none;
+  background-color: #eeeeee;
 }
-
-.popover.top .arrow {
-  bottom: 0;
-  left: 50%;
-  margin-left: -5px;
-  border-top: 5px solid #000000;
-  border-right: 5px solid transparent;
-  border-left: 5px solid transparent;
+.nav > .pull-right {
+  float: right;
 }
-
-.popover.right .arrow {
-  top: 50%;
-  left: 0;
-  margin-top: -5px;
-  border-top: 5px solid transparent;
-  border-right: 5px solid #000000;
-  border-bottom: 5px solid transparent;
+.nav .nav-header {
+  display: block;
+  padding: 3px 15px;
+  font-size: 11px;
+  font-weight: bold;
+  line-height: 18px;
+  color: #999999;
+  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
+  text-transform: uppercase;
 }
-
-.popover.bottom .arrow {
-  top: 0;
-  left: 50%;
-  margin-left: -5px;
-  border-right: 5px solid transparent;
-  border-bottom: 5px solid #000000;
-  border-left: 5px solid transparent;
+.nav li + .nav-header {
+  margin-top: 9px;
 }
-
-.popover.left .arrow {
-  top: 50%;
-  right: 0;
-  margin-top: -5px;
-  border-top: 5px solid transparent;
-  border-bottom: 5px solid transparent;
-  border-left: 5px solid #000000;
+.nav-list {
+  padding-left: 15px;
+  padding-right: 15px;
+  margin-bottom: 0;
 }
-
-.popover .arrow {
-  position: absolute;
-  width: 0;
-  height: 0;
+.nav-list > li > a,
+.nav-list .nav-header {
+  margin-left: -15px;
+  margin-right: -15px;
+  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
 }
-
-.popover-inner {
-  width: 280px;
-  padding: 3px;
-  overflow: hidden;
-  background: #000000;
-  background: rgba(0, 0, 0, 0.8);
-  -webkit-border-radius: 6px;
-     -moz-border-radius: 6px;
-          border-radius: 6px;
-  -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
-     -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
-          box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
+.nav-list > li > a {
+  padding: 3px 15px;
 }
-
-.popover-title {
-  padding: 9px 15px;
-  line-height: 1;
-  background-color: #f5f5f5;
-  border-bottom: 1px solid #eee;
-  -webkit-border-radius: 3px 3px 0 0;
-     -moz-border-radius: 3px 3px 0 0;
-          border-radius: 3px 3px 0 0;
+.nav-list > .active > a,
+.nav-list > .active > a:hover {
+  color: #ffffff;
+  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
+  background-color: #0088cc;
 }
-
-.popover-content {
-  padding: 14px;
-  background-color: #ffffff;
-  -webkit-border-radius: 0 0 3px 3px;
-     -moz-border-radius: 0 0 3px 3px;
-          border-radius: 0 0 3px 3px;
-  -webkit-background-clip: padding-box;
-     -moz-background-clip: padding-box;
-          background-clip: padding-box;
+.nav-list [class^="icon-"] {
+  margin-right: 2px;
 }
-
-.popover-content p,
-.popover-content ul,
-.popover-content ol {
-  margin-bottom: 0;
+.nav-list .divider {
+  *width: 100%;
+  height: 1px;
+  margin: 8px 1px;
+  *margin: -5px 0 5px;
+  overflow: hidden;
+  background-color: #e5e5e5;
+  border-bottom: 1px solid #ffffff;
 }
-
-.thumbnails {
-  margin-left: -20px;
-  list-style: none;
+.nav-tabs,
+.nav-pills {
   *zoom: 1;
 }
-
-.thumbnails:before,
-.thumbnails:after {
+.nav-tabs:before,
+.nav-pills:before,
+.nav-tabs:after,
+.nav-pills:after {
   display: table;
   content: "";
 }
-
-.thumbnails:after {
+.nav-tabs:after,
+.nav-pills:after {
   clear: both;
 }
-
-.row-fluid .thumbnails {
-  margin-left: 0;
-}
-
-.thumbnails > li {
+.nav-tabs > li,
+.nav-pills > li {
   float: left;
-  margin-bottom: 18px;
-  margin-left: 20px;
-}
-
-.thumbnail {
-  display: block;
-  padding: 4px;
-  line-height: 1;
-  border: 1px solid #ddd;
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
-  -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075);
-     -moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075);
-          box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075);
-}
-
-a.thumbnail:hover {
-  border-color: #0088cc;
-  -webkit-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
-     -moz-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
-          box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
-}
-
-.thumbnail > img {
-  display: block;
-  max-width: 100%;
-  margin-right: auto;
-  margin-left: auto;
 }
-
-.thumbnail .caption {
-  padding: 9px;
-}
-
-.label,
-.badge {
-  font-size: 10.998px;
-  font-weight: bold;
+.nav-tabs > li > a,
+.nav-pills > li > a {
+  padding-right: 12px;
+  padding-left: 12px;
+  margin-right: 2px;
   line-height: 14px;
-  color: #ffffff;
-  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
-  white-space: nowrap;
-  vertical-align: baseline;
-  background-color: #999999;
-}
-
-.label {
-  padding: 1px 4px 2px;
-  -webkit-border-radius: 3px;
-     -moz-border-radius: 3px;
-          border-radius: 3px;
 }
-
-.badge {
-  padding: 1px 9px 2px;
-  -webkit-border-radius: 9px;
-     -moz-border-radius: 9px;
-          border-radius: 9px;
+.nav-tabs {
+  border-bottom: 1px solid #ddd;
 }
-
-a.label:hover,
-a.badge:hover {
-  color: #ffffff;
-  text-decoration: none;
-  cursor: pointer;
+.nav-tabs > li {
+  margin-bottom: -1px;
 }
-
-.label-important,
-.badge-important {
-  background-color: #b94a48;
+.nav-tabs > li > a {
+  padding-top: 8px;
+  padding-bottom: 8px;
+  line-height: 18px;
+  border: 1px solid transparent;
+  -webkit-border-radius: 4px 4px 0 0;
+  -moz-border-radius: 4px 4px 0 0;
+  border-radius: 4px 4px 0 0;
 }
-
-.label-important[href],
-.badge-important[href] {
-  background-color: #953b39;
+.nav-tabs > li > a:hover {
+  border-color: #eeeeee #eeeeee #dddddd;
 }
-
-.label-warning,
-.badge-warning {
-  background-color: #f89406;
+.nav-tabs > .active > a,
+.nav-tabs > .active > a:hover {
+  color: #555555;
+  background-color: #ffffff;
+  border: 1px solid #ddd;
+  border-bottom-color: transparent;
+  cursor: default;
 }
-
-.label-warning[href],
-.badge-warning[href] {
-  background-color: #c67605;
+.nav-pills > li > a {
+  padding-top: 8px;
+  padding-bottom: 8px;
+  margin-top: 2px;
+  margin-bottom: 2px;
+  -webkit-border-radius: 5px;
+  -moz-border-radius: 5px;
+  border-radius: 5px;
 }
-
-.label-success,
-.badge-success {
-  background-color: #468847;
+.nav-pills > .active > a,
+.nav-pills > .active > a:hover {
+  color: #ffffff;
+  background-color: #0088cc;
 }
-
-.label-success[href],
-.badge-success[href] {
-  background-color: #356635;
+.nav-stacked > li {
+  float: none;
 }
-
-.label-info,
-.badge-info {
-  background-color: #3a87ad;
+.nav-stacked > li > a {
+  margin-right: 0;
 }
-
-.label-info[href],
-.badge-info[href] {
-  background-color: #2d6987;
+.nav-tabs.nav-stacked {
+  border-bottom: 0;
 }
-
-.label-inverse,
-.badge-inverse {
-  background-color: #333333;
+.nav-tabs.nav-stacked > li > a {
+  border: 1px solid #ddd;
+  -webkit-border-radius: 0;
+  -moz-border-radius: 0;
+  border-radius: 0;
 }
-
-.label-inverse[href],
-.badge-inverse[href] {
-  background-color: #1a1a1a;
+.nav-tabs.nav-stacked > li:first-child > a {
+  -webkit-border-radius: 4px 4px 0 0;
+  -moz-border-radius: 4px 4px 0 0;
+  border-radius: 4px 4px 0 0;
 }
-
-@-webkit-keyframes progress-bar-stripes {
-  from {
-    background-position: 40px 0;
-  }
-  to {
-    background-position: 0 0;
-  }
+.nav-tabs.nav-stacked > li:last-child > a {
+  -webkit-border-radius: 0 0 4px 4px;
+  -moz-border-radius: 0 0 4px 4px;
+  border-radius: 0 0 4px 4px;
 }
-
-@-moz-keyframes progress-bar-stripes {
-  from {
-    background-position: 40px 0;
-  }
-  to {
-    background-position: 0 0;
-  }
+.nav-tabs.nav-stacked > li > a:hover {
+  border-color: #ddd;
+  z-index: 2;
 }
-
-@-ms-keyframes progress-bar-stripes {
-  from {
-    background-position: 40px 0;
-  }
-  to {
-    background-position: 0 0;
-  }
+.nav-pills.nav-stacked > li > a {
+  margin-bottom: 3px;
 }
-
-@-o-keyframes progress-bar-stripes {
-  from {
-    background-position: 0 0;
-  }
-  to {
-    background-position: 40px 0;
-  }
+.nav-pills.nav-stacked > li:last-child > a {
+  margin-bottom: 1px;
 }
-
-@keyframes progress-bar-stripes {
-  from {
-    background-position: 40px 0;
-  }
-  to {
-    background-position: 0 0;
-  }
+.nav-tabs .dropdown-menu {
+  -webkit-border-radius: 0 0 5px 5px;
+  -moz-border-radius: 0 0 5px 5px;
+  border-radius: 0 0 5px 5px;
 }
-
-.progress {
-  height: 18px;
-  margin-bottom: 18px;
-  overflow: hidden;
-  background-color: #f7f7f7;
-  background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9);
-  background-image: -ms-linear-gradient(top, #f5f5f5, #f9f9f9);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));
-  background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9);
-  background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9);
-  background-image: linear-gradient(top, #f5f5f5, #f9f9f9);
-  background-repeat: repeat-x;
+.nav-pills .dropdown-menu {
   -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#f5f5f5', endColorstr='#f9f9f9', GradientType=0);
-  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
-     -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
-          box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
-}
-
-.progress .bar {
-  width: 0;
-  height: 18px;
-  font-size: 12px;
-  color: #ffffff;
-  text-align: center;
-  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
-  background-color: #0e90d2;
-  background-image: -moz-linear-gradient(top, #149bdf, #0480be);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be));
-  background-image: -webkit-linear-gradient(top, #149bdf, #0480be);
-  background-image: -o-linear-gradient(top, #149bdf, #0480be);
-  background-image: linear-gradient(top, #149bdf, #0480be);
-  background-image: -ms-linear-gradient(top, #149bdf, #0480be);
-  background-repeat: repeat-x;
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#149bdf', endColorstr='#0480be', GradientType=0);
-  -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
-     -moz-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
-          box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15);
-  -webkit-box-sizing: border-box;
-     -moz-box-sizing: border-box;
-      -ms-box-sizing: border-box;
-          box-sizing: border-box;
-  -webkit-transition: width 0.6s ease;
-     -moz-transition: width 0.6s ease;
-      -ms-transition: width 0.6s ease;
-       -o-transition: width 0.6s ease;
-          transition: width 0.6s ease;
-}
-
-.progress-striped .bar {
-  background-color: #149bdf;
-  background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
-  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  -webkit-background-size: 40px 40px;
-     -moz-background-size: 40px 40px;
-       -o-background-size: 40px 40px;
-          background-size: 40px 40px;
+  -moz-border-radius: 4px;
+  border-radius: 4px;
 }
-
-.progress.active .bar {
-  -webkit-animation: progress-bar-stripes 2s linear infinite;
-     -moz-animation: progress-bar-stripes 2s linear infinite;
-      -ms-animation: progress-bar-stripes 2s linear infinite;
-       -o-animation: progress-bar-stripes 2s linear infinite;
-          animation: progress-bar-stripes 2s linear infinite;
+.nav-tabs .dropdown-toggle .caret,
+.nav-pills .dropdown-toggle .caret {
+  border-top-color: #0088cc;
+  border-bottom-color: #0088cc;
+  margin-top: 6px;
 }
-
-.progress-danger .bar {
-  background-color: #dd514c;
-  background-image: -moz-linear-gradient(top, #ee5f5b, #c43c35);
-  background-image: -ms-linear-gradient(top, #ee5f5b, #c43c35);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35));
-  background-image: -webkit-linear-gradient(top, #ee5f5b, #c43c35);
-  background-image: -o-linear-gradient(top, #ee5f5b, #c43c35);
-  background-image: linear-gradient(top, #ee5f5b, #c43c35);
-  background-repeat: repeat-x;
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ee5f5b', endColorstr='#c43c35', GradientType=0);
+.nav-tabs .dropdown-toggle:hover .caret,
+.nav-pills .dropdown-toggle:hover .caret {
+  border-top-color: #005580;
+  border-bottom-color: #005580;
 }
-
-.progress-danger.progress-striped .bar {
-  background-color: #ee5f5b;
-  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
-  background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+.nav-tabs .active .dropdown-toggle .caret,
+.nav-pills .active .dropdown-toggle .caret {
+  border-top-color: #333333;
+  border-bottom-color: #333333;
 }
-
-.progress-success .bar {
-  background-color: #5eb95e;
-  background-image: -moz-linear-gradient(top, #62c462, #57a957);
-  background-image: -ms-linear-gradient(top, #62c462, #57a957);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957));
-  background-image: -webkit-linear-gradient(top, #62c462, #57a957);
-  background-image: -o-linear-gradient(top, #62c462, #57a957);
-  background-image: linear-gradient(top, #62c462, #57a957);
-  background-repeat: repeat-x;
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#62c462', endColorstr='#57a957', GradientType=0);
+.nav > .dropdown.active > a:hover {
+  color: #000000;
+  cursor: pointer;
 }
-
-.progress-success.progress-striped .bar {
-  background-color: #62c462;
-  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
-  background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+.nav-tabs .open .dropdown-toggle,
+.nav-pills .open .dropdown-toggle,
+.nav > li.dropdown.open.active > a:hover {
+  color: #ffffff;
+  background-color: #999999;
+  border-color: #999999;
 }
-
-.progress-info .bar {
-  background-color: #4bb1cf;
-  background-image: -moz-linear-gradient(top, #5bc0de, #339bb9);
-  background-image: -ms-linear-gradient(top, #5bc0de, #339bb9);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9));
-  background-image: -webkit-linear-gradient(top, #5bc0de, #339bb9);
-  background-image: -o-linear-gradient(top, #5bc0de, #339bb9);
-  background-image: linear-gradient(top, #5bc0de, #339bb9);
-  background-repeat: repeat-x;
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#5bc0de', endColorstr='#339bb9', GradientType=0);
+.nav li.dropdown.open .caret,
+.nav li.dropdown.open.active .caret,
+.nav li.dropdown.open a:hover .caret {
+  border-top-color: #ffffff;
+  border-bottom-color: #ffffff;
+  opacity: 1;
+  filter: alpha(opacity=100);
 }
-
-.progress-info.progress-striped .bar {
-  background-color: #5bc0de;
-  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
-  background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+.tabs-stacked .open > a:hover {
+  border-color: #999999;
 }
-
-.progress-warning .bar {
-  background-color: #faa732;
-  background-image: -moz-linear-gradient(top, #fbb450, #f89406);
-  background-image: -ms-linear-gradient(top, #fbb450, #f89406);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));
-  background-image: -webkit-linear-gradient(top, #fbb450, #f89406);
-  background-image: -o-linear-gradient(top, #fbb450, #f89406);
-  background-image: linear-gradient(top, #fbb450, #f89406);
-  background-repeat: repeat-x;
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#fbb450', endColorstr='#f89406', GradientType=0);
+.tabbable {
+  *zoom: 1;
 }
-
-.progress-warning.progress-striped .bar {
-  background-color: #fbb450;
-  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));
-  background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: -o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+.tabbable:before,
+.tabbable:after {
+  display: table;
+  content: "";
 }
-
-.accordion {
-  margin-bottom: 18px;
+.tabbable:after {
+  clear: both;
 }
-
-.accordion-group {
-  margin-bottom: 2px;
-  border: 1px solid #e5e5e5;
-  -webkit-border-radius: 4px;
-     -moz-border-radius: 4px;
-          border-radius: 4px;
+.tab-content {
+  overflow: auto;
 }
-
-.accordion-heading {
+.tabs-below > .nav-tabs,
+.tabs-right > .nav-tabs,
+.tabs-left > .nav-tabs {
   border-bottom: 0;
 }
-
-.accordion-heading .accordion-toggle {
+.tab-content > .tab-pane,
+.pill-content > .pill-pane {
+  display: none;
+}
+.tab-content > .active,
+.pill-content > .active {
   display: block;
-  padding: 8px 15px;
 }
-
-.accordion-toggle {
-  cursor: pointer;
+.tabs-below > .nav-tabs {
+  border-top: 1px solid #ddd;
 }
-
-.accordion-inner {
-  padding: 9px 15px;
-  border-top: 1px solid #e5e5e5;
+.tabs-below > .nav-tabs > li {
+  margin-top: -1px;
+  margin-bottom: 0;
 }
-
-.carousel {
-  position: relative;
-  margin-bottom: 18px;
-  line-height: 1;
+.tabs-below > .nav-tabs > li > a {
+  -webkit-border-radius: 0 0 4px 4px;
+  -moz-border-radius: 0 0 4px 4px;
+  border-radius: 0 0 4px 4px;
 }
-
-.carousel-inner {
-  position: relative;
-  width: 100%;
-  overflow: hidden;
+.tabs-below > .nav-tabs > li > a:hover {
+  border-bottom-color: transparent;
+  border-top-color: #ddd;
 }
-
-.carousel .item {
-  position: relative;
-  display: none;
-  -webkit-transition: 0.6s ease-in-out left;
-     -moz-transition: 0.6s ease-in-out left;
-      -ms-transition: 0.6s ease-in-out left;
-       -o-transition: 0.6s ease-in-out left;
-          transition: 0.6s ease-in-out left;
+.tabs-below > .nav-tabs > .active > a,
+.tabs-below > .nav-tabs > .active > a:hover {
+  border-color: transparent #ddd #ddd #ddd;
 }
-
-.carousel .item > img {
-  display: block;
-  line-height: 1;
+.tabs-left > .nav-tabs > li,
+.tabs-right > .nav-tabs > li {
+  float: none;
 }
-
-.carousel .active,
-.carousel .next,
-.carousel .prev {
-  display: block;
+.tabs-left > .nav-tabs > li > a,
+.tabs-right > .nav-tabs > li > a {
+  min-width: 74px;
+  margin-right: 0;
+  margin-bottom: 3px;
 }
-
-.carousel .active {
-  left: 0;
+.tabs-left > .nav-tabs {
+  float: left;
+  margin-right: 19px;
+  border-right: 1px solid #ddd;
 }
-
-.carousel .next,
-.carousel .prev {
-  position: absolute;
-  top: 0;
-  width: 100%;
+.tabs-left > .nav-tabs > li > a {
+  margin-right: -1px;
+  -webkit-border-radius: 4px 0 0 4px;
+  -moz-border-radius: 4px 0 0 4px;
+  border-radius: 4px 0 0 4px;
 }
-
-.carousel .next {
-  left: 100%;
+.tabs-left > .nav-tabs > li > a:hover {
+  border-color: #eeeeee #dddddd #eeeeee #eeeeee;
 }
-
-.carousel .prev {
-  left: -100%;
+.tabs-left > .nav-tabs .active > a,
+.tabs-left > .nav-tabs .active > a:hover {
+  border-color: #ddd transparent #ddd #ddd;
+  *border-right-color: #ffffff;
 }
-
-.carousel .next.left,
-.carousel .prev.right {
-  left: 0;
+.tabs-right > .nav-tabs {
+  float: right;
+  margin-left: 19px;
+  border-left: 1px solid #ddd;
 }
-
-.carousel .active.left {
-  left: -100%;
+.tabs-right > .nav-tabs > li > a {
+  margin-left: -1px;
+  -webkit-border-radius: 0 4px 4px 0;
+  -moz-border-radius: 0 4px 4px 0;
+  border-radius: 0 4px 4px 0;
 }
-
-.carousel .active.right {
-  left: 100%;
+.tabs-right > .nav-tabs > li > a:hover {
+  border-color: #eeeeee #eeeeee #eeeeee #dddddd;
 }
-
-.carousel-control {
-  position: absolute;
-  top: 40%;
-  left: 15px;
-  width: 40px;
-  height: 40px;
-  margin-top: -20px;
-  font-size: 60px;
-  font-weight: 100;
-  line-height: 30px;
-  color: #ffffff;
-  text-align: center;
-  background: #222222;
-  border: 3px solid #ffffff;
-  -webkit-border-radius: 23px;
-     -moz-border-radius: 23px;
-          border-radius: 23px;
-  opacity: 0.5;
-  filter: alpha(opacity=50);
+.tabs-right > .nav-tabs .active > a,
+.tabs-right > .nav-tabs .active > a:hover {
+  border-color: #ddd #ddd #ddd transparent;
+  *border-left-color: #ffffff;
 }
-
-.carousel-control.right {
-  right: 15px;
-  left: auto;
+.pagination {
+  height: 36px;
+  margin: 18px 0;
 }
+.pagination ul {
+  display: inline-block;
+  *display: inline;
+  /* IE7 inline-block hack */
 
-.carousel-control:hover {
-  color: #ffffff;
+  *zoom: 1;
+  margin-left: 0;
+  margin-bottom: 0;
+  -webkit-border-radius: 3px;
+  -moz-border-radius: 3px;
+  border-radius: 3px;
+  -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+  -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+}
+.pagination li {
+  display: inline;
+}
+.pagination a {
+  float: left;
+  padding: 0 14px;
+  line-height: 34px;
   text-decoration: none;
-  opacity: 0.9;
-  filter: alpha(opacity=90);
+  border: 1px solid #ddd;
+  border-left-width: 0;
 }
-
-.carousel-caption {
-  position: absolute;
-  right: 0;
-  bottom: 0;
-  left: 0;
-  padding: 10px 15px 5px;
-  background: #333333;
-  background: rgba(0, 0, 0, 0.75);
+.pagination a:hover,
+.pagination .active a {
+  background-color: #f5f5f5;
 }
-
-.carousel-caption h4,
-.carousel-caption p {
-  color: #ffffff;
+.pagination .active a {
+  color: #999999;
+  cursor: default;
 }
-
-.hero-unit {
-  padding: 60px;
-  margin-bottom: 30px;
-  background-color: #eeeeee;
-  -webkit-border-radius: 6px;
-     -moz-border-radius: 6px;
-          border-radius: 6px;
+.pagination .disabled span,
+.pagination .disabled a,
+.pagination .disabled a:hover {
+  color: #999999;
+  background-color: transparent;
+  cursor: default;
 }
-
-.hero-unit h1 {
-  margin-bottom: 0;
-  font-size: 60px;
-  line-height: 1;
-  letter-spacing: -1px;
-  color: inherit;
+.pagination li:first-child a {
+  border-left-width: 1px;
+  -webkit-border-radius: 3px 0 0 3px;
+  -moz-border-radius: 3px 0 0 3px;
+  border-radius: 3px 0 0 3px;
 }
-
-.hero-unit p {
-  font-size: 18px;
-  font-weight: 200;
-  line-height: 27px;
-  color: inherit;
+.pagination li:last-child a {
+  -webkit-border-radius: 0 3px 3px 0;
+  -moz-border-radius: 0 3px 3px 0;
+  border-radius: 0 3px 3px 0;
 }
-
-.pull-right {
-  float: right;
+.pagination-centered {
+  text-align: center;
 }
-
-.pull-left {
-  float: left;
+.pagination-right {
+  text-align: right;
 }
-
-.hide {
-  display: none;
+.well {
+  min-height: 20px;
+  padding: 19px;
+  margin-bottom: 20px;
+  background-color: #f5f5f5;
+  border: 1px solid #eee;
+  border: 1px solid rgba(0, 0, 0, 0.05);
+  -webkit-border-radius: 4px;
+  -moz-border-radius: 4px;
+  border-radius: 4px;
+  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+  -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
+  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
 }
-
-.show {
-  display: block;
+.well blockquote {
+  border-color: #ddd;
+  border-color: rgba(0, 0, 0, 0.15);
 }
-
-.invisible {
-  visibility: hidden;
+.well-large {
+  padding: 24px;
+  -webkit-border-radius: 6px;
+  -moz-border-radius: 6px;
+  border-radius: 6px;
+}
+.well-small {
+  padding: 9px;
+  -webkit-border-radius: 3px;
+  -moz-border-radius: 3px;
+  border-radius: 3px;
 }
diff --git a/scp/css/dashboard.css b/scp/css/dashboard.css
new file mode 100644
index 0000000000000000000000000000000000000000..43ec338890ac6bcce9d7647f85841657d362fe88
--- /dev/null
+++ b/scp/css/dashboard.css
@@ -0,0 +1,46 @@
+#line-chart-here {
+    padding: 0.4em;
+    margin-bottom: 1em;
+    border-radius: 0.3em;
+    border: 0.2em solid #ccc;
+    background: rgb(246,248,249); /* Old browsers */
+    background: -moz-linear-gradient(top, rgba(246,248,249,1) 0%, rgba(229,235,238,1) 50%, rgba(215,222,227,1) 51%, rgba(245,247,249,1) 100%); /* FF3.6+ */
+    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(246,248,249,1)), color-stop(50%,rgba(229,235,238,1)), color-stop(51%,rgba(215,222,227,1)), color-stop(100%,rgba(245,247,249,1))); /* Chrome,Safari4+ */
+    background: -webkit-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%); /* Chrome10+,Safari5.1+ */
+    background: -o-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%); /* Opera 11.10+ */
+    background: -ms-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%); /* IE10+ */
+    background: linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%); /* W3C */
+    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9', endColorstr='#f5f7f9',GradientType=0 ); /* IE6-9 */
+}
+#line-chart-here tspan {
+    font-family: Monaco, Calibri, Sans Serif;
+    font-size: 8pt;
+}
+#line-chart-legend {
+    margin: 0.6em;
+    line-height: 140%;
+}
+span.label.disabled {
+    opacity: 0.5;
+    background-color: #555 !important;
+}
+span.label {
+    cursor: pointer;
+}
+#table-here tr :not(:first-child) {
+    text-align: right;
+    padding-right: 2.3em;
+    width: 12%;
+}
+#table-here tr :not(:first-child) div {
+    position: relative;
+    margin-right: -1em;
+}
+#table-here tr :not(:first-child) div div {
+    position: absolute;
+    -moz-border-radius: 1em;
+    -webkit-border-radius: 1em;
+    border-radius: 1em;
+}
+
+
diff --git a/scp/css/scp.css b/scp/css/scp.css
index aa6ca4782492783d221fef0c6b18fe412f3cbcd5..899d9caa4726ab6009a89a8c3ef52196d425c8a9 100644
--- a/scp/css/scp.css
+++ b/scp/css/scp.css
@@ -16,6 +16,10 @@ a {
     text-align:center;
 }
 
+.full-width {
+    width: 100%;
+}
+
 .clear {
     clear:both;
 }
@@ -1140,22 +1144,22 @@ time {
     margin-right:20px;
 }
 
-/* Advanced Ticket Search */
+/* Advanced Search & Ticket print options */
 
-#overlay {
+#search_overlay {
     background:#000;
     position:absolute;
     display:none;
     z-index:1000;
 }
 
-#advanced-search, #advanced-search * {
+#advanced-search, #advanced-search *, #print-options, #print-options * {
     box-sizing: border-box;
     -moz-box-sizing: border-box;
     -webkit-box-sizing: border-box;
 }
 
-#advanced-search {
+#advanced-search, #print-options {
     position:absolute;
     padding:1em;
     width:640px;
@@ -1166,7 +1170,24 @@ time {
     z-index:1200;
 }
 
-#advanced-search h3 {
+#print-options {
+    width:500px;
+    height:250px;
+}
+
+#print-options hr {
+    height: 1px;
+    border: 0;
+    background: #aaa;
+    background: -moz-linear-gradient(left, rgba(170,170,170,0) 0%, rgba(170,170,170,1) 10%, rgba(170,170,170,1) 90%, rgba(170,170,170,0) 100%); /* FF3.6+ */
+    background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(170,170,170,0)), color-stop(10%,rgba(170,170,170,1)), color-stop(90%,rgba(170,170,170,1)), color-stop(100%,rgba(170,170,170,0))); /* Chrome,Safari4+ */
+    background: -o-linear-gradient(left, rgba(170,170,170,0) 0%,rgba(170,170,170,1) 10%,rgba(170,170,170,1) 90%,rgba(170,170,170,0) 100%); /* Opera 11.10+ */
+    background: -ms-linear-gradient(left, rgba(170,170,170,0) 0%,rgba(170,170,170,1) 10%,rgba(170,170,170,1) 90%,rgba(170,170,170,0) 100%); /* IE10+ */
+    background: linear-gradient(to right, rgba(170,170,170,0) 0%,rgba(170,170,170,1) 10%,rgba(170,170,170,1) 90%,rgba(170,170,170,0) 100%); /* W3C */
+    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00aaaaaa', endColorstr='#00aaaaaa',GradientType=1 ); /* IE6-9 */
+}
+
+#advanced-search h3, #print-options h3 {
     color:#2a67ac;
     font-size:20px;
     margin:0;
@@ -1174,16 +1195,16 @@ time {
     display:inline-block;
 }
 
-#advanced-search a.close {
+#advanced-search a.close, #print-options a.close {
     display:inline-block;
     float:right;
     font-size:16px;
     color:#777;
 }
 
-#advanced-search form {
+#advanced-search form, #print-options form {
     clear:both;
-    padding:2em 0 1em 0;
+    padding-top:2em;
     width:100%;
 }
 
@@ -1191,31 +1212,31 @@ time {
     display:none;
 }
 
-#advanced-search fieldset {
+#advanced-search fieldset, #print-options fieldset {
     margin:0;
-    padding:0.25em 0;
+    padding:0 0;
     border:none;
     overflow:hidden;
 }
 
-#advanced-search label {
+#advanced-search label, #print-options label {
     width:100px;
     display:inline-block;
     text-align:right;
     padding:10px;
 }
 
-#advanced-search fieldset input {
+#advanced-search fieldset input, #print-options fieldset input {
     border:1px solid #ccc;
     background:#fff;
 }
 
-#advanced-search fieldset select {
+#advanced-search fieldset select, #print-options fieldset select {
     width:170px;
     display:inline-block;
 }
 
-#advanced-search fieldset span {
+#advanced-search fieldset span, #print-options fieldset span {
     width:50px;
     display:inline-block;
     text-align:center;
@@ -1251,7 +1272,10 @@ time {
 
 #advanced-search input[type="submit"],
 #advanced-search input[type="reset"],
-#advanced-search input[type="button"]
+#advanced-search input[type="button"],
+#print-options input[type="submit"],
+#print-options input[type="reset"],
+#print-options input[type="button"]
 {
     display:inline-block;
     margin:0;
@@ -1264,7 +1288,10 @@ time {
     color: #333;
 }
 
-#advanced-search input[type="reset"], #advanced-search input[type="button"] {
+#advanced-search input[type="reset"],
+#advanced-search input[type="button"],
+#print-options input[type="reset"],
+#print-options input[type="button"] { 
     opacity:0.7;
 }
 
@@ -1303,3 +1330,37 @@ time {
     height:16px;
     background:inherit;
 }
+
+/* Upgrader */
+#upgrader { width: 100%; height: auto; clear: both;}
+#upgrader #sidebar { width: 220px; padding: 10px; border: 1px solid #C8DDFA; float: right; background: #F7FBFE; }
+#upgrader #sidebar h3 { font-size: 10pt; margin: 0 0 5px 0; padding: 0; text-indent: 32px; background: url('../images/cog.png?1312913866') top left no-repeat; line-height: 24px; color: #2a67ac; }
+
+#upgrader #main { width: 680px; float: left;}
+#upgrader #main h1 { margin: 0; padding: 0; font-size: 21pt; font-weight: normal; }
+#upgrader #main h2 { font-size: 12pt; margin: 0; padding: 0; color:#E65524; }
+#upgrader #main h3 { font-size: 10pt; margin: 0; padding: 0; }
+#upgrader #main div#intro { padding-bottom: 5px; margin-bottom:10px; border-bottom: 1px solid #aaaaaa; }
+#upgrader #main  { padding-bottom: 20px; }
+
+ul.progress { margin: 10px 0 20px 20px; padding: 0; }
+ul.progress li { list-style: none; margin: 0; padding: 0 0 2px 24px; background: url('../images/incomplete.png?1312910844'); background-repeat: no-repeat; background-position: 0 50%; }
+ul.progress li.yes { background-image: url('../images/yes.png?1312906296'); }
+ul.progress li.no { background-image: url('../images/no.png?1312906277'); }
+
+ul.progress li.yes small {color:green; }
+ul.progress li.no small {color:red;}
+
+#bar { clear: both; padding-top: 10px; height: 24px; line-height: 24px; text-align: center; border-top: 1px solid #aaaaaa; }
+#bar a, #bar .btn { display: inline-block; margin: 0; height: 24px; line-height: 24px; font-weight: bold; border: 1px solid #666666; text-decoration: none; padding: 0 10px; background: url('../images/grey_btn_bg.png?1312910883') top left repeat-x; color: #333; }
+#bar a:hover, #bar .btn:hover, #bar .btnover { background-position: bottom left; }
+#bar a.unstyled, #bar a.unstyled:hover { font-weight: normal; background: none; border: none; text-decoration: underline; color: #2a67ac; }
+
+#bar.error { background: #ffd; text-align: center; color: #a00; font-weight: bold; }
+
+/* Overlay */
+#overlay { display: none; position: fixed; background: #000; z-index: 1000; }
+
+#loading { padding: 10px 10px 10px 60px; width: 300px; height: 100px; background: url('../images/ajax-loader.gif?1312925608') 10px 50% no-repeat white; position: fixed; display: none; z-index: 3000; }
+#loading h4 { margin: 3px 0 0 0; padding: 0; color: #d80; }
+
diff --git a/scp/dashboard.php b/scp/dashboard.php
index 5284c901c7a5a86a9415619c805cb8a2dd0f9900..8756ca1ea86522eb77c8a7b8ee381f3928de27f9 100644
--- a/scp/dashboard.php
+++ b/scp/dashboard.php
@@ -16,7 +16,6 @@
 require('staff.inc.php');
 $nav->setTabActive('dashboard');
 require(STAFFINC_DIR.'header.inc.php');
-//require(STAFFINC_DIR.$page);
 ?>
 
 <script type="text/javascript" src="js/raphael-min.js"></script>
@@ -24,71 +23,12 @@ require(STAFFINC_DIR.'header.inc.php');
 <script type="text/javascript" src="js/g.line-min.js"></script>
 <script type="text/javascript" src="js/g.dot-min.js"></script>
 <script type="text/javascript" src="js/bootstrap-tab.js"></script>
+<script type="text/javascript" src="js/dashboard.inc.js"></script>
 
 <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
+<link rel="stylesheet" type="text/css" href="css/dashboard.css"/>
 
-<style type="text/css">
-#line-chart-here {
-  padding: 0.4em;
-  margin-bottom: 1em;
-  border-radius: 0.3em;
-  border: 0.2em solid #ccc;
-background: rgb(246,248,249); /* Old browsers */
-background: -moz-linear-gradient(top, rgba(246,248,249,1) 0%,
-rgba(229,235,238,1) 50%, rgba(215,222,227,1) 51%, rgba(245,247,249,1) 100%);
-/* FF3.6+ */
-background: -webkit-gradient(linear, left top, left bottom,
-color-stop(0%,rgba(246,248,249,1)), color-stop(50%,rgba(229,235,238,1)),
-color-stop(51%,rgba(215,222,227,1)), color-stop(100%,rgba(245,247,249,1)));
-/* Chrome,Safari4+ */
-background: -webkit-linear-gradient(top, rgba(246,248,249,1)
-0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1)
-100%); /* Chrome10+,Safari5.1+ */
-background: -o-linear-gradient(top, rgba(246,248,249,1)
-0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1)
-100%); /* Opera 11.10+ */
-background: -ms-linear-gradient(top, rgba(246,248,249,1)
-0%,rgba(229,235,238,1) 50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1)
-100%); /* IE10+ */
-background: linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,1)
-50%,rgba(215,222,227,1) 51%,rgba(245,247,249,1) 100%); /* W3C */
-filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9',
-endColorstr='#f5f7f9',GradientType=0 ); /* IE6-9 */
-}
-#line-chart-here tspan {
-    font-family: Monaco, Calibri, Sans Serif;
-    font-size: 8pt;
-}
-#line-chart-legend {
-    margin: 0.6em;
-    line-height: 140%;
-}
-span.label.disabled {
-    opacity: 0.5;
-    background-color: #555 !important;
-}
-span.label {
-    cursor: pointer;
-}
-#table-here tr :not(:first-child) {
-    text-align: right;
-    padding-right: 2.3em;
-    width: 10%;
-}
-#table-here tr :not(:first-child) div {
-    position: relative;
-    margin-right: -1em;
-}
-#table-here tr :not(:first-child) div div {
-    position: absolute;
-    -moz-border-radius: 1em;
-    -webkit-border-radius: 1em;
-    border-radius: 1em;
-}
-
-</style>
-
-<h1>Ticket Activity</h1>
+<h2>Ticket Activity</h2>
 <p>Select the starting time and period for the system activity graph</p>
 <form class="well form-inline" id="timeframe-form">
     <label>
@@ -115,272 +55,14 @@ span.label {
     <div style="position:absolute;right:0;top:0" id="line-chart-legend"></div>
 </div>
 
-<script type="text/javascript">
-    var r, previous_data;
-
-    function refresh() {
-        $('#line-chart-here').empty();
-        $('#line-chart-legend').empty();
-        var r = new Raphael('line-chart-here'),
-            width = $('#line-chart-here').width(),
-            height = $('#line-chart-here').height();
-        $.ajax({
-            method:     'GET',
-            url:        'ajax.php/report/overview/graph',
-            data:       ((this.start && this.start.value) ? {
-                'start': this.start.value,
-                'stop': this.period.value} : {}),
-            dataType:   'json',
-            success:    function(json) {
-                var previous_data = json,
-                    times = [],
-                    smtimes = Array.prototype.concat.apply([], json.times),
-                    plots = [],
-                    max = 0,
-                    primes = [2,3,5,7,9];
-
-                // Convert the timestamp to number of whole days after the
-                // unix epoch, and try and find an exact multiple of the
-                // number of days across the query that is less than 13 for
-                // the number of dates to place across the bottom.
-                for (key in smtimes) {
-                    smtimes[key] = Math.floor(smtimes[key] / 86400);
-                }
-                for (key in json.events) {
-                    e = json.events[key];
-                    if (json.plots[e] === undefined) continue;
-                    $('<span>').append(e)
-                        .attr({class:'label','style':'margin-left:0.5em'})
-                        .appendTo($('#line-chart-legend'));
-                    $('<br>').appendTo('#line-chart-legend');
-                    times.push(smtimes);
-                    plots.push(json.plots[e]);
-                    max = Math.max(max, Math.max.apply(Math, json.plots[e]));
-                }
-                m = r.linechart(10, 10, width - 80, height - 20,
-                    times, plots, { 
-                    gutter: 10,
-                    width: 1.6,
-                    nostroke: false, 
-                    shade: false,
-                    axis: "0 0 1 1",
-                    axisxstep: 8,
-                    axisystep: max,
-                    symbol: "circle",
-                    smooth: false
-                }).hoverColumn(function () {
-                    this.tags = r.set();
-                    var slots = [];
-
-                    for (var i = 0, ii = this.y.length; i < ii; i++) {
-                        if (this.values[i] === 0) continue;
-                        if (this.symbols[i].node.style.display == "none") continue;
-                        var angle = 160;
-                        for (var j = 0, jj = slots.length; j < jj; j++) {
-                            if (slots[j][0] == this.x && slots[j][1] == this.y[i]) {
-                                angle = 20;
-                                break;
-                            }
-                        }
-                        slots.push([this.x, this.y[i]]);
-                        this.tags.push(r.tag(this.x, this.y[i],
-                            this.values[i], angle,
-                            10).insertBefore(this).attr([
-                                { fill: '#eee' },
-                                { fill: this.symbols[i].attr('fill') }]));
-                    }
-                }, function () {
-                    this.tags && this.tags.remove();
-                });
-                // Change axis labels from Unix epoch
-                $('tspan', $('#line-chart-here')).each(function(e) {
-                    var text = this.firstChild.textContent;
-                    if (parseInt(text) > 10000)
-                        this.firstChild.textContent =
-                            $.datepicker.formatDate('mm-dd-yy',
-                            new Date(parseInt(text) * 86400000));
-                });
-                // Dear aspiring API writers, please consider making [easy]
-                // things simpler than this...
-                $('span.label').each(function(i, e) {
-                    e = $(e);
-                    e.click(function() {
-                        e.toggleClass('disabled');
-                        if (e.hasClass('disabled')) {
-                            m.symbols[i].hide();
-                            m.lines[i].hide();
-                        } else {
-                            m.symbols[i].show();
-                            m.lines[i].show();
-                        }
-                    });
-                });
-                $('span.label', '#line-chart-legend').css(
-                    'background-color', function(i) {
-                        return Raphael.color(m.symbols[i][0].attr('fill')).hex; 
-                });
-            }
-        });
-        return false;
-    }
-    $(refresh);
-    $('#timeframe-form').submit(refresh);
-</script>
-
-<h1>Current statistics</h1>
+<hr/>
+<h2>Statistics</h2>
+<p>Statistics of tickets organized by department, help topic, and staff
+member.</p>
 <ul class="nav nav-tabs" id="tabular-navigation"></ul>
 
 <div id="table-here"></div>
 
-<script type="text/javascript">
-
-    $(function() { $('tabular-navigation').tab(); });
-
-    // Add tabs for the tabular display
-    $(function() {
-        $.ajax({
-            url:        'ajax.php/report/overview/table/groups',
-            dataType:   'json',
-            success:    function(json) {
-                var first=true;
-                for (key in json) {
-                    $('#tabular-navigation')
-                        .append($('<li>').attr((first) ? {class:"active"} : {})
-                        .append($('<a>')
-                            .click(build_table)
-                            .attr({'table-group':key,'href':'#'})
-                            .append(json[key])));
-                    first=false;
-                }
-                build_table.apply($('#tabular-navigation li:first-child a'))
-            }
-        });
-    });
-
-    function build_table(e) {
-        $('#table-here').empty();
-        $(this).tab('show');
-        var group = $(this).attr('table-group')
-        $.ajax({
-            method:     'GET',
-            dataType:   'json',
-            url:        'ajax.php/report/overview/table',
-            data:       {group: group},
-            success:    function(json) {
-                var q = $('<table>').attr({class:'table table-condensed table-striped'});
-                var h = $('<tr>').appendTo($('<thead>').appendTo(q));
-                var pagesize = 25;
-                var min = [], max = [], range = [];
-                for (var c in json.columns) {
-                    h.append($('<th>').append(json.columns[c]));
-                    min.push(1e8); max.push(0);
-                }
-                for (y in json.data) {
-                    row = json.data[y];
-                    for (x in row) {
-                        min[x] = Math.min(min[x], parseFloat(row[x]||0));
-                        max[x] = Math.max(max[x], parseFloat(row[x]||0));
-                    }
-                }
-                for (i=1; i<min.length; i++)
-                    range[i] = max[i] - min[i]   
-                for (var i in json.data) {
-                    if (i % pagesize === 0)
-                        b = $('<tbody>').attr({'page':i/pagesize+1}).appendTo(q);
-                    row = json.data[i];
-                    tr = $('<tr>').appendTo(b);
-                    for (var j in row) {
-                        if (j == 0) 
-                            tr.append($('<th>').append(row[j]));
-                        else {
-                            val = parseFloat(row[j])||0;
-                            if (val && max[j] && json.data.length > 1) {
-                                scale = val / max[j];
-                                color = Raphael.hsb(
-                                    Math.min((1 - scale) * .4, 1),
-                                    .75, .75);
-                                size = 16 * scale;
-                            }
-                            tr.append($('<td>')
-                                .append($('<div>').append(
-                                    $('<div>').css(val && range[j] ? {
-                                        'background-color': color,
-                                        'width': size,
-                                        'height': size,
-                                        'top': 9 - (size / 2),
-                                        'right': 10 - (size / 2)
-                                    } : {})
-                                    .append("&nbsp;")))
-                                .append(row[j]));
-                        }
-                    }
-                }
-                $('#table-here').append(q);
-
-                // ----------------------> Pagination <---------------------
-                function goabs(e) {
-                    $('tbody', q).addClass('hide');
-                    if (e.target) {
-                        page = e.target.text;
-                        $('tbody[page='+page+']', q).removeClass('hide');
-                    } else {
-                        e.removeClass('hide');
-                        page = e.attr('page')
-                    }
-                    enable_next_prev(page);
-                }
-                function goprev() {
-                    current = $('tbody:not(.hide)', q).attr('page');
-                    page = Math.max(1, parseInt(current) - 1);
-                    goabs($('tbody[page='+page+']', q));
-                }
-                function gonext() {
-                    current = $('tbody:not(.hide)', q).attr('page');
-                    page = Math.min(Math.floor(json.data.length / pagesize) + 1,
-                        parseInt(current) + 1);
-                    goabs($('tbody[page='+page+']', q));
-                }
-                function enable_next_prev(page) {
-                    $('#table-here div.pagination li[page]').removeClass('active');
-                    $('#table-here div.pagination li[page='+page+']').addClass('active');
-
-                    if (page == 1)  $('#report-page-prev').addClass('disabled');
-                    else            $('#report-page-prev').removeClass('disabled');
-
-                    if (page == Math.floor(json.data.length / pagesize) + 1)
-                                    $('#report-page-next').addClass('disabled');
-                    else            $('#report-page-next').removeClass('disabled');
-                }
-
-                var p = $('<ul>')
-                    .appendTo($('<div>').attr({'class':'pagination'})
-                    .appendTo($('#table-here')));
-                $('<a>').click(goprev).attr({'href':'#'})
-                    .append('&laquo;').appendTo($('<li>').attr({'id':'report-page-prev'})
-                    .appendTo(p));
-                $('tbody', q).each(function() {
-                    page = $(this).attr('page');
-                    $('<a>').click(goabs).attr({'href':'#'}).append(page)
-                        .appendTo($('<li>').attr({'page':page})
-                        .appendTo(p));
-                });
-                $('<a>').click(gonext).attr({'href':'#'})
-                    .append('&raquo;').appendTo($('<li>').attr({'id':'report-page-next'})
-                    .appendTo(p));
-
-                // ------------------------> Export <-----------------------
-                $('<a>').attr({'href':'ajax.php/report/overview/table/export?group='
-                        +group}).append('Export')
-                    .appendTo($('<li>')
-                    .appendTo(p));
-
-                gonext();
-            }
-        });
-        return false;
-    }
-</script>
-
 <?
 include(STAFFINC_DIR.'footer.inc.php');
 ?>
diff --git a/scp/filters.php b/scp/filters.php
index 665f5bd1e0ebe736a94a743d2a83d73b817dc72d..ce61a7ea93b6a65db8654828d07302c830e63e19 100644
--- a/scp/filters.php
+++ b/scp/filters.php
@@ -15,6 +15,7 @@
 **********************************************************************/
 require('admin.inc.php');
 include_once(INCLUDE_DIR.'class.filter.php');
+require_once(INCLUDE_DIR.'class.canned.php');
 $filter=null;
 if($_REQUEST['id'] && !($filter=Filter::lookup($_REQUEST['id'])))
     $errors['err']='Unknown or invalid filter.';
diff --git a/scp/images/cog.png b/scp/images/cog.png
new file mode 100755
index 0000000000000000000000000000000000000000..20171bc655e21cb8df4b800230f7b2867d2f0ca2
Binary files /dev/null and b/scp/images/cog.png differ
diff --git a/scp/images/no.png b/scp/images/no.png
new file mode 100644
index 0000000000000000000000000000000000000000..7fc50c6bc73a1a93754306483dd15aaa45e188dd
Binary files /dev/null and b/scp/images/no.png differ
diff --git a/scp/images/yes.png b/scp/images/yes.png
new file mode 100644
index 0000000000000000000000000000000000000000..8ccfa4569a5fcdc4a9de556dba0c19a20d807233
Binary files /dev/null and b/scp/images/yes.png differ
diff --git a/scp/js/dashboard.inc.js b/scp/js/dashboard.inc.js
new file mode 100644
index 0000000000000000000000000000000000000000..cc84661cf2ce393934fa5b0f43a28c222bbe9935
--- /dev/null
+++ b/scp/js/dashboard.inc.js
@@ -0,0 +1,264 @@
+(function ($) {
+    var current_tab;
+    function refresh(e) {
+        $('#line-chart-here').empty();
+        $('#line-chart-legend').empty();
+        var r = new Raphael('line-chart-here'),
+            width = $('#line-chart-here').width(),
+            height = $('#line-chart-here').height();
+        $.ajax({
+            method:     'GET',
+            url:        'ajax.php/report/overview/graph',
+            data:       ((this.start && this.start.value) ? {
+                'start': this.start.value,
+                'stop': this.period.value} : {}),
+            dataType:   'json',
+            success:    function(json) {
+                var times = [],
+                    smtimes = Array.prototype.concat.apply([], json.times),
+                    plots = [],
+                    max = 0;
+
+                // Convert the timestamp to number of whole days after the
+                // unix epoch.
+                for (key in smtimes) {
+                    smtimes[key] = Math.floor(smtimes[key] / 86400);
+                }
+                for (key in json.events) {
+                    e = json.events[key];
+                    if (json.plots[e] === undefined) continue;
+                    $('<span>').append(e)
+                        .attr({'class':'label','style':'margin-left:0.5em'})
+                        .appendTo($('#line-chart-legend'));
+                    $('<br>').appendTo('#line-chart-legend');
+                    times.push(smtimes);
+                    plots.push(json.plots[e]);
+                    // Keep track of max value from any plot
+                    max = Math.max(max, Math.max.apply(Math, json.plots[e]));
+                }
+                m = r.linechart(20, 0, width - 70, height,
+                    times, plots, { 
+                    gutter: 20,
+                    width: 1.6,
+                    nostroke: false, 
+                    shade: false,
+                    axis: "0 0 1 1",
+                    axisxstep: 8,
+                    axisystep: Math.min(12, max),
+                    symbol: "circle",
+                    smooth: false
+                }).hoverColumn(function () {
+                    this.tags = r.set();
+                    var slots = [];
+
+                    for (var i = 0, ii = this.y.length; i < ii; i++) {
+                        if (this.values[i] === 0) continue;
+                        if (this.symbols[i].node.style.display == "none") continue;
+                        var angle = 160;
+                        for (var j = 0, jj = slots.length; j < jj; j++) {
+                            if (slots[j][0] == this.x
+                                    && Math.abs(slots[j][1] - this.y[i]) < 20) {
+                                angle = 20;
+                                break;
+                            }
+                        }
+                        slots.push([this.x, this.y[i]]);
+                        this.tags.push(r.tag(this.x, this.y[i],
+                            this.values[i], angle,
+                            10).insertBefore(this).attr([
+                                { fill: '#eee' },
+                                { fill: this.symbols[i].attr('fill') }]));
+                    }
+                }, function () {
+                    this.tags && this.tags.remove();
+                });
+                // Change axis labels from Unix epoch
+                $('tspan', $('#line-chart-here')).each(function(e) {
+                    var text = this.firstChild.textContent;
+                    if (parseInt(text) > 10000)
+                        this.firstChild.textContent =
+                            $.datepicker.formatDate('mm-dd-yy',
+                            new Date(parseInt(text) * 86400000));
+                });
+                $('span.label').each(function(i, e) {
+                    e = $(e);
+                    e.click(function() {
+                        e.toggleClass('disabled');
+                        if (e.hasClass('disabled')) {
+                            m.symbols[i].hide();
+                            m.lines[i].hide();
+                        } else {
+                            m.symbols[i].show();
+                            m.lines[i].show();
+                        }
+                    });
+                });
+                // Dear aspiring API writers, please consider making [easy]
+                // things simpler than this...
+                $('span.label', '#line-chart-legend').css(
+                    'background-color', function(i) {
+                        return Raphael.color(m.symbols[i][0].attr('fill')).hex; 
+                });
+            }
+        });
+        if (this.start) build_table.apply(this);
+        return false;
+    }
+    $(function() { $('tabular-navigation').tab(); });
+
+    // Add tabs for the tabular display
+    $(function() {
+        $.ajax({
+            url:        'ajax.php/report/overview/table/groups',
+            dataType:   'json',
+            success:    function(json) {
+                var first=true;
+                for (key in json) {
+                    $('#tabular-navigation')
+                        .append($('<li>').attr((first) ? {class:"active"} : {})
+                        .append($('<a>')
+                            .click(build_table)
+                            .attr({'table-group':key,'href':'#'})
+                            .append(json[key])));
+                    first=false;
+                }
+                build_table.apply($('#tabular-navigation li:first-child a')[0])
+            }
+        });
+    });
+
+    var start, stop;
+    function build_table() {
+        if (this.tagName == 'A') {
+            current_tab = $(this).tab('show');
+        }
+        else if (this.start) {
+            start = this.start.value || 'last month';
+            stop = this.period.value || 'now';
+        }
+        var group = current_tab.attr('table-group');
+        $.ajax({
+            method:     'GET',
+            dataType:   'json',
+            url:        'ajax.php/report/overview/table',
+            data:       {group: group, start: start, stop: stop},
+            success:    function(json) {
+                var q = $('<table>').attr({'class':'table table-condensed table-striped'}),
+                    h = $('<tr>').appendTo($('<thead>').appendTo(q)),
+                    pagesize = 25,
+                    max = [];
+                for (var c in json.columns) {
+                    h.append($('<th>').append(json.columns[c]));
+                    max.push(0);
+                }
+                for (y in json.data) {
+                    row = json.data[y];
+                    for (x in row) {
+                        max[x] = Math.max(max[x], parseFloat(row[x]||0));
+                    }
+                }
+                for (var i in json.data) {
+                    if (i % pagesize === 0)
+                        b = $('<tbody>').attr({'page':i/pagesize+1}).appendTo(q);
+                    row = json.data[i];
+                    tr = $('<tr>').appendTo(b);
+                    for (var j in row) {
+                        if (j == 0) 
+                            tr.append($('<th>').append(row[j]));
+                        else {
+                            val = parseFloat(row[j])||0;
+                            color = 'black';
+                            size = 0;
+                            if (val && max[j] && json.data.length > 1) {
+                                scale = val / max[j];
+                                color = Raphael.hsb(
+                                    Math.min((1 - scale) * .4, 1),
+                                    .75, .75);
+                                size = 16 * scale;
+                            }
+                            tr.append($('<td>')
+                                .append($('<div>').append(
+                                    $('<div>').css(val ? {
+                                        'background-color': color,
+                                        'width': size,
+                                        'height': size,
+                                        'top': 9 - (size / 2),
+                                        'right': 10 - (size / 2)
+                                    } : {})
+                                    .append("&nbsp;")))
+                                .append(row[j]));
+                        }
+                    }
+                }
+                if (json.data.length == 0) {
+                    $('<tbody>').attr('page','1').append($('<tr>').append(
+                        $('<td>').attr('colspan','8').append(
+                            'No data for this timeframe found'))).appendTo(q);
+                }
+                $('#table-here').empty().append(q);
+
+                // ----------------------> Pagination <---------------------
+                function goabs(e) {
+                    $('tbody', q).addClass('hide');
+                    if (e.target) {
+                        page = e.target.text;
+                        $('tbody[page='+page+']', q).removeClass('hide');
+                    } else {
+                        e.removeClass('hide');
+                        page = e.attr('page')
+                    }
+                    enable_next_prev(page);
+                }
+                function goprev() {
+                    current = $('tbody:not(.hide)', q).attr('page');
+                    page = Math.max(1, parseInt(current) - 1);
+                    goabs($('tbody[page='+page+']', q));
+                }
+                function gonext() {
+                    current = $('tbody:not(.hide)', q).attr('page');
+                    page = Math.min(Math.floor(json.data.length / pagesize) + 1,
+                        parseInt(current) + 1);
+                    goabs($('tbody[page='+page+']', q));
+                }
+                function enable_next_prev(page) {
+                    $('#table-here div.pagination li[page]').removeClass('active');
+                    $('#table-here div.pagination li[page='+page+']').addClass('active');
+
+                    if (page == 1)  $('#report-page-prev').addClass('disabled');
+                    else            $('#report-page-prev').removeClass('disabled');
+
+                    if (page == Math.floor(json.data.length / pagesize) + 1)
+                                    $('#report-page-next').addClass('disabled');
+                    else            $('#report-page-next').removeClass('disabled');
+                }
+
+                var p = $('<ul>')
+                    .appendTo($('<div>').attr({'class':'pagination'})
+                    .appendTo($('#table-here')));
+                $('<a>').click(goprev).attr({'href':'#'})
+                    .append('&laquo;').appendTo($('<li>').attr({'id':'report-page-prev'})
+                    .appendTo(p));
+                $('tbody', q).each(function() {
+                    page = $(this).attr('page');
+                    $('<a>').click(goabs).attr({'href':'#'}).append(page)
+                        .appendTo($('<li>').attr({'page':page})
+                        .appendTo(p));
+                });
+                $('<a>').click(gonext).attr({'href':'#'})
+                    .append('&raquo;').appendTo($('<li>').attr({'id':'report-page-next'})
+                    .appendTo(p));
+
+                // ------------------------> Export <-----------------------
+                $('<a>').attr({'href':'ajax.php/report/overview/table/export?group='
+                        +group}).append('Export')
+                    .appendTo($('<li>')
+                    .appendTo(p));
+
+                gonext();
+            }
+        });
+        return false;
+    }
+    $(refresh);
+    $(function() { $('#timeframe-form').submit(refresh); });
+})(window.jQuery);
diff --git a/scp/js/scp.js b/scp/js/scp.js
index 294c47a69b5953ee7f9fed03976b2f69d2c2c15e..81f554fb8db407668e0d36ba1a101d36e8f9fbdd 100644
--- a/scp/js/scp.js
+++ b/scp/js/scp.js
@@ -245,7 +245,7 @@ $(document).ready(function(){
     });
 
     /* advanced search */
-    $("#overlay").css({
+    $("#overlay, #search_overlay").css({
         opacity : 0.3,
         top     : 0,
         left    : 0,
@@ -261,14 +261,14 @@ $(document).ready(function(){
     $('#go-advanced').click(function(e) {
         e.preventDefault();
         $('#result-count').html('');
-        $('#overlay').show();
+        $('#search_overlay').show();
         $('#advanced-search').show();
     });
 
     $('#advanced-search').delegate('a.close, input.close', 'click', function(e) {
         e.preventDefault();
         $('#advanced-search').hide()
-        $('#overlay').hide();
+        $('#search_overlay').hide();
     }).delegate('#status', 'change', function() {
         switch($(this).val()) {
             case 'closed':
diff --git a/scp/js/ticket.js b/scp/js/ticket.js
index 5b6872f58e38ee88b2392d67d674b4206edd0a4b..2913c225cf0579f3587442831a135bb3464b53f8 100644
--- a/scp/js/ticket.js
+++ b/scp/js/ticket.js
@@ -316,6 +316,25 @@ jQuery(function($) {
             }
         }
      });
+    
+    //Ticket print options
+    $("#print-options").css({
+        top  : ($(window).height() /5),
+        left : ($(window).width() / 2 - 300)
+    });
+
+    $('a#ticket-print').click(function(e) {
+        e.preventDefault();
+        $('#overlay').show();
+        $('#print-options').show();
+        return false;
+    });
+
+    $('#print-options').delegate('a.close, input.close', 'click', function(e) {
+        e.preventDefault();
+        $('#print-options').hide()
+        $('#overlay').hide();
+    });
 
     //Start watching the form for activity.
     autoLock.Init();
diff --git a/scp/js/upgrader.js b/scp/js/upgrader.js
new file mode 100644
index 0000000000000000000000000000000000000000..09bde7766c6f39e9f95e0b50ccf3c0efc3bbb2fb
--- /dev/null
+++ b/scp/js/upgrader.js
@@ -0,0 +1,58 @@
+jQuery(function($) {
+            
+    $("#overlay").css({
+        opacity : 0.3,
+        top     : 0,
+        left    : 0,
+        width   : $(window).width(),
+        height  : $(window).height()
+        });
+
+    $("#loading").css({
+        top  : ($(window).height() / 3),
+        left : ($(window).width() / 2 - 160)
+        });
+        
+    $('form#upgrade').submit(function(e) {
+        e.preventDefault();
+        var form = $(this);
+        $('input[type=submit]', this).attr('disabled', 'disabled');
+        $('#overlay, #loading').show();
+        doTasks('upgrade.php',form.serialize());
+
+        return false;
+        });
+
+    function doTasks(url, data) {
+        function _lp(count) {
+            $.ajax({
+                type: 'POST',
+                url: 'ajax.php/upgrader',
+                async: true,
+                cache: false,
+                data: data,
+                dataType: 'text',
+                success: function(res) {
+                    if (res) { 
+                        $('#loading #msg').html(res);
+                    }
+                },
+                statusCode: {
+                    200: function() {
+                        setTimeout(function() { _lp(count+1); }, 2);
+                    },
+
+                    201: function() {
+                        $('#loading #msg').html("We're done... cleaning up!");
+                        setTimeout(function() { location.href =url+'?c='+count+'&r='+Math.floor((Math.random()*100)+1); }, 3000);
+                    }
+                },
+                error: function() {
+                    $('#loading #msg').html("Something went wrong");
+                    setTimeout(function() { location.href =url+'?c='+count+'&r='+Math.floor((Math.random()*100)+1); }, 1000);
+                }
+            });
+        };
+        _lp(0);
+    }
+});
diff --git a/scp/login.php b/scp/login.php
index b8deacfd13313f4d042e2deb7b26488a38c1e8cc..6a28e0f45130f26f733f8eca82066565f5e2d9dc 100644
--- a/scp/login.php
+++ b/scp/login.php
@@ -25,7 +25,7 @@ if($_POST && (!empty($_POST['username']) && !empty($_POST['passwd']))){
     //$_SESSION['_staff']=array(); #Uncomment to disable login strikes.
     $msg='Invalid login';
     if(($user=Staff::login($_POST['username'],$_POST['passwd'],$errors))){
-        $dest=$_SESSION['_user']['auth']['dest'];
+        $dest=$_SESSION['_staff']['auth']['dest'];
         $dest=($dest && (!strstr($dest,'login.php') && !strstr($dest,'ajax.php')))?$dest:'index.php';
         @header("Location: $dest");
         require_once('index.php'); //Just incase header is messed up.
diff --git a/scp/logout.php b/scp/logout.php
index 32d62d14abb29363df9a7da033a1f0873821cbc9..f167d5a876082b0628f1e64929626444f28a3bb0 100644
--- a/scp/logout.php
+++ b/scp/logout.php
@@ -21,7 +21,6 @@ $ost->logDebug('Staff logout',
 $_SESSION['_staff']=array();
 session_unset();
 session_destroy();
-session_write_close();
 @header('Location: login.php');
 require('login.php');
 ?>
diff --git a/scp/syslogs.php b/scp/logs.php
similarity index 98%
rename from scp/syslogs.php
rename to scp/logs.php
index aaaf1843c60c688105507d893dc647f81e587095..b34126f5defe58184f76f9f4e8f4c9e810b2f49e 100644
--- a/scp/syslogs.php
+++ b/scp/logs.php
@@ -1,6 +1,6 @@
 <?php
 /*********************************************************************
-    syslogs.php
+    logs.php
 
     System Logs
 
@@ -43,8 +43,6 @@ if($_POST){
     }
 }
 
-
-  
 $page='syslogs.inc.php';
 $nav->setTabActive('dashboard');
 require(STAFFINC_DIR.'header.inc.php');
diff --git a/scp/profile.php b/scp/profile.php
index e6506fa6ece8bd0686550cae4810e17a2c76cd6f..96e1b7e29af59bb03fa929600a02c66c60fde4ff 100644
--- a/scp/profile.php
+++ b/scp/profile.php
@@ -19,8 +19,7 @@ $msg='';
 $staff=Staff::lookup($thisstaff->getId());
 if($_POST && $_POST['id']!=$thisstaff->getId()) { //Check dummy ID used on the form.
  $errors['err']='Internal Error. Action Denied';
-}
-if(!$errors && $_POST) { //Handle post
+} elseif(!$errors && $_POST) { //Handle post
 
     if(!$staff)
         $errors['err']='Unknown or invalid staff';
diff --git a/scp/staff.inc.php b/scp/staff.inc.php
index 633c897c77443c50ad82e9ed26cea696e063dc46..c0091360794897dc5b972e069fcc54835d448526 100644
--- a/scp/staff.inc.php
+++ b/scp/staff.inc.php
@@ -13,7 +13,7 @@
 
     vim: expandtab sw=4 ts=4 sts=4:
 **********************************************************************/
-if(basename($_SERVER['SCRIPT_NAME'])==basename(__FILE__)) die('Kwaheri rafiki!'); //Say hi to our friend..
+if(basename($_SERVER['SCRIPT_NAME'])==basename(__FILE__)) die('Access denied'); //Say hi to our friend..
 
 if(!file_exists('../main.inc.php')) die('Fatal error... get technical support');
 
@@ -96,8 +96,12 @@ $errors=array();
 $msg=$warn=$sysnotice='';
 $tabs=array();
 $submenu=array();
-if($ost->isUpgradePending()) {
-    $errors['err']=$sysnotice='System upgrade is pending <a href="../setup/upgrade.php">Upgrade Now</a>';
+$exempt = in_array(basename($_SERVER['SCRIPT_NAME']), array('logout.php', 'ajax.php', 'logs.php', 'upgrade.php'));
+
+if($ost->isUpgradePending() && !$exempt) {
+    $errors['err']=$sysnotice='System upgrade is pending <a href="upgrade.php">Upgrade Now</a>';
+    require('upgrade.php');
+    exit;
 } elseif($cfg->isHelpDeskOffline()) {
     $sysnotice='<strong>System is set to offline mode</strong> - Client interface is disabled and ONLY admins can access staff control panel.';
     $sysnotice.=' <a href="settings.php">Enable</a>.';
@@ -105,7 +109,7 @@ if($ost->isUpgradePending()) {
 
 $nav = new StaffNav($thisstaff);
 //Check for forced password change.
-if($thisstaff->forcePasswdChange()){
+if($thisstaff->forcePasswdChange() && !$exempt) {
     # XXX: Call staffLoginPage() for AJAX and API requests _not_ to honor
     #      the request
     require('profile.php'); //profile.php must request this file as require_once to avoid problems.
diff --git a/scp/tickets.php b/scp/tickets.php
index 7cc7740bb677eeff2bddd177697a661c7da2996d..0feacf86429846326f98430c4c465c38262295c4 100644
--- a/scp/tickets.php
+++ b/scp/tickets.php
@@ -456,7 +456,7 @@ if($ticket) {
     $inc = 'ticket-view.inc.php';
     if($_REQUEST['a']=='edit' && $thisstaff->canEditTickets()) 
         $inc = 'ticket-edit.inc.php';
-    elseif($_REQUEST['a'] == 'print' && !$ticket->pdfExport())
+    elseif($_REQUEST['a'] == 'print' && !$ticket->pdfExport($_REQUEST['psize'], $_REQUEST['notes']))
         $errors['err'] = 'Internal error: Unable to export the ticket to PDF for print.';
 } else {
     $inc = 'tickets.inc.php';
diff --git a/setup/upgrade.php b/scp/upgrade.php
similarity index 61%
rename from setup/upgrade.php
rename to scp/upgrade.php
index e5fd21084ccb534167d681ee6288793d5a683296..c424f425cc019acb864c74a393a7adb89827f26d 100644
--- a/setup/upgrade.php
+++ b/scp/upgrade.php
@@ -13,49 +13,26 @@
 
     vim: expandtab sw=4 ts=4 sts=4:
 **********************************************************************/
-function staffLoginPage($msg) {
-        
-    $_SESSION['_staff']['auth']['dest']=THISPAGE;
-    $_SESSION['_staff']['auth']['msg']=$msg;
-    header('Location: ../scp/login.php');
-    exit;
-}
-
-require '../scp/staff.inc.php';
-if(!$thisstaff or !$thisstaff->isAdmin()) {
-    staffLoginPage('Admin Access Required!');
-    exit;
-}
-
-define('SETUPINC', true);
-define('INC_DIR', './inc/');
-define('SQL_DIR', INC_DIR.'sql/');
-
-require_once INC_DIR.'class.upgrader.php';
+require_once 'admin.inc.php';
+require_once INCLUDE_DIR.'class.upgrader.php';
 
 //$_SESSION['ost_upgrader']=null;
-$upgrader = new Upgrader($cfg->getSchemaSignature(), TABLE_PREFIX, SQL_DIR);
-
-
-$wizard=array();
-$wizard['title']='osTicket Upgrade Wizard';
-$wizard['tagline']='Upgrading osTicket to v'.$upgrader->getVersionVerbose();
-$wizard['logo']='logo-upgrade.png';
-$wizard['menu']=array('Upgrade Guide'=>'http://osticket.com/wiki/Upgrade_and_Migration',
-                      'Get Professional Help'=>'http://osticket.com/support');
+$upgrader = new Upgrader($cfg->getSchemaSignature(), TABLE_PREFIX, PATCH_DIR);
 $errors=array();
 if($_POST && $_POST['s'] && !$upgrader->isAborted()) {
     switch(strtolower($_POST['s'])) {
         case 'prereq':
-            //XXX: check if it's upgradable version??
-            if(!$ost->isUpgradePending())
+            if(!$ost->isUpgradePending()) {
                 $errors['err']=' Nothing to do! System already upgraded to the current version';
-            elseif(!$upgrader->isUpgradable())
+            } elseif(!$upgrader->isUpgradable()) {
                 $errors['err']='The upgrader does NOT support upgrading from the current vesion!';
-            elseif($upgrader->check_prereq())
+            } elseif(!$upgrader->check_prereq()) {
+                $errors['prereq']='Minimum requirements not met! Refer to Release Notes for more information';
+            } elseif(!strcasecmp(basename(CONFIG_FILE), 'settings.php')) {
+                $errors['err']='Config file rename required to continue!';
+            } else {
                 $upgrader->setState('upgrade');
-            else
-                $errors['prereq']='Minimum requirements not met!';
+            } 
             break;
         case 'upgrade': //Manual upgrade.... when JS (ajax) is not supported.
             if($upgrader->getNumPendingTasks()) {
@@ -77,25 +54,35 @@ if($_POST && $_POST['s'] && !$upgrader->isAborted()) {
 
 switch(strtolower($upgrader->getState())) {
     case 'aborted':
-        $inc='upgrade-aborted.inc.php';
+        $inc='aborted.inc.php';
         break;
     case 'upgrade':
         $inc='upgrade.inc.php';
         break;
     case 'done':
-        $inc='upgrade-done.inc.php';
+        $inc='done.inc.php';
         break;
     default:
-        $inc='upgrade-prereq.inc.php';
+        $inc='prereq.inc.php';
         if($upgrader->isAborted())
-            $inc='upgrade-aborted.inc.php';
+            $inc='aborted.inc.php';
+        elseif(!strcasecmp(basename(CONFIG_FILE), 'settings.php'))
+            $inc='rename.inc.php';
         elseif(!$ost->isUpgradePending())
-            $errors['err']='Nothing to do! System already upgraded to the latest version';
+            $errors['err']='Nothing to do! System already upgraded to <b>'.$ost->getVersion().'</b> with no pending patches to apply.';
         elseif(!$upgrader->isUpgradable())
             $errors['err']='The upgrader does NOT support upgrading from the current vesion!';
 }
 
-require(INC_DIR.'header.inc.php');
-require(INC_DIR.$inc);
-require(INC_DIR.'footer.inc.php');
+$nav = new AdminNav($thisstaff);
+$nav->setTabActive('dashboard');
+$nav->addSubMenu(array('desc'=>'Upgrader',
+                           'title'=>'Upgrader',
+                           'href'=>'upgrade.php',
+                           'iconclass'=>'preferences'),
+                        true);
+$ost->addExtraHeader('<script type="text/javascript" src="./js/upgrader.js"></script>');
+require(STAFFINC_DIR.'header.inc.php');
+require(UPGRADE_DIR.$inc);
+require(STAFFINC_DIR.'footer.inc.php');
 ?>
diff --git a/setup/cleanup-codebase.sh b/setup/cleanup-codebase.sh
new file mode 100644
index 0000000000000000000000000000000000000000..d9209b91738f3cb8b1f690bdd1d0db6fdf45a481
--- /dev/null
+++ b/setup/cleanup-codebase.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+
+find_root() {
+    local root=".";
+    while [[ ${#root} < 20 ]]; do
+        [[ -f "$root/main.inc.php" ]] && break
+        root="$root/.."
+    done
+
+    [[ ! -f "$root/main.inc.php" ]] && exit 1;
+
+    pushd . > /dev/null
+    cd $root
+    pwd -P
+    popd > /dev/null
+}
+
+root="$(find_root)"
+if [[ ! -f "$root/main.inc.php" ]]; then
+    echo "!!! Unable to determing codebase root."
+    echo "!!! Try running this inside the codebase path."
+    exit 1;
+fi
+
+while read file; do
+    if [[ -n "$file" && "${file[0]}" != "\x23" && -f "$root/$file" ]]; then
+        echo "Cleaning $file";
+        rm "$root/$file";
+    fi
+done <<< "
+# Removed in 1.6-rc5
+ostconfig.php
+
+# Removed in 1.6.0
+images/button.jpg
+images/logo.jpg
+images/new_ticket_title.jpg
+images/ticket_status_title.jpg
+include/settings.php
+
+# Removed in 1.7.0
+images/bg.gif
+images/fibres.png
+images/home.gif
+images/icons
+images/lipsum.png
+images/logo2.jpg
+images/logout.gif
+images/my_tickets.gif
+images/new_ticket.gif
+images/new_ticket_icon.jpg
+images/poweredby.jpg
+images/rainbow.png
+images/refresh_btn.gif
+images/ticket_status.gif
+images/ticket_status_icon.jpg
+images/verticalbar.jpg
+images/view_closed_btn.gif
+images/view_open_btn.gif
+include/class.msgtpl.php
+include/class.sys.php
+include/client/index.php
+include/client/viewticket.inc.php
+include/ost-config.sameple.php
+include/staff/api.inc.php
+include/staff/changepasswd.inc.php
+include/staff/dept.inc.php
+include/staff/depts.inc.php
+include/staff/editticket.inc.php
+include/staff/mypref.inc.php
+include/staff/myprofile.inc.php
+include/staff/newticket.inc.php
+include/staff/premade.inc.php
+include/staff/reply.inc.php
+include/staff/smtp.inc.php
+include/staff/viewticket.inc.php
+scp/css/autosuggest_inquisitor.css
+scp/css/datepicker.css
+scp/css/main.css
+scp/css/style.css
+scp/css/tabs.css
+scp/images/alert.png
+scp/images/bg-login-box.gif
+scp/images/icons/email_settings.gif
+scp/images/logo-support.gif
+scp/images/minus.gif
+scp/images/ostlogo.jpg
+scp/images/pagebg.jpg
+scp/images/plus.gif
+scp/images/refresh.gif
+scp/images/tab.jpg
+scp/images/view_closed.gif
+scp/images/view_open.gif
+scp/js/ajax.js
+scp/js/autolock.js
+scp/js/bsn.AutoSuggest_2.1.3.js
+scp/js/calendar.js
+scp/js/datepicker.js
+scp/js/tabber.js
+"
diff --git a/setup/inc/class.attachment.migrate.php b/setup/inc/class.attachment.migrate.php
deleted file mode 100644
index 20385fd936439fbe868c2069b4fde0601a80b0ac..0000000000000000000000000000000000000000
--- a/setup/inc/class.attachment.migrate.php
+++ /dev/null
@@ -1,162 +0,0 @@
-<?php
-/*********************************************************************
-    class.attachment.migrate.php
-
-    Attachment migration from file-based attachments in pre-1.7 to
-    database-backed attachments in osTicket v1.7. This class provides the
-    hardware to find and retrieve old attachments and move them into the new
-    database scheme with the data in the actual database.
-
-    Copyright (c)  2006-2012 osTicket
-    http://www.osticket.com
-
-    Released under the GNU General Public License WITHOUT ANY WARRANTY.
-    See LICENSE.TXT for details.
-
-    vim: expandtab sw=4 ts=4 sts=4:
-**********************************************************************/
-include_once(INCLUDE_DIR.'class.file.php');
-
-class AttachmentMigrater {
-    function AttachmentMigrater() {
-        $this->queue = array();
-        $this->current = 0;
-        $this->errors = 0;
-        $this->errorList = array();
-    }
-    /**
-     * Identifies attachments in need of migration and queues them for
-     * migration to the new database schema.
-     * 
-     * @see ::next() for output along the way
-     *
-     * Returns:
-     * TRUE/FALSE to indicate if migration finished without any errors
-     */
-    function start_migration() {
-        $this->findAttachments();
-        $this->total = count($this->queue);
-    }
-    /**
-     * Process the migration for a unit of time. This will be used to
-     * overcome the execution time restriction of PHP. This instance can be
-     * stashed in a session and have this method called periodically to
-     * process another batch of attachments
-     */
-    function do_batch($max, $time=20) {
-        $start = time();
-        $this->errors = 0;
-        while (count($this->queue) && $count++ < $max && time()-$start < $time)
-            $this->next();
-        # TODO: Log success/error indication of migration of attachments
-        return (!$this->errors);
-    }
-
-    function queue($fileinfo) {
-        $this->queue[] = $fileinfo;
-    }
-    function getQueueLength() { return count($this->queue); }
-    /**
-     * Processes the next item on the work queue. Emits a JSON messages to
-     * indicate current progress.
-     *
-     * Returns:
-     * TRUE/NULL if the migration was successful
-     */
-    function next() {
-        # Fetch next item -- use the last item so the array indices don't
-        # need to be recalculated for every shift() operation.
-        $info = array_pop($this->queue);
-        # Attach file to the ticket
-        if (!($info['data'] = @file_get_contents($info['path']))) {
-            # Continue with next file
-            return $this->error(
-                sprintf('%s: Cannot read file contents', $info['path']));
-        }
-        # Get the mime/type of each file
-        # XXX: Use finfo_buffer for PHP 5.3+
-        $info['type'] = mime_content_type($info['path']);
-        if (!($fileId = AttachmentFile::save($info))) {
-            return $this->error(
-                sprintf('%s: Unable to migrate attachment', $info['path']));
-        }
-        # Update the ATTACHMENT_TABLE record to set file_id
-        db_query('update '.TICKET_ATTACHMENT_TABLE
-                .' set file_id='.db_input($fileId)
-                .' where attach_id='.db_input($info['attachId']));
-        # Remove disk image of the file. If this fails, the migration for
-        # this file would not be retried, because the file_id in the
-        # TICKET_ATTACHMENT_TABLE has a nonzero value now
-        if (!@unlink($info['path']))
-            $this->error(
-                sprintf('%s: Unable to remove file from disk',
-                $info['path']));
-        # TODO: Log an internal note to the ticket?
-        return true;
-    }
-    /**
-     * From (class Ticket::fixAttachments), used to detect the locations of
-     * attachment files
-     */
-    /* static */ function findAttachments(){
-        global $cfg;
-
-        $res=db_query('SELECT attach_id, file_name, file_key, Ti.created'
-            .' FROM '.TICKET_ATTACHMENT_TABLE.' TA'
-            .' JOIN '.TICKET_TABLE.' Ti ON Ti.ticket_id=TA.ticket_id'
-            .' WHERE NOT file_id');
-        if (!$res) {
-            return $this->error('Unable to query for attached files');
-        } elseif (!db_num_rows($res)) {
-            return true;
-        }
-        $dir=$cfg->getUploadDir();
-        while (list($id,$name,$key,$created)=db_fetch_row($res)) {
-            $month=date('my',strtotime($created));
-            $info=array(
-                'name'=>        $name,
-                'attachId'=>    $id,
-            );
-            $filename15=sprintf("%s/%s_%s",rtrim($dir,'/'),$key,$name);
-            $filename16=sprintf("%s/%s/%s_%s",rtrim($dir,'/'),$month,$key,$name); //new destination.
-            if (file_exists($filename15)) { 
-                $info['path'] = $filename15;
-            } elseif (file_exists($filename16)) {  
-                $info['path'] = $filename16;
-            } else {
-                # XXX Cannot find file for attachment
-                $this->error(sprintf('%s: Unable to locate attachment file',
-                    $name));
-                # No need to further process this file
-                continue;
-            }
-            # TODO: Get the size and mime/type of each file.
-            #
-            # NOTE: If filesize() fails and file_get_contents() doesn't,
-            # then the AttachmentFile::save() method will automatically
-            # estimate the filesize based on the length of the string data
-            # received in $info['data'] -- ie. no need to do that here.
-            #
-            # NOTE: The size is done here because it should be quick to
-            # lookup out of file inode already loaded. The mime/type may
-            # take a while because it will require a second IO to read the
-            # file data.  To ensure this will finish before the
-            # max_execution_time, perform the type match in the ::next()
-            # method since the entire file content will be read there
-            # anyway.
-            $info['size'] = @filesize($info['path']);
-            # Coroutines would be nice ..
-            $this->queue($info);
-        }
-    }
-
-    function error($what) {
-        $this->errors++;
-        $this->errorList[] = $what;
-        # Assist in returning FALSE for inline returns with this method
-        return false;
-    }
-    function getErrors() {
-        return $this->errorList;
-    }
-}
diff --git a/setup/inc/class.installer.php b/setup/inc/class.installer.php
index 7b3dbe534eb0af30f13f27223f555849d30a6bb1..7791d9f4bc8dc3ddab88852fd688db8603e19a2e 100644
--- a/setup/inc/class.installer.php
+++ b/setup/inc/class.installer.php
@@ -13,7 +13,7 @@
 
     vim: expandtab sw=4 ts=4 sts=4:
 **********************************************************************/
-require_once INC_DIR.'class.setup.php';
+require_once INCLUDE_DIR.'class.setup.php';
 
 class Installer extends SetupWizard {
 
diff --git a/setup/inc/class.migrater.php b/setup/inc/class.migrater.php
deleted file mode 100644
index de8a3d9590e97b9d78ecb905528bcbc1bc2c03a5..0000000000000000000000000000000000000000
--- a/setup/inc/class.migrater.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/*********************************************************************
-    class.migrater.php
-
-    SQL database migrater. This provides the engine capable of rolling the
-    database for an osTicket installation forward (and perhaps even
-    backward) in time using a set of included migration scripts. Each script
-    will roll the database between two database checkpoints. Where possible,
-    the migrater will roll several checkpoint scripts into one to be applied
-    together.
-
-    Jared Hancock <jared@osticket.com>
-    Copyright (c)  2006-2012 osTicket
-    http://www.osticket.com
-
-    Released under the GNU General Public License WITHOUT ANY WARRANTY.
-    See LICENSE.TXT for details.
-
-    vim: expandtab sw=4 ts=4 sts=4:
-**********************************************************************/
-
-class DatabaseMigrater {
-
-    var $start;
-    var $end;
-    var $sqldir;
-
-    function DatabaseMigrater($start, $end, $sqldir) {
-       
-        $this->start = $start;
-        $this->end = $end;
-        $this->sqldir = $sqldir;
-       
-    }
-
-    function getPatches($stop=null) {
-
-        $start= $this->start;
-        $stop = $stop?$stop:$this->end;
-
-        $patches = array();
-        while (true) {
-            $next = glob($this->sqldir . substr($start, 0, 8)
-                         . '-*.patch.sql');
-            if (count($next) == 1) {
-                $patches[] = $next[0];
-                $start = substr(basename($next[0]), 9, 8);
-            } elseif (count($next) == 0) {
-                # There are no patches leaving the current signature. We
-                # have to assume that we've applied all the available
-                # patches.
-                break;
-            } else {
-                # Problem -- more than one patch exists from this snapshot.
-                # We probably need a graph approach to solve this.
-                break;
-            }
-
-            # Break if we've reached our target stop.
-            if(!$start || !strncasecmp($start, $stop, 8))
-                break;
-        }
-
-        return $patches;
-    }
-}
-?>
diff --git a/setup/inc/file-unclean.inc.php b/setup/inc/file-unclean.inc.php
index 1de4607e82bb5a2db8b7aea204fc6c57ba390c26..309fad10bc150d3beac23c937df1ebd448d42238 100644
--- a/setup/inc/file-unclean.inc.php
+++ b/setup/inc/file-unclean.inc.php
@@ -4,7 +4,7 @@ if(!defined('SETUPINC')) die('Kwaheri!');
     <div id="main">
             <h1 style="color:#FF7700;">osTicket is already installed?</h1>
             <div id="intro">
-             <p>Configuration file already changed - which could mean osTicket is already installed or the config file is currupted. If you are trying to upgrade osTicket, then <a href="upgrade.php" >click here</a>.</p>
+             <p>Configuration file already changed - which could mean osTicket is already installed or the config file is currupted. If you are trying to upgrade osTicket, then go to <a href="../scp/" >Admin Panel</a>.</p>
 
              <p>If you believe this is in error, please try replacing the config file with a unchanged template copy and try again or get technical help.</p>
              <p>Refer to the <a target="_blank" href="http://osticket.com/wiki/Installation">Installation Guide</a> on the wiki for more information.</p>
diff --git a/setup/inc/sql/60fcbee1-f8856d56.patch.sql b/setup/inc/sql/60fcbee1-f8856d56.patch.sql
deleted file mode 100644
index 2b7e48599816e88702f709f50557189b160a727e..0000000000000000000000000000000000000000
--- a/setup/inc/sql/60fcbee1-f8856d56.patch.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket_event`;
-CREATE TABLE `%TABLE_PREFIX%ticket_event` (
-  `ticket_id` int(11) unsigned NOT NULL default '0',
-  `staff_id` int(11) unsigned NOT NULL,
-  `team_id` int(11) unsigned NOT NULL,
-  `dept_id` int(11) unsigned NOT NULL,
-  `topic_id` int(11) unsigned NOT NULL,
-  `state` enum('created','closed','reopened','assigned','transferred','overdue') NOT NULL,
-  `staff` varchar(255) NOT NULL default 'SYSTEM',
-  `timestamp` datetime NOT NULL,
-  KEY `ticket_state` (`ticket_id`, `state`, `timestamp`),
-  KEY `ticket_stats` (`timestamp`, `state`)
-) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
-
-DROP TABLE IF EXISTS `%TABLE_PREFIX%ticket_history`;
-DROP TABLE IF EXISTS `%TABLE_PREFIX%history`;
-
-UPDATE `%TABLE_PREFIX%config`
-    SET `schema_signature`='f8856d56e51c5cc3416389de78b54515';
diff --git a/setup/inc/sql/7be60a84-522e5b78.patch.sql b/setup/inc/sql/7be60a84-522e5b78.patch.sql
deleted file mode 100644
index acdaf7d0d3c1f8baaedd40bd68e33b01b97e72c9..0000000000000000000000000000000000000000
--- a/setup/inc/sql/7be60a84-522e5b78.patch.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * @version v1.7-DPR1 (P1)
- */ 
-UPDATE `%TABLE_PREFIX%email_template`
-    SET `ticket_overlimit_subj` = 'Open Tickets Limit Reached'
-    WHERE `tpl_id` = 1 AND `cfg_id` = 1;
-
-UPDATE `%TABLE_PREFIX%config`
-    SET `schema_signature`='522e5b783c2824c67222260ee22baa93';
diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql b/setup/inc/sql/osticket-v1.7-mysql.sql
index b8bb7ce263dfbcb7442fda8b2e15b9edebdbb48c..ed6ea688e34b1e00a2adb0cbebdfe22a02e6f3d1 100644
--- a/setup/inc/sql/osticket-v1.7-mysql.sql
+++ b/setup/inc/sql/osticket-v1.7-mysql.sql
@@ -3,7 +3,7 @@ DROP TABLE IF EXISTS `%TABLE_PREFIX%api_key`;
 CREATE TABLE `%TABLE_PREFIX%api_key` (
   `id` int(10) unsigned NOT NULL auto_increment,
   `isactive` tinyint(1) NOT NULL default '1',
-  `ipaddr` varchar(16) NOT NULL,
+  `ipaddr` varchar(64) NOT NULL,
   `apikey` varchar(255) NOT NULL,
   `notes` text,
   `updated` datetime NOT NULL,
@@ -237,6 +237,7 @@ CREATE TABLE `%TABLE_PREFIX%email_filter` (
   `reject_email` tinyint(1) unsigned NOT NULL default '0',
   `use_replyto_email` tinyint(1) unsigned NOT NULL default '0',
   `disable_autoresponder` tinyint(1) unsigned NOT NULL default '0',
+  `canned_response_id` int(11) unsigned NOT NULL default '0',
   `email_id` int(10) unsigned NOT NULL default '0',
   `priority_id` int(10) unsigned NOT NULL default '0',
   `dept_id` int(10) unsigned NOT NULL default '0',
@@ -423,9 +424,8 @@ CREATE TABLE `%TABLE_PREFIX%session` (
   `session_data` longtext collate utf8_unicode_ci,
   `session_expire` datetime default NULL,
   `session_updated` datetime default NULL,
-  `user_id` int(10) unsigned NOT NULL default '0' COMMENT 'osTicket staff
-ID',
-  `user_ip` varchar(32) collate utf8_unicode_ci NOT NULL,
+  `user_id` int(10) unsigned NOT NULL default '0' COMMENT 'osTicket staff ID',
+  `user_ip` varchar(64) NOT NULL,
   `user_agent` varchar(255) collate utf8_unicode_ci NOT NULL,
   PRIMARY KEY  (`session_id`),
   KEY `updated` (`session_updated`),
@@ -497,7 +497,7 @@ CREATE TABLE `%TABLE_PREFIX%syslog` (
   `title` varchar(255) NOT NULL,
   `log` text NOT NULL,
   `logger` varchar(64) NOT NULL,
-  `ip_address` varchar(16) NOT NULL,
+  `ip_address` varchar(64) NOT NULL,
   `created` datetime NOT NULL,
   `updated` datetime NOT NULL,
   PRIMARY KEY  (`log_id`),
@@ -546,7 +546,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket` (
   `subject` varchar(64) NOT NULL default '[no subject]',
   `phone` varchar(16) default NULL,
   `phone_ext` varchar(8) default NULL,
-  `ip_address` varchar(16) NOT NULL default '',
+  `ip_address` varchar(64) NOT NULL default '',
   `status` enum('open','closed') NOT NULL default 'open',
   `source` enum('Web','Email','Phone','API','Other') NOT NULL default
 'Other',
@@ -660,6 +660,7 @@ CREATE TABLE `%TABLE_PREFIX%ticket_thread` (
   PRIMARY KEY  (`id`),
   KEY `ticket_id` (`ticket_id`),
   KEY `staff_id` (`staff_id`),
+  KEY `pid` (`pid`),
   FULLTEXT KEY `body` (`body`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 
diff --git a/setup/inc/sql/osticket-v1.7-mysql.sql.md5 b/setup/inc/sql/osticket-v1.7-mysql.sql.md5
index 4bdfcd1ce270c2ca67c9c9f461bef15d010936f6..c3f03508703f6860c9628810c3b59ef8af0ce864 100644
--- a/setup/inc/sql/osticket-v1.7-mysql.sql.md5
+++ b/setup/inc/sql/osticket-v1.7-mysql.sql.md5
@@ -1 +1 @@
-aa4664afc3b43d4068eb2e82684fc28e
+435c62c3b23795529bcfae7e7371d82e
diff --git a/setup/inc/sql/v1.6rc5-upgrade.sql b/setup/inc/sql/v1.6rc5-upgrade.sql
deleted file mode 100644
index 9f44710fe3bb1c4523433619c59e31e01bd94f73..0000000000000000000000000000000000000000
--- a/setup/inc/sql/v1.6rc5-upgrade.sql
+++ /dev/null
@@ -1,128 +0,0 @@
-ALTER TABLE `%TABLE_PREFIX%email` 
-ADD `userid` VARCHAR( 125 ) NOT NULL AFTER `name` ,
-ADD `userpass` VARCHAR( 125 ) NOT NULL AFTER `userid`,
-ADD `mail_active` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `userpass` ,
-ADD `mail_host` VARCHAR( 125 ) NOT NULL AFTER `mail_active` ,
-ADD `mail_protocol` ENUM( 'POP', 'IMAP' ) NOT NULL AFTER `mail_host` ,
-ADD `mail_encryption` ENUM( 'NONE', 'SSL' ) NOT NULL AFTER `mail_protocol` ,
-ADD `mail_port` INT( 6 ) NULL AFTER `mail_encryption` ,
-ADD `mail_fetchfreq` TINYINT( 3 ) NOT NULL DEFAULT '5' AFTER `mail_port` ,
-ADD `mail_fetchmax` TINYINT( 4 ) NOT NULL DEFAULT '30' AFTER `mail_fetchfreq` ,
-ADD `mail_delete` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `mail_fetchmax` ,
-ADD `mail_errors` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `mail_delete` ,
-ADD `mail_lasterror` DATETIME NULL AFTER `mail_errors` ,
-ADD `mail_lastfetch` DATETIME NULL AFTER `mail_lasterror` ,
-ADD `smtp_active` TINYINT( 1 ) NOT NULL AFTER `mail_lastfetch` ,
-ADD `smtp_host` VARCHAR( 125 ) NOT NULL AFTER `smtp_active` ,
-ADD `smtp_port` INT( 6 ) NULL AFTER `smtp_host` ,
-ADD `smtp_auth` TINYINT( 1 ) NOT NULL DEFAULT '1' AFTER `smtp_port` ;
-
-ALTER TABLE `%TABLE_PREFIX%groups` ADD `can_edit_tickets` TINYINT UNSIGNED NOT NULL DEFAULT '0' AFTER `dept_access` ;
-
-UPDATE `%TABLE_PREFIX%groups`  SET `can_edit_tickets`=1 WHERE `can_delete_tickets`=1;
-
-ALTER TABLE `%TABLE_PREFIX%ticket` ADD `duedate` DATETIME NULL AFTER `isoverdue` ;
-
-ALTER TABLE `%TABLE_PREFIX%ticket` ADD INDEX ( `duedate` ) ;
-
-ALTER TABLE `%TABLE_PREFIX%ticket` CHANGE `source` `source` ENUM( 'Web', 'Email', 'Phone', 'Other' ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'Other' ;
- 
-ALTER TABLE `%TABLE_PREFIX%email_template` 
-ADD `note_alert_subj` VARCHAR( 255 ) NOT NULL AFTER `message_alert_body` ,
-ADD `note_alert_body` TEXT NOT NULL AFTER `note_alert_subj` ;
-
-UPDATE `%TABLE_PREFIX%email_template`  SET  `note_alert_subj` = 'New Internal Note Alert',`note_alert_body` = '%staff,\r\n\r\nInternal note appended to ticket #%ticket\r\n\r\n----------------------\r\nName: %name\r\n\r\n%note\r\n-------------------\r\n\r\nTo view/respond to the ticket, please login to the support ticket system.\r\n\r\nYour friendly,\r\n\r\nCustomer Support System - powered by osTicket.';
-
-ALTER TABLE `%TABLE_PREFIX%ticket_message` ADD `messageId` VARCHAR( 255 ) NULL AFTER `ticket_id` ;
-ALTER TABLE `%TABLE_PREFIX%ticket_message` ADD INDEX ( `messageId` ) ;
-
-ALTER TABLE `%TABLE_PREFIX%config` 
-ADD `note_alert_active` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `message_alert_dept_manager` ,
-ADD `note_alert_laststaff` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `note_alert_active` ,
-ADD `note_alert_assigned` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `note_alert_laststaff` ,
-ADD `note_alert_dept_manager` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `note_alert_assigned` ;
-
-ALTER TABLE `%TABLE_PREFIX%department` ADD `autoresp_email_id` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `email_id` ;
-
-ALTER TABLE `%TABLE_PREFIX%department` ADD INDEX ( `autoresp_email_id` ) ;
-
-ALTER TABLE `%TABLE_PREFIX%config` CHANGE `default_priority` `default_priority_id` TINYINT( 2 ) UNSIGNED NOT NULL DEFAULT '2';
-
-ALTER TABLE `%TABLE_PREFIX%config` CHANGE `default_template` `default_template_id` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '1';
-
-ALTER TABLE `%TABLE_PREFIX%config` CHANGE `default_email` `default_email_id` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0';
-
-ALTER TABLE `%TABLE_PREFIX%config` CHANGE `default_dept` `default_dept_id` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '0';
-
-ALTER TABLE `%TABLE_PREFIX%config` CHANGE `enable_pop3_fetch` `enable_mail_fetch` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';
-
-ALTER TABLE `%TABLE_PREFIX%config` ADD `alert_email_id` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `overdue_grace_period` ;
-
-ALTER TABLE `%TABLE_PREFIX%config`
-ADD `default_smtp_id` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `default_template_id` ,
-ADD `spoof_default_smtp` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `default_smtp_id` ;
-
-ALTER TABLE `%TABLE_PREFIX%config` ADD `log_level` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '2' AFTER `random_ticket_ids` ;
-
-ALTER TABLE `%TABLE_PREFIX%config` 
-ADD `staff_max_logins` TINYINT UNSIGNED NOT NULL DEFAULT '4' AFTER `enable_daylight_saving` ,
-ADD `staff_login_timeout` INT UNSIGNED NOT NULL DEFAULT '2' AFTER `staff_max_logins` ;
-
-ALTER TABLE `%TABLE_PREFIX%config` 
-ADD `client_max_logins` TINYINT UNSIGNED NOT NULL DEFAULT '4' AFTER `staff_session_timeout` ,
-ADD `client_login_timeout` INT UNSIGNED NOT NULL DEFAULT '2' AFTER `client_max_logins` ;
-
-ALTER TABLE `%TABLE_PREFIX%config` ADD `show_answered_tickets` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `show_assigned_tickets` ;
-
-ALTER TABLE `%TABLE_PREFIX%ticket` ADD `isanswered` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `isoverdue` ;
-
-ALTER TABLE `%TABLE_PREFIX%ticket` ADD `lastmessage` DATETIME NULL AFTER `closed` , ADD `lastresponse` DATETIME NULL AFTER `lastmessage` ;
-
-ALTER TABLE `%TABLE_PREFIX%config` ADD `hide_staff_name` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `show_answered_tickets` ;
-
-ALTER TABLE `%TABLE_PREFIX%config` ADD `log_graceperiod` INT UNSIGNED NOT NULL DEFAULT '12' AFTER `log_level` ;
-
-ALTER TABLE `%TABLE_PREFIX%ticket` ADD `phone_ext` VARCHAR( 8 ) NULL DEFAULT NULL AFTER `phone` ;
-
-ALTER TABLE `%TABLE_PREFIX%ticket` ADD `topic`  VARCHAR(64) NULL DEFAULT NULL AFTER `subject` ;
-
-ALTER TABLE `%TABLE_PREFIX%ticket_message` ADD FULLTEXT (`message`);
-
-ALTER TABLE `%TABLE_PREFIX%ticket_response` ADD FULLTEXT (`response`);
-
-ALTER TABLE `%TABLE_PREFIX%ticket_note` ADD FULLTEXT (`note`);
-  
-ALTER TABLE `%TABLE_PREFIX%department` ADD `tpl_id` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `dept_id` ;
-
-ALTER TABLE `%TABLE_PREFIX%department` ADD INDEX ( `tpl_id` ) ;
-
-ALTER TABLE `%TABLE_PREFIX%email_template` ADD `notes` TEXT NULL AFTER `name` ;
-
-ALTER TABLE `%TABLE_PREFIX%config` CHANGE `api_key` `api_passphrase` VARCHAR( 125 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL;
-
-DROP TABLE IF EXISTS `%TABLE_PREFIX%api_key`;
-CREATE TABLE `%TABLE_PREFIX%api_key` (
-  `id` int(10) unsigned NOT NULL auto_increment,
-  `isactive` tinyint(1) NOT NULL default '1',
-  `ipaddr` varchar(16) NOT NULL,
-  `apikey` varchar(255) NOT NULL,
-  `updated` datetime NOT NULL default '0000-00-00 00:00:00',
-  `created` datetime NOT NULL default '0000-00-00 00:00:00',
-  PRIMARY KEY  (`id`),
-  UNIQUE KEY `ipaddr` (`ipaddr`)
-) ENGINE=MyISAM;
-
-DROP TABLE IF EXISTS `%TABLE_PREFIX%syslog`;
-CREATE TABLE `%TABLE_PREFIX%syslog` (
-  `log_id` int(11) unsigned NOT NULL auto_increment,
-  `log_type` enum('Debug','Warning','Error') NOT NULL,
-  `title` varchar(255) NOT NULL,
-  `log` text NOT NULL,
-  `logger` varchar(64) NOT NULL,
-  `ip_address` varchar(16) NOT NULL,
-  `created` datetime NOT NULL default '0000-00-00 00:00:00',
-  `updated` datetime NOT NULL default '0000-00-00 00:00:00',
-  PRIMARY KEY  (`log_id`),
-  KEY `log_type` (`log_type`)
-) ENGINE=MyISAM;
-
diff --git a/setup/inc/sql/v1.6st-upgrade.sql b/setup/inc/sql/v1.6st-upgrade.sql
deleted file mode 100644
index 571620fb1beddc9137ea77c133b7bc47cc7a6960..0000000000000000000000000000000000000000
--- a/setup/inc/sql/v1.6st-upgrade.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-ALTER TABLE `%TABLE_PREFIX%ticket` ADD `topic_id` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `priority_id`;
-
-ALTER TABLE `%TABLE_PREFIX%ticket` ADD INDEX ( `topic_id` );
-
-ALTER TABLE `%TABLE_PREFIX%ticket` CHANGE `topic` `helptopic` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
-
-ALTER TABLE `%TABLE_PREFIX%groups` ADD `can_create_tickets` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `dept_access`;
-
-ALTER TABLE `%TABLE_PREFIX%staff` ADD `auto_refresh_rate` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `max_page_size`;
-
-ALTER TABLE `%TABLE_PREFIX%config` ADD `ticket_notice_active` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `message_autoresponder`;
-
-ALTER TABLE `%TABLE_PREFIX%config` ADD `enable_captcha` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `use_email_priority`;
-
-ALTER TABLE `%TABLE_PREFIX%config` ADD `log_ticket_activity` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `strip_quoted_reply`;
-
-ALTER TABLE `%TABLE_PREFIX%config` ADD `staff_ip_binding` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER `enable_daylight_saving`;
-
-ALTER TABLE `%TABLE_PREFIX%staff` CHANGE `signature` `signature` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
-
-ALTER TABLE `%TABLE_PREFIX%department` CHANGE `dept_signature` `dept_signature` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
-
-ALTER TABLE `%TABLE_PREFIX%email_template`
-ADD `ticket_notice_subj` VARCHAR( 255 ) NOT NULL AFTER `ticket_autoresp_body` ,
-ADD `ticket_notice_body` TEXT NOT NULL AFTER `ticket_notice_subj`;
-
-INSERT INTO `%TABLE_PREFIX%kb_premade` (`premade_id`, `dept_id`, `isenabled`, `title`, `answer`, `created`, `updated`) VALUES
-    ('', 0, 1, 'Sample (with variables)', '\r\n%name,\r\n\r\nYour ticket #%ticket created on %createdate is in %dept department.\r\n\r\n', NOW(), NOW());
diff --git a/setup/inc/upgrade-done.inc.php b/setup/inc/upgrade-done.inc.php
deleted file mode 100644
index 0ec75c31a8099d5c0877231a00e274400a97f049..0000000000000000000000000000000000000000
--- a/setup/inc/upgrade-done.inc.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php if(!defined('SETUPINC')) die('Kwaheri!');
-$url=URL;
-
-?>    
-    <div id="main">
-        <h1 style="color:green;">Upgrade Completed!</h1>
-        <div id="intro">
-        <p>Congratulations osTicket upgrade has been completed successfully. Please refer to Release Notes for more information about changes and/or new features.</p>
-        <h3 style="color:#FF7700;">Post-upgrade manual cleanup</h3>
-        Please take a minute to cleanup!
-        <ul>
-            <li><b>Delete setup directory</b>:<br> After verifying that the upgrade completed correctly please delete setup folder.</li>
-            <li><b>Enable the helpdesk</b>:<br> You can now enable osTicket, be sure to take some time to explore changes and new features</li>
-        </ul>
-        </div>
-        <p>Once again, thank you for choosing osTicket. Your feedback is welcomed!</p>
-        <p>We take user feedback seriously and are dedicated to making changes based on your input. Feel free to let us know of any other improvements you would like to see in osTicket, so that we may add them in the future as we continue to develop better and better versions of osTicket.</p>
-        <p>Good luck.<p>
-        <p>osTicket Team.</p>
-        <br>
-        <p><b>PS</b>: Don't just make customers happy, make happy customers!</p>
-    </div>
-    <div id="sidebar">
-            <h3>What's Next?</h3>
-            <p><b>Post-upgrade</b>: You can now log in to <a href="../scp/admin.php" target="_blank">Admin Panel</a> and explore the new features. For complete and upto date release notes see <a href="http://osticket.com/wiki/Post-Install_Setup_Guide" target="_blank">osTicket wiki</a></p>
-          
-            <p><b>Stay up to date</b>: It's important to keep your osTicket installation up to date. Get announcements, security updates and alerts delivered directly to you! 
-            <a target="_blank" href="http://osticket.com/support/subscribe.php">Subcribe today</a> and be in the loop!</p>
-            <p><b>Commercial support available</b>: Get guidance and hands-on expertise to address unique challenges and make sure your osTicket runs smoothly, efficiently, and securely. <a target="_blank" href="http://osticket.com/support/commercial_support.php.php">Learn More!</a></p>
-   </div>
diff --git a/setup/setup.inc.php b/setup/setup.inc.php
index c2b404c74a68aeb346e091c4cd900e141464a135..5ccd831ab124fe149064c70802856d2ab9b1510a 100644
--- a/setup/setup.inc.php
+++ b/setup/setup.inc.php
@@ -14,6 +14,9 @@
     vim: expandtab sw=4 ts=4 sts=4:
 **********************************************************************/
 
+#This  version - changed on every release
+define('THIS_VERSION', '1.7-DPR4');
+
 #inits
 error_reporting(E_ALL ^ E_NOTICE); //turn on errors??
 ini_set('magic_quotes_gpc', 0);
@@ -52,6 +55,7 @@ ini_set('include_path', './'.PATH_SEPARATOR.INC_DIR.PATH_SEPARATOR.INCLUDE_DIR.P
 endif;
 
 #required files
+require_once(INCLUDE_DIR.'class.setup.php');
 require_once(INCLUDE_DIR.'class.validator.php');
 require_once(INCLUDE_DIR.'class.passwd.php');
 require_once(INCLUDE_DIR.'class.format.php');