function addComas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	//var s1 = src.substr(1, 3);	
	x2 = x.length > 1 ? '.' + x[1].substr(0, 2) : '.00';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


function WINHOUSE()
{

/*---------- WINHOUSE --------*/    /*---------- SALAMANDER --------*/
       rama0   = 2.15;       Wr0   = 2.15;        Sr0   = 2.1;
       rama1   = 3.7;        Wr1   = 3.7;         Sr1   = 3.9;
       rama2   = 4;          Wr2   = 4;           Sr2   = 5.4;

       stv0    = 2.5;       Wstv0    = 2.5;       Sstv0    = 2.4;
       stv1    = 4.5;       Wstv1    = 4;         Sstv1    = 4;
       stv2    = 4;         Wstv2    = 4.5;       Sstv2    = 5.5;

       impost0 = 2.5;       Wimpost0 = 2.5;       Simpost0 = 2.63;
       impost1 = 4.2;       Wimpost1 = 4.2;       Simpost1 = 4.6;
       impost2 = 4.5;       Wimpost2 = 4.5;       Simpost2 = 6;

       shtapik = 0.5;       Wshtapik = 0.5;       Sshtapik = 0.47;
       shColor = 1.5;       WshColor = 1.5;       SshColor = 1.5;
       sh32    = 0.51;      Wsh32    = 0.51;      Ssh32    = 0.57;

       St1k = 15.3;
       St2k = 20.5;
       Stdk = 21.5;

       uplRam  = 0.09;      WuplRam  = 0.09;      SuplRam  = 0.112;
       uplStv  = 0.13;      WuplStv  = 0.13;      SuplStv  = 0.112;
       metR    = 0.88;      WmR      = 0.88;      SmR      = 0.64;
       metZ    = 0.8;       WmZ      = 0.8;       SmZ      = 0.8;
       metImp  = 0.88;      WmImp    = 0.88;      SmImp    = 0.72;
       arm30   = 3,5;       WArm30   = 3,5;       Sarm30   = 3.2;
       arm40   = 3.5;       Warm40   = 3.5;       Sarm40   = 3.2;
       alPorog = 7;         WalPorog = 7;         SalPorog = 6;
       sPorog  = 1.2;       WsPorog  = 1.2;       SsPorog  = 1;
       pjat    = 0.35;      Wpjat    = 0.35;      Spjat    = 0.05;
       shult   = 3;         Wshult   = 3;         Sshult   = 3;
       mShult  = 0;         WmShult  = 0;         SmShult  = 0;
       zShult  = 0.4;       WzShult  = 0.4;       SzShult  = 2.1;
       metRam  = 0.88;      WmetRam  = 0.88;      SmetRam  = 0.64;
       metRam2 = 0.88;      WmetRam2 = 0.88;      SmetRam2 = 0.64;
       send    = 16;        Wsend    = 16;        Ssend    = 16;
       kn      = 1.66;
       nr      = 1.12;
       koef    = 0.8;
       skidka  = 1;

       


/*---------- /WINHOUSE --------*/      /*---------- SALAMANDER --------*/


ind = document.forms['form'];

/*--------------     G     ----------------*/
if (ind.f.value=="g")
{
   close();
   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   shtRama         = pRama - 400;
   uRama           = shtRama;
   metal           = Math.abs(pRama) - 116*4;
   steklo          = (Math.abs(ind.H.value)-110)*(Math.abs(ind.W.value)-110)/1000000;

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0      : ((ind.color.value=="1") ? Wr1   : Wr2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor : ((ind.stp.value=="2")   ? Wsh32 : Wshtapik);
           /**/uRamaCost       = WuplStv;
           /**/mCost           = WmetRam;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0      : ((ind.color.value=="1") ? Sr1   : Sr2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor : ((ind.stp.value=="2")   ? Ssh32 : Sshtapik);
           /**/uRamaCost       = SuplStv;
           /**/mCost           = SmetRam;

        }

   stCost          = (ind.stp.value=="0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);
   RAll            = (pRamaCost * pRama/1000)*1.04;
   shtAll          = (shtRamaCost * shtRama/1000)*1.08;
   uplAll          = (uRama * uRamaCost/1000)*1.05;

   mAll            = mCost*metal/1000*1.04;
   stAll           = ( steklo>0.4) ? (steklo*stCost) :  (steklo*0.4);
    summatoria = RAll + shtAll + uplAll + mAll;
   house = (ind.profile.value=="s") ?  ((summatoria + 0.5)/koef + stAll)*kn*nr*skidka :
                                       ((summatoria + 0.5)      + stAll)*kn*nr*skidka

ind.elements['cost'].value= addComas(house);

 }
/*--------------     O     ----------------*/

if (ind.f.value == "po")
{
   close();
   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = pRama-336;
   shtRama         = pRama - 816;
   uStp            = shtRama;
   uRama           = stvr*2-200;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr) - 544;
   steklo          = (Math.abs(ind.H.value)-214)*(Math.abs(ind.W.value)-214)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1     : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1   : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32   : Wshtapik);
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = WmetRam;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1     : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1   : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32   : Sshtapik);
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = SmetRam;
        }

   Fnit =   getFurn ((Math.abs(ind.H.value)-124),(Math.abs(ind.W.value)-124))

   stCost          = (ind.stp.value=="0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000)*1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   uplRAll         = (uRama       * uRamaCost     /1000)*1.05;
   uplSAll         = (uStp        * uStvCost      /1000)*1.05;

   mRAll           = (metalR      * mRCost    /1000)*1.04;
   mSAll           = (metalS      * mSCost    /1000)*1.04;
   stAll           = ( steklo>0.4) ? (steklo*stCost) :  (steklo*0.4);

   summatoria = RAll + stvrAll + shtAll + uplRAll + uplSAll + mRAll + mSAll;
   house = (ind.profile.value=="s") ? (( summatoria + 0.7)/koef + stAll + (Fnit + 0.6)/koef)*kn*nr*skidka :
                                      ((summatoria + 1)         + stAll + (Fnit + 0.6)/koef)*kn*nr*skidka;

 ind.elements['cost'].value= addComas(house);

 }

 /*--------------     og     ----------------*/

