function change()
        {
            window.document.itrate.method="POST";
            window.document.itrate.action="itrates.php";
            window.document.itrate.submit();
        }
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);
    }
function poptastic1(url)
        {
        	newwindow=window.open(url,'Search','status=1, height=510, width=370, resizable=yes, scrollbars=yes,top=20');
    	if (window.focus) {newwindow.focus()}
        }
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 pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()

    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {

        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0

        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }

    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length

    if (pad_total > 0) {

        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++)
            value_string += "0"
        }
    return value_string
}
function fbtcalc(amt,rate,sub,exm)
	{
	  		frm=document.ass;
			txtamt=amt.value;
			txtrate=rate;
			if (txtamt > exm)
				{
					txtamtn=(txtamt-exm);	  
					txtfbt=(txtamtn*txtrate);
				}
			else
				{
				  	txtamtn=txtamt;
				  	txtfbt=0;
				}
 			sub.value=dm(txtfbt/100);
 			amt.value=dm(txtamt);
	}
function calculate(gtax,gtotal)
	{
 	Tot1=document.ass.subtot1.value;
	if (Tot1=="") {Tot1='0'}
	Tot2=document.ass.subtot2.value;
	if (Tot2=="") {Tot2='0'}
	Tot3=document.ass.subtot3.value;
	if (Tot3=="") {Tot3='0'}
	Tot4=document.ass.subtot4.value;
	if (Tot4=="") {Tot4='0'}
	Tot5=document.ass.subtot5.value;
	if (Tot5=="") {Tot5='0'}
	Tot6=document.ass.subtot6.value;
	if (Tot6=="") {Tot6='0'}
	Tot7=document.ass.subtot7.value;
	if (Tot7=="") {Tot7='0'}
	Tot8=document.ass.subtot8.value;
	if (Tot8=="") {Tot8='0'}
	Tot9=document.ass.subtot9.value;
	if (Tot9=="") {Tot9='0'}
	Tot10=document.ass.subtot10.value;
	if (Tot10=="") {Tot10='0'}
	Tot11=document.ass.subtot11.value;
	if (Tot11=="") {Tot11='0'}
	Tot12=document.ass.subtot12.value;
	if (Tot12=="") {Tot12='0'}
	Tot13=document.ass.subtot13.value;
	if (Tot13=="") {Tot13='0'}
	Tot14=document.ass.subtot14.value;
	if (Tot14=="") {Tot14='0'}
	Tot15=document.ass.subtot15.value;
	if (Tot15=="") {Tot15='0'}
	Tot16=document.ass.subtot16.value;
	if (Tot16=="") {Tot16='0'}
	Tot17=document.ass.subtot17.value;
	if (Tot17=="") {Tot17='0'}
	Tot18=document.ass.subtot18.value;
	if (Tot18=="") {Tot18='0'}
	Tot19=document.ass.subtot19.value;
	if (Tot19=="") {Tot19='0'}
	Tot20=document.ass.subtot20.value;
	if (Tot20=="") {Tot20='0'}
	Tot21=document.ass.subtot21.value;
	if (Tot21=="") {Tot21='0'}
	Tot22=document.ass.subtot22.value;
	if (Tot22=="") {Tot22='0'}
	Tot23=document.ass.subtot23.value;
	if (Tot23=="") {Tot23='0'}
	Tot24=document.ass.subtot24.value;
	if (Tot24=="") {Tot24='0'}
	Tot25=document.ass.subtot25.value;
	if (Tot25=="") {Tot25='0'}
	Tot26=document.ass.subtot15.value;
	if (Tot26=="") {Tot26='0'}
	Tot27=document.ass.subtot27.value;
	if (Tot27=="") {Tot27='0'}	
	Tot28=document.ass.subtot28.value;
	if (Tot28=="") {Tot28='0'}
	Tot29=document.ass.subtot29.value;
	if (Tot29=="") {Tot29='0'}
	Tot30=document.ass.subtot30.value;
	if (Tot30=="") {Tot30='0'}	
	Tot31=document.ass.subtot31.value;
	if (Tot31=="") {Tot31='0'}
	Tot32=document.ass.subtot32.value;
	if (Tot32=="") {Tot32='0'}	

	TotTI1=document.ass.id1.value;
	if (TotTI1=="") {TotTI1='0'}
	TotTI2=document.ass.id2.value;
	if (TotTI2=="") {TotTI2='0'}
	TotTI3=document.ass.id3.value;
	if (TotTI3=="") {TotTI3='0'}
	TotTI4=document.ass.id4.value;
	if (TotTI4=="") {TotTI4='0'}
	TotTI5=document.ass.id5.value;
	if (TotTI5=="") {TotTI5='0'}
	TotTI6=document.ass.id6.value;
	if (TotTI6=="") {TotTI6='0'}
	TotTI7=document.ass.id7.value;
	if (TotTI7=="") {TotTI7='0'}
	TotTI8=document.ass.id8.value;
	if (TotTI8=="") {TotTI8='0'}
	TotTI9=document.ass.id9.value;
	if (TotTI9=="") {TotTI9='0'}
	TotTI10=document.ass.id10.value;
	if (TotTI10=="") {TotTI10='0'}
	TotTI11=document.ass.id11.value;
	if (TotTI11=="") {TotTI11='0'}
	TotTI12=document.ass.id12.value;
	if (TotTI12=="") {TotTI12='0'}
	TotTI13=document.ass.id13.value;
	if (TotTI13=="") {TotTI13='0'}
	TotTI14=document.ass.id14.value;
	if (TotTI14=="") {TotTI14='0'}
	TotTI15=document.ass.id15.value;
	if (TotTI15=="") {TotTI15='0'}
	TotTI16=document.ass.id16.value;
	if (TotTI16=="") {TotTI16='0'}
	TotTI17=document.ass.id17.value;
	if (TotTI17=="") {TotTI17='0'}
	TotTI18=document.ass.id18.value;
	if (TotTI18=="") {TotTI18='0'}
	TotTI19=document.ass.id19.value;
	if (TotTI19=="") {TotTI19='0'}
	TotTI20=document.ass.id20.value;
	if (TotTI20=="") {TotTI20='0'}
	TotTI21=document.ass.id21.value;
	if (TotTI21=="") {TotTI21='0'}
	TotTI22=document.ass.id22.value;
	if (TotTI22=="") {TotTI22='0'}
	TotTI23=document.ass.id23.value;
	if (TotTI23=="") {TotTI23='0'}
	TotTI24=document.ass.id24.value;
	if (TotTI24=="") {TotTI24='0'}
	TotTI25=document.ass.id25.value;
	if (TotTI25=="") {TotTI25='0'}
	TotTI26=document.ass.id15.value;
	if (TotTI26=="") {TotTI26='0'}
	TotTI27=document.ass.id27.value;
	if (TotTI27=="") {TotTI27='0'}	
	TotTI28=document.ass.id28.value;
	if (TotTI28=="") {TotTI28='0'}
	TotTI29=document.ass.id29.value;
	if (TotTI29=="") {TotTI29='0'}
	TotTI30=document.ass.id30.value;
	if (TotTI30=="") {TotTI30='0'}	
	TotTI31=document.ass.id31.value;
	if (TotTI31=="") {TotTI31='0'}
	TotTI32=document.ass.id32.value;
	if (TotTI32=="") {TotTI32='0'}	

Totamt= eval(Tot1) + eval(Tot2) + eval(Tot3)+ eval(Tot4)+ eval(Tot5)+ eval(Tot6)+ eval(Tot7)+ eval(Tot8)+ eval(Tot9)+ eval(Tot10)+ eval(Tot11)+ eval(Tot12)+ eval(Tot13)+ eval(Tot14)+ eval(Tot15)+eval(Tot16) + eval(Tot17) + eval(Tot18)+ eval(Tot19)+ eval(Tot20)+ eval(Tot21)+ eval(Tot22)+ eval(Tot23)+ eval(Tot24)+ eval(Tot25)+ eval(Tot26)+ eval(Tot27)+ eval(Tot28)+ eval(Tot29)+ eval(Tot30)+ eval(Tot31)+ eval(Tot32);


Tottax= eval(TotTI1) + eval(TotTI2) + eval(TotTI3)+ eval(TotTI4)+ eval(TotTI5)+ eval(TotTI6)+ eval(TotTI7)+ eval(TotTI8)+ eval(TotTI9)+ eval(TotTI10)+ eval(TotTI11)+ eval(TotTI12)+ eval(TotTI13)+ eval(TotTI14)+ eval(TotTI15)+eval(TotTI16) + eval(TotTI17) + eval(TotTI18)+ eval(TotTI19)+ eval(TotTI20)+ eval(TotTI21)+ eval(TotTI22)+ eval(TotTI23)+ eval(TotTI24)+ eval(TotTI25)+ eval(TotTI26)+ eval(TotTI27)+ eval(TotTI28)+ eval(TotTI29)+ eval(TotTI30)+ eval(TotTI31)+ eval(TotTI32);
	

	gtotal.value=formatCurrency(Totamt);
	gtax.value=formatCurrency(Tottax);
document.ass.fbtvalue.value=formatCurrency((Totamt*33.66)/100);

	}
