function new_win(img, name,width,height)
{
      w1=window.open('','new_window','resizable=no,menubar=no,status=no,scrollbars=no,width='+width+',height='+height+',top=70,left=100');
      w1.document.open();
      w1.document.write("<html><head><title>"+name+"</title></head><body leftmargin=0 topmargin=0>");
      w1.document.write("<center><a style='font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-weight : bold; font-size: 10px; text-decoration : none; color : #336699;' href='javascript:window.close()'><img src="+img+" width="+width+" height="+(height-20)+" border=0 alt='"+name+"'><br>Закрыть окно</a>");
      w1.document.write("</body></html>");
      w1.document.close();
    w1.focus();
}
function newWin(title,width,height,text){  winOpen = window.open('','newWin','resizable=no,menubar=no,status=no,scrollbars=no,width='+width+',height='+height+',top=70,left=100');
  winOpen.document.open();
  $.post('calcUser.php', function(data){    content = data;
    winOpen.document.write("<html><head><title>"+title+"</title><link rel='stylesheet' href='/calculator/style.css'/></head><body>");
    winOpen.document.write("<div class='zakaz_formPrint' style='float: right;'>");
    winOpen.document.write("<img style='margin: 6px 10px 0px 0px; cursor:pointer;' src='/images/printer.png' alt='Закрыть' border='0' onclick='window.print();'/>");
    winOpen.document.write("</div>");
    winOpen.document.write("<div id='forPrint'>");
    winOpen.document.write("<div id='zakaz_txt' style='float: left; width: 350px; margin: 0px 16px 10px 0px;'>");
    winOpen.document.write(content);
    winOpen.document.write("</div>");
    winOpen.document.write("</div>");
    winOpen.document.write("<center><a style='font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-weight : bold; font-size: 10px; text-decoration : none; color : #336699;' href='javascript:window.close();'><br>Закрыть окно</a></center>");
    winOpen.document.write("</body></html>");
    winOpen.document.close();

  });}
function new_win_href (name,title,width,height)
{
      w1=window.open('','new_window','resizable=no,menubar=no,status=no,scrollbars=no,width='+width+',height='+height+',top=70,left=100');
      w1.document.open();
      w1.document.write("<html><head><title>"+title+"</title></head><body leftmargin=0 topmargin=0>");
      w1.document.write("<center><textarea rows=4 cols=40 wrap=on>"+name+"</textarea><br><a style='font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-weight : bold; font-size: 10px; text-decoration : none; color : #336699;' href='javascript:window.close()'>Закрыть окно</a>");
      w1.document.write("</body></html>");
      w1.document.close();
    w1.focus();
}

  function imon(a,menunum,hrefnum,col)
  {
    var currentmenu = document.getElementById(menunum);
    currentmenu.src=a;
    var currenthref = document.getElementById(hrefnum);
    currenthref.style.color=col;
  }



var xmlHttp=createXmlHttpRequestObject();