if (ind.f.value == "g_o")
{
  close();
  document.getElementById("wop").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = (Math.abs(ind.opener.value)-55+6)*2+(Math.abs(ind.H.value)-84+6)*2;
   shtRama         = Math.abs(ind.W.value)*2-(102+94+50)*2+Math.abs(ind.H.value)*4-102*4-50*4;
   pImpost         = Math.abs(ind.H.value)-90;
   mI              = pImpost-5;
   pjatI           = 2;
   uStp            = shtRama;
   uRama           = stvr*2-200;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr) - 544;
   steklo1         = (Math.abs(ind.opener.value)-185)*(Math.abs(ind.H.value)-214)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.W.value)-Math.abs(ind.opener.value)-81)*(Math.abs(ind.H.value)-110)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {

           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value  == "2") ? Wimpost2   : Wimpost1);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = WmetRam;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value   == "2") ? Simpost2   : Simpost1);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = SmetRam;
        }

   Fnit =   getFurn ((Math.abs(ind.H.value)-124),(Math.abs(ind.opener.value)-95))

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000)*1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         = (pImpost     * impostCost    /1000)*1.05;
   metImpAll       = (mI          * metICost      /1000)*1.04;
   pjatAll         = (pjatI       * pjatCost           );
   uplRAll         = (uRama       * uRamaCost     /1000)*1.05;
   uplSAll         = (uStp        * uStvCost      /1000)*1.05;
   mRAll           = (metalR      * mRCost        /1000)*1.04;
   mSAll           = (metalS      * mSCost        /1000)*1.04;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) :  (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) :  (stCost*0.4);

   summatoria = (RAll + stvrAll + shtAll+  impRAll + metImpAll +  pjatAll + uplRAll + uplSAll + mRAll + mSAll);
   house = (ind.profile.value == "s") ? ((summatoria + 0.5)/koef + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka :
                                         (summatoria + 0.8       + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka ;


 ind.elements['cost'].value= addComas(house);

 }
// else      document.getElementById("wop").style.display = 'none';

/*--------------     oo     ----------------*/

if (ind.f.value == "o_o")
{
  close();
  document.getElementById("wop").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = (Math.abs(ind.W.value)-42*2-26+6*2)*2+(Math.abs(ind.H.value)-84+6)*4;
   shtRama         = Math.abs(ind.H.value)*4-102*8+Math.abs(ind.W.value)*2-102*2-146*2;
   pImpost         = Math.abs(ind.H.value)-100;
   mI              = pImpost-5;
   pjatI           = 2;
   uStp            = shtRama;
   uRama           = stvr*2-200*2;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr) - 544*2;
   steklo1         = (Math.abs(ind.opener.value)-185)*(Math.abs(ind.H.value)-214)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.W.value)-Math.abs(ind.opener.value)-185)*(Math.abs(ind.H.value)-214)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value   == "2") ? Wimpost2   : Wimpost1);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = WmetRam;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value   == "2") ? Simpost2   : Simpost1);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = SmetRam;
        }

   Fnit =   getFurn ((Math.abs(ind.H.value)-124),(Math.abs(ind.opener.value)-95))*2;

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000)*1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         = (pImpost     * impostCost    /1000)*1.05;
   metImpAll       = (mI          * metICost      /1000)*1.04;
   pjatAll         = (pjatI       * pjatCost           );
   uplRAll         = (uRama       * uRamaCost     /1000)*1.05;
   uplSAll         = (uStp        * uStvCost      /1000)*1.05;
   mRAll           = (metalR      * mRCost        /1000)*1.04;
   mSAll           = (metalS      * mSCost        /1000)*1.04;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) :  (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) :  (stCost*0.4);

   summatoria = (RAll + stvrAll + shtAll+  impRAll + metImpAll +  pjatAll + uplRAll + uplSAll + mRAll + mSAll);
   house = (ind.profile.value == "s") ? ((summatoria + 0.5)/koef + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka :
                                         (summatoria + 0.8       + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka ;


 ind.elements['cost'].value= addComas(house);

 }
// else  document.getElementById("wop").style.display = 'none';



/*--------------     g_o_g     ----------------*/

if (ind.f.value == "g_o_g")
{
  close();
  document.getElementById("wop").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = (Math.abs(ind.opener.value)-26+6)*2+(Math.abs(ind.H.value)-84+6)*2;
   shtRama         = (Math.abs(ind.W.value)-93*2-50*2)*2+(Math.abs(ind.H.value)-50*2)*4+(Math.abs(ind.H.value)-102*2)*2;
   pImpost         = (Math.abs(ind.H.value)-100)*2;
   mI              = pImpost - 5*2;
   pjatI           = 4;
   uStp            = shtRama - 470;
   uRama           = stvr - 100*3;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr) - 544;
   steklo1         = (Math.abs(ind.opener.value)                      -156)*(Math.abs(ind.H.value)-214)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.W.value)-Math.abs(ind.opener.value)-162)*(Math.abs(ind.H.value)-110)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value  == "2") ? Wimpost2   : Wimpost1);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = ((Math.abs(ind.opener.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? WmetRam  :
                                                                                                           WmetRam2 ;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value  == "2") ? Simpost2   : Simpost1);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = ((Math.abs(ind.opener.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? SmetRam  :
                                                                                                           SmetRam2 ;
        }

   Fnit =   getFurn ((Math.abs(ind.H.value)-124),(Math.abs(ind.opener.value)-95));

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000)*1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         = (pImpost     * impostCost    /1000)*1.05;
   metImpAll       = (mI          * metICost      /1000); metImpAll = (ind.profile.value == "w") ? metImpAll*1.05 : metImpAll*1.04;
   pjatAll         = (pjatI       * pjatCost           );
   uplRAll         = (uRama       * uRamaCost     /1000)*1.05;
   uplSAll         = (uStp        * uStvCost      /1000)*1.05;
   mRAll           = (metalR      * mRCost        /1000);    mRAll  = (ind.profile.value == "w") ? mRAll*1.06 : mRAll*1.04;
   mSAll           = (metalS      * mSCost        /1000);    mSAll  = (ind.profile.value == "w") ? mSAll*1.06 : mSAll*1.04;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) :  (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) :  (stCost*0.4);

   summatoria = (RAll + stvrAll + shtAll+  impRAll + metImpAll +  pjatAll + uplRAll + uplSAll + mRAll + mSAll);



   house = (ind.profile.value == "s") ? ((summatoria + 1)/koef + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka :
                                         (summatoria + 1       + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka ;


 ind.elements['cost'].value= addComas(house);

 }
// else  document.getElementById("wop").style.display = 'none';

/*--------------     g_g     ----------------*/

if (ind.f.value == "g_g")
{
  close();
  document.getElementById("wop").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   shtRama         = (Math.abs(ind.H.value)*4-400)+Math.abs(ind.W.value)*2-(50*2+40)*2;
   pImpost         = Math.abs(ind.H.value)-100;
   mI              = pImpost - 5*2;
   pjatI           = 2;
   uStp            = shtRama;
   metalR          = Math.abs(pRama) - 464;
   steklo1         = (Math.abs(ind.opener.value)                      -81)*(Math.abs(ind.H.value)-110)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.W.value)-Math.abs(ind.opener.value)-81)*(Math.abs(ind.H.value)-110)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value   == "2") ? Wimpost2   : Wimpost1);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/mRCost          = WmetRam;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value  == "2") ? Simpost2   : Simpost1);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/mRCost          = SmetRam;
        }

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         = (pImpost     * impostCost    /1000)*1.05;
   metImpAll       = (mI          * metICost      /1000)*1.04;
   pjatAll         = (pjatI       * pjatCost           );
   uplSAll         = (uStp        * uStvCost      /1000)*1.05;
   mRAll           = (metalR      * mRCost        /1000); mRAll  = (ind.profile.value == "w") ? mRAll*1.04 : mRAll*1.05;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) : (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) : (stCost*0.4);

   summatoria = (RAll + shtAll+  impRAll + metImpAll +  pjatAll + uplSAll + mRAll);

   house = (ind.profile.value == "s") ? ((summatoria + 0.5)/koef + st2All + st1All )*kn*nr*skidka :
                                         (summatoria + 0.5       + st2All + st1All )*kn*nr*skidka ;


 ind.elements['cost'].value= addComas(house);
 }
