//constructor

var FFTool_count_instance = 0;

function FFTool(_width)
{
	this.divID = FFTool_getCurrentDiv().id;
	var randstr = FFTool_getRandomString(20);
	this.so = new SWFObject('FFTool.swf?p='+randstr+'', "FFTool_id"+FFTool_count_instance, _width+'px', '1px', '9', '', true);
	this.so.addParam("wmode", "transparent");
	FFTool_count_instance++;
}

FFTool.prototype.addVariable = function(_key, _value)
{
	if(typeof _value == "string") {
		_value = _value.replace(new RegExp("&amp;", "g"), "%26");
	}
	this.so.addVariable(_key, _value);
}

FFTool.prototype.init = function()
{
	this.so.write(this.divID);
}

function FFTool_resizeSWF(_id, _width, _height) 
{
	//alert("onResize : "+_width+", "+_height);
	document.getElementById(_id).width = _width;
	document.getElementById(_id).height = _height;
}

function FFTool_getCurrentDiv()
{
	var randstr = FFTool_getRandomString(20);
	document.write("<a id='"+randstr+"' style='display:none'></a>");
	return document.getElementById(randstr).parentNode;
}

function FFTool_getRandomString(length) {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var randomstring = '';
	for (var i=0; i<length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}


