var d2t=0;
function setd2t(d){
	d2t=d;
	}

function updateProductValue(){
    setimpCost();
    setoverHead();
    setprofit();
    setcost();
    setcurrentProfit();
    setcomm();
    setincentive();
    setconmm();
}
function setbuyPrice(){
    var taka = parseFloat(document.getElementById('taka').value);
    var dollarTaka=Math.round(taka*100)/100; //now dollarTaka is not used
    var out=document.getElementById('buyPrice');
    var buyPrice=parseFloat(document.createProject.buyPrice.value)*d2t;
    out.innerHTML=Math.round(buyPrice);
}
	

function setimpCost(){
    var taka = parseFloat(document.getElementById('taka').value);
    var dollarTaka=Math.round(taka*100)/100; //now dollarTaka is not used
    var out=document.getElementById('impCost');
    var buyPrice=parseFloat(document.createProject.buyPrice.value)*d2t;
    var impCost=(buyPrice*parseFloat(document.createProject.impCost.value))/100;
    if(!impCost)impCost=0;
    out.innerHTML=Math.round(impCost);
}	

function setoverHead(){
    var taka = parseFloat(document.getElementById('taka').value);
    var dollarTaka=Math.round(taka*100)/100; //now dollarTaka is not used
    var out=document.getElementById('overHead');
    var buyPrice=parseFloat(document.createProject.buyPrice.value)*d2t;
    var overHead=(buyPrice*parseFloat(document.createProject.overHead.value))/100;
    if(!overHead)overHead=0;

    out.innerHTML=Math.round(overHead);
}	
	
	
function setprofit(){
    var taka = parseFloat(document.getElementById('taka').value);
    var dollarTaka=Math.round(taka*100)/100; //now dollarTaka is not used
    var out=document.getElementById('profit');
    var buyPrice=parseFloat(document.createProject.buyPrice.value)*d2t;
    var profit=(buyPrice*parseFloat(document.createProject.profit.value))/100;
    if(!profit)profit=0;

    out.innerHTML=Math.round(profit);
}	
	
function setcost(){
    var taka = parseFloat(document.getElementById('taka').value);
    var dollarTaka=Math.round(taka*100)/100; //now dollarTaka is not used
    var out=document.getElementById('cost');
    var buyPrice=parseFloat(document.createProject.buyPrice.value)*d2t;
    var impCost=(buyPrice*parseFloat(document.createProject.impCost.value))/100;
    var overHead=(buyPrice*parseFloat(document.createProject.overHead.value))/100;
    var profit=(buyPrice*parseFloat(document.createProject.profit.value))/100;
    //alert(buyPrice+'='+impCost+'='+overHead+'='+profit);
    var cost=0;
    if(buyPrice)cost+=buyPrice;
    if(impCost)cost+=impCost;
    if(overHead)cost+=overHead;
    if(profit)cost+=profit;

    //var cost=buyPrice+impCost+overHead+profit;
    //alert(cost);

    out.innerHTML=Math.round(cost);
}	
	
function setcurrentProfit(){
    //	alert('hi');
    var out=document.getElementById('currentProfit');
    var currentbuyPrice=parseFloat(document.getElementById('cost').innerHTML);
    var totalProfit=Math.round(parseFloat(document.getElementById('suggestedPrice').value)*currentbuyPrice/100);
    var srp = currentbuyPrice+totalProfit;
    document.getElementById('srp').innerHTML=srp;
    document.getElementById('hiddensrp').value=document.getElementById('suggestedPrice').value;
    if(!currentbuyPrice)currentbuyPrice=0;
    if(!srp)srp=0;
    var currentProfit=srp-currentbuyPrice;
    out.innerHTML=Math.round(currentProfit);
    //alert('pp'+currentProfit);
}

function setcomm(){
    var out=document.getElementById('comm');
    var profit=parseFloat(document.getElementById('currentProfit').innerHTML);
    var comm=(profit*parseFloat(document.createProject.comm.value))/100;
    if(!comm)comm=0;

    out.innerHTML=Math.round(comm);
}
function setincentive(){
    var out=document.getElementById('incent');
    var profit=parseFloat(document.getElementById('currentProfit').innerHTML);
    var incention=(profit*parseFloat(document.createProject.incentive.value))/100;
    if(!incention)incention=0;

    out.innerHTML=Math.round(incention);
}

function setconmm(){
    var out=document.getElementById('conmm');

    var profit=parseFloat(document.getElementById('currentProfit').innerHTML);
    var conmm=(profit*parseFloat(document.createProject.conmm.value))/100;
    if(!conmm)conmm=0;

    out.innerHTML=Math.round(conmm);
	}	

/*------------END product----------------------*/

/* For Add two field*/
function addMe(form, f11, f12){
     var totalPrice = parseFloat(f11) + parseFloat(f12);
     return totalPrice;
}

function divMe(f11, f12){
     var totalPrice = parseFloat(f11) / parseFloat(f12);
     return totalPrice;
}



/* For Sub two field*/
function subMe(form, f11, f12){
     var totalPrice = parseFloat(f11) - parseFloat(f12);
     return totalPrice;
}

