// this function is not used comma
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}
// for comma convert function over
function dm(amount)
{
  string = "" + amount;
  dec = string.length - string.indexOf('.');
  if (string.indexOf('.') == -1)
  return string + '.00';
  if (dec == 1)
  return string + '00';
  if (dec == 2)
  return string + '0';
  if (dec > 3)
  return string.substring(0,string.length-dec+3);
  return string;
}
function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}
function calc(qty,amt,tot,vtot,wtot,ptype)
	{
    stot=(qty.value*amt)
    tot.value=dm(stot);
    if (ptype=='T') {
    vtot.value=(stot*4/100);
    } 
    if (ptype=='W') {
    wtot.value=(stot*10.3/100);
    }
	}
function chk(chk,qty,tot,amt,vtot,wtot,ptype)
    {

	 if (chk.checked==true)
        {
          qty.value=1;
          stot=(qty.value*amt)
          tot.value=dm(stot);
          if (ptype=='T') {
          vtot.value=Math.round((stot*4/100),0);
          } 
          if (ptype=='W') {
              wtot.value=Math.round((stot*10.3/100),0);
          }
        }
      else
        {
            qty.value=0;
            stot=(qty.value*amt)
	    tot.value=dm(stot);
            if (ptype=='T') {
            vtot.value=(stot);
            }
            if (ptype=='W') {
            wtot.value=(stot);
            } 
        }

    }