function calcpro()
    {
        input1=document.frmcalc.intamt.value;
		input1=input1.replace(',','');
        input1=Math.round(input1/1);
        
           myOption = -1;
        for (i=frmcalc.firm.length-1; i > -1; i--)
            {
                if (frmcalc.firm[i].checked)
                    {
                        myOption = i;
                        //alert (frmcalc.firm[myOption].value);
                        if (frmcalc.firm[myOption].value=="A")
                            {
                                var fstvlu=67500;
                                var scdvlu=45000;
                            }
                        else
                            {
                                var fstvlu=90000;
                                var scdvlu=60000;
                            }
                    }
            }
        inputA=100/90;
        inputB=100/60;
        inputC=100/40;
        //alert (fstvlu);
        if (input1=="")
            {
              alert ("Key in the amount of remuneration proposed to be drawn");
              document.frmcalc.intamt.focus();
              return false;
            }
        else
            {
                if (input1>=50001)
                    {
			            if (input1>=fstvlu)
                            {
                                input3=(fstvlu*inputA);
                                rem3=(input1-fstvlu);

                                if (rem3>=scdvlu)
                                    {
                                        input3+=(scdvlu*inputB);
                                        rem3=(rem3-scdvlu);
                                        if (rem3 >'0')
                                                {
                                                    input3+=(rem3*inputC);
                                                }
                                    }
                                else
                                    {
                                       input3+=(rem3*inputB);
                                    }
                            }
                        else
                            {
                                input3=(input1*inputA);
                                //alert();
                            }
                                document.frmcalc.intamt.focus();
                                document.frmcalc.ans.value=formatCurrency(round_decimals(input3, 0));
                                document.frmcalc.intamt.value=formatCurrency(input1);
                                return false;
                                document.frmcalc.intamt.focus();

                    }
                else
                    {

                        alert ('The book-profit required to be earned up to Rs. 55,556/- or even loss.')
                        document.frmcalc.intamt.focus();
                        //document.frmcalc.ans.value=dm(55556);
                        document.frmcalc.ans.value=formatCurrency(55556);
                        document.frmcalc.intamt.value=formatCurrency(input1);
                        return false;
                        document.frmcalc.intamt.focus();
                    }
            }
    }
