? collapsablelink.js
? esv.css
? esv_tooltip.js
? external.js
Index: scripturefilter.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/scripturefilter/scripturefilter.inc,v
retrieving revision 1.6
diff -u -r1.6 scripturefilter.inc
--- scripturefilter.inc	21 May 2007 16:40:51 -0000	1.6
+++ scripturefilter.inc	12 Jul 2007 15:02:06 -0000
@@ -1,58 +1,69 @@
 <?php
-/* $Id: scripturefilter.inc,v 1.6 2007/05/21 16:40:51 smsimms Exp $ */
+/* $Id: scripturefilter.inc,v 1.3.4.1 2007/05/21 16:45:34 smsimms Exp $ */
 
-define('DEFAULT_BIBLE_TRANSLATION','NIV');
+//Pull Bible Translation from settings.
+define('DEFAULT_BIBLE_TRANSLATION',variable_get("scripturefilter_default_translation_format", 'NIV'));
 
 function scripturize ($text = '',$bible = DEFAULT_BIBLE_TRANSLATION){
     // skip everything within a hyperlink, a <pre> block, a <code> block, or a tag
     // we skip tags because something like <img src="blah" alt="John 3:16"> should not be messed with
-    $anchor_regex = '<a\s+href.*?<\/a>';
-    $pre_regex = '<pre>.*<\/pre>';
-    $code_regex = '<code>.*<\/code>';
-    $tag_regex = '<(?:[^<>\s]*)(?:\s[^<>]*){0,1}>'; // $tag_regex='<[^>]+>';
-    $split_regex = "/((?:$anchor_regex)|(?:$pre_regex)|(?:$code_regex)|(?:$tag_regex))/i";
-
-    $parsed_text = preg_split($split_regex,$text,-1,PREG_SPLIT_DELIM_CAPTURE);
-    $linked_text = '';
-
-    while (list($key,$value) = each($parsed_text)) {
-        if (preg_match($split_regex,$value)) {
-	    $linked_text .= $value; // if it is an HTML element or within a link, just leave it as is
-	} else {
-            $linked_text .= scripturizeAddLinks($value,$bible); // if it's text, parse it for Bible references
+
+	if (!isset($bible)) {
+		$bible = gvariable_get("scripturefilter_default_translation_format", DEFAULT_BIBLE_TRANSLATION);
 	}
-    }
-    
-    return $linked_text;
+    // skip everything within a hyperlink, a <pre> block, a <code> block, or a tag
+    // we skip inside tags because something like <img src="nicodemus.jpg" alt="John 3:16"> should not be messed with
+	$anchor_regex = '<a\s+href.*?<\/a>';
+	$pre_regex = '<pre>.*<\/pre>';
+	$code_regex = '<code>.*<\/code>';
+	$tag_regex = '<(?:[^<>\s]*)(?:\s[^<>]*){0,1}>'; // $tag_regex='<[^>]+>';
+	$split_regex = "/((?:$anchor_regex)|(?:$pre_regex)|(?:$code_regex)|(?:$tag_regex))/i";
+
+	$parsed_text = preg_split($split_regex,$text,-1,PREG_SPLIT_DELIM_CAPTURE);
+	$linked_text = '';
+
+  while (list($key,$value) = each($parsed_text)) {
+      if (preg_match($split_regex,$value)) {
+         $linked_text .= $value; // if it is an HTML element or within a link, just leave it as is
+      } else {
+        $linked_text .= scripturizeAddLinks($value,$bible); // if it's text, parse it for Bible references
+      }
+  }
+
+  return $linked_text;
 }
 
 function scripturizeAddLinks($text = '',$bible = DEFAULT_BIBLE_TRANSLATION) {
-    $volume_regex = '1|2|3|I|II|III|1st|2nd|3rd|First|Second|Third';
 
-    $book_regex  = 'Genesis|Exodus|Leviticus|Numbers|Deuteronomy|Joshua|Judges|Ruth|Samuel|Kings|Chronicles|Ezra|Nehemiah|Esther';
-    $book_regex .= '|Job|Psalms?|Proverbs?|Ecclesiastes|Songs? of Solomon|Song of Songs|Isaiah|Jeremiah|Lamentations|Ezekiel|Daniel|Hosea|Joel|Amos|Obadiah|Jonah|Micah|Nahum|Habakkuk|Zephaniah|Haggai|Zechariah|Malachi';
-    $book_regex .= '|Mat+hew|Mark|Luke|John|Acts?|Acts of the Apostles|Romans|Corinthians|Galatians|Ephesians|Phil+ippians|Colossians|Thessalonians|Timothy|Titus|Philemon|Hebrews|James|Peter|Jude|Revelations?';
+	if (!isset($bible)) {
+	//Pull Bible translation from 
+	$bible=variable_get("scripturefilter_default_translation_format", DEFAULT_BIBLE_TRANSLATION);
+	}
 
-    // split these up from the Perl code because I want to be able to have an optional period at the end of just the abbreviations
+		$volume_regex = '1|2|3|I|II|III|1st|2nd|3rd|First|Second|Third';
 
-    $abbrev_regex  = 'Gen|Ex|Exo|Lev|Num|Nmb|Deut?|Josh?|Judg?|Jdg|Rut|Sam|Ki?n|Chr(?:on?)?|Ezr|Neh|Est';
-    $abbrev_regex .= '|Jb|Psa?|Pr(?:ov?)?|Eccl?|Song?|Isa|Jer|Lam|Eze|Dan|Hos|Joe|Amo|Oba|Jon|Mic|Nah|Hab|Zeph?|Hag|Zech?|Mal';
-    $abbrev_regex .= '|Mat|Mr?k|Lu?k|Jh?n|Jo|Act|Rom|Cor|Gal|Eph|Col|Phi|The?|Thess?|Tim|Tit|Phile|Heb|Ja?m|Pe?t|Ju?d|Rev';
+		$book_regex  = 'Genesis|Exodus|Leviticus|Numbers|Deuteronomy|Joshua|Judges|Ruth|Samuel|Kings|Chronicles|Ezra|Nehemiah|Esther';
+		$book_regex .= '|Job|Psalms?|Proverbs?|Ecclesiastes|Songs? of Solomon|Song of Songs|Isaiah|Jeremiah|Lamentations|Ezekiel|Daniel|Hosea|Joel|Amos|Obadiah|Jonah|Micah|Nahum|Habakkuk|Zephaniah|Haggai|Zechariah|Malachi';
+		$book_regex .= '|Mat+hew|Mark|Luke|John|Acts?|Acts of the Apostles|Romans|Corinthians|Galatians|Ephesians|Phil+ippians|Colossians|Thessalonians|Timothy|Titus|Philemon|Hebrews|James|Peter|Jude|Revelations?';
 
-    $book_regex='(?:'.$book_regex.')|(?:'.$abbrev_regex.')\.?';
+		$abbrev_regex  = 'Gen|Ex|Exo|Lev|Num|Nmb|Deut?|Josh?|Judg?|Jdg|Rut|Sam|Ki?n|Chr(?:on?)?|Ezr|Neh|Est';
+		$abbrev_regex .= '|Jb|Psa?|Pr(?:ov?)?|Eccl?|Song?|Isa|Jer|Lam|Eze|Dan|Hos|Joe|Amo|Oba|Jon|Mic|Nah|Hab|Zeph?|Hag|Zech?|Mal';
+		$abbrev_regex .= '|Mat|Mr?k|Lu?k|Jh?n|Jo|Act|Rom|Cor|Gal|Eph|Col|Phi(?:l?)?|The?|Thess?|Tim|Tit|Phile|Heb|Ja?m|Pe?t|Ju?d|Rev';
 
-    $verse_regex="\d{1,3}(?::\d{1,3})?(?:\s?(?:[-&,]\s?\d+))*";
+		$book_regex = '(?:'.$book_regex.')|(?:'.$abbrev_regex.')\.?';
 
-    $translation_regex = 'NIV|NASB|AMP|NLT|KJV|ESV|CEV|NET|NKJV|KJ21|ASV|WE|YLT|DARBY|WYC|NIV-UK|TNIV|MSG|NIRV';
+		$verse_substr_regex = "(?:[:.][0-9]{1,3})?(?:[-&,;]\s?[0-9]{1,3})*";
+		$verse_regex = "[0-9]{1,3}(?:". $verse_substr_regex ."){1,2}";
 
-    // note that this will be executed as PHP code after substitution thanks to the /e at the end!
+    $translation_regex = 'NIV-UK|NIV|NLV|NASB|AMP|NLT|KJV|ESV|CEV|NET|NKJV|KJ21|ASV|WE|YLT|DARBY|WYC|TNIV|MSG|NIRV|NRSV|LXX';
 
+	// note that this will be executed as PHP code after substitution thanks to the /e at the end!
     $passage_regex = '/(?:('.$volume_regex.')\s)?('.$book_regex.')\s('.$verse_regex.')(?:\s?[,-]?\s?((?:'.$translation_regex.')|\s?\((?:'.$translation_regex.')\)))?/e';
 
     $replacement_regex = "scripturizeLinkReference('\\0','\\1','\\2','\\3','\\4','$bible')";
 
     $text=preg_replace($passage_regex,$replacement_regex,$text);
-
+	
     return $text;
 }
 
@@ -74,40 +85,503 @@
        $translation = trim($translation,' ()'); // strip out any parentheses that might have made it this far
    }
 