function calculate(stotal,vtotal,wtotal,gtotal)
{
    Tot24=document.frmorder.tot24.value;
	if (Tot24=="") {Tot24='0'}
	Tot25=document.frmorder.tot25.value;
	if (Tot25=="") {Tot25='0'}
	Tot26=document.frmorder.tot26.value;
	if (Tot26=="") {Tot26='0'}
	Tot27=document.frmorder.tot27.value;
	if (Tot27=="") {Tot27='0'}
	Tot28=document.frmorder.tot28.value;
	if (Tot28=="") {Tot28='0'}
	Tot29=document.frmorder.tot29.value;
	if (Tot29=="") {Tot29='0'}
	Tot30=document.frmorder.tot30.value;
	if (Tot30=="") {Tot30='0'}
	Tot31=document.frmorder.tot31.value;
	if (Tot31=="") {Tot31='0'}
	Tot32=document.frmorder.tot32.value;
	if (Tot32=="") {Tot32='0'}
	Tot33=document.frmorder.tot33.value;
	if (Tot33=="") {Tot33='0'}
	Tot34=document.frmorder.tot34.value;
	if (Tot34=="") {Tot34='0'}
	Tot35=document.frmorder.tot35.value;
	if (Tot35=="") {Tot35='0'}
	Tot36=document.frmorder.tot36.value;
	if (Tot36=="") {Tot36='0'}
	Tot37=document.frmorder.tot37.value;
	if (Tot37=="") {Tot37='0'}
	Tot38=document.frmorder.tot38.value;
	if (Tot38=="") {Tot38='0'}	
	Tot39=document.frmorder.tot39.value;
	if (Tot39=="") {Tot39='0'}	
	Tot40=document.frmorder.tot40.value;
	if (Tot40=="") {Tot40='0'}	
	Tot41=document.frmorder.tot41.value;
	if (Tot41=="") {Tot41='0'}	
	Tot42=document.frmorder.tot42.value;
	if (Tot42=="") {Tot42='0'}	
	Tot44=document.frmorder.tot44.value;
	if (Tot44=="") {Tot44='0'}	
	Tot45=document.frmorder.tot45.value;
	if (Tot45=="") {Tot45='0'}
	Tot46=document.frmorder.tot46.value;
	if (Tot46=="") {Tot46='0'}	        
        
        Totamt= eval(Tot24) + eval(Tot25) + eval(Tot26)+ eval(Tot27)+ eval(Tot28)+ eval(Tot29)+ eval(Tot30)+ eval(Tot31)+ eval(Tot32)+ eval(Tot33)+ eval(Tot34)+ eval(Tot35)+ eval(Tot36)+ eval(Tot37)+ eval(Tot38)+ eval(Tot39)+ eval(Tot40)+ eval(Tot41)+ eval(Tot42)+  eval(Tot44)+ eval(Tot45)+ eval(Tot46);
        
    VTot24=document.frmorder.vtot24.value;
	if (VTot24=="") {VTot24='0'}
	VTot25=document.frmorder.vtot25.value;
	if (VTot25=="") {VTot25='0'}
	VTot26=document.frmorder.vtot26.value;
	if (VTot26=="") {VTot26='0'}
	VTot27=document.frmorder.vtot27.value;
	if (VTot27=="") {VTot27='0'}
	VTot28=document.frmorder.vtot28.value;
	if (VTot28=="") {VTot28='0'}
	VTot29=document.frmorder.vtot29.value;
	if (VTot29=="") {VTot29='0'}
	VTot30=document.frmorder.vtot30.value;
	if (VTot30=="") {VTot30='0'}
	VTot31=document.frmorder.vtot31.value;
	if (VTot31=="") {VTot31='0'}
	VTot32=document.frmorder.vtot32.value;
	if (VTot32=="") {VTot32='0'}
	VTot33=document.frmorder.vtot33.value;
	if (VTot33=="") {VTot33='0'}
	VTot34=document.frmorder.vtot34.value;
	if (VTot34=="") {VTot34='0'}
	VTot35=document.frmorder.vtot35.value;
	if (VTot35=="") {VTot35='0'}
	VTot36=document.frmorder.vtot36.value;
	if (VTot36=="") {VTot36='0'}
	VTot37=document.frmorder.vtot37.value;
	if (VTot37=="") {VTot37='0'}
	VTot38=document.frmorder.vtot38.value;
	if (VTot38=="") {VTot38='0'}	
	VTot39=document.frmorder.vtot39.value;
	if (VTot39=="") {VTot39='0'}	
	VTot40=document.frmorder.vtot40.value;
	if (VTot40=="") {VTot40='0'}	
	VTot41=document.frmorder.vtot41.value;
	if (VTot41=="") {VTot41='0'}
	VTot42=document.frmorder.vtot42.value;
	if (VTot42=="") {VTot42='0'}	
	VTot44=document.frmorder.vtot44.value;
	if (VTot44=="") {VTot44='0'}		
        VTot45=document.frmorder.vtot45.value;
	if (VTot45=="") {VTot45='0'}	
	VTot46=document.frmorder.vtot46.value;
	if (VTot46=="") {VTot46='0'}	
        v_tax= eval(VTot24) + eval(VTot25) + eval(VTot26)+ eval(VTot27)+ eval(VTot28)+ eval(VTot29)+ eval(VTot30)+ eval(VTot31)+ eval(VTot32)+ eval(VTot33)+ eval(VTot34)+ eval(VTot35)+ eval(VTot36)+ eval(VTot37)+ eval(VTot38)+ eval(VTot39)+ eval(VTot40)+ eval(VTot41)+ eval(VTot42)+ eval(VTot44)+ eval(VTot45)+ eval(VTot46);        

    WTot24=document.frmorder.wtot24.value;
    if (WTot24=="") {WTot24='0'}
    WTot25=document.frmorder.wtot25.value;
    if (WTot25=="") {WTot25='0'}
    WTot26=document.frmorder.wtot26.value;
    if (WTot26=="") {WTot26='0'}
    WTot27=document.frmorder.wtot27.value;
    if (WTot27=="") {WTot27='0'}
    WTot28=document.frmorder.wtot28.value;
    if (WTot28=="") {WTot28='0'}
    WTot29=document.frmorder.wtot29.value;
    if (WTot29=="") {WTot29='0'}
    WTot30=document.frmorder.wtot30.value;
    if (WTot30=="") {WTot30='0'}
    WTot31=document.frmorder.wtot31.value;
    if (WTot31=="") {WTot31='0'}
    WTot32=document.frmorder.wtot32.value;
    if (WTot32=="") {WTot32='0'}
    WTot33=document.frmorder.wtot33.value;
    if (WTot33=="") {WTot33='0'}
    WTot34=document.frmorder.wtot34.value;
    if (WTot34=="") {WTot34='0'}
    WTot35=document.frmorder.wtot35.value;
    if (WTot35=="") {WTot35='0'}
    WTot36=document.frmorder.wtot36.value;
    if (WTot36=="") {WTot36='0'}
    WTot37=document.frmorder.wtot37.value;
    if (WTot37=="") {WTot37='0'}
    WTot38=document.frmorder.wtot38.value;
    if (WTot38=="") {WTot38='0'}    
    WTot39=document.frmorder.wtot39.value;
    if (WTot39=="") {WTot39='0'}    
    WTot40=document.frmorder.wtot40.value;
    if (WTot40=="") {WTot40='0'}    
    WTot41=document.frmorder.wtot41.value;
    if (WTot41=="") {WTot41='0'}
    WTot42=document.frmorder.wtot42.value;
    if (WTot42=="") {WTot42='0'}    
    WTot44=document.frmorder.wtot44.value;
    if (WTot44=="") {WTot44='0'}        
    WTot45=document.frmorder.wtot45.value;
    if (WTot45=="") {WTot45='0'}    
    WTot46=document.frmorder.wtot46.value;
    if (WTot46=="") {WTot46='0'}    
        w_tax= eval(WTot24) + eval(WTot25) + eval(WTot26)+ eval(WTot27)+ eval(WTot28)+ eval(WTot29)+ eval(WTot30)+ eval(WTot31)+ eval(WTot32)+ eval(WTot33)+ eval(WTot34)+ eval(WTot35)+ eval(WTot36)+ eval(WTot37)+ eval(WTot38)+ eval(WTot39)+ eval(WTot40)+ eval(WTot41)+ eval(WTot42)+ eval(WTot44)+ eval(WTot45)+ eval(WTot46);

stotal.value=dm(Totamt);
vtotal.value=dm(v_tax); 
wtotal.value=dm(w_tax); 
gtotal.value=dm(Totamt+v_tax+w_tax);

}

