diff --git a/adium/Release/Makefile b/adium/Release/Makefile
index 5a25d15..9280d80 100644
--- a/adium/Release/Makefile
+++ b/adium/Release/Makefile
@@ -24,6 +24,8 @@ OFFICIAL_BUILD?=TRUE
 
 # Always builds in debug mode.
 NIGHTLY?=FALSE
+NIGHTLY_REPO?=adium #change to adium-1.4 on the 1.4 branch
+NIGHTLY_BRANCH?=default
 
 ###########
 # To release!
@@ -120,6 +122,10 @@ version:
 	defaults write $(ADIUM_PLIST) CFBundleGetInfoString "$(VERSION), Copyright 2001-2009 The Adium Team"
 	defaults write $(ADIUM_PLIST) CFBundleVersion "$(VERSION)"
 	defaults write $(ADIUM_PLIST) CFBundleShortVersionString "$(VERSION)"
+ifeq ($(NIGHTLY),TRUE)
+    defaults write $(ADIUM_PLIST) AINightlyRepo "$(NIGHTLY_REPO)"
+    defaults write $(ADIUM_PLIST) AINightlyBranch "$(NIGHTLY_BRANCH)"
+end
 	plutil -convert xml1 $(ADIUM_PLIST).plist
 
 compile:
diff --git a/adium/Release/upload-nightly.sh b/adium/Release/upload-nightly.sh
index 0ecbdfe..792e84c 100755
--- a/adium/Release/upload-nightly.sh
+++ b/adium/Release/upload-nightly.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# You need to set NIGHTLY_HOST and NIGHTLY_USER in environment, and have your 
+# You need to set NIGHTLY_HOST, NIGHTLY_USER, NIGHTLY_REPO, and NIGHTLY_BRANCH in environment, and have your 
 # public key in the authorized_keys file on the nightly server.
 
 # Set our working directory to be the parent of this script, in case we're run
@@ -9,6 +9,6 @@ PARENT=$(dirname $0)
 cd ${PARENT:-.}
 
 ADIUM_RELEASE_NAME=`head -n 1 build/latest.info | tail -n 1`
-scp build/latest.info build/${ADIUM_RELEASE_NAME}.dmg.md5 build/${ADIUM_RELEASE_NAME}.dmg ${NIGHTLY_USER}@${NIGHTLY_HOST}:
+scp build/latest.info build/${ADIUM_RELEASE_NAME}.dmg.md5 build/${ADIUM_RELEASE_NAME}.dmg ${NIGHTLY_USER}@${NIGHTLY_HOST}:${NIGHTLY_REPO}-${NIGHTLY_BRANCH}
 ssh ${NIGHTLY_USER}@${NIGHTLY_HOST} chmod go+r ${ADIUM_RELEASE_NAME}.dmg latest.info ${ADIUM_RELEASE_NAME}.dmg.md5
 
diff --git a/adium/Source/AIAdium.m b/adium/Source/AIAdium.m
index ef3c1a1..16013be 100644
--- a/adium/Source/AIAdium.m
+++ b/adium/Source/AIAdium.m
@@ -1078,7 +1078,11 @@ static NSString	*prefsCategory;
 	[profileInfo addObject:UPDATE_TYPE_DICT];
 #ifdef NIGHTLY_RELEASE
 	NSString *buildId = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AIBuildIdentifier"];
+    NSString *nightlyRepo = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AINightlyRepo"];
+    NSString *nightlyBranch = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AINightlyBranch"];
 	[profileInfo addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"revision", @"key", @"Revision", @"visibleKey", buildId, @"value", buildId, @"visibleValue", nil]];