+   //Generate combined variables
+   $passage = $volume ."+". $book."+".$verse;
+   $displaypassage = trim($volume . " " . $book . " " . $verse);
+   
    // if necessary, just choose part of the verse reference to pass to the web interfaces
    // they wouldn't know what to do with John 5:1-2, 5, 10-13 so I just give them John 5:1-2
    // this doesn't work quite right with something like 1:5,6 - it gets chopped to 1:5 instead of converted to 1:5-6
    if ($verse) {
        $verse = strtok($verse,',& ');
    }
-
+   
+   //Build Title attribut according to bibleref semantic standards
+   $biblereftitle = buildBiblerefTitle($translation, $volume, $book, $verse);
+
+   //Do we want links to open in a new window?
+   If(variable_get("scripturefilter_new_window", FALSE) == TRUE){
+   $external = "rel = 'external'";
+   }
+   else{
+   $external = "";
+   }
+   
    switch ($translation) {
         case 'ESV':
-        // note: the ESV could actually support a mouseover reference
-        // we could pull it directly from their site and include it in the $title text
-        // http://www.gnpcb.org/esv/share/services/api/ for more info
-             $link = 'http://www.gnpcb.org/esv/search/?go=Go&q=';
-             $title = 'English Standard Version Bible';
-             $link = sprintf('<a href="%s%s" title="%s">%s</a>',$link,htmlentities(urlencode(trim("$volume $book $verse"))),$title,trim($reference));
-             break;
+		   	//The ESV API allows us to do much more with this translation.  Options for the ESV are set on the settings page of the plugin.
+			//Call a diferent function to return the link dependant upon the settings
+			If(variable_get("scripturefilter_default_esvdisplaystyle", 'verse')=='tooltip'){
+			$link = esv_tooltip($passage, $displaypassage, $external);
+			}
+			elseif(variable_get("scripturefilter_default_esvdisplaystyle", 'verse')=='inline'){
+			$link = esv_inline($passage,$displaypassage);
+			}
+			elseif(variable_get("scripturefilter_default_esvdisplaystyle", 'verse')=='verse'){
+			$link = '<a href="http://www.gnpcb.org/esv/search/?q='. $passage .'" class="bibleref" '.$external.' title="'.$biblereftitle. '">'. trim($displaypassage) .'</a>';
+			}
+			break;
         case 'NET':
-             $link = 'http://net.bible.org/passage.php?passage=';
-             $title = 'New English Translation';
-             $link = sprintf('<a href="%s%s" title="%s">%s</a>',$link,htmlentities(urlencode(trim("$volume $book $verse"))),$title,trim($reference));
+            $chapter = trim(strtok($verse,':'));
+            $verses = trim(strtok('-,'));			
+			$link = 'http://net.bible.org/passage.php?passage=';
+            $link = sprintf('<a href="%s%s" title="'.$biblereftitle.'"  '.$external.' class="bibleref">%s</a>',$link,htmlentities(urlencode(trim("$volume $book $verse"))),$displaypassage,trim($reference));
              break;
-	case 'TNIV':
-             $link = 'http://www.tniv.info/bible/passagesearch.php?passage_request=';
-             $title = 'Today\'s New International Version';
-             $link = sprintf('<a href="%s%s" title="%s">%s</a>',$link,htmlentities(urlencode(trim("$volume $book $verse"))),$title,trim($reference));
-	     break;
-        default:
-             $link = "http://biblegateway.com/cgi-bin/bible?language=english&version=$translation&passage=";
-             $title = 'Bible Gateway';
-             $link = sprintf('<a href="%s%s" title="%s">%s</a>',$link,htmlentities(urlencode(trim("$volume $book $verse"))),$title,trim($reference));
+			case 'NRSV':
+			// example URL http://bible.oremus.org/?passage=John+1%3A1&vnum=yes&version=nrsv
+			// there is a new interface being developed at http://bible.oremus.org/bible.cgi
+             $link = 'http://bible.oremus.org/';
+			 $options ='&amp;vnum=yes&amp;version=nrsv';
+             $link = sprintf('<a href="%s?passage=%s%s" title="%s"  '.$external.' class="bibleref">%s</a>',$link,htmlentities(urlencode(trim("$volume $book $verse"))),$options,$title,trim($reference));
              break;
+			case 'LXX':
+			// example URL http://www.zhubert.com/bible?book=Matthew&chapter=2&verse=3
+			// there's also an XML interface to this content - could do a trick like I propose with the ESV
+            $link = 'http://www.zhubert.com/bible';
+			$chapter=zhubertize_chapter($verse);
+			$verse=zhubertize_verse($verse);
+			$book=zhubertize_book($volume.' '.$book);
+            
+			If(variable_get("scripturefilter_default_lxxdisplaystyle", 'verse')=='flash'){
+			$link = lxx_inline($volume,$book,$chapter,$verse, $displaypassage);
+}
+			elseif(variable_get("scripturefilter_default_lxxdisplaystyle", 'verse')=='verse'){
+			$link = sprintf('<a href="%s?book=%s&amp;chapter=%d&amp;verse=%d" title="%s"  '.$external.' class="bibleref">%s</a>',$link,htmlentities(urlencode(trim($book))),$chapter,$verse,$title,trim($displaypassage));
+            ;
+			}
+
+			 break;
+        default:
+		//The & symbol must be replaced with &amp; throughout, including and links to be XHTML Compliant.
+            $link = "http://biblegateway.com/cgi-bin/bible?language=english&amp;version=$translation&amp;passage=";
+            $link = sprintf('<a href="%s%s" title="'.$biblereftitle.'"  '.$external.' class="bibleref">%s</a>',$link,htmlentities(urlencode(trim("$volume $book $verse"))),$displaypassage,trim($reference));
+            break;
     }
 
     return $link;
 }
 
