var flashVersion = 0;
var defErrorHandle = window.onerror;

function Flash () {
	this._swf = '';
	this._width = 0;
	this._height = 0;
	this._params = new Array();
	this._divClass = '';
}


Flash.prototype.setSWF = function (_swf, _width, _height, _divClass){
	this._swf = _swf;
	this._width = _width;
	this._height = _height;
	this._divClass = _divClass;
}


Flash.prototype.setParam = function (paramName, paramValue){
	this._params[this._params.length] = paramName+'|||'+paramValue;
}


Flash.prototype.display = function () {
	if (flashVersion < 6) return false;
	
	var _txt = '';
	var params = '';
	var _param = '';
	var i = 0;

	_txt += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this._width+'" height="'+this._height+'">\n';
	_txt += '<param name="movie" value="'+this._swf+'" />\n'
	_txt += '<param name="quality" value="high" />\n';
	for ( i=0;i<this._params.length;i++ ) {
	_param = this._params[i].split ('|||');
	_txt += '\t<param name="'+_param[0]+'" value="'+_param[1]+'" />\n';
	_txt += '\t<param name="menu" value="false" />\n';
	params += _param[0]+'="'+_param[1]+'" ';
	}

	_txt += '<embed menu="false" width="'+this._width+'" height="'+this._height+'" src="'+this._swf+'" '+params+' quality="high" type="application/x-shockwave-flash"></embed>\n';
	_txt += '</object>\n';
	
	if (this._divClass != '') _txt = '<div class="' + this._divClass + '">' + _txt + '</div>';
	document.write (_txt);
}


function calcFrameHeight() {
	var f = document.getElementById('frame');
	var height = f.contentWindow.document.body.scrollHeight;
	f.height = height;

	if (navigator.appName != 'Netscape') return;

	var f_childs = f.contentWindow.document.body.childNodes;
	var new_height = 0;

	for (var i = 0; i < f_childs.length; i++)
	{
		if (f_childs[i].className == 'child_content')
		{
			new_height = f_childs[i].scrollHeight;
		}
	}

	if (new_height > 0) f.height = new_height;

//	alert(document.getElementById('frame').contentWindow.document.body.childNodes[1].scrollHeight);
//	alert(document.getElementById('frame').contentWindow.document.body.scrollHeight);
//	alert(document.getElementById('frame').contentWindow.document.body.offsetHeight);
}



function imgWin(img){
	var scr='/images/preview/show.htm';
	var x = screen.width/2 - 400/2;
	var y = screen.height/2 - 300/2;
	var wn=window.open(scr+'?'+escape(img),'win','resizable,width=400,height=300,top='+y+',left='+x+',screenX='+x+',screenY='+y+',status=0');
	wn.focus();
	return false;
}












function GetFlashVersion() {
	window.onerror = function() {
		return true;
	}
	var ie=0
	var fz=0
	var n=navigator

	if (n.platform=='Win32' && !window.opera && n.appName!='Netscape') {
		ie=1
		for (var i=3;i<10;i++) {
			if (eval('new ActiveXObject("ShockwaveFlash.ShockwaveFlash.'+i+'")')) {
				flashVersion = i;
			}
		}
	}


	if ((ie==0)&&(n.plugins)) {
		for (var i=0;i<n.plugins.length;i++) {
			if (n.plugins[i].name.indexOf('Flash')> -1) {
				fz = parseInt(n.plugins[i].description.charAt(16));
				if (fz > flashVersion) flashVersion = fz;
			}
		}
	}
	if (flashVersion == 1) flashVersion = 10;
}
GetFlashVersion();
window.onerror = defErrorHandle;