+    [profileInfo addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"repo", @"key", nightlyRepo, @"value", nil]];
+    [profileInfo addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"branch", @"key", nightlyBranch, @"value", nil]];
 #endif
 
 	if (sendProfileInfo) {		
diff --git a/www/adium.im/sparkle/appcast-nightly.php b/www/adium.im/sparkle/appcast-nightly.php
index 89f2324..ca8c59f 100644
--- a/www/adium.im/sparkle/appcast-nightly.php
+++ b/www/adium.im/sparkle/appcast-nightly.php
@@ -1,12 +1,47 @@
 <?php
-	// The nightly host.
-	define("NIGHTLY_HOST", "nightly.adium.im");
+    function sane_path($path, $default) {
+        if (!isset($path) || preg_match("/\.\.|\/|<|>/", $path)) {
+            return $default;
+        } else {
+            return $path;
+        }
+    }
+    
+    function existing_branch($repo, $branch) {
+        if (is404(sprintf("http://%s/$repo-$branch/", NIGHTLY_DOMAIN)) {
+            $branch = "default";
+            if (is404(sprintf("http://%s/$repo-$branch/", NIGHTLY_DOMAIN)) {
+                $repo = "adium";
+            }
+        }
+        return array($repo, $branch); 
+    }
+    
+    function is404($url) {
+        $c = curl_init($url);
+        curl_setopt($c, CURLOPT_NOBODY, TRUE);
+        curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE);
+        $result = curl_exec($c);
+        curl_close($c);
+        return (strpos($result, "404 Not Found") !== FALSE);
+    }
+    
+    // The nightly domain.
+    define("NIGHTLY_DOMAIN", "nightly.adium.im");        
 	// The remote file name which contains the current build's information.
 	define("NIGHTLY_REMOTE_NAME", "latest.info");
-	// The location to cache the remote file.
-	define("NIGHTLY_CACHE", $config["cachedgraphs"] . "/nightly-cache.dat");
 	// The interval in seconds to check the remote file.
 	define("UPDATE_INTERVAL", 60*15);
+	
+    $repo = sane_path($_GET['repo'], 'adium');
+    $branch = sane_path($_GET['branch'], 'default');
+    list($repo, $branch) = existing_branch($repo, $branch);
+    $repo_branch = "$repo-$branch";
+
+	// The nightly host.
+	define("NIGHTLY_HOST", sprintf("%s/$repo_branch/", NIGHTLY_DOMAIN));
+	// The location to cache the remote file.
+	define("NIGHTLY_CACHE", $config["cachedgraphs"] . "/nightly-$repo_branch-cache.dat");
 
 	// Offsets by line in the build file:
 	define("FILENAME", 0);
@@ -34,7 +69,7 @@
 	$nightlyURL = sprintf("http://%s/%s.dmg", NIGHTLY_HOST, $nightlyData[FILENAME]);
 	
 	// The address for the changelog.
-	$tracURL = sprintf("http://hg.adium.im/adium/log?rev=%s",
+	$tracURL = sprintf("http://hg.adium.im/$repo/log?rev=%s",
 					str_replace("r", "", $nightlyData[REVISION]));
 
 ?><?php echo('<?');?>xml version="1.0" encoding="UTF-8"?>
diff --git a/www/nightly.adium.im/index.php b/www/nightly.adium.im/index.php
index 8bfd7d8..31ed0ed 100644
--- a/www/nightly.adium.im/index.php
+++ b/www/nightly.adium.im/index.php
@@ -6,6 +6,29 @@ function byteConvert(&$bytes){
         $e = (int)(log($b,1024)); 
         return number_format($b/pow(1024,$e),1,'.','').$s[$e];
 }
+
+function sane_path($path, $default) {
+    if (!isset($path) || preg_match("/\.\.|\/|<|>/", $path)) {
+        return $default;
+    } else {
+        return $path;
+    }
+}
+
+function existing_branch($repo, $branch) {
+    if (!file_exists("$repo-$branch")) {
+        $branch = "default";
+        if (!file_exists("$repo-$branch")) {
+            $repo = "adium";
+        }
+    }
+    return array($repo, $branch);
+}
+
+$repo = sane_path($_GET['repo'], 'adium');
+$branch = sane_path($_GET['branch'], 'default');
+list($repo, $branch) = existing_branch($repo, $branch);
+$repo_branch =  "$repo-$branch";
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
 	"http://www.w3.org/TR/html4/strict.dtd">
@@ -37,7 +60,7 @@ function byteConvert(&$bytes){
 			<a class="navtab" href="http://adium.im/">Download</a> <a class="navtab" href="http://adium.im/screenshots/">Screenshots</a> <a class="navtab" href="http://adium.im/screencasts/">Videos</a> <a class="navtab" href="http://adium.im/blog/">Blog</a> <a class="navtabcurrent" href="http://trac.adium.im">Support &amp; Development</a> <a class="navtab" href="http://www.adiumxtras.com/">Xtras</a>
 		</div>
 		<div id="content">
-			<h2>Nightly</h2>
+			<h2>Nightly for <?= $repo_branch ?></h2>
 			<p id="download" style="line-height: 1.3em;">
 				<img src="http://adium.im/images/logo_small.png" />
 		These are <strong>NOT A BETA</strong>; do not expect support. Betas can be found on the <a href="http://beta.adium.im">beta page</a>.<br />
@@ -53,11 +76,12 @@ function byteConvert(&$bytes){
 			<th>MD5</th>
             <th>Uploaded</th>
         </tr>
-<?  $filelist = array_reverse(scandir("/var/www/html/"));
+<?  $filelist = array_reverse(scandir($repo_branch));
 	
 	$alternating = 0;
 
-    foreach ($filelist as $filename) {  
+    foreach ($filelist as $filename) {
+        $filename = $repo_branch . "/" . $filename;
         if (preg_match("/^\./",$filename) || preg_match("/(latest.*|\.php|\.png|\.gif|\.md5)$/",$filename)) { continue; }
 
 		if ($alternating) {
@@ -97,4 +121,3 @@ function byteConvert(&$bytes){
 	</script>
 </body>
 </html>
-