// else  document.getElementById("wop").style.display = 'none';

/*--------------     g_g_g     ----------------*/

if (ind.f.value == "g_g_g")
{
  close();
  document.getElementById("wop").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   shtRama         = (Math.abs(ind.W.value)-40*2-50*2)*2+(Math.abs(ind.H.value)-50*2)*6;
   pImpost         = (Math.abs(ind.H.value)-100)*2;
   mI              = pImpost - 5*2;
   pjatI           = 4;
   uStp            = shtRama-470;
   metalR          = Math.abs(pRama) - 464;
   steklo1         = (Math.abs(ind.opener.value)                      - 52)*(Math.abs(ind.H.value)-110)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.W.value)-Math.abs(ind.opener.value)-162)*(Math.abs(ind.H.value)-110)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value    == "1") ? Wimpost1   : Wimpost2);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/mRCost          = WmetRam;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value    == "1") ? Simpost1   : Simpost2);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/mRCost          = SmetRam;
        }

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         = (pImpost     * impostCost    /1000)*1.05;
   metImpAll       = (mI          * metICost      /1000)*1.04;
   pjatAll         = (pjatI       * pjatCost           )
   uplSAll         = (uStp        * uStvCost      /1000); uplSAll  = (ind.profile.value == "w") ? uplSAll*1.05 : uplSAll*1.04;
   mRAll           = (metalR      * mRCost        /1000)*1.04;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) : (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) : (stCost*0.4);

   summatoria = (RAll + shtAll+  impRAll + metImpAll +  pjatAll + uplSAll + mRAll);
  //ind.cost.value = (RAll+'|' + shtAll+'|'+  impRAll+'|' + metImpAll+'|' +  pjatAll+'|' + uplSAll+'|' + mRAll);

   house = (ind.profile.value == "s") ? ((summatoria + 0.7)/koef + st2All + st1All )*kn*nr*skidka :
                                         (summatoria + 0.7       + st2All + st1All )*kn*nr*skidka ;

 ind.cost.value= pImpost ;
 ind.elements['cost'].value= addComas(house);
 }
// else  document.getElementById("wop").style.display = 'none';

/*--------------     o_g_o     ----------------*/

if (ind.f.value == "o_g_o")
{
  close();
  document.getElementById("wop").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = (Math.abs(ind.W.value)-Math.abs(ind.opener.value)-49*2)*2+(Math.abs(ind.H.value)-84+6)*4;
   shtRama         = (Math.abs(ind.W.value)-93*2-103*2)*2+(Math.abs(ind.H.value)-50*2)*2+(Math.abs(ind.H.value)-102*2)*4;
   pImpost         = (Math.abs(ind.H.value)-100)*2;
   mI              = pImpost - 5*2;
   pjatI           = 4;
   uStp            = shtRama - 470;
   uRama           = stvr*2 - 100*4;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr) - 544*2;
   steklo1         = (Math.abs(ind.opener.value)                       -52)*(Math.abs(ind.H.value)-110)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.W.value)-Math.abs(ind.opener.value)-370)*(Math.abs(ind.H.value)-214)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value == "2") ? Wimpost2   : Wimpost1);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = ((Math.abs(ind.opener.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? WmetRam  :
                                                                                                           WmetRam2 ;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value == "2") ? Simpost2   : Simpost1);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = ((Math.abs(ind.opener.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? SmetRam  :
                                                                                                           SmetRam2 ;
        }

   Fnit =   getFurn ((Math.abs(ind.H.value)-124),(Math.abs(ind.opener.value)-95))*2;

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000);   RAll      = (ind.profile.value == "w") ? RAll     *1.07  : RAll     *1.04;
   stvrAll         = (stvr        * pStvrCost     /1000);   stvrAll   = (ind.profile.value == "w") ? stvrAll  *1.07  : stvrAll  *1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         = (pImpost     * impostCost    /1000);   impRAll   = (ind.profile.value == "w") ? impRAll  *1.07  : impRAll  *1.05;
   metImpAll       = (mI          * metICost      /1000);   metImpAll = (ind.profile.value == "w") ? metImpAll*1.07  : metImpAll*1.04;
   pjatAll         = (pjatI       * pjatCost           );
   uplRAll         = (uRama       * uRamaCost     /1000);   uplRAll   = (ind.profile.value == "w") ? uplRAll  *1.04  : uplRAll  *1.05;
   uplSAll         = (uStp        * uStvCost      /1000);   uplSAll   = (ind.profile.value == "w") ? uplSAll  *1.04  : uplSAll  *1.05;
   mRAll           = (metalR      * mRCost        /1000);   mRAll     = (ind.profile.value == "w") ? mRAll    *1.06  : mRAll    *1.04;
   mSAll           = (metalS      * mSCost        /1000);   mSAll     = (ind.profile.value == "w") ? mSAll    *1.06  : mSAll    *1.04;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) :  (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) :  (stCost*0.4);

   summatoria = (RAll + stvrAll + shtAll+  impRAll + metImpAll +  pjatAll + uplRAll + uplSAll + mRAll + mSAll);

//  ind.cost.value = RAll + ' | ' + stvrAll+ ' | ' + shtAll+ ' | '+  impRAll+ ' | ' + metImpAll+ ' | ' +  pjatAll
//  + ' | ' + uplRAll+ ' | ' + uplSAll+ ' | ' + mRAll+ ' | ' + mSAll;
//  ind.cost.value =    uplRAll + ' | '+ uRama + ' | '+ uRamaCost;

   house = (ind.profile.value == "s") ? ((summatoria + 1)/koef + st2All + st1All + (Fnit + 1.2)/koef)*kn*nr*skidka :
                                         (summatoria + 1       + st2All + st1All + (Fnit + 1.2)/koef)*kn*nr*skidka ;


 ind.elements['cost'].value= addComas(house);
 }