function calcrem()
    {
        input1=document.frmcalc.intamt.value;
            myOption = -1;
        for (i=frmcalc.firm.length-1; i > -1; i--)
            {
                if (frmcalc.firm[i].checked)
                    {
                        myOption = i;
                        if (frmcalc.firm[myOption].value=="A")
                            {
                                var fstvlu=75000;
                            }
                        else
                            {
                                var fstvlu=100000;
                            }
                    }
            }
        inputA=0.9;
        inputB=0.6;
        inputC=0.4;
        if (input1=="")
            {
              alert ("Key in the book profit figure");
              document.frmcalc.intamt.focus();
              return false;
            }
        else
            {
                if (input1>=55556)
                    {
                        if (input1>=fstvlu)
                            {
                                input3=(fstvlu*inputA);
                                rem3=(input1-fstvlu);

                                if (rem3>=fstvlu)
                                    {
                                        input3+=(fstvlu*inputB);
                                        rem3=(rem3-fstvlu);
                                        if (rem3 >'0')
                                                {
                                                    input3+=(rem3*inputC);
                                                }
                                    }
                                else
                                    {
                                       input3+=(rem3*inputB);
                                    }
                            }
                        else
                            {
                                input3=(input1*inputA);
                            }
                                document.frmcalc.intamt.focus();
                                //document.frmcalc.ans.value=dm(round_decimals(input3, 0));
                                document.frmcalc.ans.value=formatCurrency(round_decimals(input3, 0));
                                document.frmcalc.intamt.value=formatCurrency(input1);
                                return false;
                                document.frmcalc.intamt.focus();

                    }
                else
                    {
                        alert ('The minimum eligible remuneration is Rs.50,000/- irrespective of the profit or loss earned by the firm.')
                        document.frmcalc.intamt.focus();
                        //document.frmcalc.ans.value=dm(50000);
                        document.frmcalc.ans.value=formatCurrency(50000);
                        document.frmcalc.intamt.value=formatCurrency(input1);
                        return false;
                        document.frmcalc.intamt.focus();
                    }
            }


    }
