function preload_image(image) {
	var img = new Image();
	img.src = image;
}

var base64_dat = /^data:.*;base64/i;
var base64_pth = (web ? web : "") + "/inc/base64/";

function base64_fix(img) {
	if (base64_dat.test(img.src)) {
		img.src = base64_pth + "?" + img.src.slice(5);
	}
}

function base64_fix_all() {
	for (var i = 0; i < document.images.length; i ++) {
		base64_fix(document.images[i]);
	}
}

var info_state = 0;
var info_timeo;

function display_info(html, e, t) {
	var info = document.getElementById("info");
	if (!info) return;
	switch (e.type) {
		case "mouseover":
			if (!t.id || t.id != "info") {
				info.style.left = e.clientX + (document.body && document.body.scrollLeft ? document.body.scrollLeft : 0);
				info.style.top = e.clientY + (document.body && document.body.scrollTop ? document.body.scrollTop : 0);
				if (html != '') info.innerHTML = "<div class=\"tooltip\">" + html + "</div>";
			}
			if (info_state < 0) {
				if (info_timeo) window.clearTimeout(info_timeo);
				info_state = 0;
			} else if (info_state == 0) {
				info_timeo = window.setTimeout("real_display_info()", 500);
				info_state = 1;
			}
			break;
		case "mouseout":
			if (info_state > 0) {
				if (info_timeo) window.clearTimeout(info_timeo);
				info_state = 0;
			} else if (info_state == 0) {
				info_timeo = window.setTimeout("real_hide_info()", 500);
				info_state = -1;
			}
			break;
	}
}

function real_display_info() {
	var info = document.getElementById("info");
	if (!info) return;
	info.style.display = "";
	info_state = 0;
}

function real_hide_info() {
	var info = document.getElementById("info");
	if (!info) return;
	info.style.display = "none";
	info_state = 0;
}

function _m_a_i_l_t_o(u, d, e, t) {
	if (!e) return;
	if (!t) return;
	var m = "m" + "a" + "i" + "l" + "t" + "o";
	switch (e.type) {
		case "mouseover":
			window.status = m  + ":" + u + "@" + d;
			t.href        = m  + ":" + u + "@" + d;
			return true;
			break;
		case "mouseout":
			window.status = "";
			t.href        = "";
			return true;
			break;
		case "click":
			top.location.href = m  + ":" + u + "@" + d;
			return false;
			break;
	}
}

function change_display(id) {
	var o = document.getElementById(id);
	if (o) {
		if (o.style.display == "none") {
			o.style.display = "";
		} else {
			o.style.display = "none";
		}
	}
	return true;
}

function preview(what, w, h, scrollbars) {
	if (!what) return;
	if (!w) w = 600;
	if (!h) h = 400;
	scrollbars = scrollbars ? 1 : 0;
	scr_w = screen.width;
	scr_h = screen.height;
	l = (scr_w - w) / 2;
	t = (scr_h - h) / 2;
	popup = window.open(what, "window_id", "width=" + w + "px,height=" + h + "px,left=" + l + "px,top=" + t + "px,scrollbars=" + scrollbars + ",location=0,toolbar=1,resizable=1,menubar=1,status=1,dependent=1");
	popup.focus();
}

