﻿function Cal_Pr(w,h,n,r){if(!r){r=""}var c="";var l=0;var a=0;var s="";var e="";var f=0;var t=0;var b=0;var v=0;var p="";var o=0;var m=0;var g=0;var d=0;var q=0;var u=0;var i=0;o=document.getElementById(r+"Taksong_"+w).value;optionSel=document.getElementById(r+"optionSel_"+w).value.split(",");l=lineupSet[5];q=lineupSet[6];if(q>0&&jangaeSet[0]==0){u=q}else{if(q<0&&jangaeSet[0]==1){u=q;i=q}else{if(q>0){i=q}}}if(u){if(u!=100&&u!=-100){v+=cal_teuksose(l,u)}}if(h=="start"&&document.getElementById(r+"optionSel_"+w).value){opt_standardA(w,r)}if(n){OptSet=document.getElementById(r+"optCbox_"+w+"_"+n).value.split(":");if(OptSet.length>1){if(document.getElementById(r+"optCbox_"+w+"_"+n).checked==true){opt_reject(w,n,OptSet[1],r);opt_dependA(w,n,OptSet[1],r)}else{opt_standardD(w,n,OptSet[1],r);opt_dependD(w,n,OptSet[1],r)}}}if(document.getElementById(r+"optionSel_"+w).value){tempOpt=cal_optsum(w,u,r);a=tempOpt[0];s=tempOpt[1];v+=tempOpt[2]}if(jangaeSet[5]=="J"&&v<-7150000){v=-7150000}if(u&&lineupSet[0]==150){v=0}if(document.getElementById(r+"jogunSel_"+lineupSet[3]).value&&h!="RT"){temp=document.getElementById(r+"jogunSel_"+lineupSet[3]).value.split(",");for(j=0;j<temp.length;j++){if(lineupSet[15].indexOf(temp[j])<0){temp2=document.getElementById(r+"jogunSet_"+temp[j]).value.split("^");if(temp2[0]=="P"&&jogunOk){if(temp2[2]>100){f-=parseInt(temp2[2])}else{f-=updown(temp2[2]*(parseInt(l)+parseInt(a)+parseInt(v))/100,10000,"down")}}else{if(temp2[0]=="I"&&jogunOk){if(temp2[2]>100){t-=parseInt(temp2[2])}else{t-=updown(temp2[2]*(parseInt(l)+parseInt(a)+parseInt(v))/100,10000,"down")}}else{if(temp2[0]=="M"&&jogunOk){temp3=temp2[2].split(":");temp3[0]=parseInt(temp3[0]);temp3[1]=parseInt(temp3[1]);temp3[2]=parseInt(temp3[2]);if(temp3[0]<=100){temp3[0]=updown(temp3[0]*(parseInt(l)+parseInt(a)+parseInt(v))/100,10000,"down")}f-=parseInt(temp3[0]*temp3[1]/(temp3[1]+temp3[2]));t-=parseInt(temp3[0]*temp3[2]/(temp3[1]+temp3[2]))}}}if(e){e+=","}e+=temp[j]}else{}}}if(h!="DC"&&h!="LS"&&h!="RT"&&GviewType=="L"){joList="";if(document.getElementById(r+"jogunSel1_"+lineupSet[3]).value){joList+=document.getElementById(r+"jogunSel1_"+lineupSet[3]).value}if(document.getElementById(r+"jogunSel2_"+lineupSet[3]).value){joList+=","+document.getElementById(r+"jogunSel2_"+lineupSet[3]).value}if(joList){temp=joList.split(",");for(j=0;j<temp.length;j++){if(temp[j]){temp2=document.getElementById(r+"jogunSet_"+temp[j]).value.split("^");temp3=temp2[2].split(":");if(temp3[0]<=100&&(temp2[0]=="P"||temp2[0]=="I"||temp2[0]=="M")){tempDC=updown(temp3[0]*(parseInt(l)+parseInt(a)+parseInt(v))/100,10000,"down");document.getElementById(r+"jogunVal_"+lineupSet[3]+"_"+temp[j]).innerHTML=addpt(tempDC)}}}}}if(h=="DC"){if(addcostWon.DC>100){f+=parseInt(addcostWon.DC)}else{f+=updown(parseInt(addcostWon.DC)*(parseInt(l)+parseInt(a)+parseInt(v))/100,10000,"down")}}if(lineupSet[8].indexOf("H")>=0&&i!=0&&h!="RT"){v+=cal_hybrid(parseInt(l)+parseInt(a)+parseInt(f),i,parseInt(v))}if(u&&lineupSet[0]==150){v+=cal_teuksose(parseInt(l)+parseInt(a)+parseInt(f),u);if(jangaeSet[5]=="J"&&v<-7150000){v=-7150000}}b=f+t;m=parseInt(l)+parseInt(a)+parseInt(f)+parseInt(t)+parseInt(v)+parseInt(o);g=parseInt(l)+parseInt(a)+parseInt(f)+parseInt(v)+parseInt(o);d=parseInt(l)+parseInt(a)+parseInt(f)+parseInt(v);if(h=="DC"||h=="LS"){document.getElementById(r+"PrRslt_Temp").value=c+"^"+l+"^"+a+"^"+s+"^"+e+"^"+f+"^"+t+"^"+b+"^"+v+"^"+p+"^"+o+"^"+m+"^"+g+"^"+d+"^";Cal_Dr(w,h)}else{if(h=="RT"){priceA=parseInt(l)+parseInt(a)+parseInt(v);priceB=updown(priceA/1.1,1,"mid");if(tmpRT[1]){priceC=updown(priceB*(1-tmpRT[1]/100),1,"mid")}else{priceC=priceB}if(q<0){u=-q}else{u=q}if(u){priceD=updown(priceC/(1+u/100),1,"mid")}else{priceD=priceC}v=priceC-priceD;m=parseInt(priceA);g=updown(priceD*1.1,1,"mid");d=parseInt(priceA);document.getElementById(r+"PrRslt_Temp").value=c+"^"+l+"^"+a+"^"+s+"^"+e+"^"+f+"^"+t+"^"+b+"^"+v+"^"+p+"^"+o+"^"+m+"^"+g+"^"+d+"^";Cal_Dr(w,h)}else{if(v>0){addplus="+"}else{addplus=""}if(GviewType=="M"){if(MNtab=="P"||MNtab=="C"){document.getElementById(r+"PrSumInn_"+w).innerHTML=addpt(m)}if(MRtab=="MPrSum"){document.getElementById(r+"MoreInn_"+w).innerHTML="<b>"+addpt(m)+"</b>"}}else{if(GviewType=="L"){document.getElementById(r+"PrBaseInn_"+w).innerHTML=addpt(l);document.getElementById(r+"PrOptionInn_"+w).innerHTML=addpt(a);document.getElementById(r+"DCsumInn_"+w).innerHTML=addpt(b);document.getElementById(r+"PrDCtaxInn_"+w).innerHTML=addplus+addpt(v);document.getElementById(r+"PrTaksongInn_"+w).innerHTML=addpt(o);document.getElementById(r+"PrTotalInn_"+w).innerHTML=addpt(m);document.getElementById("optSelVal").value=s;document.getElementById("jogSelVal").value=e;document.getElementById("takVal").value=o}else{if(GviewType=="C"){document.getElementById(r+"DCsumInn_"+w).innerHTML=addpt(b);document.getElementById(r+"PrDCtaxInn_"+w).innerHTML=addpt(v);document.getElementById(r+"PrTaksongInn_"+w).innerHTML=addpt(o);document.getElementById(r+"PrTotalInn_"+w).innerHTML=addpt(m)}else{if(GviewType=="I"){document.getElementById(r+"PrTotalInn_"+w).innerHTML=addpt(m)}}}}document.getElementById(r+"PrRslt_"+w).value=c+"^"+l+"^"+a+"^"+s+"^"+e+"^"+f+"^"+t+"^"+b+"^"+v+"^"+p+"^"+o+"^"+m+"^"+g+"^"+d+"^"}}}function Cal_Pr2(e,d,c,g){if(!g){g=""}var b=0;var f=0;var a=0;lineupSet=document.getElementById(g+"lineupSet_"+e).value.split("^");b=lineupSet[5];optionSel=document.getElementById(g+"optionSel_"+e).value.split(",");if(c){OptSet=document.getElementById(g+"optCbox_"+e+"_"+c).value.split(":");if(OptSet.length>1){if(document.getElementById(g+"optCbox_"+e+"_"+c).checked==true){opt_reject(e,c,OptSet[1],g);opt_dependA(e,c,OptSet[1],g)}else{opt_standardD(e,c,OptSet[1],g);opt_dependD(e,c,OptSet[1],g)}}}if(document.getElementById(g+"optionSel_"+e).value){tempOpt=cal_optsum(e,0,g);f=tempOpt[0]}a=parseInt(b)+parseInt(f);document.getElementById(g+"PrSumInn_"+e).innerHTML=addpt(a)}function cal_teuksose(b,a){if(a>100){return a-b}else{if(a>0&&a<100){return updown(-b*(a/100)/(1+a/100),1,"mid")}else{if(a<-100){a=a*-1;return(a-b)}else{if(a>-100&&a<0){return -(b*a/100)}}}}}function cal_optsum(b,a,c){if(!c){c=""}Osum=0;Onum="";Otax=0;for(j=0;j<optionSel.length;j++){temp=document.getElementById(c+"optCbox_"+b+"_"+optionSel[j]).value.split(":");if(document.getElementById(c+"optCbox_"+b+"_"+optionSel[j]).checked==true){Osum+=parseInt(temp[0]);if(Onum){Onum+=","}Onum+=optionSel[j];if(a!=0&&a>-100&&a<100){if(temp.length>2){if(temp[2]){gap=temp[2]-temp[0];if(gap<0){gap=gap*-1}if(a>0){gap=gap*-1}}else{gap=cal_teuksose(temp[0],a)}}else{gap=cal_teuksose(temp[0],a)}Otax+=gap}document.getElementById(c+"optionVal_"+b+"_"+optionSel[j]).innerHTML="<b>"+addpt(temp[0])+"</b>&nbsp;"}else{document.getElementById(c+"optionVal_"+b+"_"+optionSel[j]).innerHTML=addpt(temp[0])+"&nbsp;"}}return new Array(Osum,Onum,Otax)}function opt_standardA(a,b){if(!b){b=""}ckdOpt="";for(j=0;j<optionSel.length;j++){temp2=document.getElementById(b+"optCbox_"+a+"_"+optionSel[j]).value.split(":");if(temp2[1]){compA=temp2[1];for(k=0;k<compA.length;k++){comp=compA.substring(k,k+1);if(comp>="T"&&comp<="Z"&&comp.toUpperCase()==comp&&ckdOpt.indexOf(comp)<0){document.getElementById(b+"optCbox_"+a+"_"+optionSel[j]).checked=true;ckdOpt+=comp}}}}}function opt_standardD(c,b,a,d){if(!d){d=""}for(k=0;k<a.length;k++){comp=a.substring(k,k+1);if(comp>="T"&&comp<="Z"&&comp.toUpperCase()==comp){ckdCt=0;for(j=0;j<optionSel.length;j++){if(b!=optionSel[j]&&document.getElementById(d+"optCbox_"+c+"_"+optionSel[j]).checked==false){temp2=document.getElementById(d+"optCbox_"+c+"_"+optionSel[j]).value.split(":");if(temp2[1]){compB=temp2[1];if(compB.indexOf(comp)>=0){document.getElementById(d+"optCbox_"+c+"_"+optionSel[j]).checked=true;ckdCt=1}}}}if(ckdCt==0){document.getElementById(d+"optCbox_"+c+"_"+b).checked=true}}}}function opt_reject(c,b,a,d){if(!d){d=""}for(j=0;j<optionSel.length;j++){if(b!=optionSel[j]&&document.getElementById(d+"optCbox_"+c+"_"+optionSel[j]).checked==true){temp2=document.getElementById(d+"optCbox_"+c+"_"+optionSel[j]).value.split(":");if(temp2[1]){compA=a;compB=temp2[1];for(k=0;k<compA.length;k++){comp=compA.substring(k,k+1);if(compB.indexOf(comp)>=0&&comp.toUpperCase()==comp){document.getElementById(d+"optCbox_"+c+"_"+optionSel[j]).checked=false;compB=compB.replace(comp,"");if(compB){opt_dependD(c,optionSel[j],compB,d)}}}}}}}function opt_dependA(c,a,b,d){if(!d){d=""}ckdCt=0;unCkdOpt="";for(k2=0;k2<b.length;k2++){comp2=b.substring(k2,k2+1);if(comp2.toLowerCase()==comp2){compU2=comp2.toUpperCase();for(j2=0;j2<optionSel.length;j2++){temp22=document.getElementById(d+"optCbox_"+c+"_"+optionSel[j2]).value.split(":");if(temp22[1]&&a!=optionSel[j2]){compB2=temp22[1];if(compB2.indexOf(compU2)>=0&&document.getElementById(d+"optCbox_"+c+"_"+optionSel[j2]).checked==true&&ckdCt==0){ckdCt=1}else{if(compB2.indexOf(compU2)>=0&&document.getElementById(d+"optCbox_"+c+"_"+optionSel[j2]).checked==false&&unCkdOpt==""){unCkdOpt=optionSel[j2];unCkdVal=compB2}}}}if(ckdCt==0&&unCkdOpt){document.getElementById(d+"optCbox_"+c+"_"+unCkdOpt).checked=true;unCkdVal=unCkdVal.replace(compU2,"");if(unCkdVal){opt_reject(c,unCkdOpt,unCkdVal,d)}}}}}function opt_dependD(c,a,b,d){if(!d){d=""}for(k3=0;k3<b.length;k3++){comp3=b.substring(k3,k3+1);if(comp3.toUpperCase()==comp3){compL3=comp3.toLowerCase();for(j3=0;j3<optionSel.length;j3++){temp23=document.getElementById(d+"optCbox_"+c+"_"+optionSel[j3]).value.split(":");if(temp23[1]&&a!=optionSel[j3]){compB3=temp23[1];if(compB3.indexOf(compL3)>=0&&document.getElementById(d+"optCbox_"+c+"_"+optionSel[j3]).checked==true){document.getElementById(d+"optCbox_"+c+"_"+optionSel[j3]).checked=false}}}}}}function cal_hybrid(c,b,a){if(b>=100){gap=-1430000}else{if(b>0&&b<100){gap=updown(-c*(b/100)/(1+b/100),1,"mid");if(gap<-1430000){gap=-1430000}}else{if(b<0){if(a>1430000){gap=-1430000}else{gap=a*-1}}}}return gap};
