// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(document).ready(function(){
  $('A[rel="external"]').click( function() {
    window.open( $(this).attr('href') );
    return false;
  });
  
$('.login-form a[rel=reqpassword]').click(function(){
    $('.login-form .reqpass').toggle();    
    return false;
  });
  
  //........................
  
	$('.cpanel :radio').click(function(){
		if($(this).val() == 1)
		{
			$('.cpa span').text("Linux OS: Centos 32/64 bit");
			$('.price p').text("$"+$(this).attr('priceVal'));
			$('.info p a').attr('href', $(this).attr('moreInfLnk'));
	  		$('.order p a').attr('href', $(this).attr('orderLnk'));
		}
		else if($(this).val() == 2)
		{
			$('.cpa span').text("12 LINUX OS (Ubuntu, Debian etc..)");
			$('.price p').text("$"+$(this).attr('priceVal'));
			$('.info p a').attr('href', $(this).attr('moreInfLnk'));
	  		$('.order p a').attr('href', $(this).attr('orderLnk'));
		}		
	});
  
  //........................
  
  slice_cost = 0
  $("#flasher").animate({"top": "+=50px"},"slow");
  $("#flasher").animate({opacity: 1.0}, 3000).animate({"top": "-=50px"},"slow");
  
  /* Slider on the signup and upgrade page */
  
	$('.slider-wrap #slider').addClass( "active");
	$('.slider-wrap #slider input').css("display","none");
	$('.slider-wrap #slider input').val(2);
	$('.slider-wrap #slider .ui-slider-handle').mousedown(function () { $(this).addClass("active");});
	$('.slider-wrap #slider .ui-slider-handle').mouseup(function () { $(this).removeClass("active");});
	$('.slider-wrap #slider.ui-slider-signup').slider({ min: 1, max: 6, startValue: 1, animate: true, slide:function(e,ui){
			var t = jQuery(this);
			var x = jQuery(t).slider( "value" );
			jQuery(t).find('input').val(x);
			for (var y = 0; y <= x; y++)
        {
           $(".slider-wrap #node-"+y).addClass("active");
        }
      for (var y = x+1; y <= 15; y++)
        {
           $(".slider-wrap #node-"+y).removeClass("active");
        }
      
	  /*
	  $('.cpu p').text((x/5)+"GHz");
      $('.ram p').text((x*256)+"MB");
      $('.storage p').text((x*10)+"GB");
      $('.price p').text("$"+(x*100));*/
	  
	 switch(x)
	 {
	  
	  case 1:
	  $('.gram p').text((512)+"MB");
      $('.bram p').text((1536)+"MB");
      $('.storage p').text((75)+"GB");
      $('.bwidth p').text("Unmetered");
	  $('.price p').text("$"+(29.99));
	  $('.info p a').attr('href', 'http://www.hostv.com/vps-server.shtml');
	  $('.order p a').attr('href', 'https://billing.cirtex.com/cart.php?gid=6&systemtemplate=hostv');
	  $('.cpa span').text("Linux OS: Centos 32/64 bit");	  	  
	  break;
	  
	  case 2:
	  $('.gram p').text((768)+"MB");
      $('.bram p').text((2048)+"MB");
      $('.storage p').text((150)+"GB");
      $('.bwidth p').text("Unmetered");
	  $('.price p').text("$"+(59.99));
	  $('.info p a').attr('href', 'http://www.hostv.com/vps-server.shtml');
	  $('.order p a').attr('href', 'https://billing.cirtex.com/cart.php?gid=6&systemtemplate=hostv');
	  $('.cpa span').text("Linux OS: Centos 32/64 bit");
	  break;
	  
	  case 3:
	  $('.gram p').text((1024)+"MB");
      $('.bram p').text((4096)+"MB");
      $('.storage p').text((300)+"GB");
      $('.bwidth p').text("Unmetered");
	  $('.price p').text("$"+(109.99));
	  $('.info p a').attr('href', 'http://www.hostv.com/vps-server.shtml');
	  $('.order p a').attr('href', 'https://billing.cirtex.com/cart.php?gid=6&systemtemplate=hostv');
	  $('.cpa span').text("Linux OS: Centos 32/64 bit");
	  break;
	  
	  case 4:
	  $('.gram p').text((2048)+"MB");
      $('.bram p').text((9216)+"MB");
      $('.storage p').text((375)+"GB");
      $('.bwidth p').text("Unmetered");
	  $('.price p').text("$"+(139.99));
	  $('.info p a').attr('href', 'http://hostv.com/hybrid.shtml');
	  $('.order p a').attr('href', 'https://billing.cirtex.com/cart.php?gid=8&systemtemplate=hostv');
	  $('.cpa span').text("Linux OS: Centos 32/64 bit");
	  break;
	  
	  case 5:
	  $('.gram p').text((4096)+"MB");
      $('.bram p').text((12288)+"MB");
      $('.storage p').text((500)+"GB");
      $('.bwidth p').text("Unmetered");
	  $('.price p').text("$"+(189.99));
	  $('.info p a').attr('href', 'http://hostv.com/hybrid.shtml');
	  $('.order p a').attr('href', 'https://billing.cirtex.com/cart.php?gid=8&systemtemplate=hostv');
	  $('.cpa span').text("Linux OS: Centos 32/64 bit");
	  break;
	  
	  case 6:
	  $('.gram p').text((8192)+"MB");
      $('.bram p').text((24576)+"MB");
      $('.storage p').text((750)+"GB");
      $('.bwidth p').text("Unmetered");
	  $('.price p').text("$"+(239.99));
	  $('.info p a').attr('href', 'http://hostv.com/hybrid.shtml');
	  $('.order p a').attr('href', 'https://billing.cirtex.com/cart.php?gid=8&systemtemplate=hostv');
	  $('.cpa span').text("Linux OS: Centos 32/64 bit");
	  break;
	  
	  }
	  
	  $.fn.cpText(x);
	  
  }} ); 

	$.fn.cpText = function(option) {
		$.fn.hideOthersCP('cp-'+option);
	}
	
	$.fn.hideOthersCP = function(ref){
		$('.cpanel').each(function(item){

			if($(this).attr('id') != ref) {				
				$(this).hide();					
			}
			else
			{
				$(this).show();
				$(this).find(":radio:nth-child(1)").attr("checked", "checked");
			}
		});
	}
	
});