// else  document.getElementById("wop").style.display = 'none';


/*--------------    g_o_o_g     ----------------*/

if (ind.f.value == "g_o_o_g")
{
  close();
  document.getElementById("wop2").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = (Math.abs(ind.opener2.value)+6)*2+(Math.abs(ind.H.value)-84+6)*4;
   shtRama         = (Math.abs(ind.W.value)-93*2-50*2-144)*2+(Math.abs(ind.H.value)-50*2)*4+(Math.abs(ind.H.value)-102*2)*4;
   pImpost         = (Math.abs(ind.H.value)-86)*3;
   mI              = pImpost - 5*3;
   pjatI           = 6;
   uStp            = shtRama - 470/3*4;
   uRama           = stvr*2 - 100*6;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr) - 544*2;
   steklo1         = (Math.abs(ind.opener2.value)                     -156*2)*(Math.abs(ind.H.value)-214)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.W.value)-Math.abs(ind.opener2.value)-162  )*(Math.abs(ind.H.value)-110)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value == "2") ? Wimpost2   : Wimpost1);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = ((Math.abs(ind.opener2.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? WmetRam  :
                                                                                                            WmetRam2 ;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value == "2") ? Simpost2   : Simpost1);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = ((Math.abs(ind.opener2.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? SmetRam  :
                                                                                                            SmetRam2 ;
        }

   Fnit =   getFurn ((Math.abs(ind.H.value)-124),(Math.abs(ind.opener2.value)/2-66))*2;

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000)*1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         = (pImpost     * impostCost    /1000);   impRAll   = (ind.profile.value == "w") ? impRAll  *1.05  : impRAll  *1.04;
   metImpAll       = (mI          * metICost      /1000)*1.04;
   pjatAll         = (pjatI       * pjatCost           );
   uplRAll         = (uRama       * uRamaCost     /1000)*1.05;
   uplSAll         = (uStp        * uStvCost      /1000)*1.05;
   mRAll           = (metalR      * mRCost        /1000)*1.04;
   mSAll           = (metalS      * mSCost        /1000)*1.04;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) :  (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) :  (stCost*0.4);

   summatoria = (RAll + stvrAll + shtAll+  impRAll + metImpAll +  pjatAll + uplRAll + uplSAll + mRAll + mSAll);

   house = (ind.profile.value == "s") ? ((summatoria + 1.3)/koef + st2All + st1All + (Fnit + 1.2)/koef)*kn*nr*skidka :
                                         (summatoria + 1.3       + st2All + st1All + (Fnit + 1.2)/koef)*kn*nr*skidka ;


 ind.elements['cost'].value= addComas(house);
 }
// else  document.getElementById("wop2").style.display = 'none';

/*--------------    o_f     ----------------*/

if (ind.f.value == "o_f")
{
  close();
  document.getElementById("framuga").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = (Math.abs(ind.H.value)-Math.abs(ind.fram.value)-55+6)*2+(Math.abs(ind.W.value)-84+6)*2;
   shtRama         = (Math.abs(ind.W.value)*4-200-408)+(Math.abs(ind.H.value)*2-(102+94+50)*2);
   pImpost         = (Math.abs(ind.W.value)-100);
   mI              = Math.abs(ind.W.value)- 5;
   pjatI           = 2;
   uStp            = shtRama;
   uRama           = stvr*2 - 100*2;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr) - 544;
   steklo1         = (Math.abs(ind.H.value) - Math.abs(ind.fram.value)-78 -107)*(Math.abs(ind.W.value)       -214)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.W.value)                               -110)*(Math.abs(ind.fram.value)-55 -26)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value == "2") ? Wimpost2   : Wimpost1);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? WmetRam  :
                                                                                                      WmetRam2 ;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value == "2") ? Simpost2   : Simpost1);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? SmetRam  :
                                                                                                      SmetRam2 ;
        }

   Fnit =   getFurn ((Math.abs(ind.H.value)-Math.abs(ind.fram.value)-95),(Math.abs(ind.W.value)-124));

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000)*1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         = (pImpost     * impostCost    /1000)*1.05;
   metImpAll       = (mI          * metICost      /1000)*1.04;
   pjatAll         = (pjatI       * pjatCost           );
   uplRAll         = (uRama       * uRamaCost     /1000); uplRAll = (ind.profile.value == "w") ? uplRAll  *1.04  : uplRAll  *1.05;
   uplSAll         = (uStp        * uStvCost      /1000); uplSAll = (ind.profile.value == "w") ? uplSAll  *1.04  : uplSAll  *1.05;
   mRAll           = (metalR      * mRCost        /1000)*1.04;
   mSAll           = (metalS      * mSCost        /1000)*1.04;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) :  (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) :  (stCost*0.4);

   summatoria = (RAll + stvrAll + shtAll+  impRAll + metImpAll +  pjatAll + uplRAll + uplSAll + mRAll + mSAll);

