$(document).ready(function(){
$(".moroz").randombg({
    directory: "img/random/", 
    howmany: 3
});


	$("ul.phoneNav li").click(function(){
		var curChildIndex = $(this).prevAll().length + 1;
		$(this).parent().children('.selected').removeClass('selected');
		$(this).addClass('selected');		
		$(this).parent().next('.phoneTab').children('.selectedPhone').fadeOut(0,function(){
		$(this).removeClass('selectedPhone');
		$(this).parent().children('div:nth-child('+curChildIndex+')').fadeIn(0,function() {
		$(this).addClass('selectedPhone');});		
	});		
			return false;	});

 $('input:checkbox').click(function(){
            if (this.checked){
			$(this).parent().parent().addClass('selected');
			$(this).parent().parent().children('.hidden').removeClass('hidden');
			$(this).parent().parent().children('.col').children().children().children().children().children().addClass('validate[required,custom[onlyNumber]');	
			}
			else{
			$(this).parent().parent().removeClass('selected');
			$(this).parent().parent().children('.col').addClass('hidden');	
			$(this).parent().parent().children('.col').children().children().children().children().children().removeClass('validate[required,custom[onlyNumber]');	
			}
			
	         return true;
         });

	if ($('#order').length) {
		$.validationEngineLanguage.newLang();
		$('#order').validationEngine({promptPosition: 'topLeft', inlineValidation: false});
	}


			$("a.image").fancybox({
				'titleShow'		: false,
		 		'onComplete': function() {
			 $("#fancybox-outer").css({'height':'100%'});}
			});
			
			$("a[class=group]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titleShow'		: false,
	 		'onComplete': function() {
		 $("#fancybox-outer").css({'height':'100%'});}
			});
			
$("img.closebtn").click(function(){
	$.fancybox.close();
});



		$("a.fancy").fancybox({
		'overlayShow': true,
		'showCloseButton'	: false,
		'overlayOpacity': '0.5',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'margin': '-1',
		'titleShow': false,
		'scrollbar': false,
		'onComplete': function() {
 $("#fancybox-inner").css({'overflow-y':'hidden'});},
		'onStart': function() {
 $("input:checkbox:checked").removeAttr("checked");
 $("td.col").addClass("hidden");
 $("tr.selected").removeClass("selected");},
 		'onComplete': function() {
 $("#fancybox-outer").css({'height':'0'});},

		'onClosed': function() {
			$('div.formError').remove();
		}

	});
  });
