// IMAGE_WINDOW FUNCTION by JORGE MORENO aka AlterEbro (www.alterebro.com)
var image_window = {
	link_class : 'image_window',
	do_links : function() {
		var all_links = window.document.getElementsByTagName('a')
		for ( var i=0; i<all_links.length; i++ ) {
			if (all_links[i].className == image_window.link_class) {
				all_links[i].onclick = function() {			
					image_window.launch(this.href,this.title)
					return false
				}
			}
		}
	},
	launch : function(img_path,img_title) {
		var props = 'height=200,width=200,scrollbars=no,status=no'
	 	var win_code = '<html>\n'
	 	win_code += '<head>\n'
	 	win_code += '<title>'+img_title+'</title>\n'
	 	win_code += '<meta http-equiv="content-type" content="text/html; utf-8">\n'
	 	win_code += '<meta http-equiv="author" content="Jorge Moreno | www.alterebro.com">\n'
	 	win_code += '<meta http-equiv="imagetoolbar" content="no">\n'
	 	win_code += '<scr'+'ipt>\n'
	 	win_code += 'function resize_ie() {\n'
	 	win_code += '	window.resizeTo(200,200)\n'
	 	win_code += '	width=200-(document.body.clientWidth-document.images[0].width)\n'
	 	win_code += '	height=200-(document.body.clientHeight-document.images[0].height)\n'
	 	win_code += '	window.resizeTo(width,height)\n'
	 	win_code += '}\n'  
	 	win_code += 'function resize_nn() {\n'
	 	win_code += '	window.innerWidth=document.images[0].width\n'
	 	win_code += '	window.innerHeight=document.images[0].height\n'
	 	win_code += '}\n'
	 	win_code += 'var is_ie = (document.all)?1:0\n'
	 	win_code += 'window.onload = function() { if (is_ie == 1) { resize_ie() } else { resize_nn() } }\n'
	 	win_code += '</scr'+'ipt>\n'
	 	win_code += '<style type="text/css">html, body {margin:0; padding:0; border:none; overflow: hidden;}</style>\n'
	 	win_code += '</head>\n'
	 	win_code += '<body><img src="'+img_path+'" alt="'+img_title+'"></body>\n'
	 	win_code += '</html>\n'
	 
		var ae_win = window.open('','',props)
	 	ae_win.document.open() 
	 	ae_win.document.write(win_code)
	 	ae_win.document.close()
	}
}
var add_on = {
	// addEvent thingy by Scott Andrew
	// http://www.scottandrew.com/weblog/articles/cbs-events
	add_event : function(obj, ev_type, fn, use_capture) { 
		if (obj.addEventListener) {
			obj.addEventListener(ev_type, fn, use_capture)
			return true
		} else if (obj.attachEvent) {
			var r = obj.attachEvent("on"+ev_type, fn)
			return r
		} 
		else { return false }	
	}
}

if (document.getElementsByTagName && document.createElement) {
	add_on.add_event(window, "load", image_window.do_links, false)
}