// ind.elements['cost'].value = RAll + ' | ' + stvrAll+ ' | ' + shtAll+ ' | '+  impRAll+ ' | ' + metImpAll+ ' | ' +  pjatAll
//  + ' | ' + uplRAll+ ' | ' + uplSAll+ ' | ' + mRAll+ ' | ' + mSAll;


   house = (ind.profile.value == "s") ? ((summatoria + 0.8)/koef + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka :
                                         (summatoria + 0.8       + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka ;


 ind.elements['cost'].value= addComas(house);
 }
// else  document.getElementById("framuga").style.display = 'none';


/*--------------    g_o_f     ----------------*/

if (ind.f.value == "g_o_f")
{ close();
  document.getElementById("wop").style.display = '';
  document.getElementById("framuga").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = (Math.abs(ind.opener.value)-55+6)*2+(Math.abs(ind.H.value)-Math.abs(ind.fram.value)-55+6)*2;
   shtRama         = (Math.abs(ind.H.value)*2-102-94-50*3-40) + (Math.abs(ind.H.value)-Math.abs(ind.fram.value))*2-102-74-50-20+ Math.abs(ind.W.value)*4-50*4-102-94-40-102-94-50;
   pImpost         = (Math.abs(ind.W.value)-100)+(Math.abs(ind.H.value)-Math.abs(ind.fram.value)-50);
   mI              = pImpost - 5*2;
   pjatI           = 4;
   uStp            = shtRama - 100*2;
   uRama           = stvr*2 - 100*2;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr) - 544;
   stofr           = (Math.abs(ind.W.value) - 110)                          *(Math.abs(ind.fram.value)                                                  -81)/Math.pow(10,6);
   steklo1         = (Math.abs(ind.W.value) - Math.abs(ind.opener.value)-81)*(Math.abs(ind.H.value) - Math.abs(ind.fram.value)  -81)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.opener.value) - 185)                      *(Math.abs(ind.H.value) - Math.abs(ind.fram.value) -185)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value == "2") ? Wimpost2   : Wimpost1);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? WmetRam  :
                                                                                                      WmetRam2 ;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value == "2") ? Simpost2   : Simpost1);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? SmetRam  :
                                                                                                      SmetRam2 ;
        }

   Fnit =   getFurn ((Math.abs(ind.H.value)-Math.abs(ind.fram.value)-95),(Math.abs(ind.opener.value)-95));

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000)*1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000); shtAll = (ind.profile.value == "w") ? shtAll  *1.08  : shtAll  *1.07;
   impRAll         = (pImpost     * impostCost    /1000)*1.05;
   metImpAll       = (mI          * metICost      /1000)*1.04;
   pjatAll         = (pjatI       * pjatCost           );
   uplRAll         = (uRama       * uRamaCost     /1000)*1.04;
   uplSAll         = (uStp        * uStvCost      /1000)*1.04;
   mRAll           = (metalR      * mRCost        /1000)*1.04;
   mSAll           = (metalS      * mSCost        /1000); mSAll = (ind.profile.value == "w") ? mSAll   *1.06  : mSAll   *1.04;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) :  (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) :  (stCost*0.4);
   stofr           = (stofr   > 0.4) ? (stofr  *stCost) :  (stCost*0.4);

   summatoria = (RAll + stvrAll + shtAll+  impRAll + metImpAll +  pjatAll + uplRAll + uplSAll + mRAll + mSAll);

//  ind.cost.value = RAll + ' | ' + stvrAll+ ' | ' + shtAll+ ' | '+  impRAll+ ' | ' + metImpAll+ ' | ' +  pjatAll
//  + ' | ' + uplRAll+ ' | ' + uplSAll+ ' | ' + mRAll+ ' | ' + mSAll+ ' | ' + stofr+' | ' +st1All+ ' | ' +st2All+ ' | ' + Fnit ;

//  ind.cost.value = Fnit

   house = (ind.profile.value == "s") ? ((summatoria + 1.1)/koef + stofr + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka :
                                         (summatoria + 1.3       + stofr + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka ;


 ind.elements['cost'].value= addComas(house);
 }
// else { document.getElementById("framuga").style.display = 'none';
//        document.getElementById("wop").style.display = 'none';
//      }


/*--------------    o_o_f     ----------------*/

if (ind.f.value == "o_o_f")
{ close();
  document.getElementById("wop").style.display = '';
  document.getElementById("framuga").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = (Math.abs(ind.opener.value)-55+6)*4+(Math.abs(ind.H.value)-Math.abs(ind.fram.value)-55+6)*4;
   shtRama         = (Math.abs(ind.H.value)*2-(102+94+50)*2) + (Math.abs(ind.H.value)-Math.abs(ind.fram.value))*2-(102+74)*2+ Math.abs(ind.W.value)*4-50*2-(102+144+102)*2;
   pImpost         = (Math.abs(ind.W.value)-100)+(Math.abs(ind.H.value)-Math.abs(ind.fram.value)-50-20);
   mI              = pImpost - 5;
   pjatI           = 4;
   uStp            = shtRama - 100*3;
   uRama           = stvr*2 - 100*6;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr) - 544*2;
   stofr           = (Math.abs(ind.W.value) - 110)                           *(Math.abs(ind.fram.value)                                                  -81)/Math.pow(10,6);
   steklo1         = (Math.abs(ind.W.value) - Math.abs(ind.opener.value)-185)*(Math.abs(ind.H.value) - Math.abs(ind.fram.value) -185)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.opener.value) - 185)                      *(Math.abs(ind.H.value) - Math.abs(ind.fram.value) -185)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value == "2") ? Wimpost2   : Wimpost1);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? WmetRam  :
                                                                                                      WmetRam2 ;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value == "2") ? Simpost2   : Simpost1);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? SmetRam  :
                                                                                                      SmetRam2 ;
        }

   Fnit =   getFurn ((Math.abs(ind.H.value)-Math.abs(ind.fram.value)-95),(Math.abs(ind.opener.value)-95))*2;

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000)*1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         = (pImpost     * impostCost    /1000)*1.05;
   metImpAll       = (mI          * metICost      /1000)*1.04;
   pjatAll         = (pjatI       * pjatCost           );
   uplRAll         = (uRama       * uRamaCost     /1000)*1.04;
   uplSAll         = (uStp        * uStvCost      /1000)*1.04;
   mRAll           = (metalR      * mRCost        /1000)*1.04;
   mSAll           = (metalS      * mSCost        /1000)*1.04;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) :  (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) :  (stCost*0.4);
   stofr           = (stofr   > 0.4) ? (stofr  *stCost) :  (stCost*0.4);

   summatoria = (RAll + stvrAll + shtAll+  impRAll + metImpAll +  pjatAll + uplRAll + uplSAll + mRAll + mSAll);

