//<script>
//-------------------------------------------------------------------------------   
// HTML dialogue encapsulation
// constructor
function dbjdialog ( arg_url, dlgargs )
{
	this.version = "$Revision: 5 $"  ;
	this.url = arg_url != null ? arg_url : "about:blank" ;
	this.msg = dlgargs != null ? dlgargs : "" ;
}
// these are defaults used for every  dialogue,unless changed
	dbjdialog.font =  "font:italic normal bolder 10pt Verdana" ;
	dbjdialog.width =  "dialogWidth:440px" ;
	dbjdialog.height = "dialogHeight:180px";
	dbjdialog.center = "center:yes" ;
	dbjdialog.resizable = "resizable:yes" ;
	dbjdialog.scroll = "scroll:no" ;
	dbjdialog.status = "status:no" ;
	dbjdialog:help = "help:no" ;
	dbjdialog.yesno = new Array('yes','no','YES','NO') ;
//-------------------------------------------------------------------------------   
dbjdialog.change = function( what, how )
{
	var  errmsg = "ERROR in dbjdialog.onchange(" + what + ", " + how + "): " ;
	what  = new String(what.toUpperCase()) ;
	
	if ( null != what.match("FONT") ) {
	      if (null != how ) 
	      if ( how.length > 1 )
			dbjdialog.font = "font:" + how ;
	} 
	else if ( what.match("WIDTH") ) 
	{
		if ( isNaN(parseInt(how)) ) 
		throw new Error( 0x13 + errmsg + " second argument has to contain number" );
	    dbjdialog.width = "dialogWidth:" + how ;
	} 
	else if ( null != what.match("HEIGHT") ) 
	{
		if ( isNaN(parseInt(how)) ) 
		throw new Error( 0x13 + errmsg + " second argument has to contain number" );
	    dbjdialog.height = "dialogHeight:" + how ;
	} 
	else if ( null != what.match("CENTER") ) 
	{
		if ( ! dbjdialog.legal( how, dbjdialog.yesno) )
		throw new Error( 0x13 + errmsg + " second argument has to be 'yes' or 'no' " );
	    dbjdialog.center = "center:" + how ;
	} 
	else if ( null != what.match("RESIZABLE") ) 
	{
		if ( ! dbjdialog.legal( how, dbjdialog.yesno) )
		throw new Error( 0x13 + errmsg + " second argument has to be 'yes' or 'no' " );
	    dbjdialog.resizable = "resizable:" + how ;
	} 
	else if ( null != what.match("SCROLL") ) 
	{
		if ( ! dbjdialog.legal( how, dbjdialog.yesno) )
		throw new Error( 0x13 + errmsg + " second argument has to be 'yes' or 'no' " );
	    dbjdialog.scroll = "scroll:" + how ;
	} 	
	else if ( null != what.match("STATUS") ) 
	{
		if ( ! dbjdialog.legal( how, dbjdialog.yesno) )
		throw new Error( 0x13 + errmsg + " second argument has to be 'yes' or 'no' " );
	    dbjdialog.status = "status:" + how ;
	} 
	else if ( null != what.match("HELP") ) 
	{
		if ( ! dbjdialog.legal( how, dbjdialog.yesno) )
		throw new Error( 0x13 + errmsg + " second argument has to be 'yes' or 'no' " );
	    dbjdialog.help = "help:" + how ;
	} 
	else
		throw new Error( 0x13 +  errmsg +  " first argument is unknown.");
}	
//-------------------------------------------------------------------------------   
// this  is very cool function that has to be put into some library...
// optionaly check if value matches any from  the array  of legal values.
dbjdialog.legal = function ( to_check, legal_values, x ) 
{
	var result = ( null != to_check ) ;
    if ( result )
	if ( null != legal_values )
			for ( var j= 0 ; j  < legal_values.length; j++ )
				if (to_check == legal_values[j])
					return true ; // found it
		return result ;
}
//-------------------------------------------------------------------------------   
dbjdialog.prototype.modal = function ()
{
	var options = dbjdialog.font + ";" + dbjdialog.width + ";" + dbjdialog.height + ";" +
	              dbjdialog.center + ";" + dbjdialog.resizable + ";" + dbjdialog.scroll
	              + ";" + dbjdialog.status + ";" + dbjdialog.help ;
    //return window.showModalDialog( this.url, this.msg + "<hr>" + options, options ) ;	              
    return window.showModalDialog( this.url, this.msg , options ) ;	              
}
  
function buyBook(isbns)
{
 var dlg =  new dbjdialog( "../js/buybook.html" , isbns ) ;
 dbjdialog.change( "WIDTH", "300px" ) ;
 dbjdialog.change( "HEIGHT", "150px" ) ;
 dbjdialog.change( "HELP", "Select your choice") ;
 dbjdialog.change( "RESIZABLE", "no" ) ;  
 return dlg.modal() ; 
}

