/*
	ZoomoViewerŪ
	http://www.ZoomoViewer.com
	
*/

// Default Werte
var serverName = 'http://asp.zoomoviewer.com';
var plugIns = 'gui_default';
var servletPath = '/servlet/ImageData';

function zoomo_main (width, height) {
	var imageURL = serverName + servletPath + '?clientId=' + clientID + '&image=' + imageID ;
	var zvParameter = 'imageURL='+escape(imageURL)+'&plugIns='+serverName+'/html/zoomapp/plugins/'+ plugIns;
	
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" id="zoomo_main" align="middle">');
	document.write('<param name="movie" value="'+serverName+'/html/zoomapp/zoomo07.swf?'+zvParameter+'" />');
	document.write('<embed src="'+serverName+'/html/zoomapp/zoomo07.swf?'+zvParameter+'" quality="high" width="'+width+'" height="'+height+'" name="zoomo_main" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

function zoomo_nav (serverName, nam) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="145" height="200" id="zoomo_nav" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="'+serverName+'/html/zoomapp/'+ nam +'2.swf" /><embed src="'+serverName+'/html/zoomapp/'+ nam +'2.swf" width="145" height="200" name="zoomo_nav" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}


/*
	ZoomoViewer Object
	
*/

ZoomoViewer = function () {
	this._plugIns = new Array();
	this._images = new Array();
	this._params = new Array();	
}
ZoomoViewer.prototype = {
	width: 450,
	height: 500,
	clientID: '',
	serverName: 'http://asp.zoomoviewer.com',
	appPath: '/html/zoomapp/',
	plugInPath: '/html/zoomapp/plugins/',
	servletPath: '/servlet/ImageData',
	bgColor: '#ffffff',
	wmode: 'window',
	
	addImage: function (img, url) {
		if (url == undefined) url = "";
		this._images.push({name: img, url: url});
	},
	
	addPlugIn: function (plug){
		this._plugIns.push(plug);
	},
	
	addParam: function(name, value){
		// compatible to prototype
		this._params[name] = {value: value, zv: true};
	},
	
	getEmbedCode: function() {
		var imageURL = this.serverName + this.servletPath +'?clientId='+this.clientID;
		imageURL += this._getImages();
		
		var zvParameter = 'imageURL='+escape(imageURL)
		var itsme = "&referrer=" + encodeURIComponent(document.referrer);
		zvParameter += escape( itsme );
		zvParameter += this._getPlugIns() + this._getParams(); 
		
		var code = '';
		code += ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+this.width+'" height="'+this.height+'" id="zoomoviewer" align="middle">');
		code += ('<param name="movie" value="' + this.serverName + this.appPath + 'zoomo07.swf?'+ zvParameter +'" />');
		code += ('<param name="allowScriptAccess" value="always"><param name="bgcolor" value="'+this.bgColor+'"><param name="wmode" value="' + this.wmode + '">');
		code += ('<embed src="' + this.serverName + this.appPath + 'zoomo07.swf?'+zvParameter+'" quality="high" width="'+this.width+'" height="'+this.height+'" bgcolor="'+this.bgColor+'" wmode="'+ this.wmode +'" name="zoomoviewer" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always" swliveconnect="true" />');
		code += ('</object>');
		
		return code;
	},
	
	start: function () {
		var code = this.getEmbedCode();
		document.write(code);
	},
	
	_getImages: function () {
		var str = "";
		for (var i = 0; i < this._images.length; i++) {
			str += "&image=" + this._images[i].name;
			str += "&url=" + this._images[i].url;
		}
		return str;
	},
	
	_getPlugIns: function () {
		var str = "&plugIns=";
		for (var i = 0; i < this._plugIns.length; i++) {
			str += this.serverName + this.plugInPath + this._plugIns[i] + "|";
		}
		return str.substring(0, str.length - 1);
	},
	
	_getParams: function () {
		var str = "";
		for (var p in this._params) {
			if (this._params[p].zv) 
				str += "&" + p + "=" + this._params[p].value;
		}
		return str;
	},
	
	startSWFObject: function (divID) {
		var imageURL = this.serverName + this.servletPath +'?clientId='+this.clientID;
		imageURL += this._getImages();
		
		var zvParameter = 'imageURL='+escape(imageURL)
		zvParameter += this._getPlugIns() + this._getParams();
	
		var so = new SWFObject(this.serverName + this.appPath + "zoomo07.swf?" + zvParameter, "ZoomoViewer", this.width, this.height, "6", "#FFFFFF");
		so.addParam("allowScriptAccess", "always");
		so.addParam('bgcolor', this.bgColor);
		so.write(divID);
	}
}
