<!--

/**
* Common functions. 
*
* 'browser.js' should be included already.
*
* @package Api
* @subpackage JavaScript
*/

function openBigImg( img, w, h )
{
    if ( img ) {
	var win = openPopup( '', 'big_img', w, h );
	if ( win ) {
	    win.document.open();
	    win.document.write( '<html><head>' );
	    win.document.write( '<meta http-equiv="imagetoolbar" content="no">' );
	    win.document.write( '<style type="text/css">' );
	    win.document.write( 'body { margin: 0; overflow: auto; padding: 0; } img { cursor: pointer; cursor: hand; }' );
	    win.document.write( '</style></head><body>' );
	    win.document.write( '<img src="' + img.src + '" border="0" onclick="window.close();">' );
	    win.document.write( '</body></html>' );
	    win.document.close();
	}
    }
}

/*
* Opens popup window in center of the screen.
*/
function openPopup( url, name, width, height, prop )
{
	var left = Math.floor( screen.availWidth / 2 ) - Math.floor( width / 2 );
	var top = Math.floor( screen.availHeight / 2 ) - Math.floor( height / 2 );
	if ( ! prop ) prop = 'location=no,resizable=yes,menubar=no,status=no,scrollbars=yes'
	
	var win = window.open( url, name, 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',' + prop );
		
	if ( win ) win.focus();
	
	return win;
}

/*
* Shows text in statusbar of window.
*/
function statusText( txt )
{
	window.status = txt;
	
	return true;
}

/*
* Sets source of image.
*/
function setImg( img, newsrc )
{
	document.images[img].src = newsrc;
}

/*
* Sets HTML of some object.
*/
function setHTML( targetframe, obj_id, html )
{
	if ( ! IS_MOZ && ! IS_IE ) return;
	if ( ! targetframe ) return;
	
	var obj = targetframe.document.getElementById( obj_id );
	if ( ! obj ) return;
	
	obj.innerHTML = html;
}

//-->
