// Implements InsertDynamicAppletControl() function. This is a generic function used to generate
// applet tags. It is used by higher level api functions.
function ShowMess(msg,maxw)
{
	var o = document.body.insertBefore(document.createElement('div'), document.body.firstChild);
	var d = document.body.insertBefore(document.createElement('div'), document.body.firstChild);
	var s = '', isIE = (0 /*@cc_on + 1 @*/);
	d.innerHTML = '<div align="right" style="margin:-35px -40px 10px; border-bottom:1px solid #bee1f5;"><button style="border:0;background:#fff; font-weight:bold; cursor:pointer; margin-right:3px; padding:0;">X</button></div>' 
		+ msg 
		+'<div align="center" style="margin:20px -40px -28px; padding-top:6px; border-top:1px solid #bee1f5; "><button>Закрыть</button></div>';
	s = isIE ? 'position:absolute; filter:alpha(opacity=50); top: 0px	' : 'position:fixed; opacity:0.50;';
	o.style.cssText = 'top:0; left:0; width:1900px; height:6000px; z-index:50000; background-color:#000;' + s;

	s = isIE ? 'position:absolute;  top: expression(parseInt( document.getElementsByTagName("html")[0].scrollTop ) + parseInt(document.getElementsByTagName("html")[0].clientHeight/2)+450 +"px" );' : 'position:fixed;';
	d.style.cssText = 'top:50%; left:50%; z-index:50001; background:#fff; padding:35px 40px; border:1px solid #008dda;' + s;
	if(!maxw && d.offsetWidth >= 550) d.style.width = '550px';
	d.style.marginLeft = '-'+parseInt(d.offsetWidth/2)+'px';
	d.style.marginTop = '-'+parseInt(d.offsetHeight/2)+'px';
	s = d.getElementsByTagName('button');
	for(var i=0;i<s.length;i++)
		s[i].onclick=function(){ o.style.display='none'; d.style.display='none'; d.innerHTML = ''; };
}
			
// Implements InsertDynamicAppletControl() function. This is a generic function used to generate
// applet tags. It is used by higher level api functions.
			
function InsertDynamicAppletControl()
{  
  // Initialize variables
  var currArg = '';
  var closer = '>';
  var srcFound = false;
  var embedStr = '<applet';
  var paramStr = '';
  
  // Spin through all the argument pairs, assigning attributes and values to the object,
  // param, and embed tags as appropriate.
  for (var i=0; i < arguments.length; i=i+2)
  {
   currArg = arguments[i].toLowerCase();    

    if (currArg == "movie")
    {
        paramStr += '<param name="' + arguments[i] + '" value="' + arguments[i+1] + '"' + closer + '\n';
        srcFound = true;
    }
    else if (   currArg == "width" 
              || currArg == "height" 
              || currArg == "code" 
              || currArg == "archive" 
              || currArg == "align" 
              || currArg == "vspace" 
              || currArg == "hspace" 
              || currArg == "class" 
              || currArg == "title" 
              || currArg == "accesskey" 
              || currArg == "tabindex")
    {
      embedStr += ' ' + arguments[i] + '="' + arguments[i+1] + '"';
    }
    // This is an attribute we don't know about. Assume that we should add it to the 
    // param and embed strings.
    else
    {
      paramStr += '<param name="' + arguments[i] + '" value="' + arguments[i+1] + '"' + closer + '\n'; 
    }
  }
  
  // Tell the user that a src is required, if one was not passed in.
  if (!srcFound)
  {
    alert("The requires that a movie be passed in as one of the arguments.");
    return;
  }

  // Close off the object and embed strings
  embedStr += ' MAYSCRIPT>' + paramStr + '</applet>\n'; 
  
  document.write(embedStr);
}

function GetDynamicAppletControl()
{  
  // Initialize variables
  var currArg = '';
  var closer = '>';
  var srcFound = false;
  var embedStr = '<applet';
  var paramStr = '';
  
  // Spin through all the argument pairs, assigning attributes and values to the object,
  // param, and embed tags as appropriate.
  for (var i=0; i < arguments.length; i=i+2)
  {
   currArg = arguments[i].toLowerCase();    

    if (currArg == "movie")
    {
        paramStr += '<param name="' + arguments[i] + '" value="' + arguments[i+1] + '"' + closer + '\n';
        srcFound = true;
    }
    else if (   currArg == "width" 
              || currArg == "height" 
              || currArg == "code" 
              || currArg == "archive" 
              || currArg == "align" 
              || currArg == "vspace" 
              || currArg == "hspace" 
              || currArg == "class" 
              || currArg == "title" 
              || currArg == "accesskey" 
              || currArg == "tabindex")
    {
      embedStr += ' ' + arguments[i] + '="' + arguments[i+1] + '"';
    }
    // This is an attribute we don't know about. Assume that we should add it to the 
    // param and embed strings.
    else
    {
      paramStr += '<param name="' + arguments[i] + '" value="' + arguments[i+1] + '"' + closer + '\n'; 
    }
  }
  
  // Tell the user that a src is required, if one was not passed in.
  if (!srcFound)
  {
    alert("The requires that a movie be passed in as one of the arguments.");
    return;
  }

  // Close off the object and embed strings
  embedStr += ' MAYSCRIPT>' + paramStr + '</applet>\n'; 
  
  return embedStr;
}

function holoWnd(url) {
	ShowMess(GetDynamicAppletControl('archive', '/3d/holomatix.jar', 'code', 'blaze3d.class', 'width', '604', 'height', '447', 'align', '',
						'movie', url, 'Scale', 'showall', 'SAlign', ''),true);
}