/*for multiple 2 filed*/
function multipleMe(form, f11, f12,f13,f14,f15,f16,re){

    f1=parseFloat(f11.value);
    f2=parseFloat(f12.value);
    f3=parseFloat(f13.value);
    f4=parseFloat(f14.value);
    var totalPrice=0;


    if(!f1 && !f2 && !f3 && !f4){
        f1=f2=f3=f4=0;
        f16.value=0;
    }
    else {
        if(!f1) f1=1;
        if(!f2) f2=1;
        if(!f3) f3=1;
        if(!f4) f4=1;

        totalPrice =f2*f3*f4;
        f15.value=totalPrice;
        var totalQty=f1*totalPrice;
        if(f1 && totalQty<=re.value) f16.value=totalQty;
        else {alert('Check you values. Your values may be excedding receivable Values!!');f16.value=0;}
    }
    return totalPrice;
}


/*for multiple 3 filed*/
function multipleMe3(form, f11, f12, f13){
  
  f1=parseFloat(f11);
  f2=parseFloat(f12);
  f3=parseFloat(f13);
  
 if(!f1) f1=1;
 if(!f2) f2=1;
 if(!f3) f3=1;


  var totalPrice =f1*f2*f3;

 return totalPrice;
}

function ad(input,input2,output1,output2) {

var total = parseInt(input.value)-parseInt(input2.value);
//alert(total);
if(total==0) {output1.value=0;
  output2.value=0;
  //alert(total);
  }

else if(total>0)
output2.value=total;
else if(total<0) output1.value=total*(-1);
}


<!-- Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {

var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
//  End -->

<!--Begin 
//if(document.ven.cfacility[2].checked) {alert('ss');document.ven.camount.disabled='true';document.ven.camount.className='disabled'}"
function credit(){
	if(document.ven.cfacility[0].checked || document.ven.cfacility[1].checked) 
	{
	document.ven.camount.disabled=true;
	document.ven.camount.className='disabled'
	document.ven.camount.value=''	
	document.ven.cduration.disabled=true;
	document.ven.cduration.className='disabled';
	document.ven.cduration.value='';	
	} 
	else 
	{
	document.ven.camount.disabled=false;
	document.ven.camount.className=''
	document.ven.cduration.disabled=false;
	document.ven.cduration.className='';
	} 

}
function credit0(){
	if(document.ven.advance[0].checked) 
	{
	document.ven.advanceText.disabled=true;
	document.ven.advanceText.className='disabled'
	document.ven.advanceText.value=''	
	} 
	else 
	{
	document.ven.advanceText.disabled=false;
	document.ven.advanceText.className=''
	} 

}

//  End -->

function selector1(form, v)
{
	if(v==0){
	   form.qualityText.disabled=true;
	   form.qualityText.className='disabled';
	   form.qualityText.value='';	   
      }
	else{
	   form.qualityText.disabled=false;
	   form.qualityText.className='';
      }
}
function selector2(form, v)
{
	if(v==0){
	   form.reliabilityText.disabled=true;
	   form.reliabilityText.className='disabled';
	   form.reliabilityText.value='';	   
      }
	else{
	   form.reliabilityText.disabled=false;
	   form.reliabilityText.className='';
      }
}

function selector3(form, v)
{
	if(v==0){
	   form.availabilityText.disabled=true;
	   form.availabilityText.className='disabled';
	   form.availabilityText.value='';	   
      }
	else{
	   form.availabilityText.disabled=false;
	   form.availabilityText.className='';
      }
}
function selector4(form, v)
{
	if(v==0){
	   form.experienceMText.disabled=true;
	   form.experienceMText.className='disabled';
	   form.experienceMText.value='';	   
      }
	else{
	   form.experienceMText.disabled=false;
	   form.experienceMText.className='';
      }
}
function selector5(form, v)
{
	if(v==0){
	   form.experienceBText.disabled=true;
	   form.experienceBText.className='disabled';
	   form.experienceBText.value='';	   
      }
	else{
	   form.experienceBText.disabled=false;
	   form.experienceBText.className='';
      }
}
function selector6(form, v)
{
	if(v==0){
	   form.serviceText.disabled=true;
	   form.serviceText.className='disabled';
	   form.serviceText.value='';	   
      }
	else{
	   form.serviceText.disabled=false;
	   form.serviceText.className='';
      }
}

function ShowExtraQuestImage(divName)
{    
	var divmain = document.getElementById(divName);

	if (divmain.className == "hidden")
	{	
	    for (i = 1; i <= 4; i++)
		 {var d="div"+i;
	           var divtemp = document.getElementById(d);		 
		   divtemp.className= "hidden";
		  }

	    divmain.className = "visible";		
	}
}
function nextField(input, e) {

    var keyCode =  e.keyCode;
    //alert(keyCode);

    if(keyCode==13)
    input.form[(getIndex(input)+1)].focus();

    function getIndex(input) {
        var index = -1, i = 0, found = false;
        while (i < input.form.length && index == -1)
        if (input.form[i] == input)index = i;
        else i++;
        return index;
    }
    return true;
}

function calc(a,b,c,d,e) {
    var a = parseFloat(a);
    var b= parseFloat(b);
    var c= parseFloat(c);
    var d= parseFloat(d)/100;
    var e= parseFloat(e)/100;

    var up=(b-(b/(1+e)))*(12-c);
    var down=(a+(b*c*d));
    //alert(up);
    //alert(down);
    var roi=(up/down)*100;
    roi=Math.round(roi,2);
    return roi;
}
function ShowDiv(divName){   
    var divmain = document.getElementById(divName);
    divmain.className= "visible";
}
function hidDiv(divName){
    var divmain = document.getElementById(divName);
    divmain.className= "hidden";
}