+function esv_getverse($passage){
+//Set options for ESV text
+		$options =  "&include-footnotes=".variable_get("scripturefilter_esv_include-footnotes",TRUE);
+		$options .= "&include-audio-link=".variable_get("scripturefilter_esv_audio",TRUE);
+		$options .= "&audio-format=".variable_get('scripturefilter_esv_audio-format', 'flash');
+		$options .= "&audio-version=".variable_get('scripturefilter_esv_audio-version', 'mm');
+		$options .= "&include-headings=".variable_get("scripturefilter_esv_include-headings",TRUE);
+		$options .= "&include-subheadings=".variable_get("scripturefilter_esv_include-subheadings",TRUE);
+		$options .= "&include-verse-numbers=".variable_get("scripturefilter_esv_include-verse-numbers",TRUE);
+
+
+             $url = "http://www.gnpcb.org/esv/share/get/?key=" . variable_get("scripturefilter_esv_$API_key",IP). "&passage=" . $passage ."&action=doPassageQuery".$options;
+             
+			 //Pulls text from the ESV website via curl or fopen
+				if (function_exists("curl_init")) {
+					$ch = curl_init($url);
+					curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+					$VerseText = curl_exec($ch);
+					curl_close($ch);
+				} else if (ini_get('allow_url_fopen') == true) {
+					if ($rvs = fopen($url, 'r')) {
+						$VerseText = "";
+
+						while (!feof($rvs)) {
+							$VerseText .= fgets($rvs);
+						}
+
+						fclose($rvs);
+					}
+				} else {
+					$readerr = 1;
+					$VerseText = "Error retrieving passage text - curl and remote fopen both seem to be disabled on your host.";
+				}
+
+				if ($readerr == 0)
+				{
+					if (strpos($VerseText, "You have exceeded your quota of 500 requests per day.") === false) {
+					} else {
+						$VerseText = "Error retrieving Bible passage. Please check again tomorrow.";
+					}
+				}
+				   				
+	Return $VerseText;
+}
+
+function esv_getcache($passage,$reset = FALSE) {
+    //This function will check if the passage requested is currently in cache, if it is it will use the cached text, if not it will request the text and add it to the cache for 24hours
+	
+	if (!$reset && ($cache = cache_get('scripture'.$passage)) && !empty($cache->data)) {
+      $VerseText = unserialize($cache->data);
+    }
+    else {
+      // Do your expensive calculations here, and populate $my_data
+      // with the correct stuff..
+	  $VerseText = esv_getverse($passage);
+	  //Cache Bible Verse for 24hours - 60*60*24 = 86400
+      cache_set('scripture'.$passage, 'cache', serialize($VerseText), time() + 86400);
+    }
+  return $VerseText;
+}
+
+function esv_inline($passage, $displaypassage){
+		//This function generates the link to pass back for the collapsed inline block
+
+				$VerseText = esv_getcache($passage);
+				//clean up text
+   				$VerseText = str_replace("\n", "", $VerseText);
+				$VerseText = str_replace("\r", "", $VerseText);
+				$VerseText = str_replace("'", "&#8217;", $VerseText);
+				//replace h2,h3 and p tag as these are not xhtml complian within a span tag -  these are replaced with span tags with formatting set in the settings page.
+				$VerseText = str_replace("<h2", "<span style='font-size:".variable_get("scripturefilter_esv_inline-heading-fontsize",'20')."px;' class='passageheading'", $VerseText);
+				$VerseText = str_replace("</h2>", "</span>", $VerseText);
+				$VerseText = str_replace("<h3", "<span style='font-size:". variable_get("scripturefilter_esv_inline-subheading-fontsize",'16') ."px;' class='passagesubheading'", $VerseText);
+				$VerseText = str_replace("</h3>", "</span>", $VerseText);
+				$VerseText = str_replace("<p class=", "<span style='display:block;' class='passagetext'", $VerseText);
+				$VerseText = str_replace("<p>", "<span style='display:block;' class='passagetext'>", $VerseText);
+				$VerseText = str_replace("</p>", "</span>", $VerseText);
+				$VerseText = strip_tags($VerseText, "<br><span><object><param><a>");
+				
+
+				//Style the collasible block
+				$esv_div_style ="white-space: normal;";
+				$esv_div_style ="background-color: ".variable_get("scripturefilter_esv_inline-background-colour",'white').";";
+				$esv_div_style.="display: none;"; 
+				$esv_div_style.="padding: 10px;";
+				$esv_div_style.="border: ". variable_get('scripturefilter_esv_inline-border-style', 'dotted').' '.variable_get("scripturefilter_esv_inline-border-colour",'blue').' '.variable_get("scripturefilter_esv_inline-border-width",'1')."px;";
+				$esv_div_style.="border-left: solid ".variable_get("scripturefilter_esv_inline-border-colour",'blue')." ".variable_get("scripturefilter_esv_inline-left-border",'5')."px;";
+				$esv_div_style.="color: ".variable_get("scripturefilter_esv_inline-text-colour",'black').";";
+	
+		$esvSpanId = 'scripturefilter' .mt_rand(); //prefix the rand number with "id" to pass XHTML validation
+    
+	//Generate the link and span tags which will be passed as js variables and then replace the static link if js is available
+	$output_dynamic = "<a href=\"javascript://\" onclick=\"esvshowhide('".$esvSpanId."')\">".$displaypassage." [+/-]</a><span class='bibleref' title='".trim($displaypassage). "' id=\"" . $esvSpanId . "\" style=\"" . $esv_div_style. "\">" .$VerseText . "</span>";
+				
+				//Tidy up the passage reference so that it can be used as part of the js variable name
+				$passage_java = str_replace('+','_',$passage);
+				$passage_java = str_replace('-','_',$passage_java);
+				$passage_java = str_replace(':','_',$passage_java);
+				$passage_java = str_replace(';','v',$passage_java);
+		
+		//pass the link and span tage to a js variable which can be called by jQuery
+		drupal_add_js("var drupal_scripture".$passage_java." = " . drupal_to_js($output_dynamic) . ";", 'inline');
+		
+		//Generate a static link which will be replaced if js is available
+		$output_static = '<a href="http://www.gnpcb.org/esv/search/?q='. $passage .'"  '.$external.' class="scripturefilteresvlink bibleref" id="drupal_scripture'.$passage_java.'" title="'.trim($displaypassage). '">'. trim($displaypassage) .'</a>';
+
+	Return $output_static;
+}
+
+function esv_tooltip($passage, $displaypassage, $external){
+		//This function generates the link to pass back for the hover tooltip
+				$VerseText = esv_getcache($passage);
+
+				//Clean up the Text
+   				$VerseText = str_replace("\n", "", $VerseText);
+				$VerseText = str_replace("\r", "", $VerseText);
+				$VerseText = strip_tags($VerseText, "<div><br><span><p>");
+				$VerseText = str_replace("(Listen)", "", $VerseText);
+				$VerseText = str_replace("'", "&#8217;", $VerseText);
+
+				
+				preg_match('/<div class="esv">(.*?)<div class="esv-text">/i', $VerseText, $matches);
+				$VerseRef = $matches[0];
+				$VerseRef = strip_tags($VerseRef, "");
+				$VerseText = preg_replace('/<div class="esv">(.*?)<div class="esv-text">/i', '', $VerseText);
+			
+				//If header setting is true, then set the header
+				IF (variable_get("scripturefilter_esv_show-header",TRUE) ==  TRUE){
+				$tooltipheader = trim($displaypassage);
+				}
+				
+				//Generate link, with the text contained within the onmouseover event.  Becuase the this still forms a normal link it gracefully degrades when js is unavailable
+				$ReturnText = '<a href="http://www.gnpcb.org/esv/search/?q='. $passage .'" onmouseover="toolText(\''. $tooltipheader .'\', \''. htmlentities($VerseText) .'\');" onmouseout="clearTip()" class="bibleref"  '.$external.' title="'.trim($displaypassage). '">'. trim($displaypassage) .'</a>';
+
+						return $ReturnText;
+}
+
+function lxx_inline($volume, $book, $chapter, $verse, $displaypassage){
+		//This function generates the link to pass back for the collapsed inline flash block for the LXX translation
+		
+		$lxxSpanId = 'scripturefilter' .mt_rand(); //prefix the rand number with "id" to pass XHTML validation
+		
+		$passage = $volume ."+". $book."+".$chapter.":".$verse;
+   	
+	//Generate the embed tag which will call the flash LXX player
+	$flashplayer = "<embed src='http://www.zhubert.com/xml/interface.lzx.swf?verseref=" . $passage . "' pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" height=".variable_get("scripturefilter_lxx_flash_height",'400')." width=".variable_get("scripturefilter_lxx_flash_width",'100%').">";
+	
+	//Generate the link and span tags which will be passed as js variables and then replace the static link if js is available
+	$output_dynamic = "<a href=\"javascript://\" onclick=\"lxxshowhide('".$lxxSpanId."');\">".$displaypassage." [+/-]</a><span class='bibleref' title='".trim($displaypassage). "' id=\"" . $lxxSpanId . "\" style=\"display:none;\">". $flashplayer . "</span>";
+				
+				//Tidy up the passage reference so that it can be used as part of the js variable name
+				$passage_java = str_replace('+','_',$passage);
+				$passage_java = str_replace('-','_',$passage_java);
+				$passage_java = str_replace(':','_',$passage_java);
+				$passage_java = str_replace(';','v',$passage_java);
+		
+		//pass the link and span tage to a js variable which can be called by jQuery
+		drupal_add_js("var drupal_scripture".$passage_java." = " . drupal_to_js($output_dynamic) . ";", 'inline');
+
+        $link = 'http://www.zhubert.com/bible';
+		
+		//Generate a static link which will be replaced if js is available
+		$output_static = sprintf('<a id="drupal_scripture'.$passage_java.'"  '.$external.' title="'.trim($displaypassage). '" href="%s?book=%s&amp;chapter=%d&amp;verse=%d" class="scripturefilterlxxlink bibleref">%s</a>',$link,htmlentities(urlencode(trim($book))),$chapter,$verse,trim($displaypassage));
+
+	Return $output_static;
+}
+
+//Build a complaint bibleref title attribute
+function buildBiblerefTitle($translation, $volume, $book, $verse){
+	$book = str_replace('.','',$book);
+	$output = $translation .' ' .$volume.$book. ' ' .$verse;
+	return $output;
+}
+
+//prepare chapter reference for LXX translation
+function zhubertize_chapter($reference="") {
+	$chapter=strtok($reference,':');
+	return $chapter;
+}
+//prepare verse reference for LXX translation
+function zhubertize_verse($reference="") {
+	$chapter=strtok($reference,':');
+	$verse=strtok(' ,-;');
+	if (!$verse) {
+		$verse=1;
+	}
+	return $verse;
+}
+
+//prepare book reference for LXX translation
+function zhubertize_book($rawbook) {
+	$book = strtolower(trim($rawbook));
+    $book = preg_replace('/\s+/', '', $book); //strip whitespace
+	$book= substr($book,0,3);
+	switch ($book) {
+		case 'gen':
+			$book='Genesis';
+			break;
+		case 'exo':
+		case 'ex':
+			$book='Exodus';
+			break;
+		case 'lev':
+		case 'lv':
+			$book='Leviticus';
+			break;
+		case 'num':
+			$book='Numbers';
+			break;
+		case 'deu':
+		case 'dt':
+			$book='Deuteronomy';
+			break;
+		case 'jos':
+			$book='Joshua';
+			break;
+		case 'jud':
+		case 'jd':
+			// could be either Judges or Jude
+			// abbreviations for Judges should always have a g in them
+			$judges=strpos($rawbook,'g');
+			if ($judges===FALSE) {
+				$book='Jude';
+			} else {
+				$book='Judges';
+			}
+			break;
+		case 'rut':
+		case 'rth':
+			$book='Ruth';
+			break;
+		case '1sa':
+			$book='1 Samuel';
+			break;
+		case '2sa':
+			$book='2 Samuel';
+			break;
+		case '1ki':
+			$book='1 Kings';
+			break;
+		case '2ki':
+			$book='2 Kings';
+			break;
+		case '1ch':
+			$book='1 Chronicles';
+			break;
+		case '2ch':
+			$book='2 Chronicles';
+			break;
+		case 'ezr':
+		case 'ez':
+			$book='Ezra';
+			break;
+		case 'neh':
+		case 'nh':
+			$book='Nehemiah';
+			break;
+		case 'est':
+			$book='Esther';
+			break;
+		case 'job':
+		case 'jb':
+			$book='Job';
+			break;
+		case 'psa':
+		case 'ps':
+			$book='Psalms';
+			break;
+		case 'pro':
+		case 'pr':
+			$book='Proverbs';
+			break;
+		case 'ecc':
+			$book='Qoheleth';
+			break;
+		case 'son':
+		case 'sos':
+			$book='Canticle of Canticles';
+			break;
+		case 'isa':
+		case 'is':
+			$book='Isaiah';
+			break;
+		case 'jer':
+			$book='Jeremiah';
+			break;
+		case 'eze':
+		case 'ez':
+			$book='Ezekiel';
+			break;
+		case 'dan':
+		case 'dn':
+			$book='Daniel';
+			break;
+		case 'hos':
+			$book='Hosea';
+			break;
+		case 'joe':
+			$book='Joel';
+			break;
+		case 'amo':
+		case 'am':
+			$book='Amos';
+			break;
+		case 'oba':
+		case 'ob':
+			$book='Obadiah';
+			break;
+		case 'jon':
+			$book='Jonah';
+			break;
+		case 'mic':
+			$book='Micah';
+			break;
+		case 'nah':
+			$book='Nahum';
+			break;
+		case 'hab':
+			$book='Habakkuk';
+			break;
+		case 'zep':
+			$book='Zephaniah';
+			break;
+		case 'hag':
+			$book='Haggai';
+			break;
+		case 'zec':
+			$book='Zechariah';
+			break;
+		case 'mal':
+			$book='Malachi';
+			break;
+		case 'mat':
+		case 'mt':
+			$book='Matthew';
+			break;
+		case 'mar':
+		case 'mk':
+			$book='Mark';
+			break;
+		case 'luk':
+		case 'lk':
+			$book='Luke';
+			break;
+		case 'joh':
+		case 'jn':
+			$book='John';
+			break;
+		case 'act':
+			$book='Acts';
+			break;
+		case 'rom':
+		case 'rm':
+			$book='Romans';
+			break;
+		case '1co':
+			$book='1 Corinthians';
+			break;
+		case '2co':
+			$book='2 Corinthians';
+			break;
+		case 'gal':
+			$book='Galatians';
+			break;
+		case 'eph':
+			$book='Ephesians';
+			break;
+		case 'phi':
+			$book='Philippians';
+			break;
+		case 'col':
+			$book='Colossians';
+			break;
+		case '1th':
+			$book='1 Thessalonians';
+			break;
+		case '2th':
+			$book='2 Thessalonians';
+			break;
+		case '1ti':
+			$book='1 Timothy';
+			break;
+		case '2ti':
+			$book='2 Timothy';
+			break;
+		case 'tit':
+		case 'ti':
+			$book='Titus';
+			break;
+		case 'phi':
+			$book='Philemon';
+			break;
+		case 'heb':
+			$book='Hebrews';
+			break;
+		case 'jam':
+			$book='James';
+			break;
+		case '1pe':
+			$book='1 Peter';
+			break;
+		case '2pe':
+			$book='2 Peter';
+			break;
+		case '1jo':
+			$book='1 John';
+			break;
+		case '2jo':
+			$book='2 John';
+			break;
+		case '3jo':
+			$book='3 John';
+			break;
+		// jude is handled up by judges
+		case 'rev':
+			$book='Revelation';
+			break;
+		default:
+			$book=$rawbook;
+	}
+	return $book;
+}
+
 ?>
