function getCols(){$('div#hosting div.nwrap:eq('+colorQueue+') div.head span').css('background','#'+nwrapColor[colorQueue][1]);$('div#hosting div.nwrap:eq('+colorQueue+') div.head em').css('color','#'+nwrapColor[colorQueue][1]);$('div#hosting div.nwrap:eq('+colorQueue+') span.foot').css('background','#'+nwrapColor[colorQueue][1]+' url("/img/'+nwrapColor[colorQueue][1]+'.gif") repeat-x 0 0');colorQueue+=1;}
function getVPS(){$('div#vps div.nwrap:eq('+showVPS+') div.head span').css('background','#'+vpsColor[showVPS][1]);$('div#vps div.nwrap:eq('+showVPS+') div.head em').css('color','#'+vpsColor[showVPS][1]);$('div#vps div.nwrap:eq('+showVPS+') span.foot').css('background','#'+vpsColor[showVPS][1]+' url("/img/'+vpsColor[showVPS][1]+'.gif") repeat-x 0 0');showVPS+=1;}
function inCart(id,type){if(type=='vps'){location.href='ru/service/vps/tariffs/'+id+'/';}else{if(id=='calculate'){id=$('input[name=tariff]').val();$('form#incart').attr('action','ru/service/tariffs/'+id+'/').submit();}else if(id=='38'){location.href='ru/service/tariffs/vip/#top';}else{location.href='ru/service/tariffs/'+id+'/';}}}
function countConf(type){if(type=='vps'){}else{var curVal=$('input[name=space]').val();for(i=0;i<unlims.length;i++){if(curVal<unlims[i][2]||(curVal>unlims[i][2]*1.5)){continue;}else{var calc=curVal-unlims[i][2];if(calc.toFixed(1)==0.0){calc=0;}
$('div.hint strong:first').html(unlims[i][1]).css('color','#'+nwrapColor[i][1]);if(calc!=0){$('div.hint strong:last').html(' + '+calc.toFixed(1)+'Gb');}else{$('div.hint strong:last').html('');}
var packSpace=unlims[i][3].split(' ');var space=parseFloat(packSpace[1])/1000;var newcost=parseFloat(packSpace[2]);var addSpace=curVal-unlims[i][2];addSpace=addSpace.toFixed(1);newSpace=addSpace/space*newcost;var cost=unlims[i][4];if(calc!=0){cost=parseFloat(cost)+newSpace;}
$('strong#monthcost').html(Math.round(cost-(15/100*cost)));$('strong#yearcost').html(Math.round((cost*12)-(15/100*(cost*12))));$('input[name=tariff]').val(unlims[i][5]);$('input[name=usage]').val(addSpace*1000);}}}}
function formatnum(str){var retstr='';var now=0;for(i=str.length-1;i>=0;i--){if(now<3){now++;retstr=str.charAt(i)+retstr;}else{now=1;retstr=str.charAt(i)+' '+retstr;}}
return retstr;}
function makeOrder(){var service=5.7;var days=$('input[name=daysvps]').val();var vds_cpu=cpus[$('input[name=cpu-vps]').val()];var vds_mem=memorys[$('input[name=memory-vps]').val()];var vds_disk=spaces[$('input[name=disk-vps]').val()];var vds_opt_ip=$('select[name=dopip] option:selected').val();var storage_type=$('#storage_type input:checked').val();var vds_opt_admin_small=($('input[name=admvps]').attr('checked')==true)?1:0;var total_sum=cost;var arr_order=[];if($('#cp').attr('checked')==true&&$('#cps option:selected').attr('value')!=0){arr_order=parseFloat($('#cps option:selected').attr('value'));}
var data={"service":service,"days":days,"vds_cpu":vds_cpu,"vds_mem":vds_mem,"vds_disk":vds_disk,"vds_opt_ip":vds_opt_ip,"vds_ssd":((storage_type=='ssd')?1:0),"vds_opt_admin_small":vds_opt_admin_small,"total_sum":total_sum,"discount":discount,"template":template,"firstservices":arr_order};var url="ru/jq/cart/vdsconstructor/";var result_save;var result_text;$.ajax({type:"POST",url:url,data:data,cache:false,dataType:"json",success:function(result){switch(result["status_code"]){case 0:window.location="ru/service/cart/";break;case 1:alert(result["status_msg"]);break;}}});}
function vpsCalculate(vds_cpu_cost,vds_mem_cost,vds_disk_cost,vds_opt_ip_cost,vds_opt_admin_small_cost,free_domains_days){period=$('input[name=daysvps]').val();cpu=cpus[$('input[name=cpu-vps]').val()];memory=memorys[$('input[name=memory-vps]').val()];space=spaces[$('input[name=disk-vps]').val()];template=$('select[name=vpstemplate] option:selected').val();if($('input[name=admvps]').attr('checked')==true){management=1;}else{management=0;}
ip=$('select[name=dopip] option:selected').val();cp=false;cpID=0;cpCOST=0;if($('#cp').attr('checked')==true){cp=true;cpID=parseFloat($('#cps option:selected').attr('value'));cpCOST=parseFloat($('#cps option:selected').attr('name'));}
if(cpID==0){cp=false;}
periods={90:3,180:6,365:12,730:24};discount={90:0,180:0.05,365:0.1,730:0.15};cpu_total_cost=parseFloat(vds_cpu_cost)*cpu;memory_total_cost=parseFloat(vds_mem_cost)*memory;space_total_cost=parseFloat(vds_disk_cost)*space;all_parameters_cost=cpu_total_cost+memory_total_cost+space_total_cost;total_cost=all_parameters_cost*periods[period];discount_total=total_cost*discount[period];all_costs=total_cost-discount_total;all_costs=Math.round(all_costs);cost=all_costs;per_month_cost=all_costs/periods[period];if(ip>0){per_month_cost=per_month_cost+(ip*85);cost=cost+((ip*85)*periods[period]);}
if(management==1){per_month_cost=per_month_cost+2250;cost=cost+(2250*periods[period]);}
if(cpID==1728||cpID==1732||cpID==1730||cpID==1734){cpRent=1;per_month_cost=per_month_cost+cpCOST;}else{cpRent=0;}
if(cp){if(cpRent==0){$('#showOnes').css('display','inline');$('#yearcost-vps').html(cpCOST);}else{$('#showOnes').css('display','none');}}else{$('#showOnes').css('display','none');$('#yearcost-vps').html('0');}
discount=discounts[period];$("#monthcost-vps").html(parseInt(Math.round(per_month_cost)));}
$(function(){discounts={'90':'0','180':'5','365':'10','730':'15'};days2month={'90':'3','180':'6','365':'12','730':'24'};cpus={1200:'6',1600:'8',2000:'10',2400:'12'};memorys={'1024':'8','1536':'12','2048':'16','2560':'20','3072':'24','3584':'28','4096':'32','4608':'36','5120':'40','5632':'44','6144':'48','6656':'52','7168':'56','7680':'60','8192':'64'};spaces={'5':'1','10':'2','15':'3','20':'4','25':'5','30':'6','35':'7','40':'8','45':'9','50':'10','55':'11','60':'12','65':'13','70':'14','75':'15','80':'16','85':'17','90':'18','95':'19','100':'20'};setTimeout("$('#mainTooltip').fadeIn()",2000);setTimeout("$('#mainTooltip').fadeOut()",10000);colorQueue=0;showVPS=0;nwrapColor=[[0,'da4343'],[1,'a15cbe'],[2,'d352b3'],[3,'ffa200'],[4,'444']];vpsColor=[[0,'4375da'],[1,'f47900'],[2,'4fb327'],[3,'da435f']];for(i=0;i<nwrapColor.length;i++){setTimeout("getCols()",(i+1)*100);}
$('div.ind-links > a:first').addClass('on');$('div.mouseover').hover(function(){$(this).children('div.body').fadeIn('fast');},function(){$(this).children('div.body').fadeOut('fast');});$('div.ind-links > a').click(function(){$('.hperiod, .hperiodvps').fadeOut(50);$('div[id*=hperiod] span.fakeBack, div[id*=hperiodvps] span.fakeBack').removeAttr('style');if($(this).attr('name')=='vps'){$('#mainTooltip').fadeOut();if($('div#contentrotate').css('margin-left')=='0px'){$('div#contentrotate').animate({marginLeft:'-800px'},1000).animate({marginLeft:'-755px'},500);$('div.ind-links a').removeClass('on');$(this).addClass('on');if(showVPS==0){for(i=0;i<vpsColor.length;i++){setTimeout("getVPS()",((i+1)*50)+1000);}}}else{if($('div#contentrotate').css('margin-left')=='-755px'){$('div#contentrotate').animate({marginLeft:'-800px'},200).animate({marginLeft:'-755px'},400);}}}else{if($('div#contentrotate').css('margin-left')=='-755px'){$('div#contentrotate').animate({marginLeft:'45px'},1000).animate({marginLeft:'0'},500);$('div.ind-links a').removeClass('on');$(this).addClass('on');}else{if($('div#contentrotate').css('margin-left')=='0px'){$('div#contentrotate').animate({marginLeft:'45px'},200).animate({marginLeft:'0px'},400);}}}
return false;});countConf();});