function Mod(X, Y) { return X - Math.floor(X/Y)*Y }    
function calcfee()
    {
       var input1=document.frmcalc.intamt.value;
        if (input1=="")
            {
              alert ("Key in the amount of remuneration proposed to be drawn");
              document.frmcalc.intamt.focus();
              return false;
            }
            
	var xplus=Mod(input1,10000);
//	alert (xplus);
	if (xplus==0)
		{
		  xadd=0;
		}
	else
		{
		  xadd=1;
		}
//alert (xadd);
      if (input1 < 100001)
        {
//			document.frmcalc.intamt.value=formatCurrency(input1);
            document.frmcalc.ans.value=formatCurrency(4000);
            document.frmcalc.intamt.focus();
            return false;
        }
      else if ((input1 > 100000) && (input1 < 500001))
        {

		//	document.frmcalc.intamt.value=formatCurrency(input1);
			//alert (Math.floor((input1-100000)/10000));
            //document.frmcalc.ans.value=formatCurrency(round_decimals((300*((input1-100000)/10000)+4000),0));
            document.frmcalc.ans.value=formatCurrency(300*(Math.floor((input1-100000)/10000)+xadd)+4000);
            document.frmcalc.intamt.focus();
            return false;
        }
      else if ((input1 > 500000) && (input1 < 5000001))
        {
         //	document.frmcalc.intamt.value=formatCurrency(input1);
		    //document.frmcalc.ans.value=formatCurrency(round_decimals((200*((input1-500000)/10000)+16000),0));
            document.frmcalc.ans.value=formatCurrency(200*(Math.floor((input1-500000)/10000)+xadd)+16000);
            document.frmcalc.intamt.focus();
            return false;
        }
      else if ((input1 > 5000000) && (input1 < 10000001))
        {
	     //   document.frmcalc.intamt.value=formatCurrency(input1);
		    //document.frmcalc.ans.value=formatCurrency(round_decimals((100*((input1-5000000)/10000)+106000),0));
            document.frmcalc.ans.value=formatCurrency(100*(Math.floor((input1-5000000)/10000)+xadd)+106000);
            document.frmcalc.intamt.focus();
            return false;
        }
      else
        {
			//document.frmcalc.intamt.value=formatCurrency(input1);
            //document.frmcalc.ans.value=formatCurrency(round_decimals((50*((input1-10000000)/10000)+156000),0));
            document.frmcalc.ans.value=formatCurrency(50*(Math.floor((input1-10000000)/10000)+xadd)+156000);
            document.frmcalc.intamt.focus();
            return false;
        }
            
    }

