diff -u -r SemanticMediaWiki/includes/SMW_GlobalFunctions.php SemanticMediaWiki-zen/includes/SMW_GlobalFunctions.php
--- SemanticMediaWiki/includes/SMW_GlobalFunctions.php	2007-04-28 20:10:33.000000000 +0300
+++ SemanticMediaWiki-zen/includes/SMW_GlobalFunctions.php	2007-06-04 15:07:25.000000000 +0300
@@ -144,6 +144,7 @@
 		global $smwgScriptPath;
 
 		if (!$smwgHeadersInPlace) {
+			/** BEGIN CHANGE - move to where timeline,table,tooltip used 
 			$toolTipScript = '<script type="text/javascript" src="' . $smwgScriptPath .  '/skins/SMW_tooltip.js"></script>';
 			$out->addScript($toolTipScript);
 			$sortTableScript = '<script type="text/javascript" id="SMW_sorttable_script_inclusion" src="' . $smwgScriptPath .  '/skins/SMW_sorttable.js"></script>';
@@ -152,10 +153,11 @@
 			$out->addScript($sortTableScript);
 
 			// TODO: we should rather have a script that only pulls the whole Timeline on demand, if possible
-			$TimelineScript = '<script type="text/javascript" src="' . $smwgScriptPath .  '/skins/SimileTimeline/timeline-api.js"></script>';
-			$SMWTimelineScript = '<script type="text/javascript" src="' . $smwgScriptPath .  '/skins/SMW_timeline.js"></script>';
-			$out->addScript($TimelineScript);
-			$out->addScript($SMWTimelineScript);
+			//$TimelineScript = '<script type="text/javascript" src="' . $smwgScriptPath .  '/skins/SimileTimeline/timeline-api.js"></script>';
+			//$SMWTimelineScript = '<script type="text/javascript" src="' . $smwgScriptPath .  '/skins/SMW_timeline.js"></script>';
+			//$out->addScript($TimelineScript);
+			//$out->addScript($SMWTimelineScript);
+			* END CHANGE */
 
 			// Also we add a custom CSS file for our needs
 			$customCssUrl = $smwgScriptPath . '/skins/SMW_custom.css';
diff -u -r SemanticMediaWiki/includes/SMW_Hooks.php SemanticMediaWiki-zen/includes/SMW_Hooks.php
--- SemanticMediaWiki/includes/SMW_Hooks.php	2007-04-27 20:39:57.000000000 +0300
+++ SemanticMediaWiki-zen/includes/SMW_Hooks.php	2007-06-04 15:07:25.000000000 +0300
@@ -138,6 +138,9 @@
 	 * escaped when inserted at an earlier stage.
 	 */
 	function smwfParseAttributesAfterTidyCallback($semanticLink) {
+		global $smwgScriptPath, $wgParser;
+		$toolTipScript = '<script type="text/javascript" src="' . $smwgScriptPath .  '/skins/SMW_tooltip.js"></script>';
+		$wgParser->mOutput->addHeadItem($toolTipScript, 'tooltip');
 		// Here we read the data hosted in the "span"-container. A toolTip
 		// is created to show the attribute values. To invoke the tooltip,
 		// we have to use a javaScript function (createToolTip) which writes
diff -u -r SemanticMediaWiki/includes/SMW_InlineQueries.php SemanticMediaWiki-zen/includes/SMW_InlineQueries.php
--- SemanticMediaWiki/includes/SMW_InlineQueries.php	2007-04-24 10:33:03.000000000 +0300
+++ SemanticMediaWiki-zen/includes/SMW_InlineQueries.php	2007-06-04 15:07:25.000000000 +0300
@@ -101,11 +101,20 @@
  * $param is an array which might contain values for various parameters
  * (see SMWInlineQuery).
  */
-function smwfProcessInlineQueries( $text, $param ) {
+function smwfProcessInlineQueries( $text, $param, &$parser) {
 	global $smwgIQEnabled;
 	$iq = new SMWInlineQuery($param);
 	if ($smwgIQEnabled) {
-		return $iq->getHTMLResult($text);
+		$result = $iq->getHTMLResult($text);
+		if (!$result) {
+			return $result;
+		}
+		if (array_key_exists('headers', $result)) {
+			foreach ($result['headers'] as $tag => $header) {
+				$parser->mOutput->addHeadItem($header, $tag);
+			}
+		}
+		return $result['html'];
 	} else {
 		return wfMsgForContent('smw_iq_disabled');
 	}
diff -u -r SemanticMediaWiki/includes/SMW_QueryPrinters.php SemanticMediaWiki-zen/includes/SMW_QueryPrinters.php
--- SemanticMediaWiki/includes/SMW_QueryPrinters.php	2007-04-12 11:59:04.000000000 +0300
+++ SemanticMediaWiki-zen/includes/SMW_QueryPrinters.php	2007-06-04 15:07:25.000000000 +0300
@@ -14,6 +14,7 @@
 	 * the query object for fetching data.
 	 */
 	public function printResult();
+	
 }
 
 /**
@@ -75,8 +76,14 @@
 		// print footer
 		$result .= "\t</table>";
 
-		return $result;
+		$ret = array();
+		$ret['html'] = $result;
+		global $smwgScriptPath;
+                $sortTableScript = '<script type="text/javascript" id="SMW_sorttable_script_inclusion" src="' . $smwgScriptPath .  '/skins/SMW_sorttable.js"></script>';
+		$ret['headers']['ask_table'] = $sortTableScript;
+		return $ret;
 	}
+
 }
 
 /**
@@ -206,8 +213,10 @@
 
 		// print footer
 		$result .= $footer;
-
-		return $result;
+		
+		$ret = array();
+		$ret['html'] = $result;
+		return $ret;
 	}
 }
 
@@ -372,8 +381,19 @@
 		// print footer
 		$result .= "</div>";
 
-		return $result;
+		$ret = array();
+		$ret['html'] = $result;
+		
+		global $smwgScriptPath;
+                $TimelineScript = '<script type="text/javascript" src="' . $smwgScriptPath .  '/skins/SimileTimeline/timeline-api.js"></script>';
+                $SMWTimelineScript = '<script type="text/javascript" src="' . $smwgScriptPath .  '/skins/SMW_timeline.js"></script>';
+
+		$ret['headers']['ask_timeline_1'] = $TimelineScript;
+		$ret['headers']['ask_timeline_2'] = $SMWTimelineScript;	
+
+		return $ret;
 	}
+
 }
 
 /**
@@ -484,8 +504,12 @@
 		$result .= $footer;
 
 		$smwgStoreActive = $old_smwgStoreActive;
-		return $result;
+
+		$ret = array();
+		$ret['html'] = $result;
+		return $ret;
 	}
+	public function addHeaders($parserOutput) {}
 }
 
 /**
@@ -548,7 +572,10 @@
 		}
 
 		$smwgStoreActive = $old_smwgStoreActive;
-		return $result;
+		$ret = array();
+		$ret['html'] = $result;
+		
+		return $ret;
 	}
 }
 
diff -u -r SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php SemanticMediaWiki-zen/specials/AskSpecial/SMW_SpecialAsk.php
--- SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php	2007-04-24 15:34:12.000000000 +0300
+++ SemanticMediaWiki-zen/specials/AskSpecial/SMW_SpecialAsk.php	2007-06-04 15:07:25.000000000 +0300
@@ -54,7 +54,15 @@
 		// print results if any
 		if ($smwgIQEnabled && ('' != $query) ) {
 			$iq = new SMWInlineQuery(array('offset' => $offset, 'limit' => $limit, 'format' => 'broadtable', 'mainlabel' => ' ', 'link' => 'all', 'default' => wfMsg('smw_result_noresults'), 'sort' => $sort, 'order' => $order), false);
-			$result = $iq->getHTMLResult($query);
+			$htmlAndHeaders = $iq->getHTMLResult($query);
+			if (array_key_exists('headers', $htmlAndHeaders)) {
+				global $wgOut;
+				foreach($htmlAndHeaders['headers'] as $tag=>$header) {
+					$wgOut->addHeadItem($tag, $header);
+
+				}
+			}
+			$result = $htmlAndHeaders['html'];
 
 			// prepare navigation bar
 			if ($offset > 0) 
