function krpanoReady() {
	vt.update(true);
};

function vt_setPluginVisible() {
	
}

/**
 * @constructor
 */
VirtualTour = function (krpanoPath, xml) {
	this._containerId = null;
	this._krpanoPath = krpanoPath;
	this._xml = xml;
	this._selectedOptions = new Object();
	this._container = null;
	this._options = ['start','mode','viewtype','hole','view'];
	this._init();
}

VirtualTour.prototype = {
	update: function (autoLoad) {
		if (autoLoad) {
			this.loadScene();
		}
	},
	
	_evalFilter: function (filter) {
		if (typeof filter=='undefined' || filter=='') return true;
		var conditions = filter.split('&');
		for (i in conditions) {
			var condition = conditions[i];
			var elems = condition.split('=');
			var name = elems[0];
			var value = elems[1];
			if (this.getvar(name)!=value) return false;
		}
		return true;
	},

	loadScene: function (force) {
		for (var i=0; i<this._options.length; i++) {
			var name = this._options[i];
			if (!this.getvar(name)) return;
		}
		var inline_options = this.getvar('hole')+'_'+this.getvar('start')+'_'+this.getvar('mode')+'_'+this.getvar('viewtype')+'_'+this.getvar('view');
		if (this.last_inline_options!=inline_options || typeof force!='undefined' && (force===true || force==='true')) {
			var result = this.krpano_call('action(loadScene_'+inline_options+');');
			if (result) this.last_inline_options = inline_options;
			return result;
		} else {
			return false;
		}
	},
	
	krpano: function () {
		return document.getElementById('vt-swf-object');
	},

	krpano_get: function (name) {
		var krpano = this.krpano();
		return krpano && krpano.get ? krpano.get(name) : null;
	},
	
	krpano_call: function (flash_function) {
		var krpano = this.krpano();
		if (krpano && krpano.call) {
			krpano.call(flash_function);
			return true;
		}
		return false;
	},
	
	setvar: function (name, value, autoLoad) {
		if (autoLoad==null) autoLoad = true;
		this._selectedOptions[name] = value;
		this.update(autoLoad);
	},

	getvar: function (name) {
		if (typeof this._selectedOptions[name]=='undefined' || this._selectedOptions[name]==null) return false;
		else return this._selectedOptions[name];
	},

	_init: function () {
		//this._createVirtualTour();
		this.setvar('hole','18');
		this.setvar('view','start');
		this.setvar('start','red');
		this.setvar('mode','nature');
		this.setvar('viewtype','aerial');
	},

	init: function () {
		this.setvar('view',null);
	},

	create: function (containerId) {
		$('#krpano-infos').css('display','none');
		embedpano({
		   swf: this._krpanoPath,
		   xml: this._xml,
		   id: 'vt-swf-object',
		   target: containerId,
		   wmode: 'opaque'
		});
		this._containerId = containerId;
	},
	
	goTo: function (url) {
		app.setLocation(url);
	}
}


