///////////////////////////////////////////////////////////////////////////////
//
//  Interface.js   			version 1.0
//	2007 Julia Yu, Lenny Burdette
//
//  Set up the plugin and create content for WALDSEEMULLER MAPS
//
//  FUNCTIONS:
//			Loc.dataLoaded
//			Loc.pluginLoaded
//			Loc.setUpSilverlight
//		
//	DEPENDENCIES:	
//			Utils.js
//			XMLUtils.js
//			StageObjects.js
//
///////////////////////////////////////////////////////////////////////////////

if ( !window.Loc) { window.Loc = {}; }

/**
 * Data has been loaded 
 */
Loc.dataLoaded = function(downloader) {
	var xamlString = downloader.responseText; 
	Loc.loaderFragment = Loc.plugin.content.createFromXaml(xamlString, true); // this is the xaml fragment
	
	Loc.make('nav', { name : 'nav'});
	Loc.make('stage', { name : 'stage_content'});
	Loc.make('panel', { name : 'panel_intro' }); 
	Loc.make('button', { name: 'btn_home', text: "HOME", w: 40, h: 15, left: 920, top: 18, page: "home", bgFill : "#00000000"}); 
	
	Loc.dispatch.broadcast('pageLoad', "home"); // called when things are done making
}

/**
 * Set up components inside the plugin
 */
Loc.pluginLoaded = function(plugin, context, root) {
	Loc.plugin = plugin;					
	Loc.root = root;			
	
	this.downloadXAML = new Silverlight.Downloader({
	    resource: "cmn/xaml/preloader.xaml",
	    plugin: Loc.plugin,
	    onComplete: Loc.dataLoaded.bind(this),
	    name: 'getpreoloader'
	});
}

/**
 * Set up the silverlight plugin properties
 */
 
Loc.setUpSilverlight = function() {
	var pluginSpecs = { 
		height : '535px', width: '980px', 
		host : 'host', 
		xaml : 'cmn/xaml/stage.xaml', 
		id : 'wmap', 
		color : '#4678a9',
		postInstall : true,
		events : {
			onError: Silverlight.error,
	        onLoad: Loc.pluginLoaded
		}
	};
	Silverlight.createInstallExperience(pluginSpecs); // post install optional
}

/**
 * Create silverlight object upon DOM load
 * Turn debuggin on and off
 */
Loc.DomLoaded.load(Loc.setUpSilverlight);
Loc.debug.on = true;
