// Kort form för document ready. Dvs kör functionen när sidan laddat klart $(function(){ // alert('ok'); }); $(document).ready(function(){ //Hide div w/id extra $(".medsokande").css("display","none"); $(".spalt_rubrik").css("display","none"); $(".spalt_cost").keypress(function (e) { if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) { return false; } }); $('#cost_form').submit(function() { lanebelopp_org = $("input[name=kostnad_belopp]").val(); lanebelopp = lanebelopp_org; if(lanebelopp<10000 || lanebelopp > 200000) { alert('Lånebeloppet måste ligga mellan 10 000 kr och 200 000 kr'); return false; } totallanebelopp = lanebelopp; antalar = $("input[name=kostnad_avbetalningstid]").val(); if(antalar<1 || antalar>12) { alert('Avbetalningstiden måste vara mellan 1 år och 12 år'); return false; } $(".spalt_cost").css("display","none"); $(".berakna_kostnad").css("display","none"); $(".spalt_cost2").css("display","inline"); $(".cost_back a").css("display","inline"); $(".cost").css("height","412px"); $(".cost").css("background-image","url(wp-content/themes/Interago/bilder/Cost_background2.png)"); $("input[name=belopp]").val(lanebelopp_org); $("input[name=belopp]").css("color","#000000"); $("select[name=tid]").val(antalar + " år"); effektivranta = 0; Gr = 21.0; ranta = 5.95; aviavgift = 40; engangsavgift =350; antalmanader = antalar * 12; antaldagar = antalmanader * 30; belopp = lanebelopp/antalmanader; var akvar = new Array(antalmanader); var alanebelopp = new Array(antalmanader); totalrantekostnad = 0; totalavgift = 0; kvar = 0; totallanebelopp2 = totallanebelopp - engangsavgift; for (var i=0; i<=antalmanader-1; i++){ manadsranta = parseInt(lanebelopp* ((ranta / 100) / 12)); totalrantekostnad = totalrantekostnad + manadsranta; totalavgift = totalavgift + engangsavgift + aviavgift; lanebelopp2 = belopp + manadsranta + engangsavgift + aviavgift; alanebelopp[i] = parseInt(lanebelopp2); lanebelopp = lanebelopp - belopp; engangsavgift = 0; } /* while (kvar <= totallanebelopp){ Gr -= 0.00001; kvar = 0; for (var i=1; i<=antalmanader; i++){ akvar[i-1] = alanebelopp[i-1] / Math.pow(Gr,(i / 12)); kvar = kvar + akvar[i-1]; } } effektivranta = (Gr - 1) * 100; effektivranta = effektivranta.toFixed(2); interest = totalavgift / lanebelopp_org; effektivranta = 100 * (Math.pow(1 + interest, antalmanader) - 1); */ medelbelopp = 0; for (i = 0; i < antalmanader; i++) { medelbelopp += alanebelopp[i]; } medelbelopp = parseInt(medelbelopp / antalmanader); $("#display_1").html(lanebelopp_org + " kr"); $("#display_2").html(antalar + " år"); $("#display_3").html(ranta + " %"); $("#display_4").html(medelbelopp + " kr"); $("#display_5").html(alanebelopp[0] + " kr & " + alanebelopp[antalmanader-1] + " kr"); return false; }); // Add onclick handler to checkbox w/id checkme $("#extra_sokande_id").click(function(){ // If checked if ($("#extra_sokande_id").is(":checked")) { //show the hidden div $(".medsokande").show(); $(".spalt_rubrik").show("fast"); } }); $("a.rantefraga").click(function(){ $(".spalt_cost").hide(); $(".spalt_cost2").hide(); $(".cost_back").hide(); $(".cost_back2 a").show(); $(".rantespalt").show(); return false; }); $("a.snittfraga").click(function(){ $(".spalt_cost").hide(); $(".spalt_cost2").hide(); $(".cost_back").hide(); $(".cost_back2 a").show(); $(".snittspalt").show(); return false; }); $("a.mottagarfraga").click(function(){ $(".mottagarforklaring").css("visibility","visible");; return false; }); $(".cost_back2 a").click(function(){ $(".spalt_cost2").show(); $(".cost_back").show(); $(".cost_back2 a").hide(); $(".snittspalt").hide(); $(".rantespalt").hide(); return false; }); }); /* FILE ARCHIVED ON 10:31:01 Aug 12, 2010 AND RETRIEVED FROM THE INTERNET ARCHIVE ON 16:44:16 Jun 25, 2018. JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). */ /* playback timings (ms): LoadShardBlock: 197.262 (3) esindex: 0.006 captures_list: 216.956 CDXLines.iter: 9.877 (3) PetaboxLoader3.datanode: 178.818 (4) exclusion.robots: 0.177 exclusion.robots.policy: 0.164 RedisCDXSource: 6.664 PetaboxLoader3.resolve: 225.434 load_resource: 243.246 */