<?xml version="1.0" encoding="UTF-8" ?>
<Module>

<!-- ** Replace inside quotes with your gadgets title -->
<ModulePrefs title="WWT Gadget"
    height="10"
    scrolling="true">
     <Require feature="dynamic-height"/>
     <Require feature="opensocial-0.8"/> 
     <Require feature="minimessage"/>
</ModulePrefs> 

<Content type="html"><![CDATA[

<!-- Add HTML content here -->
<div style="height:650px">
        <object id="WWTView" 
            data="data:application/x-silverlight," 
            type="application/x-silverlight-2"             
            width="100%" height="650">

<!-- Ensure the source parameter links correctly to the wwtsl.xap file -->

            <param name="source" value="http://www.worldwidetelescope.org/webclient/clientbin/WWTSL.xap"/>
            <param name="background" value="black" />
            <param name="minRuntimeVersion" value="3.0.40624.0" />
            <param name="autoUpgrade" value="true" />
            <param name="initParams" value="NoUI=true,wtml=,webkey=AX2011Gqqu" />
            <param name="enableHtmlAccess" value="true" />
            <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0">
                 <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Install Microsoft Silverlight" /></a>
        </object> 
</div>



<!-- WWT Stuff -->
<script language="javascript">

// Create the WorldWide telescope object
    var wwtView;

// Create variables to hold the changeable settings

    var bShowCrosshairs = true;
    var bShowUI = true;
    var bShowFigures = true;

// The wwtReady function is called by the WWT Web Control software
// This function sets up the wwt object, and the initial defaults

    function wwtReady() {
        wwtView = document.getElementById("WWTView").content.WWT;

        wwtView.Settings.ShowCrosshairs = bShowCrosshairs;
        wwtView.Settings.ShowConstellationFigures = bShowFigures;
        wwtView.HideUI(!bShowUI);

        wwtView.Settings.ShowConstellationBoundries = true;
    }
</script>



<!-- Used to register with the Data Gadget -->
<script src="http://sky.astro.washington.edu/gadgets/js/gDataInterface.js" type="text/javascript"></script>

<!-- Contains UW.astro objects -->
<script src="http://sky.astro.washington.edu/gadgets/js/astroObjectLib.js" type="text/javascript"></script>



<script type="text/javascript">

var myGadget = null,
    debug = true;


// Writes to the console if debug (global) is true  
function debugLog(msg){
    if ((debug === true) && (window.console && console.log)) { 
         console.log(GADGET_NAME + ": " + msg);
    }
    return;
}

// ** Replace with your gadget's name
var GADGET_NAME = "WWT Viewer" + "_" + Math.floor(Math.random()*100000+1).toString();

// Creates gadget object
function init(){
    myGadget = new GadgetTemplate();
    gadgets.window.adjustHeight();
}



function GadgetTemplate(){
    var my = new Object();
    // CONSTANTS
    var DEFAULT_NAMESPACE = "NS1",
        MM_TIMER_DURATION = 4;

    // PRIVATE
    var _namespaceList = [ DEFAULT_NAMESPACE ];      // list of our current Namespaces. Just init with the default
    
    // Private Helper Variables
    var di = new gDataInterface(GADGET_NAME, DEFAULT_NAMESPACE); // make dataInterface object, init with default
    var miniMsg = new gadgets.MiniMessage();// make MiniMessage object

    // INIT
    
    // ** Variables to register go in this array. 
    // ex: ["VP_Coords", "VP_Points_List"]
    var variableArray = []; 
                            
    // ** Triggers to register go in this array
    // Each trigger is a 2-element array as follows:
    // [ "VariableName", triggerFunction ]
    // example with one trigger: (notice the array inside the array)
    //      var triggerArray = [ ["VP_Coords", function(){ zoomMe() }] ]
    // it is recommended to define functions outside the array for more readable code
    var triggerArray = [];
                           

    var msg = miniMsg.createStaticMessage("Attempting to register gadget...");
    di.registerMe( { gadgetName : GADGET_NAME,
                    namespaceList : _namespaceList,
                    variableList : variableArray,  
                    triggerList : triggerArray,   
                    successCallback : registrationSuccess,
                    failureCallback : registrationFailure
                } );
    
    // Callback after successful registration
    function registrationSuccess(){
        debugLog('Registration successful');
        if (msg) {
            miniMsg.dismissMessage(msg);
            // free up msg
            msg = null;
            miniMsg.createTimerMessage("Registration Succesful.", MM_TIMER_DURATION);
        }
    }
    // Callback after a failure of registration
    // Displays failure message
    function registrationFailure(){
        debugLog('Registration FAILED!');
        miniMsg.dismissMessage(msg);
        miniMsg.createDismissibleMessage("Unable to register gadget.\nWe cannot communicate with other gadgets.");
    }
    
    
    // METHODS
    // ** Add public methods (that will be called from outside the object by a button or something) 
    //
    // my.sayHello = function(){
    //    alert("Hello!");
    // 
    // }
    
    // return my;
}

gadgets.util.registerOnLoadHandler(init); 

</script>

]]></Content>
</Module>


