﻿/*////////////////////////////////////////////////////////////////////////////////////////

  swfIN 1.0.2  -  2007-02-06
  javascript toolkit for flash developers
   2004-2007 Francis Turmel  |  swfIN.nectere.ca  |  www.nectere.ca  |  francis@nectere.ca
  released under the MIT license

/*/
///////////////////////////////////////////////////////////////////////////////////////
var fd = {};
fd.showFlash = function(_1, id, _3, _4, w, h, _7, _8, _9) {
	if (fd.movies == null) {
		fd.movies = [];
	}
	if (_7 == null) {
		_7 = 0;
	}
	var _a = fd.tools.getFlashVersion();
	var _b = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+_7+",0,0,0";
	if (fd.player_download == null) {
		fd.player_download = "http://www.macromedia.com/go/getflashplayer";
	}
	fd.tryExpressInstall = (_a<_7 && _9 && _a>=6);
	(_8 != null) ? _8=_8.split(" : ") : _8="";
	if (_a>=_7 || fd.tools.getQsParam("bypassFlashCheck") == "true" || fd.tryExpressInstall) {
		fd.actions.outputTag(_1, id, _3, _4, w, h, _b);
	} else {
		if (_8[0] == "r") {
			fd.actions.redirect(_8[1], _8[2], _7, _a);
		} else {
			if (_8[0] == "i") {
				fd.actions.image(_8[1], _8[2]);
			} else {
				if (_8[0] == "d") {
					fd.actions.showDiv(_8[1]);
				} else {
					if (_8[0] == "h") {
						fd.actions.html(_8[1]);
					}
				}
			}
		}
	}
	for (var i = 0; i<fd.movies.length; i++) {
		if (fd.movies[i] == id) {
			alert("swfIN alert:\nYou cannot name two swfs by the same id. Please revise your swfs IDs in your swfIN() instanciation.");
		}
	}
	fd.movies.push(id);
};
fd.actions = {outputTag:function (_d, id, _f, _10, w, h, _13) {
	if (fd.tryExpressInstall) {
		_10["MMplayerType"] = (fd.tools.nsPlugin()) ? "PlugIn" : "ActiveX";
		document.title = document.title.slice(0, 47)+" - Flash Player Installation";
		_10["MMdoctitle"] = document.title;
		_10["MMredirectURL"] = escape(window.location);
	}
	for (var k in _10) {
		(_d.indexOf("?") == -1) ? _d += "?"+k+"="+_10[k] : _d += "&"+k+"="+_10[k];
	}
	var p = [];
	p["quality"] = "high";
	p["menu"] = "false";
	p["swLiveConnect"] = "true";
	p["pluginspage"] = fd.player_download;
	p["allowScriptAccess"] = "always";
	for (var i in _f) {
		p[i] = _f[i];
	}
	var _17, obj_h;
	if (!fd.tools.ns4()) {
		_17 = "100%";
		obj_h = "100%";
	} else {
		_17 = fd.size.calculate(w, "w");
		obj_h = fd.size.calculate(h, "h");
	}
	var cb = (fd.tools.ie7()) ? "codebase='"+_13+"'" : "";
	var tag = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' "+cb+" id='"+id+"' width='"+_17+"' height='"+obj_h+"' align='top' hspace='0' vspace='0'><param name='movie' value='"+_d+"'>";
	for (var i in p) {
		tag += "<param name='"+i+"' value='"+p[i]+"'>";
	}
	tag += "<embed src='"+_d+"' width='"+_17+"' height='"+obj_h+"' align='top' hspace='0' vspace='0' type='application/x-shockwave-flash' name='"+id+"' ";
	for (var i in p) {
		tag += i+"='"+p[i]+"' ";
	}
	tag += "></embed></object>";
	if (!fd.tools.ns4()) {
		var a = "<div id='div_"+id+"' style='width:"+fd.size.calculate(w, "w")+"; height:"+fd.size.calculate(h, "h")+"'>"+tag+"</div>";
		document.write(a);
		if (fd.tools.ie()) {
			$("div_"+id).innerHTML = $("div_"+id).innerHTML;
		}
		$("div_"+id).fd_w = w;
		$("div_"+id).fd_h = h;
	} else {
		document.write(tag);
	}
}, redirect:function (url, _1e, _1f, _20) {
	if (_1e == "true") {
		location.href = url+"?r="+_1f+"&i="+_20;
	} else {
		location.href = url;
	}
}, image:function (_21, url) {
	if (url == "none") {
		document.write("<img src='"+_21+"' border=0 />");
	} else {
		if (url == null) {
			url = fd.player_download;
		}
		document.write("<a href='"+url+"' target='_blank'><img src='"+_21+"' border=0 /></a>");
	}
}, showDiv:function (id) {
	if (!fd.tools.ns4() && !fd.tools.ie5_mac()) {
		$(id).style.display = "block";
	}
}, html:function (_24) {
	document.write(_24);
}};
fd.size = {calculate:function (val, _26) {
	if (val.indexOf(" : ") != -1) {
		val = val.split(" : ");
		var _27 = val[0].split("%");
		var _28 = (_27[0] != "" && _27[1] != null) ? (_27[0]/100) : 1;
		var _29 = fd.tools.browserSize()[_26]*_28;
		var res = (val[1]>_29 || val[1] == "") ? val[1] : val[0];
		if (res.indexOf("%")>-1) {
			return res;
		} else {
			return res+"px";
		}
	} else {
		if (val.indexOf("%")>-1) {
			return val;
		} else {
			return val+"px";
		}
	}
}, refresh:function () {
	if (!fd.tools.ns4()) {
		for (var id in fd.movies) {
			if ($("div_"+fd.movies[id])) {
				var w = fd.size.calculate($("div_"+fd.movies[id]).fd_w, "w");
				var h = fd.size.calculate($("div_"+fd.movies[id]).fd_h, "h");
				$("div_"+fd.movies[id]).style.width = w;
				$("div_"+fd.movies[id]).style.height = h;
			}
		}
	} else {
		location.reload();
	}
}, resizeDiv:function (id, w, h) {
	var _31 = $("div_"+id).fd_w.split(" : ");
	var _32 = $("div_"+id).fd_h.split(" : ");
	$("div_"+id).fd_w = (_31[1] == null) ? w : w+" : "+_31[1];
	$("div_"+id).fd_h = (_32[1] == null) ? h : h+" : "+_32[1];
	fd.size.refresh();
}, changeMinSize:function (id, w, h) {
	var _36 = $("div_"+id).fd_w.split(" : ");
	var _37 = $("div_"+id).fd_h.split(" : ");
	$("div_"+id).fd_w = _36[0]+" : "+w;
	$("div_"+id).fd_h = _37[0]+" : "+h;
	fd.size.refresh();
}, percent2pixel:function () {
	return 0;
}};
fd.tools = {getQsParam:function (key) {
	var tmp = fd.tools.getQs()[key];
	return (tmp != null && tmp != undefined && tmp != "") ? tmp : null;
}, getQs:function () {
	var _3a = window.location.search.substring(1).split("&");
	var qs = [];
	for (var i = 0; i<_3a.length; i++) {
		var pos = _3a[i].indexOf("=");
		if (pos>0) {
			qs[_3a[i].substring(0, pos)] = _3a[i].substring(pos+1);
		}
	}
	return qs;
}, getTopQs:function () {
	var _3a = parent.window.location.search.substring(1).split("&");
	var qs = [];
	for (var i = 0; i<_3a.length; i++) {
		var pos = _3a[i].indexOf("=");
		if (pos>0) {
			qs[_3a[i].substring(0, pos)] = _3a[i].substring(pos+1);
		}
	}
	return qs;
}, ns4:function () {
	return (document.layers) ? true : false;
}, ie5_mac:function () {
	var _3e = navigator.userAgent.toLowerCase();
	return (_3e.indexOf("msie 5") != -1 && _3e.indexOf("mac") != -1);
}, ie7:function () {
	var _3f = navigator.userAgent.toLowerCase();
	return (_3f.indexOf("msie 7") != -1);
}, ie:function () {
	var _40 = navigator.userAgent.toLowerCase();
	return (_40.indexOf("msie") != -1);
}, mac:function () {
	var _41 = navigator.userAgent.toLowerCase();
	return (_41.indexOf("mac") != -1);
}, nsPlugin:function () {
	return (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length);
}, browserSize:function () {
	if (self.innerWidth) {
		return {w:self.innerWidth, h:self.innerHeight};
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			return {w:document.documentElement.clientWidth, h:document.documentElement.clientHeight};
		} else {
			if (document.body) {
				return {w:document.body.clientWidth, h:document.body.clientHeight};
			}
		}
	}
	return false;
}, getFlashVersion:function () {
	document.writeln("<script language=\"VBscript\">");
	document.writeln("Function detectActiveXControl(activeXControlName)");
	document.writeln("  on error resume next");
	document.writeln("  detectActiveXControl = False");
	document.writeln("  detectActiveXControl = IsObject(CreateObject(activeXControlName))");
	document.writeln("End Function");
	document.writeln("</scr"+"ipt>");
	var _42 = 0;
	var b = navigator.userAgent.toLowerCase();
	if ((b.indexOf("msie") != -1) && (b.indexOf("win") != -1) && (b.indexOf("opera") == -1)) {
		if (fd.tools.ie7()) {
			_42 = 15;
		} else {
			for (var i = 3; i<15; i++) {
				if (detectActiveXControl("ShockwaveFlash.ShockwaveFlash."+i) == true) {
					_42 = i;
				}
			}
		}
	} else {
		if (navigator.plugins["Shockwave Flash"]) {
			var _45 = navigator.plugins["Shockwave Flash"].description;
			_42 = parseInt(_45.charAt(_45.indexOf(".")-1));
		}
		if (b.indexOf("webtv/2.6") != -1) {
			_42 = 4;
		}
		if (b.indexOf("webtv/2.5") != -1) {
			_42 = 3;
		}
		if (b.indexOf("webtv") != -1) {
			_42 = 2;
		}
	}
	return _42;
}, screenSize:function (_46) {
	if (_46 == "full") {
		return {w:screen.width, h:screen.height};
	}
	if (_46 == "avail") {
		return {w:screen.availWidth, h:screen.availHeight};
	}
	return false;
}, popUp:function (url, _48, w, h, x, y, _4d) {
	var _4e = fd.tools.screenSize("full");
	var scr = fd.tools.screenSize("avail");
	w = (w == "full") ? scr.w : w;
	h = (h == "full") ? scr.h : h;
	x = (x == "center") ? (_4e.w-w)/2 : x;
	y = (y == "center") ? (_4e.h-h)/2 : y;
	var p = [];
	p["width"] = w;
	p["innerWidth"] = w;
	p["height"] = h;
	p["innerHeight"] = h;
	p["toolbar"] = 0;
	p["location"] = 0;
	p["directories"] = 0;
	p["status"] = 0;
	p["menubar"] = 0;
	p["scrollbars"] = 0;
	p["resizable"] = 0;
	p["copyhistory"] = 0;
	p["fullscreen"] = 0;
	for (var i in _4d) {
		p[i] = _4d[i];
	}
	var _52 = "";
	for (var i in p) {
		_52 += (_52 == "") ? i+"="+p[i] : ","+i+"="+p[i];
	}
	var win = window.open(url, _48, _52);
	win.resizeTo(w, h);
	win.moveTo(0, 0);
	win.moveBy(x, y);
	win.focus();
}};
if (Array.prototype.push == null) {
	Array.prototype.push = function(val) {
		this[this.length] = val;
		return this.length;
	};
}
function $(id) {
	if (!fd.tools.ns4()) {
		return document.getElementById(id);
	} else {
		return document.layers[id];
	}
}
window.onresize = fd.size.refresh;
var swfIN = function (_57, id, w, h, _5b) {
	this.fd = fd;
	this.params = [];
	this.flashVars = [];
	this.movie = _57;
	this.id = id;
	this.w = w;
	this.h = h;
};
swfIN.prototype = {addParam:function (_5c, val) {
	this.params[_5c] = val;
}, addVar:function (_5e, val) {
	this.flashVars[_5e] = val;
}, addVars:function (_60) {
	for (var i in _60) {
		this.addVar(i, _60[i]);
	}
}, minSize:function (_62, _63) {
	if (_62 != null) {
		this.w += " : "+_62;
	}
	if (_63 != null) {
		this.h += " : "+_63;
	}
}, detect:function (_64, _65, _66, _67) {
	this.requiredVersion = _64;
	this.param1=_65, this.param2=_66, this.param3=_67;
	var _68 = "";
	for (var i = 1; i<=3; i++) {
		if (this["param"+i] != null) {
			if (_68 == "") {
				_68 += this["param"+i];
			} else {
				_68 += " : "+this["param"+i];
			}
		}
	}
	this.myAction = _68;
}, useExpressInstall:function () {
	this.express = true;
}, write:function () {
	this.fd.showFlash(this.movie, this.id, this.params, this.flashVars, this.w, this.h, this.requiredVersion, this.myAction, this.express);
	this.fd.size.refresh();
}, name:"swfIN 1.0.2  -  2007-02-06", author:"\ufffd 2004-2007 Francis Turmel  |  swfIN.nectere.ca  |  www.nectere.ca  |  francis@nectere.ca", desc:"javascript toolkit for flash developers  |  released under the MIT license"};