//  ind.cost.value = RAll + ' | ' + stvrAll+ ' | ' + shtAll+ ' | '+  impRAll+ ' | ' + metImpAll+ ' | ' +  pjatAll
//  + ' | ' + uplRAll+ ' | ' + uplSAll+ ' | ' + mRAll+ ' | ' + mSAll+ ' | ' + stofr+' | ' +st1All+ ' | ' +st2All+ ' | ' + Fnit ;

//  ind.cost.value = Fnit

   house = (ind.profile.value == "s") ? ((summatoria + 1.1)/koef + stofr + st2All + st1All + (Fnit + 2*0.6)/koef)*kn*nr*skidka :
                                         (summatoria + 1.3       + stofr + st2All + st1All + (Fnit + 2*0.6)/koef)*kn*nr*skidka ;


 ind.elements['cost'].value= addComas(house);
 }


/*--------------    g_o_g_f     ----------------*/

if (ind.f.value == "g_o_g_f")
{ close();
  document.getElementById("wop").style.display = '';
  document.getElementById("framuga").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = (Math.abs(ind.opener.value)-26+6)*2+(Math.abs(ind.H.value)-Math.abs(ind.fram.value)-42-13+6)*2;
   shtRama         = (Math.abs(ind.W.value)*4-50*4-(50+94*2+50)*2) + (Math.abs(ind.H.value)*2-(50*2+40)*2) + (Math.abs(ind.H.value) - Math.abs(ind.fram.value))*4-(50+20)*2-(102+94-20)*2;
   pImpost         = (Math.abs(ind.W.value)-100)+(Math.abs(ind.H.value)-Math.abs(ind.fram.value)-50-20)*2;
   mI              = pImpost - 5*4;
   pjatI           = 6;
   uStp            = shtRama - 470;
   uRama           = stvr*2 - 100*3;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr)  - 544;
   steklo1         = (Math.abs(ind.W.value) - Math.abs(ind.opener.value)-162)*(Math.abs(ind.H.value) - Math.abs(ind.fram.value) - 81)/Math.pow(10,6);
   steklo2         = (Math.abs(ind.W.value)                             -110)*(Math.abs(ind.fram.value)                         - 81)/Math.pow(10,6);
   stofr           = (Math.abs(ind.opener.value) - 156)                      *(Math.abs(ind.H.value) - Math.abs(ind.fram.value) -185)/Math.pow(10,6);

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Wimpost0   : ((ind.color.value == "2") ? Wimpost2   : Wimpost1);
           /**/metICost        = WmImp;
           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? WmetRam  :
                                                                                                      WmetRam2 ;
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);
           /**/impostCost      = (ind.color.value == "0") ? Simpost0   : ((ind.color.value == "2") ? Simpost2   : Simpost1);
           /**/metICost        = SmImp;
           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? SmetRam  :
                                                                                                      SmetRam2 ;
        }

   Fnit =   getFurn ((Math.abs(ind.H.value)-Math.abs(ind.fram.value)-95),(Math.abs(ind.opener.value)-66));

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000)*1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         = (pImpost     * impostCost    /1000)*1.05;
   metImpAll       = (mI          * metICost      /1000)*1.04;
   pjatAll         = (pjatI       * pjatCost           );
   uplRAll         = (uRama       * uRamaCost     /1000)*1.04;
   uplSAll         = (uStp        * uStvCost      /1000)*1.04;
   mRAll           = (metalR      * mRCost        /1000)*1.04;
   mSAll           = (metalS      * mSCost        /1000)*1.04;
   st1All          = (steklo1 > 0.4) ? (steklo1*stCost) :  (stCost*0.4);
   st2All          = (steklo2 > 0.4) ? (steklo2*stCost) :  (stCost*0.4);
   stofr           = (stofr   > 0.4) ? (stofr  *stCost) :  (stCost*0.4);

   summatoria = (RAll + stvrAll + shtAll+  impRAll + metImpAll +  pjatAll + uplRAll + uplSAll + mRAll + mSAll);

//  ind.cost.value = RAll + ' | ' + stvrAll+ ' | ' + shtAll+ ' | '+  impRAll+ ' | ' + metImpAll+ ' | ' +  pjatAll
//  + ' | ' + uplRAll+ ' | ' + uplSAll+ ' | ' + mRAll+ ' | ' + mSAll+ ' | ' + stofr+' | ' +st1All+ ' | ' +st2All+ ' | ' + Fnit ;

//  ind.cost.value = Fnit

   house = (ind.profile.value == "s") ? ((summatoria + 1)/koef + stofr + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka :
                                         (summatoria + 1       + stofr + st2All + st1All + (Fnit + 0.6)/koef)*kn*nr*skidka ;


 ind.elements['cost'].value= addComas(house);
 }

/*--------------   b     ----------------*/