Index: scripturefilter.info
===================================================================
RCS file: /cvs/drupal/contributions/modules/scripturefilter/scripturefilter.info,v
retrieving revision 1.1
diff -u -r1.1 scripturefilter.info
--- scripturefilter.info	24 Feb 2007 23:53:04 -0000	1.1
+++ scripturefilter.info	12 Jul 2007 14:16:15 -0000
@@ -1,3 +1,8 @@
 ; $Id: scripturefilter.info,v 1.1 2007/02/24 23:53:04 smsimms Exp $
 name = Scripturefilter
 description = Turns any Scripture reference into a link to one of several online Bibles.
+
+; Information added by drupal.org packaging script on 2007-02-25
+version = "5.x-1.0"
+project = "scripturefilter"
+
Index: scripturefilter.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/scripturefilter/scripturefilter.module,v
retrieving revision 1.9
diff -u -r1.9 scripturefilter.module
--- scripturefilter.module	25 Feb 2007 00:13:22 -0000	1.9
+++ scripturefilter.module	12 Jul 2007 14:31:54 -0000
@@ -1,5 +1,5 @@
 <?php
-/* $Id: scripturefilter.module,v 1.9 2007/02/25 00:13:22 smsimms Exp $ */
+/* $Id: scripturefilter.module,v 1.8.4.1 2007/05/21 16:45:34 smsimms Exp $ */
 
 function scripturefilter_help($section) {
   switch ($section) {
@@ -18,51 +18,430 @@
     case 'list':
       return array(0 => t('Scripture Filter'));
 
+	 //No chache is needed as otherwise text is not passed to js variable
+	 case 'no cache':
+     return true;
+	  
     case 'description':
       return t('Turns any Scripture reference into a link to one of several online Bibles.');
 
     case 'process':
       return scripturize($text, variable_get("scripturefilter_default_translation_$format", DEFAULT_BIBLE_TRANSLATION));
      
-    case 'settings':
-      $form['filter_scripturefilter'] = array(
-        '#type' => 'fieldset',
-        '#title' => 'Scripture filter',
-        '#collapsible' => TRUE,
-        '#description' => t('This filter enables content that has a reference to Scripture to be linked to one of several online Bibles, such as BibleGateway, the ESV online Bible and the NET Bible.')
-      );
-
-      $form['filter_scripturefilter']["scripturefilter_default_translation_$format"] = array(
-        '#type' => 'select',
-        '#title' => t('Default Bible translation'),
-        '#default_value' => variable_get("scripturefilter_default_translation_$format", DEFAULT_BIBLE_TRANSLATION),
-        '#options' => array(
-          "KJ21" => t("21st Century King James Version"),
-          "ASV" => t("American Standard Version"),
-          "AMP" => t("Amplified Bible"),
-          "CEV" => t("Contemporary English Version"),
-          "DARBY" => t("Darby Translation"),
-          "ESV" => t("English Standard Version"),
-          "KJV" => t("King James Version"),
-          "MSG" => t("The Message"),
-          "NASB" => t("New American Standard Bible"),
-          "NET" => t("New English Translation"),
-          "NIRV" => t("New International Reader's Version"),
-          "NIV" => t("New International Version"),
-          "NIV-UK" => t("New International Version - UK"),
-          "NKJV" => t("New King James Version"),
-          "NLT" => t("New Living Translation"),
-          "TNIV" => t("Today's New International Version"),
-          "WE" => t("Worldwide English New Testament"),
-          "WYC" => t("Wycliffe New Testament"),
-          "YLT" => t("Young's Literal Translation"),
-        ),
-      );
-      return $form;
+//removed Code from case 'settings' down to return $form
 
     default:
       return $text;
   }
 }
 