function display_flash(src, width, height, a) {
	if (!window.flash_id) window.flash_id = 1;
	var isIE  = !!(navigator.appVersion.indexOf("MSIE") != -1);
	var isWin = !!(navigator.appVersion.toLowerCase().indexOf("win") != -1);
	var isOpera = !!(navigator.userAgent.indexOf("Opera") != -1);
	var id = window.flash_id ++;
	var r = "";
	if (!a) a = {};
	if (!a.id) a.id = "flash_" + id;
	if (!a.version) a.version = 9;
	if (!a.align) a.align = "middle";
	if (!a.access) a.access = "sameDomain";
	if (!a.quality) a.quality = "high";
	if (!a.background) a.background = "#ffffff";
	if (!a.wmode) a.wmode = "transparent";
	if (!a.scale) a.scale = "noscale";
	if (!a.play) a.play = "true";
	if (!a.loop) a.loop = "true";
	if (!a.menu) a.menu = "false";
	if (!a.salign) a.salign = "";
	if (!a.devicefont) a.devicefont = "false";
	if (!a.fullscreen) a.fullscreen = "false";
	if (isIE && isWin && !isOpera) {
		r += ""
		 + "<object"
		 + " classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\""
		 + " codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + a.version + ",0,0,0\""
		 + " width=\"" + width + "\""
		 + " height=\"" + height + "\""
		 + " align=\"" + a.align + "\""
		 + " id=\"" + a.id + "\""
		 + " name=\"" + a.id + "\""
		 + ">"
		 + "<param name=\"movie\" value=\"" + src + "\" />"
		 + "<param name=\"quality\" value=\"" + a.quality + "\" />"
		 + "<param name=\"bgcolor\" value=\"" + a.background + "\" />"
		 + "<param name=\"allowScriptAccess\" value=\"" + a.access + "\" />"
		 + "<param name=\"wmode\" value=\"" + a.wmode + "\" />"
		 + "<param name=\"scale\" value=\"" + a.scale + "\" />"
		 + "<param name=\"play\" value=\"" + a.play + "\" />"
		 + "<param name=\"loop\" value=\"" + a.loop + "\" />"
		 + "<param name=\"menu\" value=\"" + a.menu + "\" />"
		 + "<param name=\"salign\" value=\"" + a.salign + "\" />"
		 + "<param name=\"devicefont\" value=\"" + a.devicefont + "\" />"
		 + "<param name=\"allowFullScreen\" value=\"" + a.fullscreen + "\" />"
		 + "</object>"
		;
	} else {
		r += "<embed"
		 + " src=\"" + src + "\""
		 + " width=\"" + width + "\""
		 + " height=\"" + height + "\""
		 + " align=\"" + a.align + "\""
		 + " name=\"" + a.id + "\""
		 + " quality=\"" + a.quality + "\""
		 + " bgcolor=\"" + a.background + "\""
		 + " allowScriptAccess=\"" + a.access + "\""
		 + " wmode=\"" + a.wmode + "\""
		 + " scale=\"" + a.scale + "\""
		 + " play=\"" + a.play + "\""
		 + " loop=\"" + a.loop + "\""
		 + " menu=\"" + a.menu + "\""
		 + " salign=\"" + a.salign + "\""
		 + " devicefont=\"" + a.devicefont + "\""
		 + " allowFullScreen=\"" + a.fullscreen + "\""
		 + " type=\"application/x-shockwave-flash\""
		 + " pluginspage=\"http://www.macromedia.com/go/getflashplayer\""
		 + "/>"
		;
	}
	return r;
}

function flash_version() {
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins['Shockwave Flash 2.0']) {
			return parseInt(navigator.plugins['Shockwave Flash 2.0'].description.split(" ")[2]);
		} else if (navigator.plugins['Shockwave Flash']) {
			return parseInt(navigator.plugins['Shockwave Flash'].description.split(" ")[2]);
		}
	} else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) {
		return 4;
	} else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) {
		return 3;
	} else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) {
		return 2;
	} else if ((navigator.appVersion.indexOf("MSIE") != -1) && (navigator.appVersion.toLowerCase().indexOf("win") != -1) && !(navigator.userAgent.indexOf("Opera") != -1)) {
		try {
			return parseInt(((new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")).GetVariable("$version")).split(" ")[1]);
		} catch (e) { }
		try {
			return (new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6")) ? 6 : 0;
		} catch (e) { }
		try {
			return parseInt(((new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3")).GetVariable("$version")).split(" ")[1]);
		} catch (e) { }
		try {
			return (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) ? 2 : 0;
		} catch (e) { }
	}
	return 0;
}

function write_flash(src, width, height, a) {
	document.write(display_flash(src, width, height, a));
}