function freeofr()
    {
/*
        
      var opt21=document.frmorder.qty21.value;
      var opt2=document.frmorder.qty3.value;
      var opt3=document.frmorder.qty5.value;
      var opt4=document.frmorder.qty7.value;

if (opt21 >0)
	{
		//alert ("yes");
		window.open('subcheck.php','Verify','status=1, height=560, width=370, resizable=yes, scrollbars=yes,top=20');
	}

  /*      if (opt1 >0)
            {
              //alert ("first selected");
                if (opt2 >0)
                    {
                        //alert ("second selected");
                        if (opt3 >0)
                            {
                              //alert ("third selected");
                                if (opt4 >0)
                                    {
                                        //alert ("fourth selected");
                                        document.frmorder.chk9.checked =true;
                                        document.frmorder.chk9.disabled=true;
                                        document.frmorder.qty9.disabled=true;
                                        document.frmorder.qty9.value=1;
                                        document.frmorder.tot9.value='3000.00';
                                    }
                                    else
                                        {
                                          //alert (opt4);
                                          document.frmorder.qty9.disabled=false;
                                          document.frmorder.chk9.disabled=false;
                                        }
                            }
                        else
                            {
                              //alert (opt3);
                              document.frmorder.qty9.disabled=false;
                              document.frmorder.chk9.disabled=false;
                            }
                    }
                    else
                        {
                            //alert (opt2);
                            document.frmorder.qty9.disabled=false;
                            document.frmorder.chk9.disabled=false;
                        }
            }
            else
                {
                    //alert (opt1);
                    document.frmorder.qty9.disabled=false;
                    document.frmorder.chk9.disabled=false;
                }
*/
        
/*      if ((opt1 >0) && (opt2 >0) && (opt3 >0) && (opt4 >0))
        {
            alert ("selected");
           document.frmorder.chk9.checked =true;
           document.frmorder.chk9.disabled=true;
           document.frmorder.qty9.disabled=true;
           document.frmorder.qty9.value=1;
           document.frmorder.tot9.value='3000.00';
        }
        alert (document.frmorder.tot9.value);
    if ((opt1 >0) || (opt2 >0) || (opt3 > 0) || (opt4 >0))
        {
           alert ("not selected");
           //document.frmorder.chk9.checked =true;
           document.frmorder.qty9.disabled=false;
           document.frmorder.chk9.disabled=false;
           document.frmorder.qty9.value=1;
           document.frmorder.tot9.value='3000.00';
           //document.frmorder.qty9.value=0;
        }
*/
    }