function calcit()
    {
       input1=document.frmcalc.intamt.value;
       input2=document.frmcalc.yearid.value;
        if (input1=="")
            {
              alert ("Key in the amount");
              document.frmcalc.intamt.focus();
              return false;
            }
        if (input2==245)
            {
                document.frmcalc.ans.value=formatCurrency(round_decimals((input1*36.5925/100),0));
                document.frmcalc.intamt.focus();
                return false;
            }
        else if (input2==256)
            {
                document.frmcalc.ans.value=formatCurrency(round_decimals((input1*33.66/100),0));
                document.frmcalc.intamt.focus();
                return false;
            }
        else
            {
                document.frmcalc.ans.value=formatCurrency(round_decimals((input1*33.66/100),0));
                document.frmcalc.intamt.focus();
                return false;
            }


    }
    
function pwdSubmit()
	{
        var frm = document.frmpwd;

       if((frm.usrname.value!="") || (frm.usremail.value!=""))
            {
                window.document.frmpwd.method="POST";                                                                                                                                                                                                                          window.document.frmpwd.action="pwdrec.php";
                window.document.frmpwd.submit();
            }
        else
            {
                alert("Please enter either User Name or Email address");
        		frm.usrname.focus();
            }
    }
function disableForm(theform)
    {
        if (document.all || document.getElementById)
            {
                for (i = 0; i < theform.length; i++)
                    {
                        var tempobj = theform.elements[i];
                         if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
                        tempobj.disabled = true;
                    }
                return true;
            }
    }
    function chose()
        {
            window.document.lkfrm.method="POST";
            window.document.lkfrm.action="frmlist.php";
            window.document.lkfrm.submit();
        }
function fnRegadd()
    {
        var frm = document.frmMain
        if(frm.Password.value=="")
            {
                alert("Password should not be empty");
                frm.Password.focus();
                return false;
            }
        else
            {
                if(frm.Cnfpwd.value=="")
                    {
                        alert("Confirm Password should not be empty");
                        frm.Cnfpwd.focus();
                        return false;
                    }
                else
                    {
                        if (frm.Password.value!=frm.Cnfpwd.value)
                            {
                                alert("Password and Confirm Password does not match");
                                return false;
                            }
                        else
                            {
                                 window.document.frmMain.method="POST";
                                 window.document.frmMain.action="regadd.php";
                                 window.document.frmMain.submit();
                            }
                     }
            }
    }
var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'name','status=1, height=500, width=650, resizable=yes, scrollbars=yes,top=20');
	if (window.focus) {newwindow.focus()}
}

function fnchg()
    {
	    window.document.adv.method="POST";
        window.document.adv.action="adsplace.php";
        window.document.adv.submit();
    }
function fnadchg()
    {
	    window.document.adv.method="POST";
        window.document.adv.action="advadmin.php?type=change";
        window.document.adv.submit();
    }
function fnproc()
    {
	    window.document.adv.method="POST";
        window.document.adv.action="proceed.php";
        window.document.adv.submit();
    }
function fnfin()
    {
	    window.document.frmprc.method="POST";
        window.document.frmprc.action="proceed.php";
        window.document.frmprc.submit();
    }
function fnadproc()
    {
	    window.document.adv.method="POST";
        window.document.adv.action="advadmin.php?type=add";
        window.document.adv.submit();
    }
function fnback()
    {

        window.document.RTEDemo.method="POST";
        window.document.RTEDemo.action="list.php";
        window.document.RTEDemo.submit();
    }
function fnadd()
    {

        window.document.Main.method="POST";
        window.document.Main.action="main.php";
        window.document.Main.submit();
    }
function fnaback()
    {

        window.document.Main.method="POST";
        window.document.Main.action="main.php";
        window.document.Main.submit();
    }

function fnadmbk()
    {
        window.document.optadmin.method="POST";
        window.document.optadmin.action="aceadmin.php";
        window.document.optadmin.submit();
    }
function fnadvbk()
    {
        window.document.optadmin.method="POST";
        window.document.optadmin.action="aceadmin.php?type=adv";
        window.document.optadmin.submit();
    }    
function fnred()
    {
        window.document.Main.method="POST";
        window.document.Main.action="usrout.php";
        window.document.Main.submit();
    }
function fnadlog()
    {
        window.document.fmad.method="POST";
        window.document.fmad.action="usrout.php";
        window.document.fmad.submit();
	}
function test(file,target)
    {
     	alert ('balaji');
    }
