function toggleLayer( whichLayer )
  {
    var elem, vis;
    if( document.getElementById ) // this is the way the standards work
      elem = document.getElementById( whichLayer );
    else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
    else if( document.layers ) // this is the way nn4 works
      elem = document.layers[whichLayer];
    vis = elem.style;
    // if the style.display value is blank we try to figure it out here
    if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
      vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
    vis.display = (vis.display==''||vis.display=='block')?'none':'block';
  }


function SubmitData(){
    
    //hide form, show results
    toggleLayer('que');
    toggleLayer('order_status');
    
    var xmlhttp, data, user, param, link;
    var elts = document.mainForm.getElementsByTagName("select");

    if (window.XMLHttpRequest)
    {
      xmlhttp=new XMLHttpRequest();
    }
    else
    {
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    //get selected configuration
    link = "<a href='" + window.location + "'>" + document.title + "</a>";    
    data = "^^" + elts[0].getAttribute("title") + ": " + elts[0].options[elts[0].selectedIndex].innerHTML;
    for(var i=1; i<elts.length; i++){
        if(elts[i].getAttribute("title")){
            data += "!!^^" + elts[i].getAttribute("title") + ": " + elts[i].options[elts[i].selectedIndex].innerHTML;
        }
        else{
            data += " x" + elts[i].options[elts[i].selectedIndex].innerHTML;
        }
    }
    data += "!!";
    
    //get user data
    user = "^^Компания: " + document.SubmitQ.comp.value + "!!";
    user += "^^ФИО: " + document.SubmitQ.nssn.value + "!!";
    user += "^^e-mail: " + document.SubmitQ.email.value + "!!";
    user += "^^Телефон: " + document.SubmitQ.phone.value + "!!";
    if (document.SubmitQ.comments.value){
        user += "^^Комментарии: " + document.SubmitQ.comments.value + "!!";
    }

    //collect data into string
    param = "?link=" + escape(link);
    param += "&data=" + escape(data);
    param += "&user=" + escape(user);
    param += "&em=" + escape(document.SubmitQ.email.value);
    param += "&fio=" + escape(document.SubmitQ.nssn.value);
    param += "&price=" + escape(document.mainForm.price.value);
    
    xmlhttp.onreadystatechange=function()
    {
      if(xmlhttp.readyState==4)
      {
        divEl=document.getElementById('order_status');
        divEl.innerHTML=xmlhttp.responseText;
      }
    }

    xmlhttp.open("GET","save.asp" + param, true);
    xmlhttp.send(null);
  }