function external(url, windowname, width, height) {
	var features="location=yes, menubar=yes, status=yes, scrollbars=yes, resizable=yes, toolbar=yes";	
	if (width) {
		if (window.screen.width > width)
			features+=", left="+(window.screen.width-width)/2;
		else width=window.screen.width;
			features+=", width="+width;
	}
	if (height) {
		if (window.screen.height > height)
			features+=", top="+(window.screen.height-height)/2;
		else height=window.screen.height;
			features+=", height="+height;
	}
	w = window.open(url, windowname, features);
	w.focus();
}

function external_print(url, windowname) {
	w = wopen(url, windowname);
	
	w.print();
	w.close();
}

function wopen(url, name){
	var w,h,c=false;
	var g = null;
	var l,t,o;
	var x = -1, i = 0;
	var opt = "";
	
	g = new Image();
	g.src = url;
	url = "";
	if (g.width > 0 && g.height > 0)
		opt += "width=" + (w = g.width) + ",height=" + (h = g.height);

	o = window.open (url, name, opt)
	if(g){
		o.document.open();
		o.document.write(
			'<html><head><title>' + g.src.substring(g.src.lastIndexOf('/') + 1) +
			'</title><head><body style=overflow:hidden leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><center><img src="' + 
			g.src + '"' + (w>0&&h>0?' width='+w+' height='+h : 'onload="if(self.innerWidth){self.innerWidth=this.width;self.innerHeight=this.height}else{self.resizeBy(this.width-document.body.clientWidth,this.height-document.body.clientHeight)}"')+'></center></body></html>');
		o.document.close();
	}
	return o;
}


