Index: modules/bms/include/invoices.php
===================================================================
--- modules/bms/include/invoices.php	(revision 673)
+++ modules/bms/include/invoices.php	(working copy)
@@ -272,7 +272,7 @@
 
 		function showShippingSelect($uuid,$shippingMethods){
 
-			?><select name="shippingmethodid" id="shippingmethodid" onchange="changeShipping()">
+			?><select name="shippingmethodid" id="shippingmethodid" onchange="changeShipping();changeTracking();">
 				<option value="" <?php if($uuid=="") echo "selected=\"selected\""?>>&lt;none&gt;</option>
 			<?php foreach($shippingMethods as $method){?>
 				<option value="<?php echo $method["uuid"]?>" <?php if($uuid==$method["uuid"]) echo "selected=\"selected\""?>><?php echo $method["name"]?></option>
@@ -293,7 +293,8 @@
 					`uuid`,
 					`name`,
 					`canestimate`,
-					`estimationscript`
+					`estimationscript`,
+					`trackingscript`
 				FROM
 					`shippingmethods`
 				WHERE
@@ -322,6 +323,7 @@
 				$phpbms->topJS[] = 'shippingMethods["'.$uuid.'"]["name"]="'.htmlQuotes($therecord["name"]).'";';
 				$phpbms->topJS[] = 'shippingMethods["'.$uuid.'"]["canestimate"]='.((int) $therecord["canestimate"]).';';
 				$phpbms->topJS[] = 'shippingMethods["'.$uuid.'"]["estimationscript"]="'.htmlQuotes($therecord["estimationscript"]).'";';
+				$phpbms->topJS[] = 'shippingMethods["'.$uuid.'"]["trackingscript"]="'.htmlQuotes($therecord["trackingscript"]).'";';
 			}
 
 			return $thereturn;
Index: modules/bms/install/createtables.sql
===================================================================
--- modules/bms/install/createtables.sql	(revision 673)
+++ modules/bms/install/createtables.sql	(working copy)
@@ -321,6 +321,7 @@
   `creationdate` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
   `modifiedby` INTEGER UNSIGNED,
   `modifieddate` TIMESTAMP,
+  `trackingscript` VARCHAR(128),
   `custom1` DOUBLE,
   `custom2` DOUBLE,
   `custom3` DATETIME,
Index: modules/bms/invoices_addedit.php
===================================================================
--- modules/bms/invoices_addedit.php	(revision 673)
+++ modules/bms/invoices_addedit.php	(working copy)
@@ -542,7 +542,11 @@
 
 					<p>
 						<label for="trackingno">tracking number</label><br />
-						<input id="trackingno" name="trackingno" type="text" value="<?php echo htmlQuotes($therecord["trackingno"]) ?>" size="50" maxlength="64" />
+						<?php  $trackingButtonDisable="";
+							if($therecord["trackingno"]=="") $trackingButtonDisable="Disabled";
+						?>
+						<input id="trackingno" name="trackingno" type="text" value="<?php echo htmlQuotes($therecord["trackingno"]) ?>" size="50" maxlength="64" onchange="changeTracking()" />
+						<button id="trackingButton" type="button" onclick="startTracking()" class="graphicButtons buttonShip<?php echo $trackingButtonDisable?>" title="Tracking"><span>Tracking</span></button>
 					</p>
 				</fieldset>
 			</div>
Index: modules/bms/javascript/invoice.js
===================================================================
--- modules/bms/javascript/invoice.js	(revision 673)
+++ modules/bms/javascript/invoice.js	(working copy)
@@ -1193,7 +1193,18 @@
 	estimateShippingButton.className = newClass;
 }
 
+function changeTracking(){
+	var trackingno = getObjectFromID("trackingno");
+	var TrackingButton=getObjectFromID("trackingButton");
+	var newClass="graphicButtons buttonShipDisabled";
+	var currentShipping = getObjectFromID("shippingmethodid").value;
 
+	if(trackingno.value!='' && shippingMethods[currentShipping]["trackingscript"]!='')
+		newClass="graphicButtons buttonShip";
+
+	TrackingButton.className = newClass;
+}
+
 shippingNotice="";
 function startEstimateShipping(){
 
@@ -1216,7 +1227,21 @@
 
 }//end function
 
+function startTracking(){
 
+	var thebutton = getObjectFromID("trackingButton");
+	var currentShipping = getObjectFromID("shippingmethodid").value;
+	var trackingno = getObjectFromID("trackingno").value;
+	var theURL = shippingMethods[currentShipping]["trackingscript"];
+
+	if(thebutton.className.indexOf("Disabled") == -1 && shippingMethods[currentShipping]["trackingscript"]!=''){
+		position = theURL.indexOf('%s');
+		theURL = theURL.substring(0,position)+trackingno+theURL.substring(position+2);
+		window.open(theURL,'phpBMS');
+	}//end if
+
+}//end function
+
 function performShippingEstimate(base){
 
 	var resultsArea = getObjectFromID("shippingNoticeResults");
Index: modules/bms/shippingmethods_addedit.php
===================================================================
--- modules/bms/shippingmethods_addedit.php	(revision 673)
+++ modules/bms/shippingmethods_addedit.php	(working copy)
@@ -102,6 +102,13 @@
 				<input id="estimationscript" name="estimationscript" type="text" value="<?php echo htmlQuotes($therecord["estimationscript"])?>" size="64" maxlength="128"/>
 			</p>
 		</fieldset>
+		<fieldset>
+			<legend>track shipment</legend>
+			<p><br />
+				<label for="trackingscript">tracking script</label><br />
+				<input id="trackingscript" name="trackingscript" type="text" value="<?php echo htmlQuotes($therecord["trackingscript"])?>" size="64" maxlength="128"/>
+			</p>
+		</fieldset>
 
                 <?php $theform->showCustomFields($db, $thetable->customFieldsQueryResult) ?>
 

