﻿var c_width
var norm_browser;
var div_param;
var div


function show_reserve(arg)
    {
    div_param=arg;
    show_block();
    }
function show_order()
    {
    if(document.selection && !window.getSelection)
        {
        norm_browser=false;
        }
    else
        {
        norm_browser=true;/*на всякий случай*/
        }
    close_div();
    var parent_div=document.createElement('DIV');
    parent_div.id='parent_div';
    parent_div.style.display='';
    parent_div.style.position='absolute';
    parent_div.style.top="0px";
    parent_div.style.left="0px";
    parent_div.style.width="100%"
    parent_div.style.height="800";
    parent_div.style.textAlign='center';
    parent_div.style.overflow='hidden';
    document.body.appendChild(parent_div);
    var div_t=document.createElement('DIV');
    if(norm_browser)
        {
        c_width=parseInt(parent_div.clientWidth);
        div_t.style.marginLeft=(c_width/2-15)+"px";
        }
    else
        {
        c_width=document.documentElement.offsetWidth;
        div_t.style.paddingLeft=(c_width/2)-15;
        }
    div_t.style.verticalAlign='top';
    div_t.style.textAlign='center';
    div_t.style.marginTop="50";
    div_t.style.width="30px";
    div_t.style.width="30px";
    div_t.style.height="10px";
    div_t.style.overflow='hidden';
    //div.style.position='relative';
    div_t.style.backgroundColor='#C2C2C2';
    div_t.style.opacity=0.9;
    div_t.style.filter='alpha(opacity: 90)';
    div_t.style.display='';
    div_t.innerHTML='&nbsp;';
    div_t.id='reserve_div';
    parent_div.appendChild(div_t);
    setTimeout("spread_block_w()",5)
    div = document.getElementById('reserve_div');
    }
function spread_block_w()
    {
    var w=parseInt(div.style.width);
    if(w<1000)
        {
        if(norm_browser)
            {
            div.style.width=w+20+'px';
            div.style.marginLeft=((c_width-w)/2-5)+"px";
            setTimeout("spread_block_w()",1);
            }
        else
            {
            div.style.width=w+20+"px";
            //div.style.paddingLeft=((c_width-w)/2-6)+"px";
            setTimeout("spread_block_w()",1);
            }
        }
    else
        {
        setTimeout("spread_block_h()",5)
        }
    }
function spread_block_h()
    {
    var h=parseInt(div.style.height);
    if(h<700)
        {
        div.style.height=h+20+'px';
        setTimeout("spread_block_h()",5)
        }
    else
        {
        create_frame();
        }
    }
function create_frame()
    {
    if(!norm_browser)
        {
        div.style.paddingLeft="0px";
        }
    div.innerHTML='<table width="1000" height="700" align="center" border="0"><tr height="15"><td align="right" style="vertical-align:top"><a href="javascript:close_div();"><img src="img/close.jpg" border="0" alt="Закрыть"></a></td></tr><tr><td id="text_holder" style="vertical-align:middle; padding-left:15px; padding-right:15px;" align="center"><img src="img/ajax-loader.gif" width="300" id="loader"><iframe id="frame" src="http://'+location.hostname+'/order_form.html" width="950" height="650" style="display:none;" onload="frame_load()" scrolling="auto"></iframe></td></tr></table>';
    }

function close_div()
    {
    try
        {
        document.getElementById('parent_div').parentNode.removeChild(document.getElementById('parent_div'));
        }
    catch(e){}
    }

function frame_load()
    {
    document.getElementById('loader').style.display='none';
    var frame=document.getElementById('frame');
    frame.width='100%';
    frame.height='100%';
    frame.style.display='';
    }