/*----------------------------------------------------------------------------\
|                               Server Status                                 |
|-----------------------------------------------------------------------------|
|                         Created by Christian Wellhöfer                      |
|                            ( http://chriswell.de )                          |
|                      For NanoSpy - http://www.nanospy.de/                   |
|-----------------------------------------------------------------------------|
|                Copyright (c) 2006, 2007 Christian Wellhöfer                 |
|-----------------------------------------------------------------------------|
| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| use this file except in compliance with the License.  You may obtain a copy |
| of the License at http://www.apache.org/licenses/LICENSE-2.0                |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| Unless  required  by  applicable law or  agreed  to  in  writing,  software |
| distributed under the License is distributed on an  "AS IS" BASIS,  WITHOUT |
| WARRANTIES OR  CONDITIONS OF ANY KIND,  either express or implied.  See the |
| License  for the  specific language  governing permissions  and limitations |
| under the License.                                                          |
|-----------------------------------------------------------------------------|
| Created 2006-12-18 |                                   | Updated 2007-04-13 |
\----------------------------------------------------------------------------*/

var NanoSpy = {
	base_url:"http://www.nanospy.de/",format:"",width:0,height:0,ip:"",port:0,qport:0,protocol:"",altcss:"",bordercolor:"000",borderwidth:0,
	init:function() {
		if(typeof(spy_format)=="undefined")return;
		this.format=spy_format;
		if(typeof(spy_protocol)=="string") this.protocol = spy_protocol;
		if(typeof(spy_css)=="string") { this.altcss = spy_css; } //added 04/2007
		
		this.ip = spy_ip;
		this.port = spy_port || 0;
		this.qport = spy_qport;
		
		//border stuff
		if(typeof(spy_borderwidth)=="undefined") this.borderwidth=0;
		else this.borderwidth = spy_borderwidth;
		
		this.width=parseInt(this.format.substr(0,this.format.indexOf("x")));
		this.height=parseInt(this.format.substr(this.format.indexOf("x")+1,this.format.indexOf("_")));
		this.pI();
	},
	/*different output functions*/
	dL:function() {
		document.write('<a href="'+this.base_url+this.protocol+'/'+this.ip+':'+this.qport+'/server_status.html" target="_blank">Click to Spy</a>');
	},
	dP:function() {
		document.write('<a href="'+this.base_url+this.protocol+'/'+this.ip+':'+this.qport+'/server_status.html" onclick="return false;">sometext</a>');
	},
	dI:function(itype) {
		document.write('<a href="'+this.base_url+this.protocol+'/'+this.ip+':'+this.qport+'/server_status.html" target="_blank"><img src="'+this.base_url+this.protocol+'/'+this.ip+':'+this.qport+'/'+this.width+'x'+this.height+'.'+itype+'" height="'+this.height+'" width="'+this.width+'" border="'+this.borderwidth+'" alt="NanoSpy" title="NanoSpy" /></a>');
	},
	dIF:function() {
		var url=this.base_url+"track.php?ip="+this.ip+"&amp;port="+this.port+"&amp;qport="+this.qport+"&amp;prot="+this.protocol+"&amp;width="+this.width+"&amp;height="+this.height+"&amp;t=html&amp;css="+this.altcss; 
		document.write('<iframe src="'+url+'" scrolling="no" style="overflow:hidden; border:'+this.borderwidth+'px solid #'+this.bordercolor+';width:'+this.width+'px; height:'+this.height+'px;" frameborder="'+this.borderwidth+'"></iframe>');
	},
	dF:function() {
		//display flash... soon :)
	},
	/*parse input*/
	pI:function() {
		if (this.format.indexOf("_png") != -1) this.dI('png');
		else if (this.format.indexOf("_jpg") != -1) this.dI('jpg');
		else if (this.format.indexOf("_gif") != -1) this.dI('gif');
		else if (this.format.indexOf("_html") != -1) this.dIF();
		else if (this.format.indexOf("_flash") != -1) this.dF();
		else if (this.format.indexOf("_pop") != -1) this.dP();
		else if (this.format.indexOf("_link") != -1) this.dL();
		//else alert("Invalid Format:"+this.format); 
	}
};
NanoSpy.init();