
var firstly_login = true;
var firstly_pass = true;

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ' ' + '$2');
	}
	return x1 + x2;
}

function gebi(id){
	return document.getElementById(id);
}


function waitblock_show(txt){
        if (txt == '') txt = 'Please wait...';
		$('#waitblock .waitblock_mainblock p').html(txt);
		$('#waitblock').fadeIn(300);
}
function waitblock_hide(){
		$('#waitblock').fadeOut(0);
}

$(function () {

  $('#registr_page #registr_new_client').click(function (event) {
    $('#registr_page #registr_login_block').fadeOut("fast",function(){
      $('#registr_page #registr_form_block').fadeIn(400);
	});
  });

  $('#registr_page #registr_current_client').click(function (event) {
    $('#registr_page #registr_form_block').fadeOut("fast",function(){
      $('#registr_page #registr_login_block').fadeIn(400);
	});
  });
  

  $('#billing_form').submit(function (event) {
		
        var pattern = /^[a-z0-9_-]+@[a-z0-9-]+\.([a-z]{1,6}\.)?[a-z]{2,6}$/i;
        
        if ($("input.email").val() == 'Login' || $("input.email").val() == ''){
            return false;
        } else {
            if ($("input.email").val().search(pattern) == 0){
                $(this).attr('action', 'https://bill.hostkey.com/dologin.php');
                $("input.email").attr('name', 'username');
            }
        }
        
  });

  
  $('#billing_form .email').click(function (event) {
		if(firstly_login){
            $(this).val("");
            firstly_login = false;
        }
  });

  
  $('#billing_form .pwd').click(function (event) {
		if(firstly_pass){
            $(this).val("");
            firstly_pass = false;
        }
  });

  
  $('.pleasewait').click(function (event) {
		waitblock_show('');
  });

  $('.pleasewait_payment').click(function (event) {
		waitblock_show('Please wait while you are redirected to the gateway you chose to make payment...');
  });

});