if (ind.f.value == "b")
{ close();
  document.getElementById("upImpost").style.display = '';
  document.getElementById("sV").style.display = '';

   pRama           = (Math.abs(ind.H.value) + 6 + Math.abs(ind.W.value) + 6) * 2;
   stvr            = pRama - 336;
   shtRama         = pRama - 816;
   pImpost         = Math.abs(ind.W.value)-200;
   mI              = pImpost - 5*4;
   pjatI           = 2;
   uStp            = shtRama;
   uRama           = stvr*2 - 100*2;
   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr)  - 544;

    A2 = Math.abs(ind.W.value);
    B2 = Math.abs(ind.H.value);
    E2 = Math.abs(ind.ImUp.value);
    F2 = ind.SendUp.value;

  stpak  = ((E2 == 0) ? (A2-214)*(B2-214)/Math.pow(10,6) :
                      (  (F2=="sT") ? (
                                             (A2-214)*(B2-E2-133)/Math.pow(10,6)<0.4  ? 0.4 :
                                                                                       (A2-214)*(B2-E2-133)/Math.pow(10,6) + ( (A2-214)*(E2-133)/Math.pow(10,6) < 0.4 ? 0.4 :(A2-214)*(E2-133)/Math.pow(10,6) )
                                       ) : (
                                              (A2-214)*(B2-E2-133)/Math.pow(10,6)< 0.4 ? 0.4 :
                                                                                        (A2-214)*(B2-E2-133)/Math.pow(10,6)
                                           )
                       )
         );

 sndV = (((F2=="sN") && (E2!=0)) ? ((E2-133)*(A2-214)/Math.pow(10,6)* send)  : 0)

//   ind.cost.value =   stpak ;
     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);

           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? WmetRam  :     WmetRam2 ;
           /**/impostCost      = (shtRamaCost + uStvCost)*2 + WmImp + ((ind.color.value == "0") ? Wimpost0   : ((ind.color.value == "2") ? Wimpost2   : Wimpost1));
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);

           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? SmetRam  :     SmetRam2 ;
           /**/impostCost      = (shtRamaCost + uStvCost)*2 + SmImp + ((ind.color.value == "0") ? Simpost0   : ((ind.color.value == "2") ? Simpost2   : Simpost1));
        }


   Fnit =   getFurn ((Math.abs(ind.H.value)-124),(Math.abs(ind.W.value)-124));

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000)*1.05;
   shtAll          = (shtRama     * shtRamaCost   /1000)*1.08;
   impRAll         =  (ind.profile.value=="s") ? ((E2!=0) ? (pImpost     * impostCost    /1000)*1.07 : 0) :
                                                 ((pImpost     * impostCost    /1000)*1.04);
   pjatAll         = (E2!=0) ? (pjatI * pjatCost) : 0;
   uplRAll         = (uRama       * uRamaCost     /1000)*1.04;
   uplSAll         = (uStp        * uStvCost      /1000)*1.04;
   mRAll           = (metalR      * mRCost        /1000)*1.04;
   mSAll           = (metalS      * mSCost        /1000)*1.04;
   sendAll         = sndV * 1.25;
   stAll           = (stpak  > 0.4) ? ( stpak  * stCost) :  (stCost*0.4);



  summatoria = (RAll + stvrAll + shtAll + uplSAll + uplRAll + mRAll + mSAll);
/*
  ind.cost.value = RAll     + ' | ' +
                   stvrAll  + ' | ' +
                   shtAll   + ' | ' +
                   uplSAll  + ' | ' +
                   uplRAll  + ' | ' +
                   mRAll    + ' | ' +
                   mSAll    + ' | ' +
                   stAll    + ' | ' +
                   Fnit     + ' | ' +
                   impRAll  + ' | ' +
                   pjatAll  + ' | ' +
                   sendAll  ;
*/
//  ind.cost.value = Fnit

   house = (ind.profile.value == "s") ?  ((summatoria + impRAll + pjatAll+ 1)/koef+ stAll + sendAll + (Fnit + 0.6)/koef)*kn*nr*skidka :
                                         ( summatoria + impRAll + pjatAll+ 1      + stAll + sendAll + (Fnit + 0.6)/koef)*kn*nr*skidka;

 ind.elements['cost'].value= addComas(house);
 }

/*--------------   b_s     ----------------*/

