jQuery(document).ready(function(){

jQuery(".niceCheck").mousedown(
/* при клике на чекбоксе меняем его вид и значение */
function() {

     changeCheck(jQuery(this));
     
});


jQuery(".niceCheck").each(
/* при загрузке страницы нужно проверить какое значение имеет чекбокс и в соответствии с ним выставить вид */
function() {
     
     changeCheckStart(jQuery(this));
     
});

                                        });

function changeCheck(el)
/* 
	функция смены вида и значения чекбокса
	el - span контейнер дял обычного чекбокса
	input - чекбокс
*/
{
     var el = el,
          input = el.find("input").eq(0);
   	 if(!input.attr("checked")) {
		el.css("background-position","0 -18px");	
		input.attr("checked", true)
		copyInputValues();
	} else {
		el.css("background-position","0 0");	
		input.attr("checked", false)
		clearInputValues();
	}
     return true;
}

function changeCheckStart(el)
/* 
	если установлен атрибут checked, меняем вид чекбокса
*/
{
var el = el,
		input = el.find("input").eq(0);
      if(input.attr("checked")) {
		el.css("background-position","0 -18px");	
		}
     return true;
}

function copyInputValues()
{
	for (var i = 0; i < 10; i++)
		$("#input"+(16+i)).val($("#input"+(6+i)).val());

        if(document.getElementById("shippingcountry")!=null)document.getElementById("billingcountry").selectedIndex = document.getElementById("shippingcountry").value;

}
function clearInputValues()
{
	$(".right_colum .pay_form_block input:lt(10)").val("");
}
