function jsAPI ( command, args ) {
	eval ( command + "('" + args + "');" );
	
}

function setVariable ( name, value ) {
	document.getElementById ( swfName ).SetVariable(name, value);
}

function combine ( nh, y, h ) {
	ensureItsVisible ( y, h );
	setNewHeight ( nh );
}

function setNewHeight ( nh ) {
	var newH = Number ( nh );
	//document.getElementById ( 'fc_inner' ).style.height = newH + 'px';
	document.getElementById ( swfName ).height = newH + 'px';
}

function setNewWidth ( w ) {
	minSWFwidth = Number ( w );
}

var newVScrollPos = -1;
function scrollVerticalTo ( spos ) {
	newVScrollPos = Number ( spos );
}

function ensureItsVisible ( y, h ) {
	var ny = Number ( y );
	var nh = Number ( h );
	// ...
	var st = document.body.scrollTop;
	var hei = getWindowHeight () - 20;
	
	if ( ( ny > st ) && ( ny + nh < st + hei ) ) {
		// nothing
	} else {
		if ( nh + 100 < hei ) {
			newVScrollPos = ny - ( hei - nh ) / 2;
		} else {
			newVScrollPos = ny - 20;
		}
		if ( newVScrollPos < 0 ) {
			newVScrollPos = 0;
		}
	}
}
// scales Objects
function scaleObjects2(browser) {
	var curWidth = getWindowWidth() - 1;
	if ( browser == "Firefox" ) {
		curWidth = curWidth - 20;
	}
	var nw = curWidth;
	if ( nw < minSWFwidth ) nw = minSWFwidth;
	if ( document.getElementById(swfName) != null ) {
		document.getElementById(swfName).width = nw + "px";
		so.width = nw + "px";
		//document.getElementById('fc_inner').style.width = nw + "px";
	}
	var hhh = Number ( document.getElementById ( swfName ).height );
	if ( ( newVScrollPos < 0 ) && ( newVScrollPos != -1 ) ) newVScrollPos = 0;
	if ( newVScrollPos > hhh ) newVScrollPos = hhh;
	
	var d = document.body.scrollTop;
	if ( d != lastScrollPos ) {
		newVScrollPos = -1;
	}
	
	if ( newVScrollPos != -1 ) {
		if ( ( Math.abs ( d - newVScrollPos ) < 3 ) ) {
			document.body.scrollTop = newVScrollPos;
			newVScrollPos = -1;
		} else {
			var p = Math.round ( ( newVScrollPos - d ) * 0.2 );
			if ( p == 0 ) {
				p = ( newVScrollPos > d ) ? 1 : -1;
			}
			var dd = d + p;
			document.body.scrollTop = dd;
		}
	}
	
	if ( d == document.body.scrollTop ) {
		newVScrollPos = -1;
	}
	d = document.body.scrollTop;
	
	if ( d != lastScrollPos ) {
		lastScrollPos = d;
		document.getElementById(swfName).SetVariable("vScrollPos", d);
		var vhei = getWindowHeight () - 20;
		document.getElementById(swfName).SetVariable("visHeight", vhei);
	}
	
	
	setTimeout("scaleObjects('"+browser+"');", 30 );
	
}