function cklog()
    {
           if (document.frmorder.userid.value=="")
            {
              if(confirm("Please login!"))
                    {
                        location='login.php?page=orderform.php'


                    }
            }
    }
function chkprd(rate)
    {
		if (rate=='0')
			{
			 		window.document.frmorder.method="POST";
                    window.document.frmorder.action="thanks.php";
                    window.document.frmorder.submit(); 
			}
    }
function fnorder()
    {
        if (document.frmorder.userid.value=="")
            {
              if(confirm("Please login!"))
                    {
                        location='login.php?page=orderform.php'


                    }
            }
        else
            {

                var gt=document.frmorder.g_total;
                      if ((gt.value!="") && (gt.value!=0))
                        {
                         window.document.frmorder.method="POST";
                         window.document.frmorder.action="orderdet.php?paymode=1";
                         window.document.frmorder.submit();
                        }
                      else
                        {
                          alert ('Please select any one product');
                        }
                //alert ("OK");
                //alert (document.frmorder.transid.value);
                //alert (document.frmorder.transid.value);
                //var usdamt=((document.frmorder.g_total.value)/45);
                //var result=Math.round(usdamt*100)/100
                //document.frmorder.amount.value=resutl;
            }
    }
function fnorder2()
    {
        if (document.frmorder.userid.value=="")
            {
              if(confirm("Please login!"))
                    {
                        location='login.php?page=orderform.php'
                    }
            }
        else
            {

                var gt=document.frmorder.g_total;
                      if ((gt.value!="") && (gt.value!=0))
                        {
                            window.document.frmorder.method="POST";
                            window.document.frmorder.action="orderdet.php?paymode=2";
                            window.document.frmorder.submit();
                        }
                      else
                        {
                          alert ('Please select any one product');
                        }
                //alert ("OK");
                //alert (document.frmorder.transid.value);
                //alert (document.frmorder.transid.value);
                //var usdamt=((document.frmorder.g_total.value)/45);
                //var result=Math.round(usdamt*100)/100
                //document.frmorder.amount.value=resutl;
            }
    }
function fnorder3()
    {
        if (document.frmorder.userid.value=="")
            {
              if(confirm("Please login!"))
                    {
                        location='login.php?page=orderform.php'
                    }
            }
        else
            {
				window.document.frmorder.method="POST";
                window.document.frmorder.action="orderdet.php?paymode=1";
                window.document.frmorder.submit();
            }
    }
function fnorder4()
    {
        if (document.frmorder.userid.value=="")
            {
              if(confirm("Please login!"))
                    {
                        location='login.php?page=orderform.php'
                    }
            }
        else
            {
                window.document.frmorder.method="POST";
                window.document.frmorder.action="orderdet.php?paymode=2";
                window.document.frmorder.submit();
            }
    }
function openLogo(ClientID)
{
var attributes = 'toolbar=0,location=0,directories=0,status=0, menubar=0,scrollbars=1,resizable=1,width=550,height=600,left=0,top=0';
sealWin=window.open('http://world.ccavenue.com/content/verifySeal.jsp?ClientID='+ClientID ,'win',attributes);
self.name = 'mainWin';
}
function usdcon()
    {
       var num=(document.frmorder.g_total.value/44);
       result = num.toFixed(2);
       document.frmorder.usd_total.value=num;
       document.frmorder.usd1_total.value=result;
    }

