<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs
	title="Lexicon Lookup Display"
	author_email="scribe777@gmail.com"
	author="CrossWire"
	description="Lexicon Display"
	screenshot="http://crosswire.org/images/crosswire.gif"
	thumbnail="http://crosswire.org/images/crosswire.gif"
	scrolling="false"
   >
<Optional feature="pubsub-2">
  <Param name="topics">
    <![CDATA[ 
    <Topic title="Image Selection" name="interedition.image.selected"
            description="Show an Image" type="string"
            subscribe="true"/>
    ]]>
  </Param>
</Optional>
<Optional feature="dynamic-height"/>
<Require feature="opensocial-0.8"/>
</ModulePrefs>

<UserPref name="height" datatype="enum" display_name="Gadget Height" default_value="200">
	<EnumValue value="200" display_value="Short"/>
	<EnumValue value="400" display_value="Medium"/>
	<EnumValue value="600" display_value="Tall"/>
	<EnumValue value="-1" display_value="Dynamic"/>
</UserPref>


<Content type="html">
<![CDATA[
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

	<link rel="stylesheet" type="text/css" href="/community/js/jquery-ui/jquery-ui.css"/>

	<script type="text/javascript" src="/community/js/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="/community/js/jquery.blockUI.js"></script>
	<script type="text/javascript" src="/community/js/URI.min.js"></script>
	<script type="text/javascript" src="/community/js/jquery/jquery.cookie.js"></script>
	<script type="text/javascript" src="/community/js/jquery-ui/jquery-ui.min.js"></script>
	<script type="text/javascript" src="/community/js/vmr-common.js"></script>

<style type="text/css">

.ui-widget-content {
	background: white !important;
}

body {
	margin-top: 2px;
	margin-bottom: 2px;
	margin-left: 2px;
	margin-right: 2px;
	font-size: 80%;
	font-family: 'SBL Greek', SymbolGreekU, SymbolGreekTU, SymbolGreekMetU, SymbolGreekTMetU, OdysseaU, OdysseaUBSU, TeubnerLSU, TeubnerLSCU, TeubnerVerticalU, TeubnerVerticalCU, GraecaUBSU, GraecaUBSMetU, GraecaU, HellenicaU, HellenicaCU, GreekSansLSU, GreekSansLSConU, PayneU, UncialLSU;
}

#lexContent {
	margin-left: 10px;
	margin-right: 26px;
}

.copyLine {
	margin: 1em 0px .5em 0px;
	padding: 0px 0px 0px 0px;
	border-top: 1px solid #7F673C;
	font-weight: bold;
	font-style: italic;
}

</style>
</head>
<body>
<div style="overflow:auto; border: none 0px; width:100%;" class="fillPage" id="contentDiv">
<div id="lexContent">
</div>
</div>

</body>
<script>


var lexModule = 'ls';
var lexModuleBackup = 'StrongsGreek';
var lexLookupURL = 'https://crosswire.org/study/fetchdata.jsp';
var currentKey = '';

function isNumber(n) {
	return !isNaN(parseFloat(n)) && isFinite(n);
}

function loadLexContent(key, mod) {
	if (!mod) mod = lexModule;
	if (!key || key.length < 1 || !isNumber(key)) return;
	$('#lexContent').html('<center style="width:100%;"><image src="'+VMR.imagesURL+'/loading.gif"/></center><br/><center><h1>Please wait...</h1></center>');

	var url = lexLookupURL;
	var postData = {
		mod             : mod,
		key             : key
	};

	VMR.webRequest(url, postData, function(o) {
		currentKey = key;
		var t = '';
		t += o.text;
		if (t.length < 50 && mod != lexModuleBackup) {
			loadLexContent(key, lexModuleBackup);
			return;
		}
		setDisplayContent(t);
	});
}

function setDisplayContent(t) {
	$('#lexContent').html(t);

	VMR.refreshHeight();
}

function word_selected_callback(topic, data, subscriberData) {
	if (data.strongNum) loadLexContent(data.strongNum);
}

function definition_published_callback(topic, data, subscriberData) {
	$.blockUI({ message: '<h2><img src="/community/images/loading.gif" /> Loading, please wait...</h2>', onBlock: function() {
		setDisplayContent(data);
		$.unblockUI();
	} });
}


VMR.init(function() {

	VMR.subscribe("interedition.word.selected", word_selected_callback);
	VMR.subscribe("interedition.definition.published", definition_published_callback);

}, '../../', true);



</script>
</html>

]]>
</Content>
</Module>