+//Added Code Below...
+
+//Add Permission Setting
+function scripturefilter_perm() {
+  return array('administer scripture filter');
+}
+
+function scripturefilter_menu($may_cache) {
+  //This function creates the menu link for the settings page
+  global $user;
+  $items = array();
+
+  if ($may_cache) {
+    $items[] = array(
+      'path' => 'admin/settings/scripturefilter', 
+      'title' => t('Scripture Filter'),
+      'description' => t('Configure the settings for Scripture Filter'),
+      'access' => user_access('administer scripture filter'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('scripturefilter_settings'),
+    );
+  }
+  return $items;
+} // endfunction scripturefilter_menu
+
+function scripturefilter_footer($main = 0) {
+//Add Javascript and CSS and settings for Tooltip to page
+$scripture_dir = drupal_get_path('module', 'scripturefilter');
+
+If(variable_get("scripturefilter_new_window", FALSE)== TRUE){
+    //If new windows are required call the external.js file
+	drupal_add_js($scripture_dir . '/external.js');
+};
+
+
+If(variable_get("scripturefilter_default_displaystyle", 'inline')!="verse"){
+    //If translation is ESV then add the appropirate CSS File
+	drupal_add_css($scripture_dir . '/esv.css');
+};
+
+If(variable_get("scripturefilter_default_esvdisplaystyle", 'inline')=="tooltip"){
+	//If display style is tooltip then add js and options
+	
+	// add the tooltip javascript.
+	drupal_add_js($scripture_dir . '/esv_tooltip.js');
+	//Generate and array which contains the settings for the tooltip, settins are wrapped in a scripture array to prevent overlap with drupal js elements
+	$ttoptions = array(
+		'scripture' => array(
+	'tipWidth' => variable_get("scripturefilter_esv_tooltip_width",600).'px',
+	'tipBorderSize' => variable_get("scripturefilter_esv_border-width",'1') . 'px',
+	'tipWidthHeaderSub' => (variable_get("scripturefilter_esv_tooltip_width",600)-10).'px',
+	'tipWidthBodySub' => (variable_get("scripturefilter_esv_tooltip_width",600)-4).'px',
+	'tipBorderColor' => variable_get("scripturefilter_esv_border-colour",'black'),
+	'tipHeaderOpacity' => "93",
+	'tipBodyOpacity' => "97",
+	'tipHeaderBgColor' => variable_get("scripturefilter_esv_heading-colour",'#444'),
+	'tipHeaderFontFamily' => "",
+	'tipHeaderFontSize' => variable_get("scripturefilter_esv_heading-font",16) . 'px',
+	'tipHeaderFontColor' => variable_get("scripturefilter_esv_heading-font-colour",'white'),
+	'tipHeaderAlign' => "left",
+	'tipHeaderPadding' => "5px",
+	'tipBodyBgColor' => variable_get("scripturefilter_esv_body-colour",'#E8E8FF') ,
+	'tipBodyFontFamily' => "",
+	'tipBodyFontSize' => variable_get("scripturefilter_esv_body-font",13) . 'px',
+	'tipBodyFontColor' => variable_get("scripturefilter_esv_body-font-colour",'black'),
+	'tipBodyAlign' => "left",
+	'tipBodyPadding' => "2px",
+	));
+drupal_add_js($ttoptions, 'setting');
+	};
+if((variable_get("scripturefilter_default_esvdisplaystyle", 'inline')=="inline") || (variable_get("scripturefilter_default_lxxdisplaystyle", 'verse') == 'flash')){
+	//if ESV Display style is Inline or the LXX display style is flash then add js to enable collapsing block
+	drupal_add_js($scripture_dir . '/collapsablelink.js');
+	};
+
+}
+
+function scripturefilter_settings() {
+//This array creates the Settings Menu
+      $form['filter_scripturefilter'] = array('#type' => 'fieldset',
+					      '#title' => 'Scripture filter',
+					      '#collapsible' => TRUE,
+					      '#description' => t('This filter enables content that has a reference to Scripture to be linked to one of several online Bibles, such as BibleGateway, the ESV online Bible and the NET Bible.'));
+
+      $form['filter_scripturefilter']["scripturefilter_default_translation_format"] =
+	array('#type' => 'select',
+	      '#title' => t('Default Bible translation'),
+	      '#default_value' => variable_get("scripturefilter_default_translation_format", DEFAULT_BIBLE_TRANSLATION),
+	      '#options' => array("KJ21" => t("21st Century King James Version"),
+				  "ASV" => t("American Standard Version"),
+				  "AMP" => t("Amplified Bible"),
+				  "CEV" => t("Contemporary English Version"),
+				  "DARBY" => t("Darby Translation"),
+				  "ESV" => t("English Standard Version"),
+				  "KJV" => t("King James Version"),
+				  "MSG" => t("The Message"),
+				  "NASB" => t("New American Standard Bible"),
+				  "NET" => t("New English Translation"),
+				  "NIRV" => t("New International Reader's Version"),
+				  "NIV" => t("New International Version"),
+				  "NIV-UK" => t("New International Version - UK"),
+				  "NKJV" => t("New King James Version"),
+				  "NLV" => t("New Life Version"),
+				  "NLT" => t("New Living Translation"),
+				  "NRSV" => t("New Revised Standard Version"),
+				  "LXX" => t("Septuagint Greek Text"),
+				  "TNIV" => t("Today's New International Version"),
+				  "WE" => t("Worldwide English New Testament"),
+				  "WYC" => t("Wycliffe New Testament"),
+				  "YLT" => t("Young's Literal Translation"),
+				  ),
+	      );
+
+		  $form['filter_scripturefilter']["scripturefilter_new_window"] =
+	array('#type' => 'checkbox',
+	      '#title' => t('Open links in a New Window?'),
+	      '#default_value' => variable_get("scripturefilter_new_window", FALSE),
+	      );
+
+		$form['filter_scripturefilter_esv'] = array('#type' => 'fieldset',
+					      '#title' => 'ESV settings',
+					      '#collapsible' => TRUE,
+						  '#collapsed' => TRUE,
+					      '#description' => t('These are the settings for the ESV bible.'));
+
+	$form['filter_scripturefilter_esv']["scripturefilter_esv_API_key"] =
+	array('#type' => 'textfield',
+	      '#title' => t('ESV API Key'),
+	      '#default_value' => variable_get("scripturefilter_esv_API_key",IP),
+		  '#description' => t("The default value for this is 'IP'.  Read more about this <a href='http://www.gnpcb.org/esv/share/services/'>here</a>"),
+	      '#size' => '30',
+				  );
+
+
+	$form['filter_scripturefilter_esv']["scripturefilter_default_esvdisplaystyle"] =
+	array('#type' => 'select',
+	      '#title' => t('Default Bible translation'),
+	      '#default_value' => variable_get("scripturefilter_default_esvdisplaystyle", 'verse'),
+	      '#options' => array(
+				  "tooltip" => t("Display Verse as a Tooltip   "),
+				  "inline" => t("Display Verse in collapsed Block  "),
+				  "verse" => t("Display Verse as a link   "),
+				  ),
+	      );		  
+
+	$form['filter_scripturefilter_esv']["scripturefilter_esv_show-header"] =
+	array('#type' => 'checkbox',
+	      '#title' => t('Display Header'),
+	      '#default_value' => variable_get("scripturefilter_esv_show-header",TRUE),
+		  	  );
+			  
+	$form['filter_scripturefilter_esv']["scripturefilter_esv_audio"] =
+	array('#type' => 'checkbox',
+	      '#title' => t('Display Audio Link'),
+	      '#default_value' => variable_get("scripturefilter_esv_audio",TRUE),
+		  '#description' => t("Audio is only available if you chose to display the text in the collapsible block"),
+		  	  );				  
+		  
+	  	$form['filter_scripturefilter_esv']["scripturefilter_esv_include-footnotes"] =
+	array('#type' => 'checkbox',
+	      '#title' => t('Include Footnotes'),
+	      '#default_value' => variable_get("scripturefilter_esv_include-footnotes",TRUE),
+	      	  );
+
+	$form['filter_scripturefilter_esv']["scripturefilter_esv_include-verse-numbers"] =
+	array('#type' => 'checkbox',
+	      '#title' => t('Include Verse Numbers'),
+	      '#default_value' => variable_get("scripturefilter_esv_include-verse-numbers",TRUE),
+	      	  );				  
+	$form['filter_scripturefilter_esv']["scripturefilter_esv_include-headings"] =
+	array('#type' => 'checkbox',
+	      '#title' => t('Include Section Headings'),
+	      '#default_value' => variable_get("scripturefilter_esv_include-headings",TRUE),
+	      	  );				  
+	
+	$form['filter_scripturefilter_esv']["scripturefilter_esv_include-subheadings"] =
+	array('#type' => 'checkbox',
+	      '#title' => t('Include Subheadings'),
+	      '#default_value' => variable_get("scripturefilter_esv_include-subheadings",TRUE),
+	      	  );
+
+		$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_tooltip'] = array('#type' => 'fieldset',
+					      '#title' => 'ESV Tooltip settings',
+					      '#collapsible' => TRUE,
+						  '#collapsed' => TRUE,
+					      '#description' => t('These are the settings for the ESV bible when displayed in Tooltip form.'));
+			  
+    $form['filter_scripturefilter_esv']['filter_scripturefilter_esv_tooltip']["scripturefilter_esv_tooltip_width"] =
+	array('#type' => 'textfield',
+	      '#title' => t('ESV Tooltip Width'),
+		  '#field_suffix' => t('px'),
+	      '#default_value' => variable_get("scripturefilter_esv_tooltip_width",'600'),
+	      '#size' => '6',
+				  );
+				  			  
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_tooltip']["scripturefilter_esv_border-colour"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Border Colour'),
+		  '#size' => '8',
+	      '#default_value' => variable_get("scripturefilter_esv_border-colour",'black'),
+	      	  );
+
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_tooltip']["scripturefilter_esv_border-width"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Border Width'),
+		  '#size' => '3',
+		  '#field_suffix' => t('px'),
+	      '#default_value' => variable_get("scripturefilter_esv_border-width",'1'),
+	      	  );
+
+			  
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_tooltip']["scripturefilter_esv_heading-colour"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Heading Background Colour'),
+		  '#size' => '8',
+	      '#default_value' => variable_get("scripturefilter_esv_heading-colour",'#444'),
+	      	  );
+
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_tooltip']["scripturefilter_esv_heading-font"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Heading Font Size'),
+		  '#size' => '3',
+		  '#field_suffix' => t('pt'),
+	      '#default_value' => variable_get("scripturefilter_esv_heading-font",'16'),
+	      	  );
+			  
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_tooltip']["scripturefilter_esv_heading-font-colour"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Heading Font Colour'),
+		  '#size' => '8',
+	      '#default_value' => variable_get("scripturefilter_esv_heading-font-colour",'white'),
+	      	  );
+
+			  
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_tooltip']["scripturefilter_esv_body-colour"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Body Background Colour'),
+		  '#size' => '8',
+	      '#default_value' => variable_get("scripturefilter_esv_body-colour",'#E8E8FF'),
+	      	  );
+			  
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_tooltip']["scripturefilter_esv_body-font"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Body Font Size'),
+		  '#size' => '3',
+  		  '#field_suffix' => t('pt'),
+	      '#default_value' => variable_get("scripturefilter_esv_body-font",'13'),
+	      	  );
+
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_tooltip']["scripturefilter_esv_body-font-colour"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Body Font Colour'),
+		  '#size' => '8',
+	      '#default_value' => variable_get("scripturefilter_esv_body-font-colour",'black'),
+	      	  );
+
+	  		$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline'] = array('#type' => 'fieldset',
+			      '#title' => 'ESV settings for Collasible Block Display',
+			      '#collapsible' => TRUE,
+				  '#collapsed' => TRUE,
+			      '#description' => t('These are the settings for the ESV bible when displayed in collapsible block form.'));
+
+	$audioformat = array(
+				'flash' => t('Flash Player'),
+				'mp3' => t('MP3'),
+				'real' => t('Real Audio'),
+				'wma' => t('Windows Media Audio'),
+					);
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline']["scripturefilter_esv_audio-format"] = array(
+		  '#type' => 'select',
+		  '#title' => t('Audio Format'),
+		  '#default_value' =>  variable_get('scripturefilter_esv_audio-format', 'flash'),
+		  '#options' => $audioformat,
+		  '#description' => t('RealAudio and WMA, only have New Testament recordings'),
+		     );			  
+
+	$audiospeaker = array(
+				'mm' => t('Max McLean, complete Bible'),
+				'ml' => t('Marquis Laughlin, New Testament only'),
+				'ml-mm' => t('Max McLean for Old Testament, Marquis Laughlin for New Testament'),
+					);
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline']["scripturefilter_esv_audio-version"] = array(
+		  '#type' => 'select',
+		  '#title' => t('Audio Speaker'),
+		  '#default_value' =>  variable_get('scripturefilter_esv_audio-version', 'mm'),
+		  '#options' => $audiospeaker,
+		  '#description' => t('Only affects the output if the audio format is flash or mp3'),
+		     );			  
+
+
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline']["scripturefilter_esv_inline-border-colour"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Border Colour'),
+		  '#size' => '8',
+	      '#default_value' => variable_get("scripturefilter_esv_inline-border-colour",'blue'),
+		  '#description' => t("This sets the colour of the border to the collasible block and left margin"),
+	      	  );
+			  
+	$borderstyles = array(
+				'none' => t('No Border'),
+				'dotted' => t('Dotted Border'),
+				'dashed' => t('Dashed Border'),
+				'solid' => t('Solid Border'),
+				'double' => t('Dotted Border'),
+				'groove' => t('3D Groove Border'),
+					);
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline']["scripturefilter_esv_inline-border-style"] = array(
+		  '#type' => 'select',
+		  '#title' => t('Border Style'),
+		  '#default_value' =>  variable_get('scripturefilter_esv_inline-border-style', 'dotted'),
+		  '#options' => $borderstyles,
+		     );			  
+			  
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline']["scripturefilter_esv_inline-border-width"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Border Width'),
+		  '#size' => '3',
+		  '#field_suffix' => t('px'),
+	      '#default_value' => variable_get("scripturefilter_esv_inline-border-width",'1'),
+	      	  );
+
+
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline']["scripturefilter_esv_inline-left-border"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Left Margin Size'),
+		  '#size' => '3',
+		  '#field_suffix' => t('px'),
+	      '#default_value' => variable_get("scripturefilter_esv_inline-left-border",'5'),
+	      	  );
+
+  	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline']["scripturefilter_esv_inline-heading-fontsize"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Heading Fontsize'),
+		  '#size' => '3',
+		  '#field_suffix' => t('pt'),
+	      '#default_value' => variable_get("scripturefilter_esv_inline-heading-fontsize",'18'),
+		  '#description' => t("This sets the fontsize of the Headings in the passage"),
+	      	  );
+
+   	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline']["scripturefilter_esv_inline-subheading-fontsize"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Subheading Fontsize'),
+		  '#size' => '3',
+		  '#field_suffix' => t('pt'),
+	      '#default_value' => variable_get("scripturefilter_esv_inline-subheading-fontsize",'14'),
+		  '#description' => t("This sets the fontsize of the Subheadings in the passage"),
+	      	  );
+
+	$form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline']["scripturefilter_esv_inline-text-colour"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Text Colour'),
+		  '#size' => '8',
+	      '#default_value' => variable_get("scripturefilter_esv_inline-text-colour",'black'),
+		  '#description' => t("This sets the colour of the text"),
+	      	  );
+
+  $form['filter_scripturefilter_esv']['filter_scripturefilter_esv_inline']["scripturefilter_esv_inline-background-colour"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Background Colour'),
+		  '#size' => '8',
+	      '#default_value' => variable_get("scripturefilter_esv_inline-background-colour",'white'),
+		  '#description' => t("This sets the colour of the background to the collapsable block"),
+	      	  );
+
+		$form['filter_scripturefilter_lxx'] = array('#type' => 'fieldset',
+					      '#title' => 'Septuagint - LXX settings',
+					      '#collapsible' => TRUE,
+						  '#collapsed' => TRUE,
+					      '#description' => t('These are the settings for the ESV bible.'));
+
+
+	$form['filter_scripturefilter_lxx']["scripturefilter_default_lxxdisplaystyle"] =
+	array('#type' => 'select',
+	      '#title' => t('Default Bible translation'),
+	      '#default_value' => variable_get("scripturefilter_default_lxxdisplaystyle", 'verse'),
+	      '#options' => array(
+				  "flash" => t("Display Verse within embedded flash player   "),
+				  "verse" => t("Display Verse as a link   "),
+				  ),
+	      );		  
+
+	$form['filter_scripturefilter_lxx']["scripturefilter_lxx_flash_width"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Flash block width'),
+		  '#size' => '5',
+		  '#field_suffix' => t('% or px'),
+	      '#default_value' => variable_get("scripturefilter_lxx_flash_width",'100%'),
+	      	  );
+
+	$form['filter_scripturefilter_lxx']["scripturefilter_lxx_flash_height"] =
+	array('#type' => 'textfield',
+	      '#title' => t('Flash block height'),
+		  '#size' => '5',
+		  '#field_suffix' => t('% or px'),
+	      '#default_value' => variable_get("scripturefilter_lxx_flash_height",'400'),
+	      	  );
+
+		  
+	return system_settings_form($form);
+		  
+}
+
+function scripturefilter_settings_validate($form_id, $form_values) {
+ //Clears out cached verses when settings are changed
+ cache_clear_all('scripture', 'cache', TRUE); 
+ //Clears out the Input Filter Cache - without this changes in the settings are not seen until the cache expires!
+ db_query("DELETE FROM cache_filter");
+}
+
 ?>