function getXmlHttp(){
  var xmlhttp;
  try
  {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {
    try
    {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (E)
    {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined')
  {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}


function createXmlHttpRequestObject()
{
   var xmlhttp;

  try
  {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {
    try
    {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (E)
    {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined')
  {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;

}




function handleServerResponse()
 {
   if(xmlHttp.readyState==4)
    {
     if(xmlHttp.status==200)
	      {
	       //alert(xmlHttp.responseText);
	       document.getElementById("marka").innerHTML=xmlHttp.responseText;
	      }
	     else
	      {
	       alert("При обращении к серверу возникли проблемы: " + xmlHttp.statusText);
	      }
    }
 }



function handleServerResponse_year()
 {
   if(xmlHttp.readyState==4)
    {
     if(xmlHttp.status==200)
      {
       //alert(xmlHttp.responseText);
       document.getElementById("year").innerHTML=xmlHttp.responseText;
      }
     else
      {
       alert("При обращении к серверу возникли проблемы: " + xmlHttp.statusText);
      }
    }
 }


function process_model_clear()
 {
  if(xmlHttp.readyState==4 || xmlHttp.readyState==0)
   {
     var url="/ajax_func.php?b=4&a="+encodeURIComponent(document.getElementById("marka").value);
     //alert(url);

     xmlHttp.open("GET",url, true);
     xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
     xmlHttp.onreadystatechange=handleServerResponse2;
     xmlHttp.send(null);
   }
  else
   {
    setTimeout('process_model_clear()',100);
   }
 }
function handleServerResponse2()
 {
   if(xmlHttp.readyState==4)
    {
     if(xmlHttp.status==200)
      {
       //alert(xmlHttp.responseText);
       document.getElementById("model").innerHTML=xmlHttp.responseText;
      }
     else
      {
       alert("При обращении к серверу возникли проблемы: " + xmlHttp.statusText);
      }
    }
 }



function year_change(id_year,flagus,dat)
	{

			  if(flagus==1)
	          {
			   for(i=dat;i>(dat-10);i--)
			   	{                   if(i!=id_year) document.getElementById('y_'+i).className='year_ns';
			   	}
			   document.getElementById('y_'+id_year).className='year_vs';
		      }
		      else if(flagus==2)
			  {
               for(i=dat;i>(dat-6);i--)
			   	{
                   if(i!=id_year) document.getElementById('y2_'+i).className='year_nb';
			   	}
			   document.getElementById('y2_'+id_year).className='year_vb';
			  }

             document.getElementById('year_v').value=id_year;
	}


function fransh_change(val_f,id_f)
	{

			   for(i=0;i<7;i++)
			   	{
                   if(i!=id_f) document.getElementById('f_'+i).className='year_nb';
			   	}
			   document.getElementById('f_'+id_f).className='year_vb';

             //alert(id_f);
             document.getElementById('fransh_v').value=val_f;
	}
function fransh2_change(val_f,id_f)
	{

			   for(i=0;i<6;i++)
			   	{
                   if(i!=id_f) document.getElementById('f_'+i).className='year_nb';
			   	}
			   document.getElementById('f_'+id_f).className='year_vb';

             //alert(id_f);
             document.getElementById('fransh_v').value=val_f;
	}
function srok_change(id_s)
	{

			   for(i=1;i<13;i++)
			   	{
                   if(i!=id_s) document.getElementById('s_'+i).className='year_nb';
			   	}
			   document.getElementById('s_'+id_s).className='year_vb';

             //alert(id_s);
             document.getElementById('insuranceTerm_v').value=id_s;
	}
function ds_change(val_ds,id_ds)
	{

			   for(i=1;i<8;i++)
			   	{
                   if(i!=id_ds) document.getElementById('ds_'+i).className='year_ns';
			   	}
			   document.getElementById('ds_'+id_ds).className='year_vs';

             //alert(id_ds);
             document.getElementById('dop_strax_v').value=val_ds;
	}



function pokaz_spravka(id,value)
	{
              //alert(value+'||'+id);

			   if(document.getElementById(value).value=='0')
			   {
                 document.getElementById(id).style.display='inline';
                 document.getElementById(value).value='1';
			   }
			   else if(document.getElementById(value).value=='1')
			   {                 document.getElementById(id).style.display='none';
                 document.getElementById(value).value='0';
			   }
	}


function spets_view(view_n)
	{
              //alert(view_n);

              for(i=1;i<4;i++)
			   	{
                   if(i!=view_n) document.getElementById('spets_'+i).style.display='none';
			   	}

			   document.getElementById('spets_'+view_n).style.display='inline';

               document.getElementById('spets_view').style.display='inline';
			   document.getElementById('spets_v').value=view_n;

	}
function spets_close()
	{


              for(i=1;i<4;i++)
			   	{
                   document.getElementById('spets_'+i).style.display='none';
			   	}
               document.getElementById('spets_view').style.display='none';
			   document.getElementById('spets_v').value='0';

	}

function calc_year(tip_avto,dat)
	{


              for(i=1;i<3;i++)
			   	{
                   document.getElementById('year_table_'+i).style.display='none';
			   	}
               document.getElementById('year_table_'+tip_avto).style.display='inline';
			   document.getElementById('year_v').value=dat;

	}


function getAbsPos(p)
	{
		var s = { x:0, y:0 ,w:0};

		while (p.offsetParent)
		{
			s.x += p.offsetLeft;
			s.y += p.offsetTop;
			s.w += p.Width;
			p = p.offsetParent;
		}

		return s;
	}
function openDoc(){
}