if (ind.f.value == "b_s")
{ close();
  document.getElementById("upImpost").style.display = '';
  document.getElementById("sV").style.display       = '';
  document.getElementById("wop").style.display      = '';

    A2 = Math.abs(ind.W.value);
    B2 = Math.abs(ind.H.value);
    E2 = Math.abs(ind.ImUp.value);
    F2 = ind.SendUp.value;
    G2 = Math.abs(ind.opener.value);

   pRama           = (B2 + 6 + A2 + 6) * 2;
   stvr            = B2*4-42*8+6*4+A2*2-42*4-7*2+6*4;
   shtRama         = A2*2-(102+127+102)*2+B2*4-(102+102)*4;
   pImpost         = Math.abs(ind.W.value)-310;
   pjatI           = 4;
   stShtulp        = B2-166;
   uStp            = shtRama;
   uRama           = stvr*2 - 100*4;

   metalR          = Math.abs(pRama) - 464;
   metalS          = Math.abs(stvr)  - 544*2;

  stpak  = ((E2 == 0) ? (A2-351)*(B2-351)/Math.pow(10,6) :
                      (  (F2=="sT") ? (
                                             (A2-351)*(B2-E2-133)/Math.pow(10,6)<0.4  ? 0.4 :
                                                                                       (A2-351)*(B2-E2-133)/Math.pow(10,6) + ( (A2-351)*(E2-133)/Math.pow(10,6) < 0.4 ? 0.4 :(A2-351)*(E2-133)/Math.pow(10,6) )
                                       ) : (
                                              (A2-351)*(B2-E2-133)/Math.pow(10,6)< 0.4 ? 0.4 :
                                                                                        (A2-351)*(B2-E2-133)/Math.pow(10,6)
                                           )
                       )
         );

 sndV = (((F2=="sN") && (E2!=0)) ? ((E2-133)*(A2-214)/Math.pow(10,6)* send)  : 0)

     if  (ind.profile.value=="w")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Wr0        : ((ind.color.value == "1") ? Wr1        : Wr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Wstv0      : ((ind.color.value == "1") ? Wstv1      : Wstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? WshColor   : ((ind.stp.value   == "2") ? Wsh32      : Wshtapik);

           /**/pjatCost        = Wpjat;
           /**/uStvCost        = WuplStv;
           /**/uRamaCost       = WuplRam ;
           /**/mRCost          = WmetRam;
           /**/mSCost          = ((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? WmetRam  :     WmetRam2 ;
           /**/impostCost      = (shtRamaCost + uStvCost)*2 + WmImp + ((ind.color.value == "0") ? Wimpost0   : ((ind.color.value == "2") ? Wimpost2   : Wimpost1));
        }

     if  (ind.profile.value=="s")
        {
           /**/pRamaCost       = (ind.color.value == "0") ? Sr0        : ((ind.color.value == "1") ? Sr1        : Sr2  );
           /**/pStvrCost       = (ind.color.value == "0") ? Sstv0      : ((ind.color.value == "1") ? Sstv1      : Sstv2);
           /**/shtRamaCost     = (ind.color.value == "2") ? SshColor   : ((ind.stp.value   == "2") ? Ssh32      : Sshtapik);

           /**/pjatCost        = Spjat;
           /**/uStvCost        = SuplStv;
           /**/uRamaCost       = SuplRam ;
           /**/mRCost          = SmetRam;
           /**/mSCost          =((Math.abs(ind.W.value) < 1050) || (Math.abs(ind.H.value) < 1500)) ? SmetRam  :     SmetRam2 ;
           /**/impostCost      = (shtRamaCost + uStvCost)*2 + SmImp + ((ind.color.value == "0") ? Simpost0   : ((ind.color.value == "2") ? Simpost2   : Simpost1));
        }


   Fnit =   getFurn ((Math.abs(ind.H.value)-124),(Math.abs(ind.opener.value)-77))*1.6;

   stCost          = (ind.stp.value == "0") ? St1k : ((ind.stp.value=="1") ? St2k : Stdk);

   RAll            = (pRama       * pRamaCost     /1000)*1.04;
   stvrAll         = (stvr        * pStvrCost     /1000); stvrAll = (ind.profile.value=="w") ? stvrAll*1.05 : stvrAll*1.04;
   shtAll          = (shtRama     * shtRamaCost   /1000); shtAll  = (ind.profile.value=="w") ? shtAll *1.08 : shtAll *1.04;
   impRAll         =  (ind.profile.value=="w") ? ((E2!=0) ? (pImpost     * impostCost    /1000)*1.07 : 0) :
                                                 ((pImpost     * impostCost    /1000)*1.04);
   pjatAll         = (E2!=0) ? (pjatI * pjatCost) : 0;
   shtulpAll       = (stShtulp * shult)/1000*1.1; shtulpAll  = (ind.profile.value=="w") ? (shtulpAll + WzShult) : (shtulpAll + SzShult);
   uplRAll         = (uRama       * uRamaCost     /1000)*1.04;
   uplSAll         = (uStp        * uStvCost      /1000)*1.04;
   mRAll           = (metalR      * mRCost        /1000)*1.04;
   mSAll           = (metalS      * mSCost        /1000)*1.04;
   sendAll         = sndV * 1.25;
   stAll           = (stpak  > 0.4) ? ( stpak  * stCost) :  (stCost*0.4);

  summatoria = (RAll + stvrAll + shtAll + uplSAll + uplRAll + mRAll + mSAll + shtulpAll );

/*  ind.cost.value = RAll     + ' | ' +
                   stvrAll  + ' | ' +
                   shtAll   + ' | ' +
                   uplSAll  + ' | ' +
                   uplRAll  + ' | ' +
                   mRAll    + ' | ' +
                   shtulpAll+ ' | ' +
                   mSAll    + ' | ' +
                   stAll    + ' | ' +
                   Fnit     + ' | ' +
                   impRAll  + ' | ' +
                   pjatAll  + ' | ' +
                   sendAll  ;
  */
//  ind.cost.value = Fnit

   house = (ind.profile.value == "s") ?  ((summatoria + impRAll + pjatAll+ 2)/koef+ stAll + sendAll + (Fnit + 0.6)/koef)*kn*nr*skidka :
                                         ( summatoria + impRAll + pjatAll+ 2      + stAll + sendAll + (Fnit + 0.6)/koef)*kn*nr*skidka;

 ind.elements['cost'].value= addComas(house);
 }

/*---------- WINHOUSE --------*/
}


function  getFurn( hMass,wMass)
{

/*----------   array   --------------------*/
 var masa = new Array(7);
       masa[0] = new Array( 6.5  , 6.5  , 6.5  ,  9   , 9     , 9  , 12 );
       masa[1] = new Array(  9   ,  9   ,  9   ,  9   , 10    , 10 , 13 );
       masa[2] = new Array(  10  , 10   ,  10  , 10.5 , 11.5  , 13 , 15 );
       masa[3] = new Array(  10  , 10   ,  10  , 10.5 , 11.5  , 13 , 15 );
       masa[4] = new Array( 10.5 , 10.5 , 10.5 ,  11  , 11    , 13 , 16 );
       masa[5] = new Array( 11.5 , 11.5 , 11.5 , 12.5 , 13    , 15 , 0 );
       masa[6] = new Array( 12.5 , 12.5 , 12.5 , 13.5 , 14    , 16 , 0 );

/*----------  /array   --------------------*/

j = (( hMass < 601) ? 0 :
       (( hMass < 851) ? 1 :
         (( hMass < 1001) ? 2 :
            (( hMass < 1301) ? 3 :
               (( hMass < 1901) ? 4 :
                  (( hMass < 2201) ? 5 : 6))))));

i = (( wMass < 391) ? 0 :
         (( wMass < 471) ? 1 :
              (( wMass < 621) ? 2 :
                   (( wMass < 751) ? 3 :
                        (( wMass < 921) ? 4 :
                             (( wMass < 1221) ? 5 : 6))))));
return masa[j][i]
}

 function    close()
{
 document.getElementById("framuga").style.display = 'none';
 document.getElementById("wop").style.display = 'none';
 document.getElementById("wop2").style.display = 'none';
 document.getElementById("upImpost").style.display = 'none';
 document.getElementById("sV").style.display =  'none';
}

/*
function    whomSelect()
{
	var ind = document.forms['form'];
	var img = ind.elements['f'].value;
	if (img)
	{
		document.getElementById("window").src="uploads/calc/window_"+ img + ".png";
	}
	return false;
}

 function    close()
{
 document.getElementById("framuga").style.display = 'none';
 document.getElementById("wop").style.display = 'none';
 document.getElementById("wop2").style.display = 'none';
 document.getElementById("upImpost").style.display = 'none';
 document.getElementById("sV").style.display =  'none';
}*/

function    whomSelect()
{
document.getElementById("window").src="uploads/images/calc/window_"+ document.getElementById('form').f.value + ".png";
return false;
}