--- modules/scripturefilter/collapsablelink.js
+++ modules/scripturefilter/collapsablelink.js
@@ -0,0 +1,77 @@
+jQuery(document).ready(function(){
+jQuery('a.scripturefilteresvlink').each(function(){
+var esvid = $(this).attr('id');
+jQuery(this).attr('href','javascript://');
+esvlinkcode = window[esvid];
+jQuery(this).after(esvlinkcode);
+jQuery(this).remove()
+});
+if(flash.installed) {
+jQuery('a.scripturefilterlxxlink').each(function(){
+var lxxid = $(this).attr('id');
+jQuery(this).attr('href','javascript://');
+lxxlinkcode = window[lxxid];
+jQuery(this).after(lxxlinkcode);
+jQuery(this).remove()
+});
+};
+});
+function esvshowhide(spanid){
+jQuery('span#'+spanid).toggle('slow');
+}
+function lxxshowhide(spanid){
+if(jQuery('span#'+spanid).css('display') == 'none') {
+jQuery('span#'+spanid).css('display','block')
+} else {
+jQuery('span#'+spanid).css('display','none')
+}
+}
+
+/*******************************************************
+
+FLASH DETECT 3
+All code by Ryan Parman and mjac, unless otherwise noted.
+(c) 1997-2004 Ryan Parman and mjac
+http://www.skyzyx.com
+
+*******************************************************/
+
+// This script will test up to the following version.
+flash_versions = 20;
+
+// Initialize variables and arrays
+var flash = new Object();
+flash.installed=false;
+flash.version='0.0';
+
+// Dig through Netscape-compatible plug-ins first.
+if (navigator.plugins && navigator.plugins.length) {
+	for (x=0; x < navigator.plugins.length; x++) {
+		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
+			flash.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
+			flash.installed = true;
+			break;
+		}
+	}
+}
+
+// Then, dig through ActiveX-style plug-ins afterwords
+else if (window.ActiveXObject) {
+	for (x = 2; x <= flash_versions; x++) {
+		try {
+			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
+			if(oFlash) {
+				flash.installed = true;
+				flash.version = x + '.0';
+			}
+		}
+		catch(e) {}
+	}
+}
+
+// Create sniffing variables in the following style: flash.ver[x]
+// Modified by mjac
+flash.ver = Array();
+for(i = 4; i <= flash_versions; i++) {
+	eval("flash.ver[" + i + "] = (flash.installed && parseInt(flash.version) >= " + i + ") ? true : false;");
+}

--- modules/scripturefilter/esv.css
+++ modules/scripturefilter/esv.css
@@ -0,0 +1,159 @@
+.esv-text{
+padding-top:5px;
+}
+
+blockquote.esvblock {
+/* change background-color to whatever fits your site */
+ background-color: #e1e0e0;
+ color: black;
+ padding-left: 5px;
+ border: 1px solid #123432;
+}
+
+div.esvblock {
+ margin-left: 15px;
+}
+
+.audio {
+ font-size: 11px;
+ }
+
+#tipDiv {
+ position: absolute;
+ visibility: hidden;
+ left: 0;
+ top: 0;
+ z-index: 10000;
+ background-color: #dee7f7;
+ border: 1px solid #336;
+ width: 250px;
+ padding: 4px;
+ color: #000;
+ font-size: 11px;
+ line-height: 1.2;
+}
+
+/* Taken from ESV website */
+h3 {
+ text-align: left;
+}
+
+span.verse-num, span.verse-num-woc {
+ font-size: 80%;
+ font-weight: bold;
+ padding-left: .25em;
+ vertical-align: super; 
+ }
+
+span.verse-num-woc, span.woc { /* Words of Christ (for red-letter editions) */
+ color: #900;
+ background-color: inherit;
+}
+
+span.chapter-num {
+ font-weight: bold;
+ padding-right: .5em;
+}
+
+div.esv-text p {
+ text-indent: 2em;
+}
+
+div.esv-text p.same-paragraph {
+ text-indent: 0;
+}
+
+div.block-indent p {
+ text-indent: 0;
+ padding-left: 2.5em;
+ margin-left: 0;
+}
+
+span.indent {
+ padding-left: 2em;
+}
+
+span.indent-2, span.psalm-doxology-line {
+ padding-left: 4em;
+}
+
+span.declares-line {
+ padding-left: 6em;
+}
+
+span.small-caps {
+ font-variant: small-caps;
+}
+
+span.selah {
+ font-style: italic;
+ margin-left: 1em;
+}
+
+p.extra-space {
+ margin-top: 2em;
+}
+
+div.block-indent span.verse-num, div.block-indent span.verse-num-woc  {
+ padding-left: 0;
+}
+
+h4 {
+ font-weight: normal;
+}
+
+h4.speaker {
+ padding-left: 10em;
+ font-variant: small-caps;
+ margin-bottom: -1em;
+}
+
+h4.textual-note {
+ font-variant: small-caps;
+}
+
+h4.psalm-acrostic-title {
+ font-variant: small-caps;
+}
+
+h4.psalm-title {
+}
+
+span.footnote {
+ font-size: 80%;
+ padding-right: .5em;
+ padding-left: 0em;
+ vertical-align: text-top;
+}
+
+div.footnotes h3 {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+div.footnotes p {
+ text-indent: 0;
+}
+
+span.footnote-ref {
+ font-weight: bold;
+}
+
+p.copyright {
+ text-indent: 0;
+}
+
+span.passageheading{
+display:block;
+padding-bottom:5px;
+}
+
+span.passagesubheading{
+display:block;
+padding-top:10px;
+padding-bottom:2px;
+}
+
+span.passagetext{
+display:block;
+}

--- modules/scripturefilter/esv_tooltip.js
+++ modules/scripturefilter/esv_tooltip.js
@@ -0,0 +1,156 @@
+var curPageX = 0;
+var curPagey = 0;
+
+var tipBox = "";
+
+window.document.onmousemove = trackMouse;
+
+function trackMouse(e)
+{
+	var e = (e) ? e : ((event) ? event : null);
+
+	// Functions do different things depending on whether or not a
+	// doctype is present. Node type 10 is a doctype but IE reads
+	// a doctype as Node type 8 - a comment.
+	if (document.childNodes[0].nodeType == 10 || document.childNodes[0].nodeType == 8)
+	{
+		curPageX = e.clientX + document.documentElement.scrollLeft;
+ 		curPageY = e.clientY + document.documentElement.scrollTop;
+
+ 		scrollPageY = document.documentElement.scrollTop;
+
+		viewPageX = e.clientX;
+		viewPageY = e.clientY;
+
+		viewScreenX = document.documentElement.clientWidth;
+		viewScreenY = document.documentElement.clientHeight;
+
+		totalScreenX = document.body.offsetWidth;
+		totalScreenY = document.body.offsetHeight;
+	} else {
+		curPageX = e.clientX + document.body.scrollLeft;
+ 		curPageY = e.clientY + document.body.scrollTop;
+
+ 		scrollPageY = document.body.scrollTop;
+
+		viewPageX = e.clientX;
+		viewPageY = e.clientY;
+
+		viewScreenX = document.body.clientWidth;
+		viewScreenY = document.body.clientHeight;
+
+		totalScreenX = document.documentElement.scrollWidth;
+		totalScreenY = document.documentElement.scrollHeight;
+	}
+
+	if (tipBox != "" && tipBox.style.display == "block")
+	{
+		moveTip();
+	}
+}
+
+function clearTip()
+{
+	while (tipBox.childNodes.length > 0)
+	{
+		tipBox.removeChild(tipBox.childNodes[0]);
+	}
+
+	tipBox.style.display = "none";
+}
+
+function toolText(headerText, tipText)
+{
+	if (tipBox == "")
+	{
+		tipBox = document.createElement("div");
+		tipBox.id = "toolTipDiv";
+		tipBox.style.position = "absolute";
+		tipBox.style.display = "none";
+
+		window.document.body.appendChild(tipBox);
+	} else {
+		clearTip();
+	}
+
+	// make sure box settings are up to date
+	tipBox.style.width = Drupal.settings.scripture.tipWidth;
+	tipBox.style.border = Drupal.settings.scripture.tipBorderSize + " solid " + Drupal.settings.scripture.tipBorderColor;
+
+	if (headerText != "")
+	{
+		// Build the tip header
+		var tipHead = document.createElement("div");
+		tipHead.style.backgroundColor = Drupal.settings.scripture.tipHeaderBgColor;
+		tipHead.style.fontFamily = Drupal.settings.scripture.tipHeaderFontFamily;
+		tipHead.style.fontSize = Drupal.settings.scripture.tipHeaderFontSize;
+		tipHead.style.color = Drupal.settings.scripture.tipHeaderFontColor;
+		tipHead.style.padding = Drupal.settings.scripture.tipHeaderPadding;
+		tipHead.style.textAlign = Drupal.settings.scripture.tipHeaderAlign;
+		tipHead.style.width = Drupal.settings.scripture.tipWidthHeaderSub;
+		tipHead.style.filter = "alpha(opacity=" + Drupal.settings.scripture.tipHeaderOpacity + ")";
+		tipHead.style.opacity = "." + Drupal.settings.scripture.tipHeaderOpacity;
+		tipHead.style.mozOpacity = "." + Drupal.settings.scripture.tipHeaderOpacity;
+
+		var tipHeadText = document.createTextNode(headerText);
+		tipHead.appendChild(tipHeadText);
+
+		tipBox.appendChild(tipHead);
+	}
+
+	var tipBody = document.createElement("div");
+	tipBody.style.backgroundColor = Drupal.settings.scripture.tipBodyBgColor;
+	tipBody.style.fontFamily = Drupal.settings.scripture.tipBodyFontFamily;
+	tipBody.style.fontSize = Drupal.settings.scripture.tipBodyFontSize;
+	tipBody.style.color = Drupal.settings.scripture.tipBodyFontColor;
+	tipBody.style.padding = Drupal.settings.scripture.tipBodyPadding;
+	tipBody.style.textAlign = Drupal.settings.scripture.tipBodyAlign;
+	tipBody.style.width = Drupal.settings.scripture.tipWidthBodySub;
+	tipBody.style.filter = "alpha(opacity=" + Drupal.settings.scripture.tipBodyOpacity + ")";
+	tipBody.style.opacity = "." + Drupal.settings.scripture.tipBodyOpacity;
+	tipBody.style.mozOpacity = "." + Drupal.settings.scripture.tipBodyOpacity;
+
+	tipBody.innerHTML = tipText;
+
+	tipBox.appendChild(tipBody);
+
+	tipBox.style.visibility = "hidden";
+	tipBox.style.display = "block";
+
+	tipHeight = tipBox.offsetHeight;
+
+	moveTip();
+	tipBox.style.visibility = "visible";
+}
+
+function moveTip()
+{
+	tipXloc = curPageX + 10;
+	tipYloc = curPageY + 10;
+
+	tipHeight = tipBox.offsetHeight;
+	tipWidth = tipBox.offsetWidth;
+
+	// If the tooltip extends off the side, pull it over
+	if (viewPageX + 10 + tipWidth > viewScreenX)
+	{
+		tipXloc -= (tipWidth + 15);
+	}
+
+	// If the tooltip will extend off the bottom of the screen, pull it back up.
+	if (viewPageY + 10 + tipHeight > viewScreenY)
+	{
+		pageDiff = (viewPageY + 10 + tipHeight - viewScreenY);
+		tipYloc -= pageDiff;
+	}
+
+	// If the tooltip extends off the bottom and the top, line up the top of
+	// the tooltip with the top of the page
+	if (tipHeight > viewScreenY)
+	{
+		tipYloc = scrollPageY + 5;
+	}
+
+	tipBox.style.left = tipXloc + "px";
+	tipBox.style.top = tipYloc + "px";
+}

--- modules/scripturefilter/external.js
+++ modules/scripturefilter/external.js
@@ -0,0 +1,11 @@
+function externalLinks() {
+ if (!document.getElementsByTagName) return;
+ var anchors = document.getElementsByTagName("a");
+ for (var i=0; i<anchors.length; i++) {
+   var anchor = anchors[i];
+   if (anchor.getAttribute("href") &&
+       anchor.getAttribute("rel") == "external")
+     anchor.target = "_blank";
+ }
+}
+window.onload = externalLinks;

